From thamelry at vub.ac.be Tue Jul 11 04:24:18 2000 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 11 Jul 2000 08:24:18 GMT Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: <8kelji$3i4$1@snic.vub.ac.be> David Goodger wrote: [knip] : But seriously (my comments above were in good fun, I assure you, no harm : intended), I read this newsgroup regularly and I never saw mention of the : Language Challenge 2000. Did I miss it? Perhaps the audience determined the : outcome? I remember the anouncement very well. Probably because I was laughing out loud when I saw that the prize was some Fortran compiler. : Ah, fond memories of my college Fortran course... Thank Guido for Python! Fortran is evil. It is just barely not bad enough to prevent scientist to use the more modern software tools. In other words, Fortran keeps scientists in a state of arrested development. Cheers, --- Thomas Hamelryck Institute of Molecular and Structural Biology Aarhus University Gustav Wieds Vej 10C DK-8000 Aarhus C Denmark http://zombie.imsb.au.dk/~tham From thomas.lambert at ndsatcom.de Fri Jul 14 04:28:45 2000 From: thomas.lambert at ndsatcom.de (Thomas Lambert) Date: Fri, 14 Jul 2000 10:28:45 +0200 Subject: running "PyRun_SimpleFile()" several times Message-ID: <396ECF3D.5432F3E@ndsatcom.de> Hello, I want to run "PyRun_SimpleFile()" several times in several threads at the same time. Under Linux using pthread. Now I have the problem that only one "PyRun_SimpleFile()" can run at the same time, else errors occur (segmentation faults, ...). My Question: can I call "PyRun_SimpleFile()" more than one time at the same time, e.g. in multiple threads? Is this function thread-save? Thank you very much! Thomas Lambert From swun at eSec.com.au.bbs Mon Jul 17 02:30:03 2000 From: swun at eSec.com.au.bbs (swun at eSec.com.au.bbs) Date: 17 Jul 2000 06:30:03 GMT Subject: example on how to use configparser in python? Message-ID: <3bR2VR$kaL@openbazaar.net> Does anyone have that? Thanks Sam. From donn at oz.net Sat Jul 22 11:54:05 2000 From: donn at oz.net (Donn Cave) Date: 22 Jul 2000 15:54:05 GMT Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: <8lcg2t$fbn$1@216.39.151.169> Quoth nobody : | cjc26 at nospam.cornell.edu (Cliff Crawford), in | : | > * nobody menulis: |>> now, this newbie has run into another perl idiom he'd like to figure |>> out how to rewrite in python - "while () { print; }" - and, by |>> extension, how to get python to print the string i hand it, the whole |>> string i hand it, and nothing but the string i hand it? | |> Hmm..not quite sure what you mean..maybe you want to use |> sys.stdout.write() instead? | | perhaps. unfortunately, i haven't had time to work on this since i made | that posting, so i have got no further; i expect there's some fairly easy ... He's right. Go ahead and get to work on your program, and use sys.stdout.write(). Read up on the file object in general, for more details. |> print doesn't really try to be clever with its arguments, except for |> printing a space between each one and a newline at the end. | | that's trying to be clever. then, if i'm reading raw lines from a file and | want to print them verbatim, i have to strip a newline somewhere somehow? | how do i copy a file to another one, is there a file.copy method in some | module somewhere? Not to my knowledge, but you don't need it. To read, I reckon you're probably using the file object read() or readline() functions. The file object write() function is the inverse operation and doesn't strip anything. (Well, note that on some platforms the underlying C library functions may tamper with the output and input data to get the CR/LF issues right, so open as binary if that's an issue.) The "print" statement is not for applications like this. The os module also exports the POSIX 1003.1 open(), read() and write() functions, which in a few exotic situations may be more practical than a file object. Donn Cave, donn at oz.net From aahz at netcom.com Mon Jul 3 00:27:02 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 04:27:02 GMT Subject: Threads? References: <8jlnkh$7h$1@supernews.com> <8jlvat$ohi$1@nntp9.atl.mindspring.net> <8job5d$6i$1@supernews.com> Message-ID: <8jp4mm$ks$1@nntp9.atl.mindspring.net> In article <8job5d$6i$1 at supernews.com>, Dale Strickland-Clark wrote: > >I want separate execution paths that run concurrently to (or appear to) >the main one but share the same code. > >The ability for the processes/threads to share memory and signal each >other would be a bonus. In that case, it'll be much simpler to use threads. Check out threading.Thread. The one problem with Python threads is that there is something called the "global interpreter lock". This means that only one thread can run Python code at any time, even on a multi-CPU machine. However, threads that call out to extensions (such as I/O) can run truly concurrently. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From ingoogni at CUT.THIS.OUT.home.nl Mon Jul 24 16:02:10 2000 From: ingoogni at CUT.THIS.OUT.home.nl (ingo) Date: Mon, 24 Jul 2000 20:02:10 GMT Subject: f.write(chr(10)) ? References: <8F7BD871Fseed7@212.120.66.201> <20000724201536.C4472@naxos.skunk.org> Message-ID: <8F7BE550Bseed7@212.120.66.201> Drew Csillag wrote: >Try instead: >f=open("testpy", 'wb') # note wb not wd > *blush* for some reason I've been consistently typing 'wd', I know it's 'wb'. I know, I know realy! Thanks Drew, Ingo (making a fool of himself again, mumblegrumble) -- Photography: http://members.home.nl/ingoogni/ Pov-Ray : http://members.home.nl/seed7/ From hzhu at localhost.localdomain Mon Jul 17 15:42:18 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 17 Jul 2000 19:42:18 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> Message-ID: On Mon, 17 Jul 2000 13:24:30 -0600, Bjorn Pettersen wrote: >> As to the claim that additional operators for linear algebra is somehow >> comparable to the special syntaxes/quirks of various programming languages, >> no real argument has been presented so far. It's more like: If I don't care >> and don't use such things, they must belong to a special domain and be >> somehow comparable to some other things that I do know and dislike. > >On the contrary. The argument is something like the following: > > - Python is a general purpose language, and as such it can't > support special case syntax for Matrix/cgi/xml/db programming. > (special syntax has previously been requested for both cgi and > db programming). I don't see what this tells me about Matrix being comparable to cgi/xml/db, especially on the level of syntax requirements. >If you really want to convince people, I would like to see examples of >how adding these operators would make working in other domains easier >(directly, not through translation through linear algebra). I'm not sure what this is asking for. My first impression is similar to "show me an example of how using C syntax would make working in assembly easier (directly, not by compiling a C program)". On second thought, maybe you are thinking about situations like: when doing web programming you want to add server statistics and put the graphics on the page? Of course it helps, but you have to translate the numbers into linear algebra. I don't think these arguments leading anywhere. Or maybe you want this? a = ["Alice", "Bob"] b = " is " c = ["a girl", "a boy"] d = a .+ b .+ c If the request had been: if you really want to convince people that string literals are worth having in the language, you need to give examples of it make working in other domains easier (directly, not through translating through strings), I would have exactly the same reaction. Strings are good for text. Even though you can use regular expression to calculate pi to any place you want, which is another domain, that's not the reason strings are the language. The morale of the arguement is: requiring every syntax to be useful in every domain is too extreme and not quite useful. But considering exactly what the domain is and exactly how it might be used may help. Huaiyu From weeks at golden.dtc.hp.com Fri Jul 28 11:20:22 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 28 Jul 2000 15:20:22 GMT Subject: "always passes by reference" References: <8lqd0p$snj$1@news.dtc.hp.com> <8lqiq3$7iha$1@nntp6.u.washington.edu> Message-ID: <8ls8bm$cde$1@news.dtc.hp.com> Donn Cave (donn at u.washington.edu) wrote: : Your account of the system doesn't work for me. : def f(x, t): : x = t : Where is the "the variable x"? Did f() just write a different object : into it? Well, in any practical sense, x does have a new value. The variable x is a block of memory on the execution stack (although that is more detail than a programmer needs to know), and the assignment "x = t" does indeed write a different object into it. However, call-by-value refers to what happens to a different variable: z = 0 f(z, 1) In the above code does a new object -- and remember, when I say "object" I mean an address -- get written into z on the second line? The answer is no. Regards, Greg PS to all: Once you distinguish between a word and a writing of a word, the remaining question is whether you prefer to define an "object" as 1) a region of memory or 2) an address. #2 may grate on your intuition, but otherwise it simplifies discussions of what is happening. You might say that I (and others!) simply use the term "object" when other people say "reference". That is almost true. But the people who like the term "reference" also say that there can be several references to a single object. This is confused. If an object is a region of memory, it has only one address. So if there are multiple references, then a "reference" is a *writing* of an address. I find it confusing to have an expression for a writing of a word but not for the word itself. From kulbrich at yahoo.com Fri Jul 28 19:29:52 2000 From: kulbrich at yahoo.com (Karl Ulbrich) Date: Fri, 28 Jul 2000 19:29:52 -0400 Subject: Perl is worse! In-Reply-To: ; from grey@despair.rpglink.com on Fri, Jul 28, 2000 at 09:59:01PM +0000 References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> Message-ID: <20000728192952.A32288@exeter.exeter.org> > A variable gets its type upon assignment. That is implicit typing. Variables do not have type. Data has types. If a variable later points to an object of a different type, then calculations using this variable have a different type to contend with. If variables became typed upon assignment, the following would fail: a = 1 a = "z" > >Huh? Where in Python did you find your declarations? I'm confused. > > a = None > int(a) > > a is declared as None at assignment. Not declared as. _Refers_ to None. > >Well, because it doesn't really make a lot of sense if you want to convert > >something to an integer when Python can't figure it out. If you're so > >sure of yourself, you can always do: > > > >try: > > a = int(b) > >except ValueError: > > a = 0 > > Right, which is basically what I had to do except I left None as None. > Just seems like a pain in the butt to do after I have allready made sure, > beyond all doubt, that those variables contain numbers in the first place. If they already contained numbers (well, strings of digits), and you were certain, then simply: a = int(b) > A regex could return a string or None, only one of which is convertable to > int. You must litter your code with such checks. If you do this a *lot*, maybe a little code around re to return digits as numbers, and None as 0, would be appropriate in that case? Karl Ulbrich From loewis at informatik.hu-berlin.de Sun Jul 9 06:05:16 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Jul 2000 12:05:16 +0200 Subject: extension module performance problems References: <115675da.97c91c5a@usw-ex0103-023.remarq.com> Message-ID: rwgk writes: > Can these observations be explained? Is there a way to > get full performance under all circumstances? I can guess about the causes. Threading in Python is done via a global mutex, which is help by exactly one Python thread at any time, so C code does not need to worry about multithreading. The lock is released when a blocking system call is made. So the performance of the threading library is critical to the performance of Python, at least under --enable-threads. The performance impact should be less if the thread module hasn't been imported - you may want to check if it is (looking at sys.modules). Creating shared libraries always gives a performance impact. To make the shared libraries position-independent (PIC), extra code must be generated for inter-library calls. Specifically, when you have a register pointing to the start of the library, that register needs to be reloaded every time you cross a shared-library boundary. On some systems (e.g. Alpha), you also take a performance hit if the library calls back into the executable, as each such call will go through a thunks layer. I don't know whether it explains all the performance loss, but it probably explains some of it. Regards, Martin From aboufer at atlsci.com Sat Jul 22 12:08:21 2000 From: aboufer at atlsci.com (ahmed Bouferguene) Date: Sat, 22 Jul 2000 12:08:21 -0400 Subject: Looping on more than one list Message-ID: <3979C6F4.B1FF1800@atlsci.com> Greetings all, Do no know much of python, but I am wondering whether it is possible to loop on more than one list, something like, a = [1,2,34] b=["a", "b", "d"] for x in a, y in b : print x, y and the loop exits when the shortest list is exhausted Thanks From cut_me_out at hotmail.com Sat Jul 29 17:27:06 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 Jul 2000 17:27:06 -0400 Subject: cStringIO & write error? References: <8F80A1458seed7@212.120.66.218> <8F80E5BE4seed7@212.120.66.218> Message-ID: > Thanks, but in my case it doesn't help me further Sorry, should have been more specific. What happens if you try this? from StringIO import StringIO f=open('file.dat', 'r+b') ff = StringIO() ff.write(f.read(-1)) ff.seek(0) ff.write(chr(123)) Alex. From montagne at boora.com Mon Jul 3 16:32:48 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 13:32:48 -0700 Subject: WinNT User Name References: <3960E2EB.A5B1B256@sec.noaa.gov> Message-ID: thanks to you both..I knew it was easy. -mjm From Armin at Steinhoff.de Sat Jul 8 07:56:45 2000 From: Armin at Steinhoff.de (Armin Steinhoff) Date: 8 Jul 2000 04:56:45 -0700 Subject: question for the gurus ->Setting a C-structure from Python References: <39649D5C.F1652171@seatech.fau.edu> Message-ID: <8k74tt$1evj@drn.newsguy.com> Hi all, please have a look to the inline comments. Regards Armin In article <39649D5C.F1652171 at seatech.fau.edu>, bdupire says... > >I already posted this message on www.deja.com but as it doesn't appear >in the newsgroup, I repost it here. > >My aim is to write an extension module to access functions in C which >"get" and "set" some structures from/in shared memory. > > In order to do this, I implemented the following programs: > * structure.py > * test_API.c > > It works well when I set the structure the first time, but not a second >time I have got the following (run-time) error... did I miss something? > > > >>> import structure > The structure is now: > name Benoit > age 22 > rate 3.141500 > > > Traceback (innermost last): > File "", line 1, in ? > File "structure.py", line 19, in ? > test_API.setstruct(packed) > TypeError: argument 1: expected string, > found At this point the interpreter is damaged ... stack, memory a.s.o. > > I am working with Python 1.5.2 on QNX 4.25 >test_API.c is therefore statically linked with Python as dynamic >linking is not possible on QNX. > > file : structure.py > ----------------------------------------- > import struct > import test_API > > #1st try > fmt="20sif" > a="Benoit" > b=22 > c=3.1415 > packed=struct.pack(fmt,a,b,c) > test_API.setstruct(packed) > > #2nd try > a="Ben" > b=23 > c=3.1417 > packed=struct.pack(fmt,a,b,c) > test_API.setstruct(packed) > > file: test_API.c > -------------------------------------- > #include > #include "Python.h" > > typedef struct{ > char name[20]; > int age; > float rate; > } examplestruct; > > examplestruct * example; > > static void print_struct() > { > printf("The structure is now: \n"); > printf("name %s\n",example->name); > printf("age %i\n",example->age); > printf("rate %f\n", example->rate); > } > static PyObject * test_setstruct(PyObject * self, PyObject * args) { > PyObject * string_from_python; > > if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; > > example= (examplestruct *) PyString_AsString(string_from_python); >Py_DECREF(string_from_python); > print_struct(); > > Py_INCREF(Py_None); > return Py_None; > } The following code works w/o any problems ... static PyObject * test_setstruct(PyObject * self, PyObject * args) { //PyObject * string_from_python; char * string_from_python; int len; // if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; if (!PyArg_ParseTuple(args,"s#",&string_from_python, &len)) return NULL; // example= (examplestruct *) PyString_AsString(string_from_python); example= (examplestruct *) string_from_python; // Py_DECREF(string_from_python); print_struct(); Py_INCREF(Py_None); return Py_None; } ... but why works the modified code and why the inital one NOT ?? Is it possible that a 'PyString object' can't include binary zeroes ?? > > > static PyObject * test_getstruct(PyObject * self, PyObject * args) { > /* if there are any arguments */ > if (!PyArg_NoArgs(args)) > return NULL; > return PyString_FromString(example); > } > > > /************************************************************* > METHOD REGISTRATION TABLE > List of functions defined in the module > *************************************************************/ > static struct PyMethodDef test_API_methods[] = { > {"setstruct", test_setstruct, 1}, > {"getstruct", test_getstruct, 1}, > {NULL, NULL} > }; > > /************************************************************* > Initialization function > *************************************************************/ > void inittest_API() > { > PyObject *m, *d; > > /*create the module and add the functions */ > m= Py_InitModule("test_API", test_API_methods); > > /* add symbolic constants to the module */ > d= PyModule_GetDict(m); > > if (PyErr_Occurred()) > Py_FatalError("can't initialize module test_API\n"); } > > > From jeremy at beopen.com Thu Jul 6 22:33:05 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 06 Jul 2000 22:33:05 EDT Subject: POOP / Python (Object Oriented Persistence) ? References: <8k2ieg$5mg$1@localhost.localdomain> Message-ID: fermigier at localhost.localdomain (fermigier) writes: > I've just read this announcement in Linux Weekly News today: > > ``The Poop on persistence (PerlNews). Perl News talks about two new > mailing lists for Perl Object Oriented Persistence (Poop). This is an > effort to encourage communication between module authors and to address > redundant object persistence issues. Also read about the latest Perl > modules.'' (Ref: http://news.perl.org/). > > Is there an opportunity to start such a discussion, or at least to gather > the solutions that have been developped for Python (and compare them to > their Perl/Java counterparts) ? The two Python solutions that come to mind are the pickle and cPickle modules, which just allow you to save and restore Python objects, and ZODB, a full-fledged object database from Digital Creations: http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html http://www.python.org/workshops/2000-01/proceedings/papers/fulton/fulton-zodb3.pdf If you are willing to compare these with Perl or Java approaches, I'd be interested to hear what you think. Jeremy -- Jeremy Hylton From vmoreno at germinus.com Mon Jul 10 02:52:26 2000 From: vmoreno at germinus.com (Victor M. Moreno) Date: Mon, 10 Jul 2000 08:52:26 +0200 Subject: PIL & PIDDLE Message-ID: <8kbrqu$qsa$1@talia.mad.ttd.net> Hello, I am using with success python and the piddle library. Now I need to insert an image in a ps documente generated by piddle, and so I decided to used the PIL libraray. When trying to use the PIL library, I get an error like: Erro: The _imaging C module is not installed. I have the _imaging.dll, I have place it in the path and where the python program executes, but no luck, How to install a dll module in python? Any ideas, thanks a lot Victor From bjorn at roguewave.com Fri Jul 14 20:10:27 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 18:10:27 -0600 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> Message-ID: <396FABF3.B82E0C2@roguewave.com> Huaiyu Zhu wrote: > > On Fri, 14 Jul 2000 11:38:51 -0600, Bjorn Pettersen > wrote: > > > >Well, this could actually be generally useful, but not with the .+ > >syntax (since the dot would interfer with methods on the sequence > >object). You're quoting me out of context here. What I could find generally useful is a way to spell component-wise operations... > My impression from the python-dev list is that this is not the case. Some > say it is easy to distinguish > > a. + b > a .+ b [snip] As you might have guessed, I don't really care what is done in the matrix case -- I don't use matrices. If a component-wise "operator" were to be added to Python however, I would expect it to work with e.g. list and in that case a dot is ambigous: mylist.foo() # are you calling the foo method on the list or the elements? I have a feeling that what you really want these operators to do is paralell component-wise operations on more than one collection object though, which is exactly what list comprehensions do (in a general way). -- bjorn From hei at adtranzsig.de Fri Jul 21 05:07:56 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Fri, 21 Jul 2000 11:07:56 +0200 Subject: zip() : how about braid() References: <397746c9.39446991@news.iol.ie> Message-ID: <8l941q$3bg$1@desig-bs01-s04.adtranzsig.de> I didn't follow all the suggestions, but did someone suggest align() ? (Hope my spelling is correct) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From grey at despair.rpglink.com Sun Jul 30 20:53:15 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 00:53:15 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <3982F04D.74FCF41C@webamused.com> <39834B9F.C6877761@webamused.com> <8m1evr32n4o@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 15:17:40 +0200, Alex Martelli wrote: >So Joshua has it exactly right: you find it *offensive* that people >consider 'automagic' (wild-ass-guessing by the system, based on >insufficient or ambiguous context) a technically inferior approach >to do-what-I-tell-you-DON'T-silently-second-guess-me?! And you >think that if people express this technical judgment, this justifies >your being rude about them?! No, I don't mind them finding it an inferior approach, I mind them using the term as a term of spite for a language. If I minded their opinions that would be wrong. >would appear that a courteous apology is in order. To those that didn't use it in a spiteful manner, yes, I do apologize. It was wrong of me to make a broad generalization like that. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From jkraska1 at san.rr.com Tue Jul 25 01:43:48 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 25 Jul 2000 05:43:48 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> <3L%e5.9930$r4.5151@news.indigo.ie> <397D1F01.214C4F52@my.signature> Message-ID: <397D29B0.95CCDD35@san.rr.com> > > Even 10 iterations would be only 5 minutes. A bug that took that many > > iterations to kill would require much more than 5 minutes thought. > > You're completely missing the point. It's not the number > of iterations required to *fix* the bug, it's the number > of iterations required to *find* the bug. > > The ability to watch your program execute is an extremely > powerful way to track down the causes of bugs. Boy oh boy do I agree with this! I'm currently a Lisp developer, and the ability to get into the interpreter and probe the program I'm working on with arbitrarily complex expressions in Lisp is essential to discovering sometimes very hard to find problems. The program I'm working on is a sophisticated command and control simulation with many different kinds of entities that go through very complex state changes. Without the ability to probe, I'd be sunk. This is not a case of crashes, exceptions, or obvious errors; this is a case of subtle misbehavior of model entities which often must be carefully probed for small idiosyncracies... C/ From mwh21 at cam.ac.uk Fri Jul 21 02:48:06 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Jul 2000 07:48:06 +0100 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <3977C029.2C1DC8AC@my.signature> Message-ID: Greg Ewing writes: > Michael Hudson wrote: > > > > > an elementwise tuple-creation operator > > > > You're joking, right? > > About that particular syntax, yes. But not about > the idea of some sort of zipping syntax. > > For one thing, it would make it easier to implement > parallel iteration efficiently. When I write > > for x,y in zip(a,b): > > I'm just trying to express the way the iteration is > to be carried out. I don't really mean that I want the > zip of the two lists to be computed first and then > iterated over. > > If there were a special syntax for zipping, the > compiler could easily recognise this case and > optimise it. Mmm. I *think* (and it's only thinking) that concerns for efficiency here are a little misplaced; I mean for i in range(len(l)): print i, l[i] is hardly efficient either, but I'd still wager that execution time for the loop body thoroughly dominates the overhead of the list construction (you have to take trips around the interpreter loop in ceval.c for one thing). > I haven't thought of a syntax for it that I really > like, yet, though. Yeah, and as you said in another post, the n-ary nature of the operation is going to make that tricky. Cheers, M. -- If you don't use emacs, you're a pathetic, mewling, masochistic weakling and I can't be bothered to convert you. -- Ron Echeverri From hzhu at localhost.localdomain Mon Jul 17 22:54:21 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 02:54:21 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> <8F74C4E37gmcmhypernetcom@199.171.54.155> <8l0dqm$lji$1@eeyore.INS.CWRU.Edu> Message-ID: On 18 Jul 2000 02:01:58 GMT, Kevin Jacobs wrote: >What if it could be as simple as: > >e(r'(A .* B)\C') # --> PyAlgebra.evaluate(r'(A .* B)\C', globals(), locals()) >where A, B and C are bound to variables in the current namespace >automatically? Does this not go 95% of the way toward the ideal solution? Well, not that much. What about this: webpage = webobject(url) result = e(r'transform * get_data_from(webpage)') If it is allowed wouldn't we allow result = e(r'transform * get_data_from(webobject(url))') or even using "http:..." in place of url? Eventually, wouldn't the e(r'...') be able to parse the whole python grammer? If on the other hand it is limited to numerical type objects only it is too limited. In MatPy.gplot we use lists, dicts and strings to deal with multiline plots and titles, etc. Well, maybe I just don't like to treat numerical type objects any differently from other objects because they are intermixed all over in the programs. Otherwise a python-octave gateway or just stick with octave may even be preferable. One of my biggest gripe about matlab is it forces me to treat strings as part of matrix. Now you are asking me to treat matrix as part of string. :-) >I disagree with your conclusion. Having worked with many algebra and >statistical languages, I know the road you are undertaking. It doesn't and >can't stop with one extra dot in the grammar. To do it right, you need the >ability to break more rules that are intrinsic to Python's core. e.g., >consider changing the rules for '\' as above. This makes some sense, but I know a lot of people who can resist the temptation of other syntactic sugar, except infix operator for arithmetics - it's just too good a thing to miss. There are proposals for using @/ and /@ for two directions of division, or using % for left division. I'm comfortable with the current solve(a,b), or maybe a shorter sol(a,b) but am open to any suggestions. >Another advantage to compromising and implementing a domain specific >mini-language is that it simplifies some very tough design issues that only >come up when working with the full Python grammar. Some of these syntactic >and semantic issues are very likely irreconcilable. In the end we could end >up with a any number of splinter languages with inferior support and narrow >audiences. Lets not forget we are a community of users with very diverse >goals, all trying make our lives easier by building better tools. I'm not quite with you here. Exactly for the purpose of making numerical objects and other objects work seemlessly together I am against changing syntactic structure, and only for adding syntactic contents within current structure. Well, let's see if this makes sense. What I'm saying is, .* is just another operator, so if you replace it with * the syntax structure does not change. On the other hand, using e(r'...') changes the structure because variable names within a string suddenly gets out. In this sense it is less like a function call with a string literal argument, but rather a special syntax zone delimited with strange combination symbols e(r' and '). If a program is littered with such special zones the effect is very much like an aspect of Perl that I happen to dislike. Just my thoughts. Huaiyu From thomas at cintra.no Fri Jul 7 09:20:25 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 07 Jul 2000 13:20:25 GMT Subject: What about try:except:finally Message-ID: <3967d908.363887342@news.online.no> Hi, Does python support, or if not, would it be cool to have support for : try: # some code except : # catch exception finally: # clean up whatever Thomas From m.faassen at vet.uu.nl Sat Jul 29 11:23:42 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 15:23:42 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <39824324.480835B6@nycap.rr.com> Message-ID: <8lustu$ags$1@newshost.accu.uu.nl> gbp wrote: >> >> Hmm. You seem to expect that strings and other >> things will be automatically coerced to integers whenever a function >> expects an integer. I think that's pretty scary; when I pass in the wrong >> thing to a function I *want* it to complain, as it's very likely I did it >> by accident. I don't want things to work by accident. Perhaps you're >> missing that this 'problem' is also a 'feature'; you get less 'weird' >> bugs due to the fact that your program keeps running long after your >> data got coerce-mangled to death. Python would tend to throw exceptions >> as soon as it went wrong. > I think it depends what you are doing with your program. I use Perl (and now > Python) to parse text files before putting the info in or sending it out of a > databse. This is by no means bug free software (deadlines just don't permit enough > testing). If someone sticks a letter in my input file where a number should go I > would rather my script deal with it than crash. > After all its not _my_ fault theres > a letter there. However, managment will blame me for a 'bug' if the > program throws > an exception when someone else runs it. Right, but even in that case I'd seen handling of such things explicit in the code, instead of just hoping nothing nasty will happen. You can catch this type of thing with try..except and just script the broken line or record or whatever your input may be. The alternative can be pretty devastating; imagine you have this file with a number in each row, and your script multiplies them all. If the system just treats a string (that doesn't contain an integer) as a zero, the answer will suddenly be zero. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul at prescod.net Sat Jul 15 06:26:52 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 15 Jul 2000 05:26:52 -0500 Subject: Docs for __init__.py? References: Message-ID: <39703C6C.3BEB3450@prescod.net> Matthew Cline wrote: > ... > > Specifically, does the package name have to corespond to the > name of the directory that __init__.py is in? Or is there > some way for __init__.py to say "No, *this* is the name for the > package?" No, Python doesn't read the __init__.py until after it has found the package using the traditional lookup mechanisms. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From mfein at aplcomm.jhuapl.edu Thu Jul 13 08:33:49 2000 From: mfein at aplcomm.jhuapl.edu (Matt Feinstein) Date: Thu, 13 Jul 2000 12:33:49 GMT Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: <396daf35.3870545@aplnews> On Wed, 12 Jul 2000 19:32:32 GMT, hzhu at knowledgetrack.com (Huaiyu Zhu) wrote: > >We are at a crucial juncture concerning introduction of new operators into >Python for matrix computation, > >1. Experiences with Matlab show that different operators for matrix and > elementwise operators are very important > >2. It is difficult to add .* and ./ as . is already a valid token. It seems > that next candidate on the standard keyboard is @. > >3. Gregory Lielens has just implemented a patch that could parse additional > operators containing @ > > a at b is equivalent to a*b, overloaded using __mmul__ and __rmmul__ > a@/b a/b __mrdiv__ and __rmrdiv__ > a/@b b/a __mldiv__ and __rmldiv__ > a@@b a**b __mpow__ and __rmpow__ > > He indicates similar constructions can be added easily. > > >We intend to add these operators together with Thomas Wouters's augmented >assignment operators (+=,*=, etc) to MatPy, but before that several >decisions need to be made. First, the main choices: > > >1. Use a*b as matrix mul, and a@*b as elementwise mul. >Pros: >- Consistent with Matlab. >- Consistent with current MatPy. >- Convenient for matrix computations. >Cons: >- Inconsistent with NumPy >- How to differentiate left and right div (matlab a\b and a/b)? > > >2. Use a@*b as matrix mul, and a*b as elementwise mul. >Pros: >- Consistent with NumPy >- Can use a@/b and a/@b as matlab a/b and a\b. >- Can use a at b as inner product so that a at b works irrespective of whether a > and b are row or col operators. >Cons: >- Inconsistent with current MatPy. Need great effort to switch. >- Using two symbol operator for matrix mul is cumbersome for long formulas. >- It kind of looks ugly. > > >3. Use a at b as matrix mul, and a*b as elementwise mul. This has most of the >pros and cons of choice 2, except >Pros: >- Single symbol operators for matrix mul and element mul. >Cons: >- Can't use a at b as inner product. > My own preference would be 'as consistent as possible with MATLAB, with some caveats'-- this would mean option 1, with some thought about changes in places where the current MATLAB syntax drops the ball (IMO). I don't think MATLAB's inelegances should be preserved for the sake of consistency. On the other hand, I think it's very important to make the translation from MATLAB language to Python as automatic as possible. The main thing I'd think about in addition to standard MATLAB syntax is a natural 'prolongation' syntax. In other words, contexts in which the vector [1 2 3] is naturally expanded to [1 2 3;1 2 3;1 2 3;...]. This operation is part of one of the basic strategies in vectorization-- prolongation, followed by some vectorized operation, followed in turn by selection or contraction. Presently, MATLAB can do this, but only in an idomatic and peculiar way. There are some dangers in this route-- it encourages a tendency to syntactical trickiness-- the history of the APL language provides a case in point and a warning. One thing that MATLAB does correctly (again, IMO) is its relatively relaxed attitude towards distinctions among scalars, 1x1 vectors & matrices as well as among different kinds of nulls and NAN's. You can test for these distinctions if you want to, but generally MATLAB will just quietly do the right thing. There's a tendency to get wrapped up in fine distinctions in cases where there's really no ambiguity about what the programmer wants to do. -- Matt Feinstein mfein at aplcomm.jhuapl.edu Organizational Department of Repeated and Unnecessary Redundancy From alex at magenta.com Sat Jul 29 08:11:14 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 14:11:14 +0200 Subject: Python is Zen (was Python is wierd) References: <39806045.F67EBD04@wag.caltech.edu> <8lt0ap$69q$2@newsg4.svr.pol.co.uk> Message-ID: <8luhsr61ce8@news2.newsguy.com> "Bill de h?ra" wrote in message news:8lt0ap$69q$2 at newsg4.svr.pol.co.uk... > Does this imply a "Thinking in Python"? "Thinking in Python" is among Bruce Eckel's future plans, and you can read about it on his site, but he doesn't seem to have made much progress on deciding what should be in that book (pity, since he's such an excellent writer). Let's hope Python 2.0 decides him to go ahead and that he does not get distracted by a "Thinking in C#" along the way (though that should be a modest-enough editing of "Thinking in Java" as not to take up too much of his time, while being surely lucrative:-). Alex From alex at magenta.com Mon Jul 3 05:16:29 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:16:29 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr><8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> Message-ID: <8jplru0lfe@news2.newsguy.com> Steven D. Arnold wrote in message news:4.3.1.2.20000630145109.0201d9e0 at phear.dementian.com... > At 02:15 PM 6/30/2000 +0200, Jerome Quelin wrote: > > >Then, is it better/cleaner to access private members with accessors or not? > >Is it a matter of style? Or are there hidden caveheats using (or not using) > >accessors? It _seems_ cleaner to use accessors, but man, it's quite awkward. > > If you always use accessors, then you can store or derive the value in any > way you wish internally in your class. You may completely change the way > the value is obtained, and the class user doesn't need to change anything These are excellent arguments for always using accessors from OUTSIDE the class. Jerome, however, was talking about using them from INSIDE the class as well, which is a different issue. Alex From tim.hochberg at ieee.org Wed Jul 26 16:42:15 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 26 Jul 2000 20:42:15 GMT Subject: Please help... with re References: <397F5947.EBDA7F33@e-pack.net> Message-ID: Gilles Lenfant writes: > I made an horrid 68 lines monster to split a string to a list of > substrings based on following example: > > This is an "example of a \"splitted\" text " by my monster. > > results to this list: > > [ 'This' , 'is' , 'an' , 'example of a "splitted" text ' , 'by' , 'my' , > 'monster' ] > > But the stuff is too slow to parse the lines of giant log files. > I would like to use "re" package to make a shorter and faster script but > understanding its patterns/methods is not in my poor brain capabilities. > > I have burned my last neurons to try to do it, and I'm close to the edge > of a nervous breakdown. > Who can help me to get it at work ? In general, I think you're better off breaking this into a number of shorter, simpler operations. It'll probably be faster and will almost certainly be easier to read. Consider the attached function, minimonster, it parses your example correctly and can do 10,000 repitions of it in about 2.5 s on a slowish (300 MHz machine.) I haven't seen you're monster example, but I would suspect that this is faster and easier to read. This may not be exactly what you want (it assumes no embebedded nulls for example), but maybe it'll get you started. N=10000 sampletext = r'This is an "example of a \"splitted\" text " by my monster. '*N import string, re quote = re.compile(r'[^\\]"') def minimonster(text): # Replace ", but not \" with \0 so we can split on \0 # (ASSUMES NO EMBEDDED NULLS) newtext = quote.sub('\0', text) # Now replace \" with " newtext = string.replace(newtext, r'\"', '"') # now split on nulls textlist = string.split(newtext, '\0') # Now split on even sections only (odd sections are quoted). result = [] isEven = 1 for item in textlist: if isEven: result.extend(string.split(item)) else: result.append(item) isEven = not isEven return result import time t0 = time.clock() answer = minimonster(sampletext) print time.clock() - t0 print answer[:50] From gmcm at hypernet.com Sat Jul 15 13:58:40 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 Jul 2000 17:58:40 GMT Subject: Memory leaks References: <395F78BF.CBEAA090@synacon.ch> <8F6667253gmcmhypernetcom@199.171.54.154> <8klffg$ql5$1@nnrp2.deja.com> Message-ID: <8F7281699gmcmhypernetcom@199.171.54.194> ioadler at my-deja.com wrote in <8klffg$ql5$1 at nnrp2.deja.com>: >In article <8F6667253gmcmhypernetcom at 199.171.54.154>, > gmcm at hypernet.com (Gordon McMillan) wrote: >> Ingo Adler wrote: >> >> [strange leaks in SWIG'd code] [snip] >> Doing things in the "obvious" way from your (snipped) incomplete code, >> I get no leak when using MSVC 5. >Finally, I reproduced the leaks under the control of "Code Guard", which >can list them. [snip trace and code snippets] Not only did my experiment not leak, but I can't match up your SWIG snippets with anything in my SWIG generated code. I'm running SWIG1.1p5 (as of a few weeks ago, the latest stable release). So maybe you're running a buggy SWIG. Or maybe I could ship you what I tried, and you can look for differences. I can't debug from your description (nor have I the time to do so), but I can assure you that what you're trying to do doesn't have to leak. - Gordon From niels at endea.demon.nl Fri Jul 21 12:51:11 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Fri, 21 Jul 2000 18:51:11 +0200 Subject: dynamic bases References: <20000721171635.B1431@balabit.hu> Message-ID: <39787F7F.FCBA2490@endea.demon.nl> Balazs Scheidler schreef: > My other attempt was to use __getattr__ hooks to return attributes in a way > that attributes of A are returned in case __dict__ of B doesn't contain a > given name. Functions were bound to the instance of B, then the Python > interpreter complained that self is not a subclass of B. If you want to do it as cleanly as possible, you can use something like this: class DynaMethod: def __init__(self, instance, function): self.instance = instance self.function = function def __call__(self, *args, **kwargs): apply(self.function, (self.instance,) + args, kwargs) if __name__ == '__main__': # test code def method_a(self): print 'Doing a now on object %s' % id(self) def method_b(self, arg1): print 'Doing b with argument %s' % repr(arg1) class A: def __init__(self): self.method_a = DynaMethod(self, method_a) self.method_b = DynaMethod(self, method_b) a = A() print 'Created instance %s' % id(a) dir(a) a.method_a() a.method_b('test') This does take some extra memory and time though. A more efficient, but probably implementation-dependent way would be to use new.instancemethod(). -- Niels Diepeveen Endea automatisering From wware at world.std.com Tue Jul 25 08:55:18 2000 From: wware at world.std.com (Will Ware) Date: Tue, 25 Jul 2000 12:55:18 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> <3L%e5.9930$r4.5151@news.indigo.ie> <397D1F01.214C4F52@my.signature> <397D29B0.95CCDD35@san.rr.com> Message-ID: Courageous (jkraska1 at san.rr.com) wrote: > I'm currently a Lisp developer, > and the ability to get into the interpreter and probe the > program I'm working on with arbitrarily complex expressions > in Lisp is essential to discovering sometimes very hard to find > problems. Back in my early days as a hardware engineer, I had exactly this complaint about the available logic analyzers (a kind of multi-track oscilloscope for watching the bits on many wires simultaneously), that the available triggers weren't flexible enough to catch the events I was looking for. I ended up developing a knack for whipping up small logic circuits to generate trigger signals based on things happening on three or four wires. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From dworkin at ccs.neu.edu Sun Jul 9 18:33:12 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 09 Jul 2000 18:33:12 -0400 Subject: Splitting c.l.py... In-Reply-To: Bjorn Pettersen's message of "Fri, 07 Jul 2000 12:13:53 -0600" References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> Message-ID: Bjorn Pettersen writes: > So is this a good time to re-open the discussion on splitting the > newsgroup/mailing list? Why? For a split to be worthwhile, there have to be obvious major categories to break the original group into which are hopefully not very overlapping. What subgroups do you propose splitting it into that wouldn't just result in having a lot of the traffic crossposted to multiple groups? While this newsgroup/list is fairly high traffic, I really don't see any way to split it that makes sense. -Justin From johann at physics.berkeley.edu Mon Jul 17 23:26:51 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 17 Jul 2000 20:26:51 -0700 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> <39736688.E19DD546@eecis.udel.edu> Message-ID: Charles Boncelet writes: >> - that many problems can be reduced to matrix operations is >> a non-argument, since the same is true of functional/ >> procedural/oo/predicate programming. > I agree, but there is a big userbase waiting for an alternative > to the $$ Matlab. Octave is already there as a free alternative, so I doubt python will attract many of those people. Personally, I find that the matrix-orientation of Matlab makes it harder to get things done. I more often have 3 or higher dimensional arrays than I have plain old 2D matrices, so I'd rather see the more general Numeric Python syntax than any over-specialized matrix code. When you're contracting a 4-tensor with a vector, you almost need an index-based notation. As it is, the only things missing from NumPy is an easy spelling of matrix-matrix multiplication, and if you really need that, you can just define your own class to do it. -- Johann Hibschman johann at physics.berkeley.edu From brown.2053 at osu.NOSPAM.edu Thu Jul 20 13:32:22 2000 From: brown.2053 at osu.NOSPAM.edu (Locke) Date: Thu, 20 Jul 2000 13:32:22 -0400 Subject: example Tkinter code? Message-ID: <8l7cvb$c61$1@mcnet.marietta.edu> does anyone know where i can find some example python/tkinter code? i am trying to learn, but i think some examples of how to use all those widgets would be useful. also, how can i change the text on a label? when i use the variabletext=whatever thing, the label wont show up. Thanks! From robin at jessikat.fsnet.co.uk Thu Jul 20 16:22:02 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 21:22:02 +0100 Subject: zip() : how about braid() References: <397746c9.39446991@news.iol.ie> Message-ID: In article <397746c9.39446991 at news.iol.ie>, Sean Mc Grath writes >>I think merge makes sense, >>(and I don't really have a problem with zip()), but the metaphor that >>most closely resembles what it does is braid(), as in hair.. >> >Two suggestions: > 1) raff > 2) twingle > >"raff" is an invented verb form of "raffia", fibers of which are used >to weave hats, baskets etc. (Spot the Monty Python >connection?) > >"twingle" just sounds beautiful... ... this thread is getting silly :) soon someone will mention Hitler :( -- Robin Becker From rob at hooft.net Wed Jul 19 03:02:37 2000 From: rob at hooft.net (Rob Hooft) Date: 19 Jul 2000 09:02:37 +0200 Subject: Toplevel "test()" functions in standard library Message-ID: In the standard library there is about 20 modules with the construction: ------------------------------------------ [module definitions] def test(): [testing code or general main program] if __name__=="__main__": test() ------------------------------------------ Wouldn't it be better to move the test() definition inside the if statement in these cases, to prevent name space pollution? Note that the routines are not called "_test()", so they will be imported by a "from ... import *" (There are other modules with a _test() definition as well). Even worse: the test() routine might have severe side effects: e.g. base64.test() will block waiting for data from stdin... Going one step further: Should all of these "test()" and "_test()" routines be in the code library at all, even now that we have a complete test engine? I will submit an example to the SourceForge patch manager. Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From warren at sunesis-pharma.com Fri Jul 7 13:02:29 2000 From: warren at sunesis-pharma.com (Warren L. DeLano) Date: Fri, 07 Jul 2000 10:02:29 -0700 Subject: Namespace Mystery (HELP!) References: <39655351.9EE499F2@sunesis-pharma.com> <39656345.86AADA8A@prescod.net> Message-ID: <39660D24.63BE61D3@sunesis-pharma.com> Thanks to Paul Prescod for his concise answer. Unfortunately that important information was omitted from the otherwise excellent "Python: Essential Reference". However, the crux of my question really relates to the behavior of the "exec" statement, and the fact that, with respect to local variables... exec IS NOT EQUIVALENT TO exec in globals() # A or exec in globals(),locals() # B Okay, we now know why B doesn't work, but why is it that A doesn't work as well? I have small code fragments generated at runtime (from a command-line interpreter) that I would like to execute within the local namespace of a function, but which also have access to a separate global namespace (my own namespace - not the global namespace). I don't want to touch the global namespace of the module (not thread safe). Thus I want to pass in: # illustrative example def fn(code,my_globals): a = 1 b = 1 exec "b=2" in my_globals return a+b Assume that code contains references to variables in functions in the my_globals dictionary, and that it alters the a and b variables. The above code won't work, because changes won't be preserved, even though I haven't even provided locals to exec! There is a workaround: def fn(code): a = 1 b = 1 my_locals = locals() exec code in my_globals,my_locals return my_locals['a']+my_locals['b'] which is clearly awkward if you need to do anything more complex with a and b... Warren Dag Sunde wrote: > Warren, > > Aside from your question about the locals() and Pauls > excellent answer, is there any particular reason > you're not writing something like: > > >>> def fnx(): > ... b = 1 > ... global a > ... a = 2 > ... b = 2 > ... print a, b > > Dag. > > "Paul Prescod" wrote in message > news:39656345.86AADA8A at prescod.net... > > > Why is the output "2 1" and not "2 2"? > > > What is it about the locals() function that makes it behave > > > unexpectedly? > > > > locals () > > Return a dictionary representing the current local symbol table. > > Warning: the contents of this dictionary should not be modified; > changes > > may not affect the values of local variables used by the interpreter. > > > > http://www.python.org/doc/lib/built-in-funcs.html > > > > Python doesn't typically look up local variables based on a string > name > > at runtime. That would be too inefficient. Rather it looks them up > > positionally. > > > > -- > > Paul Prescod - Not encumbered by corporate consensus > > Pop stars come and pop stars go, but amid all this change there is one > > eternal truth: Whenever Bob Dylan writes a song about a guy, the guy > is > > guilty as sin. > > - http://www.nj.com/page1/ledger/e2efc7.html > > -- mailto:warren at sunesis-pharma.com Warren L. DeLano, Ph.D. Informatics Scientist Sunesis Pharmaceuticals, Inc. 3696 Haven Ave., Suite C Redwood City, CA 94063 (650)-556-8800 fax: (650)-556-8824 From moron at Glue.umd.edu Fri Jul 21 20:29:35 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 21 Jul 2000 20:29:35 -0400 Subject: Discussion: new operators for numerical computation References: <8l8dmd$4p0@stochastic.eng.umd.edu> Message-ID: <8laptf$4mo@stochastic.eng.umd.edu> >>The old code might not even have to coexist, the new package could >>provide compatibility modules: > >Interesting. Details? I'll admit I had not thought hard about this before posting - that's why I said "might". In the current implementation of NumPy, in which arrays are a type rather than a class, and thus cannot be subclassed nor have their methods reassigned, it probably wouldn't work like I implied. But we aren't discussing the current implementation. So we could have a common base type which included all of the operations, then ------- Numeric.py ---------- class array: from array_base import * __mul__ = mul_elementwise __add__ = add_broadcasting #or maybe __add__ = lambda self, other, dest: add(self, other, dest, broadcast=1) #and so on. ------------------------------ Not sure whether the rumored future type/class healing would make this simpler. And while we're pondering reimplementaions, it might be cool to move as much non-performance-critical code as feasible up into a Python layer to ease synchronization between [C/J/IL?/???]Numeric. The top layer would be shared, and only the core would be in whichever low-level language. Then again, maybe I'm biting off more than my brain can chew on a Friday afternoon. WBF -- If you feel that you have both feet planted on level ground, then the university has failed you. -Robert Goheen, President, Princeton University From loewis at informatik.hu-berlin.de Mon Jul 10 13:20:33 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Mon, 10 Jul 2000 19:20:33 +0200 (MET DST) Subject: [Python-Help] imp.load_module from a string In-Reply-To: <3969DACB.D6C15CEF@nipltd.com> (message from Chris Withers on Mon, 10 Jul 2000 15:16:43 +0100) References: <39672E50.B83A4C81@nipltd.com> <200007081846.UAA04878@pandora.informatik.hu-berlin.de> <3969AC50.98F36FF4@nipltd.com> <200007101103.NAA14484@pandora.informatik.hu-berlin.de> <3969DACB.D6C15CEF@nipltd.com> Message-ID: <200007101720.TAA05354@pandora.informatik.hu-berlin.de> > Hmmm, some of these classes are being used to unpickle objects sent from > the server. I guess I just have to make sure the right version of the > module is in sys.modules when I unpickle the object? Exactly. pickle sends klasse.__name__ and klasse.__module__; unpickle expects to find those in sys.module, or imports the module if not found. As a result, you can't pickle nested classes, either. Regards, Martin From alex at magenta.com Fri Jul 28 10:54:41 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 16:54:41 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8ls73c01d3r@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o1vc0.vnr.grey at teleute.rpglink.com... [snip] > Like I said, every language has its quirks. Every language. Just because > this is your favorite doesn't mean it doesn't have quirks, just means you are > used to them. Just as a perl programmer I am used to perl's quirks and take > advantage of them and, yes, sometimes get caught by them as well. Just as I I have 8 years' experience with Perl, and less than a year with Python. After a *MONTH* of Python, I was far happier and more productive with it than I've ever been throughout those long, drab years of Perl (actually, I was deliriously happy already well before the month was over, but, realistically, it did take a few weeks before I started feeling _mastery_ of the language's mechanics -- I was, after all, studying it "very part-time"!). So, it most emphatically DOESN'T "just mean I am used" to the quirks of one language and not to those of another; there IS a huge difference in the quirk-sets involved. Which doesn't have to mean one of them is empty, of course. "Every sea has some water" doesn't have to mean Aral is remotely comparable to the Pacific Ocean, even as long as the former still has some drops in it; "every man has some money" doesn't mean my finances are comparable with Bill Gates'. > am in the process of learning Python (rapidly, I might add) and have, and > will, be caught by its quirks and will also learn to take advantage of them. > > But please, if you're going to toss rocks out your glass house, at least > be realistic about it, ok? At least then your neighbors are more apt to help > you sweep up the resulting mess. Realism and pragmatism are fine qualities. But they STILL don't make Aral and the Pacific directly comparable. > And just for fun, here's a good quirk for you. > > None = 1 > a = None > >>> if a: > ... print "foo\n" > ... > foo > > >>> a > 1 > > I think that is kinda neat, don't you? I don't understand why it would be a 'quirk', or 'neat', that identifiers bound in the current (global) namespace hide homonyms bound in the builtin namespace. (Similarly, those in the local namespace hide those in the global one). I've been using lexically scoped languages for over a quarter century, and it seems quite sensible and reasonable to me; having just three active namespaces rather than an unbounded amount, which is Python's peculiarity wrt other languages in this regard, plays no role in this which you claim to be a 'quirk'. Would you expect identifiers bound in a wider namespace to somehow 'lock-out' or 'pre-empt' narrower-namespace rebinding, a la Java? I did not find this Java feature at all helpful when I used Java (nor particularly damaging, either). > {grey at teleute:~} perl > null = "foo"; > Can't modify constant item in scalar assignment at - line 1, near ""foo";" > > I just don't understand how people can advocate for types and the > restrictions they impose while, on the other hand, embracing a language that > is free enough to shoot yourself in the foot by reassigning None. Naming and typing are orthogonal issues and Python keeps them carefully separated (a very strong point in its favour). The Perl idea of keeping unlimited 'barewords' available for infinite future addition of keywords is part of what forces all of those yecchy '$'. Python has chosen to define its set of keywords (reserved words) very carefully and narrowly, once and for all, limiting keywords to those which bear a needed syntactic load (following in this the tradition of Pascal, C, etc): exactly 28 of them, in a carefully designed balance between restriction of the set, and program readability. None of the 28 keywords, of course, names an object of any kind. All names of objects (functions, constants, etc) which Python defines are perfectly ordinary identifiers, just bound in advance in the __builtins__ namespace (86 of them in my current 1.5.2 setup). You can perfectly well choose to re-bind them differently in a more localized namespace, of course; in that namespace, you will then (just as "of course") have to use the long explicit form __builtins__.Identifier rather than just mentioning Identifier, if you want to access the original binding in __builtins__. Further, namespace dictionaries are not locked -- try rebinding or unbinding (deleting) __builtins__.None, for *REAL* fun (and don't be surprised if an IDE crashes when you do that:-). I think some explicit way to lock a dictionary against modification would be neat to avoid _accidental_ rebinding of entries, actually, but I doubt that this rebinding (or deleting, etc) *could* be at all likely to happen *accidentally*!-)... anybody really determined to rebind __builtins__.None would have no qualms calling the 'unlock' method on its dictionary, either!-) Alex From tim.hochberg at ieee.org Tue Jul 18 23:57:25 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 19 Jul 2000 03:57:25 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: [SNIP some stuff about how proposed notation is not consisten with existing NumPy behaviour] > I would have prefered compatibility with NumPy, except for two reasons: > 1. MatPy was started because there is a real need for using infix operator > for matrix multiplication and the only way available was to define a new > class. So for MatPy users, at least, * already means matrixwise. > 2. The current list add is not componentwise. This is fair enough. You could add that the existing list replication (*) is not componentwise either. However, with this incompatability in mind I think "just tell the newbies that . means componentwise" is a bit of an overstatement. (I'm afraid I don't have the original in front of me, so I've probably butchered that quote, sorry). > I don't know of a way that satisfies every compatibility demand. Because > the supply of binary operators has been very limited, each package assigns > them to their most deserving ones instead of according to a better overall > plan. Had there been more this could have been better coordinated. > > >Personally I think that this an overlarge crop of operators to be > >adding. Since I prefer something like: > > > >A.inv * B > > > >to > > > >A \ B > > They are equal in math, but not in practice. The former takes O(n^3) > computation while the latter is O(n^2). The former is also less accurate > for near singular A because of rounding error. Actually it's easy enough to make them equal in practice as well as in math. A.inv doesn't have to be (in fact shouldn't be) the actual inverse matrix, rather it starts it's life as a class containing a reference to A. As a simple example: class InverseMatrix: def __init__(self, matrix): self._matrix = matrix def __mul__(self, other): return LinearAlgebra.solve_linear_equations(self._matrix, other) where A.inv is initialize to InverseMatrix(A). Then A.inv * B returns LinearAlgebra.solve_linear_equation(A, B) and is order N**2 just as A\B. Things would have to more complicated in real life of course. If someone tried to look at or modify A.inv, you'd probably want to cache the modified result. Some thought would be required to get this right, but I believe it's doable. > The other operators are also useful. For example, the + and .+ do different > things. If you add a row and column vector with + it will complain about > shape mismatch, as defined in linear algebra. With .+ it will give a matrix > properly extended to both rows and columns. This has been asked for in this > thread. I've seen it been called prolongation, continuation or cross > extension, among others. In fact, in MatPy, the .+ .- .* ./ do exactly what > + - * / do in NumPy. I'm afraid I don't find this usage all that compelling, but that, of course, is just my opinion. -tim From dale at out-think.NOSPAMco.uk Wed Jul 19 09:31:38 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 19 Jul 2000 14:31:38 +0100 Subject: ADO 2.5 connection problem Message-ID: Sorry about the length of this post but I've run out of ideas. The following error is produced by a short extract of the program I'm working on. The program opens a database connection (ADO) object which it stores in the object it returns on creation. That connection is then used on subsequent calls to access record sets. The test() method shows that the connection is still open. This used to work with MDAC 2.1 but I had to upgrade to MDAC 2.5. That's when it stopped working. This error is reproducible on NT 4.0 and Windows 2000. HELP! Why can't I use this connection? >>> import thstest >>> x = thstest.ths() Create ths... >>> x.logon('fred', 'pw') Traceback (innermost last): File "", line 1, in ? File "S:\JOBS\THS\Code\thstest.py", line 52, in logon rs.open(qry, self.dbcon, adOpenStatic, adLockOptimistic, adCmdText) File "d:\Program Files\Python\win32com\client\dynamic.py", line 428, in __getattr__ raise pythoncom.com_error, details com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', 'Operation is not allowed on an object referencing a closed or invalid connection.', 'C:\\WINNT\\HELP\\ADO210.CHM', 0, -2146824579), None) >>> x.test() Connection state: 1 >>> from win32com.client import Dispatch # Constants # ---- CursorTypeEnum Values ---- adOpenStatic = 3 # ---- LockTypeEnum Values ---- adLockOptimistic = 3 # ---- CommandTypeEnum Values ---- adCmdText = 0X0001 # ---- ObjectStateEnum Values ---- adStateClosed = 0X00000000 adStateOpen = 0X00000001 adStateConnecting = 0X00000002 adStateExecuting = 0X00000004 adStateFetching = 0X00000008 sourcedb = "s:\\data\\merlin.mdb" class ths: def __init__(self): self.dbcon = Dispatch("ADODB.Connection") self.dbcon.Open("Driver={Microsoft Access Driver (*.MDB)}; DBQ=" + sourcedb) print "Create ths..." def test(self): print "Connection state:", self.dbcon.state def __del__(self): print "Deleting ths..." self.dbcon.Close() self.dbcon = None def logon(self, email, password): rs = Dispatch("ADODB.Recordset") qry = "select * from user where email = '%s' and password = '%s'" % (email, password) rs.open(qry, self.dbcon, adOpenStatic, adLockOptimistic, adCmdText) return not rs.EOF -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From neilh at scintilla.org Wed Jul 26 21:35:01 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 27 Jul 2000 01:35:01 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: <9lMf5.13032$4p3.100924@news-server.bigpond.net.au> > Watching the reactions of the dyed-in-the-wool-MS-hating-academics was > almost the most interesting part of this project. Suffice it to say they > started the project with their "Tux" t-shirts being worn proudly every > (single, smelly :-) day, but by the time the PDC came around they were > first in the queue for their .NET tshirts ;-) This is a great move for Microsoft. While a large number of languages have been implemented on the JVM, Sun has not been interested in making the Java world friendlier to other languages. I don't think they have accepted one extra byte code to help another language and some implementors have argued that very minor changes could lead to much better implementations for their language. It's not all happiness though. There has been mention of a Common Lisp group that bailed because of concerns with the .NET process. And several languages that would be good candidates for this environment such as Ruby appear ignored. Microsoft is, for now, listening very hard so now is the time for ensuring that .NET will be a good environment for languages and language features that you care about. To monitor .NET developments, subscribe to the high volume DOTNET mailing list: http://discuss.develop.com/dotnet.html Neil From tim.hochberg at ieee.org Mon Jul 24 16:34:40 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Mon, 24 Jul 2000 20:34:40 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: [...] > On Sat, 22 Jul 2000 01:28:52 GMT, Tim Hochberg wrote: > 1. Is it necessary to distiguish inner and outer? With Greg's indexing > rules these are essentially the same. Six would be enough. Someone (?) strongly requested outer. Since no syntax is really _necessary_, it's just a question of balancing how large the demand for shorthand versus the pain of adding it. I almost never user outer, so I'll leave the lobying up to those who use this. > 2. What would be the meaning of | and ^ for matrices? What's the meaning of > (|) and (^) for numbers? For the proposed operator set proposed in the summary, [(+), (-), (/), (*), (.), (|), (^)], | and ^ would be bitwise OR and XOR as they are now for Numeric. That's admittedly a little dicey, which is why another choice might be better. The natural choice for power is of course (**), but I worry that it may be hard to visually parse. (!) was suggested for solve, but it is too associated with factorial for me to be happy with it. As for the meaning of (|) and (^), for numbers; we were forbidden from assigning meanings of new matrix operations on builtin types, so I refuse to speculate<0.5 wink>. One of the reasons I keep looking for a symbol for solve is that it's more or less symmetric to (/) [or @/, etc.] and I suspect as commonly used, if not more so. It seems that it would be unfortunate to have one of the pair have a symbol while the other does not. I'm not sure, but I might rather see two forms of solve, one returning B=A(**)-1(*)C and one returning A=C(*)B(**)-1, than having one have of the pair being designated (/) and the other solve (or sol). > 3. What are the forms of augmented assignments? (op)= or (op=) I'd say (op)=. This seems obvious to me. So obvious, that I can't think of a good explanation for it. (Sigh). > Major questions: > > 1. Is the justification of (op) form mainly on aesthetic? Or is it an open > door for more operator composition within bracket in the future? If the > former, is two extra char of bracket justified? If the latter, do we > need to discuss what the future extensions might be? Aesthetics for the most part. I'm not concerned with people wearing their fingers out typing on any of the proposed syntaxes, so I refuse to worry about extra characters. I think the sole issue is how readable it is in complicated expressions; some important points are made about this below. > 2. Most important: How do real formulas look like? (See examples below.) [Snip...] > Why? In discussions, the () works as a nice delimiter so (op) appear quite > nice in the text. But in real codes it interferes with visual parsing of > existing (). > > A typical example is the matrix inversion formula, represented as (assuming > | for solve, .I for inverse) > > b = a.I - a | u / (c.I + v/a*u) * v / a > > b = a.I .- a .| u ./ (c.I .+ v./a.*u) .* v ./ a > > b = a.I @- a @| u @/ (c.I @+ v@/a@*u) @* v @/ a > > b = a.I (-) a (|) u (/) (c.I (+) v(/)a(*)u) (*) v (/) a > > The last one appears least clear, because it is difficult to visually parse > the parenthesis used for precedence. Fine tuning on spacing and case of > names may offer some relief but the main problem won't go away. The first is definitely the best. This does give me some sympathy for the reversing the sense of the operators in different packages proposal. Not enough, I don't think, but some. I think the second one is actually the worst: are you going to notice the difference between: b = a.I .- a .| u ./ (c.I .+ v./a.*u) .* v ./ a and b = a.I .- a .| u ./ (c.I .+ v./a*u) .* v ./ a It seems that accidentaly using matrix when elementwise was meant and vise versa would be a huge problem. The third is hard to parse because @ is so heavy, and the last case has parentheses problems. Blech. I went ahead and tried the other passible bracketing symbols: b = a.I [-] a [|] u [/] (c.I [+] v[/]a[*]u) [*] v [/] a b = a.I <-> a <|> u (c.I <+> va<*>u) <*> v a b = a.I {-} a {|} u {/} (c.I {+} v{/}a{*}u) {*} v {/} a The [*] form looks a little better. The <*> form bugs me because <-> looks like and arrow, but otherwise looks better than I expected. The {*} form looks no better than [*] form, and is less evocative of a matrix operation. > Although this formula might have a bit higher than average complexity, > similar types of formulas occur frequently in various applications. They > cannot all be put into named functions because there are many variations. > > As I see it, the main reason for introducing infix operators is because > otherwise we would have to use either op(a,b) or a.op(b), both of which > introduces parenthesis that clutters the code. But a(op)b has similar > effects. Although (op) has a very short range, the () can't be readily > distinguished from other usages of () with much longer range. I think the comparison with op(a,b) is not really valid since it is not infix notation. Most people prefer "A + B" to "+ A B" due to familiarlity with infix notation in this context. When the later becomes "plus(A,B)" it exacerbates the problem, but the main problem is infix versus prefix notation. That being said, a.op(b) is more or less a fair comparison. I don't think parentheses are the only issue though, even here. One is the lack of symmetry, which makes the connection with infix notation harder to see. For example, when I abused call functionality to provide matrix multiplication, people were much more likely to accept (A)(B) then A(B) despite the increase in parentheses in the former. Second is symbol length, A.add(B) use six symbols to spell matrix add while A(+)B uses only two. > So it appears ".op" and "(op)" share similar disadvantages: > ".op" because "." is numbers, class members, ... > "(op)" because "()" is precendence (tuples), function arguments, ... > maybe we need to consider "@op" more seriously? My opinion: ".op" should be killed; any more consideration of this front should go to "@op" or "~op". "(op)" should probably also die and be replaced by "[op]" or, maybe, "" or "{op}". I'm also starting to wonder if maybe there is no good, pythonic syntax to be added here . Perhaps more consideration should go into using the existing operators and making tranformations between elementwise array objects and matrix objects convenient. -tim From python at polaris.ca Sun Jul 9 02:20:36 2000 From: python at polaris.ca (Seamus Venasse) Date: Sun, 09 Jul 2000 06:20:36 GMT Subject: Parsing lists Message-ID: I am creating a simple list of titles and urls. I would like to parse this list, but I keep receiving an error. Here is a simplified version of my code and error received: >>> list = [ 'title1', 'url1', 'title2', 'url2', 'title3', 'url3' ] >>> for title, url in list: ... print title, url ... Traceback (innermost last): File "", line 1, in ? ValueError: unpack sequence of wrong size Of course, if I change the code as follows, at least it prints everything in the list: >>> list = [ 'title1', 'url1', 'title2', 'url2', 'title3', 'url3' ] >>> for title in list: ... print title ... title1 url1 title2 url2 title3 url3 What am I missing the first example? Any assistance would be greatly appreciated. Seamus From gjm11 at g.local.bbs Mon Jul 17 18:20:03 2000 From: gjm11 at g.local.bbs (gjm11 at g.local.bbs) Date: 17 Jul 2000 22:20:03 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bRRJ4$k4B@openbazaar.net> Huaiyu Zhu wrote: >>> How would you write this in list compresension (in less than 10 lines)? >>> >>> B*(sin(A*x+b).*(A*y)/3)/C >>> >>> Note that * is matrix multiplication and .* is elementwise. Note that C is >>> a matrix so the / is matrixwise. If you want to write everything as for >>> loops it takes at least 30 lines, without any decent error analysis. >> >> B*[p*q/3 for p in A*x+b, q in A*y]/C > > Someone else had already given a similar answer. But more work is needed > for such things to work: > > The x, b and y could be matrices, so p and q need to be double loops. Only if you implement matrices as lists of lists, in which case operations like * and / won't work anyway. I was assuming that (1) you have a special Matrix class, and (2) the machinery for list comprehensions is flexible enough to let it express other kinds of mapping. > The [ ... ] need to be a double lists. Is list comprehension defined for > this? It doesn't even exist yet. :-) I repeat that I'm assuming that there's mechanism for doing "comprehension" on aggregate objects other than lists, so that [f(p) for p in FOO] can be made to build a copy of FOO with the operation f applied to its elements. I think this is the Python Way (consider e.g. the fact that it does tuple indexing and list indexing and dictionary indexing all with a uniform syntax). > B*[..]/C would not work without a cast from double list to matrix. Not if my assumption above is correct. > For all these errors, what would the error messages look like? Do they > involve the dummy indices p and q? A previous answer also reused the name b > for the dummy variable, which would make the error even more obscure. These are not errors unless my (perfectly reasonable) assumptions turn out to be false. > Besides, the main point of using matrix is to be free from specifying loops > over indices with dummy names. Compare this double loop with extra syntax > with a single operator .* and you may wonder why this is considered at all. And compare the cumbersome expression above with the much simpler & which I have just defined to mean what you write as "B*(sin(A*x+b).*(A*y)/3)/C". It's easy to make things look neater by adding syntactic sugar, provided you're doing it to only one smallish class of things at a time. But there's such a thing as too much syntactic sugar. One design decision that's pretty fundamental to Python is that there's very little syntactic sugar; if you prefer a language that goes the other way, you can always try APL or J. They're pretty good with matrices, too. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From alex at magenta.com Thu Jul 20 10:41:38 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 20 Jul 2000 16:41:38 +0200 Subject: iterating over lines in a file References: Message-ID: <8l73an01lgb@news2.newsguy.com> "Roger Upole" wrote in message news:hMrd5.49275$e6.2860918 at pouncer.easynews.com... > Using an initial read is a common enough idiom in any language. It is extremely rare in languages which allow assignment in expressions, and would normally denote lack of familiarity with the language's idioms. > f=open('filename','r') > fline = f.readline() > while fline: > .... > fline = f.readline() Everything should be done ONCE, and only ONCE. In ONE place in the code. This expands the abstract operation "get next thingy if any" in two places, just because of a language quirk. > > def readline(self): > > line = self.source.readline() > > self.line = line > > return line # may be empty, thus false I don't see why not just: def readline(self): self.line = self.source.readline() return self.line Seems to have exactly the same semantics; the local-variable line does not appear to be playing any role. > > could somebody enlighten me, please? and is there any easier way to > > iterate over lines in a file without resorting to ugly break statements? The fileinput module does just that in a very elegant way, IMHO: import fileinput for line in fileinput.input("myfile.txt"): # do whatever you wish with line Alex From cut_me_out at hotmail.com Sun Jul 9 17:03:04 2000 From: cut_me_out at hotmail.com (Alex) Date: 09 Jul 2000 17:03:04 -0400 Subject: How to approach this? References: <8kal5v$8n5$1@supernews.com> Message-ID: > I want there to be just one instance of the database class which is > created as soon as it's needed by a dependant class. This might be worth a try. Alex. class Connection: '''Replace this with whatever actually makes the connection''' def query(self, query): print query class Connection_wrapper: '''Dependant classes should call this.''' connection = None reference_count = 0 def __init__(self): ref_cnt = Connection_wrapper.reference_count Connection_wrapper.reference_count = ref_cnt + 1 if Connection_wrapper.connection == None: Connection_wrapper.connection = Connection() def __getattr__(self, attr): return getattr(self.connection, attr) def __del__(self): # Can't refer to the class as Connection_wrapper, that name # can get overwritten by another version of the class during # repeated interactive invocations, for instance. my_class = self.__class__ ref_cnt = my_class.reference_count my_class.reference_count = ref_cnt - 1 if my_class.reference_count == 0: my_class.connection = None class Dependant_class: def __init__(self): self.connection = Connection_wrapper() def query(self, query): self.connection.query(query) t = Dependant_class() t.query('Testing that the query method gets called.') t.connection.connection.touched_p = 'touched.' s = Dependant_class() connection = s.connection.connection assert hasattr(connection, 'touched_p') and \ (connection.touched_p == 'touched.'), \ 'Should be the same instance.' From paul at prescod.net Mon Jul 17 15:59:32 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 14:59:32 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> Message-ID: <397365A4.87F8CD3E@prescod.net> Huaiyu Zhu wrote: > > ... > > I thought I replied your email through email ... Ah, here it is: Right, but you weren't the person who brought up the millions of Matlab users this time. > ... > On the other hand, open source may beat them > easily, as long as > > 1. we are using a better language which has more potential > 2. users have incentive to contribute because it's already useful > 3. there's no big hurdle beyond what's already in Numerical Recipe You presume a great deal of human labour which you cannot provide by yourself. We cannot extend Python based on your faith that these people will come along and do the work to make it a serious Matlab competitor. Anyhow, you can prove me wrong by making MatrixPython as popular as Python. Then we will come to YOU and ask if we can merge grammars to unify our communities. I could just as easily claim that if we add regular expressions to the Python syntax, all of the Perl users would come over here. I don't have any evidence, though. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From lordkaos at my-deja.com.bbs Mon Jul 17 19:10:03 2000 From: lordkaos at my-deja.com.bbs (lordkaos at my-deja.com.bbs) Date: 17 Jul 2000 23:10:03 GMT Subject: test_socket, similar problem: Message-ID: <3bRSXR$ja5@openbazaar.net> I'm having a similar problem to the below, but on a Mac (MacOS 9.0.4) w/ Python 1.5.2 (same error w/ test_socket, and same thing when I tried open a simple socket connection) I'm sure the problem/solution is similar, but how in specific do I fix it on a Mac? Thanks. > Harry George wrote: > > > > [I looked in dejanews, but all the socket queries are way beyond where > > I'm stuck.] > > > > I have a win95 machine which is samba'd to a linux box.? I'm trying to > > learn to do python on win95 (COM et al).? First step is to get it > > running.? py152.exe went ok; then win32all-128.exe.? python, > > pythonwin, icons in the explorer all ok.? Able to edit and run simple > > hello, worlds. > > > > Then in the interpreter I tried: > >? import test.autotest > > It ran ok (with lots of skipped optionals), but test_socket crashed > > with socket.error "host not found" > > I had the same error. As far as I understood my? computer didn't know > about his name.. ;-) I made the? file "c:\windows\hosts" , that > contained one row: > > 128.0.0.1 localhost > > and after reboot all worked fine.. > > > > Of course this could be a non-python win95 setup issue, but with > > tcp/ip running ok (samba, ftp, ping, etc.), I'm wondering if there is > > a python-specific issue.? Any ideas? > > > > -- > > Harry George > > hgg9140 at seanet.com > > Alexei Kichkine (http://infocentr. Sent via Deja.com http://www.deja.com/ Before you buy. From spam at spam.com Wed Jul 19 20:34:41 2000 From: spam at spam.com (Penfold) Date: Thu, 20 Jul 2000 01:34:41 +0100 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: Huaiyu Zhu wrote in message news:slrn8n9s6i.so.hzhu at rock.localdomain... > On Tue, 18 Jul 2000 23:35:30 +0100, Penfold wrote: > > >I'd expect it would be ... > >(i) you're asking that the grammer be dynamically changed *as* the module > >is being parsed. > >(ii) are you going to restrict the possible new tokens > >(iii) How does the python interpreter work ... for example the expression > >a+b > >results in byte code of the form > >LOAD_FAST a > >LOAD_FAST b > >BINARY_ADD > > > >That is, the BINARY_ADD operation deals with the issues of whether these are > >instance types (and thus __add__, __radd__, __coerce__ > >etc should be invoked). At least thats what Ive always believed (never > >checked the source ;-) ). So what gets generated > >for a .* operation? An explicit call? does coercion, or the equivalent of > >__radd__ ever happen? What happens when a and b > >are not classes? [well, a TypeError obviously?] > > > >I mean there are issues there ;-) > > Hmm, so I see the issue - an operator is supposed to do a lot of things, all > of which expressed as an opcode (or whatever BINARY_ADD is called). This > opcode is only available in the C source, so there is no direct pathway to > go from .* to __dotmul__ purely inside python. > > Let's see what happens to a class, which also can do a lot of things, but > all of them are available within python. Why? Because the internal things > are in __dict__. > > So why isn't there be something like a __dict__ that holds all the > properties of operators, including opcode? Maybe because operators are not > supposed to change any way? Maybe because this stage is even lower than the > implementation of dictionary? Or is there more fundamental technical > reasons (Like making the compiler much slower)? Hmm, I dont understand the question properly. My point is mostly that having new operators is fine but they'd tend to be implemented in bytecode as BINARY_DOT_ADD for example. Which means, what they are needs to be predefined. Having a system where they get dynamically created during parsing, and could be anything, makes it hard for the byte code compiler. It cant generate a BINARY_AT_DOT_HAT_ADD for a @.^+ because no such opcode exists already. So it would have to instead try to call method names etc. Which, is not that nice, especially as really, operators arent methods ;-). > > > > > I know I'm not supposed to respond to rant, but this has come up many times > so I thought I might just do it once and for all. > > [ about + - * / being easily understandable but no clue about additional > operators which have no implicit meaning] > > The implicit meaning is "the dot in front means the operator is > elementwise". Tell a newbie this, then show him the following piece of code > > [1,2] + [10,20] == [1,2,10,20] > [1,2] .+ [10,20] == [11, 22] > The point is more that given a .+ b, in a piece of code, where you *dont know* what a and b are, what is your intuitive feel for what it should do. I'd suggest nothing. It could be anything. (As an aside, why shouldn't [1,2]+[10,20] zip the lists into [(1,10), (2,20)]. ) > Then give him two minutes for brainstorming. He probably will figure out > what .* .- ./ do. No s/hes figured out what it does for lists, now ask them to decide what they think x .+ y and x .* y probably do for some arbitrary x,y. They'll extrapolate from your example, Id hypothesis that for other types of x and y, theyd do all sorts of weird ass stuff. > The best way to choose a meaningful symbol in your field is to use the ones > people have used for hundreds of years, or if your field hasn't existed that > long, spell things out explicitly. It is a general rule that the newer the > field, the more verbose the names. When things settle down the notations > will become more concise. When the total number reduces to less than 7 :-) > you could even start to consider using binary operators if all of them have > a simple rule that maps to existing arithmetic operators that a newbie > understands in two minutes. Matlab isnt quite a few hundred years old yet. And why does it make the rules? Shouldnt we more realistically have vector/matrix operators like ||A||, . These have been around a little longer ;-). Why shouldnt the parser do unicode text, and allow me to use intersection/union symbols so that I can express set theortical stuff better :-) > >[does it automatically add the spaces between the words too ;-)] > >yes, because > >map(lambda x,y: x+"is"+y, ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", > >"boy", "boy"]) > > With a little correction. For named lists it is either ack, I should read what I cut and paste ;-) > names .+ "is" .+ types > map(lambda x,y: x+"is"+y, names, types) > > The probelm is, of course, you cannot make a C module to speed up > elementwise operations with the latter notation because it uses builtin > syntax rather than method call. Well, not strictly true. We could make the whole thing uglier like so map(operator.add, map(operator.add, names, ["is]*len(names)), types) and we'd get the c speed up on the add, bypassing the slowdown from the lambda. But then, thats starting to look almost perlish ;-) > > >ever-rantingly-yours, > > > > never-reply-to-rant-again-ly y'rs > > Huaiyu perhaps one more time ;-) Des. From moshez at math.huji.ac.il Tue Jul 18 02:29:34 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 18 Jul 2000 09:29:34 +0300 (IDT) Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) In-Reply-To: Message-ID: On Mon, 17 Jul 2000, Huaiyu Zhu wrote: > Consider the proposal of having two classes, Matrixwise and Elementwise, > with methods to cast to each other. I don't know why > > (a.E()*b.E()).M()*(c.E()*d.E()).M() > > would be more preferable to > > (a.*b)*(c.*d) For the same reason import sys, re r = re.compile("a(.*)z") while 1: line = sys.stdin.readline() if not line: break m = r.search(line) if m: print m.group(1) To: while() { print $1 . "\n" if /a(.*)z/; } It's more verbose, and people are able to understand it without learning weird corners of the language. (BTW: as a former Perl hacker, I find the Perl code *extremely* readable, and I spend more time understanding the Python code. But that doesn't change the fact that Perl took me longer to master then Python, and even then I didn't really understand Perl. For example, could I lose the ";" in the Perl code? I think so, but I'm not sure) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From gmcm at hypernet.com Mon Jul 17 19:29:07 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 17 Jul 2000 23:29:07 GMT Subject: Event set/clear/wait References: <39734D0A.C40861A9@sec.noaa.gov> Message-ID: <8F74C2976gmcmhypernetcom@199.171.54.155> j vickroy wrote: >How can software be written to determine when it is "safe" to *clear* a >threading.Event that has previously been *set*? >"safe" is intended to convey the notion that all threads issuing a >*wait* on the event are no-longer blocking because of it. You don't need to worry about it. All waiting threads are notified while the setter holds the lock. Once notified, they don't look to see if the Event is set or clear - they're unblocked. - Gordon From hinsen at cnrs-orleans.fr Mon Jul 24 06:47:32 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 24 Jul 2000 12:47:32 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: > Minor questions: > > 1. Is it necessary to distiguish inner and outer? With Greg's indexing > rules these are essentially the same. Six would be enough. What are "Greg's indexing rules"? Inner and outer product are entirely different operations in my mind, although in principle the inner product can be thought of as an outer product followed by a summation. I think that implementation issues also call for separate operators; using indexing tricks might be difficult for sparse matrices, for example. > Major questions: > > 1. Is the justification of (op) form mainly on aesthetic? Or is it an open > door for more operator composition within bracket in the future? If the > former, is two extra char of bracket justified? If the latter, do we > need to discuss what the future extensions might be? I like the possibility of extending this operator concept later, but for now (in order to keep this discussion within limits) I'd just call it a set of aesthetically acceptable matrix operators. > original after s/\*/(*)/g; s/\//(\/)/g > > "-"*40 "-"(*)40 # should this work? No. > a*2 a(*)2 # should this work? Yes, as an outer product with a scalar (which happens to do the same as a*2). > But the main problem of these operators now appears to be that they do not > look as clean in long formulas as they appear indivitually. > > Why? In discussions, the () works as a nice delimiter so (op) appear quite > nice in the text. But in real codes it interferes with visual parsing of > existing (). They still look acceptable to me, but perhaps [*] etc. is better in the end. Indexing expressions are never as long as expressions in parentheses. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From boncelet at eecis.udel.edu Mon Jul 24 14:59:19 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Mon, 24 Jul 2000 14:59:19 -0400 Subject: Discussion: new operators for numerical computation References: Message-ID: <397C9207.EC0528AA@eecis.udel.edu> After reading numerous posts on the subject of adding more infix operators to Python (e.g., making Python more like Matlab), I'm starting to wonder if the proposed solutions are not worse than the original problems. A few comments (some plagiarised from others--but I'll try to attribute when I remember the source): 1. MatPy currently does a pretty good job of addressing many of the concerns for linear algebra. The syntax for inverse (A.I()) and transpose (A.T()) are both simple and allow for class specific implementations (e.g. for a triangular matrix). Yes, Matlab is simpler for linear algebra, but MatPy is not bad. (I wonder how widely used MatPy will become. It is a nice package but it deviates from numpy, which is the Python "standard" for numerical work. I wish Huaiyu good luck and hope he continues.) 2. A week or so ago, I suggested just @ for matrix multiplication. Someone else asked what about all the other operations (left and right inverse, power, etc.), but I was traveling and didn't have time to respond. Recently, Konrad Hinson and others have given the answer I would have: what do you mean by left and right inverses? matrix power? These are not uniquely defined concepts. In the universe of choices, I strongly believe that accuracy should not be sacrificed for speed. (Let the user override the defaults and program for speed if necessary.) In my work, I usually want to control which algorithm is used and would likely "roll my own" anyway. BTW, in most applications with which I'm familiar, matrix multiplication is used much more frequently than matrix division. 3. For multiarray objects, it is not clear what matrix multiplication, left and right inverse, and power should mean (to me, at least). Without a good consensus for the meaning of these objects on general nD-multiarray objects (not just 2D matrices), I wonder whether adding the proposed infix notations is ill-advised (premature?). The proposals to add dimensional indices to the infix operators are really ugly. Sorry. 4. Travis Oliphant is probably right that the biggest problems with python and numpy are the lack of toolboxes and the basically non-existent help system. Hopefully, Paul Plescod develops his proposed help system. I'd like to suggest the inclusion of all of blas and lapack in numpy as a priority. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From montagne at boora.com Wed Jul 12 15:08:50 2000 From: montagne at boora.com (michael montagne) Date: Wed, 12 Jul 2000 12:08:50 -0700 Subject: Browse for folder References: Message-ID: Unfortunately, I'm using 1.5.2 and 8.3. From morganea at bellatlantic.net Thu Jul 6 13:36:28 2000 From: morganea at bellatlantic.net (Michel Orengo) Date: Thu, 06 Jul 2000 17:36:28 GMT Subject: Ado stored procs with parameters References: Message-ID: What if you try "rs=cmd.Execute()"? Michel "Sam Corder" wrote in message news:CPEKKMGLLILAJEKJNAPDAEEBCBAA.scorder at incigna.com... > I'm having a bit of trouble using a stored proc on MSSQL that takes > parameters. I create a command object and then append the parameters to it. > Then I create a recordset object and use the open method passing the command > object and a few other parameters. Unfortunately I get an error saying that > the stored proc requires The same parameter that I just added. Below is the > code I'm using. Any ideas? > > Sam Corder > > import win32com.client > constants = win32com.client.constants > > class dbcon: > def __init__ (self, connect = None): > self.connectstr = connect > def runSQLReturnRS(self, sql, params = None): > if self.connectstr == None: > return None > else: > rs = win32com.client.Dispatch('ADODB.Recordset') > cmd = win32com.client.Dispatch('ADODB.Command') > cmd.ActiveConnection = self.connectstr > cmd.CommandText = sql > if params != None: > for parm in params: > cmd.Parameters.Append(cmd.CreateParameter(parm[0], > parm[1], constants.adParamInput, parm[2], parm[3])) > > rs.Open(cmd, CursorType = constants.adOpenForwardOnly, LockType > = constants.adLockReadOnly) > return rs > > def __AddParams(self, cmd, params): > for parm in params: > cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], > constants.adParamInput, parm[2], parm[3])) > > if __name__ == '__main__': > db = dbcon("Provider=SQLOLEDB;Data Source=s-incigna2k;User > Id=msl_login;Password=***;Connect Timeout=5;network library=dbmssocn;Initial > Catalog=msl;") > params = ("ExpJobID", constants.adInteger, 4, 11), > rs = db.runSQLReturnRS("ExpConfig_Get", params) > print rs.Fields.Count > > > From neilh at scintilla.org Mon Jul 17 21:36:41 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 18 Jul 2000 01:36:41 GMT Subject: Could someone clone MS's IL for another OS? References: Message-ID: > Could someone write a clone of MS's new intermediate compiler language to > native code compiler in order to write Perl, Python, or Eiffel on > Windows, compile it to IL, and then eventually native code compile it on > some other OS platform? I think its likely Microsoft will publish enough documentation to make it possible to write an IL VM for other systems. Microsoft may even make an IL VM available for other systems with the most likely being MacOS. If this is going to happen, I'd expect it to be announced at MacWorld this week. The question here is to what extent Microsoft wants to beat Java/Sun. Widespread availability of IL VMs would help this goal, while still allowing differentiation of the preferred platforms on the basis of which libraries are available. Microsoft will also have a large lead in designing IL VMs so will be able to ensure best perfromance is on those preferred platforms. They can also win on effort applied - when competing with their Java VM Microsoft achieved very good benchmarks. > Does anyone think such a capability is a good idea? > Does anyone think that someone will do this? Yes to both. Neil From ghost_man at my-deja.com Thu Jul 20 13:36:41 2000 From: ghost_man at my-deja.com (ghost_man at my-deja.com) Date: Thu, 20 Jul 2000 17:36:41 GMT Subject: searching for multiple strings in one pass Message-ID: <8l7db8$v3g$1@nnrp1.deja.com> I am stuck on a problem here where I am using python to grab a large amount of info from a database. I am then using python to pass command line parameters to some program based on file names. I only want to run on certain file types such as files ending with .hpp or .cpp or whatever. The problem is how can I do searches for multiple file types in one pass rather than having to run through the entire list several times? Here is a sample of how I am doing it now.... hpp = string.find(newline,".hpp") if hpp > 0: k = (creating argumenthere) os.system (k) How do I check for several file types in one pass? Sent via Deja.com http://www.deja.com/ Before you buy. From MarkH at ActiveState.com Tue Jul 25 20:24:39 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 26 Jul 2000 00:24:39 GMT Subject: Type inference for JScript.NET References: <8lktiq$rgv$14$1@news.t-online.com> Message-ID: "Eduard Hiti" wrote in message news:8lktiq$rgv$14$1 at news.t-online.com... > Nice features - leaving the question: will there be something similar for > python# | python.NET ? Dunno - I hope so. There will definately be some "detection" - ie, infering so dumb that it shouldn't be called inference! It is safe to say that Python .NET could benefit greatly from decent type inference. I'm hoping the types-sig discussion on optional type declarations, and related inference work will revive itself - I'm reluctant to start this sort of work when it appears the wider Python community is just around the corner from a concerted effort. Mark. From rumjuggler at cryptarchy.org Fri Jul 28 23:43:38 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 03:43:38 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> <8lsqld$hrq$1@newshost.accu.uu.nl> Message-ID: <82l4osonthc3dopu8s7ddrs7h4cgou1lgf@4ax.com> On 28 Jul 2000 20:32:45 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >> Shoot yourself with "conversion" or with assignments like this, either way >> your foot is shot. I say learn proper gun safty and aim it elsewhere. ;) >> Seriously, that isn't to say that None should be restricted from being >> changed, just, uh, anyone know how to change it back aside from restarting >> python? :) > >Cute question. Hm.. > >Yes: > >None = __builtins__.None > >Now for the real problem: > >__builtins__.None = 1 > >Uh oh. >>> def getnone(): pass >>> import __builtin__ >>> __builtin__.None = 1 >>> type(getnone()) -- Barnabas T. Rumjuggler A cucumber should be well sliced, and dressed with pepper and vinegar, and then thrown out, as good for nothing. -- Samuel Johnson From roberto.lupi at galactica.it Sat Jul 8 08:35:16 2000 From: roberto.lupi at galactica.it (Roberto Lupi) Date: Sat, 8 Jul 2000 14:35:16 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <00c601bfe812$febfeef0$f0c809c0@lslp7o.lsl.co.uk> <8k4t1u$7fk$1@newshost.accu.uu.nl> <8k5hd8$go8$1@localhost.localdomain> Message-ID: Although not strictly part of ZODB, I think that ZCatalog and ZClass can be used to perform queries and schema evolution. In article <8k5hd8$go8$1 at localhost.localdomain>, fermigier at localhost.localdomain says... > What I'm missing most from ZODB, and is usually easy to do with an > object-relational adapter, are queries ZCatalog > and a simple way to do schema > evolutions. ZClass -- Roberto Lupi From stuart.hungerford at zveno.com Sun Jul 30 20:52:01 2000 From: stuart.hungerford at zveno.com (Stuart Hungerford) Date: Mon, 31 Jul 2000 10:52:01 +1000 Subject: Python plug-ins for Adobe Products available References: Message-ID: <3984CDB1.11457A59@zveno.com> Grant Munsey wrote: > Adobe has opened an open source site at http://opensource.adobe.com. > > The first three projects on the site are Python plug-ins for Adobe > Photoshop, > Illustrator, and After Effects (Windows only at this point). > > The Adobe Open Source license is reasonably liberal. I'd like to say a huge "thanks" for this too. I've been driving PageMaker via Python using DDE and started working on using Photoshop and InDesign via Python using OLE and the various SDK calls, but this approach is a great improvement. Stu From just at letterror.com Wed Jul 5 15:22:05 2000 From: just at letterror.com (Just van Rossum) Date: Wed, 05 Jul 2000 20:22:05 +0100 Subject: Postscript font metrics? References: <39622330.3732B225@yahoo.com> <3963368A.8442AD75@bellatlantic.net> Message-ID: <39638AA5.7C36FD77@letterror.com> Paul Winkler wrote: > > I need to generate some nice Postscript output from a python script, > and I'm finding that I need to get at the font metrics info from the > .afm files so I can place things correctly. (Either that or write > *everything* in postscript -- no way!!) > > I can't find anything like this on Parnassus. Anyone ever seen any > python code that gets the useful info from .afm files? My (hardly advertized, but free) FontTools package contains an AFM parser: http://www.petr.nl/just/FontTools.tar.gz Sorry, the doco is, erm, somewhat limited ;-) Just From ngps at madcap.dyndns.org Mon Jul 24 10:42:41 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 24 Jul 2000 14:42:41 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lg7ft$odv$1@nnrp1.deja.com> <397BEAE5.3C1E5151@stroeder.com> <8lh9og$fi5$1@nnrp1.deja.com> Message-ID: <8lhkl1$oou$1@clematis.singnet.com.sg> According to : > Yes i have unzip all the m2crypto-005 to "C:\Program Files\Python".What > version should i run it. I'm using python 1.5.2 on win98 Try this: /usr/local/home/ngps:$ python Python 1.5.2 (#1, Sep 4 1999, 15:09:59) [GCC 2.7.2.1] on freebsd2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.path ['', '/usr/local/home/ngps/prog/m2', '/usr/local/lib/python1.5/', '/usr/local/lib/python1.5/plat-freebsd2', '/usr/local/lib/python1.5/lib-tk', '/usr/local/lib/python1.5/lib-dynload', '/usr/local/lib/python1.5/site-packages'] What is the output on your computer? -- Ng Pheng Siong * http://www.post1.com/home/ngps From hzhu at localhost.localdomain Mon Jul 24 00:27:18 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 24 Jul 2000 04:27:18 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: On Sat, 22 Jul 2000 01:28:52 GMT, Tim Hochberg wrote: >At this point there seems to be main proposals. There are variations >on these basic themes, but these two capture the main points: This summary is excellent. Since (op) has emerged as the clear winner, at least for now, without sustaining much criticism, I'd like to play antagonist here and prepare some dead chickens to be thrown on the windshield of this new aircraft. :-) >----------------------------------------------------------------------- > >Proposal two, which for lack of a better name I'll call Konrad's proposal: > >New Operators: (+), (-), (/), (*)[outer], (.)[dot], (|)[solve], (^)[power] Minor questions: 1. Is it necessary to distiguish inner and outer? With Greg's indexing rules these are essentially the same. Six would be enough. 2. What would be the meaning of | and ^ for matrices? What's the meaning of (|) and (^) for numbers? 3. What are the forms of augmented assignments? (op)= or (op=) Major questions: 1. Is the justification of (op) form mainly on aesthetic? Or is it an open door for more operator composition within bracket in the future? If the former, is two extra char of bracket justified? If the latter, do we need to discuss what the future extensions might be? 2. Most important: How do real formulas look like? (See examples below.) > >NumPy and MatPy would have that same syntax: the new operators correspond to >matrix operations in both MatPy and matrix operators in NumPy. The pain of transition now looks to be smaller than it appeared. A quick experiment with sed on the MatPy test suite produced this list of problems (most visible ones): original after s/\*/(*)/g; s/\//(\/)/g "-"*40 "-"(*)40 # should this work? from ... import * from ... import (*) # can auto correct 1*2*3 1(*)2(*)3 # this still works a*2 a(*)2 # should this work? A**2 a(*)(*)2 # can auto correct norm(A*A*A/A/(A*A) - eye(3)) norm(A(*)A(*)A(/)A(/)(A(*)A) - eye(3)) # works but kinda ugly def test(a,b,*args) def test(a,b,(*)args) # auto correct? Most of the wrong translations still work or can be avoided by better translators. Major problem comes from strings (esp regular expressions), but fortunately regex and matrix tend to live in different modules. If the translator can recognize strings it would be mostly fine. But the main problem of these operators now appears to be that they do not look as clean in long formulas as they appear indivitually. Why? In discussions, the () works as a nice delimiter so (op) appear quite nice in the text. But in real codes it interferes with visual parsing of existing (). A typical example is the matrix inversion formula, represented as (assuming | for solve, .I for inverse) b = a.I - a | u / (c.I + v/a*u) * v / a b = a.I .- a .| u ./ (c.I .+ v./a.*u) .* v ./ a b = a.I @- a @| u @/ (c.I @+ v@/a@*u) @* v @/ a b = a.I (-) a (|) u (/) (c.I (+) v(/)a(*)u) (*) v (/) a The last one appears least clear, because it is difficult to visually parse the parenthesis used for precedence. Fine tuning on spacing and case of names may offer some relief but the main problem won't go away. Although this formula might have a bit higher than average complexity, similar types of formulas occur frequently in various applications. They cannot all be put into named functions because there are many variations. As I see it, the main reason for introducing infix operators is because otherwise we would have to use either op(a,b) or a.op(b), both of which introduces parenthesis that clutters the code. But a(op)b has similar effects. Although (op) has a very short range, the () can't be readily distinguished from other usages of () with much longer range. So it appears ".op" and "(op)" share similar disadvantages: ".op" because "." is numbers, class members, ... "(op)" because "()" is precendence (tuples), function arguments, ... maybe we need to consider "@op" more seriously? In a divergent thread there are discussions of using "@" as a generic meta symbol to construct new operators. I only wish there is another free symbol that's not as dense. Well, how about b = a.I ~- a ~| u ~/ (c.I ~+ v~/a~*u) ~* v ~/ a It looks the least troublesome to me at the moment. >Disadvantages: Unfamiliar Syntax for MatLab users. This may not be a big problem as syntax can be learned. More important is if old codes can be used. If automatic translation can work 90% of the time it could be more useful than retyping. If a translator is wided used its quality is likely to be improved fairly quickly as well. Huaiyu From olivierS.dagenaisP at canadaA.comM Sun Jul 16 23:49:46 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 17 Jul 2000 03:49:46 GMT Subject: "Intellisense" drop-down... References: Message-ID: Doh! I didn't know that thing also worked in the interactive window, so I didn't test it there... It might be nice if Tab wasn't hardwired to do this and we could pass a parameter to an event to tell it what to call if the AutoComplete box isn't opened, like so: Tab = AutoCompleteOrDo ( IndentSelection ) Space = AutoCompleteOrDo ( AddSpace ) Ctrl+Space = AutoCompleteOrDo ( <> ) etc..etc... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:iwsc5.3597$4p3.27442 at news-server.bigpond.net.au... > > Here it is, folks, the ability to use another key than TAB to select a > word > > in the AutoComplete list: > > I like it - good to see someone new improving PythonWin. > > A small problem with Ctrl+Enter is that it works in the editor but not > the interactive window. > > Neil > > > From adetalabi at clara.co.uk Wed Jul 5 10:01:08 2000 From: adetalabi at clara.co.uk (Ade Talabi) Date: Wed, 05 Jul 2000 15:01:08 +0100 Subject: Segmentation fault(LINUX) and no idea why! References: <39632A2C.E6ABECEB@muc.das-werk.de> Message-ID: <39633FA4.8EBBE2DB@clara.co.uk> Thomas Thiele wrote: > > Hallo! > > In my program I create a new thread. In this new thread I fork and > replace the child with an other program > using excel. Normaly I have up to four threads with this procedure. So I > have a number of threads and the same numbers of childs (the called > program) > > The problem is sometimes (relativly seldom, so it's unreproducible ;-( ) > I get a segmantation fault and the pytthon interpreter stops. > > But I if the segmentation fault happens, one of the childs is not > running anymore. (I don't know is that the reason or a result) > A little testprogram with the same construction shows that if a > segmentaltion fault happens in one child, the parant keeps running. > I get no traceback from the interpreter. > > My Question is, where can I look for the problem. Why does the > interpreter (-> the whole program) die. What can be the reason? pstack, ptrace or truss the PID -- /--------------------------------------------------------------\ | Ade Talabi | Internet : adetalabi at clara.co.uk | | ::M1ETW:: | Web Page : http://www.net-africa.com | \--------------------------------------------------------------/ From thomas at xs4all.net Fri Jul 21 02:27:53 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 21 Jul 2000 08:27:53 +0200 Subject: [ANNOUNCE] Python Enhancement Proposals on the Web In-Reply-To: <39779F05.3181C5E5@schneider-kamp.de>; from peter@schneider-kamp.de on Fri, Jul 21, 2000 at 12:53:25AM +0000 References: <39779F05.3181C5E5@schneider-kamp.de> Message-ID: <20000721082752.B9897@xs4all.nl> On Fri, Jul 21, 2000 at 12:53:25AM +0000, Peter Schneider-Kamp wrote: > The so called PEPs (Python Enhancement Proposals) are now > available on the web at > PEPs that already carry some content include: > 0204 Range Literals twouters Damn, Peter beat me to it ;) This PEP is in first draft, so any and all comments are welcome. Do people want me to post it here in full glory, or is the webpage accessible enough ? Note: I don't think this subject will raise as much discussion as new operators or the name of a new function ;) but I would prefer it if discussion was kept at a minimum: I'll try to incorporate all opinions in the PEP, and I'm certainly not trying to be some kind of spanish inquisition, but the reason I ask this is very simple: I wouldn't be able to keep up with the posting frenzy ;-P But if we can keep it down to, ooh, a hundred or so postings a day, I think I can manage.... ;P -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From m.faassen at vet.uu.nl Mon Jul 31 04:14:28 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 08:14:28 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8m25dm$ila$1@newshost.accu.uu.nl> Message-ID: <8m3ch4$hn2$2@newshost.accu.uu.nl> Steve Lamb wrote: > On 30 Jul 2000 21:07:02 GMT, Martijn Faassen wrote: >>print bar > This is different than > bar Yes, it is; but what the interpreter does is basically put a 'print' for everything you say. The point is that you seemed to be saying 'bar' is nothing completely useless; it's not -- it's a reference to a function object and can be quite useful. What our mysterious expression "bar" (quotes not part of it) is, is an expression, just like "1 + 1" or "bar()" or "bar(50 * foo())". I'm not saying this isn't confusing initially; the point is that this is not just a random weirdness that can easily be fixed (as I and other pointed out elsewhere). It's a consequence of a consistency in Python; *other* expression statements do indeed do useful things. [snip] >>And you need to remember what all your operations do to any data type >>that they may encounter. I don't. > I never have yet. :) Well, you do, otherwise you can't figure out bugs when you get them, right? If you get a mysterious 0, you need to know that this was possible because somehow a string got involved in your arithmatic expression, right? >>1 isn't mutable into anything at all either, by the way. Neither are >>strings. The name 'b' can however be made to point to something else. >>That is an entirely different thing though, and from the way you're >>speaking I'm not entirely clear whether you understand this yet. > OK, to be strict. None can't be converted, neither can 1. For some > reason, however, b, which was pointing to 1 can be made to point to something > else which we'll call the integer formerly known as 1 where as None things > cannot be repointed from. None is like that really nasy uncle everone has who > scratches himself in public and has a huge beer belly. You don't want to > look, but you are compelled to until the end of time. That's because you put a None in there in the first place, for some obscure reason. As soon as you made sure your variable *cannot contain a None* (and no, you did *not* make sure of this in the regular expression example you gave, and that's been debated to death already; you have quite a few alternatives now), you do not have to check until the end of time. It's not as if 'b' magically can change into something else again all of a sudden. It only changes into something else if you somehow made it change (most likely with an assignment). > The net result, of course, is that int() can point b to something else in > some cases and not others, or, in layman's terms, it can convert certain > things and not others. However, since the docs for int do state "convert" > both in the language and in the book I have I don't think it was too bad of me > to have used that term, no? No; I just wasn't sure you understood what it meant. You do seem to understand what's going on behind the scenes, except that you still seem to see problems that really aren't there. 'b' can't magically change when you pass it through some function you didn't write, except if you assigned the outcome to 'b' again. If your function has the chance to return something else and you don't want 'b' to refer to that, don't do the assignment (until you made sure of the result, at least). The nice part comes in when you think a function can only return an integer and you were wrong (by mistake, or due to some bug in the function). Python will point out the mistake or bug pretty quickly. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From to_get_my_address at see.my.signature Thu Jul 27 01:09:22 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 18:09:22 +1300 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> Message-ID: <397FC3FD.92EF0A70@see.my.signature> Toby Dickenson wrote: > > I can see some cases where it would be appealing to implement a > property access handler in a C extension. Is it worth dedicating a > slot in PyTypeObject for these things? I don't think that's necessary, because attribute access for C objects already goes through a getattr handler in the type object. -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From johannes at zellner.org Tue Jul 4 21:08:26 2000 From: johannes at zellner.org (Johannes Zellner) Date: 5 Jul 2000 01:08:26 GMT Subject: history file Message-ID: Hello, is it possible to read and write a history file (e.g. ~/.python_history) ? -- Johannes From wjdandreta at worldnet.att.net Tue Jul 4 20:22:30 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Wed, 05 Jul 2000 00:22:30 GMT Subject: Looking for Python CGI resources References: <000101bfe5c6$e0e73f80$24b745c6@timaratz> Message-ID: Hi Peter, I think I read somewhere that the second edition of IPWP is being worked on and I thought it was to be released this summer. Bill Peter Timaratz wrote in message <000101bfe5c6$e0e73f80$24b745c6 at timaratz>... >I have the book 'Learning Python' and now I'm looking for material oriented >towards using Python for CGI. The only book that seems to cover this topic >in any depth is 'Internet Programming With Python' and it is out of print. >Is there any other CGI material available? > > From whdaffer at earthlink.net Tue Jul 11 19:54:43 2000 From: whdaffer at earthlink.net (William Daffer) Date: Tue, 11 Jul 2000 23:54:43 GMT Subject: python/win9x and contour plots Message-ID: Anyone got a suggestion for the best graphics package for contour plotting to use with python on a win9x box? Are there any at all? Can they handle irregularly gridded data? TIA William -- Ab hoc possum videre domum tuum. Public Key: http://home.earthlink.net/~whdaffer/#PGP-public-key From nobody at nowhere.nohow Fri Jul 28 22:13:11 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 02:13:11 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com><397FCE9C.F22BB6B4@see.my.signature> Message-ID: In article , Huaiyu Zhu wrote: >In python there are objects and there are names. There are operations that >act on existing objects and those that create new objects. These have >nothing to do with mutability, except that for immutable objects, there are >no operations acting on existing objects. Looks like a good description to me. If you're used to thinking in C, I would describe it as 1) All variables are pointers. 2) De-referencing is done automatically when you use a variable in any context other than as an lvalue. 3) All parameters are passed by value. 4) Many/most operations create a new object and return a pointer to it. 5) Some objects can't be changed after they're created, but some objects provide methods you can use to change them. Does that make sense? -- Grant Edwards grante Yow! Being a BALD HERO at is almost as FESTIVE as a visi.com TATTOOED KNOCKWURST. From fiona at sitegnome.com Sat Jul 29 10:34:52 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sun, 30 Jul 2000 00:34:52 +1000 Subject: Python in politics (sssssssssnake!) References: Message-ID: <3982EB8C.BD6DDE7C@sitegnome.com> > "Thinking like a computer scientist in Python", available at > http://yhslug.tux.org.il/obp/ Is this the right URL? My browser is telling me it can't locate the server.. thanks, Fiona From halim at mlcc.com.my Wed Jul 12 21:45:33 2000 From: halim at mlcc.com.my (halim at mlcc.com.my) Date: Thu, 13 Jul 2000 01:45:33 -0000 Subject: WBMP Message-ID: <8kj6vt+cg6f@eGroups.com> Hi.. Is there anybody who has worked on wbmp converter image from any other format in Python? If yes, where can I find it? Thank you. From cg at schlund.de Mon Jul 24 09:49:03 2000 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 24 Jul 2000 15:49:03 +0200 Subject: Bug in pythondoc? Message-ID: <397C494F.8EAE58D6@schlund.de> Hi! Consider this piece of code: #!/usr/bin/python dict = { "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6 } # EOF Running it through pythondoc 0.7 produces (among other stuff): dictionary dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4} I know that pythondoc doesn't print all elements of large structures, but normally it prints out dots (...) to indicate there are more than displayed. What's wrong here? Regards Carsten. From hinsen at cnrs-orleans.fr Mon Jul 24 06:31:38 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 24 Jul 2000 12:31:38 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: hzhu at knowledgetrack.com (Huaiyu Zhu) writes: > >For "matrix solve", I propose to follow APL and define it in the sense > >of a least-squares solution, implemented via singular value > >decomposition (SVD). There are two reasons for this: > [snip] > > Maybe the algorithm specs should go into the packages instead of operators? > The same algorithm is unlikely to be optimal for all types of matrix > classes, sparse, symetric, tridiagonal, complex, positive definite, etc. If > these are implemented as subclasses of matrices, should they be allowed to > choose the algorithm? Sure, I was thinking about the implementation for plain arrays. Of course any class can implement any method in any way it likes. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From paul at prescod.net Fri Jul 21 05:22:45 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 21 Jul 2000 04:22:45 -0500 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l7kkl$2bv$2@gxsn.com> Message-ID: <39781665.24F4C5B8@prescod.net> Sean Wilson wrote: > > Hi, > > > From a game programming perspective, you can probably consider Python to > > be dirt-slow, though. The trade-off is a lot of power for speed, but > > that power can help you gain back speed because you can be a lot smarter. > > Before I started trying to write my own scripted language I tried to find > some tutorials and articles on them but couldn't get them anywhere. Someone > directed me towards python but I couldn't find anything about the virtual > machine it uses. How does it work and why is it so slow? I think by now Martijn wishes he had spoken more clearly. Python is only slow compared to assembly language and C. It is quite reasonable in performance compared to other scripting languages!!! Python may be slower than your language because it has more sophisticated flow control. In particular, Python's function calling and name lookups are very flexible and not as efficient as in less flexible languages. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From johannes at zellner.org Thu Jul 6 18:46:10 2000 From: johannes at zellner.org (Johannes Zellner) Date: Fri, 7 Jul 2000 00:46:10 +0200 (CEST) Subject: eval Message-ID: Hi, how does eval work ? eval('print "fred"') fails. Or: how do I modify the above statement that it works? -- Johannes From bjorn at roguewave.com Sat Jul 22 11:35:40 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 22 Jul 2000 09:35:40 -0600 Subject: iterating over lines in a file References: Message-ID: <3979BF4C.6C60E636@roguewave.com> Moshe Zadka wrote: > > On Fri, 21 Jul 2000, Gareth McCaughan wrote: > > > Moshe Zadka wrote: > > > > > Preventing world war III, when Python achieves world domination. > > > If C is allowed to achieve world domination, WWIII will be cause by > > > > > > if(everything_is_ok = 0) { > > > launch_missile(); > > > } > > > > No, that will *prevent* WW3 happening when it was supposed to. > > Where do I sign up for the campaign to help C dominate the > > world? :-) > > You probably need to reread the condition. Probably not... Since 0 (zero) is false, and the result of an assignment expression in the rhs, you would never execute the block... -b From lull at acm.org Tue Jul 18 09:09:12 2000 From: lull at acm.org (John Lull) Date: 18 Jul 2000 08:09:12 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> <39739291.4155A128@prescod.net> Message-ID: At the dawn of the third millenium (by the common reckoning), Paul Prescod wrote (with possible deletions): > Look, if you took a poll of all programmers in the world, only a small > fraction use matrices very often. Therefore it is a niche. Most > programmers use numbers and strings every day, however. By that reasoning, cryptography ought not be part of the standard distribution, either. Nor should complex numbers. A very large part of the *reason* it's not used more is that linear algebra is simply *not* natively available in any common language other than Matlab. From huaiyu_zhu at yahoo.com Wed Jul 19 15:21:37 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Wed, 19 Jul 2000 12:21:37 -0700 (PDT) Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: Message-ID: This is good news! I'll make a summary of pending issues so we can have a more focused discussion. Huaiyu On Wed, 19 Jul 2000, Tim Peters wrote: > Sleeping in the same room with Guido for a night did not make it easier to > channel him, but it did make it easier to cloud his mind: Guido is not > opposed to adding new operator symbols to core Python. As of breakfast > Tuesday, anyway, and there are witnesses, so he'll have trouble changing his > mind (well, it will be clumsy for him to *admit* it if he changes his mind > ...). > > But but but (you knew it wouldn't be *that* easy!): > > + Everybody concerned that new operators are "not Pythonic" please swallow > it -- it is Pythonic, cuz Guido said it is <0.9 wink -- but see following > points too>. Contribute by helping to come up with a complete and > Pythonically beautiful implementation instead. > > + Please keep this off of Python-Dev. Doesn't belong there (at least not > yet). Interested parties can form a mailing list, or try to discuss it on > comp.lang.python (my personal hope is that you try the latter, and stick to > one Subject line). > > + There *must* be a PEP for this. Guido won't read any more of the > debate -- it's too voluminous, repetitive and contentious. He'll eventually > read a PEP, though, *after* some sort of consensus is reached. A PEP > requires a champion. I hope Huaiyu Zhu volunteers for this, as he's argued > his case eloquently and rationally. The champion doesn't need to know how > to implement it, but does need to summarize sometimes-opposing positions > dispassionately. > > + There are things Guido will & won't tolerate. Guessing which is an > interesting & educational challenge . For example, adding a new > operator like > > .+ > > is fine, as the maximal-munch rule for lexing can resolve formal ambiguities > easily. OTOH, *any* new operator symbol containing a backslash is dead > before arrival -- backslash has purely "meta" meanings in Python today. If > the goal is to make Python look exactly like some other language, forget it. > It's still Python, with some light syntactic sugar to make life in special > domains sweeter. > > + This one is from me, but it's a safe bet you can view at as precognitive > channeling if you oppose it: anyone suggesting to, e.g., make ".+" mean > something new and exciting for ints or floats or strings or ... will be > shot. There are probably no operations on the builtin types used frequently > enough to merit new syntactic shorthands (excepting, perhaps, that if P3K > changes the meaning of integer division, a new "//" operator for flooring > division was looked upon kindly in the past). The new operators are for > convenience in special domains (where the case for them is indeed very > strong), not an excuse to turn current Python into a cryptic mess. > > + Also from me: forget about user-defined precedence and associativity. > The PEP must define these once & for all, and that's that. > > + The set of new operator symbols cannot be open-ended (as it is in, e.g., > Haskell). There are at least 4 variants of Python tranlators already in > existence, and Guido wants the set of operator symbols fixed so that a > variety of parsing techniques can be used in their natural forms without > trickery. IOW, the full set of operator symbols must-- as it is today --be > a fixed finite set known in advance. > > + If the numerical folk can't reach consensus on the set of operators and > what they should mean, my bet is that Guido will let this die rather than > get sucked into Pronouncing on each of the points in dispute. After all, he > has little personal use for this stuff: if the people who *do* want it > can't agree, it's not worth having. > > how's-that-for-a-mysterious-announcement?-ly y'rs - tim > From paul at prescod.net Mon Jul 17 12:14:20 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 11:14:20 -0500 Subject: Python VM on a Chip? References: <3972ADA8.BF327969@linuxfreak.com> Message-ID: <397330DC.41ACB7C1@prescod.net> Jim Brennan wrote: > > ... > > Has anyone ever considered doing the same kind of thing with the Python > VM? Is it even possible since the data types of Python are late > binding? Does anyone know of a commercial or university project that is > implementing a Python VM using ASICs or FPGAs? The data types aren't a problem. It isn't clear (to me) what the benefit of the project would be. Python code can already run in a lot of embedded systems through x86 compatibility and JVM compatibility. A dedicated chip might give better performance, but compiling Python to x86 would probably give even better performance. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From matt at mondoinfo.com Fri Jul 21 22:32:51 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 21 Jul 2000 21:32:51 -0500 Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> Message-ID: <210720002132510070%matt@mondoinfo.com> In article <3978FD9D.B08460CB at mediaone.net>, Toy wrote: > How can I make python issue the command, "ifconfig -a eth0", and then > parse the data to grab the IP? I would think that you could tell Python > to look for the word, 'inet addr:"(is it different on different Unixes?) > and then tell it to get a number right after 'inet addr' that looks like > xx.x.xxx.xxx !! Simple Q, but I'm new, thanks. Something like this should work for you: import os import string import re import sys def getMyAddr(): p=os.popen("/sbin/ifconfig ep0") l=p.readline() while l<>"": if string.strip(l)[:5]=="inet ": matchObj=re.search("\d+.\d+.\d+.\d+",l) p.close() return matchObj.group(0) l=p.readline() p.close() return "not found" def main(): print getMyAddr() if __name__=="__main__": main() You'll also notice that the answer to your second question is yes. The format of the output of ifconfig is different from Unix to Unix. The above example works on FreeBSD. You will need to fiddle it some to get it to work under Linux. Another way to get the local IP is to use the functions in the socket module: >>> import socket >>> socket.gethostbyaddr(socket.gethostname())[2][0] But how to do that varies from machine to machine too. The code above works correctly on my FreeBSD box but on my Linux laptop it returns 127.0.0.1. In order to make it work right on that machine, I need to ask for the address of the hostname only, not the FQDN: >>> socket.gethostbyaddr(socket.gethostname() >>> [:string.find(socket.gethostname(),".")])[2][0] If there's a portable way of getting the local IP address, I don't know what it is. Regards, Matt From denalione at my-deja.com Mon Jul 10 15:16:03 2000 From: denalione at my-deja.com (Dale Burnett) Date: Mon, 10 Jul 2000 19:16:03 GMT Subject: PythonService file creation References: <8kbel1$qrp$1@nnrp1.deja.com> <8F6D93D27gmcmhypernetcom@199.171.54.154> Message-ID: <8kd7cv$3uk$1@nnrp1.deja.com> In article <8F6D93D27gmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > Dale Burnett wrote: > > >When running my app at the command prompt using the debug option I can > >create a new file and write to it. When the app is started via Control > >Panel/Services the file is not created and written too. I have used the > >python native file functions and the NT api CreateFile() function. I > >have tried running the service using the System Account with Interact > >with Desktop checked and specifying an account. > >Any suggestions? > > Besides the account it's running under, the only other problem I can think > of is relying on some (mistaken) notion of what the current directory is. > > I've written files from services, so I know there's no showstopper. > > - Gordon > Do you happen to have a code snippet handy? Sent via Deja.com http://www.deja.com/ Before you buy. From chrish at pobox.com.invalid Tue Jul 18 12:37:10 2000 From: chrish at pobox.com.invalid (Chris Herborth) Date: Tue, 18 Jul 2000 16:37:10 GMT Subject: Does Python support interfaces? References: Message-ID: According to Eric Hopper : > In article , Justin Sheehy > wrote: > > > > Just define the class, and make sure that it provides the proper > > interface. Note that I'm not using "interface" with any special > > language-dependent meaning here. If it behaves properly, it behaves > > properly, and that is all that matters. > > Whee! Inheritance by mysteriously coinciding method names is so much fun! Feh: from exceptions import TypeError class Interface: def __init__( self ): if self.__class__ == Interface: # I'm an abstract base class, don't do that. raise TypeError def SomeMethod( self ): raise TypeError class foo( Interface ): def __init__( self ): Interface.__init__( self ) def SomeMethod( self ): print "feh!" a = Interface() # raises an exception b = foo() # works like a charm -- ----------========================================================---------- Chris Herborth, DNRC Holder of Past Knowledge Arcane Dragon -==(UDIC)==- BeOS hacker, Catharon Productions, Inc. http://www.catharon.com/ CTO, Next Generation Entertainment http://www.ngent.com/ From moshez at math.huji.ac.il Tue Jul 25 07:39:14 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 25 Jul 2000 14:39:14 +0300 (IDT) Subject: SIMPLE QUESTION In-Reply-To: <397D77D1.A331770A@sicon.net> Message-ID: On Tue, 25 Jul 2000, sergio wrote: > Hi all > I''ve imported a dll into a .py file, but when i try to use a > function i get the error > > Traceback (innermost last): > File "", line 0, in ? > TypeError: unbound method must be called with class instance 1st > argument Can you try to be less vague and say 1) exactly what you did 2) exactly what you expected to happen 3) exactly what happened -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From m.faassen at vet.uu.nl Sun Jul 30 17:07:02 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jul 2000 21:07:02 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> Message-ID: <8m25dm$ila$1@newshost.accu.uu.nl> Steve Lamb wrote: > On 29 Jul 2000 02:50:37 GMT, Martijn Faassen wrote: >>Right -- that's why I didn't understand why you complained about the >>extensive exception checking or other checks you need in Python; if you >>*know* a string can be safely converted to an integer, int() does the >>job just fine by itself. > Because Python can toss two types out. String or None, only one of which > can be converted. Yes, obviously, as there is an infinity of 'types' (classes, and such). Python tosses out lots and lots of combinations, otherwise it'd be hard to remember what happens when for the programmer, and the implementation could become very hairy. The latter reason is not the most important one, though; the former is. If you want an 'int()' that can deal with more things, make your own int() like function; it's not hard. >>Ahum, the first! Especially if it deals with critical data, or *money*. >>Imagine I get a string by accident (there's a bug in the program) instead >>of a number, and the string evaluates to 0, and suddenly what I'm selling >>in my e-commerce store is *free*, I'd be rather upset. I'd rather have the >>software not working in case of such input! > Assumption it is dealing with money. What about logs processing? Depends on the application. If I want the program to tolerate mistakes, I can always make it tolerate mistakes by catching and handling some exceptions. It's harder to do the reverse though; if the system tolerate mistakes in the first place I can't easily 'harden' it to suddenly catch human errors (in the input parsing routines, for instance). Of course there are tradeoffs; static typechecking apologists would say this demands overrides all others. In the Python and Perl communities we tend to say there is such a thing as flexibility, and speed of implementation; these are important too. There are other strategies towards keeping bugs away from your code, after all, such as testing. (which is healthy no matter how many types you have anyway) >>It's not a meaningless statement. Sometimes it's very handy to get the >>representation of some Python object. For instance: >>>>> def foo(): pass >>>>> [many complicated steps later] >>...ah, but what is bar now? >>>>> bar >> > Right, I understand thta. Which is why I keep pointing out that it is > meaningless in the context of a script. You tell me why I would need to know > that in a script and maybe we can get around this. I just see no need, ever, > for something that cannot be accessed by the script in the first place. It can: print bar The trouble is with the way expressions can be statements in Python. Some expressions just don't have any side effects, and if you use an expression as a statement (without any assignment involved, for instance), such expressions are meaningless. It's definitely very hard to check for the side-effects thing; you'd need a pretty heavy program analysis and even then it could be tricky. Perhaps there's an easier way around and just forbid any expression that isn't a call to be a statement. But perhaps there are objections to this approach too. It would seem to be that this is an implementation problem; not a lot of time has been invested in fixing it because not a lot of people trip over this one, apparently. You did, though, so perhaps we need to change it, if possible. >>In non-interactive mode it isn't useful, I think (I'd love to hear some >>cases outside the function call example) so we could propose a patch to >>Python that trips over this (in the case of non-calls). > See, we're in agreement. Yes, but you seemed to say this was something inconsistent; it's not inconsistent. I just seems to be a fairly tough problem. >>That statement sounds good in rethorics, but in practice I'd rather >>have the computer give up on things if I'm trying to do things that >>don't seem to make any sense immediately. That way I need to remember >>less. > To me it is remembering more. "Now, this variable coming in from that > file over there, going through this code over here in a different module, > entering in here... was it converted twice or three times and what do I need > to do with it now." > Vs. > "Here it is, those checks said it is this, do it." Ahum, the latter isn't really possible in Python. Your integer wil never ever be converted to a noninteger. Pass it through as many routines as you like, it won't ever happen. For mutable variables such as lists or class instances, it can happen; their contents can change over time. But they'll (some exceptions possible for class instances, but rare) remain the same thing all the time, still. Your variable name may be pointing to something new and different though, but that can happen in Perl just the same. And you need to remember what all your operations do to any data type that they may encounter. I don't. >>Unless you made it possible that b contained something that couldn't be >>turned into a number, such as None. If you made that possible you aren't >>sure beyond all doubt that the variable contains a number, right? > Which is, of course, a product of the lanauge. I know it is going to be a > digit or empty. Sad part is Python makes empty None and None mutable into > pretty much nothing. That's not sad; Python is just pointing out to you that (in your initial statement) you were *wrong*. 'b' does *not* always contain a number. You were thinking sloppily, and Python caught you. 1 isn't mutable into anything at all either, by the way. Neither are strings. The name 'b' can however be made to point to something else. That is an entirely different thing though, and from the way you're speaking I'm not entirely clear whether you understand this yet. >>Sure, but it is the same in Python, right? Except that in the end you have >>to cast your integers to ints or whatever other thing you were expecting >>from your input. > So why, then, when I have done the check should I have to do it, again, > for the sake of the language. Because the language can do different things with strings than with numbers. You have to tell the language that the object you're referring to with 'b' is the object that can to arithmatic; not the object that can you can get characters from. And note that if you really insist, the language leaves you free to define an object that can do both. Not that I'd consider this object to look very pretty. If you drive your philosophy of 'data' to the extreme, you'd need an object that defines operations for *everything*. :) (as your distinction between data and objects is not correct, especially not in Python; data has behavior and objects have state) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul at prescod.net Sun Jul 23 02:33:59 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:33:59 -0500 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> Message-ID: <397A91D7.ABA1CE2D@prescod.net> Robin Becker wrote: > > ... > If the attr is a mutable sequence/map etc how can they be made readonly > using this scheme, are we forced to make immutable string types etc There are two different things. One is stopping the attr from being re-bound. That's what the PEP allows. The other is stopping the attr *value* from being mutated. That depends on the design of the attr value. I guess the PEP could help (a little) with that too. def __get_foo__(self, op, val ): return ReadOnlyProxy( self.__foo ) -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From skip at mojam.com Mon Jul 10 17:45:03 2000 From: skip at mojam.com (Skip Montanaro) Date: Mon, 10 Jul 2000 16:45:03 -0500 (CDT) Subject: [ANN] Python port to Palm Pilot In-Reply-To: <200007101546.IAA09887@rushe.aero.org> References: <200007070140.SAA31035@wd264.aero.org> <3966C005.5EF656C6@smartchat.net.au> <200007101546.IAA09887@rushe.aero.org> Message-ID: <14698.17375.15871.804581@beluga.mojam.com> Jeff> Download the .zip file instead. Apparently, downloading the .prc Jeff> files using a browser corrupts the files. I haven't tried either yet. Can this be downloaded using Linux? I can just barely do pilot-xfer to backup my Palm and could use some suggestions on the use of the other Linux pilot-* apps, particularly those that will let me download new programs like PalmPython. Thx, -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From owen at astroNOJNK.washington.edu.invalid Thu Jul 27 16:31:11 2000 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Thu, 27 Jul 2000 13:31:11 -0700 Subject: Problem deleting text in TK widget References: <8lpvj7$v1h$1@nnrp1.deja.com> Message-ID: <8lq66f$2f3e$1@nntp6.u.washington.edu> In article <8lpvj7$v1h$1 at nnrp1.deja.com>, dogboy777 at my-deja.com wrote: I don't think you are indexing the text correctly. Text widgets want "line.character", though many other options are available (such as "end", "@x,y".... See the superb Tk introduction for a very nice description. -- Russell >I'm trying to delete text in a TK Text field, and I'm getting an error I >don't understand. The code is: > > self.logarea = Text(master, height=35, width=30) > self.logarea.insert(END, 'This is a test') > self.logarea.delete(1,3) > >The resulting error... From alex at magenta.com Fri Jul 21 18:25:21 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 22 Jul 2000 00:25:21 +0200 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: <8laito01n3p@news2.newsguy.com> "Roger Upole" wrote in message news:vnLd5.27741$r9.839310 at news.easynews.com... > I must take exception to your insistence that > "Everything should be done ONCE, and only ONCE. In ONE > place in the code." Hey, if you must, you must. Maybe I should have said "must be done" rather than "should be done", too:-). > Besides sounding didactic, Uh, is this supposed to be bad? My prose's main defect is generally that of being long and convoluted. If for once I've managed to be short and pithy, it was no doubt because I was subconsciously quoting some Great Master. Or maybe channeling Him. (Kent Beck...? Ward Cunningham...?) > it is also completely false. In many cases, > an initial read is necessary to determine how (or even if) the rest of a > file will be processed. Also, different code may need to be called if > the file is empty. Yes, such special cases do indeed come up (when one just cannot control the specs/fileformats). In this case, the general structure tends to be: read the first piece if any if appropriate, do the rest The "first piece" (a line, if you're lucky; but, often, a bunch of them -- e.g., all lines up to the first empty one, included) gets read *and processed*, *once*. Then, if appropriate, after the first piece has set up stuff, "the rest" gets read and processed. In other words, the read-the-first-piece part does not leave you with an already-read beginning-of-the-rest ready to be processed before further reading, in all such cases. When it does (the read-item that tells you the first-piece is finished is not a separator/terminator token, but is already the beginning of the-rest), then you do have an input structure that may lend itself to your favourite idiom (although in some cases, pushing the inappropriate item back to be pseudo-reread next is also a very useful idiom). But then, the semantic role of the reading in the two places differs. If you pre-test, transform, &c, the line just read, you will probably do it in different ways for the prologue and the main-body. E.g., consider: line = f.readline() while we_are_in_headers(line): process_as_headers(line) line = f.readline() while we_are_in_main(line): process_as_main(line) line = f.readline() i.e., we're now reading-next-line in *three* places. While the different things we're doing are *two*. Our code's structure does not ideally reflect its internal logic; once again, the initial readline stands out as an artificial construct. We can restore the balance, and regain simplicity, with a little bit of abstraction. Maybe a bit too extreme, but sort of nice, for example: headers = Filter(f, we_are_in_headers, process_as_headers) while headers.more(): headers.next() main = Filter(f, we_are_in_main, process_as_main) while main.more(): main.next() Of course, there's no need for the while loops and the more and next methods of the Filter class, which in fact could perfectly well be a function and just do everything itself. So, our main code can become: process(f, we_are_in_headers, process_as_headers) process(f, we_are_in_main, process_as_main) utterly simple; and the function process loops just once, readline's in just one place, and has all the simplicity one could wish...: def process(file, testfun, procfun): while 1: line=file.readline() if !testfun(line): return procfun(line) ...well, all the simplicity except one little detail: we _again_ have the "while 1:" idiom!-) > Additionally, this overly simplistic programming style would be completely > inadequate for most involved programming tasks. The most involved tasks have the most ferocious need for an extremistic pursuit of simplicity. The unpleasant issue of the "extra initial readline" should, IMHO, rankle even more if the actual task looms pretty complicated, because we surely _don't_ need extra complication when the tasks itself supplies a lot. Python has just about the right degree of _sophistication_ to let me refactor things until they are satisfactorily _simple_... ...and among simplicity's cornerstones, "code each [different] thing ONCE", i.e., "in ONE place", stands pretty high indeed. Alex From cfelling at iae.nl Tue Jul 25 20:10:30 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 26 Jul 2000 02:10:30 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <8lla9m$hfd$1@animus.fel.iae.nl> Hai Math-lovers, Very interesting discussion sofar, and clearly heading into something nice and pythonic now. Huaiyu Zhu wrote: > On Mon, 24 Jul 2000 20:34:40 GMT, Tim Hochberg wrote: > It seems that @op is no better than ~op in every aspect. > So let's drop these as well. And we are left with only > ~op > As a non-math Pythonier I've been reluctant to enter this debate, though I've been planning to propose and <.some_alfanumeric_opt> on me own. But fortunately others did, ofcourse without the proper (that's mine:) arguments. So here I go: (opt) looks to me as some expression on operators, not as a simple operator. looks like an operator and was defenitely my favorite, until Huaiyu showed us <->. It still looks like an operator, but not aka some minus but aka some equivalence function or what have you. A big minus:( I would feel sorry if more of those wierd symbols would enter Python. In fact the reason I now favour ~opt is that that might open the way to get rid of those ugly bitwise operator symbols using ~ as a generic 'element/bit-wise' prefix: | becomes ~or, ^ becomes ~xor, & becomes ~and, and ~ becomes ~not, reading like bitwise or, bitwise xor etc. Much easier to remember but for ~not, besides thanks to the prefix ~ there is no need for a new xor-keyword. And as ~ is never used on its own anymore, it's bound to be easier on the eyes in visual parsing of expressions, and definitely better then (see below) > a ~add b < c > a b < c And now that w've got 'better' bitwise operator symbols we could use ^ to mean 'to the power of' (like I always think if I forget to look it up:) and we could use | or ~| to mean 'solve' (whatever that means). One last thingy, the use of a leading dot in the alfanumeric opt in ~.opt to me indicates clearly that that infix-operator has to be a method of one of the arguments involved. I hope I'm not making a fool of myself again, and please forgive my typos, I'm a dyslectic on holidays and don't have a dictionary at hand. -- groetjes, carel From aahz at netcom.com Tue Jul 25 08:53:36 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Jul 2000 12:53:36 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> <8lk1ee$71q$1@slb6.atl.mindspring.net> Message-ID: <8lk2kg$kbv$1@nntp9.atl.mindspring.net> In article , Neil Hodgson wrote: >Aahz Maruch wrote: >> Neil Hodgson wrote: >>> >>> Your version numbering is a little out of date - 1.6 will be released in >>> ... >> >> Your version numbers are also a little bit out of date. 1.6 has been >> renamed to 2.0 with the departure of the core Python team from CNRI to >> BeOpen. > > Nope - its a real soap opera now with 1.6 produced by Guido for CNRI and >then 2.0 from BeOpen. And the license to be included with 1.6 sucks because >its much longer and more complex although it probably won't make that much >difference in practical terms. Yes, I know about the soap opera. The fact remains that 1.6 will almost certainly never be a released chunk of code -- it never had a beta! It's also true that the 2.0 released from BeOpen (once the soap opera ends) will almost certainly be based primarily on the 1.6 code base. So it's reasonable to simply say that 1.6 has been renamed to 2.0 -- and in fact, that's what Guido Himself does: http://www.pythonlabs.com/tech/python16.html -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From db3l at fitlinxx.com Mon Jul 24 14:43:35 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2000 14:43:35 -0400 Subject: the right way of handling **args for __init__ and other methods References: <8lhlfg$sk5$1@news.kth.se> <397C6BD8.CF87E01@roguewave.com> Message-ID: Bjorn Pettersen writes: > Since args looks to be always empty when argdict != None, you can say > > args.update(argdict) If in fact the use of args and argdict are mutually exclusive and argdict is only around for passing on from __init__ then it would seem that you could also just re-assign args, e.g.,: if argdict: args = argdict (although I think the apply() approach is probaby cleaner since it avoids the use of the extra argument to read()). -- -- 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 stephen_purcell at yahoo.com Sat Jul 15 06:33:44 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sat, 15 Jul 2000 10:33:44 -0000 Subject: '"""' and linefeed characters In-Reply-To: Message-ID: <8kpem8+spj8@eGroups.com> Matthew Cline wrote: > I'm assuming that returns in a '"""' quoted string are given > the linefeed character(s) of the operating system Python is > run on. Is this right? Not exactly. The linefeed character(s) will presumably be whatever is in the source file itself. So, if you take a python source file in UNIX text format ('\n' line separators) containing a multi-line doc string, run that file on a Windows machine, the line separator in the doc string will still be '\n' and not the usual Windows '\r\n'. (I'd be alarmed if I'm wrong about this, but it wouldn't be the first time.) -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From olivierS.dagenaisP at canadaA.comM Tue Jul 25 12:58:44 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Tue, 25 Jul 2000 16:58:44 GMT Subject: Comparison of strings and integer References: <8lkfhs$pav$1@pollux.ip-plus.net> Message-ID: <8Hjf5.25413$Gh.363352@news20.bellglobal.com> I think Python compares the names of the types when you compare two objects of different types. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Franz GEIGER" wrote in message news:8lkfhs$pav$1 at pollux.ip-plus.net... > Still not very experienced in programming Python I recently compared > accidentially a string variable with an integer variable. Python did it his > way, which was not my way: I expected a conversion like Perl does or a > runtime error like REBOL does. Is there any way to prevent Python from doing > so? > > Python: print "1" > 1 --> 1 > > Perl: print not ("1" > 1); --> 1 > > REBOL: print "1" > 1 --> > ** Script Error: Expected one of: string! - not: integer!. > ** Where: print "1" > 1 > > Many thanks in advance and best regards > Franz GEIGER > > From julesk24 at my-deja.com.bbs Mon Jul 17 09:00:03 2000 From: julesk24 at my-deja.com.bbs (julesk24 at my-deja.com.bbs) Date: 17 Jul 2000 13:00:03 GMT Subject: Reading asynchronous data from a serial device Message-ID: <3bRCd4$kKH@openbazaar.net> I am attempting to write a program (to run on a linux box) in python which communicates to a device via a serial port. The problem is that the device is not reliable in responding when expected. Therefore, I have many reads timeout. I am relatively new to the world of multiple threads so I am probably making many mistakes. My current approach is to use a separate thread for the read and then to join() the thread back into the main thread if the read is not sucessful within the given amount of time. The end result is hundreds of hung processes and an eventual segmentation fault (the program needs to be designed to run for days). My questions are: 1) Is there any (easy) way for me to cause the thread to exit (not just join the processes) after a timeout on a read? 2) Is there a better way of reading for data (without starting my own thread for the read process and then trying to exit out of the thread after a period of time)? I have read through the newsgroups, but I haven't found anything which specifically answers my questions. Thanks to anyone who can answer my questions! Julie Kempton jmk11 at duke.edu Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Sun Jul 9 23:43:45 2000 From: aahz at netcom.com (Aahz Maruch) Date: 10 Jul 2000 03:43:45 GMT Subject: Static member variables References: <8kahdq$5e2$1@zingo.tninet.se> <963176664.23519426@news.libertysurf.fr> Message-ID: <8kbgph$afj$1@nntp9.atl.mindspring.net> In article <963176664.23519426 at news.libertysurf.fr>, Jerome Quelin wrote: > >And is it possible to have a static method (ie, a class method in C++ >jargon) ? Nope. The standard answer is to stick the class in its own module and create module-level functions that access class variables. Wish I'd known that earlier; I created a hack that saves an instance of the class..... -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From db3l at fitlinxx.com Wed Jul 19 21:38:28 2000 From: db3l at fitlinxx.com (David Bolen) Date: 19 Jul 2000 21:38:28 -0400 Subject: iterating over lines in a file References: Message-ID: nobody writes: > could somebody enlighten me, please? and is there any easier way to > iterate over lines in a file without resorting to ugly break statements? Not without duplicating your actual I/O operation (the only real way to avoid a break is to compare the current I/O within the expression of the loop, so you have to load a value to check both prior to the loop and then within the loop for the next cycle). The basic Python approach to iteratiing over a file would be: while 1: line = file.readline() if not line: break (... operations to perform ...) Yes, it has a break in it (although I personally don't consider 'break' ugly - break and continue are often the most elegant way to handle flow), and yes, it seems clumsy to those of us used to assignments within expressions, but its the sort of thing you just acknowledge and move on - it's really not that big a deal. The class you found wraps things up a bit, and effectively hides the assignment within the class, so you can use the direct expression approach in your higher level code, but that's about it. There's also a FAQ on this common question, available at: http://www.python.org/doc/FAQ.html#6.30 -- -- 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 olivierS.dagenaisP at canadaA.comM Wed Jul 19 20:46:09 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Thu, 20 Jul 2000 00:46:09 GMT Subject: Making Windows GUI programs References: <8F776CE84nickperkinsusanet@203.2.75.243> Message-ID: I recommend wxPython ( www.wxpython.org ) http://www.faqts.com/knowledge-base/view.phtml/aid/3565/fid/473 -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Nicko" wrote in message news:8F776CE84nickperkinsusanet at 203.2.75.243... > Hi. I was wondering if anyone could point me in the direction of some GUI > help for windows. I would like to write a program using the windows API > set, but the help file that came in the win32all package doesn't make any > sence to me. If someone can point me in the direction of maybe a tutorial > or a nice document that can help, I would be greatful > > Thanks in Advance, > Nick Perkins From bjorn at roguewave.com Thu Jul 6 13:47:33 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 06 Jul 2000 11:47:33 -0600 Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> <3963E6D6.F47FA4D8@roguewave.com> <3964BC64.761858FA@bioeng.ucsd.edu> Message-ID: <3964C635.E730EB97@roguewave.com> Curtis Jensen wrote: > > Bjorn Pettersen wrote: > > > > What you're seeing are the symptoms of Python having thrown an exception > > and the weblog not capturing all the information. The solution is to make > > sure Python can only throw where you can grab the exception and do > > something useful with it, like printing it to the browser... Try the > > following (but make sure you can execute it from the command line first -- > > one possible error is a SyntaxError, which this scheme will not save you > > from...) > > > > -- bjorn > > > > #!/usr/bin/env python > > print """Content-type: text/html > > > > """ > > > > def main(): > > from time import * > > > > print "" > > print "" > > print "Hello World" > > print "" > > print "" > > print "

Hello World !

" > > print "
" > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > > > print "" > > print "" > > > > import traceback > > > > def execute(fn): > > # make sure any errors are legible, and directed to the user. > > try: > > sys.stderr = sys.stdout > > fn() > > except: > > print '

Something went wrong!!!

' > > print 'Please send the transcript below to webmaster at your.web

' > > print '\n\n

'
> >         traceback.print_exc()
> >
> > execute(main)
> >
> 
> I tried this.  I got the same errors in the log and in the browser.  I
> took out the print line since it caused a discussion.  Any more
> suggestions?  Thanks.

You do need the print line! The first thing your cgi must print out
(modulo cookies) is "Content-type: text/html" followed by exactly two
newlines (yes, I know there are situations where this isn't true, but in
this case it is.. )

Check that:

 - your script is executable (by everyone)
 - some webservers require a .cgi extension (a symbolic link to your .py
will work)
 - python is where you think it is, and is executable (again by
everyone)
 - your webserver is set up to execute cgi scripts.

If all that works, try the simplest possible cgi script, something like:

#!/usr/local/bin/python
print  """Content-type: text/html

"""
print '

hello world

' hth, -- bjorn From didier.willame at ieee.org Fri Jul 14 08:53:24 2000 From: didier.willame at ieee.org (Didier WILLAME) Date: Fri, 14 Jul 2000 12:53:24 GMT Subject: Local CGI programming Message-ID: <396F0F28.7C8B8B83@ieee.org> Hello all, I need to call a CGI python script with my web browser, on my WIN NT station (local hard drive). To test this, I have written the following script. But the new page (built by the python script) is not diplayed by the web browser! Is a http service needed to perform this test? If yes, what minimal product propose you? If no, what is the error? Thank you for your time, Didier -- C:\temp\user.html --
enter data:
-- C:\temp\cgi-bin\user.py -- import cgi def go(): form = cgi.FieldStorage() print 'Content-type: text/html\n' print '' print '' if form.has_key( 'data' ) and form[ 'data' ].value != '': print '

The data are: ', form[ 'data' ].value, '

' else: print '

Error! Please enter data.

' print '' if __name__ == '__main__': go() From kpmurphy at my-deja.com.bbs Mon Jul 17 15:40:05 2000 From: kpmurphy at my-deja.com.bbs (kpmurphy at my-deja.com.bbs) Date: 17 Jul 2000 19:40:05 GMT Subject: Grid Geometry Manager and grouping? Message-ID: <3bRNB5$km0@openbazaar.net> richard, what i'm trying to do is create my own widgets. once i make one, i'd like to be able to grid it. each of my widgets will have multiple items in it (ex. label and an entry ==> myWidget) and then i would place multiples of myWidget together. i like the grid manager because i can put things exactly where i want them. can you do a grid inside a frame, then grid multiple frames toghether? thanks, -->keith In article , "richard_chamberlain" wrote: > Hi Keith, > > For what purpose do you want to group the areas? > > An example of frames: > > from Tkinter import * > root=Tk() > frame1=Frame(root,relief=GROOVE,borderwidth=3) > frame2=Frame(root,relief=GROOVE,borderwidth=3) > for i in range(1,9): > Label(frame1,text="Frame: 1 - Label: %d" %i).pack() > Label(frame2,text="Frame: 2 - Label: %d" %i).pack() > frame1.pack(side=LEFT,fill=BOTH,expand=1) > frame2.pack(side=LEFT,fill=BOTH,expand=1) > > root.mainloop() > > Pmw has got Pmw.Group, a framed widget on which you can have a label or > other widget in the frame and then a number of widgets within the frame. > > Give me an example of what you want to achieve and I'll have a go. > > Richard > > Keith Murphy wrote in message > news:8k013q$lon$1 at nnrp1.deja.com... > > i've found that i like grid the best. is there a way to group sections > > of the window together... like the left side is for one purpose and the > > right for another? I have been playing with frames to no avail. > > > > i really appreciate all the help this ng has given me thus far in > > learning python. kudos to all of you! > > > > -->keith > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Mon Jul 17 21:34:20 2000 From: db3l at fitlinxx.com (David Bolen) Date: 17 Jul 2000 21:34:20 -0400 Subject: Getting local IP address... References: Message-ID: Mike Fletcher writes: > import socket > def getLocalHostIP( remote = ("www.python.org", 80)): > '''Get the "public" address of the local machine, i.e. > that address which is connected to the general internet. > Code by Donn Cave, posted to comp.lang.python''' > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect( remote ) > ip, localport = s.getsockname() > s.close() > return ip > > That is actually from a Deja posting, seems to be fairly portable, doesn't > rely on parsing obscure Unix command responses, is readable, and is > generally quite reliable. But has a pretty large (IMHO) negative that you are making a wasted network connection to an external server that has to spend time setting up and tearing down TCP with you for no reason. That seems a pretty high overhead to pay just to determine what is essentially a locally configured piece of information. If you are in charge of your own server that you are using I suppose that's one thing, but it seems a big waste if you're connecting to someone else's. Unfortunately, really determining a local configured address just isn't that portable a thing from my experience. Probably the closest would be the SIOCGIFCONF IOCtl (for Unix systems) as previously posted. There is an Windows socket IOCtl that is similar (SIO_ADDRESS_LIST_QUERY), but I'm not sure how best to get to it from Python, aside from something like a CallDLL approach. While without an alternative that is portable as the above example makes it hard to come out too strong against it, I did want to point out that while it may be portable and readable, it has negatives on the network side in terms of wasted connections. I built backbones in a prior life, and I sort of cringe to think of tons of user code suddenly starting to do stuff like the above :-) -- -- 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 jhe at webde-ag.de Fri Jul 7 12:58:09 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Fri, 7 Jul 2000 18:58:09 +0200 Subject: Comparing 2 class types References: Message-ID: <8k5243$1gc$1@pollux.ip-plus.net> "Arint?" schrieb im Newsbeitrag news:L2k95.37383$NP5.1176274 at newsread2.prod.itd.earthlink.net... > How can you know if a 2 variables are different instances of the same class? > x = someclass() > y= someclass() > I tried is, type, and type(x) is someclass, but none seem to work unless I > did it wrong. >>> class x: pass ... >>> spam = x() >>> eggs = x() >>> spam <__main__.x instance at 80bfa0> >>> spam.__class__ >>> spam.__class__ is eggs.__class__ 1 >>> isinstance(spam, eggs.__class__) 1 From wolfgang.thaemelt at orsoft.de Mon Jul 3 08:41:26 2000 From: wolfgang.thaemelt at orsoft.de (Wolfgang Thaemelt) Date: Mon, 3 Jul 2000 14:41:26 +0200 Subject: lambda requirements Message-ID: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Running the script: #----------------------------------------- begin of script def SymmetricDifference(list1, list2): # global _list1 # global _list2 _list1 = list1 _list2 = list2 _onlylist1 = filter(lambda x: x not in _list2, _list1) return _onlylist1 if __name__ == '__main__': a = [1,2,3,4,5] b = [3,4,5,6,7] x = SymmetricDifference(a,b) print x #---------------------------------------- end of script gives the error: Traceback (innermost last): File "E:\up\000701\symmdiff.py", line 16, in ? x = SymmetricDifference(a,b) File "E:\up\000701\symmdiff.py", line 9, in SymmetricDifference _onlylist1 = filter(lambda x: x not in _list2, _list1) File "E:\up\000701\symmdiff.py", line 9, in _onlylist1 = filter(lambda x: x not in _list2, _list1) NameError: _list2 If the comment characters "#" are removed from the "global" statements everything works fine. Is there some requirement on a lambda violated in the script? Thanks Wolfgang Thaemelt OR Soft Jaenicke GmbH Geusaer Str., FH Geb. 106 06217 Merseburg Germany ====================================== Email: wolfgang.thaemelt at orsoft.de Voice: +49-3461-549033 Fax: +49-3461-549022 From fiona at sitegnome.com.bbs Wed Jul 12 06:10:03 2000 From: fiona at sitegnome.com.bbs (fiona at sitegnome.com.bbs) Date: 12 Jul 2000 10:10:03 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 12th, 2000 Message-ID: <3bNCgU$oC5@openbazaar.net> Greetings, Here are the latest entries to be entered into http://python.faqts.com regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How do you read from / write to the system clipboard from Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/4668 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain I presume that you want to paste or copy into or out of an entry or text, these widgets already have copy and paste keystrokes assigned to them (at least they do on windows). So I can do Control-c and that copies it into the clipboard and Control-p pastes it. so: from Tkinter import * root=Tk() text=Text(root) text.pack() root.clipboard_clear() root.clipboard_append('python rules!') def paste(event): text.event_generate('') text.bind('',paste) root.mainloop() In this example we append your 'python rules!' to the clipboard and then wait until the text control gets the focus and then we generate a event to paste the contents in. ------------------------------------------------------------- What's the Python equivalent for C's #include "myfile.h"? http://www.faqts.com/knowledge-base/view.phtml/aid/4669 ------------------------------------------------------------- Fiona Czuczman Rainer Deyke, Matthew Schinckel The standard substitute is: >>> import myfile or >>> from myfile import * However, this is not quite equivalent to #include. If you really need behavior identical to #include, you could try the following: exec open("myfile.h").read() ------------------------------------------------------------- How can I enumerate drives (local and network) in Python? http://www.faqts.com/knowledge-base/view.phtml/aid/4670 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain On Win32 you can use: import win32api,string drives=win32api.GetLogicalDriveStrings() drives=string.splitfields(drives,'\000') print drives GetLogicalDriveStrings returns a string with each drive null terminated so you can use the string module to separate them into a list. There is also a win32api.GetLogicalDrives() which returns a bitmask where each bit represents a drive letter, so 1101 (or 13 in decimal) would represent (going from right to left) a:\,c:\ and d:\. ------------------------------------------------------------- What is the difference between the calls PyObject_GetAttr and PyObject_GetAttrString? http://www.faqts.com/knowledge-base/view.phtml/aid/4671 ------------------------------------------------------------- Fiona Czuczman Thomas Wouters PyObject_GetAttrString takes a PyObject pointer and a char pointer, whereas PyObject_GetAttr takes two PyObject pointers: the second argument should be a PyString, which is then turned into a char pointer (using PyString_AS_STRING) and passed to PyObject_GetAttrString. ## Edited Entries ############################################## ------------------------------------------------------------- How can I create a stand alone "win32" executable file from a python script? Is a compiler available anywhere for python for win32? http://www.faqts.com/knowledge-base/view.phtml/aid/3111 ------------------------------------------------------------- Fiona Czuczman Daley, MarkX http://starship.python.net/crew/gmcm/index.html This link will provide you with a pretty good wrapper that gives you a one-file installer executable. I'm pretty sure it's win32. From perry at eclipse.stsci.edu Thu Jul 20 13:17:52 2000 From: perry at eclipse.stsci.edu (Perry Greenfield) Date: 20 Jul 2000 17:17:52 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> Message-ID: <8l7c80$mlc$1@tomm.stsci.edu> We are planning to use Numeric (or its future equivalent) heavily for our software. One thing we would strongly object to is making matrix operators the default. The vast majority of our manipulations (on images and spectra) involve elementwise operations. This would be consistent with what most astronomers would expect (and how IDL--currently the most commonly used array-based language in the astronomical community by far--handles it). Use of parentheses for matrix operators that Konrad Hinsen proposed appears to be the best solution I've seen so far. But perhaps the two camps won't be able to agree which should be the default, in which case there should be two different modules based on the same Numeric core with different operator mappings previously suggested. I don't necessarily see that a lack of agreement on this issue should prevent adding the new operators to Python as long as everyone agrees with the operator syntax. But adopting one scheme (ours of course :-) would certainly be best. Perry Greenfield From see at my.signature Sun Jul 9 22:14:33 2000 From: see at my.signature (Greg Ewing) Date: Mon, 10 Jul 2000 14:14:33 +1200 Subject: Namespace Mystery (HELP!) References: <39655351.9EE499F2@sunesis-pharma.com> <39656345.86AADA8A@prescod.net> <39660D24.63BE61D3@sunesis-pharma.com> Message-ID: <39693189.E5BE8C6@my.signature> If you're devious enough, it can be done (warning, trying to understand how this works may cause brain explosion): def spam(): my_globals = {} parrot = 'alive' cmd = "global g; g = 42; parrot = 'resting'" exec "exec cmd in my_globals, locals()" print my_globals['g'], parrot -- 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 rob at hooft.net Wed Jul 19 06:00:37 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Wed, 19 Jul 2000 12:00:37 +0200 (CEST) Subject: Toplevel "test()" functions in standard library In-Reply-To: References: Message-ID: <14709.31813.259826.332843@temoleh.chem.uu.nl> >>>>> "MZ" == Moshe Zadka writes: >> Going one step further: Should all of these "test()" and "_test()" >> routines be in the code library at all, even now that we have a >> complete test engine? MZ> Yes! This is a preliminary test, which should be available to MZ> every user of the library. If you're optimizing the few KB it MZ> takes, then you're not using Python correctly. If that is the common opinion or the opinion of our Ruler, I will subtract my proposal, and submit a bug report that those test() routines are undocumented. As a reply to your last sentence I can add that my own programs can use up to 200MB of memory during normal use, or much more if you really stress them. Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From olipt at mayo.edu Sat Jul 22 12:30:53 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Sat, 22 Jul 2000 11:30:53 -0500 Subject: Discussion: new operators for numerical computation In-Reply-To: References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: > ----------------------------------------------------------------------- > > Proposal two, which for lack of a better name I'll call Konrad's proposal: > > New Operators: (+), (-), (/), (*)[outer], (.)[dot], (|)[solve], (^)[power] > > NumPy and MatPy would have that same syntax: the new operators correspond to > matrix operations in both MatPy and matrix operators in NumPy. > > Given these two basic proposals, I strongly prefer Konrad's. I think > the syntax is more evocative of matrix operations. From the tone of > other post on this syntax, this syntax seems to be accepted, perhaps > even prefered, by most most people. I also am strongly a proponent of > the syntax of various Numeric packages being a similar as possible. In > this case NumPy and MatPy. > I strongly prefer this syntax as well for any new operators, for the same basic reasons. We could use (!) for solve and (**) for power (actually I'm not as convinced that we NEED a solve. But...) . This might assuage some purists in python-dev. I think it's useful to keep in mind tht we are not just attracting Matlab users, but IDL, PyWave, J, and other's as well. -Travis From Cedric.Lefeuvre at tcomhp43.epfl.ch Tue Jul 11 17:54:13 2000 From: Cedric.Lefeuvre at tcomhp43.epfl.ch (Cedric Lefeuvre) Date: Tue, 11 Jul 2000 23:54:13 +0200 Subject: Glade Message-ID: <396B9784.191A513D@tcomhp43.epfl.ch> Hello! I am a beginner for python and i want to know somethings about Glade..... 1...Is there a good documentation because i didn't succeed in finding one in the official site. 2...What is the capacity of Glade..I mean it seems to be easy to create static windows but is there the possibility (in the way to show results of some applications) for example to change the size of a tree or a a table.... thanks PS...if you can answer by email...it would be easier for me... -- C?dric Lefeuvre SUPAERO 2A-Stagiaire EPFL 0041 (0)21 693 26 16 http://eleves.supaero.fr/page-perso/promo_01/lefeuvre/ Fax: 0041 (0)21 693 26 83 _ _ _/_ _ ( (-(// /( -------------- next part -------------- An HTML attachment was scrubbed... URL: From MarkH at ActiveState.com Sat Jul 1 09:35:32 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 01 Jul 2000 13:35:32 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: Just to stoke the flames a little... Check out some of the talks at the upcoming PDC - http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python :-) Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! From scarblac-spamtrap at pino.selwerd.nl Tue Jul 4 09:15:50 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 4 Jul 2000 13:15:50 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: Neo Brave wrote in comp.lang.python: > In article , > "Mark Hammond" wrote: > > Under Windows NT or Win2k, you can use the PATHEXT environment > > variable. Simply add ".py" to the semi-colon sep'd list of > > extensions, and off you go! > > Great, thats a help for NT, but I also want to do this on Win98 :-). There is another trick (originally by Bruce Eckel). Name your Python file ".bat" instead of ".py" and use the following hack: @echo off rem = """ rem Run python on this bat file. Needs the full path where rem you keep your Python files. The -x causes Python to skip the first rem line of the file: python -x c:\python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofpython rem """ # The Python program goes here: print "hello, python" # For the end of the batch file: rem = """ :endofpython rem """ Or just make a .bat file that goes with your .py file and calls python for it... -- Remco Gerlich, scarblac at pino.selwerd.nl 3:12pm up 120 days, 3:25, 5 users, load average: 0.33, 0.29, 0.20 From olipt at mayo.edu Sat Jul 22 12:32:48 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Sat, 22 Jul 2000 11:32:48 -0500 Subject: Discussion: new operators for numerical computation In-Reply-To: <8laptf$4mo@stochastic.eng.umd.edu> References: <8l8dmd$4p0@stochastic.eng.umd.edu> <8laptf$4mo@stochastic.eng.umd.edu> Message-ID: > > And while we're pondering reimplementaions, it might be cool to move > as much non-performance-critical code as feasible up into a Python > layer to ease synchronization between [C/J/IL?/???]Numeric. The top > layer would be shared, and only the core would be in whichever > low-level language. > This is exactly what I'm doing right now with the help of about 2 other people (whomever wants to help is welcome to join us). It's called numpy2 and is available on the CVS tree at SourceForge under the same module name in the Numeric project. Quite a few of the details are already fleshed out. We need some C coders at this point. -Travis From alex at magenta.com Sat Jul 29 08:07:17 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 14:07:17 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <8lla9m$hfd$1@animus.fel.iae.nl> Message-ID: <8luhsp51ce8@news2.newsguy.com> "Huaiyu Zhu" wrote in message news:slrn8o42dq.1cq.hzhu at rocket.knowledgetrack.com... [snip] > >| becomes ~or, > >^ becomes ~xor, > >& becomes ~and, and > >~ becomes ~not, reading like bitwise or, bitwise xor etc. > > This would indeed be an excellent option if not for backward compatibility. [snip] > FLAG = bitwise.or(FLAG1, FLAG2, FLAG3, FLAG4, FLAG5, FLAG6, FLAG7, FLAG8) What an EXCELLENT idea. shift left/right could also be packaged that way (or, almost so; 'or' is a reserved words in Python...). > quite "unpythonic" to let them occupy four unique ascii characters as Agreed, and worse if you consider << and >>. > Furthermore, unlike math operators, unless you are designing a logical > circuit, it is rare to construct complicated formulas with these operators. > So brevity is really not important for them. The 'bitwise' module could supply easily explicit bitfield-extraction in place of the mask-and-shift idioms, too. Oh well -- maybe a hint for Python 3000, when backwards compatibility can be broken...! Alex From greg at perceval.be Fri Jul 14 04:37:31 2000 From: greg at perceval.be (Gregoire Welraeds) Date: Fri, 14 Jul 2000 10:37:31 +0200 (CEST) Subject: getpid Usage In-Reply-To: <8kksms+n5h5@eGroups.com> Message-ID: In reply to the message of david at tumbleweed.com sent on Jul 13 (see below) : You should have a look at the os.fork() function which is python "translation" of the fork system call (availability Unix). It lets you create a new process (a child process) from the current one (called the parent process). The child process execute the same than the parent process. Thus, you have two processes, executing the same code. The fork() function return 0 in the child process and the id of the new created process for the parent process. See the following example: import os i= os.fork() # Create the new process if i != 0: # If i != 0, we are in the parent process print 'Forked process as the pid : ', i else: # We are in the child process os.system('ls -la') hope-I-have-been-clear-enoughly-yours, Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Thu, 13 Jul 2000 david at tumbleweed.com wrote: > Date: Thu, 13 Jul 2000 17:02:20 -0000 > From: david at tumbleweed.com > To: python-list at cwi.nl > Subject: getpid Usage > > Is there some convenient way of getting os.getpid to return the PID of > a given executable? What I want to do is start a process and know it's > PID. When I do the following I get the PID of the python executable. > > os.system("path") > os.getpid() > > Alternatively, as a hack, I am doing: > os.system(self.m_server_start_exe) > for line in os.popen("ps -ef | grep -i IMEController | awk '{ if (NR > > 1) { print $2 }}'").readlines(): > pid = line[:-1] > > I would rather just path in an executable name/pathname and have it > return this process' pid. Is there an updated version of os.getpid I > could use to do this. If not, is there a better solution that is not > shell dependent? > > Thanks, > David > > > > -- > http://www.python.org/mailman/listinfo/python-list > > From spamfranke at bigfoot.de Sat Jul 1 13:42:53 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sat, 01 Jul 2000 17:42:53 GMT Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <395e2ca2.4792092@news.btx.dtag.de> A simple out-of-the box solution if win32all is installed on both machines: The PythonWin package by default registers a Python.Interpreter COM server, which you can start up via DCOM on any remote machine. Once started, you can execute any Python commands as strings. /s From nobody at nowhere.nohow Fri Jul 28 21:38:26 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:38:26 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <20000729085800.D15002@inkontact.com.au> Message-ID: In article <20000729085800.D15002 at inkontact.com.au>, Steve Purcell wrote: >Steve Lamb wrote: >> >> [snip] I think I've been at least fair to Python, >> all things consider. I really do like the language, I guess I was just hoping >> too much from the people. > >Hey, I resemble that remark! (a favourite pun I stole from a friend) Groucho Marx was a frind of yours? Cool. He kills. Just remember: you say it you've got to waggle your cigar and roll your eyes at the camera... BTW, it's a probably more of a malapropism than a pun. -- Grant Edwards grante Yow! ... the HIGHWAY at is made out of LIME visi.com JELLO and my HONDA is a barbequeuedOYSTER! Yum! From samschul at pacbell.net Fri Jul 7 15:09:32 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Fri, 07 Jul 2000 19:09:32 GMT Subject: How do I ring the bell? References: <8k2lcd$59v$1@gossamer.itmel.bhp.com.au> Message-ID: <8k59t7$1vt$1@nnrp1.deja.com> If you are working under Windows see these routines. Then contain an example on how to call into kernal32.dll http://www.nightmare.com/~rushing/dynwin/ Sam Schulenburg In article <8k2lcd$59v$1 at gossamer.itmel.bhp.com.au>, "A J Wilson" wrote: > Hi > > I would like to ring the PC's bell (ie internal speaker) to alert the > operator that an operation has finished running. How do I do this in my > python program? > > Thanks > Austin > > Sent via Deja.com http://www.deja.com/ Before you buy. From mbel44 at dial.pipex.net Tue Jul 25 07:20:58 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 25 Jul 2000 12:20:58 +0100 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> Message-ID: Paul Prescod wrote: >http://python.sourceforge.net/peps/pep-0213.html > >PEP: 213 >Title: Attribute Access Handlers >Version: $Revision: 1.3 $ >Owner: paul at prescod.net (Paul Prescod) >Python-Version: 2.0 >Status: Incomplete >Proposed Implementation > Property fetching > > At the layer, Python instance attribute lookup is always done > through PyInstance_getattr. > > A "get" proceeds as usual until just before the object is > returned. In addition to the current check whether the returned > object is a method it would also check whether a returned object > is an access handler. If so, it would invoke the getter method > and return the value. How does PyInstance_getattr know that an object "is an access handler" I can see some cases where it would be appealing to implement a property access handler in a C extension. Is it worth dedicating a slot in PyTypeObject for these things? Toby Dickenson tdickenson at geminidataloggers.com From stephen_purcell at yahoo.com Tue Jul 4 08:34:53 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 04 Jul 2000 12:34:53 -0000 Subject: Performance In-Reply-To: <39619175.5F8B503D@proceryon.at> Message-ID: <8jslld+s3p0@eGroups.com> Horst Gassner wrote: > The following function is one of the slower ones and I would be happy if > there are any possibilties to speed this thing up. > > subItems = {} > if s.__subList[level] : > for key in s.__subList[level].keys (): > # root level is special case! > # get all sublevels without recognizing id of sublevel > if level==0 or string.find(key, id) == 0 : > subItems[key] = s.__subList[level][key] How about: subItems = {} if s.__subList[level]: for key,value in s.__subList[level].items(): if not level or not string.find(key,id): subItems[key] = value -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ "Life must be simple if I can do it" -- Me From cookedm at physics.mcmaster.ca Mon Jul 17 17:39:33 2000 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: 17 Jul 2000 17:39:33 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> Message-ID: At some point, hzhu at localhost.localdomain (Huaiyu Zhu) wrote: > On Mon, 17 Jul 2000 14:12:02 -0500, Paul Prescod wrote: > > >Maybe you should consider how to scale back your syntactic request. > >Perhaps a single keyword or symbol at the beginning of an expression > >could make it element-wise or matrix-wise. > > Well, that would be fine if it is workable, ie, when they don't appear in > the same expression. > > Consider the proposal of having two classes, Matrixwise and Elementwise, > with methods to cast to each other. I don't know why > > (a.E()*b.E()).M()*(c.E()*d.E()).M() > > would be more preferable to > > (a.*b)*(c.*d) Well, it doesn't have to be as complicated as your first example. Assume the default is Matrixwise, and we get rid of some ()'s by overriding __getattr__, so that we can right (a.E*b.E)*(c.E*d.E) Better? It's not great, you have to remember to put .E on both. Ahh! But what if we assume that if one operand has .E, the other does also! Then we can write (a.E*b)*(c.E*d) which is two characters more than your second example. -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From thomas at xs4all.net Sat Jul 15 19:20:03 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 16 Jul 2000 01:20:03 +0200 Subject: Neil Schemenauer's GC patch in python1.6? In-Reply-To: ; from robin@jessikat.fsnet.co.uk on Sat, Jul 15, 2000 at 06:30:19PM +0100 References: <396F28A1.A181BF39@email.sps.mot.com> <3dn1jkljwy.fsf@kronos.cnri.reston.va.us> Message-ID: <20000716012003.L7340@xs4all.nl> On Sat, Jul 15, 2000 at 06:30:19PM +0100, Robin Becker wrote: > In article <3dn1jkljwy.fsf at kronos.cnri.reston.va.us>, Andrew Kuchling [ amk explains cycle-GC will be in 2.0, though possibly optionally ] > If GC has finally/nearly made it, what about Chris Tismer's stackless? A different story altogether. I'm sure Christian can give a better explanation that I can, but I believe the main showstopper is the fact it's impossible to implement (currently) in JPython, not to mention future Python compilers. There may be a lot more behind it, though. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From cgrant at medicine.adelaide.edu.au Mon Jul 24 21:51:54 2000 From: cgrant at medicine.adelaide.edu.au (Cliff Grant) Date: Tue, 25 Jul 2000 11:21:54 +0930 Subject: dzheng@medicine.adelaide.edu.au Message-ID: <397CF2BA.A12CBCFE@medicine.adelaide.edu.au> -- ************************************************************************* Cliff Grant Dept. of Anaesthesia and Intensive Care ph: +61 8303 5157 University of Adelaide fax: +61 8303 3909 Adelaide, SA 5005 cgrant at medcine.adelaide.edu.au AUSTRALIA From jkraska1 at san.rr.com Wed Jul 26 01:10:06 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 26 Jul 2000 05:10:06 GMT Subject: conatraints on "for" magic? References: <8llqso$q75$1@news.dtc.hp.com> Message-ID: <397E7350.C44A80AE@san.rr.com> > How did the implementer of the "fileinput" module convince the "for" > construct that fileinput.input() was a sequence? If you implemented an object that implemented all the methods that a sequence implemented (or just the few that the for loop object cared about), would python know the difference? NO. Remember, Python has no real notion of types. C/ From alex at magenta.com.bbs Mon Jul 17 15:20:04 2000 From: alex at magenta.com.bbs (alex at magenta.com.bbs) Date: 17 Jul 2000 19:20:04 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bRMY5$izp@openbazaar.net> "G. David Kuhlman" wrote in message news:8kvdon$tit$1 at slb3.atl.mindspring.net... [snip] > One thing (among many) that I do not understand is how C#Python can > both compile directly to IL (intermediate language?) and produce a > .DLL/.EXE. Does the .EXE contain both an interpreter (VM ?) and > the IL (byte code?) that it interprets? Or does IL mean that the > machine code is in there, but augmented with some meta-information > for debuggers and other tools? Or, what? As I "read between the lines", mostly in the paper (on the MSDN online technical articles library) about Eiffel#, the .NET framework lets IL (bytecode and metadata, or native-code and metadata) be packed into a module (DLL or EXE), and if desired multiple modules may be packed into one (modules may also refer to other modules outside of their 'packaging', but a more self-contained packaging may also be provided if desired). I guess/suspect that Python.NET (or Python# as the case may be) exploits exactly these capabilities of the framework...? Alex From thomas.heller at ion-tof.com Wed Jul 26 05:21:52 2000 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 26 Jul 2000 11:21:52 +0200 Subject: Flex scanner for Python Message-ID: <042901bff6e2$ef7b72f0$4500a8c0@thomasnb> Has someone written a Flex grammar for scanning python code? Thomas Heller From hzhu at localhost.localdomain.bbs Mon Jul 17 21:00:04 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 18 Jul 2000 01:00:04 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRVR4$jS3@openbazaar.net> On 17 Jul 2000 23:19:16 GMT, Gordon McMillan wrote: >I proposed something very similar to Huaiyu the other day: > > PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) > >I know Thomas Wouters did, too. I haven't seen a post reflecting these >suggestions. Good point. So let me say why I do not like this. (Doesn't mean it has to die.) :-) In a program where there are a lot of computations, you'll get either something like a ritual on every line, PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) for what could be (A .* B)\C (A .* B)\C (A .* B)\C or you get PyAlgebra.evaluate(r'(A .* B)\C (A .* B)\C (A .* B)\C', A=A, B=B, C=C) Everybody would rush for the latter. In the end what's inside the quote would be a minilanguage with all the bells and wistles of python. This would be just similar to patching the parser, with lesser results. >In fact, looking at this thread in one of those tree-view newsreaders, it >becomes obvious that branches die when a proposal is made, but arguments >are met with vehement counter arguments. Which leads me to believe that: > >>Silly idea 3: >> >> Lets continue arguing until everyone, both pro and con, gets >> irritated, >>starts calling each other Nazis and gives up. > >...has already won. You got it. I'm making a resolution of not going down that road from now on. Huaiyu From bjorn at roguewave.com Tue Jul 11 18:14:54 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 11 Jul 2000 16:14:54 -0600 Subject: comparing a directory to current dir... Message-ID: <396B9C5E.FCE5F683@roguewave.com> I have a directory (and a filename), and I want to copy the filename from that directory to my current directory. The problem is, I only want to do this if the directories are not equal... I tried the following: if os.path.abspath(os.curdir) != os.path.abspath(directory): shutil.copy( os.path.join(directory, filename), os.curdir ) the problem is that os.path.abspath(os.curdir) contains the drive letter on Windows and os.path.abspath(directory) doesn't. Is this a bug in os.path.abspath? (I can't think of an instance where the current behavior would be useful -- but that could just be lack of imagination ). -- bjorn From neilh at scintilla.org Sat Jul 8 00:27:40 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 08 Jul 2000 04:27:40 GMT Subject: Splitting c.l.py... References: <0007071815170C.03526@quadra.teleo.net> Message-ID: <05y95.10360$Tb7.69463@news-server.bigpond.net.au> > Okay, I've noticed people mentioning 'eff-bot' for awhile now.. and > I have one question. > > What the heck is the eff-bot?! :) The eff-bot is Fredrik Lundh, a very helpful Python user who has for the past few years responded to many requests for help on comp.lang.python. The wide range of subjects covered and the amount of time spent indicate that Fredrik is really a bot rather than human. Some of the eff-bot's knowledge is distilled into http://www.pythonware.com/people/fredrik/librarybook.htm Neil From bugparts at hotmail.com Wed Jul 19 01:19:20 2000 From: bugparts at hotmail.com (bugparts at hotmail.com) Date: Wed, 19 Jul 2000 05:19:20 GMT Subject: Hunters, Shooters README ! 5195 Message-ID: This site is for you ! http://www.ammoman.com Found it while i was browsing and their prices ROCK ! Dont miss the TARGETS PAGE.. VERY COOL IDEA !~ Have a blast ! Regards, Bob cztpjdwwvbiejotgcnpsxodpgwroullwzkdjhrcrytpu From andymac at bullseye.apana.org.au Sat Jul 8 04:41:26 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sat, 8 Jul 2000 18:41:26 +1000 (EST) Subject: Anyone used Python for GPIB instrument control? In-Reply-To: <39668E65.356337BF@home.com> Message-ID: On Sat, 8 Jul 2000 europax at home.com wrote: > I am new to this ng and to Python. I am wondering if anyone has used > Python to control a National Instruments GPIB card on a Windows NT box? > I've searched and found a couple of references on my own. If no other choice offers, it shouldn't be hard to wrap NI's interface library in a Python extension module (though a C compiler would be required) especially with the aid of SWIG. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From thomas at xs4all.net Sun Jul 30 11:32:10 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 30 Jul 2000 17:32:10 +0200 Subject: Calling C Function Pointers from Python In-Reply-To: ; from erwin@andreasen.com on Sun, Jul 30, 2000 at 12:19:23PM +0000 References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> Message-ID: <20000730173210.I266@xs4all.nl> On Sun, Jul 30, 2000 at 12:19:23PM +0000, Erwin S. Andreasen wrote: > > calldll is a low level Python extension libary which contains functions > >for creating buffers, loading DLLs, finding the address of functions within > >the loaded DLLs, and calling the functions. On top of that is a higher level > >windll module that makes it more convenient to call. > Interesting -- it should be possible to create a similar module for loading > shared objects under UNIX and calling functions in those. Although it wouldn't > be that easy, since you would need to find a way to call a function pointer > with a variable number of arguments in C. Look at the 'dl' module in the standard Python distribution. It's not terribly useful, though, for the reasons Neil pointed out: it's easy to abuse, it's easy to mis-use, and as such, most people do not enable it. (I don't, for instance ;) You're usually better off SWIGing the library you wish to interface with. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From olivierS.dagenaisP at canadaA.comM Wed Jul 19 10:29:19 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 19 Jul 2000 14:29:19 GMT Subject: Internet Programming in Python References: <397595A8.A32C8DE7@worldnet.att.net> Message-ID: <3Xid5.135735$HK2.2426013@news20.bellglobal.com> I don't, but I was thinking it might be really nice if the Python books that are going out of print would be available online, in some electronic format. Or are they already available online?? Anybody? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Sean Doull-Connolly" wrote in message news:397595A8.A32C8DE7 at worldnet.att.net... > This book by Guido and others was published in 1996 and is now > out of print. > > Does anyone have a copy in good condition which I might buy? > > Thanks. > > Sean From dworkin at ccs.neu.edu Thu Jul 13 15:20:02 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 13 Jul 2000 15:20:02 -0400 Subject: determining type In-Reply-To: "Mike Mikkelsen"'s message of "Thu, 13 Jul 2000 11:21:26 +0000" References: <396e07fd@news-out> Message-ID: "Mike Mikkelsen" writes: > consider: > >>> a = {'item1': 'hello', 'item2':{'subitem1':'goodbye'}} > Is there a way to tell if 'item2' is a dictionairy, list or simple > value like 'item1'? >>> type(a['item1']) == type({}) 0 >>> type(a['item2']) == type({}) 1 -Justin From thor at localhost.localdomain Sun Jul 16 14:09:53 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 16 Jul 2000 18:09:53 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <8knfco$jsq$1@nnrp1.deja.com> Message-ID: On Fri, 14 Jul 2000 16:33:29 GMT,tgdeveloper at my-deja.com> wrote: >For me the top language constructs, in terms of being useful in daily work >are: > >1. dictionaries > >2. lists / tuples > >3. for item in list: > >4. "blah blah %s blah %d blah" % (word, number) > >5. exception handling (try/except/raise etc.) > >6. the fact that data types can be nested (e.g. a dictionary whose key is a >string and whose value is another dictionary, etc.) > >7. The "traceback" behavior for reporting errors. This makes debugging easy. > This is are the tops language constructs for me. 1. self.whatever 1.5. import whatever 2. The assignation a = b 3. for i in list : 4. return whatever 5. class a(base) 6. dictionaries 7. xrange/range tricks 8. try/except 9. eval -- MGA From MarkH at ActiveState.com Thu Jul 20 07:14:55 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 20 Jul 2000 11:14:55 GMT Subject: Pythonwin attribute expansion Message-ID: Let me try this again... It's a bug. If you would like to fix it, look in pywin\scintilla\view.py, and locate the _AutoComplete() method. The line: items = items + dir(ob.__class__) Is at fault - dir() doesnt search sub-classes. Simply make this line smarter, by iterating over ob.__bases__ Mark. From neilh at scintilla.org Sun Jul 16 19:28:48 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 16 Jul 2000 23:28:48 GMT Subject: Pythonwin 1.5.2 References: <8kaij5$c9s$1@supernews.com> <8kaolt$flc$1@supernews.com> <838a5.12069$Tb7.82109@news-server.bigpond.net.au> Message-ID: > Another PythonWin documentation quirk: Ctrl+T is listed twice as a keyboard > shortcut. Once as "Transpose (swap) the current line with the line above" > and later as "Toggle the use of tabs for the current file (after > confirmation)" Well it could be documented this way because the underlying Scintilla Transpose command would be exposed if you change your bindings file to move toggle-tabs to a different key. But I expect its just an oversight. Neil From rob at hooft.net Mon Jul 31 06:00:20 2000 From: rob at hooft.net (Rob Hooft) Date: 31 Jul 2000 12:00:20 +0200 Subject: Pmw dialogs - very slow References: <3980375F.4D366654@proceryon.at> <8lrlui$673$1@nnrp1.deja.com> Message-ID: >>>>> "GM" == Georg Mischler writes: >> The dialog frame appears very fast but it takes between 1 and 2 >> seconds to display the contents! [...] Is there a possibilty to >> speed this up? GM> My experiments have shown that this has something to do with the GM> sequence of function calls in the setgeometryanddeiconify() GM> function in the file PmwBase.py. I'm not sure if I have found the GM> "correct" sequences yet, but I could get rid of the symptoms for GM> the unix branch by moving the final "window.tkraise()" from the GM> last line up to just below the "else:". Hmm.. You can also change window managers. I understood this delay in the tkraise call is a strange interaction between Tk and the WM. I have seen it in Enlightenment, and it is one of the reasons I went back to fvwm2. I discouraged the use of Gnome for a while to all customers that asked me.... Regards, Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From pete at visionart.com Tue Jul 18 17:04:18 2000 From: pete at visionart.com (Pete Shinners) Date: Tue, 18 Jul 2000 14:04:18 -0700 Subject: Python in game development? References: Message-ID: <8l2hn5$9qg$1@la-mail4.digilink.net> "Mallor" wrote > Are any of you game developers out there using Python as your game engine's > embedded scripting language? I am wondering what drove your decision to use > Python instead of other embeddable scripting languages? I'd like to hear what > your overriding concerns were, and also what they are now, having put Python to > the test. yes, i'm also really interested in this subject. with all the "latest" game engines running compiled bytecode for the majority of their code, i keep thinking python could be potentially the best way to go with this. (although things like UnrealScript and Quake3-C will always be a bit more optimized towards their specific goals, buti can't think python is really far behind them) i suppose important would be building a good restricted environment with "rexec" to allow for 3rd party code. (owell, i won't get into it, its a big topic, and i've never had a chance to touch it) has anyone embedded python into their game engine? how did it work out? From jacobs at darwin.epbi.cwru.edu Mon Jul 17 15:56:11 2000 From: jacobs at darwin.epbi.cwru.edu (Kevin Jacobs) Date: 17 Jul 2000 19:56:11 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> Message-ID: <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> I've held back a few times from contributing my 0.02 cents, but here goes: 1) Python is a nifty language that allows its programmers to revel in the richness of its dynamic object model. 2) Such models are always subject to abuse and can result in horrible and unmaintainable hacks. These are frequently disguised as nifty syntactic 'features'. 3) Such attempts are bound to lead to terminal feeping-creaturism if not carefully kept out of the core language. Ok, we all know this. Most of us accept it. Lets move on. Thus far, I am in line with the main-stream non-linear algebra proponents. However, I'd love to see clean linear algebra implemented in Python. So the dilemma is how to make the marriage work. First, Huaiyu has done an outstanding job as not only an advocate, but implementor, of such a hybrid system. This is always the first step. People can complain about the lack of something from now until doomsday, but without someone at bat nothing will ever happen. So, we have a critical mass. Now what? Now he is asking for advice and guidance. And what do we tell him? I'm sure that both (all) camps know their party lines at this point, but it seems to me that little constructive has been done to work around the issues. So, here I go. Brainstorming... Silly idea 1: Until add-on Python grammar modules are available, what about a PyAlgebra evaluator module. For a precedent, see regular expressions. The difference is that linear-algebra syntax can be made too Python-like for some tastes. e.g.: import PyAlgebra PyAlgebra.run(r'A = (A .* B)\C') e = PyAlgebra(r"D = A'*B") e.run() # or e() Admittedly, its not perfect, nor optimally compact, but it is no longer encumbered by having to support the full Python grammar and is free to redefine as much as necessary. Silly idea 2: How about a "Linear-Algebra Python" to "Stock Python" translator. Parsing Python isn't rocket science, so a fairly simple source-to-source translator can hide all the new syntax and turn it into redistributable stock but ugly Python code. No fuss or muss, assuming that the original source is available when necessary. Silly idea 3: Lets continue arguing until everyone, both pro and con, gets irritated, starts calling each other Nazis and gives up. Feel free to chime in! -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 778-8211 <-------- S.A.G.E. Project Technical Coordinator | Department of Epidemiology & System Administrator | & Biostatistics Internet E-mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From richard_chamberlain at ntlworld.com Thu Jul 13 13:05:12 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Thu, 13 Jul 2000 18:05:12 +0100 Subject: Simple File I/O Question References: <396DF13A.97CC3F5E@bioeng.ucsd.edu> Message-ID: <9Dmb5.515$ma3.8958@news6-win.server.ntlworld.com> Hi Curtis, Try converting you int to a string: var=5 f=open('foo','w') f.write(`var`) or f.write(str(var)) if it's clearer for you. The problem with doing this is that to read the int back you'd need to convert it back into an int, so it's a bit of pain if you have to do it alot. If you want to store lots of values try using pickle. Richard Curtis Jensen wrote in message news:396DF13A.97CC3F5E at bioeng.ucsd.edu... > I know this should be simple, but.... I have a variable that holds an > int. I want to write it to a file. The following code: > > var = 5 > f = open('foo','w') > f.write(var) > > gives this error: > TypeError: read-only buffer, int > > This works if: > var = '5' > > So, How do I write an int variable to a file? Thanks. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 From montagne at boora.com Wed Jul 12 13:39:09 2000 From: montagne at boora.com (michael montagne) Date: Wed, 12 Jul 2000 10:39:09 -0700 Subject: Browse for folder Message-ID: <522b5.7305$wE2.19499@dfw-read.news.verio.net> I found the FileDialog sample but I need to Browse for folder not dialog. How might that be done? Remeber, I'm a newbie. -mjm From richard_chamberlain at my-deja.com Wed Jul 19 03:33:39 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Wed, 19 Jul 2000 07:33:39 GMT Subject: tkinter text References: <8l1pfa$oci$1@nnrp1.deja.com> Message-ID: <8l3lkj$6if$1@nnrp1.deja.com> Keith, There may be a better way of doing it... from Tkinter import * root=Tk() text=Text(root,width=50,height=50) text.pack() def intercept(event): return 'break' text.bind('',intercept) text.insert(END,'Sweet ;-)') root.mainloop() Here I bind a event to the intercept function - where I return 'break' to stop the event propagating, so basically it's disabled. To undisable you'd just need to unbind that event. Richard In article <8l1pfa$oci$1 at nnrp1.deja.com>, Keith Murphy wrote: > is there a way to make a text box uneditable by the user, but insertable > ( insert(END, 'schweet') ) by the application? thanks > > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at rocket.knowledgetrack.com Mon Jul 24 20:53:27 2000 From: hzhu at rocket.knowledgetrack.com (Huaiyu Zhu) Date: Mon, 24 Jul 2000 17:53:27 -0700 Subject: Operators for everything (was Re: Operators for matrix) In-Reply-To: <397CB3EA.15F5514F@prescod.net> References: <397CB3EA.15F5514F@prescod.net> Message-ID: <200007250053.RAA03842@rocket.knowledgetrack.com> In comp.lang.python, you wrote: > >That's simply not true. The name of the function is "add". At the >syntactic level, "@" is an operator that takes three arguments, a left >operand, a right operand and an operation to apply. It is a >meta-operator. > >@add is not an identifier. *add* is the identifier. > >Personally, I think that this proposal is far more palatable then the >others which add five or more inscrutable multi-character symbols to the >Python lexicon. This one adds one character -- the meta-operator. Is this meta operator allowed to be combined with existing operators, or is it for identifiers only? If the former, then @+ @- @* @/ etc are also available. A related question: If @add does not need to be hard coded in C, why @+ need so? If it need to be hard coded, what does it bring us? still-confused-ly yr's Huaiyu From alex at magenta.com Fri Jul 14 10:07:48 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 14 Jul 2000 16:07:48 +0200 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> Message-ID: <8kn71u02nn4@news2.newsguy.com> "Dinu C. Gherman" wrote in message news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... [snip] > I doubt this will be very useful, like the answer to the > question: "Which are the ten most used words in English?". That one is pretty useful, actually (it identifies the all-too- frequent words, like 'the', 'of', etc, which a full-text search engine had better just skip over:-). Alex From mark at intrepid.net Wed Jul 5 10:51:42 2000 From: mark at intrepid.net (Mark Conway Wirt) Date: Wed, 05 Jul 2000 14:51:42 GMT Subject: Help: Python dumping core Message-ID: I'm working on a python script, and the interpreter keeps dumping core. I can't get much information from the core file, as python (and the module it calls: wxPython) where not compiled with debugging symbols included. All I have is really the stack trace: #0 0x281a7b7d in _atomic_lock () from /usr/lib/libc_r.so.4 #1 0x281a6033 in _spinlock_debug () from /usr/lib/libc_r.so.4 #2 0x281a9520 in pthread_mutex_lock () from /usr/lib/libc_r.so.4 #3 0x2869be52 in wxMutex::Lock () from /usr/X11R6/lib/libwx_gtk.so #4 0x28528da5 in wxEvtHandler::ProcessPendingEvents () from /usr/X11R6/lib/libwx_gtk.so #5 0x284fe831 in wxAppBase::ProcessPendingEvents () from /usr/X11R6/lib/libwx_gtk.so #6 0x284af1bb in wxApp::OnIdle () from /usr/X11R6/lib/libwx_gtk.so #7 0x28529044 in wxEvtHandler::SearchEventTable () from /usr/X11R6/lib/libwx_gtk.so etc. If I'm reading the trace correctly, it looks like the problem is somewhere in wxMutex::Lock. I have a few questions: 1) Such a core dump points to a problem at a lower level than the particular script I'm working on, correct? It seems to me that even if I have a mistake in the python code, python itself shouldn't dump core. 2) Short or recompiling wxWindows (and perhaps wxPython and perhaps python itself...) with debugging symbols, is there anything I can do track the problem? If my code is doing something stupid to cause the crash, how can I trace the problem if, by dumping core, python won't give me a stack trace? I'm at a bit of a loss. The reason that I like using tools like python is to avoid lower-level debugging like this :-) Thanks in advance! --Mark From fgeiger at datec.at Tue Jul 25 12:36:17 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Tue, 25 Jul 2000 18:36:17 +0200 Subject: Comparison of strings and integer Message-ID: <8lkfhs$pav$1@pollux.ip-plus.net> Still not very experienced in programming Python I recently compared accidentially a string variable with an integer variable. Python did it his way, which was not my way: I expected a conversion like Perl does or a runtime error like REBOL does. Is there any way to prevent Python from doing so? Python: print "1" > 1 --> 1 Perl: print not ("1" > 1); --> 1 REBOL: print "1" > 1 --> ** Script Error: Expected one of: string! - not: integer!. ** Where: print "1" > 1 Many thanks in advance and best regards Franz GEIGER From ssurland at online.no Sat Jul 29 14:41:08 2000 From: ssurland at online.no (Stein Surland) Date: Sat, 29 Jul 2000 20:41:08 +0200 Subject: ftp and lowercase? Message-ID: <39832544.2E05FCFB@online.no> I have made a small script using ftplib to retrieve a list from a ftp directory. It worked OK using ftp.retrlines('LIST', lines.append). However using it on another ftp host gives me this message: ftp.retrlines('ls', lines.append) File "/usr/lib/python1.5/ftplib.py", line 345, in retrlines conn = self.transfercmd(cmd) File "/usr/lib/python1.5/ftplib.py", line 285, in transfercmd return self.ntransfercmd(cmd)[0] File "/usr/lib/python1.5/ftplib.py", line 273, in ntransfercmd resp = self.sendcmd(cmd) File "/usr/lib/python1.5/ftplib.py", line 228, in sendcmd return self.getresp() File "/usr/lib/python1.5/ftplib.py", line 201, in getresp raise error_perm, resp ftplib.error_perm: 500 'LS': command not understood. The host did not take the LIST command so I changed it to LS and ls. It seems that the ftplib sends the list command in uppercase. How to change this to lowercase? I have ftp'ed to the host and it does not recognize LIST or LS only ls. Stein -- Stein Surland Trying is the first step towards failure ssurland at online.no - Homer Simpson http://home.online.no/~ssurland/ From phil at river-bank.demon.co.uk Sun Jul 16 12:20:57 2000 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Sun, 16 Jul 2000 17:20:57 +0100 Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME Message-ID: <963764534.1476580377@news.demon.co.uk> Visual Python is aimed at KDE and GNOME application developers and allows you to easily embed Python as a GUI enabled scripting language in your application. It includes KDE and GNOME APIs to manage Python interpreters, scripts and the communications between running scripts and your application. Users benefit from a common scripting language allowing them to develop scripting skills that are re-usable with all their applications. The same Visual Python script uses KDE widgets when run from a KDE application, and GNOME widgets when run from a GNOME application. When used in conjunction with tools like SWIG and SIP to expose application specific functionality to scripts, developers can provide their users with the ability to extend their application in many ways. The Visual Python home page is at http://www.thekompany.com/projects/vp/. Phil From jhylton at my-deja.com Mon Jul 24 16:37:15 2000 From: jhylton at my-deja.com (Jeremy Hylton) Date: Mon, 24 Jul 2000 20:37:15 GMT Subject: newb Q: security with variables References: <397BE388.349CCA17@mediaone.net> <2kYe5.25991$1h3.418424@news20.bellglobal.com> Message-ID: <8li9dq$8do$1@nnrp1.deja.com> In article <2kYe5.25991$1h3.418424 at news20.bellglobal.com>, "Olivier Dagenais" wrote: > How about encrypting the contents of the file? Or using a One Time Password > challenge/response mechanism? > Pisces has support for password-based encryption of objects, which could be used to encrypt the file contents. http://www.cnri.reston.va.us/software/pisces/manual/module- pisces.pwcrypt.html Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From neilh at scintilla.org Fri Jul 21 22:11:54 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 22 Jul 2000 02:11:54 GMT Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: > ... Surprisingly (maybe not, > considering the math-oriented constituency), the third option draws the most > praise and almost not criticism. It has more variations and have more > potential for the future. Despite that, imo, it is unlikely to be accepted > eventually, because it would not play well with by non-math audience. As one of the more reactionary Pythoneers with regard to syntax changes and as someone who is unlikely to ever need to use the new operators, I say the braced operators are the best. The .* style operators merge with the surrounding expression in a way that leads to me confusing whether they are interpreted with their normal meaning. The braced operator sequences like (*) merge together into one visual entity. When encountered by someone for the first time, its fairly obvious that they mean something new and not just a weird way of spelling a current operation. The braced operators give a reasonable basis for future expansion although it looks like you have used up all the best ones already. If this is going to be used for future expansion, I'd like to see precedence looked at closely now with all braced operators at lowest precedence. It may help to write a short demonstration script that intensively uses matrix operations to show what code based on these proposals will look like. Neil From breiter at usf.Uni-Osnabrueck.DE Mon Jul 31 08:58:57 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 31 Jul 2000 12:58:57 GMT Subject: PY to HTML References: Message-ID: <8m3t6h$g48$3@newsserver.rrzn.uni-hannover.de> In article , "Colin Meeks" writes: > Does anybody know anything that will enable me to convert a Python script to > HTML, so I can display it on a webpage nicely formatted with syntax colour > coding. Manually coding is a pain in the posterior :-) Apart from the already mentioned possibilities, there is another one. The www.vim.org (vim) editor has a function to just convert the text is highlights into html tags. (Look for it in the gvim menue...) Might turn out useful sometimes... Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From sean at digitome.com Wed Jul 5 07:01:30 2000 From: sean at digitome.com (Sean Mc Grath) Date: Wed, 05 Jul 2000 11:01:30 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> Message-ID: <39630fdb.148487854@news.iol.ie> Thanks to Christian and Gordon, I think I am well on the way to pickling Pyxie trees. More news anon. regards, Sean McGrath On Sun, 02 Jul 2000 11:51:10 GMT, sean at digitome.com (Sean Mc Grath) wrote: >I have a reproduceable GPF on NT when picking objects of a class >that has a __getattr__ implementation. Take out the __getattr__ and >the pickle works fine. > >Are there ways to implement __getattr__ and yet preserve the ability >to pickle? > >regards, > From claird at starbase.neosoft.com Wed Jul 26 08:00:32 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 26 Jul 2000 07:00:32 -0500 Subject: Newbie pythoner, with bizzare problem References: <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F79257Amilenkomoonshinecouk@194.73.73.116> <8lcef2$fbn$0@216.39.151.169> Message-ID: In article <8lcef2$fbn$0 at 216.39.151.169>, Donn Cave wrote: . . . >| What surprises me, though, is that no one ever >| mentions the possibility of writing >| inp = __builtin__.open("c:/autoexec.bat",'r') > >What surprises me is that you mentioned it. I mean, >it's interesting in an academic way, but it's not >clear to me how you would see that working in practice. > > Donn Cave, donn at oz.net It's a development idiom, like many of the introspective facilities. While it's not what I want to see in production code, I personally might find it handy to be in the inter- preter, type from os import * as an abbreviation I think I can tolerate temporarily, and then want access to __builtin__.open() without having to restart my interpreter state. Guido wisely keeps various contaminants of the handy-abbreviation-for-something-already- expressible (think of the "while 1" controversies) out of the language; at the same time, I think it's right for a working programmer to know tactical dodges that enhance productivity while staying within the language. Thanks, by the way, to Gordon, Paul, and the others who supplied much more precise context for its semantics. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From offer at sgi.com Wed Jul 12 10:35:23 2000 From: offer at sgi.com (Nhi Vanye) Date: 12 Jul 2000 14:35:23 GMT Subject: PIL for SGI IRIX References: <396BD2E7.1E38FF95@bioeng.ucsd.edu> Message-ID: <8khvnb$4hhhn$1@fido.engr.sgi.com> $ from cjensen at bioeng.ucsd.edu -#98042 | sed "1,$s/^/> /" > > >While running ./configure for the PIL module, I get this output: > >loading cache ./config.cache >checking for --without-gcc... no >checking for gcc... gcc >checking whether we are using GNU C... yes >checking whether gcc accepts -g... yes >checking for ranlib... : >checking for ar... ar >checking MACHDEP... irix646 >checking for -ljpeg... no >checking for -lmpeg... no >checking for -lz... yes >checking how to run the C preprocessor... gcc -E >checking whether cross-compiling... 360246:./conftest: rld: Fatal Error: >Cannot Successfully map soname 'libz.so.1.1.3' under any of the >filenames >/usr/lib32/libz.so.1.1.3:/usr/lib32/internal/libz.so.1.1.3:/lib32/libz.so.1.1.3:/opt/lib32/libz.so.1.1.3: >yes >checking for ANSI C header files... yes >checking for inline... inline >checking whether byte ordering is bigendian... configure: error: can not >run test program while cross compiling > > >How do I get past this point? Also, I have the jpeg library, and it >compiled fine, but configure doesn't find it. How do I make configure >see it? Thanks. Which version of gcc ? The problem is that the configuration used cannot produce a linked binary, not that libz is missing. My suspicion is that you've got o32/n32 issues. Check the config.log file for the last messages. >Curtis Jensen richard. -- Richard Offer Widget FAQ --> http://reality.sgi.com/widgetFAQ MTS-Core Design (Motif) ___________________________________________http://reality.sgi.com/offer From nobody at nowhere.nohow Sun Jul 16 14:03:14 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 16 Jul 2000 18:03:14 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <8kpavi04id@news1.newsguy.com> <8kpt05$uj6$1@slb3.atl.mindspring.net> <8kss1j$s39$1@slb7.atl.mindspring.net> Message-ID: On 16 Jul 2000 17:40:03 GMT, Aahz Maruch wrote: >True enough -- but if I don't visit their site, I'm not product >for them. Right. Once they cross the line where people dislike something enough that they stop using/watching, then they're loosing out. >I literally can't remember the last time I bothered visiting >AltaVista for anything other than a quick test to see if >they've improved their software, and I also warn other eyeballs >away from them. I gave up on altavista over a year ago and use google most of the time. Back when altavista was just a demo of how big/fast a DEC machine could be, it seemed to provide (to me) useful info. Once it switched over to being an ad-driven profit-center, it went into the dumpster pretty quickly. -- Grant Edwards grante Yow! I'm having a at RELIGIOUS EXPERIENCE... and visi.com I don't take any DRUGS From stpol at mindspring.com Wed Jul 19 12:25:15 2000 From: stpol at mindspring.com (Dan^) Date: Wed, 19 Jul 2000 12:25:15 -0400 Subject: are there any tutorials that someone completly new to programming can understand? Message-ID: <8l4klm$2kl$1@slb6.atl.mindspring.net> well..im 17 and thought that i should start with a programming language, and after checking with some of my friends, they pointed me to python but, all the tutorials seem to be for those that have spent years in programming (mabey im just looking in the wrong places) but id really like to try my hand at this anywho, thx in advance -Dan From thomas at xs4all.net Thu Jul 6 07:10:41 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 13:10:41 +0200 Subject: socket error In-Reply-To: ; from mad@sympatico.ca on Thu, Jul 06, 2000 at 03:09:32AM +0000 References: Message-ID: <20000706131041.I13478@xs4all.nl> On Thu, Jul 06, 2000 at 03:09:32AM +0000, Duke wrote: > I'm using Python 1.5.2 for Windows 98, and am trying to do some socket > stuff. Copying an example right out of the manual (section 7.2.2), I get > the following error: > File "C:/Programming/Python/socket.py", line 5, in ? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > s = socket (AF_INET, SOCK_STREAM) > NameError: socket You named the file 'socket.py', did you ? :-) Don't do that. 'import socket' will then load your own file again, instead of the 'socket' module. > The example I'm using works fine on my Linux box Python interpreter, version > 1.5.2. > Any ideas? You probably named it differently, under Linux ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From hzhu at localhost.localdomain Tue Jul 18 13:31:12 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 17:31:12 GMT Subject: Does Python have "not a number" floating point values? References: <3bRVEQ$l1k@openbazaar.net> Message-ID: On 18 Jul 2000 00:50:01 GMT, Warren B. Focke wrote: > >However, according to a recent post, the OpenVMS port of python uses >VAX-format math[1], which has less exponent range than IEEE. I think >that that expression for Inf will not parse there. I don't even know >if VAXen have Inf or NaN. > >Warren Focke > >[1] http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=640022415&fmt=text Here's my notes on this issue. I'd like to collect more reports. According to discussions on comp.lang.python, there is no universal way to treat NaN, but the following codes work on Windows (NT and 98), Solaris (2.7 with gcc) and Linux (RH6.1 with egcs). It core dumps on Tru64 Unix on Compaq Alpha [Solution: When using DEC (Compaq) compiler to build Python try using -ieee switch]. Supposedly it should work on any machine using IEEE arithmetics. An alternative that sometimes works is NaN = math.exp(1000) / math.exp(1000) -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From lance.shuler at intel.com Fri Jul 28 14:30:47 2000 From: lance.shuler at intel.com (Lance Shuler) Date: Fri, 28 Jul 2000 11:30:47 -0700 Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> <8lrvae015nm@news2.newsguy.com> Message-ID: <3981D157.D7A1A347@intel.com> Thanks all, Two line examples always do the trick. While the NetUseAdd title makes sense for "net use", the documentation is not as descriptive (no reflection on Mark, the words look like they match MSDN). I looked at NetUseAdd and then movde on by thinking it wasn't what I needed. Yes, I have been using the Win32 extensions (including COM) for over a year and I own "Python Programming on Win32". I find it very useful. The example below (including NetUseAdd) is not addressed in "Python Programming on Win32". Alex, regarding "local". I avoid mapping to a specific drive letter and just always use "\\server\share\dir1\dir2\file". This works when moving between machines, without worrying about whether "K:" is in use or not. I only use "net use" to map a share in a different domain or as a different user. For these cases, I will use USE_INFO_2. Thanks again, Lance Alex Martelli wrote: > wrote in message news:8lr9nc$tdf$1 at nnrp1.deja.com... > > Is there an API using Win32 extensions to map a > > drive share? I have not found one yet and have > > tried searching "Win32 map drive". I am looking > > for the equivalent of: > > > > net use > > > > If not, is there an alternative other than making > > a call to system("net use "). > > import win32net > win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:'}) > > is an example (not all that easy to fathom from the docs, but I > found it out with a little help from the docs, a little from MSDN, > and a little experimentation). If you're not already validated with > the server, you may need to add a 'password':'whatever' entry > to the dictionary that is the third argument to NetUseAdd. But > this is equivalent to > net use K: \\server\share > as I do not know what net use means _without_ the local > devicename (e.g., the 'K:' here). > > win32net contains all the API's you may desire to emulate > "net use" and other subcommands of "net"; much of what > you need to know about it, you can gather from MSDN's > entries about "Platform SDK: Network Management" (use > msdn.microsoft.com for online access, if you don't have a > handy CD or DVD with MSDN on it), but of course there is > some mapping between the argument types involved. Where > the original (C-level) API wants a structure, win32net uses a > dictionary instead, with entries corresponding to the struct's > fieldnames shorn of prefixes (e.g., the struct USE_INFO_1 > that the C-level NetUseAdd API wants has fields named > ui1_remote and ui1_local). > > But if you plan to do a lot of system programming and/or > system administration on Windows with Python (a very > workable and excellent plan, as it happens) you really > should splurge for the "Python Programming on Win32" > book by Hammond and Robinson, published by O'Reilly. > It's not perfect (for example, I can't find in its reference > Appendix any specific info on NetUseAdd, while it does > document a lot of OTHER win32net functions!-) but it > still helps a lot. > > Alex From root at ns.rgz.ru Thu Jul 27 06:17:54 2000 From: root at ns.rgz.ru (Charlie Root) Date: 27 Jul 2000 14:07:54 +0350 Subject: wxPython Message-ID: <398009fa$1@news.edunet.ru> There a great python library to programm under Motif and other called wxPython , I think it is more powerfull then Tk From rumjuggler at cryptarchy.org Sat Jul 29 00:57:01 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 04:57:01 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> <8lsqld$hrq$1@newshost.accu.uu.nl> <82l4osonthc3dopu8s7ddrs7h4cgou1lgf@4ax.com> Message-ID: On Sat, 29 Jul 2000 04:45:14 GMT, jeff at ollie.clive.ia.us (Jeffrey C. Ollie) wrote: >On Sat, 29 Jul 2000 03:43:38 GMT, Ben Wolfson wrote: >>>>> def getnone(): >> pass >> >>>>> import __builtin__ >>>>> __builtin__.None = 1 >>>>> type(getnone()) >> > > >I think that you are not fully comprehending the difference in Python >between variables and objects. Variables in Python are nothing more >that references to objects. When you type 'None' in a program, Python >uses the object (usually, the 'None' object) referenced by the label >'None'. As you have found out, you can change which object that the >label 'None' references. I was actually trying to show that even if you modify __builtin__.None, it is recoverable. With that function (or any function that doesn't return a value, but that one has no other purpose) you would just do __builtin__.None = getnone() and all would be well in the world again. -- Barnabas T. Rumjuggler The world is turning into a cesspool of imbeciles. -- Harlan Ellison From hzhu at localhost.localdomain Thu Jul 20 20:33:03 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 00:33:03 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> <39779175.3F2D163B@roguewave.com> Message-ID: On Thu, 20 Jul 2000 17:55:33 -0600, Bjorn Pettersen wrote: > >> OTOH, would you care to give a brief summary of how these other languages >> deal with these issues? It may indeed provide valuable insight. > >I agree with Paul, if you want to use Matlab syntax, use Matlab. Here's >links to APL/J info http://www.acm.org/sigapl/links.htm It would be great if you could summarize some of the issues concerning treatment of multiarray in APL/J. The purpose of this discussion is for all sides to spell out their favorite. Imho, issues that are so involved that could not be explained here are unlikely to be suitable to go into the PEP. As to why not use matlab alone, I think this has been discussed many times already: Other than calculator languages, a languages has far more things than math operators. I'm sure you can compile a long list of advantages of python over matlab. Huaiyu From johngrayson at home.com.bbs Sat Jul 15 10:20:01 2000 From: johngrayson at home.com.bbs (johngrayson at home.com.bbs) Date: 15 Jul 2000 14:20:01 GMT Subject: Why make a language case sensitive? Message-ID: <3bPZh1$lrf@openbazaar.net> In article <000c01bfedcf$3e316160$6cb745c6 at timaratz>, "Peter Timaratz" wrote: > I thought there might be a reason why it needs to be case sensitive. I guess > if you come from a Unix background (which I don't) and you create a > language, then it seems natural to make it case sensitive. > > I'm not trying to start a war, so I'll refrain from expressing my opinion. > :) > > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of richard_chamberlain > > Sent: Friday, July 14, 2000 9:52 AM > > To: python-list at python.org > > Subject: Re: Why make a language case sensitive? > > > > > > Hi Peter, > > > > That's a bit of a sore point at the moment :-) > > > > do a search on deja for case sensitive and you'll find a whole argument on > > the subject. > > > > Richard > > > > Peter Timaratz wrote in message > > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > > I can't think of any advantages to a case sensitive language. > > Python is a > > > very well-designed language though, so I imagine there is a good reason > > that > > > it is case sensitive. So what are the advantages of a case sensitive > > > language? > > > > > > > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > If you're used to C++ (or Python or Java), which don't have to be Unix-based, then you quickly discover that a simple naming convention in your code makes for easy (cheap) maintenance and reuse... e.g. MyClass ... Class definition myClass ... Instance of class (or other 'variable') MYCLASS ... Constant (maybe an enumeration) Then, within a class, instance or variable name, mixed case aids readability: A = ... ? Old Basic ;-) mainwindowframeborderwidth = ... Caseless language (or poor C++) mainWindowFrameBorderWidth = ... IMHO better Take a look at example code for any of the major languages and I'm sure that you'll spot a trend... Of course, if you're an assembler programmer, then you probably don't care -- but even assemblers can be case sensitive :-) John Sent via Deja.com http://www.deja.com/ Before you buy. From root at rainerdeyke.com Sat Jul 15 17:17:22 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 15 Jul 2000 21:17:22 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> Message-ID: "Alex" wrote in message news:etdbszzw6wv.fsf at w20-575-115.mit.edu... > > > Well it's exactly what I was doing once because I was a lot more > > clever than the guys who said I shouldn't. And then I decided quite > > suddenly that they were right. (At the end of a _long_ stretch trying > > to figure out why the heck something wasn't working - of course the > > answer is the object in question was very different from the object it > > appeared it should be...) > > It can have really confusing consequences, but it's still too useful for > me to abandon. If you have a class which takes a long time to > instantiate (e.g., you have to load a lot of statistical data into > memory,) then having a script like More importantly (for me), you can run a simulation program where one simulated entity changes into another type of simulated entity. The alternative (using proxies) is less efficient and elegant (IMO). -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From matt at null.net Wed Jul 12 01:28:16 2000 From: matt at null.net (Matthew Schinckel) Date: Wed, 12 Jul 2000 14:58:16 +0930 Subject: checking the existence of a fiel In-Reply-To: References: Message-ID: On Jul 11, I overheard Fernando Rodr?guez mutter: > How can I check if a file exists? O:-) try: fp = open(file,'r') # code to run if file exists. except IOError: print "File:",file,"Does not exist." -- Matthew Schinckel What I tell you three times is true. From tanzer at swing.co.at Thu Jul 27 02:00:02 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Thu, 27 Jul 2000 08:00:02 +0200 Subject: Don't be too hard on those who want class methods (Re: Python is wierd!) In-Reply-To: Your message of "Thu, 27 Jul 2000 17:15:43 +1300." <397FB76D.C05BD86B@see.my.signature> Message-ID: Greg Ewing, , wrote: > Usually when people say that class methods > are not needed, they're talking about C++ or Java style static > methods. But Smalltalk-style class methods are a different > species altogether. In Smalltalk, a class is also an instance > (of class Class or some subclass thereof), so > > aClass frobulate: aBlivet > > is dynamically dispatched on the runtime class of aClass, > just like any other message. There is no direct equivalent of > this in Python, because classes are not instances, they're a > different kind of object. The suggestion by Moshe Zadka: > > > > class Function: > > > > > > def __init__(self, func): > > > self.func = func > > > > > > def __call__(self, *args, **kw): > > > return apply(self.func, args, kw) > > > > > > class SomeClass: > > > > > > def class_method(a, b, c): > > > return a+b+c > > > > > > class_method = Function(class_method) > > isn't quite the same thing, because there is no 'self' > in scope in the method which is bound to the receiving > class object (which might be a subclass of SomeClass, > so you can't just assume that it's SomeClass). > > There are no doubt even more convoluted hacks that could > be used to fix that, but in 999,999,999 cases out of > a billion it's probably better to revise your design > so that you don't need class methods in the first place. That's the one of the reasons I'm hoping to see first-class metaclasses in some future Python implementation (and hopefully before Python 3000). In practice however, I need class variables much more often than class methods, and class methods not needing `self' (denoting the class in question) much more often than class methods needing `self'. And even than, default arguments offer an easy workaround. So I think that your 1 ppb is slightly overstated. -- 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 thomas at xs4all.net Wed Jul 5 12:12:44 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 5 Jul 2000 18:12:44 +0200 Subject: PyObject_GetAttr(String) ... In-Reply-To: <8jvjbf$1eus@drn.newsguy.com>; from Armin@Steinhoff.de on Wed, Jul 05, 2000 at 08:13:51AM -0700 References: <8jvjbf$1eus@drn.newsguy.com> Message-ID: <20000705181243.B13478@xs4all.nl> On Wed, Jul 05, 2000 at 08:13:51AM -0700, Armin Steinhoff wrote: > a question for the gurus: > what is the difference between the calls > > - PyObject_GetAttr and > - PyObject_GetAttrString ?? > Both have the same 'documented' semantic ... but they are magically > different. Actually, no, they aren't the same. PyObject_GetAttrString takes a PyObject pointer and a char pointer, whereas PyObject_GetAttr takes two PyObject pointers: the second argument should be a PyString, which is then turned into a char pointer (using PyString_AS_STRING) and passed to PyObject_GetAttrString. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rupole at compaq.net Fri Jul 7 00:29:26 2000 From: rupole at compaq.net (Roger Upole) Date: Fri, 07 Jul 2000 04:29:26 GMT Subject: Python COM: How to access constants in type lib References: <8k37mi$o76$1@nnrp1.deja.com> Message-ID: If you first run Makepy on the object (it shows as Microsoft DAO Object Library on my system), the constants will be available in win32com.client.constants. eg win32com.client.constants.dbQMakeTable HTH Roger Upole "Charles Medcoff" wrote in message news:8k37mi$o76$1 at nnrp1.deja.com... > When using Python as a COM client, how can I use/access constants > defined in a type lib from Python. > > Example: > > > import win32com.client > > engine = win32com.client.Dispatch("DAO.DBEngine.35") > db = engine.OpenDatabase(r"\test.mdb") > > query = db.CreateQueryDef("base", "SELECT, bla, bla...") > query.Type = dbQMakeTable # this doesn't work > > Thanks, > Chuck > > > > > > > -- > Charles Medcoff > Senior Systems Engineer > Pyramid Solutions > 1850 Research Drive, Suite 300 > Troy, MI 48083 > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From bgriggs at pobox.com Sun Jul 2 20:30:36 2000 From: bgriggs at pobox.com (B Griggs) Date: Mon, 03 Jul 2000 00:30:36 GMT Subject: urllib and linksys router References: <038701bfe3ec$ece104a0$6401a8c0@home> Message-ID: Darrell, Speaking of urllib and the LinkSys router... http://greenman.dyndns.org/ls_dyndns I have written a dyndns.org client for the linksys router. Should work on all Python platforms. Regards, Bobby "Darrell Gallion" wrote in message news:038701bfe3ec$ece104a0$6401a8c0 at home... > Tried to use urllib to access my linksys router, which requires a password. > After much pain, it turns out the router needs to see the request as one > string. > Maybe it's a timing thing since urllib sends each line separately. > > This works. > > def direct(): > s = socket(AF_INET, SOCK_STREAM) > s.connect("192.168.1.1",80) > > msgs=[ > 'GET /Status.htm HTTP/1.0\015\012', > 'Authorization: Basic xxxxxxxx==\015\012', > '\015\012', > ] > s.send(string.join(msgs,'')) > print s.recv(1024) > print s.recv(1024) > > > > --Darrell Gallion > > From garry at sage.att.com Fri Jul 28 13:25:36 2000 From: garry at sage.att.com (Garry Hodgson) Date: Fri, 28 Jul 2000 17:25:36 GMT Subject: Perl is worse! References: Message-ID: <3981C210.8F0D0908@sage.att.com> Steve Lamb wrote: > > On Fri, 28 Jul 2000 01:24:08 -0400, Tim Peters wrote: > >Steve, in case it isn't clear yet, Python programmers *want* to be blown out > >of the water when doing something as senseless as > > > 1 + "foo" > > It isn't senseless. That is the whole point. It is only senseless > because of typing. Clearly you cannot add a word to a number, granted. But > what of 1 + "1"? That isn't senseless, those are two numbers. I can see they > are two numbers, it is only because of typing that it fails. you can see that because you are smarter than my computer. in the general case, adding an integer to a string is, indeed, nonsense. it also likely, or at least possible, that it represents a programming error. the choice python makes is to alert the programmer to this (possible) error, and make them explicitly override this if that is really what they want to do. 1 + "1" might mean 2, or it might be an error. 1 + "foo" might mean "1foo", or it might be an error. the system can't know which i intended, so it makes be specify. it is much easier to say, "yes, i meant that" by adding a cast, than to debug an errant program, possibly years later. > So I ask you this /VERY/ simple question. Why can't Python do both? Hm? > What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it > together? see above. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From edream at tds.net Sun Jul 9 14:08:05 2000 From: edream at tds.net (Edward K. Ream) Date: Sun, 09 Jul 2000 18:08:05 GMT Subject: Borland C++ Builder make files for Python? References: <3967DBDB.7FBDD3E5@tds.net> <3968581B.C9571894@dittmar.net> <8_1a5.124522$WS3.1076728@typhoon.we.rr.com> Message-ID: <3968BF6E.F5D5FFCC@tds.net> Hi, Thanks for all these excellent suggestions. They are appreciated. > > I think Borland supplies a tool to convert Visual C++ workspaces to C++ > > Builder projects, at least they mention VCTOBPR.EXE in their help files > > for the free command line tools. Excellent idea. I'll give it a try. BTW, I've been messing with the config.h file for the PC version, and the Borland part of that file appears to be lacking a few #defines. Hopefully these will be easy to find and supply. > > Unfortunately, this tool is not part of the free tools, so please submit > > your converted makefiles to the Python team. I'll do so if/when it works ;-) > Hinthint. Don't forget to run coff2omf on the VC lib if you just link it > to your borland project :) I actually managed to stumble across this by accident. Thanks for the hint, though. > > BTW, I don't think it is really necessary to rebuild Python, just try > > linking against the import lib created from the python15.dll. As I wrote to this list in a message called FILE * in C API's ??, I think that this will not work: you must use the same compiler that created the .dll (converted to .lib) file. Otherwise the struct FILE in the .lib will not match the struct FILE in the rest of the build. This appears to be an unfortunate oversight in the "very high level functions" part of the C API. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 12:30:04 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 16:30:04 GMT Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME Message-ID: <3bQSbS$lTz@openbazaar.net> You may want to hook up with the guys at ActiveState for your Win32 version of VisualPython: http://www.activestate.com/Products/VisualPython.html Unless both of you came up with the name "Visual Python" to mean totally different things?? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Phil Thompson" wrote in message news:963764534.1476580377 at news.demon.co.uk... > Visual Python is aimed at KDE and GNOME application developers and allows you > to easily embed Python as a GUI enabled scripting language in your application. > > It includes KDE and GNOME APIs to manage Python interpreters, scripts and the > communications between running scripts and your application. > > Users benefit from a common scripting language allowing them to develop > scripting skills that are re-usable with all their applications. The same > Visual Python script uses KDE widgets when run from a KDE application, and > GNOME widgets when run from a GNOME application. > > When used in conjunction with tools like SWIG and SIP to expose application > specific functionality to scripts, developers can provide their users with the > ability to extend their application in many ways. > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. > > Phil From dale at out-think.NOSPAMco.uk Tue Jul 11 03:10:35 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 11 Jul 2000 08:10:35 +0100 Subject: How to approach this? References: <8kal5v$8n5$1@supernews.com> Message-ID: <8keh9o$k0n$1@supernews.com> Thanks for the replies. I studied them carefully and had a think and I've come up with this, which I think does what I want: ------------------ class master: def __init__(self): print "master" def __del__(self): print "deleted" def newslave(self, id): return sub(self, id) class slave: def __init__(self, parent, id): print "slave init", id self.p, id = parent, id def __del__(self): print "slave del", self.id ----------------------- 'newslave,' being a method of 'master', necessarily requires an instance of 'master'. It returns an instance of 'slave'. However that instance won't be deleted until all of the instances of 'slave' have gone. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants jepler epler wrote in message news:slrn8mhp6b.fu4.jepler.lnk at potty.housenet... > You may be aware of the idiom: > > class C: pass > > _instance = None > def SingletonMaker(): > global _instance > if _instance is None: > _instance = C() > return _instance > > thus, instead of instantiating C directly, you call SingletonMaker. > > However, this doesn't do the other thing you want, which is to collect > _instance when it has no more users. > > Something like the following ought to work: > > class UsesSingleton: > def __init__(self): > self.instance = SingletonMaker() > > def __del__(self): > if sys.getrefcount(self.instance) == 3: > # _instance, self.instance, and the arg to > # sys.getrefcount > _instance = None > # When the function ends, the refcount will > # drop to 0, so self.instance will be collected > # and the next call to SingletonMaker will > # make a new one > # else, there are other references to the instance... > > Of course, if someone else stores a reference to the singleton object, > this won't work.. > > Jeff From db3l at fitlinxx.com Thu Jul 27 01:45:00 2000 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2000 01:45:00 -0400 Subject: Python is wierd! References: <8lk1c5$fv4$1@nnrp1.deja.com> <8llqkl$rof$1@nnrp1.deja.com> <397FC213.88603B9E@see.my.signature> Message-ID: Greg Ewing writes: > And to answer your question, yes, you can create an instance > variable at any time simply by executing "instance.name = value". Which actually leads to an interesting question relating to a point that I'm curious how others handle. If I'm going to package up some state (various bits of information) into a class (aka using one as a structure - data only), one approach could be to define an empty class: class MyInfo: pass and then whenever I need to later: newstate = MyInfo() newstate.variable = value newstate.other_variable = value and so on. Or instead, I can be a little more up front in the first place and do something like: class MyInfo: def __init__(self): self.variable = initial_value self.other_variable = initial_value I find that the latter approach seems cleaner to me in terms of defining what I'm going to be using the structure for, but in practical terms unless you want special initialization, there's not a lot of difference between the two methods I suppose. And I've even found myself in one instance going this route but then in an error path through the code augmenting the structure with another instance variable or two just for the failure path (boy, that "felt" wierd). Of course, if you don't fully populate the information, then you have to be prepared to field NameErrors later on attributes within the class instance that weren't assigned. I'm curious what others would think of the two approaches? -- -- 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 digitig at cix.co.uk Sun Jul 16 16:26:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Sun, 16 Jul 2000 21:26 +0100 (BST) Subject: Top 10 Language Constructs (Phyton) References: <8kmtab$4or$1@pollux.ip-plus.net> Message-ID: In article <8kmtab$4or$1 at pollux.ip-plus.net>, GustavsB at ch.sibt.com (Bruno Gustavs) wrote: > "Dinu C. Gherman" wrote in message > news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... > > What do you mean by "language constructs", Python keywords > > like "for" or "class"? Are you expecting some statistics of > > used keywords over one's own code? > > > > I doubt this will be very useful, like the answer to the > > question: "Which are the ten most used words in English?". > > But maybe I'm not understanding well how you think you'll > > benefit from such an answer... > > Lets assume you're going to design Phyton2. What would this > language contain? What should Phyton2 support? What would you > like to solve with Phyton2? People's "top 10 constructs" would be a disastrous basis for such a language. I'm trying to remember the name of a language I used many years ago that was designed by government committee. It had about 10 ways of doing some obscure things (because everybody on the committee had contributed their favourite solution) but no ways of doing quite ordinary things (because everyone on the committee used those things but none of them noticed them). The result was like a car with three different air-conditioning units and no engine. /Much/ better IMHO is to see what application domains Python is particularly strong in, and to try to find out what distinguishes Python in those domains. Then look for ways it can be improved in those specific domains and expanded into closely related domains. At the moment there are things I use Python for and things I use Ada for. If the next version of Python tried to muscle in on the mainstream Ada territory it would almost certainly find that Ada still did those things better but the attempted shift had broken it's advantage in those things it was good at before. From robin at jessikat.fsnet.co.uk Fri Jul 14 12:28:40 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 14 Jul 2000 17:28:40 +0100 Subject: find -name *.ext in Python References: <396F1C32.9A1CE891@seatech.fau.edu> Message-ID: In article <396F1C32.9A1CE891 at seatech.fau.edu>, Benoit Dupire writes >I wrote a simple Python script to perform the Unix function >find -name *.ext >on a NT system. >I would like to know if there is a way to simplify it (or to perfect >it). > 1.5.2 has a find.py in Lib, but it's going away apparently. -- Robin Becker From kpmurphy at my-deja.com Mon Jul 17 15:32:53 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 17 Jul 2000 19:32:53 GMT Subject: Grid Geometry Manager and grouping? References: <8k013q$lon$1@nnrp1.deja.com> Message-ID: <8kvn15$7t3$1@nnrp1.deja.com> richard, what i'm trying to do is create my own widgets. once i make one, i'd like to be able to grid it. each of my widgets will have multiple items in it (ex. label and an entry ==> myWidget) and then i would place multiples of myWidget together. i like the grid manager because i can put things exactly where i want them. can you do a grid inside a frame, then grid multiple frames toghether? thanks, -->keith In article , "richard_chamberlain" wrote: > Hi Keith, > > For what purpose do you want to group the areas? > > An example of frames: > > from Tkinter import * > root=Tk() > frame1=Frame(root,relief=GROOVE,borderwidth=3) > frame2=Frame(root,relief=GROOVE,borderwidth=3) > for i in range(1,9): > Label(frame1,text="Frame: 1 - Label: %d" %i).pack() > Label(frame2,text="Frame: 2 - Label: %d" %i).pack() > frame1.pack(side=LEFT,fill=BOTH,expand=1) > frame2.pack(side=LEFT,fill=BOTH,expand=1) > > root.mainloop() > > Pmw has got Pmw.Group, a framed widget on which you can have a label or > other widget in the frame and then a number of widgets within the frame. > > Give me an example of what you want to achieve and I'll have a go. > > Richard > > Keith Murphy wrote in message > news:8k013q$lon$1 at nnrp1.deja.com... > > i've found that i like grid the best. is there a way to group sections > > of the window together... like the left side is for one purpose and the > > right for another? I have been playing with frames to no avail. > > > > i really appreciate all the help this ng has given me thus far in > > learning python. kudos to all of you! > > > > -->keith > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Thu Jul 27 04:30:27 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 27 Jul 2000 18:30:27 +1000 Subject: Python & AI References: Message-ID: <397FF323.1A9EB0D0@sitegnome.com> Hi ! I don't know how useful it is but this link was added into python.faqts.com by Arthur T. Murray Porting Mind.Forth AI to Python http://www.geocities.com/mentifex/python.html he also has been working on http://ai.faqts.com , though it's only got 3 entries :-) cheers, F. rhymes wrote: > > Do u know something on the net related to Artificial Intelligence and > Python Language?? > > Thanx in advance. > > Lawrence Oluyede > > rhymes at tiscalinet.it > > "Per cambiare, > per diventare un' altra cosa > dobbiamo prima sapere cosa siamo" > > Bruce Lee -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From dalke at acm.org Sun Jul 30 16:20:26 2000 From: dalke at acm.org (Andrew Dalke) Date: Sun, 30 Jul 2000 14:20:26 -0600 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> <8lvovs1dj1@news2.newsguy.com> Message-ID: <8m22fg$5gs$1@nntp9.atl.mindspring.net> Steve Lamb wrote: >1 > >What comes next? The phrase "is the lonliest number" http://dork.com/pirfuct/oneisthelonliest.html Or "o'clock, 2 o'clock, 3 o'clock rock" Or "for the money, 2 for the show" Or "ring to bring them all and in the darkness bind them" http://www.flwyd.dhs.org/metw/cotd/issues/298.html :) Andrew dalke at acm.org From yartz at imaginet.fr Sun Jul 16 09:46:08 2000 From: yartz at imaginet.fr (Yann Schwartz) Date: Sun, 16 Jul 2000 15:46:08 +0200 Subject: Pythonwin: problem with syntax highlighting References: <32966860B9270DBB.82F799B3E78DDCD7.9E33DCD378F53BB0@lp.airnews.net> Message-ID: On Sun, 16 Jul 2000 12:58:54 GMT, "Neil Hodgson" wrote: > Telling us what version number will help. Using PythonWin 132 is best if >you are running Python 1.5.x. I'm using pythonwin build 132 and python 1.5.2. All the win32 stuff works well, I can run scripts and code my own, but no call tips whatsoever. > >> There's just one irritating thing, not with the language itself, but >> with the pythonwin editor. I havn't managed to make autocompleting and >> syntax highlighting to work. > > Autocompletion requires some symbols to be loaded. I don't know all the >ways this can happen but in the interactive window try > >import win32api >win32api. > > After you press the '.' you should see a list appear. And no list appears when I try this. I remember seeing such lists two or three weeks ago, but now nothing shows up (and I've installed python+pythonwin on 3 different setups : win98, nt4serv and w2k advanced server. I don't have autocompletion on any of those). > > Syntax highlighting should just happen - it even looks as though Mark has >dropped the option to turn off syntax highlighting. Do you mean coloring ? The source is colored alright. > Help is bad too? Your machine is posessed by the anti-Python! Try >uninstalling and reinstalling. And use Python 1.5.2 and PythonWin 132. Actually the online help is fine, I was talking about call tips, autocompletion and all these niceties which make life easier (and yes, I've uninstalled and reinstalled twice already). I know it sounds strange.... From grey at despair.rpglink.com Sat Jul 29 18:21:40 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:21:40 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> <3981BE50.23DB16C5@infercor.no> <8lsu2a02ho4@news2.newsguy.com> <8luhsl21ce8@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 12:13:16 +0200, Alex Martelli wrote: >(XML helps. But don't anybody think it's anywhere close to >the panacea it's apparently considered to be in some circles; >that is just Yet Another recurrence of the never-ending dream >for the Magic Bullet:-). Someone tell that to the people who wrote O'Reilly's Java & XML and, hmm, there was another one out there. If you want a good chuckle pick it up and read the first two paragraphs of the preface and introduction. In a nutshell anyone who has that awesome tome in their trembling hands is clearly sweating bullets because they don't know XML, their manager is breathing down their neck for not knowing it, their wife is leaving them, they are lost in a sea of data, unable to do anything, unable to even SLEEP, until they understand XML because XML is /THE/ languages of the gods, business, and Robert Downey Jr!!! Me, I filed the book away until I actually have a need for it in spite of the author's view of its use in the world. So far I have seen two /examples/ of its use at one conference and to me it looks like a markup language with definable tags. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From mwh21 at cam.ac.uk Thu Jul 27 18:02:25 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 Jul 2000 23:02:25 +0100 Subject: PY to HTML References: Message-ID: "Colin Meeks" writes: > Does anybody know anything that will enable me to convert a Python script to > HTML, so I can display it on a webpage nicely formatted with syntax colour > coding. Manually coding is a pain in the posterior :-) There's one here (py2html.py): http://starship.python.net/crew/lemburg/ Cheers, M. -- If i don't understand lisp, it would be wise to not bray about how lisp is stupid or otherwise criticize, because my stupidity would be archived and open for all in the know to see. -- Xah, comp.lang.lisp From alex at magenta.com Sun Jul 30 10:29:42 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 16:29:42 +0200 Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> <8luhso41ce8@news2.newsguy.com> Message-ID: <8m1f0462n4o@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o6lo2.f91.grey at teleute.rpglink.com... > On Sat, 29 Jul 2000 13:53:02 +0200, Alex Martelli wrote: > >Yes, so the latter is best when you have a single format you want to > >apply to several different variables at various point, the former is > >best when the names are fixed. That's why Python supplies both. > > Excellent description except for one thing, I never said that the variable > names were fixed. Take a look at Perl's ##foo, for example. Well, more > accurately ${$foo}. Again, just taking a pseudo-code, not a real lanauge. The 'soft-reference' where a variable holds the _name_ of another variable? As I understand it, it's deprecated, Perl texts suggest you don't use it, and use strict (which is strongly suggested) cries to high heavens if you do use it. I would not take it as something Perl experts consider a particularly good idea, then. > > "Here is a very %(adj)s %(noun)s!" > "Here is a very $$adj:$format $$noun:$format!" > > "Ecco una %(noun)s molto %(adj)s!" > "Ecci una $$noun:$format molto $$adj:$format!" > > > print format % {'adj':adjective1, 'noun':noun1} > > print format % {'adj':adjective2, 'noun':noun2} > > print format > > Adj and noun need to be assighed in either case. Except when we do it > inline we can see what formatting goes with what. It really is semantical in > nature since there is no different at all in function that I can find. The When the format string is expressed as an inline constant you can see it in place, but you don't have the other advantages (such as internationalization, and assurance that the *same* format is used in N places, without having to edit each place with the utmost care each time a change is specified) that only come with obtaining the format-string through a variable. The second class of advantages generally dominate in larger programs. But on these axes there is indeed no important difference between Python's exact syntax and the hypothetical one you suggest (most definitely, NO _semantical_ difference: semantical="related to meaning"; do you mean syntactical?). The advantages of referring to an explicitly specified dictionary (mapping object) rather than force the reference to be always and only to the implicit mapping-object variable_names->variable_values are however multifarious. Several bindings (mapping objects, dictionaries) can be easily maintained and passed around, with choice between them taken at whatever moment is desired, up to the very last moment; the same thing is horridly cumbrous to do if the implicit vars() mapping is the only one you can use. For example, say the two outputs may themselves need to be made in the reverse order; then, having the two dictionaries in a 2-element sequence, you only need to arrange to have either (0,1) or (1,0) in another variable, and use a for loop over that variable. Encoding such aspects in data is most often handier than expressing them in code, which you'll need far more frequently if the tools you have always necessarily make reference to the implicit mapping that variable-names encode. (That's part of why 'eval' is needed much more often in Perl than in Python, by the way, as soon as a program gains any heft and/or need for 'solidity'; but these are other issues). > only difference is having to match up what is at the end of the string with > what is right there where you're looking at the moment. When you end with % vars(), there is no substantial difference. When you use the more substantial flexibility allowed by using other mapping-objects, if that flexibility is needed, then the advantages are many -- see above for a *beginning* to them. > >> "%d:0:0 %c:U %s %s %s %s %d %s %s %s \ > >> %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k > > >> What variable goes with what again? > > >Yes, a format-string with named-placeholders does help with that, too. > > But not as much as just having the variables in line with the formatting > where reading is still the natural left to right (for us natives of European > lanauges) with all information presented where it must be. I'm a European native, too, and I disagree with your contention that there is any substantial difference. > >I'm very happy not _having_ to invent some arbitrary name when what > >I want to do is output one or more arbitrary expressions, computed > >on the fly, for example. Naming has its place, but so does quiet > >anonimity...:-). > > Why do you need to place them at the end? For many reasons, above all the need to distinguish and separate _computational substance_ from _presentation_ -- as most obviously shewn on the web, where far too many site-authors that just do not understand this issue have made such an utter mess of things. Presentation style in ONE place (be it a style-sheet, or a humble format-string), computational content in ANOTHER (scripts, formulas, expressions), makes each easy to edit, maintain, develop, and reuse separately. Mixing them up too much just makes a mess. > "1 + 1 = ",1 + 1:0:0, ",really, it is!" > > Again, fake language. I don't see a need to have placeholders for simple > statements at the end when you can place those statements in line. Apparently, you're very, VERY keen to never sell your software anywhere except English-speaking markets, and, even there, strive to make life as hard as possible for the technical writers that are responsible for maintaining the text you present to the end user, which are not the same people who maintain the program's computational parts and should not have to delve into the code of that program. Most of us would just as soon keep things more flexible and usable, with a format-string with place-holders, that can most easily be moved to a separate file (where specialists can edit it, internationalize it, etc) and fetched from there at need. But even then, your fake language appears to have very strange problems in order to offer you the disadvantage of mixing things up that way. Specifically, the flags and numbers related to string-formatting end up mixed with the syntax of other kinds of expressions. You will therefore need to use more special characters, distinct from those used for all other operators, as well as lots of rules about precedence and grouping. This smacks to me as lots of ad-hoccitis, hard work, and complexity, all for no benefit at all (indeed, the reverse). I suggest you go ahead and fully design the fake-language of your dreams, implement it (Python makes that pretty easy, exactly because it has so LITTLE ad-hoccitis & complexity!), and use it for a while. I suspect this will give you much keener insight and clearer perception of the issues that are involved, one way or another; i.e., such experience will by no means nevessarily change your opinions to make them more similar to mine (many language designers and implementers have all sorts of differing opinions on this, clearly -- just look at the huge variability in languages' approach to formatting) but at the very least it will give your opinions sharpness and founding, which at this time they lack. (Like most people in our field with decades of experience, I've had to design and implement several special-purpose languages of various scope along the years, and, having essayed all flavours, I now consider format-strings, particularly Python-like ones, quite preferable to variable-by-variable formatting, e.g. the mainstream-C++ approach; and note that I use C++ even more than Python, so, once again, it's NOT an issue of "what I'm [most] familiar with", but a well-rooted technical evaluation of the pro's and con's of the many alternatives). > >Could be (I _am_, after all, a well-known sadomasochist!), but, if > >it were that, I think I'd be programming in C shell (hard to think > >of a more painful way to make a living; and yet there _were_ people > >writing scripts in it rather than the somewhat-less-painful Bourne > >shell, for reasons I've always found utterly unfathomable...). > > ESC-P comes to mind. I find all shell scripts horrible. Any time I need > to work on one I take the basic logic and rewrite in Perl. Less need to have That's what I would have liked to do, but often couldn't because Perl might not be installed on some target-machines, sigh. At least, Bourne-shell could be counted on at the time. > to worry about globbing and proper escaping of everything and handing > different input/output expectations from different programs. Sure, I'll use > grep on the command line but I'd rather see while(<>){m//;} in the script, > thank you. You're welcome. But for line in fileinput.input(): if cre.match(line): print line currently makes me even happier:-). Alex From johannes at zellner.org Fri Jul 7 17:17:52 2000 From: johannes at zellner.org (Johannes Zellner) Date: Fri, 7 Jul 2000 23:17:52 +0200 (CEST) Subject: accessing a char* from a dl.sym Message-ID: Hello, this question is really a question about a /dirty/ hack. Anyway: suppose I've import dl handle = dl.open('/usr/lib/libreadline.so') cp = handle.sym('rl_completion_append_character') print cp so far so good. cp contains a pointer to a c (char*) pointer. Can I assign something to this pointer ? 1) how do I assign a 0 from python, what would read in c: *rl_completion_append_character = 0; 1) how do I assign a string from python, again in c it would be: rl_completion_append_character = strdup('fred'); any help would be much appreciated. -- Johannes From kellyk at my-deja.com Wed Jul 12 17:40:10 2000 From: kellyk at my-deja.com (kellyk at my-deja.com) Date: Wed, 12 Jul 2000 21:40:10 GMT Subject: Pythonwin IIS-ASP module imports (bug) Message-ID: <8kiojo$69q$1@nnrp1.deja.com> In IIS 4 using Pythonwin 132 modules are not reloaded when an ASP script is run. Modules are reloaded properly in Pythonwin 129 (I just tested this) so I will just go back to version 129 but... The following script should just print out Python's version number but each time it is refreshed in the browser it tags on an additional "banana". Refresh it 5 times and sys.version has 5 "banana"'s appended. ---begin script <%@ LANGUAGE = Python %> <% import sys Response.Write("

" + sys.version + "

") sys.version= sys.version + "banana" %> ---end script Sent via Deja.com http://www.deja.com/ Before you buy. From lull at acm.org Thu Jul 20 21:57:04 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 20:57:04 -0500 Subject: Discussion: new operators for numerical computation References: <39771F6D.A9A0A26B@yale.edu> Message-ID: At the dawn of the third millenium (by the common reckoning), hzhu at localhost.localdomain (Huaiyu Zhu) wrote (with possible deletions): > On Thu, 20 Jul 2000 11:49:01 -0400, Paul Magwene wrote: > >Konrad Hinsen wrote: > >A(+.*)B > There is one reason this will not be accepted eventually. The parathesis > suggests the possibility of a calculas of operators within them, when, in > fact, operators are hardcoded in the C program. John Lull had given a clear > explanation why this is so. I think your objection here is to the '+.*' bit, rather than the parentheses. Correct? Do you have the same objection to the simple (*) ? I really like the general form of this proposal, but am a bit troubled by the use of parentheses. I wish there was another character available, such that (at some future time) this mechanism might be extended to permit arbitrary named operators to be added -- something like a :*: b evolving to permit a :opName: b where the surrounding :: flags both of these to the compiler as operators handled in a standard way -- the first pre-defined by the language, the second defined by either object. Parentheses & brackets clearly can't be extended this way, since a(opName) and b[opName] already have clear meanings to the compiler. Braces likely would not work for a similar reason. I don't know that : is the appropriate character to use here, nor whether its use would cause other problems during lexical analysis. I think it's worth considering any characters that might be appropriate. Somehow the :: isn't quite as satisfying or obvious in matrix applications as () or []. I kind of like the degree symbol someone else proposed as the modifier. Too bad it's not more generally available. In any case, we don't *need* to solve the general problem -- but it wouldn't hurt to consider it. If such a mechanism had been already in Python, we probably wouldn't be having this discussion. Regards, John From pduffin at hursley.ibm.com Wed Jul 26 08:31:48 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Wed, 26 Jul 2000 13:31:48 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> Message-ID: <397EDA34.9CFF2BF2@hursley.ibm.com> Mark Hammond wrote: > > "David Arnold" wrote in message > news:200007260357.NAA28707 at xevious.dstc.monash.edu.au... > > -->"Alex" == Alex Martelli writes: > > > > Alex> since IL does not support multiple inheritance of > > Alex> implementation, which full Eiffel wants; dunno what Python > > Alex> .NET will do about that). > > > > urk! is that true? mark? is this an issue for Python/IL ? > > Yes, and yes. > > Not a huge problem for Python - just a "to be implemented" :-) Python > defines very dynamic semantics, meaning we can fake this. > > For example, multiple inheritance when used from Python will work just > fine - but if you look at this Python class using the .NET disassembler > (for example), it will not be apparent that this MI exists - the compiler > will simply generate the code to populate the __bases__ attribute of the > class, but the actual attribute lookups will still be done at runtime. > However, I believe that raw benchmark figures will keep pressure on the > Python port having the necessary tricks to take full advantage of the > platform when necessary. > > Neil's previous post about the homogenisation of the languages is pretty > close to the truth - except that this is as much a time and effort issue > as a requirement forced by the platform. The Eiffel and Python efforts > are both putting the existing language semantics over new .NET features, > but the pressure of getting working code out means we are willing to make > short-term compromises to get a reasonable 80% solution. It has been a > moving target, and anyone expecting to find a fully functional > implementation of _any_ non-MS language is going to be disappointed. > Fortunately, we appear to have a reasonable amount of time before this is > actually released, so it is still very much early days. > How likely do you consider the possibility that Microsoft will change the IL to allow the non-MS languages to be fully supported ? Unless the probability is VERY high what is the point of doing this at all as you would end up with a versions of the language which were not compatible with the other versions. From david at tumbleweed.com Thu Jul 13 13:02:20 2000 From: david at tumbleweed.com (david at tumbleweed.com) Date: Thu, 13 Jul 2000 17:02:20 -0000 Subject: getpid Usage Message-ID: <8kksms+n5h5@eGroups.com> Is there some convenient way of getting os.getpid to return the PID of a given executable? What I want to do is start a process and know it's PID. When I do the following I get the PID of the python executable. os.system("path") os.getpid() Alternatively, as a hack, I am doing: os.system(self.m_server_start_exe) for line in os.popen("ps -ef | grep -i IMEController | awk '{ if (NR > 1) { print $2 }}'").readlines(): pid = line[:-1] I would rather just path in an executable name/pathname and have it return this process' pid. Is there an updated version of os.getpid I could use to do this. If not, is there a better solution that is not shell dependent? Thanks, David From W.Whiten at mailbox.uq.edu.au Fri Jul 21 18:04:49 2000 From: W.Whiten at mailbox.uq.edu.au (Bill Whiten) Date: Sat, 22 Jul 2000 08:04:49 +1000 Subject: Operators for everything (was Re: Operators for matrix) References: <3977AF5E.552F4F42@my.signature> <39789C90.B1212E48@prescod.net> Message-ID: In article <39789C90.B1212E48 at prescod.net>, Paul Prescod wrote: > Michael Hudson wrote: > > > > The semantics would be: > > > > a @ b === (a,b) > > > > for any valid identifier . > > > > There are still precedence issues, but I think they can be ignored > > (make everything of this from the same (low) precedence & left > > asssociative). > > I like this idea. Is it appropriate to have just the whitespace as the > delimiter though? You could terminate with another @ or _ . Or these, plus the alternative of white space. None is perfect - but it could be practical and useful. > > It also seems like it could be combined (perhaps painfully) with the > requirement that some operators take parameters: > > a @foo(x,y) b This could build a nice tensor notation. Eg the arguments specify the summing subscripts. Regards, ----------- Bill Whiten, W.Whiten at mailbox.uq.oz.au Julius Kruttschnitt Mineral Research Centre, The University Of Queensland, Tel: int +61 7 3365 5888 Isles Rd, Indooroopilly, Fax: int +61 7 3365 5999 Brisbane Qld 4068, AUSTRALIA. From gmcm at hypernet.com Wed Jul 5 16:39:50 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 05 Jul 2000 20:39:50 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <8F68A4032gmcmhypernetcom@199.171.54.194> Warren Postma wrote: > >"Gordon McMillan" wrote in message >news:8F655BA3Egmcmhypernetcom at 199.171.54.154... >> [posted and mailed] >> C'mon Sean! You've been around a while. You know when __getattr__ >> hacks go bad it's because they go recursive. (And the stack size on >> Windows is off by some tiny amount, so it GPFs instead of traps.) > > >That kinda says (a) Windows Sucketh, and (b) surely there must be a >workaround for the Infinite-Recursion-Crash bug? Well, (a) is your own conclusion, not mine; and Christian also has a tiny little patch that fixes (b) for standard Python on Windows (it's a miscalculation in Python's config that doesn't leave enough stack space for handling the traceback). I don't use it, because I know the symptoms, and can usually fix the problem before the stack trace finishes printing. >Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. >Hope that stackless makes it into the official python, by 1.7, or if >not, there's always 3000. Here's hoping. I love it too, but it gives you a whole bunch of entertaining new ways to get into infinite recursions. - Gordon From avv at quasar.ipa.nw.ru Fri Jul 28 14:54:30 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Fri, 28 Jul 2000 11:54:30 -0700 Subject: to better observe locales Message-ID: <3981D6E6.CE74151D@quasar.ipa.nw.ru> Hi Python Author and Contributors, I hope it's not too late to discuss this. It seems that Python would better observe locales at almost no cost. 1. list.sort(). If the sorted list is just a list of strings, it's trivial to pass 'strcoll' as an argument. But if the list element is a tuple, I have to write my own comparison function which would use locale. 2. Those '\xxx\yyy\zzz' in the string literals, emitted by 'repr'. It would be a good idea not to encode that way those letters, which are claimed as letters by the locale. The default locale is easily read from the environment both on Unices and on win32. No idea about the rest of the world. Therefore, if the locale, read from the environment, is not 'en', one may just apply its rules immediately upon interpreter startup (for the two mentioned issues, and maybe some others: use strcoll instead of strcmp _everywhere internally_, use letter ranges, defined by the locale, etc). Otherwise the current Python supprt of locales would really have no practical use, even mislead those who believe that support to exist. Thank you in advance Alexander From dgoodger at bigfoot.com Sun Jul 2 22:00:50 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 02 Jul 2000 22:00:50 -0400 Subject: multiple inheritance in Python? In-Reply-To: <395FE156.C0C13FBE@esec.com.au> References: <395FE156.C0C13FBE@esec.com.au> Message-ID: on 2000-07-02 20:41, Sam Wun (swun at esec.com.au) wrote: > Does anyone have example of implement multiple inheritance in Python? My typelib.py module does (available at http://gotools.sourceforge.net/sgflib in the sgflib.tgz archive). It defines classes which emulate most of the Python built-in types (duplicating functionality in UserList and UserDict, I know; I wrote it before I "discovered" these two standard modules :). Multiple inheritance is emplyed for common functionality reuse. For example, both the Number and String classes support the "%" (modulo, or string formatting) operator, so that functionality is implemented in the ModMixin class, which is inherited by both classes along with other superclasses: class Number(SuperType, AddMulMixin, ModMixin): class Sequence(Container, AddMulMixin): class String(Sequence, ModMixin): Hope this helps. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From gerrit.muller at philips.com Fri Jul 28 08:49:30 2000 From: gerrit.muller at philips.com (Gerrit Muller) Date: Fri, 28 Jul 2000 12:49:30 GMT Subject: [Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> Message-ID: <3981815A.58A7070F@philips.com> The most effective letter contains an open question: asking for clarification and rationale. Give CNRI the credit for years of active support and hence assume a good intention. A letter which sounds like an accusation will force CNRI in the defense, which at best results in political correct statements and worst case in lawyer lingo or silence. Peter Schneider-Kamp wrote: >[...snip...] --- begin open letter ------------------------------------------------------- > To: Dr. Robert E. Kahn , > (president of The Corporation for National Research Initiatives) > > Dear Mr. Kahn, > > as a member of the Python Community which gathers around the newsgroup > comp.lang.python I would like to express my concern about the latest > license issues that have arisen around the new 1.6/2.0 releases. > > As of now I have not had the chance to witness any official statement > from your institution. So I sincerely request a clarification of CNRI's > position on this matter. We are especially interested in the underlying intention of this change. > > I have attached a list of signatures of members of the Python Community > who are also concerned about the recent developments and through their > signature support this request for clarification. > > Kind regards, > Peter Schneider-Kamp > > P.S.: > I find it rather startling that you see a need to change the license of > a software whose development already has moved away from your institution. > > --- end open letter ---------------------------------------------------------- > --- begin signature list ----------------------------------------------------- > Diehard Py. Fan (diehard at python.fan) > Implementation Issue (impl at implement.com) > Want My Python Now (Want.My at Python.Now) > ... > --- end signature list ------------------------------------------------------- > > Or should it better by a letter from the community to CNRI? Don't make it too anonimous, a single spokesman backed by the community is OK. > > while 1: if feedback: break > Peter > -- > Peter Schneider-Kamp ++47-7388-7331 > Herman Krags veg 51-11 mailto:peter at schneider-kamp.de > N-7050 Trondheim http://schneider-kamp.de -- ------------------------------------------------------------------------- Gerrit Muller Philips Research Laboratories Eindhoven Building: WLp 1 17 Prof. Holstlaan 4 Phone: +31 40 27 45242 5656 AA Eindhoven Fax: +31 40 2743741 The Netherlands mailto:gerrit.muller at philips.com http://www.extra.research.philips.com/natlab/sysarch/index.html From tim.hochberg at ieee.org Thu Jul 20 10:39:02 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 20 Jul 2000 14:39:02 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > In article , > Huaiyu Zhu wrote: > > > > matrix element names (with prefix m or e) > > + .+ add > > - .- sub > > I am strongly opposed to operators of the form ".+". What happens if > take an expression of the form "5.+matrix"? No, that goes against the > Python rule of having zero ambiguity. Note that if .+, etc are matrix operations, there is no ambiguity since (5.)+A, etc. is not a legal expression, so the only interpretation is 5.(+A). Still it looks confusing. I think we should consider Konrad's suggestion of (*) or something similar. -tim From level2junkie at my-deja.com.bbs Mon Jul 17 11:40:02 2000 From: level2junkie at my-deja.com.bbs (level2junkie at my-deja.com.bbs) Date: 17 Jul 2000 15:40:02 GMT Subject: freeze .pyw files? Message-ID: <3bRGl2$ja5@openbazaar.net> Can someone tell me if it's possible to freeze a .pyw file. I've gotten freeze to work with .py files, but for some reason it seems to hate the .pyw files. I'd rather not have that console window pop up everytime I want to run my application. Does anyone know how to freeze a .pyw file? Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sun Jul 16 23:35:23 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 16 Jul 2000 22:35:23 -0500 Subject: Wishlist sumbission form? References: Message-ID: <39727EFB.77234AEA@prescod.net> Matthew Cline wrote: > > Is there any way of submitting feature requests for Python, > other than by filing a bug report? I don't think so. If it is a very targeted request, you could try the but report route. If it is large and arguable, you should probably post it here and get some people to support it. If its good, someone will implement it. In open source software, only the features that developers are interested in get implemented so a wish list might well get ignored anyhow. It's not that nobody cares what you think it's that there's an infinite list of wishes so people tend to attack them in the order in order of personal interest or widespread demand. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From bjorn at roguewave.com Tue Jul 18 17:37:23 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 18 Jul 2000 15:37:23 -0600 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <3974CE13.3267A16B@roguewave.com> Andrew Kuchling wrote: > > This is a first experiment in whether I can make a useful, > interesting, somewhat coherent summary of python-dev activity. > If reaction is favorable, and time permits, it may become a biweekly > posting. > > --amk I think a lot of people would appreciate this (including me)! [snip] > ESR suggested adding a standard lexer to the core, and /F suggested an > extension to regular expressions that would make them more useful for > tokenizing: > http://www.python.org/pipermail/python-dev/2000-July/012032.html Wasn't there an announcement about plex(?) a little while ago (a pure python implementation of a lexer)? -- bjorn From to_get_my_address at see.my.signature Thu Jul 27 01:01:11 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 18:01:11 +1300 Subject: Python is wierd! References: <8lk1c5$fv4$1@nnrp1.deja.com> <8llqkl$rof$1@nnrp1.deja.com> Message-ID: <397FC213.88603B9E@see.my.signature> Jonathan wrote: > > you can even declare a instance > variable out of the scope(am i right?) Strictly speaking, you never "declare" anything in Python. Even the class and def statements are executable statements that create an object and put a reference to it in the current namespace. And to answer your question, yes, you can create an instance variable at any time simply by executing "instance.name = value". -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From jeremy at beopen.com Mon Jul 10 14:29:42 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: Mon, 10 Jul 2000 14:29:42 -0400 (EDT) Subject: RADIUS authentication poll Message-ID: <14698.5654.645828.624122@bitdiddle.concentric.net> We recently received a module submission for the Python standard library that implements very basic RADIUS authentication. It's not clear how widely useful this module would be. I've never heard of RADIUS authentication before, so I'm inclined to think it is a bit obscure for the standard library. If you think I'm wrong and would like to see it in the library, please send me a note to that effect. I'll be happy to include it by popular demand. The module can be viewed from the Python patch manager at SourceForge: http://sourceforge.net/patch/download.php?id=100700 -- Jeremy Hylton From hinsen at cnrs-orleans.fr Wed Jul 26 05:23:27 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 26 Jul 2000 11:23:27 +0200 Subject: linear algebra in pure Python? References: <397E9CBC.2AD8FA89@crystal.uwa.edu.au> Message-ID: Douglas du Boulay writes: > I know that there is the Numeric python extension and/or the > Matrix extension MatPy, but is there not anywhere a pure Python > linear algebra package exploiting lists of lists for matrices and the > like? I can send you an array class written in Python and using lists of lists as data representation. However, there are none of the standard linear algebra operations (inversion, eigenvalues, ...), and for a good reason: performance. Even for matrix multiplies this class is a few orders of magnitudes slower than NumPy! In case anyone wonders why I wrote it: it was used as a case study in the early days of NumPy development, before the C implementation was written. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From michealk at newlix.com Mon Jul 31 10:14:28 2000 From: michealk at newlix.com (Micheal Kelly) Date: Mon, 31 Jul 2000 14:14:28 GMT Subject: Accessing NIC configuration via Python Message-ID: <8Rfh5.23380$07.914891@news1.rdc1.on.wave.home.com> Hoping someone can help: Earlier I posted a message asking how to access low-level Linux network information in Python - Shae Erisson was kind enough to point out gnetstat (http://www.linuxcare.com.au/projects/gnetstat) to me... Unfortunately, this wasn't quite what I was after. What I'd really like to get is low-level NIC configuration information, such as the device names of all configured ethernet cards (eth0, eth1... ethx), their IP addresses, netmasks, etc. I could do this by parsing the output of ifconfig, but for various reasons don't want to do that. Is there any sort of low-level interface that I can access via Python to get this information? I've looked through /proc to see if there was something I could read, but nothing that seems to contain the information I'm after. Help! :) - Mike K. From m.faassen at vet.uu.nl Tue Jul 4 07:36:02 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jul 2000 11:36:02 GMT Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: <8jsi72$r02$1@newshost.accu.uu.nl> PM wrote: > My head hurts. I'm sorry to hear that. > If I move to Python from Java from RPG from C++ from C from Basic from > 6502, am I really, really, really, really stupid? I was not very good at > -any- of them, but I'm as persistent as a crap dance record on Radio 1. Persistence is important in a good programmer. :) I skipped Java and RPG and 6502 (I did Z80 there), insert some Pascal somewhere in the list and a smattering of other languages, but I don't consider myself stupid and came to Python. > Will this group answer all questions, It's decent at getting questions answered, yes. Not all. > solve life's problems? Unlikely. :) > Can Python kick large bottoms with decent database access - not just SQL > not ODBC, could it go to DB2/400? I don't have any experience with DB2/400, but I would imagine that if someone hadn't whipped something up already, it's possible to do so. > What I liked about good old DOS/basic was the ability to knock-things up > and try things out, now that's what has piqued my interest in Python, > but is it true.... Yes, Python is good for that kind of iterative style of programming; rapid prototyping is easy. Advantage above Basic is that the programming language is actually nice and powerful. > I'll probably waste some time trying to find out, Good -- have fun! > but I'm not 14 years old. Wish I was - and could still drive my Audi. I'm-not-14-years-old-either-and-don't-have-an-Audi-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From olivierS.dagenaisP at canadaA.comM Sun Jul 16 23:54:48 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 17 Jul 2000 03:54:48 GMT Subject: problems trying wxPython in Win 95 References: Message-ID: I also had a problem with running a wxPython app on a Win95 machine. Mine was crashing in the wx(something).DLL. I think it might have been an MFC DLL issue, which I have seen a few posts discuss in this newsgroup before. Try a search on www.deja.com (go to USENET, and then find this newsgroup and search for something like "wxPython MFC") to see what turns up... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Rob" wrote in message news:iFtc5.19052$V34.236887 at news1.sttls1.wa.home.com... > I want to run the demo program included in wxPython 2.1. Upon starting it I > immediately get the message appended to this post. I have two versions of > Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and > get the same result. I tried running it from the console, from PythonWin, > and from IDLE, all with negative results. Does anyone have an idea of what > is going on? > > Thanks, Rob. > > PYTHONWIN caused an exception c06d007eH in module KERNEL32.DLL at > 0137:bff9a07c. > Registers: > EAX=0063d7bc CS=0137 EIP=bff9a07c EFLGS=00000246 > EBX=00000000 SS=013f ESP=0063d7b8 EBP=0063d80c > ECX=0063d7d4 DS=013f ESI=0063d864 FS=2287 > EDX=ffffffff ES=013f EDI=00000000 GS=0000 > Bytes at CS:EIP: > 5e 8b e5 5d c2 10 00 64 a1 00 00 00 00 55 8b ec > Stack dump: > 018a9c34 c06d007e 00000000 00000000 bff9a07c 00000001 0063d830 bff782c7 > 817f9000 81821708 00081822 00000000 0063d6e3 00000000 bff7c4f7 0188e4d0 > > From chwieser at ee.oulu.fi Wed Jul 5 05:33:52 2000 From: chwieser at ee.oulu.fi (Christian Wieser) Date: 5 Jul 2000 09:33:52 GMT Subject: py-libcap Message-ID: <8juve0$n1o$2@ousrvr3.oulu.fi> -- Morning, I am in need of py-libcap. Unfortunally the link at Pamasus is down ;-( http://www.vex.net/parnassus/apyllo.py/126307487.528281449 Can someone please send me the file? And maybe an example? By the way: Is there a wrapper for libnet to inject IP packets too available? Regards, -- Christian Wieser - Oulu Secure Programming Group mailto: chwieser at ee.oulu.fi See my homepage at http://www.ee.oulu.fi/~chwieser for my PGP-Public-Key From jesse at multimediacollective.com Fri Jul 28 14:47:14 2000 From: jesse at multimediacollective.com (jesse at multimediacollective.com) Date: Fri, 28 Jul 2000 18:47:14 -0000 Subject: finding/counting files Message-ID: <8lskfi+r5ek@eGroups.com> What would the proper command be for finding a file within a folder? I want my program to check to see if there is a folder called 'test.txt' in the folder, and if there is, count the number of files in that folder. What commands would I use for both these problems? From stephen at cerebralmaelstrom.com Mon Jul 10 01:19:00 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Mon, 10 Jul 2000 05:19:00 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> Message-ID: <81da5.125084$WS3.1096675@typhoon.we.rr.com> I do not know any specifics on C#, but I do know (or believe, at least) that: #1) There is no Java code used in C# #2) The language is not going to be designed in the exact same way #3) The language does not claim to be Java Exactly what do you think Sun can do? File for copyright infrigement? What did the copy -- the purpose of the language? You can't copyright an entire field or application for something. Neither can you patent it -- you can only patent a specific method or device that is being used to accompilsh the terms. So what if C# behaves ever so much like Java. Java is rather similar to other languages, too. As far as i'm aware, you can get around software patents or copyrights by simply rewriting the software yourself. It can fit into the exact same nitch, but its your code done your way. --S Thaddeus L. Olczyk wrote in message news:3968fadf.299209218 at nntp.interaccess.com... > On Sat, 01 Jul 2000 05:10:50 GMT, Courageous > wrote: (snip) > Nope. Microshit is stupid to even try to copy Jva. I hold up a page of > Java code and a page ofC++ and tell you which is which. Java is not a > variant of C++. Java is a very different variant of C . Otherwise it > would not be so popular. After all, if it were a C++ variant why would > people go to all the trouble to switch from C++. > > C# OTOH is a clear rip off of Java. It is hard if not impossible to > take a C# program remove all "Microsoft Enhancements" ( meaning > all the features that tie it to COM ) and have it not look like a Java > program. I suggest that if you want to continue Astroturfing, you > learn something about programming language syntax. > > > From amused at webamused.com Sat Jul 1 11:51:48 2000 From: amused at webamused.com (Joshua Macy) Date: Sat, 01 Jul 2000 15:51:48 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> Message-ID: <395E05CD.E38F642C@webamused.com> "Thaddeus L. Olczyk" wrote: > > On 28 Jun 2000 06:02:09 GMT, thomas at xs4all.nl (Thomas Wouters) wrote: > > >On Wed, 28 Jun 2000 04:05:21 GMT, Courageous wrote: > > > >>> On top of that, very likely that if SUN sues they win. > > > >>Ridiculous. > > > >Very much so. But it wouldn't be suprising just the same, given the American > >patenting/registration practices and the average american courthouse ;-) > > > >Overseas-ly y'rs, > > Thomas > Virtually all SUN has to do is pull some of the demo programs out of > Microsofts manual. Write the equivalent code in python, perl, C++, > pascal, and a few other languages. Compare them side by side. A fairly > sophisticated person can see that it's resemblance to Java. Look at > the law judges are sophisticated enough. Given that Microshit is being > sued by SUN for their abuse of Java, I don't think it will be hard at > all for SUN to convince a judge that all C# is, is a variant of Java > with tons of proprietary crap glued on and the label changed. You seem to be under the misapprehension that under American law, Sun owns the very concept of the Java language--that's just not true. Microsoft could make their own version of Java if they wanted...that's perfectly legal; IBM is contemplating doing just that. What Microsoft did wrong was they used Sun's own code, which came with a license that forbade making incompatible extensions, to make an implementation with incompatible extensions. If they had gone to the effort of making a clean version of the code, they would have been in the clear. The only problem they would have faced is that they might not have been able to use the Java trademark, which--guess what--C# doesn't do. Joshua From slinkp23 at yahoo.com Mon Jul 10 06:43:04 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 10 Jul 2000 06:43:04 -0400 Subject: Namespace weirdness References: <3968E1B0.B6E6F3E9@yahoo.com> <8F6CECA93gmcmhypernetcom@199.171.54.194> <39692118.9D6EAFAA@yahoo.com> Message-ID: <3969A8B8.FCA803F3@yahoo.com> Tim Hochberg wrote: > Just to add to keep tings a bit confusing, let me show a way to do more or > less what you're trying to do. I don't really recomend it, but it's an > entertaining little trick. There are two signifigant changes: first the > class definition is moved up yet another level so that it's defined in the > __init__ function. This is because you're really trying to get at instance > data, not class data. The second change is to specificall add the instance > namespace to the BodyPart class. I also manually added BodyPart to the > instance namespace since otherwise there would be no way to get at it. So > here, for your entertainment is the final version. Enjoy! > > class Food: > def __init__(self, attr1): > self.attr1 = attr1 > class BodyPart: > def do_it(self): > print self._foodInstance.attr1 > BodyPart._foodInstance = self > self.BodyPart = BodyPart That is very peculiar indeed. attr1 is now shared across all instances of Food.BodyPart() which indeed has the effect I wanted. I can even manually change attr1 and it affects all subsequent calls to Food.BodyPart.do_it(). I like that, but the fact that it's so unusual makes me think that this is probably not the best way to design my app... The whole thing I was trying to avoid was passing a hundred arguments to a dozen objects contained within a Food instance, and it turns out there's a better way. (I should learn to just ask "How should I do x?" rather than "Can I do x in this particular strange fashion?") The job I'm trying to do has a _lot_ of variables involved, and being a novice I of course came up with the weirdest possible strategy for avoiding a lot of typing. :) And of course there's a better way, see below. For instance I didn't want to have to say: class Food: def __init__(self, arg1, arg2, arg3, ...arg100): self.arg1 = arg1 self.arg2 = arg2 ... self.arg100 = arg100 # Note below that I can't just say SomeClass(arg1, arg2...) # because then changing some_food_instance.arg1 will not # affect some_food_instance.some_SomeClass_instance, # which I need it to do. self.thing1 = SomeClass(self.arg1, self.arg2, ...self.arg100) self.thing2 = SomeClass(self.arg1, self.arg2, ...self.arg100) ... class SomeClass: def __init__(self, arg1, arg2, arg3... arg100) self.arg1 = arg1 self.arg2 = arg2 self.arg3 = arg3 ... self.arg100 = arg100 ... See my point? for each argument, I have to type the argument twice to get it into my Food class, then twice more for every class that needs to do something with it, then at least once more to actually use it in a method. So for N parameters that affect Food, I have to type as many as N * 5 variables just to do anything at all. This seems like too much work. If N = 100, and it might be, it will drive me crazy. But I overlooked the obvious. Just stuff all those arguments into a dictionary! Then my code above looks like: class Food: def __init__(self, args = {}): self.args = args self.thing1 = SomeClass(self.args) self.thing2 = SomeClass(self.args) ... class SomeClass: def __init__(self, args) self.args = args def do_something_useful: print self.args['some_key'] ... Ahhh, much better. Now I only have to deal with the entire list of args (now keys) once, when I create a Food instance, and then just reference each by key when needed. And accessing the parameters as args['key'] is actually a lot easier than typing self._parentInstance.arg1 or some such weirdness. p.s. there are several common English insults that take the form of Food.BodyPart, hence my weird choice of names. egg.head meat.head cheese.head lard.ass pizza.face beer.belly I have the feeling there are more... -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From peter at schneider-kamp.de Wed Jul 12 04:51:28 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 12 Jul 2000 08:51:28 +0000 Subject: Sound module question References: <396BBA07.E844152@bresnanlink.net> Message-ID: <396C3190.ACB821A8@schneider-kamp.de> Aaron Berg wrote: > > I started programming python a few months ago and I am still learning. > Does anyone know of a sound module for simple reading and writing of > sound in linux? I know there is a win32 sound module and there is one > for SGI but is there one for linux? oss or alsa... I don't know much > about this issue so it is possible i am just looking in the wrong place. There is a linuxaudiodev module, but that's probably not what you are looking for (too low level?). I don't know what that does. A Python soundserver for linux is available from http://pysol.tsx.org For an application that uses it you are also right on that page (hint). It can play WAV, MP3 and MOD files and uses the SDL library. You also need another library called smpeg (or so, look at the README that comes with the soundserver). SDL is a sound library which runs on win32, linux and (as I understand) some other systems. So you should be pretty portable with that one. I haven't tried, but I think extending that module to play other sound etc. should be easy. hope-that-helps, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From fiona at sitegnome.com Wed Jul 5 19:53:39 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 06 Jul 2000 09:53:39 +1000 Subject: [ANNOUNCE] Python Snippets added to python.faqts.com Message-ID: <3963CA83.5A50F446@sitegnome.com> Many thanks to Hans Nowak for providing FAQTs with his collection of snippets for entry into http://python.faqts.com. They can be found directly at http://www.faqts.com/knowledge-base/index.phtml/fid/538/lang/en The knowledge base now contains greater than 653 questions with answers!! regards, Fiona Czuczman From gregholmes at my-deja.com Thu Jul 6 13:09:26 2000 From: gregholmes at my-deja.com (gregholmes at my-deja.com) Date: Thu, 06 Jul 2000 17:09:26 GMT Subject: tkinter frames References: <8k26af$1nq$1@nnrp1.deja.com> Message-ID: <8k2efs$7fd$1@nnrp1.deja.com> Don't you need to pack() or grid() the label sometime? label1.pack() In article <8k26af$1nq$1 at nnrp1.deja.com>, Keith Murphy wrote: > can anyone tell me why this doesn't work? > > from Tkinter import * > > root = Tk() > myFrame = Frame(root, width=200, height=200, bg='red') > myFrame2 = Frame(root, width=200, height=200, bg='orange') > > label1 = Label(myFrame, text='hi') > > myFrame.grid(row=0, column=0) > myFrame2.grid(row=0, column=2) > > root.mainloop() > > ...(in my mind)it should display two colored frames, one containing a > label. > > thanks, > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From gregory.lielens at fft.be Thu Jul 20 14:17:17 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Thu, 20 Jul 2000 20:17:17 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39773559.77C3D696@yale.edu> Message-ID: <3977422D.ED3EAF05@fft.be> Paul Magwene wrote: > > Tim Hochberg wrote: > > > > Gregory Lielens writes: > > > > > Tim Hochberg wrote: > > [...] > > > I like the parethese a lot! except for ? which is probably out of > > > question, > > > this is the prettier way to do it, but (alwas a but :-( ) > > > > > > - the solve operator indeed...The only thing i can come with is the ugly > > > (%) > > > or the pretty but out-of-question (\) > > > > My favorite right now is |. So one would have: > > > > A[*]B # matouter > > A(*)B # matinner > > A(/)B # matdiv > > A(|)B # matsolve > > A(^)B # matpower > > > > Alternatively, one could use: > > > > A(*)B # matouter > > A(.)B # matinner (AKA dot, get it?) > > > > That would cut down on the available symbols, but might make parsing > > easier? It might also be easier to distinguish between the two > > products. > > > > I've left out other potential outer operators (outer sum, etc) and > > alternate inner products (Lie, Kroneker, ?) pending finding a > > constituency for them. > > Kronecker products get used enough (at least in statistics) that I'd > hope we'd include 'em (we're already on our way down the slippery slope, > so I may as well lobby for operators *I* want ;-). > > How about: > > A{*}B # matkron > > (Paralleling A[*]B for matouter, and A(*)B for matinner) I think thay may be a little too many products here( - I never though I would say that :-)), am i wrong? I would let the inner (*) and element product * be the main one (they are the more used, I think ... at least tey were the only one i was aware of (except vector/cross product for vectors) 2 hours ago!) The other ones could be functions, or mapped to a third unallowed product-like sign, [*] for example, depending on your particular field...A general inner/outer product specifing indices of contraction,and new dummy indices, could probably be used to defined quite easily all these particular products... here is my attempt for matouter a[*]b as an example, using my previous notation and a RemoveAxis which would be the pendant of NumPy NewAxis and will change a rank n tensor into a rank n-1 tensor with the same number of elements (a generalisation of matlab a(:) which transform a matrix in a column vector) (if this looks completely ridiculous to you - it probably is, i am a beginner both in Python and NumPy, so do not hesitate to correct my stupid errors!) def __specialproduct__(self,b): rank4tensor = self.i(1,2) (*) b.i(3,4) return(rank4tensor[RemoveAxis,RemoveAxis,:,:]) What do you think? Greg. From hzhu at localhost.localdomain.bbs Mon Jul 17 21:50:02 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 18 Jul 2000 01:50:02 GMT Subject: Does Python support interfaces? Message-ID: <3bRWfR$lLf@openbazaar.net> On Tue, 18 Jul 2000 01:08:03 GMT, Randall Parker wrote: >I'm quite new to Python. For those who are familiar with Java interfaces: >Does Python have a similar facility? > >Can one declare interfaces, then declare that a class implements some >interface, instantiate an object of that class type, and then cast it to >an interface that it is declared to support and then pass it around as a >reference to that interface type and make calls to methods of that >interface type? > Maybe someone has a better solution, but here's a little program that checks which method is implemented in which class, of what type. You can add more bells and whistles in similar fashion (like the names of arguments) http://x53.deja.com/getdoc.xp?AN=635109618 I can only track it in deja news. It seems that the archive for Jun 1-15 is missing from pipermail archive. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From paulb at infercor.no Fri Jul 28 13:09:36 2000 From: paulb at infercor.no (Paul Boddie) Date: Fri, 28 Jul 2000 19:09:36 +0200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> Message-ID: <3981BE50.23DB16C5@infercor.no> Alex Martelli wrote: > > "Paul Boddie" wrote in message > news:39814767.FFEFE5D0 at infercor.no... > [snip] > > > 1 + "foo" = string ("1foo") > > > > Doesn't Perl do this last one as well? I refer you to the example I give > above - > > Nope; in Perl, 1 + "foo" is 1. I was probably referring to Perl's string concatenation operator. > > to have such behaviour permeating one's code is "nasty" to say the least. > > I do consider it impractical, but what's "nasty" about it? Well, the string concatenation is not so nasty, provided that you want the number to be encoded in decimal notation within the string, for example. After all variables, unlike literals, may not contain number base information and so you might not be able to direct the encoding implicitly. Of course, explicit method or function calls in Java and Python can also cause the "wrong" encoding to be used: numberVariable.toString(); // Use the java.text package. str(numberVariable) // Use format strings. > Specifically: in mathematics, there is a natural injection from naturals to > integers, from integers to rationals, from rationals to reals, from reals to > complex. Unfortunately, things are *NOT* all roses and wine in the > real world, because we don't really have rationals in Pythons (much less > reals, of course:-), but rather an approximation -- so, precision-loss, > which is a form of information-loss, threatens...: > > >>> long(12345678901234567890123L*1.0) > 12345678901234567741440L Indeed. I do recall noting that some people are irritated by such behaviour. Also, in the indirectly related area of the string encoding of longs with the "L" suffix, such results of the str function were once an irritation too, although I think that issue is to be fixed in 1.6. > > whereas 1 + "foo" is meaningless to almost everyone except Perl coders. > > No way -- it's perfectly valid in C, too, except that there it means the > constant-string "oo". Really, truly, X my heart, I kid you not, check it > out if you don't believe me (I wouldn't blame you for disbelieving this!). I did do C before Python, and sometimes write the occasional C program, so I am aware of this "interesting" possibility. However, I believe that the result of adding 1 to "foo" is implementation dependent, as Cameron Laird pointed out. (I don't recall the size constraints on the char type, however.) Regards, Paul From cpr at emsoftware.com Tue Jul 25 13:10:39 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Tue, 25 Jul 2000 17:10:39 GMT Subject: Python & AI References: Message-ID: See http://www.norvig.com/python-lisp.html for a start. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "rhymes" wrote in message news:fr8rnskopofu13smscl4rm0b1pacisbikk at 4ax.com... > > Do u know something on the net related to Artificial Intelligence and > Python Language?? > > Thanx in advance. > > Lawrence Oluyede > > rhymes at tiscalinet.it > > "Per cambiare, > per diventare un' altra cosa > dobbiamo prima sapere cosa siamo" > > Bruce Lee From pete at visionart.com Mon Jul 17 18:49:02 2000 From: pete at visionart.com (Pete Shinners) Date: Mon, 17 Jul 2000 15:49:02 -0700 Subject: event handler advice Message-ID: <8l033n$pr2$1@la-mail4.digilink.net> i'm trying to write a simple event handler python class. so far i haven't come up with an 'elegant' solution i was expecting. i have a list of different messages, and they are all given different interger values. this list is defined in a C extension, for example msg.INIT, msg.EXIT, msg.STOP, msg.PLAY, ... i want to make a inheritable class that receives one of these messages and calls a member routine with the same name. my handler doesn't know the name of the variable, since python only sends it the INT value. so i need to find some nice way to map these message ids to a method name. i then need to get this name and have the class call it on itself. the end result being i can call "mymessagehandler_inst.handle(msg.PLAY)" and this will in turn call "mymessagehandler_inst.PLAY()" there's a good sized list of these messages, and in the future it will likely expand my guess is i need some dictionary that defines the messages and their routine name (no shortcut way to do this unless python had #define like macros :]) messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} then a routine like class basehandler: def handle(messageid): name = messages[messageid] self.name() #HAHA, no really, how do i do this? but i'm not exactly sure how to write this. need help, thx From alex at magenta.com Mon Jul 3 10:43:00 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 16:43:00 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr><8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> <8jplru0lfe@news2.newsguy.com> <962626013.769258863@news.libertysurf.fr> Message-ID: <8jq90e014sb@news2.newsguy.com> Jerome Quelin wrote in message news:962626013.769258863 at news.libertysurf.fr... > "Alex Martelli" wrote: > >These are excellent arguments for always using accessors from OUTSIDE the > >class. Jerome, however, was talking about using them from INSIDE the class > >as well, which is a different issue. > Sure, I'm always using accessors from outside. Bravo. One day you'll be happy you did. > But from inside the class, I don't know which is the best. I feel like the KISS > rule should apply, but what do you OO gurus think of it ? How far encapsulation > should go ? "Do the simplest thing that could possibly work". For a class not meant to be inherited from, that implies accessing the attributes directly until and unless very specific reasons emerge such that this "cannot possibly work" any more. It is quite unlikely that such reasons will ever emerge, and, if and when they ever do, then refactoring your program is not going to be a horribly huge cost to pay. 99+% of the time you will enjoy the simplicity and the resulting reduction in hassles, and the price of refactoring is not disproportionate in those cases where it will be needed. (The tradeoffs might be somewhat different in other languages, but dynamic ones such as Python strongly enable this excellent approach). Alex From lordkaos at my-deja.com Tue Jul 18 20:15:42 2000 From: lordkaos at my-deja.com (lordkaos at my-deja.com) Date: Wed, 19 Jul 2000 00:15:42 GMT Subject: newb question References: <3bRfYe$jTl@openbazaar.net> Message-ID: <8l2rv1$k2t$1@nnrp1.deja.com> Is the user inputting whatever variables he wants, or are you presenting the user with some variables that he assigns values to? e.g. >>>yourscript.py Input var,val pairs, separated by semicolons: cow=milk;pig=pork;red=1 Thank you (where the user keeps entering any/whatever variables and values they want, or like this...) >>>yourscript.py Give a value for 'cow':milk Give a value for 'pig':pork Give a value for 'red':1 Thank you. (that's all they get to set values for... whatever cow, pig, red you specifically program) Both scenarios are not too hard to implement, but they are different enough that you should distinguish between what you want to do... This will help me answer your question. --Jared In article <3bRfYe$jTl at openbazaar.net>, gee308 at mediaone.net.bbs@openbazaar.net (Toy) wrote: > Do you need to use classes? I'm a newb and I'm just writing a > "read-down"script with one or 2 functions. What do you mean by raw_input > and read() and write()? Thanks for th help. > Jason Toy > > lordkaos at my-deja.com wrote: > > > In article <3973EE1B.15B0B32E at mediaone.net>, > > Toy wrote: > > > what is a simple way I can save variables that people enter in from > > > 'raw_input' ? That way, someone enters the variables they want, then > > > when the script is booted up everytime the machine starts, it will > > grab > > > the variables from somewhere. Thanks. > > > Jason Toy > > > toyboy at toy.eyep.net > > > > > > > > The tutorial at Python's > > website tells a simple and easy way to do exactly what you're > > saying. If you can get the variables into a class (read section 9, in > > particular 9.3) then it is easy to read and write a big set of vars all > > together in one operation by using the 'pickle' command (read about > > this and easy file creation/opening in section 7.2). I just read over > > this and it should answer your question. Come to think of it, raw_input > > stores your input as a string, so you can just read() and write() in > > one swipe to do the same thing (This would be much easier). > > > > --Jared > > > > Sent via Deja.com http://www.deja.com/ > > Before Sent via Deja.com http://www.deja.com/ Before you buy. From niels at endea.demon.nl Fri Jul 28 09:21:09 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Fri, 28 Jul 2000 15:21:09 +0200 Subject: Python 2.0 - win32pipe routines inclusion for Windows References: <39802DB6.73CEC178@endea.demon.nl> <3980ABA5.4190FC4F@endea.demon.nl> Message-ID: <398188C5.B630AE23@endea.demon.nl> David Bolen schreef: > internally, the close() function has no automatic access to anything > outside of the file handle - the patch I proposed linked the selected > (stdin) handle to the original process handle, so a wait and retrieve > result could be done, but cross-linking all of the files that relate > to the same process handle, although not impossible, is much more > effort to ensure correctness. I had a quick look at the source and as far as I can tell you're doing something like _PyPopenProcs[id(files[0])] = hProcess when opening, and if _PyPopenProcs.has_key(id(file)): exit_code = GetExitCodeProcess(_PyPopenProcs[id(file)]) del _PyOpenProcs[id(file)] when closing. Maybe you could change this to something that saves all the file objects with a reference to the process handle and the number of open pipes, like: procdata = [hProcess, len(files)] for f in files: _PyPopenProcs[id(f)] = procdata when opening, and procdata = _PyOpenProcs[id(file)] procdata[1] = procdata[1] - 1 if procdata[1] == 0: exit_code = GetExitCodeProcess(_PyPopenProcs[id(file)]) del _PyOpenProcs[id(file)] when closing > > It would also mean subtlety in terms of knowing for sure if you are > getting the exit code or not. If somehow you didn't actually close > all the file handles you thought you did, you might mistake the > close() return of 0 on what you thought was the final handle for a > successful child process exit when you just hadn't happened to close > all handles yet. I thought that it would be easy to return None instead of 0, but looking at the code I realise that is not an option. Pity. Still, looking on the bright side, you *can* get the exit code this way, if you're careful, and with this approach I think nothing will work worse than it already did. > > Hmm - maybe implementing pclose() semantics in a popen#() environment > (e.g., not the normal plain popen()) isn't practical - I agree that we > don't want to leave the potential for a deadlocked wait for a child > process that an application can't protect against. Well, some way to get at the exit code would certainly be useful, even if it's not the easiest one imaginable. > > Does anyone know if the higher order popen# calls part of Posix? Does > it have defined behavior for retrieving exit codes in such a case? Posix has only popen. The others are Python-specific. The only "standard" is probably popen2.py. To get an exit code there you have to instantiate the Popen3 class explicitly, not through the popen2() and popen3() helper functions. Then you can call its .wait() method. Unfortunately win32pipe has no such object. By the way, wouldn't it be easier to implement all this stuff in Python, except for the basic Win32 functions? That is the way it is done on Unix. Surely speed is not an issue. CreateProcess is horribly expensive anyway. -- Niels Diepeveen Endea automatisering From pinard at iro.umontreal.ca Mon Jul 31 16:06:54 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 31 Jul 2000 16:06:54 -0400 Subject: random.shuffle? In-Reply-To: Erik Max Francis's message of "Mon, 31 Jul 2000 11:37:19 -0700" References: <3985C75F.7030AB6C@alcyone.com> Message-ID: [Erik Max Francis] > Fran?ois Pinard wrote: > > def shuffle(items): > > """Shuffle ITEMS in place. ITEMS should normally be a list.""" > > for top in range(len(items)-1, 0, -1): > > index = whrandom.randint(0, top) > > items[index], items[top] = items[top], items[index] > This is a biased shuffling algorithm. When swapping cards, you'd want > to pick the other card from the whole of the deck, not the deck that > you've touched so far. If you start with a sorted deck, for instance, > it's easy to see that cards can't end up in every place; see Knuth. "See Knuth" is rather vague. It reads like "Go fishing!". It would be more polite giving some precise reference of what you want me to look at. You also write: "It's easy to see that cards can't end up in every place;". I may be stubborn and opaque, but I do not see it. Please kindly explain. My feeling is that the algorithm above corresponds to what is being written in the Art of Computer Programming, volume II, section 3.4.2, algorithm P. My transcription may be wrong, of course, but then, please tell me where. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mark.w.daley at intel.com Fri Jul 28 11:53:13 2000 From: mark.w.daley at intel.com (Daley, Mark W) Date: Fri, 28 Jul 2000 08:53:13 -0700 Subject: Values and variables for Tk radio buttons Message-ID: <75F7304BB41CD411B06600A0C98414FCB36827@ORSMSX54> I am trying to struggle through the design of a GUI using Tkinter. I'm not doing to bad, for a beginner, but I am having a problem retrieving the values assigned by selecting a certain button. Here is the code I wrote (forgive the crudity, I'm not savvy with classes yet!): from Tkinter import * import dbi, odbc import time, os, sys servername = ['Server1', 'Server2', 'Server3'] name = (('None', 'None'), ('name1', 'Name1'), ('name2', 'Name2'), ('name3', 'Name3')) def die(): sys.exit() root = Tk() root.title("Test GUI") servar = StringVar() namevar = StringVar() for item in range(len(servername)): b1 = Radiobutton(root, text = servername[item], variable = servar, value = servername[item]) b1.grid(row = item, column = 0, sticky=W) for index in range(len(name)): b2 = Radiobutton(root, text = name[index][1], variable = namevar, value = name[index][1]) b2.grid(row = index, column = 1, sticky=W) q = Button(root, text = 'Quit', command = die, width = 10) q.grid(row = 13, column = 0, sticky = W) root.mainloop() This gives me two columns of radio buttons (the name tuple is longer, and contrived since I usually get the values from a database). I have no idea how to get the values from the buttons. Should I be doing something other than StringVar() for servar and namevar? - Mark ---------------------------------------------- The opinions expressed are mine, and are not necessarily those of my employer. From Richard.Jones at fulcrum.com.au Fri Jul 28 00:23:07 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 28 Jul 2000 14:23:07 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from Richard Jones of 2000-Jul-28 14:16:1, <200007280416.OAA31003@envy.fulcrum.com.au> Message-ID: <200007280423.OAA31058@envy.fulcrum.com.au> [Richard Jones] > Eh? You're comparing the assignment operation - the placing of a label on > an > object - with the automagical creation of an object? How is: > > a = 1 > > ... the same as > > $a = undef; > $a->{foo} = 1; ... or different. My apologies for not putting forward a reasonable argument here. I'm going to leave you all alone now. Better examples would've been nice - but Real Work intervenes. Richard From neilh at scintilla.org Mon Jul 10 23:56:25 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 11 Jul 2000 03:56:25 GMT Subject: Can anyone hear me? (was Solution to IDLE and Tkinter proble References: <200007110344.UAA23990@stevie.loop.com> Message-ID: > Sourry for the stupid question, but: Which path? Is it the > Pythonpath, the Windows path, the dos config.sys path, or some other > path? Thank you for a reply anyway. The path environment variable, which may be set in a DOS initialisation file - normally in autoexec.bat. Maybe it can be set in config.sys now. It is then used by Windows. Open a DOS box and type "set" which should reveal all your environment variables. Neil From tim_one at email.msn.com Thu Jul 27 13:41:10 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 27 Jul 2000 13:41:10 -0400 Subject: Python 3000 In-Reply-To: <8lp4t5$6bu$1@newshost.accu.uu.nl> Message-ID: [/F] > according to plans, 1.6 beta 1 will be released in > about a week. for more info, see PEP-160: > > http://python.sourceforge.net/peps/pep-0160.html [Martijn Faassen]> > What a mess. So that was why I didn't watch soap operas. :) > > It'd be useful for the community if there were some document out there > that described what the heck is going on, and why. That would be useful for me too <0.3 wink>. > Once all of this becomes a bit more clear for the parties > involved, that is. > > It keeps changing and it makes people worried. At least it makes me > worried. What can we do about that? In the short term it *is* a mess. While all the parties are negotiating, everything is subject to change, so if we say anything we're open to (valid!) "it keeps changing" charges, but if we say nothing, wild speculation fills the void. To my mind it compounds the uncertainties that CNRI says nothing in public. I think BeOpen PythonLabs has done everything it *can* do in the way of communicating what's going on, and if you want more than that then raising your concerns on c.l.py simply isn't going to help (AFAIK, CNRI doesn't monitor this newsgroup, so won't hear your concerns). still-speaking-for-nobody-but-me-ly y'rs - tim From rloisel at helicon.net Sun Jul 23 20:50:27 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Sun, 23 Jul 2000 20:50:27 -0400 Subject: my difficulty with Python was: IDLE window closes Message-ID: <397B92D3.80DB7160@helicon.net> The _Tkinter.pyd is already in the python\dll import Tkiner returns something like "if import Tkinter fails the Python may not be configured for Tk DLL load failed... So why wouldn't Python 1.5.2 be configured for Tk if it seems to depend on it for most activities. I got the distribution from the Python web page and used the install program. All I can do is ' run Python' or use the start menu icon and get the generic window with the >>> prompt. Not very useful. rloisel Sam Schulenburg wrote: > Usually the problem is IDLE can not find the Tk dll's. My solution has > been to copy the Dll's from the Tk\bin directory to the Python\DLL > directory. > > Sam Schulenburg > > In article , > "Olivier Dagenais" wrote: > > The Python binary might be in your path, but maybe the libraries > aren't? > > > > -- > > ---------------------------------------------------------------------- > > Olivier A. Dagenais - Carleton University - Computer Science III > > > > "Rodney Loisel" wrote in message > > news:397B0D93.6A5EE7CB at helicon.net... > > > Changed the DOS properties not to close on exit > > > the following is the result of > > > import Tkinter > > > several levels of error > > > last: > > > DLL load failed: one of the library files > > > needed to run this application cannot be > > > found. > > > rloisel > > > > > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From jvickroy at sec.noaa.gov Fri Jul 21 10:07:48 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Fri, 21 Jul 2000 08:07:48 -0600 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> Message-ID: <39785934.FD37DFD8@sec.noaa.gov> Hello Duncan, Unless I'm missing something here, the file will not be closed by this method (function) if n <=900000. If the file is not closed elsewhere in the code, it will only be closed (by Python) when the interpreter exits as part of its cleanup. Duncan Smith wrote: > I am attempting to write data to a file so I can export it to another > application after running a simulated annealing algorithm. (self.cost == 0 > on the first iteration only.) The relevant code is below. The file seems > to be created and written to O.K., bit it's not closed and I can't access > 'simresults.txt' without shutting down Python. I've checked the FAQ etc. > but I'm no computer scientist and I can't figure out where I'm going wrong. > Thanks in advance for any help. > > from Numeric import * > from Set import * > from RandomArray import * > import sys > > def acceptsim(self, cost, n): > t = 10000.0 / n > if self.cost == 0: > outputfile = open('simresults.txt', 'w') > sys.stdout = outputfile > self.cost = DJT.totalcost(self) > self.low_cost = self.cost > self.low_ordering = self.ordering[:] > if n > 900000: > outputfile.close() > return 'stop' > if cost > 0: > p = exp ((-1 / t) * (float(cost) / self.cost)) > if random() > p: > print self.cost > return 0 > else: > self.cost = self.cost + cost > print self.cost > return 1 > else: > self.cost = self.cost + cost > if self.cost < self.low_cost: > self.low_cost = self.cost > self.low_ordering = self.ordering[:] > print self.cost > return 1 From kain at cableadmin.com Fri Jul 21 08:06:00 2000 From: kain at cableadmin.com (Scott) Date: Fri, 21 Jul 2000 12:06:00 GMT Subject: MySQL on Win9X Message-ID: Hello, Are there any pre-compiled MySQL modules for windows? I've found the sources but don't have nor can I install a compiler on this machine. Thanks, Scott ------------------------------------------------------------------------------- "That's a deer shooting hat." "Like hell it is. This is a people shooting hat. I shoot people in this hat." From gmcm at hypernet.com Sat Jul 22 11:35:43 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 Jul 2000 15:35:43 GMT Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> Message-ID: <8F797551Agmcmhypernetcom@199.171.54.194> Bjorn Pettersen wrote: >Paul Prescod wrote: >> Actually, I'm not sure if my proposal would help here. Appending to a >> cStringIO is not an assignment operation... > >The only requirement was that the attribute access (myObject.property) >stay the same, only instead of returning a string it would compute >.value() on the cStringIO object. I.e., original: > > class MyObject: > def __init__(self,s): > self.s = s > >new version: > > class MyObject: > def __init__(self,s): > self._s = cStringIO.StringIO(s) > def __getattr__(self, a): > if a == 's': > return self.__dict__['_s'].value() > else: > return self.__dict__[a] Umm, that should be: def __getattr__(self, a): if a == 's': return self._s.value() raise AttributeError, a (__getattr__ is last resort - not called if the attribute is found.) >> > Perhaps you should add a few words about why you chose __attr_XXX__ >> > instead of __set/get/del_XXX__? >> >> That was actually the first proposal. But inheritance could get >> confusing if you inherited set without get or get without set etc. > >Hmmm... I'm not quite sure I understand... Of course you don't! Because Paul forgot to tell you that the first proposal said that defining one or more of __set/get/del_XXX__ automatically defines all 3, with default behavior of "you can't do that". So a base class defining __get_X__ and a derived class defining __set_X__ will have the wrong semantics 50% of the time whichever way you choose to handle it. >With __set/get/del_XXX__ >defined in a superclass you would automatically inherit all of them and >could choose to only override one of them, e.g. if you wanted to perform >further checks on a set but the get was the same. With __attr_XXX__ you >would have to explicitly call the superclass' __attr_XXX__ method if you >didn't define all of set/get/del(?) I have a feeling I'm missing >something... The current implementation has one generalized "access handler" for each type of access (get/set/del). For set/del, the handler is always called, meaning you have to write the class (and derived classes) with this in mind. Both versions of this proposal work by installing an "access handler" for an attribute. In the first, the fact that there was one "access handler" was completely implicit - it looked like there were 3. So it would be ambiguous whether the author of an override knew what they were doing (overriding the "access handler"), or being naive (attempting to override just one method of the "access handler"). In the current version, it's pretty obvious that you are overriding the one-and-only "access handler". But since the handler has the name of the attribute, chaining to a base class implementation means we need the handler also available under a different name. -Gordon From ngps at post1.com Sun Jul 30 11:19:41 2000 From: ngps at post1.com (Ng Pheng Siong) Date: Sun, 30 Jul 2000 23:19:41 +0800 Subject: bug in M2Crypto.urllib2 .. In-Reply-To: ; from sabren@manifestation.com on Fri, Jul 28, 2000 at 09:28:53AM -0400 References: Message-ID: <20000730231941.A295@madcap.dyndns.org> On Fri, Jul 28, 2000 at 09:28:53AM -0400, Michal Wallace wrote: > I've been using the excellent M2Crypto package for its HTTPS > support, and I've discovered a small bug that I'm trying to > track down. /tmp:$ cat py #!/usr/local/bin/python import M2Crypto.urllib2 url = 'https://secure.authorize.net/gateway/transact.dll' page = M2Crypto.urllib2.urlopen(url) print page.headers print '-' * 50 print page.read() print '-' * 50 /tmp:$ python py Server: Microsoft-IIS/4.0 Date: Sun, 30 Jul 2000 15:18:26 GMT Content-Type: text/html Content-Length: 42 Content: -------------------------------------------------- Invalid Merchant Login or Account Inactive -------------------------------------------------- /tmp:$ -- Ng Pheng Siong * http://www.post1.com/home/ngps From olivierS.dagenaisP at canadaA.comM Tue Jul 11 23:03:43 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 12 Jul 2000 03:03:43 GMT Subject: redirect output of functions to a string or file References: Message-ID: Sounds like you're looking for some tracing functionality to help you debug? I don't think you would want ALL functions to display their output to a file, since you may find that file grows really, really quick! You may just want to add a "print" at the end of functions that you want to debug, or use some class that doesn't do anything in "retail" mode, but in "debug" mode, will print all output in a window or out to a file.... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Fernando Rodr?guez" wrote in message news:LBpa5.563$iT2.6319 at m2newsread.uni2.es... > Hi! > > I have several functions that return strings. The output of these > functions must be combined and saved into a file. > > Is there a way to tell Python to "automagically" redirect the output > of _all_ functions to a string or file? O:-) > > TIA > --------------------------------------- > Fernando Rodr?guez > > From root at rainerdeyke.com Mon Jul 31 23:00:18 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 01 Aug 2000 03:00:18 GMT Subject: to close or not to close? References: <8m4s6i$2sdk@drn.newsguy.com> <20000801010533.P266@xs4all.nl> Message-ID: <63rh5.54100$6y5.36325446@news2.rdc2.tx.home.com> "Fran?ois Pinard" wrote in message news:oq7la1u9k4.fsf at titan.progiciels-bpi.ca... > I came to consider it is a better form to _not_ close explicitely. Cases > where explicit close is really useful are rather unusual, in my experience. > In which cases, an explicit `close' gets more meaningful, and less noisy. > And even then, I much prefer `file = None' than `close(file)', because the > former really represents my intent: I promise I will not use `file' anymore. > I like to think that closing a file is a system concern, not a user concern. Why not 'del file'? This should catch attempts to use 'file' earlier, and should be more memory efficient. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From paul at prescod.net Thu Jul 20 15:37:23 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 14:37:23 -0500 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> <8l7f69$bon$1@fermi.tro.net> Message-ID: <397754F3.8F730CBB@prescod.net> Moritz Voss wrote: > > Maybe I don't get the python concept. Do you link it statically? Yes, you link the interpreter statically and then you can pass it strings of code to execute or arrays of already-computed byte-code. > Now, my own language would be an assembler-style thing. The concept is as > follows - every instruction corresponds to an index. Each of these indices, > after compilation, are then translated, during runtime, into direct function > addresses. So what I have is my program that consists of a huge bunch > pointers to C functions (which can have any level of complexity). These > would just be loaded, and called, loaded, and called. I'm not going into the > depths of this here but passing parameters and references is not a problem. You're going to write AI in this language? What about conditionals? Control flow? Modularity? Exception handling? Data types? Maybe you really need two levels of language. There is your simple unsafe, internal-use byte-code and the player's user-level AI logic. > I'll play around with python, but I found the way to embed it totally > confusing. (That is, of course, because I have never worked with embedded > languages yet). Also, I find no tutorial that clearly tells me how to change > my C variable "X" from within my Python program "Y" that is invoked by the C > Program. Well Python can't directly write to pointers, which is good for you because you want to enforce "proper" behavior (no flying through walls, etc.) So you should start thinking a little more OO for the user-level scripting. Let's say a handler is a function with the following signature: def handleAction( me, what_happened, current_time ): if what_happened=="hit": me.shields.invoke() me.weapon.raise() me.weapon.fire() Now each of these properties is attached to the "me" object in your C code and each of the methods is attached to the shields and weapon objects by the same code. The methods are *c code*. You get a callback and update your object's internal state. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From hei at adtranzsig.de Thu Jul 20 06:20:41 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 20 Jul 2000 12:20:41 +0200 Subject: zip() : how about braid() References: <8l6cbp$fgr$1@pollux.ip-plus.net> Message-ID: <8l6ju6$5bq$1@desig-bs01-s04.adtranzsig.de> "J?rgen Hermann" schrieb im Newsbeitrag news:8l6cbp$fgr$1 at pollux.ip-plus.net...> merge() is the best yet, since it's a common (programming) term with a > well-defined meaning. Don't forget EnglishAsA2nd speakers, which won't know > what "braid" is all about, but are likely to know merge. Ah come on. As soon as some important american programming language has a keyword "parrot", people around the globe will learn that term as well. (When i used VMS i used to know what "purge" is.) What's the silliest keyword you ever encountered in a programming language? I vote for "rof". (short for Rolling-On-Floor, i think in ALGOL68.) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From cnd at ecn.purdue.edu Thu Jul 27 00:03:53 2000 From: cnd at ecn.purdue.edu (Christopher N. Deckard) Date: Wed, 26 Jul 2000 23:03:53 -0500 Subject: ioctl IOError Message-ID: <397FB4A9.EABD99C2@ecn.purdue.edu> In my quest to learn Python, more about C, and learn syscalls, I decided to port a C program to Python. The program is called pcfm and it's used to talk to the GemTek serial radio tuner (AM/FM). Why use something that works, when I can rewrite it in another language right? So, I've got the serial port part working, now I'm trying to get the sound mixer stuff to work, and I'm running into problems. Here are the thingers in C which use ioctl. The first, setvolume, is used to set the volume of the mixer. The second fetches the current volume setting. Also, from soundcard.h, we have: SOUND_MIXER_READ_LINE = 0x80044D06 SOUND_MIXER_WRITE_LINE = 0xC0044D06 (you can also get these under Linux by doing 'man 2 ioctl_list') void setvolume(int fd, int value) { value = (value<<8)|value; if (ioctl(fd, SOUND_MIXER_WRITE_LINE, &value)<0) perror("ioctl write"); } int getvolume(int fd) { int value; if (ioctl(fd, SOUND_MIXER_READ_LINE, &value)<0) perror("ioctl read"); return ( ((value&0xff)+(value>>8)) /2 ); } So, I basically need these functions in python. So I've got a class called mixer which has the file descriptor (fd), and then these functions: def setvolume(self, value): value = (value << 8) | value fnctl.ioctl(self.fd, SOUND_MIXER_WRITE_LINE, value) def getvolume(self): value = 0 fnctl.ioctl(self.fd, SOUND_MIXER_READ_LINE, value) return (((value & 0xff) + (value >> 8)) / 2) When I simply call the 'getvolume' function, I get: IOError: (14, 'Bad address') What is going on? How do I fix it? I'd like to leave these in Python, but it is my understanding that I could create a C object and link them in somehow? How is that done? Thanks for the help. Please email me as well as reply to the newsgroup. -Chris -- ---------------------------------------------------------------------- Christopher N. Deckard | Lead Web Technician cnd at ecn.purdue.edu | Engineering Computer Network http://triad.dhs.org | http://www.ecn.purdue.edu/ECN/ ---------------------------------------------------------------------- From MarkH at ActiveState.com Sun Jul 2 10:47:41 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 02 Jul 2000 14:47:41 GMT Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: You want "popen". For non-windows platforms, "os.popen" is where you can find it. For Win32 systems, you need the win32 extensions, and "win32pipe.popen". Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! wrote in message news:8jn34q$kpn$1 at news.lth.se... > Hi, > > I'm executing a command with os.system and are > trying to capture the output into a python > variable. The only I can find to do it in > at the moment is to redirrect the output > to a file and the read it. That feels wrong, > isn't there another simple way?? > > Thanks, > Bjorn From lull at acm.org Sun Jul 23 16:07:02 2000 From: lull at acm.org (John Lull) Date: 23 Jul 2000 15:07:02 -0500 Subject: POP3 server in Python? Message-ID: <7ijmnsc8u9qeg1h8rjbr77k2085kqktgq5@4ax.com> I find myself in need of a simple POP3 server written in Python. It does *not* need to handle multiple clients at one time, and performance is not an issue. Anyone know if one's available? Thanks. Regards, John From tim_one at email.msn.com Sun Jul 9 01:34:18 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 9 Jul 2000 01:34:18 -0400 Subject: Splitting c.l.py... In-Reply-To: <8k7lld$g53$1@nnrp1.deja.com> Message-ID: [Alex ] > Is there a synopsis of the legal woes that befell python somewhere? > It sounds sort of interesting. [Jeremy Hylton] > It's not interesting <0.2 wink>. And it's even less interesting for me, as (unlike Jeremy) I never worked at CNRI so have no interest at all in their internal politics. From my POV, it looks almost exactly like a divorce, except that besides just arguing over custody of the children (Python's license makes that pretty much a non-issue over the long haul), they're also wrangling over who gets the kid's used clothes, the old security blanket, and the first tooth that fell out. Separations are painful! Sometimes messy too. This is apparently one of those. I do believe both sides want Python to thrive, though. he-said-she-said-he-said-she-said-in-the-end-everyone-will-just-get- tired-ly y'rs - tim, speaking only for himself From michael at stroeder.com Mon Jul 24 03:06:13 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 24 Jul 2000 09:06:13 +0200 Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lc6jk$1f1$1@coco.singnet.com.sg> <8lde5s$vba$1@nnrp1.deja.com> <8leo17$tnt$1@dahlia.singnet.com.sg> <8lg7ft$odv$1@nnrp1.deja.com> Message-ID: <397BEAE5.3C1E5151@stroeder.com> ryzam at my-deja.com wrote: > > ImportError: NO module named M2Crypto Are you sure that you copied the module directory M2Crypto to your Python path (e.g. into site-packages/)? Ciao, Michael. From stephen_purcell at yahoo.com Fri Jul 28 02:51:43 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 28 Jul 2000 16:51:43 +1000 Subject: best apache+python module? In-Reply-To: ; from see@message.body on Thu, Jul 27, 2000 at 10:24:53PM -0700 References: <20000728113918.B12152@inkontact.com.au> Message-ID: <20000728165143.A15002@inkontact.com.au> Sam Penrose wrote: > > After having a Bad Experience with [PyApache] > I must ask why they are so popular. My company writes > pure-Python sites whose CGIs handle tens of thousands of hits a day on > unremarkable Intel hardware running vanilla Linux. I agree; plain CGI should always be the starting point, and solutions that rely on silliness like linking Python into Apache are probably asking for trouble. But *if* someone wanted to do such 'hyper-CGI', PCGI seems to be the big hitter. Not tried it personally, but since Zope + PCGI is a standard pairing, PCGI presumably has some merit. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From hzhu at localhost.localdomain.bbs Sat Jul 15 02:00:02 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 15 Jul 2000 06:00:02 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bPMg2$mPw@openbazaar.net> On Fri, 14 Jul 2000 23:00:14 -0500, Paul Prescod wrote: >> The problem is that Python provides no way for an add-on module to >> define new operators. > >But that's not really an accident. There are languages that allow you to >define new operators. REBOL is the most flexible example. Python >emphasizes syntactic *simplicity*. Well, I think there are two levels of syntactic simplicity: 1. Different structures: like the difference among identifiers, various literals (number, list, dict, string), indentation delimited blocks, function arguments. 2. Allowed members within a structure: like which function names are legal, which operators are binary, which functions can be overloaded. To keep the first kind of simplicity we need to restrict number of things allowed. But to keep simplicity of the second kind we need to remove arbitrary restrictions. For example, I had included a file aux.py in the MatPy package which caused a great deal of headache for Windows users. It turned out that Windows do not allow file name to be aux because it's a device name. This kind of unreadonable restrictions represent complexity, not simplicity. Python already provides both function names and binary operators, so the first level issue is not there. However, while it gives almost unlimited supply of function names that can be overridden, there is only a handful of binary operators which have deep rooted meanings and not enough for overloading. This limit is largely arbitrary, and is therefore complexity. >> Unfortunately, the current lack of appropriate notation makes these >> problems very difficult to code clearly. > >Every domain of computing would be enhanced with special notation. Text >processing, XML, COM, databases, Web programming etc. Haven't we already talked this through? Text processing already got its special syntax, even of the first level, which is quoted string. Within a quoted string you could put in any text sequence. In this specific domain it happens that only very limited number of binary operators are required, and they are duly provided, like string + string, string % string, or string * number. All the other things you mentioned could be built on top of this. This domain is not even as mature as matrix computation - in many earlier languages it was though that special syntax is needed for printing, formats and regular expressions, which turned out to be just ordinary string operations and functions, as python shows. On the other hand, for proper matrix operation, there is not much need for any additional first level structure, but there does exist a great need for a larger supply of binary operators. What we are saying is that extending the number of operators overridable by applications represents a much smaller risk of incompatability than giving everyone a complete parser. With the given operators, all the fields like scientific computation, graphics, statistical analysis and artificial intelligence could also be built on top of this. Before you dismiss numerical computation as just another domain, why not try a few packages and get a feeling of how large the domain is? Huaiyu From hgg9140 at seanet.com Sun Jul 23 18:42:21 2000 From: hgg9140 at seanet.com (Harry George) Date: 23 Jul 2000 15:42:21 -0700 Subject: 5.2.1 fails 5 tests: SGI Indigo-2 IRIX 6.2 gcc -O2 References: <3978D151.8208C03B@ids.net> Message-ID: I can't speak to those particular errors, but can give some related data points: I had python 1.5.2, numpy, and PyXML compiled via gcc 2.95.2 under irix 6.5 but was never able to get it visible to irix 6.2. So I fully recompiled using sgi's own cc, and can now run on either 6.2 or 6.5. [I had built the gcc from sources, instead of using the "freeware" install mechanism.] Eben Oldmixon writes: > Can somebody comment on these failures from the Python 5.2.1 > distribution test suite? I found mention of an error from test_re under > SunOS in the Deja News archives, nothing from python's test_long, and > didn't look further. Are these likely to turn and bite? I installed > anyway. I particularly like the non-overflowing of maxint+1, although > '+-1' (!) is a close second. > > #file: error_msgs > > #errors from build of Python 5.2.1 on SGI Indigo-2 under IRIX 6.2 > # using gcc -O2 > # errors from: > # test_grammar > # test_builtin > # test_types > # test_long > # test_re > > > python test_grammar.py > 1. Parser > 1.1 Tokens > 1.1.1 Backslashes > 1.1.2 Numeric literals > 1.1.2.1 Plain integers > Traceback (innermost last): > File "test_grammar.py", line 44, in ? > elif eval('maxint == 9223372036854775807'): > OverflowError: integer literal too large > error_msgs > Traceback (innermost last): > File "test_re.py", line 63, in ? > raise TestFailed, "re.sub" > test_support -- test failed: re.sub > > > > 4. Built-in functions > test_b1 > __import__ > abs > apply > callable > chr > cmp > coerce > compile > complex > delattr > dir > divmod > eval > execfile > filter > float > getattr > hasattr > hash > hex > id > int > Traceback (innermost last): > File "test_builtin.py", line 9, in ? > impo6. Built-in types > 6.1 Truth value testing > 6.2 Boolean operations > 6.3 Comparisons > 6.4 Numeric types (mostly conversions) > 6.4.1 32-bit integers > 6.4.2 Long integers > Traceback (innermost last): > File "test_types.py", line 85, in ? > else:raise TestFailed, 'long op' > test_support -- test failed: long op > rt test_b1 > File "test_b1.py", line 287, in ? > raise TestFailed, "int(%s) raised ValueError: %s" % (`ss`, e) > test_support -- test failed: int('+-1') raised ValueError: invalid > literal for int(): +-1 > > > > 6. Built-in types > 6.1 Truth value testing > 6.2 Boolean operations > 6.3 Comparisons > 6.4 Numeric types (mostly conversions) > 6.4.1 32-bit integers > 6.4.2 Long integers > Traceback (innermost last): > File "test_types.py", line 85, in ? > else:raise TestFailed, 'long op' > test_support -- test failed: long op > > > > python test_long.py > long / * % divmod > long bit-operation identities > long str/hex/oct/atol > long miscellaneous operations > Traceback (innermost last): > File "test_long.py", line 251, in ? > test_misc() > File "test_long.py", line 235, in test_misc > raise TestFailed, "int(long(sys.maxint) + 1) didn't overflow" > test_support -- test failed: int(long(sys.maxint) + 1) didn't overflow > > > > > Running tests on re.search and re.match > Running tests on re.sub > Traceback (innermost last): > File "test_re.py", line 63, in ? > raise TestFailed, "re.sub" > test_support -- test failed: re.sub -- Harry George hgg9140 at seanet.com From nospam4methx at hotmail.com Thu Jul 27 23:09:04 2000 From: nospam4methx at hotmail.com (RC) Date: Fri, 28 Jul 2000 03:09:04 GMT Subject: Unary Operators Message-ID: <3980F944.19EBFF7C@hotmail.com> Are there any unary operators (^, |, etc...) in Python such as in Verilog HDL? From root at rainerdeyke.com Tue Jul 25 12:38:33 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 25 Jul 2000 16:38:33 GMT Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: "Jonathan" wrote in message news:8lj7kr$ttc$1 at nnrp1.deja.com... > Hi, just finished going through the 'Learning Python' book, and the > feeling that i get is that Python is really wierd(compared to other > conventional languages like C++, Java, etc). For e.g.(correct me if i'm > wrong) > > 1. There are no keywords to declare static or instance variables; it > all depends where they are placed(whether it's right after the > statement, or inside a ). Isn't it harder for other programmers to > know at one glance what type of attributes the class define? > > 2. No *formal* declaration of static class methods, e.g. no 'static' > keyword (though i'm not sure how useful static methods are in OOP > design). I read somewhere in this newsgroup that the workaround way is > to define the method outside of the class - doesn't it break > the 'encapsulation' a class suppose to have? Static variables and methods are a mess anyway. In Python, there is no need for them - just place the variables and functions outside the class. In Java, they are a (poor) substitite for placing things outside the class. In C++, static class members are sometimes useful for access control and templates, both of which have no place in Python. > 3. No keywords to differentiate between passing arguments by reference > or value! An integer is passed by value(reference to a new copy), while > a mutable object is by reference. To pass a list by 'value', i know you > just need to insert one more line(list = [:]), but it seems > so 'inconsistent' compared to Java or even PHP. In Python, all arguments, including integers, are passed by reference. Always. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From robin at jessikat.fsnet.co.uk Wed Jul 19 11:38:47 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 19 Jul 2000 16:38:47 +0100 Subject: CVS missing xmlparse.h References: <3975BA62.91AE3D0@prescod.net> Message-ID: <5YhvBcAHucd5Ewz$@jessikat.fsnet.co.uk> In article <3975BA62.91AE3D0 at prescod.net>, Paul Prescod writes >You need Expat. > >http://www.jclark.com/xml/expat.html > >Robin Becker wrote: >> >> pyexpat.c(18) : fatal error C1083: Cannot open include file: >> 'xmlparse.h' >> -- >> Robin Becker >> -- >> http://www.python.org/mailman/listinfo/python-list > so the core will include the module source, but not a needed .h file; the python-xml kit used to include all; do I need pyexpat.pyd? Probably not. -- Robin Becker From no at bo.dy Mon Jul 24 08:45:43 2000 From: no at bo.dy (nobody) Date: Mon, 24 Jul 2000 07:45:43 -0500 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: <%TVe5.12$o45.2102@news.corecomm.net> David Bolen , in : [many thanksworthy things snipped - thanks!] > Just to note too - you mention reading "raw lines" - that's sort of > oxymoronic, since by definition "lines" have format information (end of > line markers that differ by platform) that have to be processed, and > thus you aren't really reading anything "raw" :-) i wasn't really thinking about that, but now that you mention it, you're right about that. i'm not just new to python, i'm fairly new to programming in general, and i don't always have the philosophical insights the right way around yet. they're the hardest, and most important, part to get. > Oh BTW, if you really just wanted a file copy, then yes, you could also > use the higher level copy() method in the shutil module. what i was actually trying to do was a prepend-this-string-to-that-file routine, and i think i got it. the straight translation from perl got really, really long due to all the try-except pairs; i like exceptions better than perl's "do {} or die" idiom as they're clearer and seem more flexible, but they're sure more verbose, too. From kpmurphy at my-deja.com Mon Jul 17 14:58:17 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 17 Jul 2000 18:58:17 GMT Subject: grid Message-ID: <8kvkvt$68h$1@nnrp1.deja.com> can you embed grids? ...what i'd like to do is grid within several frames, and then grid the frames together. sort of like html tables... i hate pack. -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From chrisw at nipltd.com Mon Jul 10 06:58:24 2000 From: chrisw at nipltd.com (Chris Withers) Date: Mon, 10 Jul 2000 11:58:24 +0100 Subject: [Python-Help] imp.load_module from a string References: <39672E50.B83A4C81@nipltd.com> <200007081846.UAA04878@pandora.informatik.hu-berlin.de> Message-ID: <3969AC50.98F36FF4@nipltd.com> Thanks for the help so far :-) Okay, another question: What is the difference between the contents of a .pyc file and what is returned by compile(str,'notafile','exec')? Martin von Loewis wrote: > This is tricky. I believe the only way to load a module from a string > is by marshal.loads, which requires you to skip the magic first. In > turn, this will give you a code object which you'll need to execute in > a newly-created module's dictionary. Hmm, plan B was to execute a compile(...) on the server using the source code and ship a pickle of the result to the client. On the client, take this codeobject and execute it into a module: module = imp.new_module('MyModule') sys.modules['MyModule'] = module exec codepbject in vars(module) Would this work? How efficient is it? More hassles... ;-) The idea is for the client to cache different versions of modules for use when processing different jobs. say module1 is created with: module1 = imp.new_module('MyModule') exec code1 in vars(module1) ...and module2 is created with: module2 = imp.new_module('MyModule') exec code2 in vars(module2) ...can I just swap them as follows?: sys.modules['MyModule'] = module1 ...create and use objects from MyModule... sys.modules['MyModule'] = module2 ...create and use objects from MyModule, hopefully using new code?... ...what happens to objects created from old MyModule code?... More confusingly, what happens to objects created from classes in MyModule that exist before and after swapping the module in sys.modules? Head hurtingly yours, Chris From alex at magenta.com Wed Jul 5 07:14:41 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 13:14:41 +0200 Subject: Singleton COM local/remote server? References: <7bd5msssk48km280t9bvds4i3v6hs7r8or@4ax.com> Message-ID: <8jvad40s00@news1.newsguy.com> John Lull wrote in message news:7bd5msssk48km280t9bvds4i3v6hs7r8or at 4ax.com... > I'm prototyping a DCOM server in Python. The server coordinates [snip] > Since each port can belong to at most one server, I cannot have > multiple servers on the same machine. I can't figure out how to > ensure there is only *one* copy of the server started, regardless of > how many clients want to use it. > > Any samples, pointers to documentation, key phrases to search MSDN > for, etc. would be *greatly* appreciated. I'm not sure how this translates to Python's implementation of COM, but, at a lower abstraction level, this is exactly what is accomplished by passing the REGCLS_MULTIPLEUSE value as the "flags" parameter in the CoRegisterClassObject calls that an .EXE does, at startup, to let the Service Control Manager of COM know about its class-objects (IClassFactory instances). When such a call is made, and, later, another instance of the object is required, the SCM won't start another process, but rather re-use the class-factory it knows is already active (and which, it has been informed, is OK for multiple use). You can take further precautions to check that this is indeed working as designed, but they should not be needed. Now, there remains the issue of, how to control the flags used on CoRegisterClassObject by pythonw.exe...? I can't find it in the docs (which doesn't mean it isn't there... it just says I can't find it). Maybe we need to look at the sources...? Alex From lull at acm.org Thu Jul 20 22:26:03 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 21:26:03 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <8l7qol$91u$1@la-mail4.digilink.net> Message-ID: "Pete Shinners" wrote (with possible deletions): > but while we're at it, i would hope that we don't overlook the > potential of elementwise assignment operators. sometimes those > matrices can get rather large, and rather than create a new > temporary matrix for every operation, it would be nice to have > it done "in place" > > MatrixA (*)= MatrixB > MatrixA (.)= MatrixB For all the other augmented assignment operators, A op= B is precisely equivalent to A = A op B If * is elementwise multiplication then *= should naturally be the corresponsing elementwise operator, and A (*)= B should be precisely equivalent to A = A (*) B Anything else means these operators are different from standard operators -- and that leads to confusion. Regards, John From aahz at netcom.com Sat Jul 15 00:15:45 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 Jul 2000 04:15:45 GMT Subject: using threading module References: <396fd2ff.3598724@news.prodigy.net> <8kokjv$tjf$1@slb7.atl.mindspring.net> <396fd7fe.4877753@news.prodigy.net> Message-ID: <8koohh$khb$1@slb6.atl.mindspring.net> In article <396fd7fe.4877753 at news.prodigy.net>, Victor Muslin wrote: > >Ok, that worked. What gives? The documentation does not make this clear. The documentation specifically says "tuple". What makes a chunk of data a tuple is not the parentheses (which are used for grouping), but the comma. This is a tuple: 'foo', This is not a tuple: ('foo') In any event, I think you'll probably find life with threads easier if you subclass Thread rather than passing in a function. This becomes particularly important when you want to associate data with each thread. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From yartz at imaginet.fr Sun Jul 16 08:03:43 2000 From: yartz at imaginet.fr (Yann Schwartz) Date: Sun, 16 Jul 2000 14:03:43 +0200 Subject: Pythonwin: problem with syntax highlighting Message-ID: <32966860B9270DBB.82F799B3E78DDCD7.9E33DCD378F53BB0@lp.airnews.net> First of all, hi. I've been fiddling with Python for two weeks and it's getting better and better. I'm starting to fall in love with the language. There's just one irritating thing, not with the language itself, but with the pythonwin editor. I havn't managed to make autocompleting and syntax highlighting to work. I've checked and unchecked the options in the GUI, but it didn't change a thing. I've looked into the registry to see if a component had'nt been registered properly during setup but I didn't see anything wrong. What could prevent my machine from displaying online help ? From ge at nowhere.none Fri Jul 21 12:37:22 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 21 Jul 2000 16:37:22 GMT Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> <8l9qfp$gc6$1@nnrp1.deja.com> Message-ID: <6%_d5.1964$6E.417529@ptah.visi.com> In article <8l9qfp$gc6$1 at nnrp1.deja.com>, david_ullrich at my-deja.com wrote: >> You're using a single index whose value is the expression 2,3. >> The expression 2,3 evaluates to a tuple, which is passed to >> _getitem__, just as would the value of any other expression >> used as an index. > > Ok, then I should revise what I said: You can use the >notation [2,3] to accomplish the same thing. > > No doubt you're exactly right. But evidently there's a >difference between [] indices and function parameters here: > >def hmm(x): > return x > >print hmm(2,3) > >gives an error (hence my suspicion that someone might >expect whatever[2,3] to give an error without trying it...) > > Why is "2,3" a single expression in whatever[2,3] >but not in hmm(2,3)? Because that's the way the language syntax is defined. :) The syntax for a function call includes the commas separating the parameters. The syntax for an index doesn't include any commas, so the commas are part of an expression yeilding a tuple. It would be a bit more obvious if one used foo[(4,5)]. A comma may be one of (three things (at least)): 1) token seperating function arguments 2) token seperating literal list items 3) tuple construction operator Deciding which function is being performed by a particular comma requires you to look at the context. There are several special contexts -- if none of them is in effect, then a comma is a tuple constructor operator. There is a shortage of delimiters and operators, so '(' has three usages... Function call: foo(3) Empty tuple: () Expression grouping: (4+4)*5 '[' has two usages... Indexing: foo[4] Literal list delimiters: [4,5,9] ',' has three usages... Tuple construction: 4,5,6 List seperator: [4,5,6] Parameter seperator: foo(4,5,6) The last example is potentially ambiguous, since it could be either a single parameter whose value is the expression 4,5,6 or it could be three seperate parameters. Python syntax is defined such that it is the latter. If you want the former, you've got to add parens (in their expression grouping mode): foo((4,5,6)) The triple-overloading of commas and parenthesis is unfortunate, but as the matrix users will attest, there is a dire shortage of operators and delimiters in the 7-bit ASCII character set. I vote we switch to the APL character set... -- Grant Edwards grante Yow! Now I am depressed... at visi.com From rloisel at helicon.net Sun Jul 23 20:30:18 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Sun, 23 Jul 2000 20:30:18 -0400 Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> Message-ID: <397B8E19.273116A@helicon.net> The path in the error message appears to be correct.. rloisel Olivier Dagenais wrote: > The Python binary might be in your path, but maybe the libraries aren't? > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Rodney Loisel" wrote in message > news:397B0D93.6A5EE7CB at helicon.net... > > Changed the DOS properties not to close on exit > > the following is the result of > > import Tkinter > > several levels of error > > last: > > DLL load failed: one of the library files > > needed to run this application cannot be > > found. > > rloisel > > From fw at deneb.enyo.de Sun Jul 9 06:33:58 2000 From: fw at deneb.enyo.de (Florian Weimer) Date: 09 Jul 2000 12:33:58 +0200 Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> <8k8q17$rov$1@thrud.anatomy.usyd.edu.au> Message-ID: <87sntjpp7t.fsf@deneb.enyo.de> danny at thrud.anatomy.usyd.edu.au (Danny Yee) writes: > >Just reverse the dictionnary, to be found in htmlentitydefs. > > Where do I find this? Have you tried "import htmlentitydefs"? SCNR. From fred at niwot.scd.ucar.edu Tue Jul 11 20:00:28 2000 From: fred at niwot.scd.ucar.edu (Fred Clare) Date: 12 Jul 2000 00:00:28 GMT Subject: importing shared library on SGI Message-ID: <8kgces$c1j$1@ncar.ucar.edu> I am running python on an SGI IRIX 6.5 system. I have created a shared library (adder.so) that implements a C extension and when I do an import in Python I get the error: ImportError: 3907647:python: rld: Fatal Error: Cannot Successfully map soname './adder.so' under any of the filenames ./adder.so When I do exactly the same thing on a Sun, it works fine. Any ideas? -- Fred Clare fred at ucar.edu From skip at mojam.com Sun Jul 9 19:40:27 2000 From: skip at mojam.com (Skip Montanaro) Date: Sun, 9 Jul 2000 18:40:27 -0500 (CDT) Subject: Run Python as separate process with Apache? In-Reply-To: References: Message-ID: <14697.3435.929500.668699@beluga.mojam.com> Randall> So I am wondering whether there is a way with Python and Apache Randall> to: Randall> 1) Have a persistent Python process that processes http Randall> requests. Yup, Medusa, Zope, the ZServer part of Zope (which is a lightly touched up Medusa), or something based on the HTTPServer class in the Python core should do the trick. I use ZServer listening on 127.0.0.2 at port 9673 and have Apache running on the same machine with proxy support. It then proxies to the server only those things I want the ZServer to see. Randall> 2) Have that persistent process manage a database connection Randall> pool. My ZServer then talks to a MySQL database using the MySQLdb module. If you want SQL connection capability I suspect you'll find Zope is much closer to a complete solution. Randall> 3) Have that persistent process hand out new session ids for Randall> new users, time them out automatically and all the other Randall> session management that servlet containers do for you. Then I think you probably really want Zope. There are tons of contributed Zope products available. There's bound to be one that will do session id management. -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From paul at prescod.net Wed Jul 19 20:27:28 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 19:27:28 -0500 Subject: CDDB References: <3976402D.9B957E2F@uniserve.com> Message-ID: <39764770.5D6BDE72@prescod.net> Bob van der Poel wrote: > > Has anyone converted the cddb code which calulates the cddb id and track > timing for a cd from C to python? Looks like it should be possible > without too much work...I was going to try this myself, but figured I'd > ask before I started... Here are more specific sites: http://csl.cse.ucsc.edu/~ben/python/ http://home.clear.net.nz/pages/c.evans/sw/cd/ -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From boncelet at eecis.udel.edu Mon Jul 17 16:03:20 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Mon, 17 Jul 2000 16:03:20 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> Message-ID: <39736688.E19DD546@eecis.udel.edu> Bjorn Pettersen wrote: > On the contrary. The argument is something like the following: > > - Python is a general purpose language, and as such it can't > support special case syntax for Matrix/cgi/xml/db programming. > (special syntax has previously been requested for both cgi and > db programming). Not trying to be argumentative, but why not? Why not allow an additional, overloadable, operator? > - The proposal is to add a handful of operators that would only > have meaning in this one domain. > - the criteria for addition to the core is something that is > generally useful for a large segment of the community. > (and it's your job to convince us of it, not ours to > convince you that it isn't -- many more people would like > to see Stackless in the core, but that's not going to happen > anytime soon either...) I'd love to see stackless and += added. > - that many problems can be reduced to matrix operations is > a non-argument, since the same is true of functional/ > procedural/oo/predicate programming. I agree, but there is a big userbase waiting for an alternative to the $$ Matlab. > - There are allready ways of performing the required tasks in > Python, so there is no absolute need to add this to the core. The same can be said of any simplification. There is no need for it, but adding it may make life a lot easier. > - Other straight forward solutions has been proposed including > list comprehensions and Moshe Zadka's elementwise class > approach. This I must object to. Linear algebra often involves big objects. These operations want to call a carefully written C function. Any time you use Python to loop over matrix objects, you are dead in a big problem. As far as I understand (and I could be wrong) neither list comprehensions nor the elementwise approach would be able to call the underlying C functions without python loops. > > > On the other hand, alternative arguments based on analysis of functionality, > > overall design, history of evolution and possible future extension, etc, > > would carry some real persuasive weight. > > If you really want to convince people, I would like to see examples of > how adding these operators would make working in other domains easier > (directly, not through translation through linear algebra). This may be Hauiyu's argument, but it is not mine. I'll let the people working in other domains to give the examples for their domains. My argument is that there is a very large potential user group Python could address if it were improved slightly (for that domain.) -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From jerome.vacher at tts.thomson-csf.com Tue Jul 11 12:37:00 2000 From: jerome.vacher at tts.thomson-csf.com (Jerome Vacher) Date: Tue, 11 Jul 2000 16:37:00 GMT Subject: checking the existence of a fiel References: Message-ID: <396B4D2C.19ACF45@tts.thomson-csf.com> hi back, import os if os.path.isfile(): easy Jerry, the foolish dracomorpheus "Fernando Rodr?guez" a ?crit : > Hi! > > How can I check if a file exists? O:-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez From bjorn at roguewave.com Mon Jul 17 15:24:30 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 17 Jul 2000 13:24:30 -0600 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> Message-ID: <39735D6E.8E3349D9@roguewave.com> Huaiyu Zhu wrote: [snip] > As to the claim that additional operators for linear algebra is somehow > comparable to the special syntaxes/quirks of various programming languages, > no real argument has been presented so far. It's more like: If I don't care > and don't use such things, they must belong to a special domain and be > somehow comparable to some other things that I do know and dislike. On the contrary. The argument is something like the following: - Python is a general purpose language, and as such it can't support special case syntax for Matrix/cgi/xml/db programming. (special syntax has previously been requested for both cgi and db programming). - The proposal is to add a handful of operators that would only have meaning in this one domain. - the criteria for addition to the core is something that is generally useful for a large segment of the community. (and it's your job to convince us of it, not ours to convince you that it isn't -- many more people would like to see Stackless in the core, but that's not going to happen anytime soon either...) - that many problems can be reduced to matrix operations is a non-argument, since the same is true of functional/ procedural/oo/predicate programming. - There are allready ways of performing the required tasks in Python, so there is no absolute need to add this to the core. - Other straight forward solutions has been proposed including list comprehensions and Moshe Zadka's elementwise class approach. > On the other hand, alternative arguments based on analysis of functionality, > overall design, history of evolution and possible future extension, etc, > would carry some real persuasive weight. If you really want to convince people, I would like to see examples of how adding these operators would make working in other domains easier (directly, not through translation through linear algebra). -- bjorn From m.faassen at vet.uu.nl Thu Jul 20 11:54:29 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jul 2000 15:54:29 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <39770DB6.372D4CFB@prescod.net> Message-ID: <8l77bl$puk$1@newshost.accu.uu.nl> Paul Prescod wrote: > Martijn Faassen wrote: >> >> ... >> >> >From a game programming perspective, you can probably consider Python to >> be dirt-slow, though. The trade-off is a lot of power for speed, but >> that power can help you gain back speed because you can be a lot smarter. > Python is dirt-slow if you are going to write a whole game in it. I wonder, in fact. :) Depends on the game and how smartly you offload the speed critical bits to C. > But is > it really much slower than the embedded scripting languages these games > sometimes have? Depends, probably not. See my other reply. I know game programmers have a very speed oriented mind set, and to leave absolutely no impression that Python's fast compared to C or assembler, I used the word 'dirt-slow'. A custom scripting language in a game can be faster at what it is designed for. Often it's probably also extremely frustrating if you want to do anything else, I imagine. And people *will* want to do something else with it. That said, I think Python can definitely be used in a game engine and that it wouldn't be too slow for many purposes. Include babbling about 'premature optimization' and 'reinventing the wheel' here as arguments for the use of Python in games. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From thomas_s at ebox.tninet.se Sun Jul 9 15:37:22 2000 From: thomas_s at ebox.tninet.se (Thomas Svensson) Date: Sun, 09 Jul 2000 20:37:22 +0100 Subject: Tkinter and default options References: <8jnbhm$bb6$1@cubacola.tninet.se> Message-ID: <8kaggk$3no$1@zingo.tninet.se> In article , "richard_chamberlain" wrote: > Hi Thomas, > > You can use an option database. If you create a file called optionDB > with for example the following kind of entries: > > *font: Times New Roman > *Button*foreground blue Thanks, I've tried and it works.. almost. It seems like some options are not read from the file. For instance I have the following options defined: *Button*activebackground: green *Button*activeforeground: yellow *Button*background: black *Button*foreground: green *Button*highlightground: black *Button*activeforeground: lightgreen *Button*relief: flat It works for all but activebackground and activeforeground, they are still grey. Did I do something wrong or could this be a bug in Tkinter? Regards, Thomas From shouldbe at message.com Mon Jul 31 15:33:42 2000 From: shouldbe at message.com (Arinté) Date: Mon, 31 Jul 2000 19:33:42 GMT Subject: Best way to solve dual call??? Message-ID: Review: I have this app that allows python scripts to talk to devices thru a c++ app and a dll. At certain times the device may need to send a message to the script like COVER_OPENED/COVER_CLOSED. Currently, it is giving me a error in the Thread State stuff. It works ok if there is a call to the script and while that call is being made then send the message. Example I have a messagebox in my dll that python scripts can pop up, while the script is waiting for that messagebox to go away Messages from the device can safely make it in. I could tell the testers to popup a window whenever a message may be expected, but that is not practical or possible. Any hints on what I could do? I am using python 1.5.2 and these will mostly be windows machines for now. thanx. From fiona at sitegnome.com Sun Jul 30 00:35:44 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 30 Jul 2000 04:35:44 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 30th, 2000 Message-ID: <20000730043544.27027.qmail@synop.com> Hello Guys, The latest entries to http://python.faqts.com cheers, Fiona ## New Entries ################################################# ------------------------------------------------------------- What is the difference between 'import Tkinter' and 'from Tkinter import *'? http://www.faqts.com/knowledge-base/view.phtml/aid/5096 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain If you use the from import it imports the contents into the current namespace. For instance if you use: from Tkinter import * you can use Label or Button directly, However, if you use import Tkinter you would have to use Tkinter.Label or Tkinter.Button. It is considered fairly poor practice to use from * import because you're bringing everything into the current namespace. One of the exceptions to this is GUI programming (i.e. Tkinter or whatever) because the names used are fairly obviously GUI related (Button,Widget,Canvas,etc.) ------------------------------------------------------------- Does anyone know how to read the PCI configuration space with Python under Win 98 or Linux? http://www.faqts.com/knowledge-base/view.phtml/aid/5097 ------------------------------------------------------------- Fiona Czuczman Shae Erisson, Erno Kuusela, Moshe Zadka, Tim Roberts Under linux you have 3 options: * use the lspci program. try lspci -x or lspci -vvv * read the files under /proc/bus/pci/ (this is actually what the lspci program does, but using lspci might save you from future format changes in these files...) * read /proc/pci do this if you are using an older version of linux (2.0.x) cat /proc/pci Or, in Python, open("/proc/pci").read() Doing this under Windows requires a C extension, and even then it isn't easy. Under Windows 98, you can scan the BIOS for the PCI entry point and call it directly. Under Windows NT, even this doesn't work; you need the help of a kernel driver. Much of the interesting PCI information is buried in the registry, which IS accessible from Python. From paul at prescod.net Fri Jul 14 09:44:32 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 08:44:32 -0500 Subject: Test writing volunteers needed References: <14700.44683.572283.391037@beluga.mojam.com> <396EDC58.8A60673D@darwin.in-berlin.de> Message-ID: <396F1940.384E8C1F@prescod.net> "Dinu C. Gherman" wrote: > > > What about using the excellent Python unittest module > (pyunit.sourceforge.net) to accomplish this, like in the > code below? There are two issues. First Skip asked about testing particular modules that are not currently tested using Python's standard test suite. Those test cases should use Python's standard testing framework, which is documented in the Python source distribution. Unrelated, there has been a little idle chatter about adopting a more sophisticated unit testing suite. It may go nowhere, but Jeremy has recently asked for a volunteer to compare and contrast some of the existing unit testing packages as a basis for discussion. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From annebo at nbnet.nb.ca Tue Jul 11 14:30:13 2000 From: annebo at nbnet.nb.ca (pascal bosse) Date: Tue, 11 Jul 2000 18:30:13 GMT Subject: www.toomany.net new web site Message-ID: <396B9F37.F551A274@nbnet.nb.ca> From matt at nightrealms.com Sat Jul 15 04:41:31 2000 From: matt at nightrealms.com (Matthew Cline) Date: Sat, 15 Jul 2000 00:41:31 -0800 Subject: '"""' and linefeed characters Message-ID: I'm assuming that returns in a '"""' quoted string are given the linefeed character(s) of the operating system Python is run on. Is this right? Thanks in advance. From olivierS.dagenaisP at canadaA.comM Mon Jul 24 10:40:53 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 24 Jul 2000 14:40:53 GMT Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> <8lfq6o$g07$1@nnrp1.deja.com> <397B96EE.9C62A45F@helicon.net> <397C3567.18E4546B@helicon.net> Message-ID: "Rodney Loisel" wrote in message news:397C3567.18E4546B at helicon.net... > If I have to type the following in a dos prompt with no history or mouse support > every time I want to run a python program perhaps I'm asking the wrong > questions... > As a programmer, the mouse becomes less and less useful because it takes so much longer to do what your eight fingers can do. Trust me: learn keyboard shortcuts for everything and you'll be amazed as to how quicker it will be. Oh, and you can easily get history in NT, and in Win9X, type DOSKEY once and you'll have history. (you may want to put it in your AUTOEXEC.BAT file) Besides, you only need to use a DOS prompt to see the exceptions being thrown when double-clicking on a .py file produces a window that disappears right away... > "C:\Your\Dir\Here>python C:\Your\Dir\Here>python hello.py" I don't know what you're trying to do with this, but I don't think it will work for you. Your\Dir\Here was meant to represent the path where your scripts were and also the point where you invoked Python... The rest of your questions seem to have been answered... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From alex at magenta.com Sun Jul 30 05:28:35 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 11:28:35 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: <8m1evd02n4o@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o75j2.fjt.grey at teleute.rpglink.com... > On Sun, 30 Jul 2000 01:48:32 GMT, Grant Edwards wrote: > >I concur. In non-programming, life is strictly typed. Allowed > >operations are determined by the type of the object. You can't > >make a phone call on a waffle-iron. Were I to _try_ to make a > >phone call on a waffle-iron, it doesn't "automagically" convert > >istelf into a telephone. Instead, I get a rather interesting > >burn pattern on the side of my head. > > You're making the mistake of trying to associate programming concepts to > real world objects. Why is that a mistake? We're trying to MODEL "the real world", at some remove (abstraction) to be sure. Prima facie, a correspondence between significand and significant is A Good Thing (it helps rather than hinder the modeling); while there are of course exceptions, the burden of proof is clearly on the one trying to show that a certain characteristic is best not-modeled in a given context. Much, perhaps most, of what philosophers have been trying to do over the last 2,600 years or so, is exactly about this, by the way. While the drastical criticisms of this endeavour in the "Philosophical Untersuchungen" are well warranted, some grounding in what went on before does help in making heads or tails out of it. I've always been rather perplexed at the lack of philosophy courses in the education of typical software engineers (as for me, fortunately, I am old enough, and European enough, that I got a "typical liberal education" in a Lyceum before moving on to Engineering in University:-). For an interesting mix of these philosophical considerations with some rigour and pragmatism, try modern semiotics, most particularly Umberto Eco (of course I'm biased in his favour -- he teaches at my Alma Mater [which happens to be THE original "Alma Mater"], albeit in Arts rather than Engineering, plus, how many high-powered academics you know that are also best-selling novelists?-). > I'm sorry, but that is why I said data is data is data. "Significants are significants", but they signify different significands in any semiotic system (meaning-system). Nor do you deny this, except that you want to draw the line at 'structure' or 'behaviour', AND fail to accept that strings in particular have both structure and behaviour so you'd like to get them 'merged' with numbers (whose behaviour in fact differs). > To give you a counter example when I write my pen doesn't toss up an > exception when I write out, "11 people are insane!" because it contains an > integer in a string context! As a tool for modeling, a pen significantly fails to possess any semantic capability itself. All it does is lay ink on some surface, and all levels of meaning upon those ink-blobs (the very fact that they are meant to be structured into sequences of characters, the alphabet being used, and so on up) depend on other layers of the modeling-system. Your pen won't (can't) complain, nor help you avoid the problem, if you use it to make totally random splotches of ink. Other tools impose more structure -- e.g., a typewriter imposes a character-oriented structure, and a given alphabet of character-symbols; that makes it more suitable for its intended tasks, while at the same time removing some flexibility (if you need to prepare a Rorschach test, a pen or brush is more appropriate than a typewriter; but for writing text, a typewriter offers a higher productivity if it's applicable in your given context). It's not a meaningful criticism of a typewriter that it's not as good as a pen if making random splotches of ink is your purpose. It IS an important consideration to keep in mind if you often need Rorschach-work, to help you pick the best tool for each task, of course. Alex From lull at acm.org Tue Jul 18 10:51:52 2000 From: lull at acm.org (John Lull) Date: 18 Jul 2000 09:51:52 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> Message-ID: At the dawn of the third millenium (by the common reckoning), Paul Prescod wrote (with possible deletions): > I don't think you need __getattr__ > > class Matrix: > def __init__( self, ....): > self.T=Transpose( self ) > self.H=Hermitian( self ) > self.I=Inverse( self ) > self.C=Conjugate( self ) > self.E=Elementwise( self ) > self.M=self # matrixwise is default > ... other matrix-like methods ... This, I think, works for everything but .E. You can write a method Transpose which, for most possible classes derived from Matrix, does the right thing by returning a derived class object with the data transposed. An element-wise matrix, however, would have exactly the same data as the original matrix, it just has a lot of the *methods* replaced. To make this work for derived classes, you have to either add a level of indirection to all the standard operator methods, or prohibit overriding the standard operator methods. How about one small change to Python, breaking no existing code, and applicable (I'm sure) to domains far-afield from linear algebra: Currently, object operator other is really just convenient shorthand for: object.__operatorname__(other) or other.__roperatorname__(object) where operator is any binary arithmetic operator. What if we simply make object @operator other convenient shorthand for: object.__alt__operatorname__(other) or other.__alt__roperatorname__(object) for all those same operators? This would be a syntax error when applied to anything other than an object, and would raise an appropriate exception if neither object nor other provided an appropriat __alt method. This would provide a way of adding a reasonable variety of domain-specific operators to *any* class with very little impact on the language, zero runtime penalty, and obvious & correct behaviour when creating derived classes. It would not break any existing code and should be very simple to implement. I haven't thought through whether the same behavior should apply to anything other than binary arithmetic operators. Doing so would seem very Pythonic. Regards, John From nobody at nowhere.nohow Fri Jul 28 21:22:29 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:22:29 GMT Subject: Perl is worse! References: <3h8zumi4i2.fsf@angband.org> Message-ID: In article , Steve Lamb wrote: >On 28 Jul 2000 12:49:57 -0400, Eric Lorenzo wrote: >>But communication with the *computer* isn't actually the primary >>purpose of typing. Rather, typing is a means for programmers to > > Funny, I thought that was what comments were for. Comments are in theory good things. In practice they're usually bad because they're generally wrong. > Given the choice, I'd rather have comments, not cues in the code. :) You must have been given code to maintain that was in a much different state than most of that upon which I've worked. Even if only 10% of the comments are wrong, you don't know _which_ 10% are wrong, so you've to figure out what the code does anyway. If I can tell what a line of code does, I delete the comment. If I can't tell what a line of code does, I figure out what it does, re-write it to make it more obvious, and delete the coment. The only comments I've ever found to be useful are the general descriptions of what a function is supposed to do. Comments along the lines of "This function appends files (given pathnames) to a MIME e-mail" "This function sends a MIME e-mail to an SMTP server" Comments documenting individual lines of code are in my experience wrong often enough that they are useless. The possible exception to this is in _very_ carefully maintained assembly language programs where there is simply no way to make the purpose of a line of code obvious without a comment. -- Grant Edwards grante Yow! Was my SOY LOAF left at out in th'RAIN? It tastes visi.com REAL GOOD!! From figNOfiSPAM at oreilly.com.invalid Fri Jul 7 20:35:51 2000 From: figNOfiSPAM at oreilly.com.invalid (fig) Date: Fri, 07 Jul 2000 17:35:51 -0700 Subject: More math on the O'Reilly Network References: <3964CA9B.CBCD5B03@oreilly.com> <8k41s8$a8i$1@snic.vub.ac.be> Message-ID: <21a69d79.ebd96c80@usw-ex0104-032.remarq.com> Thomas Hamelryck wrote: > Well, it's more an introduction to vector and matrix algebra > than a tutorial on Numpy. Most people who take the trouble > installing Numpy are quite familiar with this stuff. I was hoping some people reading it might be inspired to install NumPy without being quite familiar with this stuff. I think Python is a great educational tool for exploring Linear Algebra. Sounds like the article didn't go where you wanted it to go. What aspects of NumPy were you looking for a good tutorial on? ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From sharris at nospam.primus.com.bbs Mon Jul 17 13:10:02 2000 From: sharris at nospam.primus.com.bbs (sharris at nospam.primus.com.bbs) Date: 17 Jul 2000 17:10:02 GMT Subject: Changing the class of an instance Message-ID: <3bRJFQ$kPw@openbazaar.net> richard at cogsci.ed.ac.uk (Richard Tobin) writes: [...] > None, except to directly model the XML Schema specification which > talks in terms of adding properties to info items in an existing > infoset. Perhaps the "Envelope-Letter Idiom" is applicable here, provided that clients of the validation transformation don't need to know the precise type of the grove nodes. Which raises a different idea: Would a generic "get/set property" interface be acceptable? In that way, the additional properties getting added by the validation phase don't change the objects' concrete interface. Rather, they just expand the range of possible property strings to set or get. I know that's not as syntactically nice as swapping the concrete interface. [...] -- Steven E. Harris Primus Knowledge Solutions, Inc. http://www.primus.com From luthi at vaw.baug.ethz.NOSPAM.ch Mon Jul 24 12:39:08 2000 From: luthi at vaw.baug.ethz.NOSPAM.ch (luthi at vaw.baug.ethz.NOSPAM.ch) Date: 24 Jul 2000 18:39:08 +0200 Subject: Searching a binary file Message-ID: What is the fastest way to search a binary file for a certain byte pattern (**** in my case)? I came up with this solution, but I guess there is a better way to do it. Thanks for all suggestions. Martin Luethi ===== # constants MaxFileSizeInMemory = 10*1000*1000 file = open('my_binary_file', 'b') file.seek(0,2) # set the pointer to the end of the file filesize = file.tell() # get the size of the file file.seek(0) # reset the file pointer rex = re.compile(r'[\*]{4}') # the bytes to search for starpointer = [] # position of the '****' in the file oldpos = 0 for i in range(filesize/MaxFileSizeInMemory + 1): data = self.file.read(MaxFileSizeInMemory) # read a chunk of bytes m = rex.search(data) while m: # find all '****' in this chunk pos = m.start() - 4 # corrected for the length of '****' incpointer.append(pos + i*MaxFileSizeInMemory) m = rex.search(data, pos + 10) oldpos = pos file.close() # close the file -- ============================================================ Martin Luethi Tel. +41 1 632 40 92 VAW ETH Zuerich CH-8092 Zuerich mail luthi at vaw.baum.ethz.ch Switzerland ============================================================ From jblaine at kickflop.ne.mediaone.net Thu Jul 13 21:44:51 2000 From: jblaine at kickflop.ne.mediaone.net (Jeff Blaine) Date: Fri, 14 Jul 2000 01:44:51 GMT Subject: getpid Usage References: <8kksms+n5h5@eGroups.com> Message-ID: In article <8kksms+n5h5 at eGroups.com>, david at tumbleweed.com wrote: >Is there some convenient way of getting os.getpid to return the PID of >a given executable? What I want to do is start a process and know it's >PID. When I do the following I get the PID of the python executable. > >os.system("path") >os.getpid() > >Alternatively, as a hack, I am doing: >os.system(self.m_server_start_exe) >for line in os.popen("ps -ef | grep -i IMEController | awk '{ if (NR > >1) { print $2 }}'").readlines(): > pid = line[:-1] > >I would rather just path in an executable name/pathname and have it >return this process' pid. Is there an updated version of os.getpid I >could use to do this. If not, is there a better solution that is not >shell dependent? Unless someone has an answer to this (I don't know of one), if you have the source to the thing you are spawning, I recommend writing out a PID file as part of that program (/tmp/my.pid, whatever). From mikk at microbsys.com Thu Jul 13 07:21:26 2000 From: mikk at microbsys.com (Mike Mikkelsen) Date: Thu, 13 Jul 2000 11:21:26 +0000 Subject: determining type Message-ID: <396e07fd@news-out> Hello All, Is there a way, programmatically, to determine if an item in a dictionairy is itself a dictionairy? consider: >>> a = {'item1': 'hello', 'item2':{'subitem1':'goodbye'}} >>> print a['item2']['subitem1'] goodbye Is there a way to tell if 'item2' is a dictionairy, list or simple value like 'item1'? TIA -- Mike Mikkelsen mikk at microbsys.com Micro Business Systems http://microbsys.com Fresno Linux Users Group http://linux.fresno.ca.us It's all GNU to me! From Jonathan_Epstein at nih.gov Thu Jul 20 15:11:54 2000 From: Jonathan_Epstein at nih.gov (Jonathan Epstein) Date: Thu, 20 Jul 2000 15:11:54 -0400 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> Message-ID: <39774EFA.62287E6E@nih.gov> This looks very nice, although I like the second solution, i.e. A(*)B # matouter A(.)B # matinner (AKA dot, get it?) much better. It would be best to stay away from brackets and braces if we can ... somebody else may want to use them someday, and this sort of trickery looks too much like line noise to me. The special constituencies can even be addressed using two-character sequences within the parens if necessary. E.g., for Kroneker use A(.K)B I'm not actually proposing this specific syntax because it's so horrible looking and potentially hard to parse, but some variant on this might do the trick. -Jonathan Tim Hochberg wrote: > > Gregory Lielens writes: > > > Tim Hochberg wrote: > [...] > > I like the parethese a lot! except for ? which is probably out of > > question, > > this is the prettier way to do it, but (alwas a but :-( ) > > > > - the solve operator indeed...The only thing i can come with is the ugly > > (%) > > or the pretty but out-of-question (\) > > My favorite right now is |. So one would have: > > A[*]B # matouter > A(*)B # matinner > A(/)B # matdiv > A(|)B # matsolve > A(^)B # matpower > > Alternatively, one could use: > > A(*)B # matouter > A(.)B # matinner (AKA dot, get it?) > > That would cut down on the available symbols, but might make parsing > easier? It might also be easier to distinguish between the two > products. > > I've left out other potential outer operators (outer sum, etc) and > alternate inner products (Lie, Kroneker, ?) pending finding a > constituency for them. > > [snip grammar issues and how to choose inner product axes] > > -tim From thiele at muc.das-werk.de Wed Jul 26 07:37:01 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 26 Jul 2000 13:37:01 +0200 Subject: reading stdout from child Message-ID: <397ECD5D.409A6819@muc.das-werk.de> Hallo! I have a python program. It works fine. But: I wrote a second python program that should start these program using popen to read it's stdout. And this works not fine, too. But not always. Sorry but it is little bit long. First the wrapper ( I use my own popen for experiment ): This program forks a child and should print it's stdoutput. LOCALSTART.py #------------------------------------------------------------------------------------ #! /usr/local/python/bin/python import popen2, os, select, sys, string class LocalWrapper: def __init__(self): self.listofchilds = [] def start(self, command): self.startone(command) def startone(self, command): #create pipes for communication p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() errout, errin = os.pipe() #fork new process self.PID = os.fork() if self.PID == 0: #**********child********** #stdout und stdin os.close(0) os.close(1) os.close(2) if os.dup(p2cread) != 0: sys.stderr.write('popen2: bad read dup\n') if os.dup(c2pwrite) != 1: sys.stderr.write('popen2: bad write dup\n') if os.dup(errin) != 2: pass for i in range(3, 256): try: os.close(i) except: pass commlist = string.split(command, " ") try: os.execvp( commlist[0], commlist ) finally: os._exit(1) if self.PID > 0: #**********father********** os.close(p2cread) os.close(c2pwrite) os.close(errin) fout = os.fdopen(c2pread) while 1: stdoutput, errorout = "", "" stdoutput = fout.readline() <------- ????????? if stdoutput: print stdoutput, if not stdoutput: break try: os.waitpid(self.PID, 0) except OSError: print "no child" #pass os.close(p2cwrite) os.close(c2pread) os.close(errout) print "child is dead!!!!!!" #****************************************** #* Main * #****************************************** if __name__ == "__main__": import sys argstr = sys.argv[1] for arg in sys.argv[2:]: argstr = argstr + " " + arg LocalWrapper().start(argstr) #------------------------------------------------------------------------------------ second the main part from the other script LOCALSERVER.py. It's actually a server derived from SocketServer.py with a class for functionality #------------------------------------------------------------------------------------ #****************************************** #* Main * #******************************************* import sys sys.stdout.write("HHHHHHAAAAAAAALLLLLLLLLLLLLLLOOOOOOOOOO!\n") if __name__ == '__main__': import os,sys,string def usage(): print 'Usage: %s host port processors memory(mb)' % os.path.basename(sys.argv[0]) if len(sys.argv) < 4: usage() else: # Handle command line arguments host = sys.argv[1] port = string.atoi(sys.argv[2]) processors = string.atoi(sys.argv[3]) if len(sys.argv) >= 5: memory = string.atoi(sys.argv[4]) else: memory = 0 print "Starting local render server: Host: ", host, "Port: ", port, "Process: ", processors, "RAM(mb): ", memory, "\n" print "Version: ", VERSION, "\n" executer = Local_Job_Executer(processors, memory, host) <-- this class is not of interest server = Local_Job_Server(host, port, executer) <-- derived from SocketServer(multithreading) server.serve_forever() <--- disabled: it works #------------------------------------------------------------------------------------ When I call "LOCALSTART.py LOCALSERVER.py odin 1750 1" I expect to get the normal screen output: HHHHHHAAAAAAAALLLLLLLLLLLLLLLOOOOOOOOOO! Starting local render server: Host: odin Port: 1750 Process: 1 RAM(mb): 0 Version: 25_07_2000_1 and from all other prints later in the program LOCALSERVER.py but It works only if I disable server.serve_forever(). If the program runs into the infinite loop I will get no output. I cannot read the output in the warpper (see marked line <---??????? in LOCALSTART.py). Why? I expect that readline read when an output with newline at the end was written? Thank you for help Thomas From kpmurphy at my-deja.com Tue Jul 18 10:27:11 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Tue, 18 Jul 2000 14:27:11 GMT Subject: tkinter text Message-ID: <8l1pfa$oci$1@nnrp1.deja.com> is there a way to make a text box uneditable by the user, but insertable ( insert(END, 'schweet') ) by the application? thanks -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Wed Jul 12 15:13:13 2000 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jul 2000 15:13:13 -0400 Subject: comparing a directory to current dir... References: <396B9C5E.FCE5F683@roguewave.com> <8kh9if$5co$1@pollux.ip-plus.net> Message-ID: "J?rgen Hermann" writes: > "Bjorn Pettersen" schrieb im Newsbeitrag > news:396B9C5E.FCE5F683 at roguewave.com... > > the problem is that os.path.abspath(os.curdir) contains the drive letter > > on Windows and os.path.abspath(directory) doesn't. (...) > Your windows must be different from mine. :) Mine is NT4SP6a. Either that or Bjorn doesn't have the win32 extensions installed. It turns out that ntpath.py in the standard library will actually try to use the win32 extensions to let NT produce the absolute path, but if not present will silently revert to internal functions, which can under some conditions produce the behavior Bjorn was seeing. It depends on os.path.isabs() being used to determine if the supplied string is already an absolute path, which it will say yes to if it starts with / or \, even if it doesn't have a drive. In that case, it doesn't do the join mentioned in the documentation, but only does os.path.normalize() and you can end up with a result without the drive letter. I guess the problem is that "absolute" is sort of ambiguous under Windows, since you can have absolute paths on your current drive, or a really absolute path that always includes the drive. It would probably help to see the value that was in "directory" from the original poster to know if that's what was up (and/or if he had the win32 extensions installed). -- -- 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 richard_chamberlain at ntlworld.com Sun Jul 9 16:42:58 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sun, 9 Jul 2000 21:42:58 +0100 Subject: Pythonwin 1.5.2 References: <8kaij5$c9s$1@supernews.com> Message-ID: Up and down arrow keys and tab. Richard Dale Strickland-Clark wrote in message news:8kaij5$c9s$1 at supernews.com... > Is anyone else running this who has figured out how to select from the > pop-up keyword prompts without using the mouse? > > I've tried all the obvious ones like ctrl-enter without success. > > Thanks > > Dale Strickland-Clark > > > From mal at lemburg.com Thu Jul 20 11:49:20 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 20 Jul 2000 17:49:20 +0200 Subject: [Python-Dev] Coercion (RE: Discussion: Introducing new operators for matrix computation) References: Message-ID: <39771F80.90DD0C99@lemburg.com> [Adding new operators] Just a side note before everyone forgets: I think we'll need to carefully redefine coercion *before* adding any new slots/operators/etc. to Python. The current model where coercion is centralized won't scale well with the new operators. My (old) proposal for this (see my Python Pages) was to decentralize coercion and make the coercion process part of the operators task. Thoughts ? -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From grey at despair.rpglink.com Sun Jul 30 21:06:28 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 01:06:28 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 16:22:07 GMT, Grant Edwards wrote: >But in many, many programs (at least in the embedded and >process control areas where I do most of my work) program >objects _do_ correspond to real world objects. Granted, and in those cases it is appropriate to remember the limitations of the physical world. However in programming languages, peach.debone is valid, as is waffle-iron.dial. :) >I don't understand the analogy. Pens are not responsible for >parsing English sentances and proofreading them. They're >responsible for leaving a visible trail when they're dragged >across a paper surface. Exactly. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From jimhribar at msn.com Sun Jul 23 15:20:34 2000 From: jimhribar at msn.com (Jim Hribar) Date: Sun, 23 Jul 2000 15:20:34 -0400 Subject: Color, "DOS" programs, locate... Message-ID: Where can I get information on using Python for text based programs, specifically formatting the screen, changing colors, etc. I'm using Python for Windows. I saw something called the "curses" module, but doesn't seem to be for Windows. Please respond by email.. _][ ][ ][\/][ jimhribar at msn.com --- Get Paid to surf the web! http://www.alladvantage.com/go.asp?refid=BWQ812 --- From grey at despair.rpglink.com Sat Jul 29 22:44:15 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sun, 30 Jul 2000 02:44:15 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> <8lvovs1dj1@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 01:21:09 +0200, Alex Martelli wrote: >> How many would say that abc is a sequence. ;P >Most would, of course -- just ask what comes next, and anybody >with positive IQ will guess 'd'. 1 What comes next? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From robin at jessikat.fsnet.co.uk Thu Jul 20 10:55:48 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 15:55:48 +0100 Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <39763FF4.2CA5BF75@schneider-kamp.de> <8l59pa$6ff$1@slb1.atl.mindspring.net> <8l6vc5$c07$1@slb6.atl.mindspring.net> Message-ID: <+MLEAgA0Lxd5EwDd@jessikat.fsnet.co.uk> In article <8l6vc5$c07$1 at slb6.atl.mindspring.net>, Aahz Maruch writes ... >>The function zip as proposed (combine two lists into a list of pairs) >>is straight from Haskell (and other functional languages) just like map >>and filter. I think zip is the obvious name. > >Ah. Hmmmm.... Well, then, I guess I withdraw my objections to zip. >I'd still prefer something else, but.... ... so are we saying that the almost unknown language Haskell has the correct semantics for this; zip has at least three common usages other than of zip fastener meaning (interlace). -- Robin Becker From bjorn at roguewave.com Fri Jul 28 18:43:39 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 28 Jul 2000 16:43:39 -0600 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <39820C9B.C21776D@roguewave.com> Steve Lamb wrote: > > On Fri, 28 Jul 2000 19:50:27 +0100, Gareth McCaughan > wrote: > >None doesn't mean "empty object". It means "no object". There's > >a big difference, whether or not you care to recognise it. As > >big as the difference between "no bottles" and "an empty bottle", > >which is insignificant only if all you care about is the beer. :-) > i > Be hard to fool me on that. > > type(a) > a = None > type(a) > > If it were no object how come it doesn't bomb out again. Maybe the more > precise answer would be that I am trying to create the name a and point to > nothing. None is not nothing. None /is/s something. It is a type. :P Sure it is, it's the embodiment (or is that physical reincarnation) of Nothing-ness. Note that None is not a type, but it has a type. Anyone else remember Objective-C and how the type of nil was the bottom of the type hierarchy (it was a subtype of every type), so you could do [nil foo:5 bar:6] and it would work for any method? -b From europax at home.com Sat Jul 8 17:57:45 2000 From: europax at home.com (europax at home.com) Date: Sat, 08 Jul 2000 21:57:45 GMT Subject: Anyone used Python for GPIB instrument control? References: Message-ID: <3967A2E2.F6AFEE44@home.com> I think I am going to get a C compiler for work where we use NT. At home here I use Linux and don't want to eat up my hard drive with Windoze stuff (I have Windows 3.1, though since it is so small) I saw that Borland is selling a CD with Turbo C, Turbo C++,etc for about $60. Thats a pretty good deal. I also found some free WIN32 compilers. One based on the GNU gcc and it has an IDE called Rhine. Rob. Andrew MacIntyre wrote: > > On Sat, 8 Jul 2000 europax at home.com wrote: > > > I am new to this ng and to Python. I am wondering if anyone has used > > Python to control a National Instruments GPIB card on a Windows NT box? > > I've searched and found a couple of references on my own. > > If no other choice offers, it shouldn't be hard to wrap NI's interface > library in a Python extension module (though a C compiler would be > required) especially with the aid of SWIG. > > -- > Andrew I MacIntyre "These thoughts are mine alone..." > E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 > andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 > andymac at pcug.org.au (play2) | Australia From mfletch at tpresence.com Tue Jul 18 19:38:15 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 18 Jul 2000 19:38:15 -0400 Subject: Getting local IP address... Message-ID: The primary problem with #1 is complex network configurations. For instance, here is what the code gives you on my machine (and my configuration is not that complex in the grand scheme of things)... >>> import socket >>> socket.gethostbyname( socket.gethostname()) '192.0.2.201' Which seems perfectly reasonable, except that that is actually an address on our VPN, and is completely un-addressable by the outside world. (Incidentally, you likely get the same information from the Linux hackery, since it only accesses "the first" ethernet adapter, is, effectively, doing exactly the same thing as gethostbyname, just in an obscure way, and you still are left not knowing what is connected to the Internet). >>> socket.gethostbyname_ex( socket.gethostname()) ('cr706570-a.yec1.on.wave.home.com', [], ['192.0.2.201', '24.112.128.169', '172.16.0.1']) Shows the three different addresses for my machine. Only the second address is a public IP address. If I were to publish either of the other two addresses, no one would be able to connect to me using them (unless they happen to be either on our VPN or using my testing computer on its little testing network (which, points up the neat feature of the testing approach, as I can actually use the same code for all three networks, simply changing the "remote address" I use to establish my own IP address)). Of course, as Donn mentioned, if you already have a connection, it is really cheap to simply read off the address from that connection. One of our (older) projects even uses reflection, having the server report to the client the public address from which the client appears to be connecting (which, incidentally, lets you notice that you are behind a firewall or the like). That, of course, requires a server somewhere :o) . So, for 80% of the end-users out there, who only have a single IP address, no big deal, you can use the DNS lookups (gethostbyname, gethostname). If this is just for "information" purposes, you could use the DNS lookups without a problem. For anyone with a more complex networking structure, you may run into problems. The choice is yours. Networking is an ugly mess. Use the address wisely, Luke. Multi-homed systems are the sign of the devil, don't trust anyone using one. All who would defy nature and put more than one NIC in a computer are lying scoundrels! Mike -----Original Message----- From: stephen at cerebralmaelstrom.com.bbs@openbazaar.net [mailto:stephen at cerebralmaelstrom.com.bbs@openbazaar.net] Sent: Tuesday, July 18, 2000 4:40 AM To: python-list at python.org Subject: Re: Getting local IP address... Um, jeez. I'm rather surprised by these responses -- I assumed it was some simple little function somewhere I was missing.. I'm also even more surprised at the differences between the three approaches -- #1 -- socket.gethostbyname(socket.gethostname()) -- #2 -- Some complicated stuff dealing with asking Linux (which, incidentely, is bad since i'm primarily on a Windows machine for the time being -- and in the future will be on a *BSD, and hope to have my program working on all three :)) what the address is on the given ethernet card.. -- #3 -- Just go all out and connect, since in the process you have to be telilng the other side where you are, so you can get it that way. #2 and #3 just seem .. convoluted .. as heck. But because so many people sugguested them, I have to assume that they beileve there is some central problem with #1... What is it? :) ... From mksql at my-deja.com Thu Jul 13 17:40:54 2000 From: mksql at my-deja.com (mksql at my-deja.com) Date: Thu, 13 Jul 2000 21:40:54 GMT Subject: Python interpreter check and exit? References: <8kl9mc$1e3$1@nnrp1.deja.com> Message-ID: <8kld13$44d$1@nnrp1.deja.com> Answered my own question (did not use the right search terms on my first few attempts). Found a post with a Unix shell script that does the job. Here is my DOS/Win .BAT version for any who are interested (checks a single file): @python -c "from py_compile import compile; compile('%1')" In article <8kl9mc$1e3$1 at nnrp1.deja.com>, mksql at my-deja.com wrote: > Does the Python interpreter have a "check the syntax of the program and > then exit without executing it" mode or command line parameter, as > in "Perl -c program.pl" ? > > PythonWin has this ability through the check function, but I would like > to apply it to other editors. > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From dgoodger at bigfoot.com Sun Jul 23 00:41:08 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 23 Jul 2000 00:41:08 -0400 Subject: bit manipulation frustration In-Reply-To: <397A6980.CF15DB96@san.rr.com> References: <397A6980.CF15DB96@san.rr.com> Message-ID: on 2000-07-22 23:38, Courageous (jkraska1 at san.rr.com) wrote: > First, in one fell swoop of antigenious, I seem to have > forgotten how to convert strings to sequences of char and > vice versa. Eeek. Help? Will someone please remind me and > hit me with a rubber mallet??? :) >>> s="abcd" >>> map(None, s) ['a', 'b', 'c', 'd'] ... is one way. There are probably others. Consider youself whalloped. > Second, this whole paradigm seems so skrewball. ... > get it?) No, not really. Post an example? -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From Jarkko.Veijalainen at tecnomen.fi Mon Jul 3 06:14:40 2000 From: Jarkko.Veijalainen at tecnomen.fi (Jarkko Veijalainen) Date: Mon, 3 Jul 2000 13:14:40 +0300 Subject: slicing string Message-ID: <00Jul3.130616eest.119043@sister.tecnomen.fi> Hi! I'm real newbie with Python. I started learnig Python just last week. I have a problem slicing a string, imported from file. can anyone help me with simple solution. Input string follows this pattern: attr=value , attr2=value2, attr3= , attr4=value2. I have made an Object class, where all attributes are class variables. How can i slice that sring and store those att=value pairs in my object? I'm desperated... JarkkoV From srs25 at cornell.edu Thu Jul 20 15:06:36 2000 From: srs25 at cornell.edu (Samuel Scarano) Date: Thu, 20 Jul 2000 15:06:36 -0400 Subject: Type checking in python? References: <39770CD5.215D4C0C@cornell.edu> <397296BC.415C97E1@prescod.net> <8l7au1$mf6$1@nntp6.u.washington.edu> Message-ID: <39774DBC.5785A660@cornell.edu> (First of all, I just wanted take a moment to thank Paul Prescod for his very informative response to my post in this thread.) Donn Cave wrote: [snip] > What about the file object and StringIO? I mean, supposing that you were > motivated to implement a class like StringIO, and that the file object > were also a Python class, would you make StringIO a subclass of file, or > just implement the interface? > > I would just implement the interface, just because there's nothing of > value for me (that I can think of, anyway) in the file implementation. > I want something that ``walks like a duck'', but is not a natural duck > of some exotic species but a completely unrelated thing that shares only > its very simple abstractions. If I carried along a natural duck in > there, it would be kind of an ancestor fetish, not a useful thing. Fair enough. I agree that implementing the necessary methods is the most practical solution in this case -- and in many others. However, I think that the obvious objection to this approach would be that because there *are* no explicit interfaces in python, you can't create a class that's guaranteed to work wherever another class works just by implementing the same methods. It all seems rather sloppy to me, but I guess that's what you have to live with in a non-typesafe language. After all, "if you want typesafety, you know where to get it", right? :-) > Maybe both should inherit from some class that represents the basic > notions that they all implement, even though there wouldn't be any > actual implementation at that level of abstraction, just so's we > could look at the class hierarchy and say ``It's a duck!''. I guess > some languages do this, Python doesn't. I think that's good. Because > we don't respect the ancestor fetish, I don't have to go back to the > author of file and say ``Hey, why don't you pull an abstract base class > up out of your class so I can inherit from it?'' and then to the author > of some library function and say ``Hey, we have this new abstract base > class for "file", so expect that instead and I can use your function.'' > I just bolt on the duck stuff and we're ready to go in 10 minutes. Yes, well, my response to this would be that the author should have provided a distinct interface and implementation in the first place. As Paul Prescod pointed out, that's the way it works in sather -- and how it *can* work in java. It would be nice if python provided a means to do this, but then it wouldn't be python anymore, would it? :-) Anyway, I now understand that Python really just doesn't provide any interface mechanism, and that one should not consider the class system to serve this purpose in any capacity (as I once did) -- it is only for the purpose of code re-use. From this perspective, the language design and the programming style it encourages make a lot more sense. -- Samuel R. Scarano "Due to circumstances beyond my undergraduate, Cornell University control, I am master of my fate and captain of my soul." http://people.cornell.edu/pages/srs25/ -- Ashleigh Brilliant From grey at despair.rpglink.com Fri Jul 28 11:01:58 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:01:58 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> Message-ID: On Fri, 28 Jul 2000 10:42:15 +0200, Paul Boddie wrote: >Having seen Perl's behaviour in cases like the one Tim quoted, albeit in the >following form... > 1 + $variable >(trying to remember Perl syntax) where $variable is some text which should have >been a number but for various reasons happened to be something like "foo", I >would rather my chosen implementation language did raise an exception than >pretend nothing was wrong. This is a matter of opinion. I have to ask, where were your data checks in the first place? >What about 1 + "23"? Is "23" a decimal number or a hexadecimal number or what? Decimal. Is that not decimal form? >Doesn't Perl do this last one as well? I refer you to the example I give >above - to have such behaviour permeating one's code is "nasty" to say the >least. Nope. 1 + "foo" = 1. Perl uses the a different syntax to put strings together. + is only a mathematical operator, not a math and string operator. >whereas 1 + "foo" is meaningless to almost everyone except Perl coders. But 1 + "1" is not. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From pete at visionart.com Tue Jul 18 14:16:38 2000 From: pete at visionart.com (Pete Shinners) Date: Tue, 18 Jul 2000 11:16:38 -0700 Subject: merging numpy's array into python2 Message-ID: <8l27h4$7vq$1@la-mail4.digilink.net> i find using the numerical array stuff to be so useful i was wondering if there are ever plans to implement some of the package into the standard python release? specifically, the array object and it's helpful ufuncs would be great addition to the standard release (imho) i find it hard to imagine having a great/flexible n-D array object (that's fast to boot!) wouldn't be helpful in all pythons uses. python already has a standard "array" module, but it seems pretty weak compared to the numpy version. and the ufuncs work equally well on numpy arrays as well with standard python sequence objects. want to do an element- wise add two lists? i find "List1 + List2" much better all around than "map(lambda x,y: x+y, List1, List2)" (well, i'm sure we're all aware of how numpy works, :] ) is numeric too much baggage for the standard python release? are there areas of development where more rigid and quick arrays wouldn't be beneficial? does the numerical team even wish to be a part of the standard python, or do they prefer their own schedule? to me it seems more useful and a lot less 'specific' than most of the modules that are a part of the std python release. (could it make 2.0?) From neilh at scintilla.org Sat Jul 22 23:05:40 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 23 Jul 2000 03:05:40 GMT Subject: Discussion: new operators for numerical computation References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <8lcnf4$vmr$1@slb0.atl.mindspring.net> Message-ID: <8ite5.9395$4p3.69392@news-server.bigpond.net.au> > I first ran into this when I tried to implement a sparse matrix > class. At that time, the Numpy distribution had a Matrix class that > implemented regular matrix multiplication with '*', and I wanted to > write another class SparseMatrix that would do the right thing > whenever it was multiplied with a Matrix. I had a look at Dylan a few years ago and multimethods look good for some areas but you also lose the encapsulating aspect of normal OO. The functionality for a class isn't nicely tied up in one bundle but is federated over a wide and extensible area. I would expect Python with multimethods to look very different from current Python. Like Aahz, I'd like to see what your idea of Python with multimethods would look like? Neil From ldw at us.ibm.com Tue Jul 18 10:06:41 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Tue, 18 Jul 2000 09:06:41 -0500 Subject: Using filter() Message-ID: <8l1o9h$pto$1@news.rchland.ibm.com> I have a simple problem and from the description, filter() seems like a match. But I can't figure out how to make it work. Here's the code without using filter() include string, os def filter1( fileList, name ): #-------------------------------------------------------- # matches name to the first characters of a file in the file list temp = [] for i in range(len(fileList)): if string.find( fileList[i], name ) == 0: temp.append( fileList[i] ) return temp def filter2( filelist, aString ): #------------------------------------------------- # finds aString somewhere in the file list temp = [] for i in range(len(filelist)): if string.find( filelist[i], aString ) != -1: # is in the string somewhere temp.append( filelist[i] ) return temp def main(): #-------------------------------------------------------------- # somewhere in main tracePath = 'u:\\trc45\\junebug\\' traceFileName = 'jbtpcc.' traceFileExt = '.gz' infiles = filter2( filter1( os.listdir( tracePath ), traceFileName ), traceFileExt ) infiles.sort() print infiles I suspect using filter() would simplify this. Can someone help? Larry From sjuranic at condor.ee.washington.edu Thu Jul 27 13:43:23 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Thu, 27 Jul 2000 10:43:23 -0700 Subject: Local user modules? Message-ID: I've been perusing the Python documentation. I've just about finished "Learhing Python" and started leafing through "Extending and Embedding the Python Interpreter". I would like to use Python in my research, but because of the amount of data that I have to deal with, I will /have/ to write some C/C++ code (I'd like to get my Ph.D. within a reasonable amount of time ). Admittedly, I haven't read the entire "Extending..." document, but I'm looking for a short answer here, because if I don't get the answer that I'm looking for, that might place Python out of the realm of reasonability for me. Without further ado, here's my question: Is it possible for a user to write a module in C/C++ and make that available to the Python interpreter *without* needing to edit systemfiles like ${PYTHON_HOME}/Modules/Setup.local? Is is possible for me to add NumPy to my Python path without actually sticking it in the main Python system path? So far, this has been my biggest frustration with Python. If there is somewhere where I could RTFM, please let me know. I would be more than happy to do this, but I must know how to get around this problem. FYI, I know all about how to alter sys.path to add a directory like ~/Python/MyModules that would add modules implemented in Python, but how do I do the same thing for objects implemented in C/C++? Thanks a lot for the help! -------------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://truk.ee.washington.edu/ssli From bwinton at tor.dhs.org Mon Jul 10 23:22:00 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Mon, 10 Jul 2000 23:22:00 -0400 Subject: [ANN] Python port to Palm Pilot In-Reply-To: <14698.17375.15871.804581@beluga.mojam.com> References: <200007070140.SAA31035@wd264.aero.org> <3966C005.5EF656C6@smartchat.net.au> <200007101546.IAA09887@rushe.aero.org> <14698.17375.15871.804581@beluga.mojam.com> Message-ID: <200007110322.XAA02259@tor.dhs.org> In comp.lang.python, you wrote: >I haven't tried either yet. Can this be downloaded using Linux? I >can just barely do pilot-xfer to backup my Palm and could use some >suggestions on the use of the other Linux pilot-* apps, particularly >those that will let me download new programs like PalmPython. If you want any help on the pilot-link programs, just let me know, and I'll tell you what (little) I know. The stuff that comes to mind now is "pilot-xfer -i filename.prc" installs filename.prc on your Palm. "pilot-xfer -b backupdir" backs up your entire Palm to a directory. "pilot-xfer -r backupdir" restores your entire Palm from a directory. "install-memo filename.txt" copys filename.txt into your memos. "memos -d spam" copys all the memos from your Palm into a directory. That's about it for now. If you have any specific questions, just let me know, and I'll see what I can do... Later, Blake. -- 10:07pm up 1 day, 11:20, 1 user, load average: 0.00, 0.00, 0.00 From jerome.vacher at tts.thomson-csf.com Tue Jul 11 12:34:30 2000 From: jerome.vacher at tts.thomson-csf.com (Jerome Vacher) Date: Tue, 11 Jul 2000 16:34:30 GMT Subject: checking the existence of a fiel References: Message-ID: <396B4C96.A04B808@tts.thomson-csf.com> hi back import os if os.path.isfile(): easy Jerry, the foolish dracomorpheus "Fernando Rodr?guez" a ?crit : > Hi! > > How can I check if a file exists? O:-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez From tismer at appliedbiometrics.com Sun Jul 2 13:22:02 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 02 Jul 2000 19:22:02 +0200 Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> <8jno3n$p6m$1@nnrp2.deja.com> Message-ID: <395F7A3A.FFB0B903@appliedbiometrics.com> Hi Sean, seanmcgrath at my-deja.com wrote: > > At 09:07 02/07/00 -0400, Gordon McMillan wrote: > > > >Do you have a __getinitargs__ or __getstate__ or > __setstate__ that might be > >triggering a call to __getattr__? > > > > I don't have calls to __getinitargs__, > __getstate__ or __setstate__. > > What I do have is a __getattr__ which I suspect is > involved in this:-) > > The patient is pyxie.py > (http://www.digitome.com/pyxie.py). > The object I am trying to pickle is a tree > structure. > A variable CurPos points to a sub-ordinate object > which can be of type xElement or xData. > > The __getattr__ hook achieves a Delphi-like effect > in which attributes of these sub-ordinate objects > appear as attributes of the top level object. > > It seemed like a good idea at the time:-) Well, I see that your __getattr__ is a little insane. def __getattr__(self,n): if hasattr(self.CurPos,n): return getattr(self.CurPos,n) else: raise PyxieException ( "No attribute '%s' on xTree or current xNode" % n) It redirects *every* reading attribute access to the CurPos object, so Pickle can't even figure out what your xTree's class is. Also, the CurPos object can's be saved with it, nothing is accessible. First, I suggest to redirect all requests with __ to the class, second, give access to xTree object attributes a higher priority by first looking into self by self.__dict__.has_key(n) . This might work. Maybe you also want to avoid to store CurPos in the pickle at all. This can be done by introducing __getinitargs__ or __getstate__ and __setstate__ . cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From Denys.Duchier at ps.uni-sb.de Wed Jul 19 15:00:55 2000 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 19 Jul 2000 21:00:55 +0200 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: wtanksle at dolphin.openprojects.net (William Tanksley) writes: > >1. Make a pure python way to introduce additional operators, like > > import NewOperator > > NewOperator.define(".+", "__dotadd__") > > NewOperator.define("+=", "__add_ab__") > > NewOperator.define(":=", "__copy__") > > This isn't feasable -- it would require modifying the lexer and parser at > runtime, which would be a MAJOR change and can have unpredictable results. > (You know what I mean if and only if you've ever written a compiler with a > grammar.) I know what you mean, and it's simply not true. What it takes is simply to express the grammar in terms of operator precedence levels rather than in terms of specific operators. Thus your grammar has a fixed number of predefined operator levels and corresponding rules involving BINOP_LEVEL_1, BINOP_LEVEL_2, etc... Only the lexer needs to be able to be parametrized in terms of the operators that it needs to recognize. Typically this is done with a table and a greedy algorithm which recognizes the largest operator present in the table. I am, of course, not making any claims as to the applicability/feasability/desirability of this approach for Python :-) Sincerely, -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From root at rainerdeyke.com Fri Jul 28 21:31:07 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 29 Jul 2000 01:31:07 GMT Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: "Vespe Savikko" wrote in message news:vph8zun26wx.fsf at hiirihaukka.cs.tut.fi... > Also sprach "Rainer Deyke" : > > Static variables and methods are a mess anyway. In Python, there is > no need for them - just place the variables and functions outside > the class. In Java, they are a (poor) substitite for placing things > outside the class. In C++, static class members are sometimes > useful for access control and templates, both of which have no place > in Python. > > I think you are being too hard on static variables. The class > attributes have their uses in Python as well. For example, since class > attribute becomes a part of the class.__dict__, you can later define > that same attribute in the subclasses as well, and still can retain > the access to the 'same' class attribute in the superclass. In other > words the value of the class attribute can be seen to as accumulating > knowledge: besides its own class attribute a subclass instance can > query the value of the class attribute of the base class as well. Let me clarify my position: static variables/methods in Java/C++ are a mess (although still sometimes useful, especially with templates). Class attributes in Python are elegant and useful in ways that static variables in Java and C++ aren't (although get_? functions could often serve the same purpose). -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From alex at magenta.com Fri Jul 28 07:43:20 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 13:43:20 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> <3dittrsdhl.fsf@kronos.cnri.reston.va.us> <39815602.18CCB9A0@hursley.ibm.com> Message-ID: <8lrrsi0123s@news2.newsguy.com> "Paul Duffin" wrote in message news:39815602.18CCB9A0 at hursley.ibm.com... > Andrew Kuchling wrote: > > > > Robin Becker writes: > > > This IL stuff is not a big deal intellectually so why doesn't M$ just > > > release the language definition and sources and let the big & small guys > > > play? > > > > It would certainly be interesting to see a spec for MSIL and CLR, in > > order to gauge the complexity of writing an independent > > implementation. It might provide a decent chance of unifying the > > hopelessly fragmented state of scripting languages on Unix. > > This is exactly what Jean-Claude Wippler has been trying to do for ages. I > don't know if you remember Minotaur but it is conceptually the same as .NET > except that it used Forth as the lowest layer (the IL). A key difference appears to be that IL is not designed for easy interpretation, but rather specifically for compilation down to machine-code (possibly JIT, possibly at assembly-installation time, that could be an administrative choice). Forth, of course, is an excellent form for interpretation, not particularly suited for machine-code generation. JVM's bytecode seems to be somewhat in between. Of course it will be possible to interpret IL, if trying hard enough (just as, say, any machine-language can be interpreted, aka emulated), but, from what I've read so far, that definitely does not seem to be its emphasis, nor what the .NET/NWGS runtime is mostly going to do. If so, then it would appear to be far closer to OSF's old and beautiful project, the ANDF (Architecture-Neutral Distribution-Format), which never really got anywhere in practical terms -- maybe IL is sufficiently less ambitious, more focused, and/or better-funded than ANDF... who knows, one can hope!-) > I have had a look at .NET at it seems really neat, if only it was not > proprietary and worked across multiple platforms. If that was so then it It's early to tell, but I suspect that, just as for COM, the specs for IL, CLS, CRL, .NET will be available for clean-room reimplementation on other platforms, if people want to try. Of course, this is just speculation (I have absolutely NO access to any privileged information in the matter), and it's far from clear that, even if so, then such a reimplementation will indeed happen (Mozilla's XPCOM could be seen as a cross-platform clone of COM, but it's still not in a released-stable state, and how many years it's been since COM specs have been out...? IL+CLS+CRL+.NET/NWGS seems to be order of magnitude more work to reimplement, than COM's far more modest architecture & infrastructure, too...). > would probably replace JVMs and Java would be just another language you > could choose to use, rather than one you have to use because of the hype. I think there's far too much Java deployed out there for JVM's to be so easily "replaced". IL, as far as I understand it, does not really emulate the typical JVM's functionality; retargeting Java compilers for it, while quite feasible, would then not be a snap, nor is all of that huge mass of Java code going to be recompiled all that easily, I suspect... Alex From MarkH at ActiveState.com Thu Jul 27 19:52:25 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 27 Jul 2000 23:52:25 GMT Subject: retrieveing mail from a pop3 account References: <8lps39+ski@eGroups.com> Message-ID: wrote in message news:8lps39+ski at eGroups.com... > Hey, I've been writing a program which connects to my Pop3 mail > account, logs in, retrieves each mail in order and prints them out. > (just printing to standard output for now). However, say I have two > messages in my mailbox. It will print out the body of the first > message TWICE. So it will use the first body message as the body of > every message. You code assumes that messages are indexed from 0 - they are indexed from 1. > Here is the code. > numMessages = len(open_mail.list()[1]) > for index in range(numMessages): Should be: > numMessages = len(open_mail.list()[1]) > for index in range(1, numMessages+1): The pop server should probably fail when asking for message 0, but there may be a reason why it doesnt - Ive never read the relevant RFC in detail. Mark. From wware at world.std.com Wed Jul 26 12:13:13 2000 From: wware at world.std.com (Will Ware) Date: Wed, 26 Jul 2000 16:13:13 GMT Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> <397F0C1F.48F761AF@bioeng.ucsd.edu> Message-ID: Curtis Jensen (cjensen at bioeng.ucsd.edu) wrote: > [Python's format-string mechanism] > only works with tuples, not lists. The % operator with strings > requires tuples. I'm not sure why the chose to make this limitation. > The following code gives this error. > a = [1,2,3,4,5] > print (5*"%5i ") % a > Traceback (innermost last): > File "", line 1, in ? > TypeError: illegal argument type for built-in operation This is all true, but it's not too bad because you can easily convert a list to a tuple using the tuple() function. Just type print (5*"%5i ") % tuple(a) and you should be OK. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From rob at hooft.net Wed Jul 19 08:35:35 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Wed, 19 Jul 2000 14:35:35 +0200 (CEST) Subject: SEGFAULT. Bug in interpreter? Message-ID: <14709.41111.349921.206139@temoleh.chem.uu.nl> I am running the current CVS version of python on a redhat 6.2 box and see the following: -------------------------------- no203[394]~%3% python x.py zsh: segmentation fault python x.py no203[394]~%3% gdb =python GNU gdb 19991004 Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... (gdb) run x.py Starting program: /usr/local/nonius/bin/python x.py Program received signal SIGSEGV, Segmentation fault. PyErr_NormalizeException (exc=0xbffff73c, val=0xbffff740, tb=0xbffff744) at errors.c:166 166 if (PyClass_Check(type)) { (gdb) where #0 PyErr_NormalizeException (exc=0xbffff73c, val=0xbffff740, tb=0xbffff744) at errors.c:166 #1 0x8063931 in PyErr_PrintEx (set_sys_last_vars=1) at pythonrun.c:690 #2 0x8063906 in PyErr_Print () at pythonrun.c:680 #3 0x80636bb in PyRun_SimpleFile (fp=0x80f3ae8, filename=0xbffff9a1 "x.py") at pythonrun.c:585 #4 0x806338d in PyRun_AnyFile (fp=0x80f3ae8, filename=0xbffff9a1 "x.py") at pythonrun.c:463 #5 0x80513f7 in Py_Main (argc=2, argv=0xbffff824) at main.c:271 #6 0x8050f86 in main (argc=2, argv=0xbffff824) at python.c:10 (gdb) ----------------------------------------- On the script below. I have undressed it as much as possible, but anything I change further in the "genkappa" routine changes the crash into an error message either in "gentheta" or in "genkappa": SyntaxError: 'continue' not properly in loop (line 4) --------------------------------------- def gentheta(): while 1: try: continue finally: pass def genkappa(): if whatsmounted!='crystal': mountcrystal() while 1: if not inhibitmake: projtls.moveoutofway('kappa',dirok=1) os.mkdir('kappa') os.chdir('kappa') try: announce("Testing Kappa zero-point") # Use the detalign.vic produced by the dx calibration dal=os.path.join('..','dx','detalign.vic') if os.path.exists(dal): print "NOTE: Using detalign.vic from dx calibration" filecopy(dal,'detalign.vic') if not inhibitmake: status=os.system('calkappa make') else: status=os.system('calkappa') if status!=0: beeper.on() answer=command.question(root,'Calkappa Warnings',text='Calkappa issued some warnings and/or errors.\nPlease check what they are, and tell me what to do', strings=("Ignore them","Retry calkappa","Cancel and quit")) beeper.off() if answer==2: cancel() if answer==1: continue if os.path.exists('instruct.txt'): beeper.on() answer=command.fixedfontquestion( root,'Kappa missetting needs correction', text=open('instruct.txt').read(), strings=("I have now done this","I'm ignoring this for now","Cancel and quit")) beeper.off() if answer==2: cancel() if answer==1: break else: # No instructions means no correction required break finally: os.chdir('..') From thor at localhost.localdomain Tue Jul 4 12:13:05 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 4 Jul 2000 16:13:05 GMT Subject: Socket problem References: <39652e57.16380596@news.btx.dtag.de> Message-ID: On Tue, 04 Jul 2000 00:23:05 GMT, Stefan Franke wrote: >[Might be a repost..] > >On 3 Jul 2000 17:08:24 GMT, thor at localhost.localdomain (Manuel Gutierrez Algaba) wrote: > >> >>I'm doing a game for my University. It's divided into 3 parts >>( AI (clips), core(python), GUI(python)) communicated by sockets. > >Sorry, no help for your question, but just for interest - how do you interface >with clips? expectk BTW, I've solved the problem, /sbin/ifconfig lo 127.0.0.1 did the trick. -- MGA From aahz at netcom.com Sat Jul 22 22:15:03 2000 From: aahz at netcom.com (Aahz Maruch) Date: 23 Jul 2000 02:15:03 GMT Subject: Looping on more than one list References: <3979C6F4.B1FF1800@atlsci.com> Message-ID: <8ldkf7$7km$1@nntp9.atl.mindspring.net> In article <3979C6F4.B1FF1800 at atlsci.com>, ahmed Bouferguene wrote: > > Do no know much of python, but I am wondering whether it is possible >to loop >on more than one list, something like, > >a = [1,2,34] >b=["a", "b", "d"] > >for x in a, y in b : > print x, y Not currently. Look at all the threads about zip(), marry(), braid(), etc. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From shapr at uab.edu Tue Jul 25 14:24:21 2000 From: shapr at uab.edu (Shae Erisson) Date: Tue, 25 Jul 2000 18:24:21 GMT Subject: Python & AI References: Message-ID: <397DDA8A.6646F6F1@uab.edu> rhymes wrote: > > Do u know something on the net related to Artificial Intelligence and > Python Language?? http://www.strout.net/python/ has some AI in Python source. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From paul at prescod.net Wed Jul 12 18:55:56 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 12 Jul 2000 17:55:56 -0500 Subject: What is UnboundLocalError for? References: Message-ID: <396CF77C.DE3FB111@prescod.net> Alex wrote: > > (Python 2.0 question.) > > I was wondering what situations the UnboundLocalError exception is > intended to be thrown in. I encountered it when I made a mistake like > this: > > >>> f() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1, in f > UnboundLocalError: l Well you didn't show the code that gave you the error, but it probably would have given you a pretty good idea. An UnboundLocal is called when you assign to a local in a function but refer to it first. It's like referring to something before you declare it in languages that have variable declarations. In Python, the assignment *is* the declaration. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html From john.osullivan at chase.com.bbs Thu Jul 13 08:20:04 2000 From: john.osullivan at chase.com.bbs (john.osullivan at chase.com.bbs) Date: 13 Jul 2000 12:20:04 GMT Subject: Solaris/SparcWorks 1.5.2 build Message-ID: <3bO5b4$nW2@openbazaar.net> I did a build and install of Python 1.5.2 on my Solaris box recently. I'm running Solaris 2.6 on an Ultra 5, with SparcWorks 4.2 C and C++ compilers. I ran across some gotchas which I thought I'd document. Others, who like me are working in a corporate environment where gcc and gmake aren't available, may find them handy. If you're trying to build with SparcWorks C/C++ and Solaris make you may well run into gotchas 1 to 3. Number 4 is a really bizarre one which is quite improbable - I wrote it down 'cos I enjoy winkling out a good bug... JOS 2000-07-13 (john.osullivan at chase.com) 1. Run configure to build without gcc and with support for threading... ./configure --without-gcc --with-thread 2. Make sure your path picks up the SparcWorks C and C++ compilers first, before /usr/ucb. My SparcWorks is in /dvl/sw/SUNWspro_4.2/bin. If you pick up /usr/ucb/cc first you will get something like... {dvcls105_le0:38} ./configure --without-gcc --with-thread loading cache ./config.cache checking MACHDEP... sunos5 checking CCC... checking for --without-gcc... yes checking for gcc... (cached) cc checking whether the C compiler (cc ) works... no configure: error: installation or configuration problem: C compiler cannot create executables. If you get this you can check whether the problem is caused by /usr/ucb/cc like so... {dvcls105_le0:34} cc /usr/ucb/cc: language optional software package not installed {dvcls105_le0:35} ls -l /usr/ucb/cc -r-xr-xr-x 1 bin bin 3084 Jul 16 1997 /usr/ucb/cc 3. Make sure that DEFS includes -D_REENTRANT -mt in the Makefiles... DEFS= -DHAVE_CONFIG_H -D_REENTRANT -mt You need this for multithreading - which you will need if you want to run, for instance, Zope. 4. Look out for Solaris make's implicit rules kicking in. The implicit rules live in /usr/share/lib/make/make.rules. They can cause the invocation of, among other things, sccs and yacc. I experienced a particularly bizarre interaction since I had a PROJECTDIR environment var set. sccs looks for an SCCS subdirectory below the dir pointed to by PROJECTDIR, and mine just happened to have an old history file called s.parser.y, which got recovered by an implicit rule in /usr/share/lib/make/make.rules and passed through yacc to overwrite parser.c. The output below was generated by 'make -d'. The "parser.y" prefixing the C compiler error reports was caused by a preprocessor directive in parser.y and the generated parser.c -O -I./../Include -I.. -DHAVE_CONFIG_H -D_REENTRANT -mt -c node.c Building pgen because it is out of date relative to node.o Sccs getting parser.y because s. file is younger than source file sccs get -s parser.y -Gparser.y Building parser.c using suffix rule for .y.c because it is out of date relative to parser.y yacc parser.y mv y.tab.c parser.c Building parser.o because it is out of date relative to parser.c Building parser.o using suffix rule for .c.o because it is out of date relative to parser.c cc -O -I./../Include -I.. -DHAVE_CONFIG_H -D_REENTRANT -mt -c parser.c "parser.y", line 12: cannot find include file: "parser.y", line 26: undefined or not a type: cmd_descriptor "parser.y", line 26: syntax error before or at: * "parser.y", line 26: warning: old-style declaration or incorrect type for: cursource "parser.y", line 27: undefined or not a type: cList "parser.y", line 27: syntax error before or at: * "parser.y", line 27: warning: old-style declaration or incorrect type for: curargs Sent via Deja.com http://www.deja.com/ Before you buy. From grey at despair.rpglink.com Fri Jul 28 18:04:37 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 22:04:37 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> Message-ID: On Fri, 28 Jul 2000 11:55:51 -0700, Erik Max Francis wrote: >Steve Lamb wrote: > >> As a human, type 1. Character? String? Integer? Floating >> number? No, >> it is 1 and it can be all of those all on context. >In Python, and most programming languages that have some notion of type, >it is an integer. If you wanted a string, then you'd have typed '1', or >converted it to a string with `1` or repr(1) or str(1). Most, not all. Again, I ask, as a /human/. Not as a computer, calculator, dog, fish, pet rock, face on mars, some gas creature in delta-theta 3 (word up, gass monster) or almond, is 1 a character a string an integer a floating point number or what? If you have problems ask about 2 dozen people off the street what 1 is with that question and see how many puzzled looks you get. >If you don't like Python, then don't use it. When did I say I didn't like it? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From stephen at cerebralmaelstrom.com Fri Jul 14 19:47:43 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Fri, 14 Jul 2000 23:47:43 GMT Subject: Getting local IP address... Message-ID: <8ko8qr$7cd$1@nnrp1.deja.com> How do I go about getting my dynamic IP address? I want to make a little program to check periodically (daily or so) and log the results so I can determine how often my IP is getting shuffled. :) Thanks :) --Stephen Sent via Deja.com http://www.deja.com/ Before you buy. From scarblac-spamtrap at pino.selwerd.nl Thu Jul 20 02:36:51 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 20 Jul 2000 06:36:51 GMT Subject: iterating over lines in a file References: Message-ID: nobody wrote in comp.lang.python: > (fwiw, my prefeerence for this stems mostly from a liking for brevity; There's another common idiom noone mentioned yet: import fileinput for line in fileinput.input("somefile"): process(line) (it opens it for you too) -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From interfaze at my-deja.com Tue Jul 11 09:47:27 2000 From: interfaze at my-deja.com (Tom Smith) Date: Tue, 11 Jul 2000 13:47:27 GMT Subject: [ANN] Python port to Palm Pilot References: <200007070140.SAA31035@wd264.aero.org> <200007101546.IAA09887@rushe.aero.org> <14698.38478.979087.248189@malibu.aero.org> Message-ID: <8kf8h9$ica$1@nnrp1.deja.com> So, forgive my ignorance, what exactly does palmPython (snigger) do? I too installed before reading any docs, ran it...thought I'd crashed it, then typed ... print "testeroony" ...and it went away and ran some tests... Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Wed Jul 26 09:06:20 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 26 Jul 2000 13:06:20 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 26th, 2000 Message-ID: <20000726130620.20298.qmail@synop.com> Hi All, The latest entries into http://python.faqts.com regards, Fiona Czuczman Including: - Manipulating PNG files using Win32 PIL - How can I map the read() function of a file object? - What is the fastest way to search a binary file for a certain byte pattern (**** in my case)? - Embedding Python code in a C++ program, I get dynamic linking errors if I try to import any non-built in module, what's wrong? ## New Entries ################################################# ------------------------------------------------------------- Manipulating PNG files using Win32 PIL http://www.faqts.com/knowledge-base/view.phtml/aid/5025 ------------------------------------------------------------- Fiona Czuczman Olivier A. Dagenais Problem: I've writen a script to generate PNG images using PIL. It works a treat under Linux, but when I try to port it to MSWindows, the PIL/PngImagePlugin spits saying that I don't have a zip encoder. I already have a copy of pkzip, but I got hold of a copy of gzip.exe and stuck it in C:\Windows\zip.exe but to no avail. Can anyone confirm that I need a zip executable, or is the PIL wanting a DLL, etc? Solution: http://www.pythonware.com/downloads.htm Says this, near the end of the page: "Optional support libraries must be downloaded separately: jpeg and zlib." ...you'll want to follow the zlib link: ftp://ftp.freesoftware.com/.0/infozip/zlib/zlib.html The zlib library is used for manipulating PNG files... ------------------------------------------------------------- How can I map the read() function of a file object? http://www.faqts.com/knowledge-base/view.phtml/aid/5028 ------------------------------------------------------------- Fiona Czuczman Peter Schneider-Kamp, Bjorn Pettersen Just use a lambda like this: map(lambda f:open(f,"r").read(), list_of_filenames) or perhaps: def openAndRead(filename): return open(filename).read() map( openAndRead, listOfFilenames ) ------------------------------------------------------------- What is the fastest way to search a binary file for a certain byte pattern (**** in my case)? http://www.faqts.com/knowledge-base/view.phtml/aid/5029 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen Use: import string string.find( open('my_binary_file','rb').read(), '****' ) ------------------------------------------------------------- Embedding Python code in a C++ program, I get dynamic linking errors if I try to import any non-built in module, what's wrong? http://www.faqts.com/knowledge-base/view.phtml/aid/5030 ------------------------------------------------------------- Fiona Czuczman Ted Drain Problem: I am trying to learn how to embed Python code in a C++ program. I got the example from the docs (the one that imports sys and prints out a couple of strings -- search from initxyzzy in google). The problem I get is that if I try to import any non-built in module, I get dynamic linking errors. For example, adding the following line 31 works: _______________________________________________________________________ ... 29 /* Execute some Python statements (in module __main__) */ 30 PyRun_SimpleString("import sys\n"); --> 31 PyRun_SimpleString("import thread\n"); 32 PyRun_SimpleString("print sys.builtin_module_names\n"); ... _______________________________________________________________________ but adding the following line instead: _______________________________________________________________________ ... 29 /* Execute some Python statements (in module __main__) */ 30 PyRun_SimpleString("import sys\n"); --> 31 PyRun_SimpleString("import random\n"); 32 PyRun_SimpleString("print sys.builtin_module_names\n"); ... _______________________________________________________________________ produces: _______________________________________________________________________ [lopes at groucho lopes]$ ./demo Hello, brave new world Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/random.py", line 22, in ? import whrandom File "/usr/lib/python1.5/whrandom.py", line 140, in ? _inst = whrandom() File "/usr/lib/python1.5/whrandom.py", line 46, in __init__ self.seed(x, y, z) File "/usr/lib/python1.5/whrandom.py", line 58, in seed import time ImportError: /usr/lib/python1.5/lib-dynload/timemodule.so: undefined symbol: PyExc_IOError ('__builtin__', '__main__', 'imp', 'marshal', 'pcre', 'posix', 'regex', 'signal', 'sys', 'thread') ['xyzzy', 'os.path', 'os', 'exceptions', '__main__', 'posix', 'whrandom', 'sys', '__builtin__', 'site', 'random', 'signal', 'UserDict', 'posixpath', 'stat'] ./demo ['./demo'] _______________________________________________________________________ Solution: If you're building w/ gcc, add the link line option: -Wl,-E This says to pass the -E option to the linker. This option tells the linker to make all statically linked symbols available to the dynamic libraries. Without it, the symbols linked from libpython1.5.a aren't seen by symbols in the dynamic libraries. From gmcm at hypernet.com Sun Jul 16 21:11:19 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 17 Jul 2000 01:11:19 GMT Subject: Can't load .pyd files from embedded Python interp References: <39722B90.A41E02B5@tds.net> Message-ID: <8F73D685Egmcmhypernetcom@199.171.54.194> Edward K. Ream wrote: >I'm having difficulty importing modules defined in .pyd files from an >embedded Python interpreter. The problem seems to be that two sets of >variables are being used and no linking is happening when the DLL is >loaded. Perhaps you DLL gurus will spot the problem immediatly. >Details follow... Thank you for posting such detailed research! Extension modules are linked against an import lib for python15.dll. So they load python15.dll automatically, and use the symbols exported from the dll, not the ones statically linked into your embedded app. While it is possible to export symbols from an .exe (in MSVC land, this produces an .exp file), I've never experimented with back-linking a dll to an exe. Most people just use python15.dll from their embedding app so both get the same copy. Using Borland probably adds some warts to the process, since everybody has to end up using the same c runtime. Your best bet is to look for some posts by Gordon Williams, who has instructions on building python with Borland. Good luck! - Gordon From fermigier at localhost.localdomain Fri Jul 7 17:17:28 2000 From: fermigier at localhost.localdomain (fermigier) Date: 7 Jul 2000 23:17:28 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <00c601bfe812$febfeef0$f0c809c0@lslp7o.lsl.co.uk> <8k4t1u$7fk$1@newshost.accu.uu.nl> Message-ID: <8k5hd8$go8$1@localhost.localdomain> In article <8k4t1u$7fk$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: >Right, and since us Zope folks are using the stuff, some of these problems >seem to be taken care of. Do you still think what the ZODB does is much >different from what you're describing? Well, from my point of view, ZODB is a transactional persistent Python object store, not an object oriented-database since it lacks a query language (like OQL). What I'm missing most from ZODB, and is usually easy to do with an object-relational adapter, are queries and a simple way to do schema evolutions. S. -- St?fane Fermigier, From robin at jessikat.fsnet.co.uk Thu Jul 27 12:15:38 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 27 Jul 2000 17:15:38 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: In article , Neil Hodgson writes >> The fact that there are dyed in the wool M$ hating academics is surely a >> reflection of M$'s past behaviour. The fact that M$ can apparently turn >> these guys around so easily says a lot about what M$ is really good at >> (selling and hype) and also about what the academics are poor at (real >> world judgement). > > You are overlooking the appeal of a decent sized research grant to your >average starving academic ;) > > Neil ... Luckily when I was an academic I wasn't the one tasked with getting the next grant application together :) I do remember that it took one of the more astute members of the research group around 25-30% of their time to get something useful together. Not to mention the 5-10% of everyone's time spent in arguing and attending committee meetings etc. If M$ doesn't cost the academics that sort of effort before giving money I would strongly advise them to get a good Greek horse dentist. -My M$ muMath is no longer supported-ly yrs- Robin Becker From olczyk at interaccess.com Sat Jul 1 00:40:10 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Sat, 01 Jul 2000 04:40:10 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> Message-ID: <395d728e.117049078@nntp.interaccess.com> On 28 Jun 2000 06:02:09 GMT, thomas at xs4all.nl (Thomas Wouters) wrote: >On Wed, 28 Jun 2000 04:05:21 GMT, Courageous wrote: > >>> On top of that, very likely that if SUN sues they win. > >>Ridiculous. > >Very much so. But it wouldn't be suprising just the same, given the American >patenting/registration practices and the average american courthouse ;-) > >Overseas-ly y'rs, > Thomas Virtually all SUN has to do is pull some of the demo programs out of Microsofts manual. Write the equivalent code in python, perl, C++, pascal, and a few other languages. Compare them side by side. A fairly sophisticated person can see that it's resemblance to Java. Look at the law judges are sophisticated enough. Given that Microshit is being sued by SUN for their abuse of Java, I don't think it will be hard at all for SUN to convince a judge that all C# is, is a variant of Java with tons of proprietary crap glued on and the label changed. From edream at tds.net.bbs Mon Jul 17 12:40:01 2000 From: edream at tds.net.bbs (edream at tds.net.bbs) Date: 17 Jul 2000 16:40:01 GMT Subject: Can't load .pyd files from embedded Python interp Message-ID: <3bRIQ1$jm0@openbazaar.net> Gordon McMillan wrote: > Most people just use python15.dll from their embedding app so both get the > same copy. Using Borland probably adds some warts to the process, since > everybody has to end up using the same c runtime. Your best bet is to look > for some posts by Gordon Williams, who has instructions on building python > with Borland. Gordon, thanks so much for this reply. This was precisely what I needed. There were several factors making it difficult for me to see the obvious. 1. I had no idea that python15.dll existed or that it was loaded as part of the Windows install. One of Gordon Williams posts on comp.lang.python mentions that python15.dll is found in C:\Windows\System 2. I had previously abandoned the idea of using either python15.dll or python15.lib with Borland C because some of the "very high level" C API's use FILE * arguments, which obviously won't work with Borland C. But the solution is trivial: just make sure that the code in the embedding app never calls these functions! 3. I had no idea that linking python15.dll, rather than python15.lib, is required when embedding Python in an app. It is required so that imported .pyd files can access variables in the Python interpreter. This illustrates one of the most common failings in documentation: failing to tell _what_ the reader is to do and _why_. Much documentation just jumps in and explains _how_ to do something. I just reviewed the Python Extending and Embedding docs. There is no mention that one must link against python15.dll, and certainly no hint about why that is necessary. One or two sentences in the docs might have saved me about a week of enjoyable, but useless, work. I'll write up my experiences when I've successfully embedded Python in my app. For now the conclusion seems to be that one only need link in C:\Windows\System\python15.dll to the app. There are some details specific to Borland, but presumably they won't be difficult. Again, thanks so much for setting me on the right track. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From jeremy at beopen.com Fri Jul 7 11:20:06 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: Fri, 7 Jul 2000 11:20:06 -0400 (EDT) Subject: Python bug reporting [was: Re: readline.c & more] In-Reply-To: References: Message-ID: <14693.62758.307370.268472@bitdiddle.concentric.net> >>>>> "FP" == ISO-8859-1 writes: FP> [Jeremy Hylton] >> I agree that the system [of necessarily using the Web to report >> Python bugs, instead of the usual Python bug reporting email >> address] isn't great, but at least it provides us with a >> mechanism to track patches and assign responsibility for them. >> The old email approach didn't have either feature, which made it >> much harder for the people catching the patches. FP> There are plenty of users, and a much smaller bunch of FP> maintainers. It seems more fit to me to adapt to the plenty of FP> users, than force all of them into the methods of a few. This FP> is not far from haughty maintenance. Besides, if the new FP> mechanics and bug tracking systems did not even care to provide FP> some interface or tools, so maintainers can receive and sort FP> email into it, then that system is also haughty and aggressive FP> at imposing itself. I think haughty is a melodramatic word for the problem. Rather, it's an unfortunate side-effect of the transition to SourceForge. That transition has had a number of positive changes, not least of which is giving a lot more developers write access to the CVS tree. But SourceForge isn't perfect and its support of email-only communication is probably its weakest point. We'd love to have a patch manager that supported tracking, assigning responsibility, and email-only access! But we don't have one and we don't have the resources to build one. >From what little I've seen of it, I'm http://software-carpentry.codesourcery.com/entries/second-round/track/Roundup/ http://www.lfw.org/ping/sc-roundup.html I hope that the eventual winner of the Software Carpentry contest in the issues tracker category can be adopted by SourceForge for bugs and patches. >> You might suggestion an email interface in the SourceForge >> feature request forum: https://sourceforge.net/forum/?group_id=1 FP> Are you serious? You would force me to use a Web forum to FP> discuss that Web is inappropriate? This isn't real, I am FP> dreaming. :-( You can discuss it on comp.lang.python to your heart's content, but it won't have any effect on the people who maintain SourceForge. If you want to have an impact, you need to reach the people who have the power to effect changes. FP> Please consider Web as a possible service, not as an inescapable FP> religion. email is still ubiquitous, and very usable. If your I prefer email to the web as well, BTW. FP> bug tracking system cannot help you handling email, this should FP> be the problem of those having written or selected it, not mine, FP> and surely not mine to correct. There's a big difference between one or two people requesting a feature (email-only interface to patches) and many people requesting a feature. I ask you to request the feature on SourceForge because it will only become a priority if its is seen as serving the needs of many users. FP> P.S. - I nearly missed your message, it had no quote, and the FP> subject was improper. Web abuse destroys one's elementary FP> communication skills :-). ??? My last message had the same subject as the message I responded to. No quoting was necessary as I wasn't addressing the specific words of the previous messages. Perhaps opposition to anything Web related leads to tilting at windmills <1.0 wink>. -- Jeremy Hylton From tim_one at email.msn.com Tue Jul 25 22:19:55 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 25 Jul 2000 22:19:55 -0400 Subject: "always passes by reference" In-Reply-To: <8llct3$n34$1@news.dtc.hp.com> Message-ID: [Greg Weeks] > Once upon a time, "pass by reference" meant that a function call > f(x) could modify the binding of the variable x. I suspect you're conflating "once upon a time" with the specific languages you just happened to be using back then. Calling conventions have *always* been a zoo in reality, and all terms used to describe them are heavily overloaded. They usually make sense only in the context of a specific language. > With this definition, "pass by reference" effectively passes the > address of the variable x to the function. "pass by value", by contrast, > passes only the value of the variable x, not its address. > > With these definitions, Python is uniformly "pass by value". > So are Lisp, Java, and C, but not C++ and Perl. I don't agree with any of that, but in the absence of much more careful definitions this isn't going to get anywhere. > I like these old definitions. Unfortunately, things now get > confusing when the value of a variable is an address. This wasn't > always the case. In the Lisp and Smalltalk communities back in the > early 80's (as I recall), it was generally understood that an > interesting mutable data type (such as a list) is implemented > internally as an address. The address isn't a "reference" to a > list. The address IS the list. But now it seems that under the > influence of C and especially C++, the notion that an address can > represent a thing (such as a list) is entirely out of favor. Oh, > well. Languages that expose implementation accidents (like addresses) have a real need to make this distinction. Python, happily, does not. > I prefer the old way of speaking. I suspect I've been around even longer than you , and there was no "the" old way of speaking: just as now, there where many ways of speaking about calling conventions, and some languages (e.g., Fortran) allowed many ways of implementing their visible calling semantics (e.g., Fortran is what you'd probably call a "call by reference" language based on its semantics, but many implementations actually passed copies of scalar values, then copied alterations of those copies back into the caller's memory locations upon return -- in the Fortran implementation world, this went by the name of "call by value/result"). > With the new way of speaking, both Python and Perl are "pass by > reference", but Perl is somehow *more* so. Perl is much more call by value, even in the venerable old Pascal sense. For example, if you pass a list in Perl, Perl passes (the address of) a physical copy of the list (much as Pascal made physical copies of non-var array arguments). It wasn't until Perl 5 that you could even ask for a reference in Perl. Python passes (the address of) the actual list, and "list" can be replaced by any Python type whatsoever; all Python arguments are treated exactly the same way. > That's confusing. That may be self-inflicted, you know . Seriously, implementations are subtle and varied. > And in the new way of speaking, in Python you don't pass numbers, > lists, and so on to functions. You have to say that you pass > "references" to these things. But when you're in a hurry, you skip > this "references" business and talk about passing numbers, lists, > and so on. This hasty way of speaking used to be considered correct, > and I still like it. By all means, use it! You won't find Python experts talking about "passing references" unless they're speaking to hardcore C or C++ people who can't think in any other terms. I *never* think of call semantics in Python that way. A semi-accepted term to describe what Python (and similar languages) do is "call by object". Anyone thinking about references under the covers is just confusing their mental picture -- only the implementers have to worry about that, and even then rarely. it's-not-easy-to-be-simple-ly y'rs - tim From musingattheruins at my-deja.com Sat Jul 22 01:15:41 2000 From: musingattheruins at my-deja.com (musingattheruins at my-deja.com) Date: Sat, 22 Jul 2000 05:15:41 GMT Subject: Class static variables References: <8l9vb3$kae$1@nnrp1.deja.com> <8la0fa$l9r$1@nnrp1.deja.com> <8la2mp$n5v$1@nnrp1.deja.com> Message-ID: <8lball$jrf$1@nnrp1.deja.com> In article <8la2mp$n5v$1 at nnrp1.deja.com>, Guillaume wrote: > > > you are attaching a per-object variable with b.a=2 try CA.a - i think > > you will find it is still 0. > > regards, > > bill > > Right, but what I want is a static class var defined in A. CA.a __is__ the static class var. get it? it's the same for all instances. Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Sat Jul 22 23:38:39 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 23 Jul 2000 03:38:39 GMT Subject: bit manipulation frustration Message-ID: <397A6980.CF15DB96@san.rr.com> Okay. I'm getting a bit frustrated here. I'm trying to suck bits out of a file (which is in a simple, but non standard image format) and then convert this to a bitmap for wxPython. I haven't gotten to the wxBitmap part yet, which I am assuming will be easy, but the in-between part is driving me nuts. First, in one fell swoop of antigenious, I seem to have forgotten how to convert strings to sequences of char and vice versa. Eeek. Help? Will someone please remind me and hit me with a rubber mallet??? :) Second, this whole paradigm seems so skrewball. While I know exactly how to implement all of this in a external C module, the program I'm writing is just a one off, and I was expecting it to be easier in python. The bitmap image is 16 bit color, but it's stored in byte runs. As I load the image, I need to load 2,4,6, 8...44,42,40...2, 16 bit chunks at a time, but as I'm doing this I have to create "black" runs on either side, making the whole thing 44x44 (it's an isometric tile... a square rotated 45 degrees, but bitmaps are square, get it?) I'm not seeing an elegant solution here; loading the image as a string to begin with isn't right, because my chunks are actually two byte chunks. Anyone with any practical experience on how to *BEST* do this kind of thing? Am I just not thinking about this right? C/ From thiele at muc.das-werk.de Mon Jul 3 10:36:03 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 16:36:03 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> Message-ID: <3960A4D3.F45133B4@muc.das-werk.de> No I think this is not sooo nice. Becouse I want to replace the widget with others. mode One | not changing area | -------------------- | Label Entry Button | | | -------------------- and then I want to change the layout into: mode Two | not changing area | -------------------- | Entry Button Entry | | | -------------------- (For instance.) Just like an other dialog but within the mainframe. And I want to switch between the two modes. From tim_one at email.msn.com Sat Jul 1 23:38:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 1 Jul 2000 23:38:09 -0400 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: <037101bfe3e4$8558c820$6401a8c0@home> Message-ID: [Paul Prescod, links to ...] > http://www.activestate.com/Products/VisualPython.html [Darrell Gallion] > Thanks for pointing this out. I see it comes up on google also. > > This should make the job of Python evangelizer that much simpler. > Some people will feel that VC support puts Python on main street. Well, that's just silly. What it *does* do is validate Microsoft as a serious competitor in the modern computer marketplace . languages-live-longer-than-platforms-ly y'rs - tim From GustavsB at ch.sibt.com.bbs Tue Jul 18 02:10:03 2000 From: GustavsB at ch.sibt.com.bbs (GustavsB at ch.sibt.com.bbs) Date: 18 Jul 2000 06:10:03 GMT Subject: Top 10 Language Constructs (Phyton) Message-ID: <3bRdUR$lK9@openbazaar.net> "John Grayson" wrote in message news:8kmurf$6rf$1 at nnrp1.deja.com... > Oh, well now I understand! > You've reached the wrong newsgroup: you want comp.lang.phyton. > You might get a reponse there! (or not...) Shame on me! As an old dyslexic I was able to misspell the name of Python :-( Shame on me! Bruno Gustavs From fiona at sitegnome.com Mon Jul 17 00:52:37 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 17 Jul 2000 04:52:37 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 17th, 2000 Message-ID: <20000717045237.19026.qmail@synop.com> Hi Guys, Below are the latest entries to be entered into http://python.faqts.com cheers, Fiona Czuczman Including: - I'm writing a script that will act as a GUI interface to another script, and I want to have file browsing ability. How do I call this in Tkinter? - Searching code for parsing mail headers encoded according to RFC 2047 (Message Header Extensions for Non-ASCII Text). - Is there a way how I can identify the operating system my Python script is running on (e.g., Linux, Windows, Mac, ...)? - How does python invoke external C function? - How do I go about getting my dynamic IP address? - How does the statement 'global' work? ## Unanswered Questions ######################################## ------------------------------------------------------------- can i run a script in an already running interpreter to hook a gui to a server process http://www.faqts.com/knowledge-base/view.phtml/aid/4761 ------------------------------------------------------------- Slimy ## New Entries ################################################# ------------------------------------------------------------- I'm writing a script that will act as a GUI interface to another script, and I want to have file browsing ability. How do I call this in Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/4768 ------------------------------------------------------------- Fiona Czuczman John Grayson This is not really a Tkinter issue, since you can fire up a file browser window from a simple Python program. However, it may introduce some special problems if you're doing it from a GUI. Therefore, here is some sample code to illustrate how to do this for Windows and Solaris platforms. You would have to adjust for other platforms. Note that if you're doing this just for Unix, that you don't need to thread: you can just fire off the command in the background... from Tkinter import * from tkSimpleDialog import * import sys, os, thread class App: def __init__(self, master): self.master = master Label(master, text='Browsing:').pack(side=LEFT, padx=4, pady=15) self.entry = StringVar() Entry(master, width=50, bg='gray', textvariable=self.entry, state=DISABLED).pack(side=LEFT, padx=15, pady=15) Button(master, text='Browse...', command=self.browse).pack(side=BOTTOM) def browse(self): path = askstring("Browse", "Enter directory") self.entry.set(path) browser = Browse(folder=path) class Browse: def __init__(self, folder='.'): if sys.platform == 'win32': cmd = 'Explorer %s' % folder else: cmd = 'dtfile -folder %s' % folder thread.start_new_thread(self.doIt, (cmd,)) def doIt(self, where): os.system(where) root = Tk() display = App(root) root.mainloop() Hope this helps to get you started. BTW: Chapter 18 of Python and Tkinter Programming covers handling asynchronous events and things that block the mainloop... ------------------------------------------------------------- Searching code for parsing mail headers encoded according to RFC 2047 (Message Header Extensions for Non-ASCII Text). http://www.faqts.com/knowledge-base/view.phtml/aid/4772 ------------------------------------------------------------- Fiona Czuczman Fran?ois Pinard I needed this soon after learning Python (so this is part of my first Python lines, I would probably write something simpler today :-) and quickly wrote what appears below. However, I found out after the fact that the Python library had something already. See mimify.mime_decode_header. # Handling of RFC 2047 (previously RFC 1522) headers. import re, string def to_latin1(text): return _sub_f(r'=\?ISO-8859-1\?Q\?([^?]*)\?=', re.I, _replace1, text) def _replace1(match): return _sub_f('=([0-9A-F][0-9A-F])', re.I, _replace2, re.sub('_', ' ', match.group(1))) def _replace2(match): return chr(string.atoi(match.group(1), 16)) def _sub_f(pattern, flags, function, text): matcher = re.compile(pattern, flags).search position = 0 results = [] while 1: match = matcher(text, position) if not match: results.append(text[position:]) return string.joinfields(results, '') results.append(text[position:match.start(0)]) position = match.end(0) results.append(function(match)) ------------------------------------------------------------- Is there a way how I can identify the operating system my Python script is running on (e.g., Linux, Windows, Mac, ...)? http://www.faqts.com/knowledge-base/view.phtml/aid/4773 ------------------------------------------------------------- Fiona Czuczman Emile van Sebille, Mahogany Rush, Matthew Schinckel Look for Marc Lemburg's platform.py, or use the standard sys.platform. Python 1.6a2 (#1, May 14 2000, 08:15:17) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.platform 'sunos5' If it is only for compatibilty reasons, you can use os.name. This will give you one of: ['posix', 'nt', 'dos', 'mac', 'os2', 'ce']. ------------------------------------------------------------- How does python invoke external C function? http://www.faqts.com/knowledge-base/view.phtml/aid/4774 ------------------------------------------------------------- Fiona Czuczman Wolfgang Grafen I would recommend SWIG for a first step. You don't have to learn a lot about extension modules with SWIG. Often it is easy like this (for sun solaris 2.5): swig -python -module a a.c gcc -O02 -DSWIG -c -fpic a.c a_wrap.c \ -I/user/freepool/sparc-sun-solaris2.5.1/lib/python/python1.52/include/py thon1.5/ ld -G a.o a_wrap.o -o a.so Then in Python you can use it like it is. Python 1.5.2 (#33, May 17 2000, 17:03:52) [GCC 2.7.2] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import a >>> dir(a) ['__doc__', '__file__', '__name__', 'hex2bin', 'hex2bin_char', 'hex2bin_expand'] >>> SWIG has a very good documentation. You can build extensions for PERL and TCL the same way http://www.swig.org There is also another Corba-like Package called ILU. Probably SWIG is more easy to use while ILU might be more powerful. ftp://ftp.parc.xerox.com/pub/ilu/ilu.html ## Edited Entries ############################################## ------------------------------------------------------------- How do I go about getting my dynamic IP address? Detecting own computer's IP http://www.faqts.com/knowledge-base/view.phtml/aid/4378 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Hans Nowak, Snippet 188, Python Snippet Support Team """ Packages: networking.sockets """ """ detectip.py Detects your own IP address. No big deal on Python; more work on Delphi (where the code originated from :). """ import socket def detectip(): buf = socket.gethostname() remotehost = socket.gethostbyname(buf) return remotehost if __name__ == "__main__": print "Your IP address is", detectip() raw_input() ------------------------------------------------------------- How does the statement 'global' work? http://www.faqts.com/knowledge-base/view.phtml/aid/2902 ------------------------------------------------------------- Fiona Czuczman Remco Gerlich, Thomas Wouters Answer1: Inside functions, if you assign to a variable, it is assumed to be local to the function. If you want to assign to a global (module namespace) variable, you'll have to tell Python that it's a global first. ie, x = 4 def spam(): x = 5 spam() Doesn't change the module's x. But x = 4 def spam() global x x = 5 spam() does. If, inside a function, you only use the variable and never assign to it, it can't be a local variable, so Python assumes you mean a global. This doesn't only hold for functions, but classes and methods too. Answer2: Python has two namespaces it uses for name lookups: the 'local' namespace and the 'global' namespace (you could call it the 'search path'.) The local namespace is the function or class you are in, the global namespace is the namespace of the module. If you are not in a function or class, the local namespace is the global namespace. However, *assigning* to a variable does not use this search path ! Instead, if you assign, you always assign in the local namespace. So, for instance: X = None def FillX(x): X = x would not work, because the X you assign to, is the *local* X, not the global one. This wouldn't even generate an error, by the way. Even more confusing is it if you read from and assign to 'X' in the same function: X = None def FillX(x): if not X: X = x In Python 1.5.2, this generates a NameError: Traceback (innermost last): File "", line 1, in ? File "", line 2, in FillX NameError: X and in Python 1.6, an UnboundLocalError: Traceback (most recent call last): File "", line 1, in ? File "", line 3, in FillX UnboundLocalError: X It generates this strange error because the 'X' name exists in the local namespace, but at the time of the test on X, it isn't filled in yet. The interpreter knows it should be there, but can't find it at the time of execution. And this is what the 'global' keyword is for. It says 'this name is global, *even if* it gets assigned to. You only need it when you are assigning to globals, not when you are mutating them (appending to lists, adding to dictionaries, etc.) From fredp at mygale.org.nospam Thu Jul 20 11:42:07 2000 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 20 Jul 2000 15:42:07 GMT Subject: Advice sought: text-mode (but not CLI) apps in Windows console ? References: <8F7682C13PaCmAnRDLM@195.25.12.37> <8F7765F6DPaCmAnRDLM@161.48.76.20> Message-ID: <8F77B9FF5PaCmAnRDLM@161.48.76.20> ge at nowhere.none (Grant Edwards) said : >>Sadly, all this is much too cryptic for the sort of casual use >>I had in mind -- it would actually be faster for me to dig out >>the win32 extensions and do regular Windows, which I wanted to >>avoid in the first place :-) > >If you want something easy to use, Tkinter is probably as >simple as anything (and certainly simpler than curses). * sigh * guess so... :-) Somehow I had managed to avoid delving into Tkinter up to now... one more thing to learn about :-) Thanks anyway ! -- YAFAP : http://www.multimania.com/fredp/ From johnvert at my-deja.com Tue Jul 11 14:50:15 2000 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Tue, 11 Jul 2000 18:50:15 GMT Subject: Comparing a string Message-ID: <8kfq90$vd$1@nnrp1.deja.com> Hi, How can I compare two strings in a case-insensetive way? I couldn't find a function similar to strcasecmp or even to strcmp in http://www.python.org/doc/current/lib/module-string.html. I understand it's a silly question, but I can't find a way to do this (I don't want to use regexps) Thanks, -- John Sent via Deja.com http://www.deja.com/ Before you buy. From tony at lsl.co.uk Mon Jul 10 11:58:52 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Mon, 10 Jul 2000 16:58:52 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8kcqug$p32$1@newshost.accu.uu.nl> Message-ID: <002901bfea87$be58fa10$f0c809c0@lslp7o.lsl.co.uk> Martijn Faassen wrote: > > In todays emphasis on shared services over the > > net, a lot of this begins to sound remarkably prescient. > > Definitely! When did this research take place? Ooh - I left Glasgow (where I *wasn't* working in Computing Science!) about 3 years ago now, and it had been going on for at least 3 years before that. The person I knew who used to make it all sound like it mattered (he used to work with the same company I work for) is/was Peter Dickman, and his homepage at http://www.dcs.gla.ac.uk/~pd/ may be a sensible starting point (and the PJama homepage from the other end, of course). > > But I *know* I don't understand the field, so I'll shut up straight away > > about it... > > I don't understand the field either, so let's babble on. Perhaps we'll > learn something. :) Unfortunately, all I need is *another* thing to learn about on my backburner (but, damn, it just got added - time to do some reading I guess...) > This article by Andrew Kuchling may be interesting, if you're > just interested in the ZODB and ZEO by itself: > http://starship.python.net/crew/amk/python/writing/zodb-zeo.html Right - if I can get damned IE to do it, I'll print that off and add it to the other couple of ZODB/etc papers I'd found to take home. Tibs (the signature? well, it's related to the reason I started the mxTextTools metalanguage thingy, which then relates to why I might be interested in ZODB, and Zope, and also to a biliography I never finished, and ...) -- BikeCode0.2 http://www.tibsnjoan.demon.co.uk/bikecode.html P: [Tibs] Tc B10 K:++ i29:30" h1.65m n1960 H+:~ v~ A+ M+ Rg- B: [AnthroTech] 3tRu U1c w37" Wr19:406 Mfr SAf bDh[Sachs]:C G3x7 8s Lrr1B Cb[Michael] VjsX col[MidnightBlue] T: [BurleyD'Lite] 2c2[Thomas] f++ VsX My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From fred at niwot.scd.ucar.edu Wed Jul 5 20:22:29 2000 From: fred at niwot.scd.ucar.edu (Fred Clare) Date: 6 Jul 2000 00:22:29 GMT Subject: pyfort Message-ID: <8k0jg5$ics$1@ncar.ucar.edu> I have just started looking at pyfort (see http://www-pcmdi.llnl.gov/software/cdat/index.html) to add Fortran extensions. Running pyfort produces a C file that contains an include: #include "Numeric/arrayobject.h" I have implemented Numeric Python, but nowhere can I find the above include file in the source. Any pointers would be appreciated. -- Fred Clare fred at ucar.edu From grey at despair.rpglink.com Fri Jul 28 11:07:09 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:07:09 GMT Subject: Perl is worse! References: <75k2osst2eh5nbel73ju033l8s97bs2v0s@4ax.com> Message-ID: On Fri, 28 Jul 2000 09:21:28 GMT, Ben Wolfson wrote: >Well, what if you wanted > 1 + "1" >to result in "11", not 2? Then cast it as a string operation explicitly. The point is that it is easier to cast the exceptions rather than as the rule. >That could lead to some interesting results if you expect numerical input. Yes it could, that is why good programmers check their input data before performing opertions when the data set is not trusted. I'm amazed that people in this thread have repeatedly stated things like, "Well, if it did that it would work in design but a user would make it crap out." Sorry, same thing can be said for Python as well for any time user input is taken and the variables are not checked before performing operations. It raises an exception all the way out (because if you assume a programmer doesn't check their data, they don't check exceptions, either) and the program still craps out. I'd much rather the language assume I am intelligent enough to check instead of assume I am not and question me on every single operation. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From aahz at netcom.com Fri Jul 14 11:50:25 2000 From: aahz at netcom.com (Aahz Maruch) Date: 14 Jul 2000 15:50:25 GMT Subject: OSCON dinner? (Thurs 7/20) Message-ID: <8kncs1$j2f$1@slb7.atl.mindspring.net> Because of work, I can only be at OSCON next week for one day. Anyone want to get together for dinner on Thursday 7/20? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From guido at beopen.com Mon Jul 24 11:00:00 2000 From: guido at beopen.com (Guido van Rossum) Date: Mon, 24 Jul 2000 10:00:00 -0500 Subject: Open letter to Guido van Rossum In-Reply-To: Your message of "Mon, 24 Jul 2000 00:02:57 -0400." <200007240401.AAA07578@mail3.mia.bellsouth.net> References: <200007240401.AAA07578@mail3.mia.bellsouth.net> Message-ID: <200007241500.KAA15212@cj20424-a.reston1.va.home.com> Dan, Thanks for your letter. I'll try to address each point separately: Point: Oracle. I know zit about Oracle, and I don't have an Oracle database sitting in a corner here, so I don't know how I could decide between the existing solutions! (I see at least three in the Vaults of Parnassus.) This is an issue better brought up in the db-sig, but last I looked the db-sig was comatose itself. I really don't know what else I could do! Point: Apache module. As far as I know this is the module currently favored by Greg Stein, who knows the Apache internals far better than I do. If you have specific problems with mod_python, I suggest sending a bug report (or better: a patch!) to its author (see http://www.modpython.org/). Point: MySQL. Almost the same as Oracle, except PythonLabs team member Jeremy Hylton knows a lot about MySQL. I've cc'ed him. Jeremy, can you recommend a specific MySQL extension? We could do something about this, e.g. include it in the core distribution (if it's orphaned and the license allows it) or at least have a recommendation on python.org. --Guido van Rossum (home page: http://dinsdale.python.org/~guido/) > Subject: Open letter to Guido van Rossum > From: Dan Grassi > To: "Guido van Rossum" > Cc: , , > > Date: Mon, 24 Jul 2000 00:02:57 -0400 > > Hi Guido, > > Well, I am rather ambivalent about 1.6. See, I really like python and > want to use it at work, a dot-com --- in fact I would like it to be the > standard. But I doubt that it will come to pass, there are to many > stumbling blocks. > > First and foremost is database support as a part of the languare > _package_! In particulay I need Oracle on ix86, a not uncommon database. > But that is no trivial task. Thus python fails because it can not be > used in a production environment that involves Oracle. > > Then there is the mod-python/mod_pyapache mess, two competing versions > both with major problems ranging from re not working in the module > version of mod_python to memory leaks in both versions. Memory leaks are > a major problem in a shop that is serving over 1 million pages a day. > > Also in the area of divergence is the MySQL database interface modules, > there are at least two and I believe four current versions. > > OK, but this is not python! Well, technically that is true but these are > problems when one tries to use python in production! > > I suggest that you, Guido van Rossum, father and inventor of Python, > "bless" some versions and thus get development behind single versions > instead of diverging from each other. Thjis in much the same manner that > Linus blesses a release of Linux. > > Oh well, this is just wishing upon a star. :-) At least I do get to use > python on occasion, thanks. > > Dan Grassi From moshez at math.huji.ac.il Sat Jul 29 01:00:45 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 29 Jul 2000 08:00:45 +0300 (IDT) Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message-ID: On Fri, 28 Jul 2000, Grant Edwards wrote: > Why does "what non-programmers do" matter when designing a > programming language? Because Python is meant to be an easy first language. and-it-does-that-wonderfully-ly y'rs, Z. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From ge at nowhere.none.bbs Mon Jul 17 16:50:04 2000 From: ge at nowhere.none.bbs (ge at nowhere.none.bbs) Date: 17 Jul 2000 20:50:04 GMT Subject: newbie unimpressed... Message-ID: <3bRP2T$m9_@openbazaar.net> In article <8kvqqb$8e5$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >In article <8kvp81$9q1$1 at nnrp1.deja.com>, wrote: >> >>(I'm using python 1.5.1 on Redhat 5.2) > >I strongly recommend upgrading to Python 1.5.2. The documentation is >much better, for starters. FWIW, RH 5.2 is getting a bit old also. I couldn't recommand 6.[01], but 6.2 seems to be decent. -- Grant Edwards grante Yow! I'm wearing PAMPERS!! at visi.com From johannes at zellner.org Thu Jul 6 19:15:20 2000 From: johannes at zellner.org (Johannes Zellner) Date: Fri, 7 Jul 2000 01:15:20 +0200 (CEST) Subject: eval In-Reply-To: <006601bfe79f$77fe8b10$788b18ac@boeckh.com> Message-ID: On Thu, 6 Jul 2000, Stuart Ford wrote: > > ----- Original Message ----- > From: Johannes Zellner > To: > Sent: Thursday, July 06, 2000 5:46 PM > Subject: eval > > > > > > Hi, > > > > how does eval work ? > > > > eval('print "fred"') > > > > exec not a function in the real sense, but a core command, > it does not require the use of parentheses. > > Examples: > > eval 'print "fred"' will work.. > > or > > command = 'print "fred"' > exec command will work just as well.. > > I have used exec to process dynamically written code within the > current namespace. ahh. I see. thanks. And how do I define the scope where exec evaluates ? E.g. def generator(x): eval 'def '+x+'(y): print "fred"' and after calling >>> generator('lola') I want to be able to use >>> lola('lolita') -- Johannes From forums at memoire.com Fri Jul 21 12:56:12 2000 From: forums at memoire.com (Guillaume) Date: Fri, 21 Jul 2000 16:56:12 GMT Subject: Class static variables Message-ID: <8l9vb3$kae$1@nnrp1.deja.com> > > I'm writing a tool to translate a variety of OO > > programming languages. Especially I target Python > > but I am hesitating about the way to define > > class-scope static variables. Could you suggest me > > what is the best and natural form ? > > > > Example: MyClass { static int a; } > > - MyClass_a > > - accessors + global var > > - any other form > MyClass.a will work unless it is a function. (class attributes that are > functions are magically turned into instance methods) For example: > > class MyClass: > #define class attribute > a = 0 > def method(self): > #use class attribute > do_something_with(MyClass.a) > > #use class attribute outside of MyClass > do_something_else_with(MyClass.a) Thanx for the answer but... >>> class CA: ... a=0 ... >>> b=CA() >>> b.a 0 >>> b.a=2 >>> c=CA() >>> c.a 0 >>> b.a 2 # c.a should be 2 and not 0 if a is a static attribute. >>> class CB(CA): ... pass >>> CB.a=3 >>> CB.a 3 >>> CA.a 0 # here a big problem. the attribute is not inherited... So for all these reasons, I think I will use __getattr__ and __setattr__ Here is the code I should generate for managing static vars. Fortunately, there is no need to change the python access for reading. class A: def __setattr__(self,name,value): print "A: set "+name+" %s" % value try: A.__dict__[name] A.__dict__[name]=value return None except KeyError: self.__dict__[name]=value # static vars for A A.x="XX" A.w="WW" class B(A): # instance vars for B z=None def __setattr__(self,name,value): print "B: set "+name+" %s" % value try: B.__dict__[name] B.__dict__[name]=value return None except KeyError: A.__setattr__(self,name,value) # static vars for B B.y="YY" a=A() b=B() b.z="ZZ" print b.z print b.w print a.x a.x="XXXX" print a.x print b.y b.y="YYYY" print b.y print b.x try: print b.v except AttributeError: print "v is not defined..." Sent via Deja.com http://www.deja.com/ Before you buy. From tim.hochberg at ieee.org Wed Jul 19 11:06:13 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 19 Jul 2000 15:06:13 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: <39751EFA.6293FDFE@prescod.net> <39756EEB.7CC8F262@fft.be> Message-ID: Gregory Lielens writes: [SNIP] > On the other hand, the JNumeric "symmetric" notation looks already > better, even "sexy": > (A)(B), yeah! > > but I see 2 problems: > > -the parentheses around A are important because they are a visual hint > to indicate that this is not a function call, > but a matrix multiply (or more generally, an inner product for Nd > numeric arrays). But internally, (A)(B) is the same as A(B) (I think it > is the case, please correct me if I am wrong), This is indeed the case. > so we have to count on > the good will of people to avoid the A(B) thing, and to avoid to write > (f)(A) when f is a function. The last case is not likely, but if f is an > array of functions, (f[i])(A) could happen (and have a totally different > meaning if f is an array of Numeric arrays). This problem comes only > from "look", but it is important imho, I really fear to see A(B)! This (obviously) doesn't bother me as much as it bothers you. In part because it's common to see indistinguishable notation for multiplication and functions "on paper". Although I will admit that A(B) is the the one permutation that rarely means multiplication. On the other hand, you almost never see matrix multiplication represented using the same symbol as scalar multiplication as is being proposed with *. > -it gives one more operator only, the multiplication...This is the more > important, I agree, especially if (A.inv)(B) can be evaluated at the > same cost as Matlab's A\B, but it rules out the distinction one could > want to make regarding other operations. I'm not super enamored of these other operations. Plus I've been around CLP for a long time, and its been my experience that the odds of a big pile of new operators will make it into the core in less than several years is very low. Therefore, I'm primarily thinking of what can be done within the current syntax. -tim From plakal at nospam-cs.wisc.edu Mon Jul 24 18:28:05 2000 From: plakal at nospam-cs.wisc.edu (plakal at nospam-cs.wisc.edu) Date: 24 Jul 2000 22:28:05 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> Message-ID: <8liftl$nov@spool.cs.wisc.edu> Dan Grassi wrote: > First and foremost is database support as a part of the languare > _package_! In particulay I need Oracle on ix86, a not uncommon database. > But that is no trivial task. Thus python fails because it can not be > used in a production environment that involves Oracle. I presume you've already seen the modules listed at: http://www.python.org/topics/database/modules.html Have you tried using the mxODBC module to connect to Oracle via ODBC? There's also a module specifically for Oracle: DCOracle. Disclaimer: I haven't used any of these myself. Manoj From hzhu at localhost.localdomain Sat Jul 22 14:48:54 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Sat, 22 Jul 2000 18:48:54 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: On Sat, 22 Jul 2000 11:30:53 -0500, Travis Oliphant wrote: > >We could use (!) for solve and (**) for power (actually I'm not as >convinced that we NEED a solve. But...) . This might assuage some >purists in python-dev. Definitely. > I think it's useful to keep in mind tht we are >not just attracting Matlab users, but IDL, PyWave, J, and other's as well. While Matlab syntax (* for matrix and .* for element) has been mentioned many times here, no one seems to have bothered to describe the others except for IDL (?) that's # for matrix and * for element. Not everyone have used all the different languages or packages. Brief summaries by their users here would provide very helpful background information. Huaiyu From cg at schlund.de Tue Jul 11 11:08:53 2000 From: cg at schlund.de (Carsten Gaebler) Date: Tue, 11 Jul 2000 17:08:53 +0200 Subject: Sybase module crashes (segfault) References: <396B2DEA.2FAEA72B@schlund.de> Message-ID: <396B3885.F612FD76@schlund.de> Solved: I forgot to create the "interfaces" file in the Sybase directory. :-} Now it works. Carsten. From roebling at ruf.uni-freiburg.de Sat Jul 15 03:16:32 2000 From: roebling at ruf.uni-freiburg.de (Robert Roebling) Date: Sat, 15 Jul 2000 09:16:32 +0200 Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython Message-ID: <39700FD0.3C368827@ruf.uni-freiburg.de> Hello, [I am using this list, since the python-announce list is no longer functional.] I would like to announce wxDesigner 1.0, a commercial program that can be used in connection with the free C++ GUI wxWindows library and its populare Python bindings called wxPython. wxDesigner is a dialog editor that allows its users to visually create dialogs using a simple point and click interface. The output produced by wxDesigner can be either of C++ code, Python code or XML, making co-development with wxWindows and wxPython much easier than before. wxDesigner is available for Windows and Linux (Intel and PowerPC), more information including pricing is available from: http://www.roebling.de For more information about wxWindows and wxPython, have a look at: http://www.wxwindows.org http://www.wxpython.org Regards, Robert Roebling

wxDesigner 1.0 - Commercial dialog editor for wxWindows and wxPython. (13-July-2000) From peter at schneider-kamp.de Wed Jul 19 19:55:32 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 23:55:32 +0000 Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3975E070.308511F4@roguewave.com> <3975FF92.1B031588@schneider-kamp.de> <3975EF36.1651C9CB@roguewave.com> <8l52re$tbe$1@nntp9.atl.mindspring.net> Message-ID: <39763FF4.2CA5BF75@schneider-kamp.de> Aahz Maruch wrote: > > Precisely. "Zip" has come to mean compression, and I think *that's* a I hate to warm up the whole thread from python-dev, but I'll post a quote from /F: > is this the end of Python development? > > just imagine what this crowd would have done if guido had asked > you *before* he added things like: > > dir ("hey, dir should give you a list of filenames") > > cgi ("the computer graphics crowd won't like that") > > del ("removes files, right?") > > compile ("but people will think that it generates > machine code") > > global ("but it's not truly global. how about regional > or domestic?") > > hash ("that's a data type, right?") ("or perhaps something > from the The Amsterdam Aloha Seed Bank?") > > hex ("now wait. it's not clear from the name if it con- > verts a hex string to an integer, or the other way around. > oh, it's the latter. sorry, but that will confuse perl pro- > grammers") > > type ("is that some variation of print, or?") > > copy ("I'd say most people expect it to copy entire files") Come on, other languages can live with zip(), too. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From nobody at nowhere.nohow Sun Jul 30 22:08:14 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Mon, 31 Jul 2000 02:08:14 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: In article , Steve Lamb wrote: >On Sun, 30 Jul 2000 16:22:07 GMT, Grant Edwards wrote: >>But in many, many programs (at least in the embedded and process control >>areas where I do most of my work) program objects _do_ correspond to real >>world objects. > > Granted, and in those cases it is appropriate to remember the limitations >of the physical world. However in programming languages, peach.debone is >valid, as is waffle-iron.dial. :) Only if "debone" is a valid operation for the object "peach" and if dial is a valid operation for the object "waffle-iron". You can't state a-priori that this is the case. In real-life only certain operations are valid for a particular object. The same is true in Python. I'm suggesting that this makes Python an easy language for a new programmer to learn. >>I don't understand the analogy. Pens are not responsible for >>parsing English sentances and proofreading them. They're >>responsible for leaving a visible trail when they're dragged >>across a paper surface. > > Exactly. Huh? -- Grant Edwards grante Yow! NOW, I'm supposed at to SCRAMBLE two, and HOLD visi.com th' MAYO!! From ge at nowhere.none Mon Jul 17 16:53:46 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 17 Jul 2000 20:53:46 GMT Subject: newbie unimpressed... References: <8kvp81$9q1$1@nnrp1.deja.com> <8kvqqb$8e5$1@nntp9.atl.mindspring.net> Message-ID: In article <8kvqqb$8e5$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >In article <8kvp81$9q1$1 at nnrp1.deja.com>, wrote: >> >>(I'm using python 1.5.1 on Redhat 5.2) > >I strongly recommend upgrading to Python 1.5.2. The documentation is >much better, for starters. FWIW, RH 5.2 is getting a bit old also. I couldn't recommand 6.[01], but 6.2 seems to be decent. -- Grant Edwards grante Yow! I'm wearing PAMPERS!! at visi.com From gmcm at hypernet.com.bbs Mon Jul 17 19:20:03 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 17 Jul 2000 23:20:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRSk3$hS9@openbazaar.net> Kevin Jacobs wrote: >Silly idea 1: > > Until add-on Python grammar modules are available, what about a > PyAlgebra evaluator module. For a precedent, see regular expressions. > The difference is that linear-algebra syntax can be made too > Python-like for some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() I proposed something very similar to Huaiyu the other day: PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) I know Thomas Wouters did, too. I haven't seen a post reflecting these suggestions. In fact, looking at this thread in one of those tree-view newsreaders, it becomes obvious that branches die when a proposal is made, but arguments are met with vehement counter arguments. Which leads me to believe that: >Silly idea 3: > > Lets continue arguing until everyone, both pro and con, gets > irritated, >starts calling each other Nazis and gives up. ...has already won. - Gordon From btang at pacific.jpl.nasa.gov Tue Jul 25 17:35:15 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Tue, 25 Jul 2000 14:35:15 -0700 Subject: python Message-ID: <397E0813.640A3D21@pacific.jpl.nasa.gov> 1. Learning Python (Help for Programmers) by Mark Lutz, et al I learned python from this book. But it is can be hard for the very beginner. It is a good book though. 2. The Quick Python Book by Daryl D. Harms, Kenneth McDonald I don't have this book, but I read it in bookstore. I think it is better the Lutz's book for beginners. The python distribution also includes a good tutorial. You can learn the very basic from there. -- <> Benyang Tang office: 818/354-0327 <> <> 300-323, JPL fax: 818/393-6720 <> <> 4800 Oak Grove Drive mail: btang at pacific.jpl.nasa.gov <> <> Pasadena, CA 91109, USA <> From m.faassen at vet.uu.nl Thu Jul 27 09:01:54 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Jul 2000 13:01:54 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: <8lpbs3$oac$2@newshost.accu.uu.nl> Guido van Rossum wrote: > A preview of what we will announce: [snip] Ah, good, I was hoping for some clarification. I couldn't keep track of the soap very well; who had died, who had returned with memory loss, who's a good guy, who's a bad guy, if the blind guy will be miraculously healed, will the marriage succeed, and what version numbers they all have. And why. Some hinting as to the 'why' of this confusion in your future announcement would be useful too. Regards, Martijn From aahz at netcom.com Thu Jul 27 10:36:09 2000 From: aahz at netcom.com (Aahz Maruch) Date: 27 Jul 2000 14:36:09 GMT Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> <397F382E.196DE01@sage.att.com> Message-ID: <8lphcp$jdv$1@slb6.atl.mindspring.net> In article <397F382E.196DE01 at sage.att.com>, Garry Hodgson wrote: > >either of these is poor code. how about having the names reflect usage, >which is arguably more relevant than type? > > def ComputeSalary( employeeID, salary, employee ) > >(my salary is very complex :-) Hey! I don't see any complex() declarations! -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From walter111 at structurex.net.bbs Fri Jul 14 23:40:02 2000 From: walter111 at structurex.net.bbs (walter111 at structurex.net.bbs) Date: 15 Jul 2000 03:40:02 GMT Subject: help with tkinter coding Message-ID: <3bPJB2$mTd@openbazaar.net> i got this file from a person on the list not too long ago, thanks for this, it is better then what i was thinking of before just 2 questions: first, how can i make the frame that is to the right of the first one appear on the bottom of it instead second, how do i write more then just a label into the second frame, in the second frame is going to be a new set of options depending on which option was picked in the first frame, so how do i do that? this code works as a standalone -- File test.py #!/usr/bin/python from Tkinter import * class Main: def __init__(self, root): # The top label. text = 'this program figures the area, perimeter, and power of n' text = text + '\n' + '_'*len(text) Label(root, text=text).pack(side=TOP, fill=X) # The 'main' panel to command the option frame to show. self.var = StringVar() self.var.set('power') main = Frame(root, bd=2, relief=SUNKEN) Radiobutton(main, text="1 = Find the power of a number", value='power', command=self.update_frame, variable=self.var).pack(anchor=W) Radiobutton(main, text="2 = Find the area of a shape", value='area', command=self.update_frame, variable=self.var).pack(anchor=W) Radiobutton(main, text="3 = Find the perimeter of a shape", value='perim', command=self.update_frame, variable=self.var).pack(anchor=W) Button(main, text="Close", command=root.destroy).pack(padx=10, pady=10) main.pack(side=LEFT, padx=5, pady=5) # Create 3 frames, one for each option. self.frames = { 'power': Frame(root), 'area': Frame(root), 'perim': Frame(root) } # Populate the option frames at your convenience. prefix = 'this frame is where you put information to get ' list = (('power', 'power of n'), ('area', 'the area of a shape'), ('perim', 'the perimeter of a shape')) for (frame_name, text) in list: frame = self.frames[frame_name] text = prefix + text text = text + '\n' + '_'*len(text) Label(frame, text=text).pack(expand=YES, fill=BOTH) # We start with one frame. self.update_frame() def update_frame(self): # Unpack every option frame. for n in self.frames.keys(): self.frames[n].pack_forget() # Pack the current option frame. self.frames[self.var.get()].pack(side=RIGHT) if __name__== '__main__': root = Tk() root.title('test') start = Main(root) root.mainloop() -- End of file I throw up your class Func and swept a little your code. Hope this helps ? Regards, Jerome From shindich at my-deja.com Fri Jul 14 03:27:20 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Fri, 14 Jul 2000 07:27:20 GMT Subject: Apache Log Parser in written Python Message-ID: <8kmfcf$siv$1@nnrp1.deja.com> There are numerous free Apache Log Parsers floating around. Most of them were written in Perl. I recently installed an Apache server and I needed a utility to parse the access log and produce some simple reports. Naturally I wrote t in Python. While this utility is probably going to be too slow if you have huge log files, for most of you folks who have no more then 100 hits a day this utility could be useful. If anyone is interested you can get it at http://www.shindich.com/sources/. Click on Apache Log Parser link on this page. Enjoy! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From richard_chamberlain at ntlworld.com Fri Jul 28 01:39:31 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 28 Jul 2000 06:39:31 +0100 Subject: javadoc equivalent for python? References: <3980AA2F.4E4E6E1F@seas.upenn.edu> Message-ID: David, A couple of things spring to mind: There is PythonDoc - which I've not used but you can get it at: http://starship.python.net/crew/danilo/pythondoc/ Also Ka-Ping Yee's inspect.py and htmldoc are very good: http://www.lfw.org/python/ These produce documentation based on docstrings and comments (#). Paul Prescod recently asked me to write a raw text ouput using inspect.py which you can have if you let me know. Richard David White wrote in message news:3980AA2F.4E4E6E1F at seas.upenn.edu... > Hi all, > > Is there an equivalent python application to javadoc? > > thanks, > david From boncelet at eecis.udel.edu Mon Jul 17 15:44:19 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Mon, 17 Jul 2000 15:44:19 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> Message-ID: <39736213.15848862@eecis.udel.edu> Bjorn Pettersen wrote: > > Perl, C++, Visual Basic, Java, and probably also Tcl are all more > popular than Python. Are you suggesting we should add their special > syntaxes/quirks just because a lot of people know them? Not at all. Python has a clean, simple syntax and I don't want to clutter it the way Perl, for one, has. However, the Python community should look at these other languages/domains and be willing to adopt the things they have done right! (The primary problem, as Huayiu keeps pointing out, is that linear algebra has two sets of operaters: those that work on elements and those that work on whole matrices/vectors. The main need is to distinguish these two for multiplication. If simple syntax for division--inversion--could be defined, all the better.) Why is it ordained that objects should have only two operations, "*" and "+", defined with simple operators? "+" on strings means something entirely different than "+" on numbers. Why not add an "@" operator? With some thought, I'd wager that we could define useful meanings for []@[], {}@{}, etc. And if not and the only problem domain that needs/wants a "@" operator is linear algebra, then just how much clutter are we talking about? Then make it available only when "import Numeric" is done. My argument is that linear algebra is a *big* problem domain. It should not be dismissed as "just another problem." Python could become the primary open source alternative to Matlab in time if a few changes were made: Incorporate numpy into the core distribution (or release a distribution with it already embedded), simplify the syntax for matrix operations, and improve the help facility at the interpreter. Matlab, of course, comes with numerous toolboxes that are unavailable in numpy. Early adoptors will have to write them--just as they do for Matlab! If you build it, they will come... Python, because of its clean syntax, numpy, and existing scientific/graphical tools is better positioned than Perl, TCL, etc, to grab the linear algebra users. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From europax at home.com Mon Jul 10 22:07:36 2000 From: europax at home.com (europax at home.com) Date: Tue, 11 Jul 2000 02:07:36 GMT Subject: Anyone used Python for GPIB instrument control? References: <39668E65.356337BF@home.com> <3967E902.AE41CF0D@attglobal.net> Message-ID: <396A806F.C8695B84@home.com> I didn't think that a wrapper designed for a Linux kernel module would also work for wrapping a Windows Dll. I'll have to take a look at it. Thanks, Rob. Jon McLin wrote: > > The Linux Lab project has a gpib driver, and Python wrappers are included. I > believe the drivers emulate the NI drivers, so this wrapper should work for you. > > ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/IEEE488/ From alex at magenta.com Sun Jul 30 05:41:15 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 11:41:15 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> <8lvovs1dj1@news2.newsguy.com> Message-ID: <8m1evi12n4o@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o75fq.fjt.grey at teleute.rpglink.com... > On Sun, 30 Jul 2000 01:21:09 +0200, Alex Martelli wrote: > >> How many would say that abc is a sequence. ;P > > >Most would, of course -- just ask what comes next, and anybody > >with positive IQ will guess 'd'. > > 1 > > What comes next? Now THAT is a poser. In Europe at least, for example, if you're looking for a house you know that what's likely to come next is 3, then 5, etc; odd-numbered addresses are on one side of the road, even-numbered ones on the other (two separate sequences). If you're taking a bus at the stop I often use, what's likely to come next is 27 -- it most often comes by a minute or two after 1 has come and gone. If you're scanning an alphabetized list, such as a typical book's index, what's likely to come next is 10. Etc, etc. In other words, a single item by itself just does not give enough context to make anything but a wild-assed guess. There is no sequence yet, so you must pick, more or less at random, one of the several typical sequences that start with that single item. Giving two items is already much better, and three, very often, give enough indications -- not to determine _univocally_ the rest of the sequence, of course, but still very often to indicate what is MOST LIKELY to come next (a typical question in IQ tests). Be particularly careful with *numbers* -- confusing them with strings is a very high risk here. Given, for example, 123, it's anybody's guess whether this is a number (one more than 122, one less than 124) or a string, i.e. a sequence of three characters, in which case 4 is reasonably likely to be the next one. Isn't it fortunate that good programming languages don't let you suffer from that pernicious ambiguity, by distinguishing 123, the number, from '123', the sequence-of-characters (string)?-) Alex From sglanger at u.washington.edu.bbs Sun Jul 16 17:10:13 2000 From: sglanger at u.washington.edu.bbs (sglanger at u.washington.edu.bbs) Date: 16 Jul 2000 21:10:13 GMT Subject: Internet Programming in Python Message-ID: <3bQa3a$j1_@openbazaar.net> Does anyone know a used book store that would carry this out of print book? Email great. thanks, SL sglanger at oakland.edu From alex at magenta.com Mon Jul 3 11:31:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 17:31:43 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> Message-ID: <8jqbru017gf@news2.newsguy.com> wrote in message news:uhfa7qn9c.fsf at cs.uu.nl... > >>>>> "Alex Martelli" (AM) writes: > > AM> Don Tuttle wrote in message > AM> news:qJ165.8938$nZ5.153196 at typhoon.southeast.rr.com... > >> Consider this a heads up NOT a promotion!! > > AM> Why would the Python community care about a Microsoft-proprietary > AM> quasi-Java-clone...? > > It is not proprietary. They will put the language definition in the public > domain. Maybe not the implementation. OK, let's assume they do. And so...? It's a Java dialect in anything but name, and not a very interesting one either ("Pizza" added much more significant enhancements a LONG time ago, for example). I believe the only relevant issue for the Python community is: C#, like every other Microsoft offering in recent times, will be *STRONGLY* oriented to COM. Every C# object will be a COM object (just like every Java object was one when run under Microsoft's Java VM), etc, etc. So, C#'s possible (unlikely...) emergence as a major language is just the N-plus-1-th motivation for Windows versions of Python to support COM *very, VERY* well. There are many other reasons which apply *right now*, of course. Python's COM support is good, but I think it could be better. Type libraries are no doubt (at some point in the future) going to be obsoleted in favour of other, fuller meta-information, but until that happens I think any enhancement in support for them is going to be a very significant plus for Python, for example. Custom (non-dual) interfaces may be in decline, but, again, there is very substantial need for support for them *today* -- Python supports a lot of them, but, again, I'd like to see more -- more ease in interfacing a given set of interfaces to Python (maybe by autobuilding a .PYD for them?), more ease in generating 'stub' implementations for them to which Python substance can be added, ... Yeah, I know, I should put my coding efforts where my mouth is -- and, having expended substantial efforts doing just this sort of thing for a proprietary scripting language (which I'm pushing _hard_ to be "stabilized" in the future in favour of much better languages such as Python!), I do have the skills and experience... on the COM side of things, at least; haven't really looked at Python's internals yet, and it's been so long since I last programmed in C (as opposed to C++) that I wonder if I still can...:-). But anyway, that's my personal take on the C# "impact" (comparable to that of a goosedown pillow) on Python. Re .NET -- I dunno, and I wish I did! Any relevant URLs will be GRATEFULLY received - I could post a dozen, but I'll do y'all a favour and summarize them into basically two stances: "It's Microsoft and thus evil, vapourware, immoral, and/or fattening" "It's Microsoft and thus good, splendid, progressive, and/or sexy" Nothing REAL, TECHNICAL, DETAILED, nothing one could sink one's teeth into, sigh. Well, apart from XML, and SOAP in particular, but those we already knew as today's silver bullets (and, seriously, they do have real technical substance, of course; the more Microsoft's architectures get "open" by such means, the better -- but Python is already moving fast towards excellent support of XML and even SOAP, so there's no course-change in sight because of those, is there? Just, once again, extra motivation to do what's already being done). I do wonder what other items that have technical reality are in .NET besides C#, XML, and SOAP. If any, that is. Alex From m.faassen at vet.uu.nl Fri Jul 7 11:30:06 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Jul 2000 15:30:06 GMT Subject: POOP / Python (Object Oriented Persistence) ? References: <00c601bfe812$febfeef0$f0c809c0@lslp7o.lsl.co.uk> Message-ID: <8k4t1u$7fk$1@newshost.accu.uu.nl> "Tony J Ibbs (Tibs)" wrote: [snip] > Being able to rely on objects still being around at the next invocation of a > program without the programmer having to (seem to) take any special action > can make certain types of application rather quicker to write ("certain > types" including things like GIS, for instance). [snip] > If that's what's being talked about, it's a bit beyond just having *Pickle > around (and if it's not what's being talked about, that's a pity), and I > think Zope, etc., aren't quite talking about the same thing either. In fact, I do think the Zope Object Database (ZODB) does this. The only real thing you need to take care of is mutable attributes; you need to treat those as immutables or explicitly call the transaction. Everything else is transparent as long as you derive your object from Persistent. > [One of the other exciting aspects of the Glasgow efforts is/was that they > were also looking carefully at the problems of versioning The ZODB has this; it could be improved but right you can change the ZODB from one point of view, keeping it the same from others. It also has undo facilities allowing you to undo transactions back in time. > multi-user access, The ZODB obviously can do this; multi-threaded access to the object database exists. > persistence over LARGE networks, etc. What would this mean? Looks like ZODB can't do this; what is in the works though is ZEO, which allows one to cluster object databases; there's still a single object database but different servers may mirror it; any changes to one will be paralleled by changes in others. Another topic in Zope that I haven't looked a lot at is mountable databases, allowing one to connect a number of ZODBs with different properties together. > - all the real problems one would get if one actually *used* the stuff] Right, and since us Zope folks are using the stuff, some of these problems seem to be taken care of. Do you still think what the ZODB does is much different from what you're describing? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gee308 at mediaone.net Sat Jul 22 20:42:59 2000 From: gee308 at mediaone.net (Toy) Date: Sun, 23 Jul 2000 00:42:59 GMT Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> <210720002132510070%matt@mondoinfo.com> <39794752.D54A50CD@mediaone.net> <220720001345342915%matt@mondoinfo.com> Message-ID: <397A44A8.E3697BF1@mediaone.net> Thanks for the tips. I was trying to analyze your code. Which line is the line that is 'print results from ifconfig'? How do I make is so I can say 'x = ifconfigresults' Thanks Matthew Dixon Cowles wrote: > In article <39794752.D54A50CD at mediaone.net>, Toy > wrote: > > > Thanks for showing me how to do that. I tried to edit something, but it > > didn't work, I'll show you: > > > > > > def getMyAddr(): > > object = raw_input(Which device is connect to the internet(i.e. ppp0, eth0, > > ne3: ") > > p=os.popen("/sbin/ifconfig",object) > > > > Is it possible to do that? > > It's possible to do something like that. The argument to os.popen (and > to os.system) needs to be a character string. So you need to build up > the string so that it looks just like what you'd type at the keyboard. > The string concatenation operator is +, so you'd do something like: > > dev=raw_input("Device name? ") > p=os.popen("/sbin/ifconfig "+dev) > > > Will it work with os.system? What are the differences bewteen using > > os.popen and os.system? > > os.system is similar to os.popen in that both execute a command of the > sort that you'd ordinarily type at a shell prompt. They're different in > that os.system just executes that command and if the command produces > any output, it's printed in your shell window, while os.popen (if you > accept its default) returns a file-like object that you can use to read > the output that the command produces and use it in your program. > > > BTW, I only compared OpenBSD 2.7, Linux 2.2.15, and FreeBSD 4.0, but it seems > > if you do the string search on ifconfig with find text on 1 line beginning > > with inet and ending with mask, It looks like you can get the IP from those 3 > > machines.(of coure I still can't write some code to actually do it). > > In situations like this, it's generally possible to find some mechanism > that works almost all of the time. It's also almost always the case > that eventually something that you were depending on will change and > you'll have to fix your code. > > Regards, > Matt From asmith at valleyt.freeserve.co.uk Sat Jul 29 05:52:34 2000 From: asmith at valleyt.freeserve.co.uk (asmith) Date: Sat, 29 Jul 2000 10:52:34 +0100 Subject: (no subject) Message-ID: <3982A962.226AC51E@14inverleith.freeserve.co.uk> -- ****************************************************************************** Andrew Smith BSc(Hons), MBA Tel: 0131-551 2702 Valley Technology Research Limited, Edinburgh. SCOTLAND Fax: 0131-551 2702 ****************************************************************************** From paul at prescod.net Mon Jul 24 03:55:22 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 02:55:22 -0500 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> <397BDCC6.9C498F01@my.signature> Message-ID: <397BF66A.EF8BDEF4@prescod.net> Greg Ewing wrote: > > ... > > I assume that the main reason for funnelling all three > accessors through a single function stems from the desire to > be able to look up the function using an interned string, > and if it were necessary to turn "foo" into "__get_foo__" etc. > on the fly, that wouldn't be possible. You sound like you are on the right track but I don't know what you mean by the last sentence. If a single dictionary lookup could search for two values in the same time it takes to look up a single value then the design would probably be different. Interning was never my concern. Now I'll add it to my list of concerns. :) > However, this could be easily dealt with by keeping a cache > of translations from attribute names to interned accessor names. I don't see how that helps at all. It's not interning that I'm concerned about. It's looking things up twice. If you've got a solution with the features you describe I'm all for it but I need you to describe the full lookup algorithm. How many lookups does it take to get a normal attribute that is NOT "handled?" How many for a handled attribute? How many to set a handled attribute? How many to set an unhandled attribute? How much book-keeping is required at object creation time? How dynamic is your proposed solution? Are there two dictionaries per instance or one? Two dictionaries per class or one? How does the depth of the class hierarchy affect your solution? If your proposal has these features: > 3. Doesn't magically put any names in the class dict that weren't > explicitly put there by the programmer. > 4. As a consequence of 3, doesn't preclude having a real attribute with > the same name in either the class or instance dict. Then I can only presume that you look up the __get_?? method *first* before falling back to the "real" version. That will slow down plain old ordinary "gets" when there is no __get_?? method. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From bjrubble at shell16.ba.best.com Fri Jul 7 20:15:13 2000 From: bjrubble at shell16.ba.best.com (Adam Clark) Date: 8 Jul 2000 00:15:13 GMT Subject: Help! Indenting craziness! References: <8k5pev$182l$1@nntp1.ba.best.com> <8k5pmq$k3k$1@nntp9.atl.mindspring.net> Message-ID: <8k5rqh$1b5j$1@nntp1.ba.best.com> Ack! Okay, here's the part where I apologize for my bandwidth-wasting ignorance. I found the problem -- a space-indented line about 20 lines up from the flagged line, easily identified by cursoring through it. Paint me red and call me a luser... Aahz Maruch wrote: > In article <8k5pev$182l$1 at nntp1.ba.best.com>, > Adam Clark wrote: >> >>Does anybody have a technique for avoiding syntax errors due to blank, >>unindented lines? I'm getting these on a regular basis, and I haven't >>figured out any reliable way to fix them. Sometimes if I take every line >>in the vicinity, backspace it to the end of the previous line, and >>reposition it, the errors go away. But often they don't, and I end up >>just deleting chunks and rewriting them until Python stops complaining. >> >>This is with Emacs and python-mode. > That doesn't make any sense. This sounds like what can happen if you > switch between Windoze and Unix. Can you give us an example? > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > "do you want my self-identities alphabetically, chronologically, or in > random order?" -- Misha From jhauser at ifm.uni-kiel.de.bbs Tue Jul 18 03:20:12 2000 From: jhauser at ifm.uni-kiel.de.bbs (jhauser at ifm.uni-kiel.de.bbs) Date: 18 Jul 2000 07:20:12 GMT Subject: Does Python have "not a number" floating point values? Message-ID: <3bRfMC$iX_@openbazaar.net> This raised a floating point exception on an Alpha machine. At the moment this is not portable. __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From breiter at usf.Uni-Osnabrueck.DE.bbs Mon Jul 17 06:00:02 2000 From: breiter at usf.Uni-Osnabrueck.DE.bbs (breiter at usf.Uni-Osnabrueck.DE.bbs) Date: 17 Jul 2000 10:00:02 GMT Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython Message-ID: <3bR863$j5_@openbazaar.net> There is a free software wxPython GUI builder: Boa-Constructor. http://sourceforge.net/project/?group_id=1909 http://boa-constructor.sourceforge.net/ wxDesigner is not free software it is not only commercial but proprietory. So it is not the way to go. I supported Mark Hammond with pythonwin, because he wrote free software. I cannot support wxDesigner. We should help making Boa-Constructor even better. (For the people into it, the CVS version was finally updated. Work on the 0.0.4 release is going on. Do not let the low version number fool you.) Bernhard In article <39779151.1066402235 at news.online.no>, thomas at cintra.no (Thomas Weholt) writes: > This is just what Python needs; helper for GUI programming. A single > user licence costs $69 if I remember correctly, which is probably ok, > at least for commercial purposes. ( Nowhere near PythonWorks insane > price-tag ) > > It would, of course, be better if it was free, > On Sat, 15 Jul 2000 09:16:32 +0200, Robert Roebling > wrote: >>[I am using this list, since the python-announce list is no >> longer functional.] >> >>I would like to announce wxDesigner 1.0, a commercial program >>that can be used in connection with the free C++ GUI wxWindows >>library and its populare Python bindings called wxPython. -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From nospam at email.com Thu Jul 20 15:26:32 2000 From: nospam at email.com (CB) Date: Thu, 20 Jul 2000 19:26:32 GMT Subject: Checking for end of a file Message-ID: If I'm iterating through a text file, reading one line at a time within a while statement, how do I check for the end of file. I tried while filename.eof and filename.eof() but to no avail? Colin From jick78 at my-deja.com Wed Jul 12 14:52:10 2000 From: jick78 at my-deja.com (jick78 at my-deja.com) Date: Wed, 12 Jul 2000 18:52:10 GMT Subject: [ANN] mod_snake 0.2.0 - Apache + Python integration Message-ID: <8kieoh$v0k$1@nnrp1.deja.com> (Kinda following suit here, as there doesnt seem to be a working CLPA) Mod Snake --------- An Apache 1.3 and 2.0 plugin to load Python modules Mod_Snake is an Apache 1.3 and 2.0 module that allows Python developers to write Apache modules in Python with as much power as modules written in C. In addition, simple modules are provided to accelerate Python CGIs, to process embedded Python within HTML, and to give a mod_perl style directive power. URL: modsnake.sourceforge.net Download: http://download.sourceforge.net/modsnake License: BSD Style Categories: Net Applications Jon Travis (jtravis at p00p.org) modsnake.sourceforge.net Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com.bbs Mon Jul 17 21:40:02 2000 From: db3l at fitlinxx.com.bbs (db3l at fitlinxx.com.bbs) Date: 18 Jul 2000 01:40:02 GMT Subject: Multiline strings and indentation Message-ID: <3bRWT2$kbr@openbazaar.net> "donotspam-jen at personic.com" writes: > But in both cases you have to put in extra quotes and explict newline > characters (unless you don't care where the text wraps). Well, you sort of have to explicitly handle the newlines with multi-line strings as well, since they are only going to wrap where you actually wrap them. > Multi-line strings > save a bit of typing, and are a bit easier to reformat when editing. So I > guess this means I have to choose between weird indentation (multi-line > strings) or typing more characters? Either that or see what is leading you to using such long, multiple-line strings (needs line breaks within string) directly within the code and see if you might not be better suited with some sort of data structure to access those strings. I don't know what the strings are for, but if they are messages, or prompts, or other user I/O, perhaps installing them in a dictionary or some other structure within your code would permit you to just retrieve the appropriate string later without needing the inline multi-line strings. That would also permit later extraction for separate message handling, internationalization, etc.. should the need ever arise. It would also cluster these long messages in a single place in your code for maintenance. Just a thought - it might not be relevant in your particular application. For myself I tend to find most strings relatively small (and the occasional full line string that is longer than my source line I just let Python do with the automatic string concatentation of two adjacent strings) within the source itself, longer strings tending to be related to some other structure within the code. -- -- 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 jblaine at kickflop.ne.mediaone.net Wed Jul 26 16:28:56 2000 From: jblaine at kickflop.ne.mediaone.net (Jeff Blaine) Date: Wed, 26 Jul 2000 20:28:56 GMT Subject: s = shelve.open(blah), s.items() Attribute Error Message-ID: It seems that shelf objects do not have an .items() method like normal dictionary objects. Is this true? If so, it should probably be pointed out in the docs under 'Restrictions' for shelve. And also, is there a reason? If not, what am I doing wrong? s = {} s = shelve.open(blah, 'c') i = s.items() AttributeError: items From cookedm at physics.mcmaster.ca Tue Jul 18 20:47:05 2000 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: 18 Jul 2000 20:47:05 -0400 Subject: Getting method from within method? Message-ID: I want to do recursion, like this: def factorial(n): if n <= 1: return 1 else return n * factorial(n-1) However, this depends on the name of the method staying the same. For instance, if I did this: fact = factorial factorial = None fact(5) would give me an error since factorial isn't a method anymore. It would be nice if there was some way of referring to the method inside of the method. Is there any way of doing this easily? -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From moshez at math.huji.ac.il Mon Jul 24 08:21:08 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 24 Jul 2000 15:21:08 +0300 (IDT) Subject: iterating over lines in a file In-Reply-To: <%TVe5.12$o45.2102@news.corecomm.net> Message-ID: On Mon, 24 Jul 2000, nobody wrote: > what i was actually trying to do was a prepend-this-string-to-that-file > routine, and i think i got it. the straight translation from perl got > really, really long due to all the try-except pairs; i like exceptions > better than perl's "do {} or die" idiom as they're clearer and seem more > flexible, but they're sure more verbose, too. As a rule, if you find your code littered with try/except's, you're probably doing something wrong. They're called exceptions for a reason. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From pinard at iro.umontreal.ca Thu Jul 6 19:30:04 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 06 Jul 2000 19:30:04 -0400 Subject: readline.c & more In-Reply-To: Thomas Wouters's message of "Thu, 6 Jul 2000 00:25:11 +0200" References: <3963C85D.3924126C@stud.ntnu.no> <20000706002510.F13478@xs4all.nl> Message-ID: [Thomas Wouters] > Actually, SourceForge is now preferred over patches at python.org. Yet, I need a way to submit patches without being Internet-connected, which is my usual state. That is, using email. Besides, composing messages in Web pages is horrible, when one is used to good editors. Moving away from email is not a good thing, from my viewpoint, it should always be available to users. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From see at my.signature Mon Jul 24 01:14:41 2000 From: see at my.signature (Greg Ewing) Date: Mon, 24 Jul 2000 17:14:41 +1200 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <3977C029.2C1DC8AC@my.signature> <397A921E.4FCF8214@prescod.net> Message-ID: <397BD0C1.D85E2395@my.signature> Paul Prescod wrote: > > Plus, why add syntax when a function will do? Because of the extra step of mental gymnastics required to recognise that a zip followed by iteration and unpacking into a tuple is equivalent to parallel iteration. I want to be able to write a loop that *looks* like parallel iteration right from the outset. I must say I rather like the suggestion of calling it tuples(). Maybe make it even a bit more explicit, such as for x, y in tuplesfrom(a,b): I'd still rather have a direct parallel iteration syntax, but I could live with something like that. -- 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 shindich at my-deja.com Mon Jul 10 20:24:10 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Tue, 11 Jul 2000 00:24:10 GMT Subject: Python book suggestions? References: Message-ID: <8kdpeq$hqe$1@nnrp1.deja.com> In article , Randall Parker wrote: > I would like to learn Python because people I respect think highly of it. > I have backgroun in C++, Java, and assorted other languages. I intend to > use Python to do web site development. > > Does anyone have any suggestions as to which books are good for learning > the Python language? > > How about a book about Python and XML? > > How about a book about Python for web site development? > > I'm thinking of starting with the v1.6 version that I see from an article > has a number of language changes over previous versions. Are any books > due out imminently that will cover this newer version? > > There were a cople of dicussions on this subject before. Search dejanews and you will find plenty of suggestions. My personal favorite is "Learning Python". It's a very good book for a beginner. I hope this helps! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com Tue Jul 25 17:03:47 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 25 Jul 2000 15:03:47 -0600 Subject: perl to python, case + regular expression question References: Message-ID: <397E00B3.746787B9@roguewave.com> Jim McKim wrote: > [snip] > The best way I've been able to come up with in python is to execute a > re.search() method twice, once in the if statement, and then again in > the block following the if statement to obtain the match object. > Something like: > > if re.search('^log entry (\d+)', input_line): > match = re.search('^log entry (\d+)', input_line) > log_entry_num = match.group(1) > ...etc. > ... The canonical way is: match = re.search('^log entry (\d+)', input_line) if match: log_entry_num = match.group(1) ... you might also want to take a look at re.compile() if you are matching a lot of regular expressions frequently (I believe the current implementation caches ~30, but I haven't looked at the code lately...) at-least-until-someone-starts-arguing-for-assignment-expressions-again'ly y'rs -- bjorn From hzhu at knowledgetrack.com Fri Jul 21 19:57:32 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Fri, 21 Jul 2000 23:57:32 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> <50ggnss2rhdf2uh3pe6m4o1slib9d6fvko@4ax.com> Message-ID: Would someone like to make a brief summary of the thread on (*) type operators? I did not follow all of them, and can't seem to be able to figure out what the consensus is now. Whether this goes into the PEP, it would be nice to have a summary of the discussion so far. Thanks. John, would you volunteer? Huaiyu On 21 Jul 2000 07:24:31 -0500, John Lull wrote: >"Rainer Deyke" wrote (with possible deletions): > >> "John Lull" wrote in message >> news:ueefns037mjarv63dqpbh52mmr1k6vvaop at 4ax.com... >> > This shouldn't be hard to parse. In fact, it might be a reasonable >> > foundation for class-specific operators: >> > A(.opName)B >> > would get executed as either >> > A.__opName__(B) >> > or >> > B.__ropName__(A) >> > or raise an exception as appropriate. >> >> This would allow constructs such as: >> >> A(.init)B >> >> In other words, it would turn all existing __magic__ functions into >> operators. Not a good idea IMO. > > >One could easily prevent that by having > A(.opName)B >invoke > A.___opName__(B) >instead of > A.__opName__(B) >or some such. > >Clearly there's nothing to force use of the same naming convention for >these operator methods. > >Regards, >John -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From tanzer at swing.co.at Mon Jul 24 01:52:52 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 24 Jul 2000 07:52:52 +0200 Subject: New PEP: Attribute Access Handlers In-Reply-To: Your message of "Sun, 23 Jul 2000 13:17:15 CDT." <397B36AB.92E30999@prescod.net> Message-ID: Paul Prescod wrote: > > In short, folding get/set/del into one function sucks. Besides, it > > doesn't really help when you want to overload just get, but would like > > to keep the set/del of the ancestor. > > That isn't true. You can chain gets to your ancestor's __attr_XXX__ > method if you want, but handle sets yourself or vice versa. You can chain `__getattr__' to your ancestor's `__getattr__', too. It just is a bit cumbersome. IMHO, your proposal exchanges the handling of different attributes in one function with the handling of different aspects of attribute handling in one function There are good reasons for the design of `__{g,s]etattr__' (it is a general solution with a minimum of complexity and implementation effort). I don't see any good reasons for mixing `get/set/del' of a particular attribute into the same function (in particular, it is not a general solution). -- 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 cut_me_out at hotmail.com Mon Jul 3 17:04:03 2000 From: cut_me_out at hotmail.com (Alex) Date: 03 Jul 2000 17:04:03 -0400 Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: Perhaps the tutorial? http://www.python.org/doc/tut/node11.html It all depends on what a definitive statement would be, I guess. Alex. From bvdpoel at uniserve.com.bbs Sun Jul 16 01:30:03 2000 From: bvdpoel at uniserve.com.bbs (bvdpoel at uniserve.com.bbs) Date: 16 Jul 2000 05:30:03 GMT Subject: converting tcl database file to python Message-ID: <3bQBSR$k8M@openbazaar.net> Bob Schmertz wrote: > > Bob van der Poel wrote: > > > also thinking that this is dumb. If I were using C I'd use a structure > > like this: > > > > typedef struct{ > > char *Title, *Artist, *Composer, *Timing; > > }CDITEM; > > typedef struct{ > > char *Name; > > char *Comment; > > char *CDItem[]; > > }CDENTRY; > > > > CDENTRY Mydata[maxtitles]; > > > > Or something like that. Any suggestions on how that would translate to a > > proper python idiom? > > > > Did you consider a CdItem class? No. I've looked at them but the one thing that bothered me is that after defining a class (aka structure) one is free to add variables a will. > class CDITEM(): > def __init__(self, name, comment, etc): > self.name = name > self.comment = comment > self.etc = etc > > mydata = [] > mydata.append(CDITEM("Thriller", "gift from my mom", "more stuff")) For example, after the above I can write: mydata.dummy="bad data" but, since it's just as hard to access the 'dummy' I guess it's not a big deal. Just used to C too much I guess. Looks like a class is the way to go. > > 2. Any quick ideas on how to convert the tcl-style data file to > > something python can deal with? > > Tcl's probably what I'd go with for this. Haven't dealt with it for a while, > though. Yes. started a bit this PM. I think that what I'll do is write a conversion in tcl and end up with a very-verbose datafile format. With PentiumIIs who cares about a few extra cycles of overhead parsing a file. I've just gotta get into the 21th century. -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From sean at digitome.com Sun Jul 2 07:51:10 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:51:10 GMT Subject: __getattr__ and pickle Message-ID: <395f26a4.1832855@news.iol.ie> I have a reproduceable GPF on NT when picking objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From wlfraed at ix.netcom.com Tue Jul 11 00:14:21 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 10 Jul 2000 21:14:21 -0700 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: <126lmsosi64hj8v5dse4ln3khnuvdtpbb8@4ax.com> On Mon, 10 Jul 2000 15:07:54 -0700, bv declaimed the following in comp.lang.python: > > To view the contest summary please click on the "Language Challenge > 2000" on http://sdynamix.com > "The server does not have a DNS entry" (as reported by netscape, and for once it is not my ISP having problems -- I can hit other pages fine). -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From olivierS.dagenaisP at canadaA.comM Sat Jul 22 22:14:13 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 23 Jul 2000 02:14:13 GMT Subject: Making Windows GUI programs References: <8F776CE84nickperkinsusanet@203.2.75.243> <397A529E.900C180A@sitegnome.com> Message-ID: It used to be that 0 out of 8 people found the answer useful (including me), which is why I changed it (added twice to it) in the first place. However, it didn't reset that counter, so really 3 out of 4 people found it useful... : ) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III olivier.dagenais at canada.com "Fiona Czuczman" wrote in message news:397A529E.900C180A at sitegnome.com... > Olivier Dagenais wrote: > > > > I recommend wxPython ( www.wxpython.org ) > > > > http://www.faqts.com/knowledge-base/view.phtml/aid/3565/fid/473 > > Looking at the answer in FAQTs, only 3 out of 12 people said the answer > was useful.. > > I'm very tempted to remove this answer altogether, so, this is a call to > improve the current answer. > > As it stands currently: > > --------start---------- > > What is wxPython? How does it compare with Tkinter? > > Fiona Czuczman, Olivier Dagenais > Shae Erisson, > http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpother > > > wxPython [ http://www.wxpython.org ] is a set of Python bindings for > the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was > written as a C++ library to provide a platform-independant way of > implementing rich and fast user interfaces. > > ----------------------------------------------------- > > I chose wxPython over Tkinter (for my projects) because: > - wxWindows seems to have more widgets than Tk > - special widgets (like the TreeView) are implemented using the > operating system's native implementations, not complete re-writes > - it's more than a "lowest common denominator" among platforms, > wxWindows seeks to provide the same, advanced functionality on all > platforms, even if it means they have to write a lot of code to > complement a platform's native component > - wxWindows seems to cover more ground, in terms of functionality (it's > more than a GUI toolkit, it also seeks to provide functions/classes for > files, threads, printing, clipboard, networking, ODBC, etc...) > - I was *really* impressed with the wxPython demo > > ----------------------------------------------------- > > The wxWindows documentation emphasizes the "less good" points of other > GUI toolkits (namely Tkinter) to motivate wxPython: > > http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpothe > r > > --------end-------------- > > Thanks, > > Fiona Czuczman > > > > > > -- > > ---------------------------------------------------------------------- > > Olivier A. Dagenais - Carleton University - Computer Science III > > > > "Nicko" wrote in message > > news:8F776CE84nickperkinsusanet at 203.2.75.243... > > > Hi. I was wondering if anyone could point me in the direction of some GUI > > > help for windows. I would like to write a program using the windows API > > > set, but the help file that came in the win32all package doesn't make any > > > sence to me. If someone can point me in the direction of maybe a tutorial > > > or a nice document that can help, I would be greatful > > > > > > Thanks in Advance, > > > Nick Perkins > > -- > > Site Gnome - site maintenance, documentation and proof reading > > http://www.sitegnome.com From paul at prescod.net Wed Jul 19 12:08:24 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:08:24 -0500 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <3974C185.E39E082E@prescod.net> Message-ID: <3975D278.7EAB230C@prescod.net> Eric Hopper wrote: > >... > > OK, genericity. I call generic programming 'inheritance for the lazy'. But it has nothing to do with inheritance! > Of the modern languages, the one I can think of right offhand is Java. > And that's something I actually like about it. Java does not require inheritance to do genericity either. Java does require you to pre-declare your interfaces, but you "implement" an interface. You do not inherit from it. The point is that there are three different concepts here, unconstrained genericity, inheritance-constrained genericity and interface-contrained genericity. And we haven't even got to the subtle parts yet! > So, what class do you need to define a read method for? Where did that > object get passed in? What if the read method is only called in some odd > circumstance that manages to excape anyone's notice for years? If you want to check that the read method is defined, you can do that at method boundaries. You don't need to enforce an inheritance hierarchy. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From donn at oz.net Sat Jul 22 11:26:26 2000 From: donn at oz.net (Donn Cave) Date: 22 Jul 2000 15:26:26 GMT Subject: Newbie pythoner, with bizzare problem References: <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F79257Amilenkomoonshinecouk@194.73.73.116> Message-ID: <8lcef2$fbn$0@216.39.151.169> Quoth claird at starbase.neosoft.com (Cameron Laird): | In article , | Michael Hudson wrote: ... |> 5 gets you 7 that you have added a |> |> from os import * |> |> to your script. |> |> Don't do that. | . | . | . | I'd be willing to raise the odds on that bet. Me too. | You're also right that | from os import * | is, of course, universally deprecated. So where do so many new programmers learn to do this? This is a serious question. Is there some tutorial out there that leads them astray? | What surprises me, though, is that no one ever | mentions the possibility of writing | inp = __builtin__.open("c:/autoexec.bat",'r') What surprises me is that you mentioned it. I mean, it's interesting in an academic way, but it's not clear to me how you would see that working in practice. Donn Cave, donn at oz.net From claird at starbase.neosoft.com Tue Jul 18 10:15:23 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Jul 2000 09:15:23 -0500 Subject: Getting local IP address... References: <3974183d_2@my.newsfeeds.com> Message-ID: In article <3974183d_2 at my.newsfeeds.com>, Stephen Hansen wrote: > Um, jeez. I'm rather surprised by these responses -- I assumed it >was some simple little function somewhere I was missing.. I'm also >even more surprised at the differences between the three approaches > >-- #1 -- socket.gethostbyname(socket.gethostname()) >-- #2 -- Some complicated stuff dealing with asking Linux (which, >incidentely, is bad since i'm primarily on a Windows machine for >the time being -- and in the future will be on a *BSD, and hope >to have my program working on all three :)) what the address is >on the given ethernet card.. >-- #3 -- Just go all out and connect, since in the process you >have to be telilng the other side where you are, so you can >get it that way. > >#2 and #3 just seem .. convoluted .. as heck. But because so >many people sugguested them, I have to assume that they >beileve there is some central problem with #1... What is it? :) . . . Yes, there is a central problem that drives people toward convolution in this area. As the OSs are defined in their full generality, there is no guar- antee of a particular numeric address until the connection is established. I sympathize with the perception of wastefulness. That truly is how IP works, though. On the other hand, the most common configurations allow for shortcuts that slash orders of magnitude off that kind of processing. If you know you con- nect through Ethernet as one poster explained, it's certainly OK by me to interrogate your NIC at a hardware level. I've been threatening to write a tutorial on this subject ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From beat.bolli at dware.ch Tue Jul 18 02:48:03 2000 From: beat.bolli at dware.ch (Beat Bolli) Date: Tue, 18 Jul 2000 08:48:03 +0200 Subject: [Patch] {l,r}just with optional pad character parameter References: <8kshd3$l1h$2@bw107zhb.bluewin.ch> <20000716165538.V7340@xs4all.nl> <39733AC7.96CCBF81@schneider-kamp.de> <8kvd70$dn4$1@news.udel.edu> Message-ID: <8l0ujr$h0v$1@news1.sunrise.ch> > > Two reasons why not: > > - it would have been harder to implement > > - undetermined semantics: > > "GvR".ljust(6,"12") =?= "GvR121" > > This is exactly what I would expect -- a 6 char result string > I've been working on this last night; I implemented it for ljust, rjust and center. Right now I'm trying to integrate Unicode support, too. Let me know if you want to see an intermediate version just for strings. Beat Bolli -- dware design & software GmbH Mattenstrasse 11, CH-2555 Br?gg b. Biel Telefon: +41 (32) 374 27 00, Telefax: +41 (32) 374 27 01 E-Mail: beat.bolli at dware.ch From bjorn at roguewave.com Thu Jul 20 12:09:29 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 20 Jul 2000 10:09:29 -0600 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> Message-ID: <39772439.839B99C6@roguewave.com> Greg Ewing wrote: > > Paul Prescod wrote: > > > > We're looking just to pair up elements. > > In that case, obviously the solution is to combine this > thread with the one on new operator symbols, and define > an elementwise tuple-creation operator > > ., I think this would/should be the obvious consequence of adding elementwise operators, I also think it's a wonderful argument for not adding them... for i,j in [1,2,3].+[4,5,6].,[7,8,9].*[10,11,12]: print 'what was the precedence of elementwise operators again?' -- bjorn From gmcm at hypernet.com.bbs Mon Jul 17 14:00:02 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 17 Jul 2000 18:00:02 GMT Subject: Can't load .pyd files from embedded Python interp Message-ID: <3bRKU2$jW4@openbazaar.net> Edward K. Ream wrote: >Gordon McMillan wrote: > >> Most people just use python15.dll from their embedding app so both get >> the same copy. [snip] >Gordon, thanks so much for this reply. This was precisely what I >needed. > [snip] >This illustrates one of the most common failings in documentation: >failing to tell _what_ the reader is to do and _why_. Much >documentation just jumps in and explains _how_ to do something. I just >reviewed the Python Extending and Embedding docs. There is no mention >that one must link against python15.dll, and certainly no hint about >why that is necessary. One or two sentences in the docs might have >saved me about a week of enjoyable, but useless, work. Well, this is a requirement that's unique to Windows. Unixen (those that allow dynamic linking) do (essentially) a full link at runtime, so there's no problem getting symbols from the executable. There's also no concept of an "import lib". And Windows doesn't spell "import lib" differently than "static lib", so it's easy to mistake "python15.lib" for a reference to a static lib, when in fact it means the import lib for python15.dll. It's difficult to know where to document all the platform specific aspects of embedding / extending (especially when it's kind of a moving target). I would guess that most people started by building Python from source, and then playing with the examples. >I'll write up my experiences when I've successfully embedded Python in >my app. For now the conclusion seems to be that one only need link in >C:\Windows\System\python15.dll to the app. There are some details >specific to Borland, but presumably they won't be difficult. I hope you're right about that. - Gordon From alex at magenta.com Sat Jul 29 19:55:43 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 01:55:43 +0200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> Message-ID: <8lvr4n0iue@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o6nub.f91.grey at teleute.rpglink.com... [snip] > >As the 'behaving oddly' will typically produce irreversible alterations > >of a precious persistent database > > Only if you're typically working with persistent databases. Which is what most computer work is doing, though the DB's may not be relational ones. Files, mailboxes, documents, saved games, newsgroups, sites -- call them as you wish, they do persist (hopefully:-) and your data are right there. > Personally, if my email client died because of some uncaught exception > versus me being able to close out my message beacuse of some bug in a display > routine, I'd rather be able to close out and save my 20k message than have to > retype it. There is more to programs than databases. The crucial thing is that it must not mess up your mailbox and its archives -- the rich, large, precious persistent database. If it does not keep a reasonably current copy of what you've typed so far in a safe place on disk, it's junk anyway -- 20k worth of text is likely to be *hours* of worth, and if they're kept in such a way that a program crash makes you lose them, you'll also lose them if electricity goes away, or the *OS* crashes (far from unknown, in Microsoft widespread OS's especially), etc. Losing one working-session, say several hours, is serious damage, and clearly depends on a fundamentally wrong design of the program that handles your work. Losing a serious database, such as a full mail archive, is utter tragedy -- the kind of thing that can break a small company (if they haven't been religiously careful about backing up *everything* frequently -- and far too many aren't). A "small anomaly" that goes unnoticed (rather than triggering an exception, that the programmer cannot ignore by default, but must take a specific decision to catch somewhere) can corrupt the data in ways that are subtle, hard to notice for a long time, and are quite likely to degrade things. A good example I've already seen given to you is a program that's computing prices by multiplying unit price, number of units, taxrate, discount, etc; if any one of those, due to another bug, comes up as the string 'xyz', would you rather the program took that as 0, and by multiplying get the overall price as also zero, so the buyer can get the goods you're selling at no cost at all? Or would you rather get an unmistakable exception just as soon as the wrong data is attempted to be taken as a number? Exceptions are your friends, because mistakes DO happen -- and people writing programs never put in them ALL the checks they should, if the default is that an error goes unnoticed. With exceptions, the default is a dramatic indication of the error, so it DOES get handled -- not always WELL, mind you, since a wilfully wrong-headed programmer can always deliberately choose to catch and explicitly ignore them, but that requires a higher order of perversity than the common mistake of failing to check for each and every possible error!-) > >Fortunately, it doesn't have to be made: wrapping the top-level entries > >in a try/except is so TRIVIALLY easy, that there is really NO excuse > >for any program not doing so. > > Great, and then we're out of some other common practices. CNTL-C, for > example. :P Control-C (depending on the operating system) will cause a specific exception, and the programmer decides how it gets handled. > >but that does not stop ME from having a last will registered, nor > >from wrapping my programs in try/except...:-). > > Just out of curiousity, how do you get back down into the loop if it is, > say, 12 deep? Does Python hit the handler, do its thing, drop back down? No! The semantics of 'restartable exceptions', which you refer to, used to be very popular back when exceptions were first invented, but turned out to be both extremely complex to implement correctly, AND extremely complex to USE, so in practice there was really no pay-off to the complexity. Modern exception-systems are non-restartable: once the stack is unwound all the way to an except clause that handles the specific exception, execution continues right after that whole try/except block. I think the only restartable-exception you're at all likely to encounter today (depending on what kind of work you do, and on what platforms) is Win32's "Structured Error Handling" (SEH), and even that is normally wrapped up into nonrestartable-exception frameworks, such as C++'s (I'm not sure what Python does about SEH, if indeed it does anything about it). If the 12 nested loops must continue (which is infrequent: unhandled exceptions mean unexpected errors, so the whole computation is most likely junked), the try/except block must be at the lowest level. > >Hey, you just *SAID* there could be a None, so you had NOT made > >sure at all that they did contain numbers! None is NOT a number. > >The empty sequence is not a number. You're contradicting yourself! > > No, I made sure there was a number in there, Python is the one that > decided to drop a None in. That group did not match any part of the input string. So, HOW did you "make sure it contained a number"?! no match -> empty sequence (by default: you could have used the argument to groups to have no match correspond to something else, but didn't, so accepting the default of None). An empty sequence is not a number. So you did NOT make sure the group contained a number! You made sure it EITHER contained a sequence of digits, OR it did not (and in this latter case it would contain None). What's Python got to do with it?! What sequence of digits do you believe Python could or should have possibly placed into a group that did not match any part at all of your input string?! Having chosen to place yourself in an either-or case (rather than force both cases to uniformity through the argument to the groups method), you then obviously have to handle each branch. I've lost count of the zillions of ways that have been suggested to you for that purpose, from the plainest if/else, to try/except, to the subtly elegant int(x or 0), etc, etc. _These_ are all ways to "make sure there's a number" (or, for try/except, you could frame it as, assuming there is a number, but also handling the case where there is not), just as the argument to groups is (in a more wholesale way, rather than case-by-case). Alex From rickhigh at aol.com Mon Jul 3 03:27:30 2000 From: rickhigh at aol.com (RICKHIGH) Date: 03 Jul 2000 07:27:30 GMT Subject: JPython and Java integration References: <8j7h3m$5v18j$1@fu-berlin.de> Message-ID: <20000703032730.01208.00001107@ng-cp1.aol.com> Think about using IBM's BSF. BSF = Bean Scripting Framework. It works with JPython, BeanShell, etc. For the price of integrating one language in your applicatoin you get many, many languages. I wrote an article on BSF and JPython at the JDJ (Java Developer's Journal). go to www.sys-con.com hit the JDJ gif, then search for BSF or JPython. From vtbl.moorepe at memo.volvo.se Tue Jul 11 04:55:00 2000 From: vtbl.moorepe at memo.volvo.se (PM) Date: Tue, 11 Jul 2000 08:55:00 +0000 Subject: Installing and running JPython on the AS/400 References: <3969fb38_1@nnrp1.news.uk.psi.net> Message-ID: <396AE0E4.DB024B52@memo.volvo.se> I wonder if the installer need a GUI, if so have you set up remote AWT? Be interested to know if you get it working... Simon Brunning wrote: > > Has anyone done this? I can't even get the JPython installer (from > ) to execute... > > -- > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > The opinions expressed are mine, and are not necessarily those of my > employer. All comments provided "as is" with no warranties of any > kind whatsoever. From ldw at us.ibm.com Tue Jul 18 16:53:54 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Tue, 18 Jul 2000 15:53:54 -0500 Subject: Using filter() References: <8l1o9h$pto$1@news.rchland.ibm.com> <8l256r$d7n$1@netserv.univ-lille1.fr> Message-ID: <8l2g53$14ha$1@news.rchland.ibm.com> Thanks, that certainly works. I don't understand why lambda needs the second parameter. When I experiment with filter( lambda x: string.find( x, name) == 0, fileList) in place of filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) it works as well. I suspect that your codeing come from something more general. Can you explain the reason the sf=string.find construction is useful in this context? Thanks, Larry "Calvelo Daniel" wrote in message news:8l256r$d7n$1 at netserv.univ-lille1.fr... > Larry Whitley wrote: > : I have a simple problem and from the description, filter() seems like a > : match. But I can't figure out how to make it work. Here's the code without > : using filter() > > : include string, os > > : def filter1( fileList, name ): > : #-------------------------------------------------------- > : # matches name to the first characters of a file in the file list > : temp = [] > : for i in range(len(fileList)): > : if string.find( fileList[i], name ) == 0: > : temp.append( fileList[i] ) > : return temp > > This: > > filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) > > gives you back the same result. In this and filter2(), the point > of using the built-in filter is to move out of the loop and design > the test function element-wise. filter then does the job. > > : def filter2( filelist, aString ): > : #------------------------------------------------- > : # finds aString somewhere in the file list > : temp = [] > : for i in range(len(filelist)): > : if string.find( filelist[i], aString ) != -1: # is in the string > : somewhere > : temp.append( filelist[i] ) > : return temp > > Likewise: > > filter( lambda x,sf=string.find: sf(x, name ) !=-1, fileList ) > > [snip main] > > : I suspect using filter() would simplify this. Can someone help? > > : Larry > > HTH > > docstrings-are-your-friend-if-not-then-they-are-enemies-to-be-feared-ly y'rs > > Daniel. > > -- Daniel Calvelo Aros > calvelo at lifl.fr From horst at proceryon.at Tue Jul 18 01:28:52 2000 From: horst at proceryon.at (Horst Gassner) Date: Tue, 18 Jul 2000 07:28:52 +0200 Subject: Best way to switch between different view Message-ID: <3973EB14.1D3F17BF@proceryon.at> Hi all! In my application there are three different kind of views. Each of them has to be displayed in the same main window. Two of them are scrolled canvases and one is a scrolled frame (all of them with many widgets inside). What is the best way to handle this different views? At the moment I completely destroy one view and rebuild the new one but there must be a better way. Some time ago I have read something about an unpack method to hide a widget. Could this be the best way to do this? Thanx in advance Horst From Lisowski.Tomasz at sssa.nospam.pl Wed Jul 12 05:11:04 2000 From: Lisowski.Tomasz at sssa.nospam.pl (Tomek Lisowski) Date: Wed, 12 Jul 2000 09:11:04 GMT Subject: Odp: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: U?ytkownik Olivier Dagenais w wiadomo?ci do grup dyskusyjnych napisa?:rkl95.48923$W35.1068917 at news20.bellglobal.com... > If I remember the tutorial correctly, it doesn't support finally with > anything else. I have a feeling you would need to do: > > try: > #init > try: > # stuff > except: > # stuff > finally: > #stuff > > ...that is, assuming that your "except" would only catch specific exceptions > that you would want to prepare an error message with. Please quote the original message next time. At least I can see in your example one error. If you place try...except... within try...finally..., the latter construct won't see any exceptions at all. Moreover, if #init raises an exception, it won't be caught! I see it more logical in this order: try: try: #init #stuff except: #stuff finally: #stuff If you want separate behaviour for exceptions in #init and the first #stuff sections, add yet another try...except... contruct. If #init is safe, and will not raise any exceptions, it can be placed outside of the inner try...except... construct. Tomek Lisowski From fplancke at my-deja.com Mon Jul 3 14:59:02 2000 From: fplancke at my-deja.com (Frédéric van der Plancke) Date: Mon, 03 Jul 2000 18:59:02 GMT Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> <395D79FE.4E4FDBCE@colconsulting.com> <8jplbd0l5c@news2.newsguy.com> Message-ID: <8jqnpe$vao$1@nnrp1.deja.com> In article <8jplbd0l5c at news2.newsguy.com>, "Alex Martelli" wrote: > Such "prohibition" is not hard at all: > > class dontderive: > def __init__(self): > if self.__class__ != dontderive: > raise "told you not to!" > > class foo(dontderive): > pass > #but... class bypassing_prohibition(dontderive): def __init__(self): pass eh = bypassing_prohibition() #this works because __init__ never automatically calls the __init__ #method of base classes... -- Frederic van der Plancke e-mail address: reverse and add dot-at-dot to: (I don't read regularly.) Sent via Deja.com http://www.deja.com/ Before you buy. From cjw at connection.com Fri Jul 28 12:34:02 2000 From: cjw at connection.com (Colin J. Williams) Date: Fri, 28 Jul 2000 12:34:02 -0400 Subject: List Comprehension Message-ID: <3981B5FA.77941F06@connection.com> Is the following, from http://www.pythonlabs.com/talks/PythonState_files/v3_document.htm a misprint? [(x,x**2) for x in range(5)] -> [(0,0), (1,1), (4,4), (9,9), (16,16)] Should the result not be: [(0, 0), (1, 1), (2, 4) (3, 9), (4, 16)]? Colin W. From to_get_my_address at see.my.signature Wed Jul 26 23:37:22 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 16:37:22 +1300 Subject: Operators for everything (was Re: Operators for matrix) References: <397CB3EA.15F5514F@prescod.net> <200007250053.RAA03842@rocket.knowledgetrack.com> <397CFDAC.38A22DAF@prescod.net> Message-ID: <397FAE70.67357E5C@see.my.signature> Cliff Crawford wrote: > > They sorta remind me of Smalltalk's keyword messages: Hmmm, I must say that A mmul: B looks rather less ugly to me than A @mmul B There are a couple of reasons for this, I think. One is that I find @ to be an ugly symbol in itself to begin with. The other is that it comes with a preconceived pronunciation -- in my mind I hear "A at mmul B" and think "what the &^%#* does that mean?" Whereas the colon doesn't normally have a pronunciation, so the first one sounds better. Also, it harmonises with the usual way of using a colon in English. However, I don't think that any of this sort of thing is going to satisfy the mathematicians. Infix operators work not only because they are infix, but because they are extremely compact, allowing very complicated formulas to be expressed concisely yet readably. The requirement for readability is where all of the proposals for non-alphabetic symbol combinations fall down as well, to my eyes. Even the claimed-to-be-superior (1~+2)~*3 ~- 4 == (10~/2)~^1 doesn't look much better to me than any of the others. When I look at that, the first thing I see is a whole bunch of tildes, and I have to look quite hard to pick out exactly what is after each tilde. It also doesn't help that 1~+2 looks rather like 1 ~ +2 etc. If I had to decide on some set of multi-character operators, I think I would have to go for one of the bracketed sets that have been suggested. And it would probably have to be {}. Both () and [] clash too much with their other uses in an expression, and <-> looks too arrowish. It's unlikely that dictionary construction is going to be used in a linear algebra expression very often, though. A = 3*B{*}C + (D{*}e - F{*}g) {-} H{/}J Not all that great, but at least it has a chance of being read. I think we're just going to have to wait for Unicode before we can solve this in a really satisfactory way, folks. -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From shapr at uab.edu Wed Jul 26 16:57:44 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 26 Jul 2000 20:57:44 GMT Subject: Reading PCI Configuration Space... References: Message-ID: <397F501F.B733ECCB@uab.edu> Jerome Chan wrote: > > Does anyone know how to read the PCI configuration space with Python > under Win 98 or Linux? In linux, try: cat /proc/pci Though I recall that PCI reading via the /proc filesystem has changed recently, although it also maintains backwards compatibility. I do not recall whether reading /proc/pci is the new way, or the old way. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From thor at localhost.localdomain Thu Jul 20 17:57:21 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 20 Jul 2000 21:57:21 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <39770DB6.372D4CFB@prescod.net> <8l77bl$puk$1@newshost.accu.uu.nl> Message-ID: On 20 Jul 2000 Martijn Faassen wrote: >Paul Prescod wrote: >> Martijn Faassen wrote: >>> >>> ... >>> >>> >From a game programming perspective, you can probably consider Python to >>> be dirt-slow, though. The trade-off is a lot of power for speed, but >>> that power can help you gain back speed because you can be a lot smarter. > >> Python is dirt-slow if you are going to write a whole game in it. > > >That said, I think Python can definitely be used in a game engine and that >it wouldn't be too slow for many purposes. Include babbling about >'premature optimization' and 'reinventing the wheel' here as arguments >for the use of Python in games. > I've implemented a game in python for the university. It uses Clips for AI , and tkinter for "graphics". It's 10000+ lines long. It's not slow. And it'll be made public by September (if everything goes well). python is wonderful, much better than pythonistas think. P.S.: The game is entirely written in SPANISH, so till I translate it into English, THOSE with a knowledge in SPANISH may enjoy the reading of such a beast ! I hope everything goes well and by October/November we have the best game with the best AI implemented in PURE python and Clips. --- MGA From stephen_purcell at yahoo.com Wed Jul 12 03:56:47 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 12 Jul 2000 07:56:47 -0000 Subject: example of accessing email account. In-Reply-To: <396C0E23.887E46DA@esec.com.au> Message-ID: <8kh8bv+gipi@eGroups.com> sss wrote: > does anyone have python of how to access web (eg.yahoo) email account? For web mail accounts that have POP access, such as Yahoo, check out the 'poplib' standard library module: http://www.python.org/doc/current/lib/pop3-example.html -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From hzhu at localhost.localdomain Mon Jul 17 16:02:31 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 17 Jul 2000 20:02:31 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> Message-ID: On Mon, 17 Jul 2000 14:12:02 -0500, Paul Prescod wrote: >Maybe you should consider how to scale back your syntactic request. >Perhaps a single keyword or symbol at the beginning of an expression >could make it element-wise or matrix-wise. Well, that would be fine if it is workable, ie, when they don't appear in the same expression. Consider the proposal of having two classes, Matrixwise and Elementwise, with methods to cast to each other. I don't know why (a.E()*b.E()).M()*(c.E()*d.E()).M() would be more preferable to (a.*b)*(c.*d) I chose python because most expressions I write I can visually parse at a glance. Please show an example of special xml syntax proposed that was rejected because it was too special, and we'll see what kind of simplicity the proposal represents. Huaiyu From fiona at sitegnome.com Thu Jul 27 06:53:32 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 27 Jul 2000 10:53:32 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 27th, 2000 Message-ID: <20000727105332.32115.qmail@synop.com> Hi Guys, Here are the latest entries into http://python.faqts.com enjoy, Fiona Including: - How can I determine the number of threads that are running? - Searching an example that has multiple threads write to the Queue object? - How to build arbitrarily-sized lists in one fell swoop? - Does anybody know of a compiler for python? ## New Entries ################################################# ------------------------------------------------------------- How can I determine the number of threads that are running? http://www.faqts.com/knowledge-base/view.phtml/aid/5043 ------------------------------------------------------------- Fiona Czuczman Aahz Maruch If you are using threading.py, and if you create all your threads using threading.Thread() (or subclasses thereof), then you can use threading.activeCount(). However, you should be aware of two caveats: * The main thread that starts up the subthreads *does* count as a thread, so your thread count is always one higher than your first guess. * While occasionally useful for what I call "brute force" threading, activeCount() is mostly useless in "real" threaded programs. If you really want to know how many threads are running, use some kind of variable that you increment and decrement through a mutex. But there are usually no reasons other than debugging to do this. ------------------------------------------------------------- Searching an example that has multiple threads write to the Queue object? http://www.faqts.com/knowledge-base/view.phtml/aid/5044 ------------------------------------------------------------- Fiona Czuczman Robert W. Bill If you hypothetically wanted to have one class log events from threads, you could subclass threading.Thread and start with something that looks like this: from threading import * from Queue import Queue class clientThread(Thread): def __init__(self, q, myNumber): self.q = q self.myNumber = myNumber Thread.__init__(self) def run(self): # do something wacky # logline = "This is a log from thread #" + str(self.myNumber) self.q.put(logline) # this blocks--see Python Library Ref # you may want to wrap in try/except # with put_nowait class logger(Thread): def __init__(self, q): self.q = q Thread.__init__(self) def run(self): print "logger started" # replace next line (range) with an event or something more # useful for i in range(10): logEntry = q.get() # this blocks--see Python Library Ref # you may want get_nowait() in try/except print logEntry if __name__=='__main__': q = Queue(10) logger(q).start() for i in range(10): clientThread(q,i).start() ------------------------------------------------------------- How to build arbitrarily-sized lists in one fell swoop? http://www.faqts.com/knowledge-base/view.phtml/aid/5045 ------------------------------------------------------------- Fiona Czuczman Remco Gerlich l = [x]*n Does what you do here. I don't know what kind of object x is, but note that this doesn't make *copies* of x; if it's some instance, then all elements of l will be a reference to the same old x. Same for your methods. ------------------------------------------------------------- Does anybody know of a compiler for python? http://www.faqts.com/knowledge-base/view.phtml/aid/5046 ------------------------------------------------------------- Fiona Czuczman Shae Matijs Erisson Jeremy Hylton has a source to bytecode compiler written in Python. it's in the python/nondist/Compiler/ part of the CVS tree. Greg Stein and Bill Tutt wrote a Python2C translator, which cuts at least 10percent off of running time from what I've read. The C file that's written is a Python module, and so won't let you make a pure executable though. It's at http://lima.mudlib.org/~rassilon/py2c/ (or was last I checked) A python compiler is definitely possible, especially once you've checked out the two projects mentioned above. I don't know how much it's needed though. From moshez at math.huji.ac.il Mon Jul 3 06:56:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 3 Jul 2000 13:56:03 +0300 (IDT) Subject: Python CGI security In-Reply-To: <39605B6A.28B4E36D@stroeder.com> Message-ID: On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > Thomas Wouters wrote: > > > > On Mon, 03 Jul 2000 08:47:47 +0200, Michael Str?der > > wrote: > > >"E. Jordan Bojar" wrote: > > > > >> [..] buffer overflow [..] > > > > >I'm not a C programmer at all and therefore I just naively used a > > >tool named ITS4: to find parts > > >in the Python interpreter which might have buffer overrun issues. I > > >would really like to have some discussion about the ITS4-output. > > > > If you do want to have that discussion, feel free to send me that report, > > or post it here > > Ok, here are some examples from Python1.6a2 sources (see below). I'm > not a C programmer therefore such tools are my only possibility to > raise some discussion by pointing to code. Off course the tool > outputs only hints. Not every code line listed is a real security > hole. OK, here is an answer to the report I just snipped. There are a few types of "potential security holes": -- exposing insecure parts of the API, such as os.system(). These should stay, since the user should have those at his disposale -- OS/2 message formatting. I haven't looked at it, but this only concerns you if you're working on OS/2 -- checked "dangerous" functions, which are therefore fine as far as I could see -- one sprintf() which will work fine as long as integers are <128 bits, which is true in the forseeable feature. I'm planning to patch this, just in case, but it should be fine anyway. (I'm talking about the first sprintf() in posixmodule.c) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From bkhl at swipnet.se Sat Jul 8 02:16:52 2000 From: bkhl at swipnet.se (Bjoern Lindstroem) Date: Sat, 8 Jul 2000 08:16:52 +0200 Subject: Making tabs illegal References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: Matthew Schinckel wrote: > > > As for the space/tab mixing issue, the answer is simple: Make tab an > > > illegal character in python. Problem solved. > > > > > Ugh! Don't make this the default - I hate having to hit space four times, > I'd much rather just use tab. Um... I had no problem to configure my editor to insert an appropriate amount of spaces when i press . -- Bjoern Lindstroem http://home.swipnet.se/bkhl From mbel44 at dial.pipex.net Mon Jul 31 05:30:17 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Mon, 31 Jul 2000 10:30:17 +0100 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <397FC3FD.92EF0A70@see.my.signature> Message-ID: Greg Ewing wrote: >Toby Dickenson wrote: >> >> I can see some cases where it would be appealing to implement a >> property access handler in a C extension. Is it worth dedicating a >> slot in PyTypeObject for these things? > >I don't think that's necessary, because attribute access >for C objects already goes through a getattr handler in >the type object. Through a getattr hander in the container object, yes. But not a handler of the contained Getter/Setter object (unless it has the special type - and that's the restriction that would be better relaxed). Toby Dickenson tdickenson at geminidataloggers.com From david_ullrich at my-deja.com Sun Jul 9 14:58:19 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sun, 09 Jul 2000 18:58:19 GMT Subject: Problem with real-accurate module num != num References: Message-ID: <8kai06$7an$1@nnrp1.deja.com> In article , cmfinlay at magnet.com.au wrote: > I am having problems with the code below > > QUOTE > from real import * > num = r(0) > num_real = r(0) > if num == num_real: > print "ok" > else: > print "Bad" # the code goes here. > UN QUOTE > > Also > > if num_real == 0 > > Goes to the wrong place as well. All you have to do is add a __cmp__ method to a subclass. With no __cmp__ method real instances get compared by object identity (address?), which is not what you want. There are other problems with real.py - you may want to try Tim's fixed-point class (you can find hints on how __cmp__ should work there in any case). I think it's fp.py, available everywhere (except I don't appear to have a copy on the machine in the office or I could tell you for sure what it's called...) DU > Any help would be very much appreciated > > Col. Finlay > cmfinlaySPAM at magnet.com.au > Sent via Deja.com http://www.deja.com/ Before you buy. From matthias.huening at univie.ac.at Mon Jul 3 11:25:55 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Mon, 3 Jul 2000 17:25:55 +0200 Subject: Again: ODBC / Win98 -> crash References: <8jq7i6$395g$1@www.univie.ac.at> <8F666B563gmcmhypernetcom@199.171.54.154> Message-ID: <8jqbbn$38cc$1@www.univie.ac.at> Gordon McMillan: >Since that's the JET driver (ie, the one that translates ODBC to >JET), you can thank your lucky stars that it works at all . :-) >Access behaves very poorly through ODBC. If you really have to >use Access, you might find ADO more satisfactory. Well, it has to be Access for this project, but I certainly would like to get suggestions for better alternatives on Windows. (But it has to be as comfortable and simple as Access for my colleagues who only see and work with the database frontend.) Now for a really strange thing: I just moved my script to a different computer (almost identical configuration), and... - everything works just fine! No crashes, no problems whatsoever. I hate computers. Matthias From mmorris at mindspring.com Mon Jul 24 11:00:43 2000 From: mmorris at mindspring.com (Mitchell Morris) Date: 24 Jul 2000 15:00:43 GMT Subject: searching for multiple strings in one pass References: <8l7db8$v3g$1@nnrp1.deja.com> <8l9v1k$1tf0$1@nntp6.u.washington.edu> Message-ID: <8F7B58704beablebeable@209.155.56.81> owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) wrote in <8l9v1k $1tf0$1 at nntp6.u.washington.edu>: >In article <8l7db8$v3g$1 at nnrp1.deja.com>, ghost_man at my-deja.com wrote: > [deletia] >>How do I check for several file types in one pass? > >Not knowing the details of the data you're parsing, two ways come to >mind. There are undoubtedly others. > >1) Use regular expressions, i.e. the "re" module. In the example you >gave, you could look for: > \.(?P(hpp)|(cpp)|(etc)) >to match the extension. (?P...) labels the found text; if you call >the groupdict() method on the match object, you'll get a dictionary, one >of whose keys is "ext" -- the found extension. > [deletia] > >Regards, > >-- Russell Stealing a page from the other 'P' language, you could construct a list of the compiled regex objects and apply the compiled form inside your inner loop: import re import sys # Worker bees def do_hpp(line): print 'hpp:', line def do_cpp(line): print 'cpp:', line def do_c(line): print 'c:', line def do_h(line): print 'h:', line # Selector funcs = { re.compile('\.hpp'): do_hpp, re.compile('\.cpp'): do_cpp, re.compile('\.c'): do_c, re.compile('\.h'): do_h } # Off to work with you while 1: line = sys.stdin.readline() if not line: break for pat in funcs.keys(): if pat.search(line): funcs[pat](line) break From aahz at netcom.com Sat Jul 22 14:00:04 2000 From: aahz at netcom.com (Aahz Maruch) Date: 22 Jul 2000 18:00:04 GMT Subject: Discussion: new operators for numerical computation References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> Message-ID: <8lcnf4$vmr$1@slb0.atl.mindspring.net> In article , Neel Krishnaswami wrote: > >My proposal would be to replace it with encapsulated multimethods, >because that's the best way of solving the binary method problem in an >OO language. Explain this in plain English, please (or better yet, plain Python), for those of us who dropped out before getting our CS degrees. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From peter at schneider-kamp.de Wed Jul 19 08:00:31 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 12:00:31 +0000 Subject: Toplevel "test()" functions in standard library References: Message-ID: <3975985F.FF8D1591@schneider-kamp.de> Rob Hooft wrote: > > Wouldn't it be better to move the test() definition inside the if > statement in these cases, to prevent name space pollution? Note that > the routines are not called "_test()", so they will be imported by a > "from ... import *" (There are other modules with a _test() definition > as well). I cannot comment on the reason for this idiom, but for your name space pollution using "from ... import *": Don't use it. Even in the short time I have been on the list I have seen examples of nearly untrackable bugs because of name space collisions when using "from ... import *". I don't even use "from Tkinter import *" in GUI apps. I prefer "import Tkinter; tk = Tkinter; del Tkinter", though it would be really nice to have something like this: "import Tkinter as tk" Which would be short for "tk=__import__("Tkinter",globals,locals,None)" Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From cg at schlund.de Wed Jul 26 04:02:45 2000 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 26 Jul 2000 10:02:45 +0200 Subject: perl to python, case + regular expression question References: <8ll282$mel$1@slb6.atl.mindspring.net> Message-ID: <397E9B25.EC0E3103@schlund.de> Andrew Dalke wrote: > words = string.split(input_line) > if words.get(0, None) == "log": get() only works with dictionaries, not with sequences. Carsten. From Gareth.McCaughan at pobox.com Sat Jul 29 09:10:43 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sat, 29 Jul 2000 14:10:43 +0100 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: Steve Lamb wrote: [I said:] >> None doesn't mean "empty object". It means "no object". There's >> a big difference, whether or not you care to recognise it. As >> big as the difference between "no bottles" and "an empty bottle", >> which is insignificant only if all you care about is the beer. :-) > > Be hard to fool me on that. I'm not trying to fool anyone. > > type(a) > a = None > type(a) > > If it were no object how come it doesn't bomb out again. Maybe the more > precise answer would be that I am trying to create the name a and point to > nothing. None is not nothing. None /is/ something. It is a type. :P Whatever it is, it isn't a type. The word "type" has a meaning (several meanings, in fact), and for none of them is the object called "None" in Python a type. (Although the type of None is called ...) Anyway: it's true that None isn't exactly equivalent to "no object". (Obviously, since None is something you can assign to variables, use as a key or value in a dictionary, etc, etc.) But if you're going to think about it in terms that are as naive as "empty object", then "no object" is a lot closer, and that was what I was trying to say. The thing Python calls "None" is not a sequence. It is not a set. It is not a dictionary. It is not a number. If you'd prefer it to be one of those, or to behave like one of those without any effort on the programmer's part, that's fine; but that isn't the preference of the person who designed Python, it isn't mine, and I rather suspect it wouldn't be many people's. You say that you want to "create the name a and point to nothing". *Why* do you want to do this? The brief description you've given of the problem doesn't give me any clue why Python can't easily do just what you need. (Though not necessarily with the exact sequence of statements you want. That's not a problem: the right way to write a Python program isn't to write a Perl program and translate it line by line.) * The article from which you quoted that one paragraph said a lot of other stuff. I'd be interested in your reaction to it. * I think your basic complaint could be paraphrased like this: "There are lots of things I've got used to Perl doing. Python doesn't do them. Therefore Python is weird, it's full of quirks, it doesn't behave the way real humans expect". To which I reply: Indeed, Python is unlike Perl in many ways. Being unlike Perl isn't in itself a quirk. You happen to find Perl's decisions in some matters congenial; please don't try to make out (as you seem to have been doing in other articles) that this is because you're a Human Being and those of us who find Python's decisions mostly more natural are Weird Geeks, though, because that's not so. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From olivierS.dagenaisP at canadaA.comM Tue Jul 25 22:39:57 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 26 Jul 2000 02:39:57 GMT Subject: PythonWin/Scintilla aggressive folding... References: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> Message-ID: <1csf5.40036$Gh.442627@news20.bellglobal.com> If you don't mind, I opened a bug to track the issue: https://sourceforge.net/bugs/?func=detailbug&bug_id=110240&group_id=2439 It's not a big rush for me to have this feature (dang, I should have opened it as a "Feature Request"), but I would appreciate it as much as (or more than) Mark and others. I would, on the other hand, comment your example as follows (so as to keep the code looking consistent): def z(y): x = 1 # x = sin(y) return x*2 If you assumed that comments were not "level neutral", would that fix it for me? Maybe this could be an option, a flag of somesort called "LevelNeutralComments"??? Is this a work-around-patch-fix that would satisfy more than me? Would a different type of comment (like a double or triple sharp?) also help? There's still the issue of blank lines after a fold. I've noticed that strings on a line don't seem to execute anything, so if you change my comment in the example with a string: class ztApp ( wxApp ) : def OnInit ( self ) : frame = ztLoader ( ) frame.Show ( true ) self.SetTopWindow ( frame ) return true """ Main code """ pngHandler = wxPNGHandler ( ) wxImage_AddHandler ( pngHandler ) app = ztApp ( 0 ) app.MainLoop ( ) ...the string isn't folded in with the class... And since a triple-quote string can also span multiple lines... """ Main code """ ...I'm cool with that... But I have a feeling that I might have a memory or performance issue if I start sprinkling "triple-quote comments" all over the place like that. Is this the case? Maybe the triple-sharp comment idea would be better?? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:2trf5.12076$4p3.93728 at news-server.bigpond.net.au... > [PythonWin / Scintilla folds away comments that belong to next > definition] > > Mark's comments are correct but I'd like to explain a little more. > > Scintilla uses a simple fold discovery algorithm that relies mostly on > indentation and only looks at a narrow window of lines. Often, comments are > not indented with the executable code so are treated by the folder as having > a 'neutral' indentation level which will bind to the indentation level of a > nearby piece of executable code. Blank lines also have neutral indentation > level as they are often sprinkled within a function. This allows a function > like > > def z(y): > x = 1 > # x = sin(y) > > return x*2 > > to fold correctly. It has the downside of binding the top level comment > in your example to the preceding definition. > > This could be fixed by doing a much better job of parsing the Python code > or by doing some more tweaks such as detecting this particular common case. > The argument against a really good parser is the need for performance as the > folding structure is being continuously recalculated as editing occurs. > > Eventually I'll do some more work on the code folder but haven't yet > found a good alternative. It'd be great if someone else was interested in > working on this. > > Neil > > > From postbox at counter4all.com Fri Jul 28 10:21:43 2000 From: postbox at counter4all.com (postbox at counter4all.com) Date: Fri, 28 Jul 2000 16:21:43 +0200 Subject: Professional statistics for your homepage Message-ID: Hi python-list at python.org Check http://www.counter4all.com/omcounter.asp From timin at home.com Wed Jul 12 18:36:32 2000 From: timin at home.com (Mitchell Timin) Date: Wed, 12 Jul 2000 22:36:32 GMT Subject: Seeking Talented People to Work for Stock Message-ID: <396CF36D.D8FD0255@home.com> Hi, This is Mitchell Timin, originator of the Robot Auto Racing Simulation (RARS). That project, although very interesting, is a non-profit enterprise with a narrow audience. I've just started on a new project which is intended to appeal to a large audience. It will be just as interesting to work on as RARS, but will involve a profit making corporation. The product will be a massively multiplayer business simulation game. I'm currently seeking a few people to become the original shareholders of a corporation to be formed. You will not contribute any money, just the product of your time and talent. We will need website design, programming, e-business setup, server setup and operation, technical writing, and legal talent. m From borlak at home.com Fri Jul 21 16:06:08 2000 From: borlak at home.com (Michael Morrison) Date: Fri, 21 Jul 2000 20:06:08 GMT Subject: Accessing current namespace's dictionary... Message-ID: What I'm doing is I have a dictionary that I want added to the modules namespace dictionary. I'm trying to access the module that is running namespace dictionary, but I can't seem to find a way to do it. something like class C: def foo(): __dict__[key] = value Doesn't seem to work. I tried making __dict__ global and failed miserably :P I don't want to result in calling the filename, I want it to be as dynamic as possible. Thanks for any input. Hope I was clear enough :) Michael From alex at magenta.com Wed Jul 5 10:56:38 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 16:56:38 +0200 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> <1c934748.cd75dee0@usw-ex0106-045.remarq.com> Message-ID: <8jvii30149t@news1.newsguy.com> Simon B wrote in message news:1c934748.cd75dee0 at usw-ex0106-045.remarq.com... > I've not heard of any way of getting at DB2/400 from Python > other than via ODBC. But I'd love to be wrong! > > If someone were to port JPython to the '400, you would be able > to use the AS/400 Toolbox for Java's native DB access APIs, but > that would be a pretty major job in itself. Why would JPython have to be "ported" at all? Doesn't it "just run" with any common-or-garden Java Virtual Machine? Alex From paul at prescod.net Sun Jul 23 02:33:03 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:33:03 -0500 Subject: Discussion: new operators for numerical computation References: <8l7c80$mlc$1@tomm.stsci.edu> <8lb6jb$vj9$1@slb6.atl.mindspring.net> Message-ID: <397A919F.331C3933@prescod.net> Neel Krishnaswami wrote: > > ... > > We do need to muck with the language to fix this, but the answer is > NOT to add syntax, but to remove the type/class dichotomy. Then it > will be possible to do something to fix the __mul__/__rmul__ thing so > it's actually usable. > > My proposal would be to replace it with encapsulated multimethods, > because that's the best way of solving the binary method problem in an > OO language. Neel, I think you have projected your own wishes onto that of the matrix people! They specifically *asked for new syntax*. They are perfectly happy with Python's semantics. They just think it doesn't look matrix-y enough. (which it doesn't) -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From cpaulicka at 8cs.com Wed Jul 26 15:07:00 2000 From: cpaulicka at 8cs.com (Christopher Paulicka) Date: Wed, 26 Jul 2000 12:07:00 -0700 Subject: Two COM Questions: QueryInterface, and Callback Inheritance References: <3pnf5.50267$DH3.1583089@news-east.usenetserver.com> <8lm7r402fmm@news1.newsguy.com> Message-ID: > > So maybe I've not understood what is it that you're trying to do. If > you want to access another interface of an object you already have > a reference to, then QI is correct, but you have to specify the interface > identification -- the IID, not the CLSID. If you want to instantiate a > brand-new object, then the CLSID is correct. But that is a > substantially different task. > Okay, I didn't give enough detail, and I appreciate all your help. In PythonWin (or pythoncom), when you generate Python wrappers for your classes, it does so for both the interfaces (dispatch interfaces) and the coclasses. If you look at the generated code, it calls their GUID (either CLSID or IID) the "CLSID" attribute of the particular Python class. Okay, perhaps the simplest thing to do is to just give you an example, and see if you can help me. The following code is exactly what I want to do. You must have DirectAnimation installed on your machine (by default with 98, and W2K, also comes with IE5). Using makepy, convert "DirectAnimation Library (1.0)". PythonWin 1.5.2 (#0, May 29 2000, 13:52:29) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-2000 Mark Hammond (MHammond at skippinet.com.au) >>> import win32com.client >>> control = win32com.client.Dispatch("DirectAnimation.DirectAnimationWindowedIntegratedM ediaControl.1") >>> m = control.MeterLibrary >>> print m >>> geo = m.ImportGeometry (r"D:\Program Files\Microsoft SDK for Java 4.0\Samples\DirectX\d3drmviewer\Teapot.x") >>> geo >>> geo = geo.Transform(m.Translate3(1.0, 1.0, 1.0)) >>> geo # Now, I assumed that this was old leftovers, that this IDAGeometry also supports the IDA3Geometry interface >>> geo._oleobj_ >>> qi = geo._oleobj_.QueryInterface('{EB5093C7-56F9-11D2-88CE-00C04FA35859}') #IDA3Geometry interface IID Traceback (innermost last): File "", line 1, in ? TypeError: There is no interface object registered that supports this IID # But then I thought, maybe not. Maybe the old library code doesn't really make everything as IDA3Geometry interface # Well, I can still test QueryInterface(), though >>> geo2 = m.ImportGeometry (r"D:\Program Files\Microsoft SDK for Java 4.0\Samples\DirectX\d3drmviewer\Teapot.x") >>> geo2 >>> qi = geo2._oleobj_.QueryInterface('{C46C1BDF-3C52-11D0-9200-848C1D000000}') # IDAGeometry Interface IID Traceback (innermost last): File "", line 1, in ? TypeError: There is no interface object registered that supports this IID # Now this is really strange, anything supporting IDA3Geometry should be queryable to IDAGeometry # Wait, let's try something else... >>> qi = geo2._oleobj_.QueryInterface('{EB5093C7-56F9-11D2-88CE-00C04FA35859}') #IDA3Geometry interface IID Traceback (innermost last): File "", line 1, in ? TypeError: There is no interface object registered that supports this IID >>> # Well, isn't that wierd. An object of type IDA3Geometry doesn't support the interface IID for IDA3Geometry? # # I am very, very confused. This leads me to believe that QueryInterface() is not working, or DirectAnimation is very messed up. From richard_chamberlain at ntlworld.com Mon Jul 10 16:12:41 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Mon, 10 Jul 2000 21:12:41 +0100 Subject: Enumerating drives References: Message-ID: Hi Lars, On Win32 you can use: import win32api,string drives=win32api.GetLogicalDriveStrings() drives=string.splitfields(drives,'\000') print drives GetLogicalDriveStrings returns a string with each drive null terminated so you can use the string module to separate them into a list. There is also a win32api.GetLogicalDrives() which returns a bitmask where each bit represents a drive letter, so 1101 (or 13 in decimal) would represent (going from right to left) a:\,c:\ and d:\. Richard Lars Lundstedt wrote in message news:Syna5.206$967.189230592 at newsb.telia.net... > Anyone know how to enumerate drives (local and network) in Python? > > > /LasseLu > > From rumjuggler at cryptarchy.org Fri Jul 21 17:58:53 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 21 Jul 2000 21:58:53 GMT Subject: Range Literals (was Re: [ANNOUNCE] Python Enhancement Proposals on the Web) References: <39779F05.3181C5E5@schneider-kamp.de> <20000721082752.B9897@xs4all.nl> Message-ID: On Fri, 21 Jul 2000 08:27:53 +0200, Thomas Wouters wrote: >On Fri, Jul 21, 2000 at 12:53:25AM +0000, Peter Schneider-Kamp wrote: > >> The so called PEPs (Python Enhancement Proposals) are now >> available on the web at > >> PEPs that already carry some content include: > >> 0204 Range Literals twouters > >Damn, Peter beat me to it ;) This PEP is in first draft, so any and all >comments are welcome. Do people want me to post it here in full glory, or is >the webpage accessible enough ? > >Note: I don't think this subject will raise as much discussion as new >operators or the name of a new function ;) but I would prefer it if >discussion was kept at a minimum: I'll try to incorporate all opinions in >the PEP, and I'm certainly not trying to be some kind of spanish >inquisition, but the reason I ask this is very simple: I wouldn't be able to >keep up with the posting frenzy ;-P > >But if we can keep it down to, ooh, a hundred or so postings a day, I think >I can manage.... ;P Well, in the PEP you give an example of a non-numerical range literal, ['a':'z']. But in the current slice notation, that would result in a list with elements from a to y. There isn't a one-after-z letter, so how would a list with elements from a to z be constructed? Also, I think that ['a':'z':'b'], as a way to indicate step, is much less legible than ['a':'z':2]. -- Barnabas T. Rumjuggler The night of time far surpasseth the day, and who knows when was the equinox? -- Thomas Browne From alex at magenta.com Tue Jul 25 08:50:02 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 25 Jul 2000 14:50:02 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8ljvta$epd$1@nnrp1.deja.com> Message-ID: <8lk2kc0esc@news1.newsguy.com> "Hartford Hackers" wrote in message news:8ljvta$epd$1 at nnrp1.deja.com... > Is it me or has it been totaly missed that C# sits on top of the Common > Language Runtime Libray. It supports, Eifle, Perl, Python, VB, C++, C# > and Java. Any language can call any object from any other language! I have not missed it, but it surely bears emphasizing. Although Java is not what Microsoft is hot about -- substitute Cobol in that list, I guess:-). (And most languages will be in dialects/subsets for full IL interoperation; e.g., Eiffel# rather than real/full/true/complete Eiffel, since IL does not support multiple inheritance of implementation, which full Eiffel wants; dunno what Python .NET will do about that). > My question though, is, how does this effect future versions of Python, > or Perl for that matter? Who controls the distribution of this library? CRL (or CLR or whatever the correct acronym happens to be) is a Microsoft-proprietary thing; I doubt it will be available for non-MS platforms, judging from how COM fared on such platforms in the past (e.g., Mozilla has its own portable COM clone, but I do not think it interoperates with any other COM, clone or true, on the planet). ActiveState is handling the porting of Python and Perl to the .NET framework (and thus, to IL and CRL in particular), and Hammond in specific is Numero Uno on Python .NET, it appears from his recent posts to this group. But there isn't much yet on ActiveState's site about either Python .NET or Perl .NET. Presumably things will be a little better when Visual Studio .NET's first beta appears (currently, only a pre-beta of it is yet around). Alex From calvin at studcs.uni-sb.de Sun Jul 16 07:03:55 2000 From: calvin at studcs.uni-sb.de (The Dude) Date: Sun, 16 Jul 2000 13:03:55 +0200 Subject: html link parser? References: Message-ID: <3971969B.20EA6D30@studcs.uni-sb.de> Paul Johnston wrote: > > I'm looking to parse the links out of an html document. Is there a module > analogous to Html::LinkExtor (perl)? > > Thanks for your help, > Paul This is part of my LinkChecker (linkchecker.sourceforge.net). The code does not honor a tag, but if you look into the complete source code, you can find it there. _linkMatcher = r""" (?i) # case insensitive < # open tag \s* # whitespace %s # tag name \s+ # whitespace [^>]*? # skip leading attributes %s # attrib name \s* # whitespace = # equal sign \s* # whitespace (?P # attribute value ".*?" | # in double quotes '.*?' | # in single quotes [^\s>]+) # unquoted [^>]* # skip trailing attributes > # close tag """ # note: you can use other link tags too like "img src=..." pattern = re.compile(_linkMatcher % ("a", "href"), re.VERBOSE) htmltext="..." index = 0 while 1: match = pattern.search(htmltext, index) if not match: break index = match.end() print "Found url %s" % match.group('value') From moshez at math.huji.ac.il Mon Jul 31 00:46:08 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 31 Jul 2000 07:46:08 +0300 (IDT) Subject: Content of the Perl6 talk In-Reply-To: <14724.19154.174891.634614@anthem.concentric.net> Message-ID: On Sun, 30 Jul 2000, Barry A. Warsaw wrote: > Probably much more useful, if possible, would be to modularize some > key functionality that the languages have in common. The only example > I can think of off hand would be a regexp engine. It's kind of silly > that all three languages would support the same syntax and largely the > same features and functionality with entirely different code bases. Sadly, even that's not really true. You can ask Andrew about the wonderful fun he had trying to pry Perl's regexp engine from the clutch of interdependancies. Perl's regexps are part of the language, and the language is part of them (e.g., /e). -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From aahz at netcom.com Mon Jul 31 19:33:27 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 23:33:27 GMT Subject: [6th Draft] Open Letter to CNRI: Request for clarification References: <39861173.30E94EDC@nowonder.de> Message-ID: <8m52c7$ki4$1@nntp9.atl.mindspring.net> In article <39861173.30E94EDC at nowonder.de>, Peter Schneider-Kamp wrote: > >Aahz Maruch [aahz at pobox.com] Please list my name as "Aahz", not "Aahz Maruch"; "Aahz" is my legal name. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From cut_me_out at hotmail.com.bbs Mon Jul 17 14:30:07 2000 From: cut_me_out at hotmail.com.bbs (cut_me_out at hotmail.com.bbs) Date: 17 Jul 2000 18:30:07 GMT Subject: Changing the class of an instance Message-ID: <3bRLJW$k02@openbazaar.net> > I don't think "confusing" is the right word. Although I'm fairly > certain I won't get the words right: It destroys the... maybe the > word is "encapsulation" or "modularity" or something - it means that > you cannot verify things are correct by just looking at things > locally. You're probably right, I don't know much of the jargon. > Not sure what sort of debugging we're referring to. If you're trying > to figure out how to do something, as opposed to writing code meant to > be used later, that's different. True, that's what I was trying to do, so the changing of the class was only happening on a very limited and interactive level (and it still got a bit confusing at times. :) > Possibly I missed it, but I haven't seen any reason given why changing > __class__ is better than creating a new instance Well, if you want to do it by creating a new instance, you have to make some sort of copy constructor. Unless you automate the process so that it copies every attribute of the instance, you are bound to forget one at some point. Alex. From jmcbray at carcosa.net Thu Jul 27 10:26:06 2000 From: jmcbray at carcosa.net (Jason F. McBrayer) Date: 27 Jul 2000 10:26:06 -0400 Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> Message-ID: >>>>> "SP" == Steve Purcell writes: SP> Shae Erisson wrote: >> And I'm opposed to it because it seems like sugar to me. I've always >> loved Python's simplicity, and I hope it stays that way. >> Adding new operators and new syntax will make Python harder to read, and >> harder to learn. I don't want that. SP> Yay! Python luddites unite! SP> It also seems to me that Python is popular and effective exactly SP> because of its simplicity. I love the fact that Perl folks rant SP> about features 'missing' in Python only to find that the exact SP> same functionality is available in a nicely packaged form in a SP> standard module (e.g., 're'). This is the Python aesthetic, and I SP> love it. Me too! I wouldn't at all mind seeing the standard library grow massive and all-encompassing over time, but the core language is as big as it needs to be. -- +-----------------------------------------------------------+ | Jason F. McBrayer jmcbray at carcosa.net | | A flower falls, even though we love it; and a weed grows, | | even though we do not love it. -- Dogen | From thomas at cintra.no Tue Jul 25 08:32:49 2000 From: thomas at cintra.no (Thomas Weholt) Date: Tue, 25 Jul 2000 12:32:49 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> Message-ID: <3980872e.118551357@news.online.no> I asked the same exact question some time ago. Nobody knows. I don't think Guido knows either ( allthough I hope he has some idea :-> ). Now, Python after 1.6-beta cycle will be Python 2.0, not 1.7, if I'm not mistaken. Python 3000 will possibly have some new features etc. that will not be compatible with 1.x or 2.x. Having seen how Python has evolved over time I think you can be sure that Guido and his teammates know what they're doing and that reasons for new, non-backward-compatible features will outnumber the reasons for letting thing stay as they are. As of now, look forward to 2.0, and take everything said about the future of Python with a truckload of salt. ;-> Thomas On Mon, 24 Jul 2000 22:01:00 +0200, "Patrick Fichou" wrote: >Anyone knows more about what will be Python 3000 ? It seems that it will be >the next evolution of this language, after the 1.7 version. The big issue is >that Python 3000 would not be compatible withe the actual 1.n language !? >How it is possible and what it means ? > >Patrick > > From grey at despair.rpglink.com Sat Jul 29 22:45:58 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sun, 30 Jul 2000 02:45:58 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 01:48:32 GMT, Grant Edwards wrote: >I concur. In non-programming, life is strictly typed. Allowed >operations are determined by the type of the object. You can't >make a phone call on a waffle-iron. Were I to _try_ to make a >phone call on a waffle-iron, it doesn't "automagically" convert >istelf into a telephone. Instead, I get a rather interesting >burn pattern on the side of my head. You're making the mistake of trying to associate programming concepts to real world objects. I'm sorry, but that is why I said data is data is data. To give you a counter example when I write my pen doesn't toss up an exception when I write out, "11 people are insane!" because it contains an integer in a string context! -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From lull at acm.org Thu Jul 13 22:57:03 2000 From: lull at acm.org (John Lull) Date: 13 Jul 2000 21:57:03 -0500 Subject: TypeLib for Python COM Server? References: <4D0A23B3F74DD111ACCD00805F31D8101D8BD2CD@RED-MSG-50> Message-ID: <480tmsoca5s08fevqa27or2do9cqe08gv2@4ax.com> Bill Tutt wrote: > Don't rely on the 1000 thing. You should specifically declare the dispid's > in the Python class. How? Thanks, John From edream at tds.net.bbs Sun Jul 16 17:40:13 2000 From: edream at tds.net.bbs (edream at tds.net.bbs) Date: 16 Jul 2000 21:40:13 GMT Subject: Can't load .pyd files from embedded Python interp Message-ID: <3bQafC$lz_@openbazaar.net> Hi, I'm having difficulty importing modules defined in .pyd files from an embedded Python interpreter. The problem seems to be that two sets of variables are being used and no linking is happening when the DLL is loaded. Perhaps you DLL gurus will spot the problem immediatly. Details follow... I've embedded the Python interpreter in a wxWindows test app using the Borland compiler. The interpreter was embedded in a straightforward way, by creating python15.lib and parserLib.lib from the sources, then linking these libs with no special options into my app. I've also used the python15.lib and parser.lib files from the Windows distribution, with approximately the same results. Because of problems with FILE * params in the C API, it seemed best to build the .lib files using the Borland compiler. The app can execute code such as the following from the wxWindows OnInit code: Py_Initialize(); PyRun_SimpleString("for i in sys.path: print i"); Py_Initialize() exercises lots of code, including all the code I modified for the Borland compiler, so most everything is working. However, I am not able to import files defined in any .pyd file, say like this: Py_Initialize(); PyRun_SimpleString("import parser") ; where parser is contained in parser.pyd. No matter what .pyd file is imported, the code fails by calling Py_FatalError inside the DLL's initialization routine, parser.initparser in this example. What happens is this: 1. The call to PyRun_SimpleString("import parser") eventually results in a call to _PyImport_LoadDynamicModule which loads the DLL called parser.pyd by calling: hDLL = LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); The call succeeds. 2. _PyImport_LoadDynamicModule then calls: p = GetProcAddress(hDLL, funcname); where funcname is "initparser" in this example. This call also succeeds, so p points to the init function for parser module. 3. _PyImport_LoadDynamicModule then calls: (*p)(); This statement calls the init function for the imported .pyd file. 4. The init function appears to be entered correctly and very soon the init function calls Py_FatalError. The reason is clear: the init code is using a separate copy of the variable PyThreadState_Current and that variable is NULL because it has never been initialized. The Borland debugger shows this variable as [python15.PyThreadState_Current] rather than [interp_head+4] for the same variable in the embedded interpreter. So what is happening seems clear: there are two separate variables called PyThreadState_Current, and the call to Py_Initialize() in the embedded interpreter initializes only the interpreter's copy, not the DLL's copy. In my mind there are several possible ways to make the two copies of PyThreadState_Current refer to the same memory. 1. [Unlikely] With some special initialization code before calling (*p)(). This is unlikely for several reasons, of which one is there is no indication anywhere that importing .pyd files should require special code. And changing code in _PyImport_LoadDynamicModule seems out of the question. 2. [Unlikely] Perhaps the call (*p)() is defective. Borland C has several directives for declaring function pointers. The present Borland code declares p with: typedef __cdecl FARPROC dl_funcptr; dl_funcptr p; However, the difference between __cdecl, __pascal and __stdcall should make a diffence only if p has arguments. And the init routine seems to be called properly. 3. [More likely?] We should provide information to LoadLibraryEx so that LoadLibraryEx can fixup references within the DLL to point at the corresponding locations in the embedded interpreter. I've looked in vain for information about how to do this. Is this a matter of using special link options, or of providing tables to LoadLibraryEx? 4. [Less likely?] The Windows 32-bit API docs mention the DllEntryPoint mechanism. I don't see anything in the _PyImport_LoadDynamicModule to indicate that this mechanism is used. Instead, .pyd files seem to be using their own kind of init function. After all this background, can anyone tell me how to load .pyd files from an embedded Python interpreter? Also, can anyone suggest a URL that really explains Windows DLL files? The entries at http://msdn.microsoft.com/library seem less than completely satisfactory. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From olczyk at interaccess.com Fri Jul 14 15:14:45 2000 From: olczyk at interaccess.com (Thaddeus L Olczyk) Date: Fri, 14 Jul 2000 19:14:45 GMT Subject: ANNOUNCE: omniORBpy 1.0 is now available References: <8knc6c$mp1$1@pegasus.csx.cam.ac.uk> Message-ID: <3975666e.271888750@nntp.interaccess.com> On 14 Jul 2000 15:38:52 GMT, Duncan Grisby wrote: >AT&T Laboratories Cambridge is pleased to announce the release of >omniORBpy version 1.0. > >omniORBpy is a robust, high-performance CORBA 2.3 ORB for Python. It >is available for free, under the terms of the GNU General Public >License; the libraries are under the GNU Lesser General Public >License. > >Technical features: > > - Fully adheres to the OMG standard Python mapping. > > - Support for the Portable Object Adapter (POA). > > - Support for the Interoperable Naming Service (INS). > > - Strict 2.3 compliant IDL compiler. With the new compiler, it is > easy to write your own customised code generators, using Python. > > - The omniORBpy runtime is fully multithreaded. > > - A persistent COS Naming Service, omniNames, is provided. > > >omniORBpy 1.0 is available for many Unix platforms, Windows, and a >number of other operating systems. Pre-compiled binaries are available >for Windows (NT, 2000, and 9x), Solaris 2.5, Linux glibc2.1, HPUX 11, >and Irix 6.5. > >For more details, and to download omniORBpy 1.0, see > > http://www.uk.research.att.com/omniORB/omniORBpy/ Couldn't you have announced this and omniorb 3 at the same time? Now I have to go back to your web site. Sigh. From jason at _nospam_asylumsoft.com Tue Jul 18 22:18:19 2000 From: jason at _nospam_asylumsoft.com (Jason Ely) Date: Tue, 18 Jul 2000 21:18:19 -0500 Subject: Python in game development? References: Message-ID: <8l32vu$l7$1@news.jump.net> Origin is currently using Python as the scripting language of choice for Ultima Online II They love it from what I understand. What drove them to it? -Jason "Mallor" wrote in message news:v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... > Are any of you game developers out there using Python as your game engine's > embedded scripting language? I am wondering what drove your decision to use > Python instead of other embeddable scripting languages? I'd like to hear what > your overriding concerns were, and also what they are now, having put Python to > the test. > > -- > Cheers, Infernal Troublemaker Troll > Mallor "By simple mistake, mortals themselves amuse." > > > From olivierS.dagenaisP at canadaA.comM Tue Jul 4 23:03:01 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 03:03:01 GMT Subject: Q: Concurrent versionning Message-ID: Hi again... I'm looking into implementing a version control system on a database, so that individual rows (of select tables) can be versionned. (ie: make a copy of that row and increment the version field of the new one, then make changes) My question is regarding modules [or resources] that can detect and report line-level or paragraph-level differences between two text files, very much like the windiff tool provides. Are there such things, out there, already available? Not only that, but (as I'm accustomed to the SLM - aka Slime - version control system, the only one I've ever used) also the capability to merge two textfiles and to elegantly report merge conflicts, very much like "ssync" (again, part of SLM) will do. Maybe this is simple enough to implement, and I just need to understand some techniques in concurrent versionning, so any help would be appreciated. Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From richard_chamberlain at ntlworld.com Tue Jul 25 02:21:12 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Tue, 25 Jul 2000 07:21:12 +0100 Subject: tkinter: grid: expand and fill References: <8lhrbd$t4v$1@nnrp1.deja.com> <8lhs6l$tpt$1@nnrp1.deja.com> <8lhurd$3d$1@nnrp1.deja.com> <397CCB2D.DFD84326@ajubasolutions.com> Message-ID: row_configure(0,weight=1) column_configure(0,weight=1) Richard Dan Kuchler wrote in message news:397CCB2D.DFD84326 at ajubasolutions.com... > Keith Murphy wrote: > > > > here's my example that still doesn't work: > > > > class scrolledtext: > > def __init__(self, master, scrollflags=(NO,NO)): > > stxt = self.stxt = Frame(master) > > txt = Text(stxt, height=5) > > txt.grid(row=0, column=0, sticky=NSEW) > > > > if scrollflags[0]: > > hbar = Scrollbar(stxt, orient=HORIZONTAL, takefocus=NO, > > width=10) > > hbar.grid(row=1, column=0, sticky=W+E, columnspan=2) > > txt.config(xscrollcommand=hbar.set) > > > > if scrollflags[1]: > > vbar = Scrollbar(stxt, orient=VERTICAL, takefocus=NO, > > width=10) > > vbar.grid(row=0, column=1, sticky=N+S) > > txt.config(yscrollcommand=vbar.set) > > > > ...called with the following line: > > statustxt = scrolledtext(sbar, (YES, YES)) > > where sbar is a frame. > > > > i want the text to fill the area except for the spots where the scroll > > bars are. i also want the window to be able to be resized. help! > > > > thanks, > > -->keith > > > > > > is there a way to make a frame, that's been formatted using grid, > > > expand > > > > to fill the space it is given? > > In tcl/tk this would be solved by making column 0 and > row 0 have a weight of 1 and by making column 1 and row > 1 have a weight of 0. > > This would be done using 'grid columnconfigure' and 'grid > rowconfigure' in combination with the sticky code that you > already added. > > If you can find the python equivalent of setting the weight > of the columns and rows, I think your code should work. > > --Dan From paul at prescod.net Mon Jul 17 15:54:57 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 14:54:57 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> Message-ID: <39736491.8AE5ADCE@prescod.net> Olivier Dagenais wrote: > > ... > > We can write a "MatrixPython compiler" (or maybe it would be a > pre-processor) that takes a file that uses Huaiyu's operators and spews out > "normal" Python code. The "compiler" would pass through all non-matrix > specific code and substitute matrix operators with function calls or > something. Something like this has been proposed several times and is IMHO, the best solution by far. Even if we agreed to add matrix ops. to Python, experimentation would be needed in order to choose them. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From ejr at lotus.CS.Berkeley.EDU Mon Jul 24 23:36:56 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 25 Jul 2000 03:36:56 GMT Subject: Multiple dispatch [was Re: Discussion: ...] References: <8ite5.9395$4p3.69392@news-server.bigpond.net.au> <3hu2dfrndo.fsf@angband.org> Message-ID: <8lj20o$36v$1@agate.berkeley.edu> And Eric Lorenzo writes: - - So yeah, you're reducing encapsulation a bit with multi-methods, [...] People keep saying that, but I've yet to be convinced. Even Scott Meyers isn't too sure. The idea behind the following article isn't too far from the CLOS or Dylan view of encapsulation: http://www.cuj.com/archive/1802/feature.html However, note that real impact is only felt when combined with some way of directing the language system to perform type checks for you. If you can stay purely dynamic, multiple dispatch seems much less important to me. A function in a module already doesn't care what type its arguments are... If you're simply using basic attribute methods in its arguments, it's already generic enough. But when you _need_ the types... And sometimes you do. Consider Matlab's non-treatment of the difference between 1x1 matrices and scalars. Or the fact that people commonly expect to add a scalar to a matrix or vector, but not a vector to a matrix. - but in my view, that's okay, because arbitrarily encapsulating the - addition of two objects into the class of whichever happens to be on - the left isn't really appropriate, anyways. Yup. However, you can imagine encapsulation within the _module_. That's a CLOS way to think about OO. Objects aren't necessarily the unit of encapsulation. - Now, to my eye, the latter is far more elegant and matches what's - happening conceptually much more closely, since it treats the type of - each of the two arguments as if they are of equal importance and uses - the same mechanism to deal with both. You can carry this to an extreme. See Cecil's predicate objects at the following super-long URL: http://www.cs.washington.edu/research/projects/cecil/www/www/www/Release/doc-cecil-lang/cecil-spec-23.html Interesting, but unproven. - Because C++ takes into account the type of all parameters [...] At compile time. The standard implementation is much different than that of run-time dispatching (virtual). Python's entirely run-time dispatched. That makes efficient implementations much more difficult. Oh, and the compile-time flexibility in C++ also seems to help my object constructors. The tradititional dynamic way to make objects includes passing dictionaries of options, lots of keyed arguments, etc. That tends to add a ton of conditionals into my constructors, and I don't like code with tons of conditionals. I'm still not sure if this is a deficiency on my side or not... Probably is. Jason, who likes the artificial compile-time / run-time dichotomy less and less... From paul at prescod.net Tue Jul 18 22:58:28 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 21:58:28 -0500 Subject: On special syntax (was Re: Matlab vs Python ...) References: Message-ID: <39751954.97E7906D@prescod.net> Huaiyu Zhu wrote: > >... > > Ok, since the issue of additional binary operators has been repeatedly > compared with various features of Perl that people dislike, without much > details, it might be worthwhile to give it some more thoughts here. We've > already seen that the "it has a small userbase" argument is largely vacuous. Argh. No, it isn't vacuous. Compared to the total number of programmers in the world, the number of matrix programmers is small. > There is also a perception that Perl has too many special symbols that makes > Perl code look like line noise. However, if we look carefully, the fault of > special symbols is not that they are non-alphanumeric, but that they > introducing scoping rules. You have to really think hard to decipher the > scoping of things like @{$a->{$b}}[2]. (Sorry if it is wrong - I'm forgetting > how to make it right now.) > There might be an argument that special characters are hard to read. As I > said, they are hard to read mainly because of their magical effects. No, special characters are hard to read because when you first see them, they have no meaning. Method names have meaning because they are words in some human language. "+", "-", "*" have meaning because you learn them in primary school. @* has no meaning. That's why it looks like Perl to many people. Perl is a language which, among other flaws, ascribes meanings to symbols that have no intrinsic meaning, which is bad from an aesthetic point of view but also makes the language more difficult to learn. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From alex at magenta.com Mon Jul 10 03:39:27 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 10 Jul 2000 09:39:27 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <81da5.125084$WS3.1096675@typhoon.we.rr.com> Message-ID: <8kbuqn0uoa@news1.newsguy.com> "Stephen Hansen" wrote in message news:81da5.125084$WS3.1096675 at typhoon.we.rr.com... [snip] > to other languages, too. As far as i'm aware, you can get around software > patents or copyrights by simply rewriting the software yourself. It can fit > into the exact same nitch, but its your code done your way. Yes, for copyrights; no, alas, for patents, which is why patents on software (and business processes, etc) are such a horrid idea. Alex From db3l at fitlinxx.com Wed Jul 5 20:50:11 2000 From: db3l at fitlinxx.com (David Bolen) Date: 05 Jul 2000 20:50:11 -0400 Subject: "Write to a file" question please? References: <8jvgk9012ca@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > Another alternative: > > import sys > sys.stdout = OUT > print "Number =", number > sys.stdout = sys.__stdout__ > OUT.close() > > By assigning an opened file to sys.stdout > you temporarily "redirect" the output of > normal "print" to that file; you can then > go back to normal using sys.__stdout__, > which keeps the ORIGINAL value. Not worth > it for writing just a few things, but fine > if you have some function doing a lot of > output with print, for example. Just one thought - unless you know that you aren't going to be embedded in some other module (and given how easy it is for one module to import another, who can say for sure :-)), it's safer to save the value of sys.stdout and restore to that rather than explicitly using sys.__stdout__. If the surrounding environment had already "redirected" sys.stdout, this code would have an unintended side-effect of undoing that redirection. -- -- 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.magwene at yale.edu Mon Jul 24 20:32:09 2000 From: paul.magwene at yale.edu (Paul Magwene) Date: Mon, 24 Jul 2000 20:32:09 -0400 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> Message-ID: <397CE009.69835D49@yale.edu> "ye, wei" wrote: > [stuff about braces, variable declaration snipped] > You'll find, I believe, that people on this newsgroup are not likely to give these issues much attention, because they have been rehashed innumerous times on this newsgroup. Having read this newsgroup for about 2 years, the general patterns seems to be that newcomers initially complain loudly, propose the use of braces, variable declarations, etc. (Gee, how come NOBODY thought of that before!). Following this initial period of whininess, they begin to actually program in Python for a little while, find that they didn't really need (or want) those crutches, and preceed to become happy Python converts [I imagine those who don't quietly sulk back to Java and/or Perl]. Please go back and read the hundreds of previous messages on the topic(s). If after doing so and programming in Python for a month or two, you still think you have some valid complaints (and better yet working patches), by all means reraise the topic. --Paul Magwene From alex at magenta.com Wed Jul 26 19:18:52 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 27 Jul 2000 01:18:52 +0200 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <8ljrvu09t6@news1.newsguy.com> <8lma5602i08@news1.newsguy.com> Message-ID: <8lnrpk0qoc@news1.newsguy.com> This discussion may appear out of place in this group, but I do not think it is, because its central theme is VERY germane to recent Python discussions: what IS the correct unit/granularity for encapsulation. Some people appear to believe that the class holds that role, and worry about Python's "weirdness" in making it so explicitly not-so. I claim that, not just (e.g.) in Java with its explicit package concept and default package-accessibility, but also in C++ (through the proper use of 'friend'), the component, NOT the class, holds that role. So, here we go again...: "Mark Baker" wrote in message news:SQGf5.5281$c04.627774 at nntp2.onemain.com... [snip] > >> friend is simply an evil way of violating encapsulation. It's not > > analogous to > > > > Absolutely false, although people with a superficial understanding of > > C++ do tend to think that way. The proper use of 'friend' is to split > > an encapsulated, cohesive functionality among more than one class, > > *because the class is NOT the natural unit of encapsulation*. friend [snip] > I've been writing in C++ for many years now, but this isn't a matter of > who has a larger penis... Clearly not: it is a matter of who is right, and who is wrong, about a specific technical issue: is "friend", in C++, "simply an evil way of violating encapsulation", as you say, or is it rather a way to correctly partition the functionality of one component among more than one class, as I say? I think that Lakos, in his "Large-Scale C++ Software Design", puts it best (p. 136 ff in the edition I have). I can't use bold fonts and pretty display presentation in a post, but that's what he uses in his book to highlight this...: """ Principle: Friendship within a component is an implementation detail of that component. """ "By treating the component and not the class as the fundamental unit of design, we gain an entirely different perspective" -- one without which, Lakos explains (and I fully agree), effective design of large-scale C++ systems is simply unfeasible. The C++ class is *not* the correct unit of encapsulation: the *component*, a coordinated set of classes (and, possibly, free standing functions), that are designed, tested, and released together. (Martin also makes, and richly exemplifies, this crucial concept, in his book and in his articles, of course). Therefore, back to quoting Lakos...: """ Principle: Granting (local) friendship to classes defined within the same component does _not_ violate encapsulation. """ (Here, the _not_ is in italics in Lakos' text). An example that Lakos gives is the Container/Iterator pattern: two classes, that are part of one, single component, and need intimate access to each other's private parts *to the exclusion of other classes that lie outside the component*. "Locally, within a single component, friendship should be granted where necessary to achieve proper encapsulation for the component as a whole". As it happens, one B. Stroustrup appears to share this opinion, in as much as he wrote, for example, in the Annotated C++ Reference Manual, "A friend is as much a part of the interface of a class as a member is". Saying that friends are evil and break encapsulation is therefore just about as silly as saying that member functions do so; they are BOTH parts of the class's interface, so why single out one over the other as "evil" &c? > If an object's internals are to be accessed externally, then methods should > be provided to this inside of the object itself. It should not indicate that > it's alright for "some" people to violate its encapsulation. It's not an issue of *people*. The key issue is that "certain parts need to be accessed from code that is syntactically not part of the class" (but IS "part of the interface of the class", because a friend IS that -- or do you think the ARM does not describe C++, but rather some different language?), but that code is part of the same COMPONENT -- the same unit of encapsulation. No other code needs such unrestrained access: providing that access, now THAT *would* violate the component's encapsulation. > If another object needs access to the internals of another object, then this > should solely be provided by the accessor/mutator pattern. There is no reason to say that, if some classes within one component need to be closely coupled, and interact strongly (which is quite frequent: a component IS well designed as a cohesive unit, after all!), then the close-coupling must be exposed so it can be accessed from *outside* the boundary of the component! For example: in my component I can expose a class X, that I do NOT want other components to instantiate and delete at will; every request-for-an-instance of X, and every return- of-an-used-instance of X, *must* go through the appropriate method of class Factory. I hope you can see that this is a frequent and important case; for example, class X may encapsulate costly/scarce resources, and Factory embeds the recycling strategy for those resources (as well as the other uses of those resources encapsulated in other classes Y, Z, and T, of the same component). Or, X might be a semantically-rich Iterator, not creatable "in vacuo" but only in the context of a given Tree (which is the class that would play Factory's role then), and a Tree must keep track of all the Iterators extant upon it. Etc, etc. How do you propose that the component's semantics, "every 'creation' of X MUST occur through a call to Factory's methods, every 'destruction' of X MUST occur through yet another set of such methods", be enforced "by the accessor/mutator pattern"? I'll tell you: *YOU DON'T*. With 'friend', of course, this is trivially easy -- X's constructors and destructor are private, and X declares Factory as its friend. Compile-time checking of correct encapsulation is then as guaranteed as it ever can be in the C++ language. C++'s approach to encapsulation has its limits, but "friend" is DEFINITELY not such a "limit": it is a crucial ingredient of good large-scale C++ software design. Have you never met such issues in your "many years" of C++ experience?! Or have you let your fetish for letting the class play the inappropriate role of unit of encapsulation stand in the way of good design, when faced with such issues? Perhaps not noticing the fact that friends *are* a part of a class's interface...? > Friends, if attempted for use as "encapsulation" suffer from issues regarding > protecting implementation details, in a paradoxial and limitedly extendable way. > It is rare to be used in this manner. Well-designed software is rare. In well-designed C++ software, however, the proper use of 'friend' is QUITE frequent, and suffers from none of the ills you claim for it. When I want to constrain the creation/disposal of X objects to happen through Factory, this is NOT an "implementation detail" I'm "protecting" -- it IS a crucial part of the interface of my component, with absolutely no paradox to it. In Python, I would rely on convention, as it does not enforce encapsulation. In Java, I would rely on package level accessibility for the constructors. In C++, I will rely on "friend". Accessors and mutators have nothing to do with the case. > They are used quite often to violate real encapsulation principles, for the sake > of performance. Methods that are declared inline may or may not end up as > such with any given compiler. Plus depending on the complexity of accessors, > one may not wish to have this code inlined in every case. In the end, the In which case, one provides two otherwise-identical accessors -- an inline one, and a non-inline one. Hardly rocket science, after all. But if the accessor is complex enough to make inlining it a problem, then the performance 'boost' of the inlining will normally be risible anyway -- and so will be that gained by 'manually inlining' all of this complex code. Worst case, a good designer, faced with a horrible performance bottleneck, may provide lower-level accessors (to expose the specific details that are though to be so crucial to performance, without uselessly exposing all the rest). And if your compiler won't inline "int getX() const { return this->x; }", you have worse problems than any amount of 'friend' can cure. > compiler and not the programmer should be concerned with these, in any event. > But now I'm diverging... > > In the real world, people do use friend to violate encapsulation. In the real world, there's a lot of horribly designed code, and a lot of people who do not understand a too-complex tool well even if they have been using it for years. C++ is arguably too complex for most programmers who now use it, and for most uses to which it is put; Python's simplicity and straightforwardness are a deep breath of fresh air, in comparison, even to somebody who's easily in the top centile in terms of knowledge of C++'s arcana. But that does not justify insulting those language features one does not understand, rather than either trying to understand them better, or giving up the language altogether. > >> modules, packages, or anything else. It simply provides a means of > > violating > >> C++'s encapsulation (usually for speed purposes, since you should be > >> able to use the accessor/mutator pattern to work with object > >> properties) > > > > Again, absolutely false, and, again, suggesting rather superficial > > understanding of C++'s working. A public accessor/mutator can be, and > > generally is, written in-line, with no speed penalty whatsoever over > > access to an instance variable. > > Unless of course you're not simply returning a primitive instance variable. > And then perhaps, as I said, you aren't inclined to want it inlined, or have > it inlined automatically by the compiler. > > Friend, though, is also used rather often to execute private methods. Yes, of course, and of course your "usually for speed purposes" becomes laughable here. What "speed purposes" do you claim are being served, by making a method private and using friend, rather than making the method public?! Clearly, and in exact rebuttal to your "usually", in these cases which now you claim occur "rather often", the purpose here is letting a certain strong coupling happen *selectively*: only between those classes (of the same component) that specifically NEED it, keeping the component's encapsulation INTACT with regard to classes OUTSIDE of the component itself. Note that my example, above, does concern itself with private methods (specifically, private constructors and destructor). I suspect that (partly due to convenience issues) this may be a more frequent case than access to private instance-variables (or private static class variables and functions, probably a rarer need). > > The problem is, this lets ANYBODY read/write that property (through the > > accessor and mutator); what if you only want ONE OTHER, SPECIFIC CLASS, > > to have that ability? Answer: you use friend, which lets you ENFORCE > > encapsulation > > (and keep the accessor and/or mutator private, so that only the friend > > class > > can make use of them -- if it still makes sense to have them, which it > > often does, essentially for purposes of convenience). > > This allows you to partially violate encapsulation, in order to maintain it > elsewhere. This doesn't really increase it, it decreases the violation of it. > To claim otherwise is amusing, at best. Only to someone who clings to the idea that the class is the right unit/granularity for encapsulation, and does not accept the fact (proclaimed in the ARM) that friends are a part of a class's interface. To anybody who understands, there is no violation at all in letting any part of a class's interface access the class's internals, of course, and, so, no occasion for merriment. > More often than not, if you need access to some part of an object's > information, there are chances that someone else will. If you need Nope. I need strong coupling between the classes that make up my single, coherent component; for example, I need my Factory class to strictly control creation and disposal of other object-instances provided by the component. This affords no inference that anybody else needs equally strict control. > access to someone's private implementation, then their framework > lacks much to be desired. Encapsulation is meant to protect mostly the > latter. I suspect you mean "leaves", rather than "lacks", but this is still rather unparsable even with this substitution. "Someone's private implementation" is not the issue. "friend" is never correct _across_ component boundaries; it IS a crucial implementation detail *within* a component. > The Design and Evolution of C++ and The C++ Programming Language are > also good in that Bjarne is more than willing to say where C++ could have been > better, or why a "bad" decision was made. Yes, and never does he say that "friend" is one such bad decision. Much less "evil", as you assert. Stroustrup does not defend bad design decisions (such as the existence of protected data members); you should be thereby readier to listen when he does explain crucial issues, such as the fact that a friend is part of a class's interface just as much as any member is. > Multi-Paradigm Designs for C++, Generic Programming and the STL, and other > such books are also interesting as far as C++ goes. And Lakos' "Large Scale C++ Software Design". I would not recommend it to a C++ beginner, but if you are still using C++ as well as having all those years of experience, you would be well advised to have a go at it: it's VERY instructive. > Even better than strictly C++ books are things such as Design Patterns, > Analysis Patterns: Reusable Object Models, Smalltalk 80: The Language, > Understanding CLOS, and some others. It's much more interesting to look > at language, framework, and pattern designs for a multitude of things, and > then look at any one language's specific features, instead of accepting the > decisions or beliefs of one faction of programmers. Learning and practising many languages is a wonderful thing, but it does not substitute for a deep and complete understanding of one language -- not if one wants to use that language for the best, and not if one wants to freely use words as strong as "evil" to condemn very specific features of that language. It's not an issue of "factions". If you consider C++ too complex, and want to eschew using it wherever avoidable, you will hear no disagreement from me -- it IS too complex for optimal human use, and I believe an ideal situation would see it used only for a small minority of the tasks in which it's so pervasive today, those for which it really _can_ be optimal (mostly, IMHO, for performance reasons). But as and when you use it, or discuss it, you really should base your usage, and your discussion, on a deeper and more complete understanding -- exactly because it IS so rich & complex, facilely branding specific features of it as "evil", without a full understanding of their role in the overall scheme of things, is a temptation a wise man would, I believe, carefully avoid. (But then, I'm not half as good in knowledge about what wise men do, than I am about how C++ is exactly defined and best used in various cases:-). Alex From ge at nowhere.none Fri Jul 28 11:47:26 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 15:47:26 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> Message-ID: In article , Steve Lamb wrote: >On Fri, 28 Jul 2000 09:14:31 GMT, Ben Wolfson >>If I type 1, I think "integer". Sorry. This is true outside >>the realm of programming. If I'm talking to someone online and >>I want to express the idea of a string containing the character >>'1', I will write "1" or '1'. > > Is it? How many non-programmers would do that? You do it only > because you are a programmer who is used to catagorizing data > into different types. Why does "what non-programmers do" matter when designing a programming language? -- Grant Edwards grante Yow! Of course, you at UNDERSTAND about the PLAIDS visi.com in the SPIN CYCLE -- From herzog at online.de Thu Jul 20 10:57:07 2000 From: herzog at online.de (Bernhard Herzog) Date: 20 Jul 2000 16:57:07 +0200 Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3975EF36.1651C9CB@roguewave.com> <8l52re$tbe$1@nntp9.atl.mindspring.net> <39763FF4.2CA5BF75@schneider-kamp.de> <8l59pa$6ff$1@slb1.atl.mindspring.net> <3976B4E9.B26F5FA@schneider-kamp.de> Message-ID: Peter Schneider-Kamp writes: > If there wasn't this cross product connotation problem I'd really > prefer the syntactic sugar: > > for x,y; y in [(1,2), (3,4)]; [5, 6] Could it be you meant for x; y in [(1,2), (3,4)]; [5, 6]: ? That's the version you used in your questionnaire. This may habe been proposed before, but how about || as in for x, y in sequence1 || sequence2: pass sequence1 || sequence2 would be equivalent to zip(sequence1, sequence2). I think || conveys the notion of parallel iteration nicely. The main disadvantage is that Python newbies coming from e.g. C or Perl will confuse it with the logical or operator at first. The zip() builtin has the advantage that you can influence its behavior with extra keyword arguments like pad. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From jepler.lnk at lnk.ispi.net Fri Jul 7 09:03:08 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Fri, 07 Jul 2000 13:03:08 GMT Subject: Comparing 2 class types References: Message-ID: On Fri, 07 Jul 2000 12:29:31 GMT, Arint? wrote: >How can you know if a 2 variables are different instances of the same class? >x = someclass() >y= someclass() >I tried is, type, and type(x) is someclass, but none seem to work unless I >did it wrong. > > isinstance() Jeff From andre at UltraShell.Net Mon Jul 31 17:44:47 2000 From: andre at UltraShell.Net (Andre van Straaten) Date: Mon, 31 Jul 2000 21:44:47 GMT Subject: check file exists References: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: Randy Heiland wrote: > How does one test for whether or not a (Unix) file exists? > thanks, > Randy I use generally something like this: # check if in_file exists if (0 == os.path.isfile(sys.argv[1]) or (0 == os.stat(sys.argv[1])[stat.ST_SIZE])): # if filesize = 0 print "no valid input file\n" else: -- avs Andre van Straaten http://www.vanstraatensoft.com ______________________________________________ flames please to /dev/null at vanstraatensoft.com From bjorn at roguewave.com Sat Jul 22 12:06:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 22 Jul 2000 10:06:31 -0600 Subject: iterating over lines in a file References: <3979BF4C.6C60E636@roguewave.com> <1hje5.11204$Z43.122073@news20.bellglobal.com> Message-ID: <3979C687.4BA9C0FF@roguewave.com> Olivier Dagenais wrote: > > Supposing it evaluates to 0 (false). Now, everything_is_ok is equal to > zero, so the next time you evaluate it... In this code sample, the same thing... but I see your point :-) -b > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Bjorn Pettersen" wrote in message > news:3979BF4C.6C60E636 at roguewave.com... > > Moshe Zadka wrote: > > > > > > On Fri, 21 Jul 2000, Gareth McCaughan wrote: > > > > > > > Moshe Zadka wrote: > > > > > > > > > Preventing world war III, when Python achieves world domination. > > > > > If C is allowed to achieve world domination, WWIII will be cause by > > > > > > > > > > if(everything_is_ok = 0) { > > > > > launch_missile(); > > > > > } > > > > > > > > No, that will *prevent* WW3 happening when it was supposed to. > > > > Where do I sign up for the campaign to help C dominate the > > > > world? :-) > > > > > > You probably need to reread the condition. > > > > Probably not... Since 0 (zero) is false, and the result of an assignment > > expression in the rhs, you would never execute the block... > > > > -b > > > > -- > http://www.python.org/mailman/listinfo/python-list From garry at sage.att.com Wed Jul 26 15:12:46 2000 From: garry at sage.att.com (Garry Hodgson) Date: Wed, 26 Jul 2000 19:12:46 GMT Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> Message-ID: <397F382E.196DE01@sage.att.com> "ye, wei" wrote: > Remco Gerlich wrote: > > "ye, wei" wrote: > > > 2. Why variable doesn't have to be declared before use? > > > > Because it's not necessary! > > I can bear the {} issue, however I couldn't bear with variable without > declaration. > I wrote many applications, I couldn't live without declaration. the short answer is: if this is really important to you, then you don't want to use python. alternately, you might give it a try and discover what many others have. it turns out not to be a problem in practice. the third option, insisting that python change to meet your presuppositions of what is important, is unlikely to be fruitful. > > Although there is work in progress on this issue - it may become optional > > in the future. If you make everything strict and using { } and so on you've > > just got some dialect of Objective C or Java or something... > > I will be very *HAPPY* if it's true!!!!! I believe Python will be much > stronger and grow faster > if such features are enabled. if memory serves, much of the impetus for this was that it would enable certain performance improvements, rather than for safety purposes. > However it should be a good language, ahem. > which can as more as possible > to correct the mistake people may make. This help programmers to > shorten development and testing time. many people's experience has shown the opposite to be true. > If don't specify the variable type: > 1. When you read code, it's not easy for you to understand how to invoke that > function. > For example, compare > def f(x, y, z): ... with def f(int x, complex b, Employ c): ... > which declaration give you more information without read further code? > You know how to invoke the latter one without read its code and comments in > most cases. either of these is poor code. how about having the names reflect usage, which is arguably more relevant than type? def ComputeSalary( employeeID, salary, employee ) (my salary is very complex :-) -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From paul at prescod.net Mon Jul 24 02:42:52 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 01:42:52 -0500 Subject: New PEP: Attribute Access Handlers References: Message-ID: <397BE56C.6CEA865@prescod.net> Christian Tanzer wrote: > > ... > > * A "get" proceeds as usual until just before `__getattr__' would be > could. At this point, the dictionary `__attr_getters__' would be > checked -- if it contains a get-function for the attribute in > question, that function is called, otherwise `__getattr__' is > called as usual. That's a good first pass but there are a lot of unresolved issues. For every "get" failure you do an extra dictionary lookup (even if the attribute doesn't have handlers). get failures are common in Python because people does hasattr(x,"y") alot. __getattr__ will also take longer to get to until today. You won't find a computed attribute until you've gone through the entire class hierarchy and come up with no value. Even a computed attribute directly in the instance's __dict__ won't get found until all class's have been exhausted. Also an extra dictionary allocation is a non-trivial cost. Plus, it isn't clear how this dictionary is set up in the first place. Is it per-class or per-instance? Do runtime assignments change it? Does it get bigger as the inheritance hierarchy gets deeper? > * A set proceeds by checking the `__attr_setters__' dictionary. > If it does not contain a set-function for the attribute in > question, everything proceeds as it does today. Otherwise that > function is called. Okay, so let's say I have a get function but no set function. Won't the very first "set" put a variable in the dictionary so that future "gets" will fail according to the algorithm you described? -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From paul at prescod.net Mon Jul 17 19:10:06 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 18:10:06 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> <396FABF3.B82E0C2@roguewave.com> Message-ID: <3973924E.DACD1D7F@prescod.net> Gareth McCaughan wrote: > > ... > > Only if you implement matrices as lists of lists, in which > case operations like * and / won't work anyway. I was assuming > that (1) you have a special Matrix class, and (2) the machinery > for list comprehensions is flexible enough to let it express > other kinds of mapping. Today, the list comprehension syntax is syntactic sugar for a=[] for i in firstloop: for j in secondloop: ... a.append( i, j ) I don't see any easy way to guess what type you want as "output" so it has to default to a fixed type. You could of course do this: Matrix( [...] ) I would be curious about ideas for allowing the output object to be specified or inferred. What would the protocol be? -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From amk at mira.erols.com Sun Jul 16 12:31:20 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 16 Jul 2000 16:31:20 GMT Subject: Anyone going to OLS? References: Message-ID: On Sat, 15 Jul 2000 21:10:40 GMT, Olivier Dagenais wrote: >Hey, I'm in Ottawa! Where's the OLS being held? You think it's a problem >if I never use Linux and I go to the OLS??? : ) See www.ottawalinuxsymposium.org; unfortunately I think all 500 places were sold out in June. A pity for you, since it's an impressively technical conference -- no vendors, no sales people, just techies. Some talks are Linux-specific, but others are of general interest to any Unix programmer -- talks on GNOME, DocBook, writing network daemons, etc. --amk From nowonder at nowonder.de Mon Jul 31 11:09:16 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 15:09:16 +0000 Subject: [4th Draft] Open Letter to CNRI: Request for clarification Message-ID: <3985969C.48222D21@nowonder.de> Good point from Martijn, so here is the 4th draft: --- begin open letter ------------------------------------------------- To: Dr. Robert E. Kahn , (president of The Corporation for National Research Initiatives) Dear Mr. Kahn, a lot of people in the Python community around the newsgroup comp.lang.python are deeply concerned about the latest license issues that have arisen around the new 1.6/2.0 releases. The following attached signatures represent people from the Python community who would like some clarification regarding the future of the Python language. As of now, there has been no official statement from your institution regarding the new Python license. We are especially interested in the underlying intention of this change. So we request a plain-English, non-legalese statement regarding the purpose of that change and the ways in which it affects Python's use. Kind regards, Peter Schneider-Kamp --- end open letter ---------------------------------------------------- --- begin signature list ----------------------------------------------- Martijn Faassen Jay Graves Konrad Hinsen (Centre de Biophysique Moleculaire (CNRS)) Gareth McCaughan David Mertz (author of a Python column for IBM developerworks) Moshe Zadka (mathematician, Python developer) --- end signature list ------------------------------------------------- Please add/change/remove your signatures. Feedback as always strongly appreciated. or-should-I-send-the-1st-draft--ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From shindich at my-deja.com Fri Jul 7 22:51:43 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Sat, 08 Jul 2000 02:51:43 GMT Subject: eval References: Message-ID: <8k64vt$jbs$1@nnrp1.deja.com> In article , Johannes Zellner wrote: > On Thu, 6 Jul 2000, Stuart Ford wrote: > > > > > ----- Original Message ----- > > From: Johannes Zellner > > To: > > Sent: Thursday, July 06, 2000 5:46 PM > > Subject: eval > > > > > > > > > > Hi, > > > > > > how does eval work ? > > > > > > eval('print "fred"') > > > > > > > exec not a function in the real sense, but a core command, > > it does not require the use of parentheses. > > > > Examples: > > > > eval 'print "fred"' will work.. > > > > or > > > > command = 'print "fred"' > > exec command will work just as well.. > > > > I have used exec to process dynamically written code within the > > current namespace. > > ahh. I see. thanks. > > And how do I define the scope where exec evaluates ? > E.g. > > def generator(x): > eval 'def '+x+'(y): print "fred"' > > and after calling > >>> generator('lola') > I want to be able to use > >>> lola('lolita') > > -- > Johannes > You might want to try the following: >>> def generator (functionName, globaldict): ... exec 'def ' + functionName + '(): print "fred"' in globaldict >>> generator ('lola', vars ()) >>> lola >>> lola () fred >>> I hope this helps! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sun Jul 23 02:34:19 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:34:19 -0500 Subject: Multimethods References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <8lcnf4$vmr$1@slb0.atl.mindspring.net> Message-ID: <397A91EB.80B74AE9@prescod.net> Neel Krishnaswami wrote: > > .... > > So multimethods. In ordinary OO programming, you can think of a method > as a set of functions, and the function body that's chosen is based on > the runtime type of the first argument. You could, but Python exposes so much of the underlying implementation that this is not a very intuitive way to think about it. In particular, every instance of a class could have a *unique method* frob simply by assigning to the frob attribute. So you have to think of the function body being selected not based on runtime type but rather on the particular runtime instance's identity (e.g. "id()"). So it isn't clear to me how you extend this into multimethods. If Python dispatch is not type-based to start with making a mechanism that is doubly type-based seems inconsistent. I mean the first step would be to make a form of Python method invocation that is type-based even for one argument. def foo( int a ): .... def foo( float b): ... -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From scarblac-spamtrap at pino.selwerd.nl Thu Jul 20 03:56:02 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 20 Jul 2000 07:56:02 GMT Subject: Get the name of the superlcass? References: <39779f54.3806062@news.online.no> Message-ID: Thomas Weholt wrote in comp.lang.python: > I`m subclassing from a superclass. I can get the name of the subclass > by using Subclass.__class__.name. But I would like to get the name of > the superclass as well, but not lose the option of getting the > subclass either. > > Ex. I got a class Structure, and a sublcass Building. I want to check > in a list for structures, then see if any of them are buildings. Use isinstance(). isinstance(object, class) is 1 if the object is an instance of the class or one of its subclasses. class Structure: pass class Building(Structure): pass generic_structue = Structure() some_building = Building() Now isinstance(some_building, Structure) == 1 isinstance(some_building, Building) == 1 isinstance(generic_structure, Structure) == 1 isinstance(generic_structure, Building) == 0 If you want to know the superclasses of a class, use class.__bases__ (like Building.__bases__[0].__name__ == "Structure"). But using isinstance is probably better. -- Remco Gerlich, scarblac at pino.selwerd.nl 9:54am up 135 days, 22:03, 6 users, load average: 0.40, 0.19, 0.12 From scarblac-spamtrap at pino.selwerd.nl Tue Jul 25 10:25:09 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 25 Jul 2000 14:25:09 GMT Subject: how to build arbitrarily-sized lists in one fell swoop? References: <397DA1E0.B65DC47@cornell.edu> Message-ID: Samuel Scarano wrote in comp.lang.python: > There's a simple thing I want to do in python but I can't find a way that is > obvious to the reader and efficient for the interpreter. I want to make a > list with n copies of x. > > This is the way that's most obvious to me: > > l = [] > for i in range(n): > l.append(x) > > But that looks awfully verbose for Python, and I'm sure there's a more > efficient way. > > Then there's: > > l = map(lambda y: x, range(n)) > > That's briefer, but it still involves a lot of function calls, and the > wasteful construction of a range. > > So what's the right way? l = [x]*n Does what you do here. I don't know what kind of object x is, but note that this doesn't make *copies* of x; if it's some instance, then all elements of l will be a reference to the same old x. Same for your methods. -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From gmcm at hypernet.com Mon Jul 3 10:42:32 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 14:42:32 GMT Subject: Again: ODBC / Win98 -> crash References: <8jq7i6$395g$1@www.univie.ac.at> Message-ID: <8F666B563gmcmhypernetcom@199.171.54.154> Matthias Huening wrote: >Some days ago I posted a problem with ODBC on my Win98-machine. I >thought that it could be the win32-ODBC module that caused the crash I >reported, so I switched to Marc-Andre Lemburg's mxODBC module. To keep >it simple I give a minimal example (where dsn is a valid dsn): > >>>> import ODBC.Windows >>>> db = ODBC.Windows.Connect(dsn) >>>> db.close() > >Up to here, everything is fine. No problems so far. >But when I do it again: > >>>> db = ODBC.Windows.Connect(dsn) > >I get an immediate crash of Python. > >My (German) version of Win98 tells me: > > PYTHONW verursachte einen Fehler durch eine ung?ltige Seite > in Modul ODBCJT32.DLL bei 015f:04c0ac36. > >It seems like something isn't closed properly when I do db.close(). >Any suggestions? All this points to it being the driver. That is, your dsn gets looked up, and the driver for the appropriate DB is loaded. Since that's the JET driver (ie, the one that translates ODBC to JET), you can thank your lucky stars that it works at all . Access behaves very poorly through ODBC. If you really have to use Access, you might find ADO more satisfactory. - Gordon From genablu at my-deja.com Fri Jul 14 04:40:13 2000 From: genablu at my-deja.com (genablu at my-deja.com) Date: Fri, 14 Jul 2000 08:40:13 GMT Subject: Python + Apache 1.3.x (CGI) not working (no mod_python) Message-ID: <8kmjlb$vji$1@nnrp1.deja.com> Please help! I am running the following Python program: #!/usr/bin/python print 'Content-type: text/plain' print ' ' print '' print 'cgi-bin test' print 'Hello, World!' in my /home/httpd/cgi-bin directory. Permissions are set to 755, chown root.nobody. When I try requesting http://myserver.domain.com/cgi-bin/hello.py I get the following error: INTERNAL SERVER ERROR The server encountered an internal error or misconfiguration and was unable to complete your request. malformed header from script. Bad header=:/home/httpd/cgi-bin/hello.py The equivalent PERL program works just fine. Here are the modules built into my Apache server: httpd -l Compiled in modules: http_core.c mod_so.c What am I missing? Why doesn't this work but the PERL program does? I would like to run this script by spawning the Python interpreter rather then compiling it as a module. Is this possible? I'm aware this might be an Apache question; can you point me to a good place to learn how to solve this in Apache? I've been fighting this for a loooong time! Can someone please help? Thanks! Gena Bleu Sent via Deja.com http://www.deja.com/ Before you buy. From ldwhitley at home.com Tue Jul 4 15:41:30 2000 From: ldwhitley at home.com (Larry Whitley) Date: Tue, 04 Jul 2000 19:41:30 GMT Subject: Python to C++ in a pickle Message-ID: I'd like to pickle an object in python and unpickle it in C++. The object in question is a python dictionary so it will have to go into a C++ map. Has someone done this and is willing to share? Or, is the cPickle source available on the web somewhere? Larry From paul at prescod.net Sat Jul 22 12:38:26 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 22 Jul 2000 11:38:26 -0500 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F7974AF5gmcmhypernetcom@199.171.54.194> Message-ID: <3979CE02.D2744B7E@prescod.net> Gordon McMillan wrote: > > >What surprises me, though, is that no one ever > >mentions the possibility of writing > > inp = __builtin__.open("c:/autoexec.bat",'r') > > Because __builtin__ is a module and has to be imported. And someone who > says Well yes, but not __builtins__ (with the "s") Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> __builtins__ -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From tim.hochberg at ieee.org Tue Jul 4 21:47:49 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 05 Jul 2000 01:47:49 GMT Subject: regex's References: <39627fa7.705005544@news1.on.sympatico.ca> Message-ID: chibaA at TinterlogD.Tcom writes: > Hi... I'm having a bit of a brain-tease... I have the following code > (example): > > import re > > str = '123' > if re.compile('1').match(str): > print "matched 1" > if re.compile('2').match(str): > print "matched 2" > if re.compile('3').match(str): > print "matched 3" > > ------------------- > > I would think that this code would print 'matched 1 matched 2 matched > 3'... But in this case, it would only printed "matched 1". Any > reasons? Is there any way to have it print all three (since the > conditions seem to be true)? re.match matches from the beginning of the string (e.g., re.compile('2').match(str) will only match strings starting with '2'. What you want is re.search. For example: #.... if re.compile('2').search(str): # ... You could also use: #.... if re.search('2', str): # ... However, the former will be faster if you reuse the regular expression since you can compile it once and reuse the compiled version. -tim > Thanks in advance! > > kc. From alex at magenta.com Sat Jul 29 20:37:50 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 02:37:50 +0200 Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: <8lvth11ntg@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o6lp3.f91.grey at teleute.rpglink.com... > On Sat, 29 Jul 2000 14:16:47 GMT, Steffen Ries > wrote: > >In this case I would use the dictionary variant of the format string: > >"%(a)0d %(b)c:U %(c)s %(d)s %(e)s %(f)s %(g)s %(h)s %(i)s %(j)s %(k)s"\ > > % vars() > ^^^^^^ > > Still doesn't change the fact the variables are at the end. The variable *names* are in the format-string (named placeholders). What variable goes where, which was your original issue, is thus completely solved. That the whole format-string gets applied to vars() just tells us we're in that particular case (frequent in some people's styles, less so in others). Alex From jclonts at mastnet.net Tue Jul 18 23:10:18 2000 From: jclonts at mastnet.net (John Clonts) Date: Tue, 18 Jul 2000 22:10:18 -0500 Subject: PyPGP? Message-ID: <39751C1A.5F476774@mastnet.net> I am trying to get this to work and am having trouble.... Is this a current effort? Is there some other or better source for PGP encrypt/decrypt services for Python? Thanks, John From moshez at math.huji.ac.il Sat Jul 1 07:13:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 14:13:03 +0300 (IDT) Subject: Passing variable-length keyworded arguments list to base class constructor? In-Reply-To: <962379165.85859735@news.libertysurf.fr> Message-ID: On Fri, 30 Jun 2000, Jerome Quelin wrote: > "Beat Bolli" wrote: > >Starting with Python 1.6a[12], you can call Parent.__init__(self, **args). > And with python 1.5.2? Use the apply() built-in function. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From stianh at ifi.uio.no Thu Jul 27 18:10:18 2000 From: stianh at ifi.uio.no (Stian Husemoen) Date: 27 Jul 2000 22:10:18 GMT Subject: The State of Python References: Message-ID: Tim Peters wrote: >credible answer on that one. Note that contributions to Python generally >weren't accepted if they contained a license more restrictive than the >Python license; for example, there is no GPL'ed code in the Python >distribution. Note also that, late in the game, CNRI required a release >form with all Python contributions, specifically granting CNRI certain broad >rights to your code. If Python had the GPL-license we would never have gotten into this mess. My main argument for *not* using Python at first was that it didn't have the GPL attached to it... Yes, the GPL is more restricive but you can't have both ways. There will always be a danger of this happening again until someone make a GNU version of Python. (btw. would this be possible?) -- Stian Husemoen From cjensen at bioeng.ucsd.edu Wed Jul 26 17:23:24 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 26 Jul 2000 14:23:24 -0700 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> Message-ID: <397F56CC.55C036EF@bioeng.ucsd.edu> > I'm still curious as to why sys.stdout.write is so bad. > > -- > -William "Billy" Tanksley What is the difference between "print" and "sys.stdout.write"? Other than the obvious new line character. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From moron at Glue.umd.edu Thu Jul 20 23:08:09 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 20 Jul 2000 23:08:09 -0400 Subject: Does Python have "not a number" floating point values? References: <3bRVEQ$l1k@openbazaar.net> Message-ID: <8l8eqp$4sj@stochastic.eng.umd.edu> Huaiyu Zhu: >According to discussions on comp.lang.python, there is no universal >way to treat NaN, but the following codes work on Windows (NT and 98), >Solaris (2.7 with gcc) and Linux (RH6.1 with egcs). There is an fpectl module in the standard distribution. It's not built by default, and doesn't support all systems, and all it does at the moment is make this stuff NOT work on the systems it supports, but interested parties might be able to fix [some of] these issues. Warren Focke -- If you feel that you have both feet planted on level ground, then the university has failed you. -Robert Goheen, President, Princeton University From cjensen at bioeng.ucsd.edu Tue Jul 25 20:47:44 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 25 Jul 2000 17:47:44 -0700 Subject: print format Message-ID: <397E3530.E821018C@bioeng.ucsd.edu> I don't know if this is possible in python but, Is there a way to repeat a format command a spceified number of times? For example, in Fortran there is the format code "20I5" Which is the same as "I5" twenty times. I want something like: print '20(%i5) ' % [list of 20 intgers] Also, how do I print without a new line other than using sys.stdout.write? Thanks -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From bjorn at roguewave.com Sat Jul 22 00:54:13 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 21 Jul 2000 22:54:13 -0600 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <8lb71j$gkm$1@slb7.atl.mindspring.net> Message-ID: <397928F5.76734DC6@roguewave.com> Aahz Maruch wrote: > > In article , > Huaiyu Zhu wrote: > > > >number .+ matrix > > > >illigal, which can be done by leaving __rdotadd__ undefined. > > No, no, no. No runtime errors based on syntactical ambiguity. Remember > that the above example is not the ambiguous one, it's "number.+matrix" > with no spaces. It just doesn't work, and I guarantee you'll get a > virulent reaction from long-term Pythonistas if you push this at all. I'm sure someone will implement __rdotadd__ for their class sooner or later and then the following lines would have different semantics: 5.+A 5 .+ A I'm sure we're all going to love answering _those_ whitespace posts... at-least-Dylan-has-a-reason-for-being-whitespace-sensitive-in-this-area'ly y'rs -- bjorn From tim.hochberg at ieee.org Wed Jul 19 20:58:06 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 20 Jul 2000 00:58:06 GMT Subject: Discussion: new operators for numerical computation References: Message-ID: Huaiyu Zhu writes: > Now that Guido has given the go-ahead for adding new operators for numerical > computation, let us consider carefully how to allocate this new resource, > taken into account Tim's guidelines. > > Here's a list of issues that come to mind: > > 1. What symbols to use. > > It seems that we can more or less concentrate on using either . or @ > together with existing math operators. Issues: > > (1) Use . or @ Not '@'. It's too dense and looks to much like a letter. '.' is better, but is has the potential to cause confusion in situations such as 3.+M. This equation is ambiguous if the ".x" operators are elementwise, but not if they're matrixwise (I'm assuming that the elementwise operators obey the same broadcasting rules that NumPy's operators do today). > (2) Which is matrixwise or elementwise I can't see a good answer here. NumPy has been around for a long time and I believe it has a fairly large user base which is a strong argument in favor of the ".x" operators being matrixwise. However, other operators within python (*,+) operate "objectwise" on sequences (concatenation and replication). I think it would be suprising if these operators were elementwise for matrices and objectwise for other, similar, objects (sequences). This tends to favor ".x" being elementwise. > (3) Compatibility: NumPy uses * for elementwise, MatPy uses * for > matrixwise. Do you have an idea of what the relative sizes of the userbases of these two packages are? Honest question -- I have no idea, but I've been operating under the assumption that userbase of MatPy was relatively small. > (4) Similarity with Matlab (but not really compatibility). I think it's a mistake to look just at Matlab here. If were going to look to matrix languages for inspriation we should look to several. Unfortunately, I'm no help here. > 3. Their behavior on other objects: > > Even though they are supposed to be used for numerical objects only, what > if user writes [10,20].+[1,2]? > > - Exception: no __dotadd__ or __rdotadd__ defined > > - Behave as eadd and give [11,22] > > - Behave as current + and give [10,20,1,2] > > The last one is dead, people writing [].+[] either made a typo of > [].member+[] or want eadd. > > The second seems most sensible and least surprising, but it does need to > include list in the implementation of eadd. > > My understanding is that Tim wants the first one. So let's leave it > there lest it drags other bits down. Note that if ".x" ends up being matrixwise, things will become horribly inconsistent if it is later decided to extend these operators to other sequences. This IMO is probably the strongest argument for making ".x" elementwise. > > > 4. The magic words: > > This really depends on issue 3 above. > > - If it is intended that these thing should never acquire a meaning > outside numerical computation, they should be called __mmul__, > __emul__, etc, because that would describe the intension well. > > - If other classes, like UserList, are allowed to use them, it's better > to use __dotmul__, __atmul__, etc, so the association with the symbols > are strong. > > - Someone mentioned __altmul__ for @*, meaning alternative mul. Not ready to dive in here till some other stuff is resolved. > > 5. Other bits and pieces: > > - How to deal with left division? > > (1) Use sol(a,b) > (2) use /@ or /. > (3) use % '%' is already a valid elementwise operator and to have "%" and ".%" mean completely different things is not good, so (3) is out. I think (2) only makes sense if the ".x" operators are matrixwise. It seems just too weird to have "/" be right division "/." be left division and "./" be elementwise. It's much more sensible to have "/" be elementwise, "/." be left division, and "./" be right division for instance. If possible I would like to avoid (1). 'sol' would almost certainly be in the a seperate module and this is potentially painful. > - How to deal with power? It is already two characters > > (1) Use ** and .** or @** > (2) Steal ^ with .^ or @^ (not much chance, just mentioning here) It's gotta be (1). Unless a limited set of operations is considered (see below), then _maybe_ ".^". > - Do we want a copy operator := which is different from =? It allows > efficient code. The following code does not change A > B := A > B += C > This definitely will be usable for other classes. Call it __copy__? This seems to be a general request and not particularly numeric specific. And I don't think it adds much in the way of functionality. I would drop this. > - Since augmented assignment almost certainly will get in the core, we > need to consider combining them. A few possible opinions > > (1) Just use prefix . or @ to mean e or m, use suffix = to mean in > place assignment, and all are well defined. > > (2) a .**= 3 looks too long. Don't combine them. > > (3) allow .+=, etc but ban .**=. Here I'd go with (1), consistency over beauty. After rereading my answers to the above, I'm going to have to come down on the side of ".x" being matrixwise, despite the clash with sequence concatenation and replication. It removes the ambiguity of the grammer, it makes more sense with "./" and "/." and it's consistent with NumPy. I'm not yet convinced as yet that all of these operators are needed; the +, - and .+, .- operators are very similar in behaviour. The main reason they are present seems to be orthogonality. I'm sure this has been brought up before, but does MatLab have both broadcasting and non broadcasting versions of its operators? Is it worth considering adding only the matrix operators .*, ./, /., and(?) .** and letting NumPy/ MatPy choose whether they wish to broadcast or not? It seems that the difference between .* and * is different in character than the proposed difference between .+ and +; in one it's between elementwise and matrixwise operations, and in the second it's between broadcasting and nonbroadcasting operations. Yes, you can think of the second in terms of the first, but it still feels a bit forced to me. Based on my ramblings I'll toss out a proposed operator set for the pack to feed upon: Operator Name .* matmul ./ matdiv /. matsol .** or(?) .^ matpow * mul / div %,^,&,|,** mod, xor, and, or, pow With broadcasting / nonbroadcasting decided by the individual packages. My 3 cents. -tim From sblakey at freei.com Mon Jul 17 20:19:12 2000 From: sblakey at freei.com (Sean Blakey) Date: Mon, 17 Jul 2000 17:19:12 -0700 Subject: event handler advice In-Reply-To: <8l033n$pr2$1@la-mail4.digilink.net>; from pete@visionart.com on Mon, Jul 17, 2000 at 03:49:02PM -0700 References: <8l033n$pr2$1@la-mail4.digilink.net> Message-ID: <20000717171912.A25518@freei.com> On Mon, Jul 17, 2000 at 03:49:02PM -0700, Pete Shinners wrote: > i'm trying to write a simple event handler python class. > so far i haven't come up with an 'elegant' solution i was > expecting. > <> > > my guess is i need some dictionary that defines the > messages and their routine name (no shortcut way to do > this unless python had #define like macros :]) > > messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} > > then a routine like > > class basehandler: > def handle(messageid): > name = messages[messageid] > self.name() #HAHA, no really, how do i do this? > > but i'm not exactly sure how to write this. need help, thx > > > Probably he simplest solution is along the lines of: class basehandler: def handle(messageid): name = messages[messageid] bound_method = getattr(self, name) bound_method() Personally, I would be more comfortable with: class basehandler: def handle(messageid): try: name = messages[messageid] bound_method = getattr(self, name) except KeyError: if __debug__: print 'Invalid message sent', messageid # or other error handling (syslog?) except AttributeError: if __debug__: print 'Unhandled message received', name # other misc error handling else: bound_method() This approach allows trapping of "illegitimate" messages (or messages you haven't gotten around to implementing yet) without the nastiness of an unhandles exception. -Sean -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 "It ain't so much the things we don't know that get us in trouble. It's the things we know that ain't so." -- Artemus Ward aka Charles Farrar Brown From thomas at xs4all.net Sun Jul 16 05:23:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 16 Jul 2000 11:23:48 +0200 Subject: Neil Schemenauer's GC patch in python1.6? In-Reply-To: <0k1sOJAQmQc5Ew5z@jessikat.fsnet.co.uk>; from robin@jessikat.fsnet.co.uk on Sun, Jul 16, 2000 at 02:02:08AM +0100 References: <396F28A1.A181BF39@email.sps.mot.com> <3dn1jkljwy.fsf@kronos.cnri.reston.va.us> <20000716012003.L7340@xs4all.nl> <0k1sOJAQmQc5Ew5z@jessikat.fsnet.co.uk> Message-ID: <20000716112348.O7340@xs4all.nl> On Sun, Jul 16, 2000 at 02:02:08AM +0100, Robin Becker wrote: > In article <20000716012003.L7340 at xs4all.nl>, Thomas Wouters > writes > >On Sat, Jul 15, 2000 at 06:30:19PM +0100, Robin Becker wrote: > >[ amk explains cycle-GC will be in 2.0, though possibly optionally ] > >> If GC has finally/nearly made it, what about Chris Tismer's stackless? > > > >A different story altogether. I'm sure Christian can give a better > >explanation that I can, but I believe the main showstopper is the fact it's > >impossible to implement (currently) in JPython, not to mention future Python > >compilers. There may be a lot more behind it, though. > bit strange that features/defects in java should determine where python > goes. I would certainly like generator style programming to be easier. Not really. Unlike Perl, Python is more than its implementation. JPython is a popular implementation on its own, and shouldn't be treated like some backward kid ;-) I'm fairly certain this isn't the only problem though: stackless code is pretty complex, incorporating it means a lot changes in Python's innards, it means all developers that hack there have to adjust to it. It also means totally new ways of programming, which may be contra to what Guido wants with Python. And don't forget that Stackless still has no 'killer app'; there isn't a package that requires stackless that has everyone going 'add stackless!' These arguments are pretty old, though, so I'm not sure if they still hold. Probably not, in fact ;-) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rumjuggler at cryptarchy.org Sat Jul 8 23:31:09 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 09 Jul 2000 03:31:09 GMT Subject: win32pipe question Message-ID: I don't know if this is the way pipes work or not, in which case this might be a general pipe question, but I'm using the win32pipe module, so. When I use popen2 to get input to and output from a process, I find that if I try to read from the the out pipe before the process has completely finished, the program hangs, but if I keep writing until I'm done and the process exits, then read, it's fine. Is there a way to read and write as the process runs, instead of doing one, then the other? I'm on win98, btw. -- Barnabas T. Rumjuggler That happens to me often: I'll find an old coffee on the bookshelf or a banana on the mantelpeice or myself halfway up the ladder to the attic and not know how the old coffee, the banana, or I arrived at those places. -- Russell Hoban, _The Medusa Frequency_ From mcknight at email.unc.edu Fri Jul 21 09:10:33 2000 From: mcknight at email.unc.edu (Sean McKnight) Date: Fri, 21 Jul 2000 09:10:33 -0400 Subject: setup.py and NumPy Message-ID: <39784BC9.FBD411FF@email.unc.edu> Hello, I am new to Python and would like some help with the "setup.py" script and NumPy. I have run the "setup.py" script and I get the following result: % python setup.py build running build running build_py not copying Lib/ArrayPrinter.py (output up-to-date) not copying Lib/FFT.py (output up-to-date) not copying Lib/LinearAlgebra.py (output up-to-date) not copying Lib/MLab.py (output up-to-date) not copying Lib/Matrix.py (output up-to-date) not copying Lib/MA.py (output up-to-date) not copying Lib/Numeric.py (output up-to-date) not copying Lib/Precision.py (output up-to-date) not copying Lib/RandomArray.py (output up-to-date) not copying Lib/UserArray.py (output up-to-date) running build_ext building '_numpy' extension gcc -c -IInclude -I/usr/local/include/python1.6 -g -O2 Src/_numpymodule.c -o build/temp.sunos5-sun4u/Src/_numpymodule.o Src/_numpymodule.c:1: Python.h: No such file or directory error: command 'gcc' failed with exit status 1 The problem is that the search path for the "Python.h" include file is incorrect. I have installed python in another location since I do not have write access to "/usr/local". I have looked at the disutils documentation but have been unable to determine what needs to be done in order to change the include path from the standard location of "/usr/local/include/python1.6" to a non-standard location. I have the python binary in my path and have set the PYTHONHOME env. variable but this does not seem to have any effect. Thanks! Sean -------------------------------------------------------------------------------- Sean McKnight Department of Geography University of North Carolina at Chapel Hill Campus Box 3220 203 Saunders Hall Chapel Hill, NC 27599-3220 Phone: (919) 962-3870 Email: mcknight at email.unc.edu -------------------------------------------------------------------------------- From root at rainerdeyke.com Sat Jul 8 00:36:25 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 08 Jul 2000 04:36:25 GMT Subject: Palm Python? References: <8h8jmc$t9i$1@gaia.cdg.acriter.nl> <14649.14534.184930.984180@malibu.aero.org> <3939FFB4.A7824367@mindspring.com> Message-ID: "Blake Winton" wrote in message news:slrn8md52n.gb2.bwinton at tor.dhs.org... > "Why can't I name two functions the same when they're in different > files, and I only use them in their respective files?" Too used to > OO, I guess. You can; just declare them as static. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From dcalvelo at pharion.univ-lille2.fr Tue Jul 18 13:33:53 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 18 Jul 2000 17:33:53 GMT Subject: Line numbers outside exceptions References: <396F524B.33D636A2@home.com> Message-ID: <8l24e1$d2g$1@netserv.univ-lille1.fr> Ivan Van Laningham wrote: : Hi All-- Hola. : Is there a standard way, not too horrific, to retrieve the current line : number in a script at run-time outside of an exception context? "Not too horrific" I would say no. You have "somewhat hacky" ways of retrieving the line number from the bytecode of function spam: Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> def spam(n="eggs"): ... print n ... return n ... >>> spam.func_code.co_code '\177\001\000\177\002\000|\000\000GH\177\003\000|\000\000Sd\000\000S' In that last string, the two bytes (this may be platform-specific) after a '\177' are line numbers. See 'dis'. "At run-time"? You mean for the current line being executed? Really really dunno... : Metta, : Ivan HTH Daniel. -- Daniel Calvelo Aros calvelo at lifl.fr From paul at prescod.net Tue Jul 18 22:51:50 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 21:51:50 -0500 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <397517C6.93911CF0@prescod.net> Robin Becker wrote: > > I suppose there must be something desperately wrong with using the > __mul__ for sequences to indicate the set pairwise product. I would > certainly be for > > x,y in A*B rather than x,y in zip(A,B) or marry(A,B), but since * is the > obvious operator it must be that someone else has reserved it. We aren't looking for the set pairwise product (which I am taking as a synonym for cross-product). We're looking just to pair up elements. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From moron at Glue.umd.edu Fri Jul 21 02:08:11 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 21 Jul 2000 02:08:11 -0400 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397684EB.3E0C5D88@my.signature> <8l68s5$3ht$1@nnrp1.deja.com> <3977C173.B93EB70B@my.signature> Message-ID: <8l8pcb$5l7@stochastic.eng.umd.edu> quoth Greg Ewing: >Matthias wrote: >> >> for x,y,z in a&b&c: > >But a&b&c parses as (a&b)&c, which is not what >we want at all! I was going to bring that up, but remembered comparisons: a < b < c is not the same as (a < b) < c. Warren Focke -- I am Dyslexic of Borg. Prepare to have your ass laminated. From tsmets at altern.org Mon Jul 24 19:54:48 2000 From: tsmets at altern.org (Thomas SMETS) Date: Mon, 24 Jul 2000 23:54:48 GMT Subject: inserting integer in Table Message-ID: <397CEEA4.7683A17@altern.org> In PostgreSQL table is : test=> \d test_blob_s; Table = test_blob_s +----------------------------------+----------------------------------+-------+ | Field | Type | Length| +----------------------------------+----------------------------------+-------+ | filenumber | int4 | 4 | | filename | varchar() | 100 | | filecontent | oid | 4 | +----------------------------------+----------------------------------+-------+ test=> Now I'm willing to insert in that table rows like this one : , , . Here's is the (not-so-running) code : # # # ############################################ import os, glob from pg import DB conn=DB('test') conn.query("BEGIN WORK;") i = 0 for name in glob.glob("*.jpg"): print "Name is ", name, try: conn.query("insert into test_blob_s filenumber values (" + i + ")") print " inserted" except TypeError,e: print '\nerror ', e, 'undefined' # conn.query( "update test_blob_s set filename = '" + name + "')") # conn.query( "update test_blob_s set filecontent = '" + lo_import(name) + "')") i = i + 1 conn.query(" COMMIT WORK;"); of course I can't have it passing the insert of "i" Could some one help ? Thomas, -- Thomas SMETS Phone : +32 (0)2 742. 05. 94. Av. de la Braban?onne 133 / 3 e-mail : tsmets @altern.org 1030 Bruxelles ==== Quote of the day ========= You shouldn't wallow in self-pity. But it's OK to put your feet in it and swish them around a little. -- Guindon ======= End of Quote ========= From smoriano at sicon.net Tue Jul 25 07:19:45 2000 From: smoriano at sicon.net (sergio) Date: Tue, 25 Jul 2000 13:19:45 +0200 Subject: SIMPLE QUESTION Message-ID: <397D77D1.A331770A@sicon.net> Hi all I''ve imported a dll into a .py file, but when i try to use a function i get the error Traceback (innermost last): File "", line 0, in ? TypeError: unbound method must be called with class instance 1st argument The question is , how can i get the "class instance", or maybe i have to pass a string with the name of the class on the first argument. Thanks in advance for all your responses From effbot at pythonware.com Tue Jul 25 09:23:43 2000 From: effbot at pythonware.com (effbot at pythonware.com) Date: Tue, 25 Jul 2000 13:23:43 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> <8lk1ee$71q$1@slb6.atl.mindspring.net> <8lk2kg$kbv$1@nntp9.atl.mindspring.net> Message-ID: <8lk4cp$i9c$1@nnrp1.deja.com> Aahz Maruch wrote: > Yes, I know about the soap opera. The fact remains that 1.6 > will almost certainly never be a released chunk of code -- it > never had a beta! looks like you've missed the last episode. according to plans, 1.6 beta 1 will be released in about a week. for more info, see PEP-160: http://python.sourceforge.net/peps/ Sent via Deja.com http://www.deja.com/ Before you buy. From rupole at compaq.net Sun Jul 9 09:48:48 2000 From: rupole at compaq.net (Roger Upole) Date: Sun, 09 Jul 2000 13:48:48 GMT Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> Message-ID: <4p%95.10247$A06.1298430@pouncer.easynews.com> It should speed up your COM calls. Also, you can browse thru the generated file and see all the properties and methods of the COM object. Once the object has been created, the constants will be available as win32com.client.constants.someconstantname. There is a Readme.html in the /win32com directory, and more documentation in /win32com/HTML/QuickStartClientCom.html. HTH Roger Upole "News.tele2.co.uk" wrote in message news:8k9o91$7b1$1 at supernews.com... > Well I've run it and it seemed to work but I'm not really sure what to do > next. > > In fact, I'm not entirely sure what it's supposed to do for me but I'm > hoping it will at least give me access to some COM object constants. > > Where is it documented? > > Thanks > > Dale Strickland-Clark > > > > From darrell at dorb.com Sat Jul 1 21:05:15 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 18:05:15 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <033e01bfe3c1$959868d0$6401a8c0@home> From: "Mark Hammond" > Just to stoke the flames a little... > > Check out some of the talks at the upcoming PDC - > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python Hey! Is this something you've been working on? So all these vendors are on board with integration into this new framework? I want to know the rest of the story now. --Darrell Gallion From jvickroy at sec.noaa.gov Fri Jul 21 09:54:22 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Fri, 21 Jul 2000 07:54:22 -0600 Subject: process id from os.system References: <3977482B.478D2754@sec.noaa.gov> Message-ID: <3978560E.DFBC1522@sec.noaa.gov> Thanks very much for calling this to my attention. Michael Hudson wrote: > j vickroy writes: > > > How can I obtain the process id for a program launched via > > > > os.system (theProgram) ? > > > > I would like to do this portability (Unix, Windows). > > > > Presently on Unix, I'm getting the pid by parsing the output from: > > > > "ps -ef | grep theProgram" > > > > but that seems messy and unreliable since "theProgram" may be truncated > > in the output from ps. > > I think you should be able to use the os.spawn* functions in > 1.6^H^H^H2.0 for this, eg: > > >>> os.spawnlp(os.P_NOWAIT,"xterm","xterm") > 4722 > > the spawn* functions are easy-ish to implement in terms of exec* & > fork; look here: > > http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/Lib/os.py?rev=1.35&content-type=text/x-cvsweb-markup&cvsroot=python > > HTH, > Michael > > -- > 8. A programming language is low level when its programs require > attention to the irrelevant. > -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivanlan at home.com Fri Jul 14 13:47:55 2000 From: ivanlan at home.com (Ivan Van Laningham) Date: Fri, 14 Jul 2000 11:47:55 -0600 Subject: Line numbers outside exceptions Message-ID: <396F524B.33D636A2@home.com> Hi All-- Is there a standard way, not too horrific, to retrieve the current line number in a script at run-time outside of an exception context? Metta, Ivan ---------------------------------------------- Ivan Van Laningham Axent Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From richard_chamberlain at ntlworld.com Mon Jul 10 07:38:34 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Mon, 10 Jul 2000 12:38:34 +0100 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: Hi, There isn't one that I know of, however there are a few nice examples in tcl which you could convert. Try looking at the links from dev.ajubasolutions.com. Richard Fanny Yeung wrote in message news:07ga5.11385$BS1.314666 at brie.direct.ca... > Hi everybody, > > I am reading "Python and Tkinter Programming" and I am thinking of writing a > simple database application that need to show table of data ( something > similar to grid control in VB or Jtable in Swing). I guess I can use Canvas > to implement that but I wonder anyone have implement this already ? If yes, > can I use it ? Or is there by any chance provided by Tkinter directly or > indirectly ? > > Thanks > > Mak > > From skeltobc at mailandnews.com Tue Jul 11 08:24:48 2000 From: skeltobc at mailandnews.com (Ben) Date: Tue, 11 Jul 2000 14:24:48 +0200 Subject: a show stopper with pygimp-0.5 Message-ID: <00071114244803.12022@avalon> Hi Im having a problem with pygimp v0.5. What am I messing here? Gimp works, the plugins with pygimp work, but... >>> import gimp >>> img = gimp.image (200,300,0) GLib-CRITICAL **: file ghash.c: line 138 (g_hash_table_lookup): assertion `hash_table != NULL' failed. ** ERROR **: could not find handler for message: 5 aborting... Aborted cheers --Ben From matt at nightrealms.com Wed Jul 26 01:08:44 2000 From: matt at nightrealms.com (Matthew Cline) Date: Tue, 25 Jul 2000 22:08:44 -0700 Subject: conatraints on "for" magic? References: <8llqso$q75$1@news.dtc.hp.com> Message-ID: <7uuf5.13834$G7.486572@news-west.usenetserver.com> In article <8llqso$q75$1 at news.dtc.hp.com>, weeks at golden.dtc.hp.com ((Greg Weeks)) wrote: > How did the implementer of the "fileinput" module convince the "for" > construct that fileinput.input() was a sequence? You can subclass from UserList to have a class that acts like a sequence. From jkraska1 at san.rr.com Sun Jul 23 01:30:01 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 23 Jul 2000 05:30:01 GMT Subject: bit manipulation frustration References: <397A6980.CF15DB96@san.rr.com> <397A7BB5.A6024F70@san.rr.com> Message-ID: <397A839B.D3BCAF41@san.rr.com> > > > get it?) > > No.. The image is runs of values where 'X' represents a 16 bit RGB value. It's like this: XX XXXX XXXXXX ... >From 2 to 44 to 2 again. However, upon load, this needs to be converted to a bitmap like this (where "-" is black, and X is a 16 bit RGB value): ---------------------XX--------------------- --------------------XXXX-------------------- -------------------XXXXXX------------------- ------------------XXXXXXXX------------------ -----------------XXXXXXXXXX----------------- ----------------XXXXXXXXXXXX---------------- ---------------XXXXXXXXXXXXXX--------------- --------------XXXXXXXXXXXXXXXX-------------- -------------XXXXXXXXXXXXXXXXXX------------- ------------XXXXXXXXXXXXXXXXXXXX------------ -----------XXXXXXXXXXXXXXXXXXXXXX----------- ----------XXXXXXXXXXXXXXXXXXXXXXXX---------- ---------XXXXXXXXXXXXXXXXXXXXXXXXXX--------- --------XXXXXXXXXXXXXXXXXXXXXXXXXXXX-------- -------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------- ------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------ -----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX----- ----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---- ---XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--- --XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-- -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX- --XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-- ---XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX--- ----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX---- -----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX----- ------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------ -------XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX------- --------XXXXXXXXXXXXXXXXXXXXXXXXXXXX-------- ---------XXXXXXXXXXXXXXXXXXXXXXXXXX--------- ----------XXXXXXXXXXXXXXXXXXXXXXXX---------- -----------XXXXXXXXXXXXXXXXXXXXXX----------- ------------XXXXXXXXXXXXXXXXXXXX------------ -------------XXXXXXXXXXXXXXXXXX------------- --------------XXXXXXXXXXXXXXXX-------------- ---------------XXXXXXXXXXXXXX--------------- ----------------XXXXXXXXXXXX---------------- -----------------XXXXXXXXXX----------------- ------------------XXXXXXXX------------------ -------------------XXXXXX------------------- --------------------XXXX-------------------- ---------------------XX--------------------- This is an isometric tile, where the only data stored in the file is the diamond part of X's in the middle. The -'s are all predictable, so there's no reason to store them. Ergo, I'm looking for the best way to create a bitmap from something that isn't one. C/ From jkraska1 at san.rr.com Sat Jul 29 21:54:55 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 30 Jul 2000 01:54:55 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: <39838BAC.C855EDCB@san.rr.com> > > Actually I think it would be easier for non-programmers to > >learn a language if it has strict typing. > > I concur. In non-programming, life is strictly typed. Allowed > operations are determined by the type of the object. You can't > make a phone call on a waffle-iron. This is a conceptualization issue, and I suspect to a degree, false. If "x" is merely a label, one can imagine x labeling 3 or x labelling red quite easily. Your analogy works because you carefully framed it, but there's nothing at all to say that your framing of it was right. To the contrary; while I can't prove it, I do believe it's wrong. C/ From smoriano at sicon.net Tue Jul 4 08:00:18 2000 From: smoriano at sicon.net (sergio) Date: Tue, 04 Jul 2000 14:00:18 +0200 Subject: PROCESS QUESTION Message-ID: <3961D1D2.9C66B425@sicon.net> Hi all, I'm working in NT SERVER 4.0 How can i search the id of a process running, searching it by the name? Thanks for all your responses From alex_c at mit.edu Tue Jul 18 07:46:52 2000 From: alex_c at mit.edu (Alex Coventry) Date: 18 Jul 2000 07:46:52 -0400 Subject: pty.py: any example code out there? References: Message-ID: Hi, David. Here is something I wrote a little while back. It works on Linux, at least. It's kind of ugly -- it's one of those things where I thought it would be easy, but I kept having to deal with problems I hadn't anticipated. Hope the pty_Popen class helps as an example, though. That part's fairly simple. Alex. #!/usr/bin/python # No warranty. I don't have any money, anyway, so sue someone else, # please. Do as you wish with this code. '''Sync up Apache and Unix passwords.''' password_file = '/etc/htpasswd' import os, pty, time, signal, getpass, pdb, sys, string, re st = pdb.set_trace class pty_Popen: def __init__ (self, command, args, delay=0.1): self.delay = delay # Clone this process in a separate thread. self.pid, self.child = pty.fork () # In the child process, pid will contain 0. In the parent, # it will contain the pid of the child. if self.pid == 0: # In the child process, so replace the python # process with the requested command. os.execv (command, [''] + args) else: # In the parent process, which stays live pass def read (self, max_read): time.sleep (self.delay) return os.read (self.child, max_read) def write (self, text): time.sleep (self.delay) return os.write (self.child, text) class UnexpectedProcessOutputError (Exception): pass def get_effective_user (): effective_user = os.popen ('/usr/bin/whoami').readline () assert effective_user[-1] == '\n' return effective_user[:-1] class Passwd: def __init__ (self, username): self.username = username self.effective_user = get_effective_user () self.log = [] self.unexpected_process_output_p = None def execute (self): self.get_passwd_process () # Just for initial authentication. self.get_password () self.change_password () def get_password (self): while 1: self.new_password = getpass.getpass ('New password: ') if self.validate_password (self.new_password): break def validate_password (self, password): if password == self.current_password: print 'That\'s your old password!' return 0 if re.search ("['\\\\]", password): print 'Please don\'t use single quotes or backslashes\n' \ 'in your password.' return 0 check_result = self.check_password_against_machine (password) if check_result != '': print 'This paranoid machine thinks that password is\n'\ 'too easy to guess. Please try something else.\n' \ 'Its complaint was:' check_result = string.split (check_result, '\n') if len (check_result) >= 2 and check_result[-1] == \ 'New UNIX password: ': print string.strip (check_result[0]) else: print string.join (check_result, '\n') return 0 re_entry = getpass.getpass ('Please retype it, so I know ' \ 'there\'s no typos: ') if re_entry != password: print 'Mismatch. Lucky I checked, huh?' return 0 else: return 1 def check_password_against_machine (self, password): # Go through the passwd exchange up to the point where the new # password is requested. self.get_passwd_process () self.write (self.new_password) response = self.get_response () # It it's accepted, it will ask for it to be retyped. if response == 'Retype new UNIX password:': return '' else: return response def change_password (self): self.get_passwd_process () self.write (self.new_password) self.get_response () == 'Retype new UNIX password:' self.write (self.new_password) self.check_process_output (('passwd: all authentication '\ 'tokens updated successfully'), self.get_response ()) def get_current_password (self): if not hasattr (self, 'current_password'): self.current_password = getpass.getpass ('Current password: ') def wrong_password (self): print 'Incorrect password entered.' sys.exit (1) def get_passwd_process (self): self.get_current_password () self.passwd_process = pty_Popen ('/bin/su', [self.username, '-c', '/usr/bin/passwd']) response = self.get_response () if self.effective_user != 'root': # Negotiate the password challenge. self.check_process_output ('Password:', response) self.write (self.current_password) response = self.get_response() if response == ': incorrect password': self.wrong_password () # Next response is sometimes not read in completely the first time. lines = string.split (response, '\n') if len (lines) == 1: lines.append (self.get_response ()) lines = map (string.strip, lines) response = string.join (lines) expected_response = 'Changing password for %s ' % self.username + \ '(current) UNIX password:' self.check_process_output (expected_response, response[-len (expected_response):]) self.write (self.current_password) response = self.get_response () if response != 'New UNIX password:': if self.check_process_output ('passwd: Authentication failure', response): self.wrong_password () # Die. def get_response (self): while 1: response = string.strip (self.passwd_process.read (1024)) self.log.append (('o', response)) if response: break return response def write (self, text): self.log.append (('i', text)) assert self.passwd_process.write (text + '\n') == len (text) + 1 def check_process_output (self, expected, actual): if expected != actual: self.log.append (('expected', expected)) self.unexpected_process_output_p = 1 print 'Unexpected output from passwd process encountered:' print response print 'Continuing in the hope that the response does not' print 'indicate a fatal error.' return 0 else: return 1 def get_executing_user (): id_info = os.popen ('/usr/bin/id').read()[:-1] id_info = string.split (id_info)[1] id_re = re.match (r'gid=\d+\(([^)]*)\)', id_info) assert id_re user = id_re.group (1) return user def main (t): executing_user = get_executing_user () no_keyboard_interrupts = 1 try: try: t.execute () except KeyboardInterrupt: no_keyboard_interrupts = None except EOFError: no_keyboard_interrupts = None if not no_keyboard_interrupts: print print 'Stopped.' sys.exit (2) # If the database has not yet been created, use the '-c' flag # to do so. if os.path.exists (password_file): flags = '-b' else: flags = '-bc' # Quote the password, since that came from the user. # Just in case they try anything funny. args = [flags, password_file, executing_user, "'%s'" % t.new_password] command = string.join (['/usr/local/bin/htpasswd'] + args) # Save a backup, just in case current_password_file_contents = open (password_file).readlines () home_dir = os.path.expanduser ('~' + get_effective_user ()) backup_filename = os.path.split (password_file)[1] + '.bak' backup_filename = os.path.join (home_dir, backup_filename) open (backup_filename, 'w').writelines (current_password_file_contents) assert os.system (command) == 0 # Check that nothing got stomped on in password_file. new_password_file_contents = open (password_file).readlines () for line in current_password_file_contents: if line not in new_password_file_contents and \ string.split (line, ':')[0] != executing_user: # alert_alex ('Contents of password file have been ' \ 'inadvertantly destroyed.') # print 'Back up stored in', backup_filename def test (): global password_file password_file = '/home/alex_c/com/python/htpasswd' executing_user = 'alex_c' t = Passwd (executing_user) t.current_password, t.new_password = 'whynot.', 'flurgle.' st () t.check_password_against_machine (t.new_password) t.change_password () raise 'stopped' if __name__ == '__main__': executing_user = get_executing_user () t = Passwd (executing_user) main (t) if t.unexpected_process_output_p: error_log_file = open ('/home/ht_keeper/error_log', 'a') # Want to record a log of the exchange, but don't want to # record any passwords. log = [] for line in t.log: if line[0] != 'i': # Don't get user input. log.append (line[1]) error_log_file.write ('%s: %s\n' % (executing_user, log)) # alert_alex ("There was an error in passwd.ht.") # Log the change. import time log_filename = '/home/ht_keeper/log' log_file = open (log_filename, 'a') log_file.write ('%s %s\n' % (executing_user, time.time ())) log_file.close () From grey at despair.rpglink.com Thu Jul 27 22:56:21 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 02:56:21 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280117.LAA23637@mbuna.arbhome.com.au> Message-ID: On Fri, 28 Jul 2000 11:17:31 +1000, Anthony Baxter wrote: >Euw! No, the "oh, I know what you want that to be, I'll change it for you" is >my #1 all-time perl hate. Why? Has it ever messed up? It does exactly what you tell it to unlike the babysitting languages that barf with "Oh, you don't know what you're doing so I won't let you do it." Before you answer know the difference between it messing up and /you/, as the programmer, messing up. It is just like me with my problem where a method wasn't being called and I couldn't figure out why. It is because I forgot the parens. Whoops, my mistake even though I say, for argument's sake, that Python in non-interactive mode should catch it. Now that I know what is going on I can recognize it and move on. >Particularly when combined with magic linenoise - use the wrong bit of >linenoise, and suddenly your large complex datastructure is an int. Yaaay. The above example applies here. Once you know what is going on it is all fairly straight forward. BTW, your large, complex datastructure isn't an int. There is no int unless you use int(), just like in Python, or try to stuff it into someplace that expects something that could be called an int, in which case it is your fault as a programmer, not the languages, and has nothing to do with the symbols. In fact, I can't really think of how that applies at all since most "line noise" in perl is in regex (which Python uses PCRE so don't get me started there) and scalar/array/hash which is amazingly simple to manipulate and keep track of compared to int, long, float, str, repr (and the difference between repr and str), tuple, list (and the difference there), directory. You have three characters to keep track of, $, @ and %. If you have mastered types you can master those three in a virtually typeless context. Trust me on that. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From olivierS.dagenaisP at canadaA.comM Wed Jul 26 16:10:18 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 26 Jul 2000 20:10:18 GMT Subject: Deleting files with wildcards References: <397f046d.193858654@news.atnet.at> <8lncs70240i@news2.newsguy.com> Message-ID: I will laugh so hard if, in a few weeks time, we see a Python virus going around doing exactly this. It would be the first totally portable virus, now wouldn't it?? : ) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Alex Martelli" wrote in message news:8lncs70240i at news2.newsguy.com... > "Manfred Pisecky" wrote in message > news:397f046d.193858654 at news.atnet.at... > > Hello everyone! > > > > I have to delete a bundle of files, e.g. *.txt in a portable way (it > > must work for Linux and NT). > > > > I use Python 1.5.2. and have not found a way to either delete files > > with wildcards or to read the directory content (and do it file by > > file). > > > > Is there a portable way in 1.5.2 ? > > os.listdir(path) will portably return the list of all files in > the path, and os.unlink can be used to delete one or more of > them (or, os.remove, too). os.path.walk is also handy if you > need to iterate on a whole subdirectory tree. > > > Alex > > > From m.faassen at vet.uu.nl Mon Jul 31 04:19:45 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 08:19:45 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8m25dm$ila$1@newshost.accu.uu.nl> Message-ID: <8m3cr1$hn2$3@newshost.accu.uu.nl> Paul Foley wrote: > On Mon, 31 Jul 2000 00:46:17 GMT, Steve Lamb wrote: [snip] >> reason, however, b, which was pointing to 1 can be made to point to something >> else which we'll call the integer formerly known as 1 where as None things >> cannot be repointed from. None is like that really nasy uncle everone has who > Nonsense. Ah, indeed; I didn't read this part of Steve's post when I replied just now. This does seem to point out a misconception on Steve's part and in my previous post I claimed he seemed to get it. :) There is two ways to describe it. "None cannot be repointed from" correct: without an explicit assignment (or equivalent such as in a for loop), there is no way to make a name that points to None suddenly point to something else. But in that sense, there's no way to make that name point to something else *at all*; it doesn't matter what the name contained. nonsense: a name pointing to None can be made to repoint to something else just as easily as any name. Just use assignment. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From no at bo.dy Sat Jul 22 11:46:07 2000 From: no at bo.dy (nobody) Date: Sat, 22 Jul 2000 10:46:07 -0500 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: cjc26 at nospam.cornell.edu (Cliff Crawford), in : > * nobody menulis: >> now, this newbie has run into another perl idiom he'd like to figure >> out how to rewrite in python - "while () { print; }" - and, by >> extension, how to get python to print the string i hand it, the whole >> string i hand it, and nothing but the string i hand it? > Hmm..not quite sure what you mean..maybe you want to use > sys.stdout.write() instead? perhaps. unfortunately, i haven't had time to work on this since i made that posting, so i have got no further; i expect there's some fairly easy way to write (copy) all the lines from one file to another one, possibly (though not necessarily) stdout. perl is nice in that this task is a one- liner in that language; i don't *need* it that concise, but it would be nice. i like one-liners. >> i despise machines trying to second- guess my intentions, and silly >> little print statements trying to be clever with their arguments are >> nothing more than that. > print doesn't really try to be clever with its arguments, except for > printing a space between each one and a newline at the end. that's trying to be clever. then, if i'm reading raw lines from a file and want to print them verbatim, i have to strip a newline somewhere somehow? how do i copy a file to another one, is there a file.copy method in some module somewhere? > Maybe what you're looking for is the format operator? it's certainly useful, but will it stop the print statement from outputting things i may or occasionally may not want output? [...] >> i like it, i just wish its functions would be more consistent about >> what sort of regexps they want - either all compiled or all not >> compiled; i'm seeing some wanting one and some the other, for some >> reason. might be just my system, i suppose... > The two should be interchangable..AFAIK wherever you can use a compiled > regexp, you can use an uncompiled one, and vice-versa. that's what the documentation claims, but here's what i get: Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import re >>> test="this is a test string" >>> reg=r"est" >>> reg_c=re.compile(reg) >>> match=re.match(reg_c,test) Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/re.py", line 40, in match return _cachecompile(pattern, flags).match(string) File "/usr/lib/python1.5/re.py", line 33, in _cachecompile value = compile(pattern, flags) File "/usr/lib/python1.5/re.py", line 79, in compile code=pcre_compile(pattern, flags, groupindex) TypeError: argument 1: expected string, instance found >>> match=re.match(reg,test) >>> the compiled one works in re.findall, though. i've no idea why this bites me in this way, but it's not too hard to work around, so... From jeroen at valcke.com.bbs Mon Jul 17 11:00:01 2000 From: jeroen at valcke.com.bbs (jeroen at valcke.com.bbs) Date: 17 Jul 2000 15:00:01 GMT Subject: automatically filling web forms? Message-ID: <3bRFj1$keM@openbazaar.net> Whaaw, great, although I'm a newbie to python I managed to write to a cgi script in a matter of minutes. I had read about python, and it is true: this is powerful stuff! I'm hooked. I'm going to learn python. Thanks for this sample code, it helped me alot! Still, have some questions though. Another cgi script that I'm trying to write to doesn't work. The python program hangs and just waits until I terminate it. Any idea. Somebody mentioned that on that particular site you can't write to their cgi scripts. It is only possible to use that script from within there own pages. Is that possible? Also, a small question about the code what about the file you open in the code, is that to write results? because the file never gets created when i run the program, I don't need results too. -- Jeroen Valcke jeroen at valcke.com ICQ# 30116911 Home page: http://users.pandora.be/valcke/jeroen/ The best glimpse of heaven ... is on the way into hell. From jpowers at acm.org Mon Jul 10 11:52:24 2000 From: jpowers at acm.org (John Powers) Date: Mon, 10 Jul 2000 10:52:24 -0500 Subject: Tkinter: buttons are dead of tkFileDialog.askopenfilename Message-ID: <3969F138.4EFE768E@acm.org> I have a simple Python script to illustrate a problem I'm having with askopenfilename. The following program displays a window with a "Quit" button. The "Quit" button works until you uncomment the statement which calls askopenfilename. After selecting a file from the Open Dialog box, the button window appears but the "Quit" button is dead -- absolutely no response to pressing it. What's up? Maybe I shouldn't be calling askopenfilename while initializing App? from Tkinter import * import tkFileDialog class App(Tk): def __init__(self): Tk.__init__(self) filename = "filename" #filename = tkFileDialog.askopenfilename() Label(self, text=filename).pack() Button(self, text="Quit", command=self.quit).pack() App().mainloop() tia, jpp -------------- next part -------------- An HTML attachment was scrubbed... URL: From deprince at sprynet.com Sat Jul 8 21:53:00 2000 From: deprince at sprynet.com (Adam DePrince) Date: Sun, 09 Jul 2000 01:53:00 +0000 Subject: 123.4+2=125.40000000000001 References: <3950A30D.DEE4CF4D@brb.midat.de> Message-ID: <3967DAFC.B1D5A1D3@sprynet.com> Konrad Hinsen wrote: > > Peter Koppatz writes: > > > >>> 123.4+2 > > 125.40000000000001 # is this OK? > > >>> print 123.4+2 > > 125.4 > > >>> > > > > On my calculator: 123.4+2 = 125.4 !? > > Because your calculator works with a decimal representation of > numbers, whereas Python (and the vast majority of other programming > languages) uses a binary representation. In binary, the result of your > calculation has an infinite number of digits (like 1./3. has in > decimal) and cannot be represented exactly in a computer. That causes > the effect you observe. Python uses C's "double" type, which on almost all modern machines uses the IEEE format. Omiting tons of neat details, IEEE double expresses values as: 2^n * m/2^53 where m is unsigned between 0 and 2^53-1. .4 cannot be expressed precisely in the above fraction; in base two .4 is a "repeating becimal" -- Adam DePrince - firstname at lastname dot net, all in lowercase From alex at magenta.com Fri Jul 28 08:41:56 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 14:41:56 +0200 Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> Message-ID: <8lrvae015nm@news2.newsguy.com> wrote in message news:8lr9nc$tdf$1 at nnrp1.deja.com... > Is there an API using Win32 extensions to map a > drive share? I have not found one yet and have > tried searching "Win32 map drive". I am looking > for the equivalent of: > > net use > > If not, is there an alternative other than making > a call to system("net use "). import win32net win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:'}) is an example (not all that easy to fathom from the docs, but I found it out with a little help from the docs, a little from MSDN, and a little experimentation). If you're not already validated with the server, you may need to add a 'password':'whatever' entry to the dictionary that is the third argument to NetUseAdd. But this is equivalent to net use K: \\server\share as I do not know what net use means _without_ the local devicename (e.g., the 'K:' here). win32net contains all the API's you may desire to emulate "net use" and other subcommands of "net"; much of what you need to know about it, you can gather from MSDN's entries about "Platform SDK: Network Management" (use msdn.microsoft.com for online access, if you don't have a handy CD or DVD with MSDN on it), but of course there is some mapping between the argument types involved. Where the original (C-level) API wants a structure, win32net uses a dictionary instead, with entries corresponding to the struct's fieldnames shorn of prefixes (e.g., the struct USE_INFO_1 that the C-level NetUseAdd API wants has fields named ui1_remote and ui1_local). But if you plan to do a lot of system programming and/or system administration on Windows with Python (a very workable and excellent plan, as it happens) you really should splurge for the "Python Programming on Win32" book by Hammond and Robinson, published by O'Reilly. It's not perfect (for example, I can't find in its reference Appendix any specific info on NetUseAdd, while it does document a lot of OTHER win32net functions!-) but it still helps a lot. Alex From aahz at netcom.com Wed Jul 26 09:46:50 2000 From: aahz at netcom.com (Aahz Maruch) Date: 26 Jul 2000 13:46:50 GMT Subject: how to know number of threads are running. References: <397E524E.412FE123@eSec.com.au> Message-ID: <8lmq4a$mge$1@nntp9.atl.mindspring.net> In article <397E524E.412FE123 at eSec.com.au>, Sam Wun wrote: >thanks If you are using threading.py, and if you create all your threads using threading.Thread() (or subclasses thereof), then you can use threading.activeCount(). However, you should be aware of two caveats: * The main thread that starts up the subthreads *does* count as a thread, so your thread count is always one higher than your first guess. * While occasionally useful for what I call "brute force" threading, activeCount() is mostly useless in "real" threaded programs. If you really want to know how many threads are running, use some kind of variable that you increment and decrement through a mutex. But there are usually no reasons other than debugging to do this. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From wtanksle at dolphin.openprojects.net Fri Jul 28 23:53:19 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 29 Jul 2000 03:53:19 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 23:05:24 GMT, Steve Lamb wrote: >On Fri, 28 Jul 2000 22:38:32 GMT, William Tanksley > wrote: >>That's a really cruel statement for you to make. I hope you were making >>it in jest. I've seen nothing to indicate anything waranting this kind of >>attack. > Neither cruel or jest. I consider "Automagic" coversion on the same vein >as "Winblows". I have hoped that there were people who were above that, there >are some, but it is here as in everywhere else. You consider "automagic" an insult? I've never HEARD of such a thing. Please at least *inform* us before you take offence. Note that your "taking offence" (which included an accusation that the entire Python community was a disgrace to the language they support) paragraph was not anywhere NEAR to any use of the word "automagic", so left no possibility of figuring out why you were offended. I at least will be careful not to use that word in further disscusion, now that I know. I would ask that in the future you state exactly what offends you, rather than shotgun accusing the *entire community* of being jerks. > Steve C. Lamb -- -William "Billy" Tanksley From richard at whitequeen.com Sat Jul 8 20:46:18 2000 From: richard at whitequeen.com (richard offer) Date: Sat, 08 Jul 2000 17:46:18 -0700 Subject: [ANN] slashbox - class to get/display slashdot.org (and others) stories Message-ID: <3967CB5A.C0710FFD@whitequeen.com> Hi, Here's a quick hack of a class to get and format news stories from a number of sites. It was designed with mod_python in mind, so all you need to do under mod_python is import slashbox ... def handler(req): ... req.write(str(slashbox.Slashdot())) To add the latest stories from slashdot to your page. However there's nothing mod_pythong specific to it.... A number of other sites are included, its easy to add new ones simply by sub-classing slashbox. The trick is to find the sites .rss/.rdf file. You'll need the latest PyXML code. I'm in the process of re-implementing my web server, so I have no url to give you.... richard. -------------- next part -------------- # $Id: slashbox.py,v 1.3 2000/07/09 00:34:38 richard Exp $ # Copyright (c) 2000 Richard Offer . All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # Richard Offer BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of Richard Offer shall not be # used in advertising or otherwise to promote the sale, use or other dealings # in this Software without prior written authorization from Richard Offer. # # # A python class to grab the Slashdot (and other sites using RSS/RDF) stories. import stat import xmllib import urllib import urlparse import os import time import string import sys from xml.sax import saxlib,saxexts class _myrdf(saxlib.HandlerBase): def __init__(self): self._in={} self._in["title"]=0 self._in["link"]=0 self._in["description"]=0 self._txt={} self._txt["title"]="" self._txt["link"]="" self._txt["description"]="" self._stories=[] def startElement(self,ele,attr): if ele == 'item' : self._txt={} self._txt["title"]="" self._txt["link"]="" self._txt["description"]="" elif self._in.has_key(ele) : self._in[ele]=1 else: pass def endElement(self,ele): if self._in.has_key(ele) : self._in[ele] = 0 self._txt[ele] = string.join(string.split((self._txt[ele]))) elif ele == 'item' : self._stories.append(self._txt) def characters(self,ch,start,length): for i in self._in.keys(): if self._in[i] == 1: self._txt[i] = self._txt[i] + ch[start:start+length] def stories(self): return self._stories # class Site() class slashbox: """ Create a single slashbox. slashbox(url,freq) url is the url of the RSS/RDF file, freq is the update period (mins). The freq cannot be less than 30 raw() returns a list of stories (each story is stored in a dict). __str__() returns a HTML table containing the stories. Several subclasses are available, these already have the url defined, so to get the headlines from slashdot.org simply do >>> print Slashdot() The list of built-in sites is Slashdot() Freshmeat() SecurityFocus() Parnassus() LWN() Fool() LinuxNetNews() SourceForgeReleases() SourceForgeNews() If you are using mod_python, you can embed a slashbox simply by import slashbox ... req.write(str(slashbox.Slashdot())) """ def __init__(self, url='http://slashdot.org/slashdot.rdf', freq=60): self._url=url if freq < 30: freq=30 self._freq=freq _u=urlparse.urlparse(self._url) self._file=_u[1] + "-" + os.path.basename(url) if self._file == '': self._file = os.path.basename(url) self._file = "/tmp/slashbox-" + self._file self.site= _u[0]+ "://" + _u[1] + "/" self.name= _u[1] try: st=os.stat(self._file) if st[8] < ( time.time() - (self._freq*60) ): (fname,headers)=urllib.urlretrieve(self._url, self._file) except OSError: (fname,headers)=urllib.urlretrieve(self._url,self._file) fp=open(self._file) xmlp=saxexts.make_parser() self.dh=_myrdf() xmlp.setDocumentHandler(self.dh) xmlp.parseFile(fp) def stories(self): return self.dh.stories() def __str__(self): str="\n\n" str=str + '\n' % ( self.site, self.name ) str=str + "\n
%s
\n \n" for i in self.dh.stories(): str=str + ' \n' str=str+"
%s' % ( i['link'],i['title'] ) if i.has_key("description"): str=str + "
%s" % ( i['description']) str=str + '
\n\n" return str def setName(self,name): self.name=name class Slashdot(slashbox): """slashbox sub-class for Slashdot.org""" def __init__(self): _url='http://slashdot.org/slashdot.rdf' slashbox.__init__(self,url=_url) self.setName('Slashdot') class Freshmeat(slashbox): """slashbox sub-class for Freshmeat.net""" def __init__(self): _url='http://freshmeat.net/backend/fm.rdf' slashbox.__init__(self,url=_url) self.setName('Freshmeat') class SecurityFocus(slashbox): """slashbox sub-class for SecurityFocus.com""" def __init__(self): _url='http://www.securityfocus.com/topnews-rss.html' slashbox.__init__(self,url=_url) self.setName('Security Focus') class Parnassus(slashbox): """slashbox sub-class for the Vaults of Parnassus""" def __init__(self): _url='http://www.vex.net/parnassus/parnassus.rss' slashbox.__init__(self,url=_url) self.setName('Vaults of Parnassus') class LWN(slashbox): """slashbox sub-class for the Linux Weekly News""" def __init__(self): _url='http://lwn.net/headlines/rss' slashbox.__init__(self,url=_url) self.setName('Linux Weekly News') class Fool(slashbox): """slashbox sub-class for the Motley Fool""" def __init__(self): _url='http://www.fool.com/About/headlines/rss_headlines.asp' slashbox.__init__(self,url=_url) self.setName('The Motley Fool') class LinuxNetNews(slashbox): """slashbox sub-class for Linux Net News""" def __init__(self): _url='http://www.netnews.opensrc.org/index.rdf' slashbox.__init__(self,url=_url) self.setName('Linux Net News') class SourceForgeReleases(slashbox): """slashbox sub-class for new releases on SourceForge""" def __init__(self): _url='http://sourceforge.net/export/rss_sfnewreleases.php' slashbox.__init__(self,url=_url) self.setName('Sourceforge New Releases') class SourceForgeNews(slashbox): """slashbox sub-class for Project News at SourceForge""" def __init__(self): _url='http://sourceforge.net/export/rss_sfnews.php' slashbox.__init__(self,url=_url) self.setName('Sourceforge News') if __name__ == "__main__": print Slashdot() From amk at mira.erols.com.bbs Sun Jul 16 12:30:03 2000 From: amk at mira.erols.com.bbs (amk at mira.erols.com.bbs) Date: 16 Jul 2000 16:30:03 GMT Subject: Anyone going to OLS? Message-ID: <3bQSbR$lPy@openbazaar.net> On Sat, 15 Jul 2000 21:10:40 GMT, Olivier Dagenais wrote: >Hey, I'm in Ottawa! Where's the OLS being held? You think it's a problem >if I never use Linux and I go to the OLS??? : ) See www.ottawalinuxsymposium.org; unfortunately I think all 500 places were sold out in June. A pity for you, since it's an impressively technical conference -- no vendors, no sales people, just techies. Some talks are Linux-specific, but others are of general interest to any Unix programmer -- talks on GNOME, DocBook, writing network daemons, etc. --amk From moshez at math.huji.ac.il Thu Jul 20 14:57:41 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 20 Jul 2000 21:57:41 +0300 (IDT) Subject: iterating over lines in a file In-Reply-To: <8l75im$sc$1@sunnews.cern.ch> Message-ID: On 20 Jul 2000, Radovan Garabik wrote: > Moshe Zadka wrote: > ... > > : Preventing world war III, when Python achieves world domination. > : If C is allowed to achieve world domination, WWIII will be cause by > > : if(everything_is_ok = 0) { > : launch_missile(); > : } > > : Whereas since Python wwill achieve world domination, > > : if everything_is_ok = 0: > : launch_missile() > > : Is a syntax error, and wil be detected before it is allowed into the > : automated defense system. > > nah... WWIII will be started with this code: > > def check_if_there_is_an_attack(): > .... > if ....: > return 0 > else: > return 1 > > if check_if_there_is_an_attack: > launch_counterattack() C won't help you here either: int check_if_there_is_an_attack() { ... } main() { if(check_if_there_is_an_attack) launch_counterattack(); } Is just as valid...a pointer to a valid function is never NULL. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From gmcm at hypernet.com Mon Jul 17 19:19:16 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 17 Jul 2000 23:19:16 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> Message-ID: <8F74C4E37gmcmhypernetcom@199.171.54.155> Kevin Jacobs wrote: >Silly idea 1: > > Until add-on Python grammar modules are available, what about a > PyAlgebra evaluator module. For a precedent, see regular expressions. > The difference is that linear-algebra syntax can be made too > Python-like for some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() I proposed something very similar to Huaiyu the other day: PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) I know Thomas Wouters did, too. I haven't seen a post reflecting these suggestions. In fact, looking at this thread in one of those tree-view newsreaders, it becomes obvious that branches die when a proposal is made, but arguments are met with vehement counter arguments. Which leads me to believe that: >Silly idea 3: > > Lets continue arguing until everyone, both pro and con, gets > irritated, >starts calling each other Nazis and gives up. ...has already won. - Gordon From MarkH at ActiveState.com Thu Jul 20 21:24:40 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 21 Jul 2000 01:24:40 GMT Subject: process id from os.system References: <3977482B.478D2754@sec.noaa.gov> Message-ID: "j vickroy" wrote in message news:3977482B.478D2754 at sec.noaa.gov... > How can I obtain the process id for a program launched via > > os.system (theProgram) ? > > I would like to do this portability (Unix, Windows). AFAIK, there is no portable solution. Using win32process.CreateProcess() under Windows will return the PID (along with the process handle, which can be used to wait for the process to terminate) Mark. From donn at u.washington.edu Fri Jul 21 12:36:18 2000 From: donn at u.washington.edu (Donn Cave) Date: 21 Jul 2000 16:36:18 GMT Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: <8l9u62$1tag$1@nntp6.u.washington.edu> Quoth "Roger Upole" : | I must take exception to your insistence that | "Everything should be done ONCE, and only ONCE. In ONE | place in the code." | Besides sounding didactic, it is also completely false. In many cases, | an initial read is necessary to determine how (or even if) the rest of a | file will be processed. Also, different code may need to be called if | the file is empty. | Additionally, this overly simplistic programming style would be completely | inadequate for most involved programming tasks. Whatever. You do what you want. But when that means stuff like this, |>> f=open('filename','r') |>> fline = f.readline() |>> while fline: |>> .... |>> fline = f.readline() eventually you're going to have a debugging problem when you change that function at one site and neglect to make the same change at the other. That was the context for that statement. If you have to sort this out here before you can go on to do anything today, clarity may come if you look at it this way: what is a "thing", when we say "everything should be done once?" Does that mean f.readline(), i.e., f.readline() can be called in only one place? If we have two places in our program that test __name__ == '__main__', should those two be consolidated into one? What about "import sys"? As stupid as that would be, to write code like the example above just to avoid a "while 1" is worse, because at least our "one" philosophy has an explanation. If you're looking for a sensible statement that you wouldn't have to take exception to, what if a "thing" is a section of code that if duplicated would certainly be subject to the same change issues in each instance. I.e., if changed at site 1 it would certainly have to be changed in the same way at site 2. Where that's not the case, we are evidently talking about a different "thing", something that looks the same but has a different meaning. No one would want to argue that two things with different meanings should be forced together, only when the meaning is the same. Donn Cave, donn at u.washington.edu From samschul at pacbell.net Thu Jul 13 11:14:00 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Thu, 13 Jul 2000 15:14:00 GMT Subject: OSCON help? (Second try) References: <8kkjke$l59$1@slb6.atl.mindspring.net> Message-ID: <8kkmb6$ha0$1@nnrp1.deja.com> I'll be at the conference. Give me details on what's required and I will be happy to help if I can. Sam Schulenburg (408)325 5941 (work) (408) 683-2276 (home) In article <8kkjke$l59$1 at slb6.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > I'm giving a presentation at OSCON next week on threads in Python. The > presentation is Thursday, 7/20, at 3:30. I'm hearing-impaired, so I'd > like some help transcribing questions from the audience. Emile van > Sebille has already kindly offered to help, but I'd like at least one > more volunteer as backup. Any takers? > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "do you want my self-identities alphabetically, chronologically, or in > random order?" -- Misha > Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Mon Jul 31 18:13:49 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 22:13:49 GMT Subject: removing characters from a string? References: <8m4rqn+jpg0@eGroups.com> Message-ID: <8m4tmt$d6h$1@slb1.atl.mindspring.net> In article <8m4rqn+jpg0 at eGroups.com>, wrote: > >this_string = "jesse at multimediacollective.com" > >"""and I wanted to get rid of the @, how would I do that? This >process has to be efficent for removing large quantities of special >characters, such as <,>,#,%,* etc, from the same string. string.translate(,,deletechars) is the fastest. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From peter at schneider-kamp.de Wed Jul 12 07:51:31 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 12 Jul 2000 11:51:31 +0000 Subject: Sound module question References: <396BBA07.E844152@bresnanlink.net> <396BC08E.A3C036A4@pehr.net> <396C18D8.EC4CC59@bresnanlink.net> Message-ID: <396C5BC3.A0C7882@schneider-kamp.de> Aaron Berg wrote: > > I have already tried that. I need to record sound in a time sensitive > eviroment. I will most likely need to write my own sound module which I really > > don't want to do...because I don't know where to start with that either. I > have this really simple program called sound-recorder that has simple read and > > write but in order to stop a recording the person needs to do ^c (ctrl + c) > how would I start that program in a thread and be able to stop it at a certain > > point using ctrl + c? A sound module for python would probably be the best > solution still. If you have the sources for that simple program it should not be hard to write a Python module on top of that. (note: should, maybe it's hard though). If you can tell me where to find the sources, I'll take a look. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From alex at magenta.com Mon Jul 17 14:43:50 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 17 Jul 2000 20:43:50 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> <8kvdon$tit$1@slb3.atl.mindspring.net> Message-ID: <8kvkb401g1e@news1.newsguy.com> "G. David Kuhlman" wrote in message news:8kvdon$tit$1 at slb3.atl.mindspring.net... [snip] > One thing (among many) that I do not understand is how C#Python can > both compile directly to IL (intermediate language?) and produce a > .DLL/.EXE. Does the .EXE contain both an interpreter (VM ?) and > the IL (byte code?) that it interprets? Or does IL mean that the > machine code is in there, but augmented with some meta-information > for debuggers and other tools? Or, what? As I "read between the lines", mostly in the paper (on the MSDN online technical articles library) about Eiffel#, the .NET framework lets IL (bytecode and metadata, or native-code and metadata) be packed into a module (DLL or EXE), and if desired multiple modules may be packed into one (modules may also refer to other modules outside of their 'packaging', but a more self-contained packaging may also be provided if desired). I guess/suspect that Python.NET (or Python# as the case may be) exploits exactly these capabilities of the framework...? Alex From Rod.Haper at sage.nelesautomation.com.bbs Fri Jul 14 19:00:01 2000 From: Rod.Haper at sage.nelesautomation.com.bbs (Rod.Haper at sage.nelesautomation.com.bbs) Date: 14 Jul 2000 23:00:01 GMT Subject: atof problem. Message-ID: <3bPBj1$mXq@openbazaar.net> Also make sure that your locale is not set to something useful - the default is usually 'C' which leave most of the locale parameters unset. Here is an example of setting the locale to en_US showing how it sets the various locale parameters: >>> >>> import locale >>> locale.setlocale(locale.LC_ALL) 'C' >>> >>> locale.localeconv() {'grouping': [127], 'currency_symbol': '', 'n_sign_posn': 127, 'p_cs_precedes': 127, 'n_cs_precedes': 127, 'mon_grouping': [], 'n_sep_by_space': 127, 'decimal_point': '.', 'negative_sign': '', 'positive_sign': '', 'p_sep_by_space': 127, 'int_curr_symbol': '', 'p_sign_posn': 127, 'thousands_sep': '', 'mon_thousands_sep': '', 'frac_digits': 127, 'mon_decimal_point': '', 'int_frac_digits': 127} >>> >>> locale.setlocale(locale.LC_ALL, 'en_US') 'en_US' >>> >>> locale.localeconv() {'grouping': [3, 3, 0], 'currency_symbol': '$', 'n_sign_posn': 1, 'p_cs_precedes': 1, 'n_cs_precedes': 1, 'mon_grouping': [3, 3, 0], 'n_sep_by_space': 0, 'decimal_point': '.', 'negative_sign': '-', 'positive_sign': '', 'p_sep_by_space': 0, 'int_curr_symbol': 'USD ', 'p_sign_posn': 1, 'thousands_sep': ',', 'mon_thousands_sep': ',', 'frac_digits': 2, 'mon_decimal_point': '.', 'int_frac_digits': 2} >>> >>> s = '123,456,789.2' >>> s '123,456,789.2' >>> locale.atof(s) 123456789.2 >>> richard_chamberlain wrote: > > Hi William, > > Yes you could use the locale module to do what you want: > > import locale > s="123,456,789.2" > print locale.atof(s) > > As Bjorn said you'll have to get the locale module from somewhere. > > Otherwise do something like below: > > import string > def rcatof(num): > try: > flt=float(string.replace(num,',','')) > return flt > except: > return None > > >>> import myScript > >>> myScript.rcatof('123,456.2') > 123456.2 > > Richard > > William Dandreta wrote in message > news:yUqb5.977$tI4.52638 at bgtnsc05-news.ops.worldnet.att.net... > > I am having a problem with the atof function. I tried to convert 1,142.00 > to > > a float but the comma causes a problem. I resolved the problem by removing > > the comma but there must be a better way. > > > > I looked in the documentation and there was mention of the $LANG > > environmental variable but it did not tell haw to use it. Also, it > mentioned > > settings could be made using the functions in locale module. I tried to > > import the locale module but I get an error message that the _locale > module > > doesn't exist. > > > > Anyone have a clue about this? > > > > Bill > > > > -- +----------------------------------------------------------------------+ | Rod Haper, Senior Systems Analyst | Neles Automation | | Phone: 713-346-0652 - direct | SCADA Solutions, Inc. | | 713-939-0393 - fax | 7000 Hollister | | Rod.Haper at sage.nelesautomation.com | Houston, Texas 77040, USA | +----------------------------------------------------------------------+ From baron at null.net Sat Jul 8 00:51:06 2000 From: baron at null.net (Matthew Schinckel) Date: Sat, 8 Jul 2000 14:21:06 +0930 Subject: Making tabs illegal In-Reply-To: <8k5l8d$9lr$1@nnrp1.deja.com> References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: On Fri, 7 Jul 2000, Forrest Cahoon wrote: > In article <3950C0E2.7532D38 at sightreader.com>, > Ken Seehof wrote: > > [ ... ] > > > > As for the space/tab mixing issue, the answer is simple: Make tab an > > illegal character in python. Problem solved. > > Ugh! Don't make this the default - I hate having to hit space four times, I'd much rather just use tab. -- Matthew Schinckel ARCHDUKE FERDINAND FOUND ALIVE -- FIRST WORLD WAR MISTAKE From 340083143317-0001 at t-online.de Tue Jul 18 16:34:10 2000 From: 340083143317-0001 at t-online.de (Thomas Malik) Date: Tue, 18 Jul 2000 22:34:10 +0200 Subject: Newbie question: PyOpenGL installation References: <3bRNNT$lvY@openbazaar.net> Message-ID: <8l2emv$583$13$1@news.t-online.com> > > * install python-numpy-15.3-1.i386.rpm from > http://download.sourceforge.net/numpy/python-numpy-15.3-1.i386.rpm > > * grab pyOpenGL from CVS using the instructions on > http://www.pythonpros.com/cvs.html > That's quite old, the actual PyOpenGL is now on http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/?cvsroot=PyOpenGL cheerio Thomas From ulrich.schreiner at innuendo.de Sat Jul 29 05:05:33 2000 From: ulrich.schreiner at innuendo.de (Ulrich Schreiner) Date: Sat, 29 Jul 2000 11:05:33 +0200 Subject: "always passes by reference" References: <8lqd0p$snj$1@news.dtc.hp.com> <8lqiq3$7iha$1@nntp6.u.washington.edu> <8ls8bm$cde$1@news.dtc.hp.com> Message-ID: <39829E5D.45357D37@innuendo.de> it is all so easy, so why this big discussion? you have ONE and exactly ONE object identity, but you can have multiple references to this identity. in your program you always work with references. if there is no reference your object (the identity) will be GC'd. if your object is immuatable you do not have a chance to change its value, but this is a completely different discussion. how do you call this python style of argument passing? i really don't care. but i find it normal and i do not have any problems with it, although i'm relatively new to python (half a year). the people having problems with this sort of "passing references to perhaps immutable object identities by value" have this problems with any language. i saw really terrible java code from so called "java experts" (sun employees!!!) and these guys have a big problem with their understandig of java's argument passing style. but they don't know this ... ;-) it is really always the same. and it is really very very very simple :-)) "(Greg Weeks)" wrote: > PS to all: Once you distinguish between a word and a writing of a word, the > remaining question is whether you prefer to define an "object" as 1) a > region of memory or 2) an address. #2 may grate on your intuition, but > otherwise it simplifies discussions of what is happening. > > You might say that I (and others!) simply use the term "object" when other > people say "reference". That is almost true. But the people who like the > term "reference" also say that there can be several references to a single > object. This is confused. If an object is a region of memory, it has only > one address. So if there are multiple references, then a "reference" is a > *writing* of an address. I find it confusing to have an expression for a > writing of a word but not for the word itself. From to_get_my_address at see.my.signature Wed Jul 26 22:47:27 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 15:47:27 +1300 Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: <397FA2BE.14B34022@see.my.signature> Huaiyu Zhu writes: > > 3. If there could be future calculus of operators, would we now > favor (*)= or (*=) for augmented assignment? Depends on whether you want to elementwise multiply and assign, or multiply and assign elementwise :-) I'm sure the people who favour + and .+ doing different things will be able to come up with some subtle difference between these, and argue for having both... -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From mckim at bandersnatch.lerc.nasa.gov Tue Jul 25 16:23:10 2000 From: mckim at bandersnatch.lerc.nasa.gov (Jim McKim) Date: 25 Jul 2000 16:23:10 -0400 Subject: perl to python, case + regular expression question Message-ID: I'm looking at adopting python for a project. Until now, most of my experience has been in perl. Right now I'm cramming python. I've got a question about what would be a good way in python to express an operation that needs to be done fairly often in this project. The operation (parsing log files) in perl would look like: if ($input_line =~ /^log entry (\d+)/) { my $log_entry_num = $1; ...etc. } elsif ($input_line =~ /^run number (\d+) timestamp (.*)/) { my $run_number = $1; my $timestamp = $2; ...etc. } ... The best way I've been able to come up with in python is to execute a re.search() method twice, once in the if statement, and then again in the block following the if statement to obtain the match object. Something like: if re.search('^log entry (\d+)', input_line): match = re.search('^log entry (\d+)', input_line) log_entry_num = match.group(1) ...etc. ... Having to do the search twice looks cluttered and wordy. It probably isn't efficient. It doesn't enhance maintainability. Is there a better way? -- Jim McKim NASA Glenn Research Center From jkraska1 at san.rr.com Mon Jul 10 21:53:36 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 11 Jul 2000 01:53:36 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> Message-ID: <396A7ECC.730B84D@san.rr.com> > >And all Java is is a variant of the C++ language with the kitchen > >think glued on and the label changed. Hence the ridiculousness of > >the claim. Sun would be stupid to even try. > Nope. Microshit is stupid to even try to copy Jva. Thank goodness for the world you're not in the intellectual property business, eh? (HINT: take a peek into Sun's intellectual property claims regarding Java before you claim what they can sue for). C/ From news at heitlager.com Wed Jul 12 06:07:08 2000 From: news at heitlager.com (Ilja Heitlager) Date: Wed, 12 Jul 2000 12:07:08 +0200 Subject: win32com: How to use optional parameters? References: <8ket8e$nj6$1@spectra.a2000.nl> <8kf3i4$1gu$1@spectra.a2000.nl> <8kft89$rnd$1@news2.acs.oakland.edu> Message-ID: <8khfuj$qp$1@tesla.a2000.nl> >why not hold the places like this: > >xl.Worksheets.Add(NULL,NULL,NULL,aftervaluehere) NULL is not a keyword in Python, but if I used pythoncom.Empty instead It worked thanx Marc Hammond suggested I changed the top few constants from "pythoncom.Missing" to "pythoncom.Empty" in the .py generated by makepy. Which works if beter, bexuase I can use the named parameters >just as if you weren't using the "parametername=varnam" syntax, even VB >would default to the order the function expects the calls. Now both work. > >Another sure way to find out would be to generate the MIDL for the excel VBA >you are coding, then you could do the same thing in C/C++ COM which would >most certainly require the correct order of parameters and not named >parameters in any order. Don't understand this, but sound complicated. Since Python, C/C++ is not an option for me anymore ;-) From mksql at my-deja.com Thu Jul 6 16:21:12 2000 From: mksql at my-deja.com (mksql at my-deja.com) Date: Thu, 06 Jul 2000 20:21:12 GMT Subject: Win32com ADO curiosity #1: MoveNext Message-ID: <8k2pnc$f64$1@nnrp1.deja.com> In the following code (rs refers to an ADO recordset already created): print rs.Fields(1).Value rs.MoveNext print rs.Fields(1).Value prints the same record twice, while: print rs.Fields(1).Value rs.MoveNext() print rs.Fields(1).Value prints 2 records, as expected. Why does MoveNext require the () ? The ADO object model does not specify parameters for MoveNext, MoveFirst, etc. Sent via Deja.com http://www.deja.com/ Before you buy. From neelk at brick.cswv.com Sat Jul 22 09:23:50 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 22 Jul 2000 13:23:50 GMT Subject: Discussion: new operators for numerical computation References: <8l7c80$mlc$1@tomm.stsci.edu> <8lb6jb$vj9$1@slb6.atl.mindspring.net> Message-ID: Aahz Maruch wrote: > In article , > Ben Caradoc-Davies wrote: > > > >The fact that APL has been mentioned in this thread is a bad, *bad* sign. > > Yeah, that's my feeling, too. It's not entirely clear to me why we > can't use some kind of string-based expression mechanism instead of > adding all this at the language level. Python's brilliance is its > *clean* syntax. Why are we mucking with the core language for this? We do need to muck with the language to fix this, but the answer is NOT to add syntax, but to remove the type/class dichotomy. Then it will be possible to do something to fix the __mul__/__rmul__ thing so it's actually usable. My proposal would be to replace it with encapsulated multimethods, because that's the best way of solving the binary method problem in an OO language. This is really the key problem people face: Elementwise and matrixwise multiplication are easy to implement, but doing it so that Python calls the right one at the right time, in a way that you can still extend the system with new subclasses, is hard. Neel From olivierS.dagenaisP at canadaA.comM Mon Jul 3 10:42:00 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 03 Jul 2000 14:42:00 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: How about a batch file called p.bat ? (with optional status messages) -----start p.bat-------- @echo off echo Starting script '%1.py' .... c:\progra~1\Python\python "%1.py" %2 %3 %4 %5 %6 %7 %8 %9 echo Execution complete! ----end p.bat----------- Given you have a script called "spam.py": -----start spam.py------ print "Spam spam spam spam" -----end spam.py-------- Then, you would type: c:\work\python\stuff>p spam Starting script 'spam.py' ... Spam spam spam spam Execution complete! Is that what you wanted?? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neo Brave" wrote in message news:8jp3pt$q7j$1 at nnrp1.deja.com... > In article , > "Mark Hammond" wrote: > > Under Windows NT or Win2k, you can use the PATHEXT environment > > variable. Simply add ".py" to the semi-colon sep'd list of > > extensions, and off you go! > > Great, thats a help for NT, but I also want to do this on Win98 :-). > > > No solution I am aware of for 95, although there are some tricks > > you can pull (Im sure someone else will fill these in for you)! > > Anyone??? > > Neo > -- > Neo Brave > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From paul at prescod.net.bbs Mon Jul 17 20:20:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 18 Jul 2000 00:20:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operatorsfo Message-ID: <3bRUP3$kW4@openbazaar.net> Huaiyu Zhu wrote: > > ... > > That's a good point. Can __getattr__ be made to work only on a selected > number of attributes? We could use it on T, H, I, C for transpose, > Hermitian transpose, inverse and conjugate. But if it works on all the > undefind members the error message may be too obscure. I don't think you need __getattr__ class Matrix: def __init__( self, ....): self.T=Transpose( self ) self.H=Hermitian( self ) self.I=Inverse( self ) self.C=Conjugate( self ) self.E=Elementwise( self ) self.M=self # matrixwise is default ... other matrix-like methods ... class Transpose: def __init__( self, mymatrix ): self.mymatrix=mymatrix ... other matrix-like methods, but transposed ... Notice that no computation (e.g. actual transposition) needs to be done until you actually need to calculate a value. Maybe you can find optimizations that allow only tiny parts of matrices to be computed. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From g2 at seebelow.org Mon Jul 31 14:30:01 2000 From: g2 at seebelow.org (Grant Griffin) Date: Mon, 31 Jul 2000 19:30:01 +0100 Subject: The State of Python References: <39817536.FDBC508D@hursley.ibm.com> <87g0ota6fo.fsf@psyche.evansnet> <3985424E.90C4AC49@hursley.ibm.com> Message-ID: <3985C5A9.21FB@seebelow.org> Paul Duffin wrote: > ... > Does this mean that it is possible to create a GPL version of Python ? > > If so then this would result in a split as patches submitted under the > original license could be merged into the GPL version but the reverse > direction would not be allowed, otherwise they would both end up a GPL. Ya' know...this whole nutty GPL thing is beginning to sound a lot like a venereal disease. (Kids, be sure to protect yourselves. ;-) (abstinence-is-the-ultimate-protection-)-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 zo at angband.org Sat Jul 29 13:54:16 2000 From: zo at angband.org (Eric Lorenzo) Date: 29 Jul 2000 13:54:16 -0400 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: <3h7la4bz5j.fsf@angband.org> Steffen Ries writes: > grey at despair.rpglink.com (Steve Lamb) writes: > > On Fri, 28 Jul 2000 19:29:52 -0400, Karl Ulbrich wrote: > > >If they already contained numbers (well, strings of digits), and > > >you were certain, then simply: > > > > > a = int(b) > > > > As stated, that would work except Python returns a None on a > > no-match and None can't be converted. > > use: > a = int(b or 0) > then. Steve's entire die-parsing problem could be cleaned up with the tip above, and a better regexp. I can't see any good reason for him to put the modifier's sign into a seperate group from the digits, and I can't see any reason to use two big regexps then the two forms of expression (with or without modifier) vary by only a bit at the end. How about this: import re parse_die_re = re.compile('^(\d{1,2})[dD](\d{1,3})([+-]\d{1,3}|)$') def parse_die(s): try: g = parse_die_re.match(s).groups() except AttributeError: raise ValueError('Not a valid die expression') return int(g[0]), int(g[1]), int(g[2] or 0) This the always generates 3 groups, the last one being an explicitly signed integer when there's a modifier present, and the empty string otherwise. Since the empty string behaves as a boolean false, the 'g[2] or 0' thing works. The interesting thing about this is that it's actually an example of Python behaving the way that Steve says it doesn't (but should): g[2], a string, is treated like a boolean when used with the boolean operator 'or', but goes back to being a string once the result of that expression gets passed into int. If Python was *really* as completely anal-retentive about types as he thinks, there would be a BooleanType, and the 'or' operator would choke on both the string and the integer. Eric From bill at dehora.fsnet.co.uk Fri Jul 28 18:50:11 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Fri, 28 Jul 2000 23:50:11 +0100 Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: <8lt3pm$bgg$3@newsg4.svr.pol.co.uk> > By the way, does BeOpen have anything to do with > the BeOS people? If not, it would seem to be a > rather confusing choice of name. I don't understand why BeOS chose that name either. From db3l at fitlinxx.com Wed Jul 12 15:07:21 2000 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jul 2000 15:07:21 -0400 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> <8kft65$rnc$1@news2.acs.oakland.edu> Message-ID: "Neil Hodgson" writes: > So, I'll repeat Richard's code and copy it to your email in the hope that > telia is better at email than usenet. > > import win32api,string > > drives=win32api.GetLogicalDriveStrings() > drives=string.splitfields(drives,'\000') > print drives > > Looks like it gets one too many elements - the last is empty. That's due to the definition for GetLogicalDriveStrings() - it returns a string of NUL-terminated drive names back to back, and the overall list is terminated with another NUL. So if you split on the NUL, you'll always have an empty string at the end. -- -- 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 schneider-kamp.de Thu Jul 20 04:53:11 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Thu, 20 Jul 2000 08:53:11 +0000 Subject: questionnaire about zip and for loops Message-ID: <3976BDF7.82FB6C56@schneider-kamp.de> This is a slightly reduced version of a questionnaire run by Greg Wilson on some CS grad students. I'd like to use the readers of comp.lang.python as guinea pigs this time. PLEASE SEND THE RESULTS TO mailto:peter at schneider-kamp.de - DON'T SEND THEM TO THE LIST Thanks for your time, Peter ----------------------------------------------------------------------------------------- The single and double loop below print the output shown: for x in [10, 20, 30]: for x in [10, 20, 30]: print x for y in [1, 2, 3]: print x+y 10 11 20 12 30 13 21 22 23 31 32 33 Match each of the following example for-loops to an output. Only make one cross per line. Please consider each example on its own. (Note that several examples may print the same thing.) (1) (2) (3) (4) (5) (6) 11 11 11 11 error ?? 22 12 22 12 33 13 21 21 22 22 31 23 32 31 32 33 (A) for (x, y) in [[10, 1], [20, 2], [30, 3]]: o o o o o o print x+y (B) for [x, y] in zip([10, 20, 30], [1, 2, 3]): o o o o o o print x+y (C) for [x, y] in zip([10, 20, 30], [1, 2]): o o o o o o print x+y (D) for x; y in [10, 20, 30]; [1, 2, 3]: o o o o o o print x+y (E) for x; y in [10, 20, 30]; [1, 2]: o o o o o o print x+y (F) for x in [10, 20, 30]; y in [1, 2, 3]: o o o o o o print x+y (G) for x in [10, 20, 30]; y in [1, 2]: o o o o o o print x+y -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From fiona at sitegnome.com Thu Jul 13 00:09:17 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 13 Jul 2000 04:09:17 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 13th, 2000 Message-ID: <20000713040917.10090.qmail@synop.com> Hi! Below are the latest entries into http://python.faqts.com cheers, Fiona Including: - What Python code can I use to find all the network ports that are in use on a server? - Can I use python to access web (eg.yahoo) email account? - Is there any way to find the mount point of a filesystem given the path to a file within the file system? - How can I create a wxBitmap image from a Python Imaging Library (PIL) image? - How can I compare two strings in a case-insensitive way? ## New Entries ################################################# ------------------------------------------------------------- What Python code can I use to find all the network ports that are in use on a server? http://www.faqts.com/knowledge-base/view.phtml/aid/4684 ------------------------------------------------------------- Fiona Czuczman Aaron Berg to figure out what ports are used on a server you could use netstat -a -n import os popen("netstat -a -n") ------------------------------------------------------------- Can I use python to access web (eg.yahoo) email account? http://www.faqts.com/knowledge-base/view.phtml/aid/4685 ------------------------------------------------------------- Fiona Czuczman Steve Purcell For web mail accounts that have POP access, such as Yahoo, check out the 'poplib' standard library module: http://www.python.org/doc/current/lib/pop3-example.html ------------------------------------------------------------- Is there any way to find the mount point of a filesystem given the path to a file within the file system? http://www.faqts.com/knowledge-base/view.phtml/aid/4686 ------------------------------------------------------------- Fiona Czuczman John Clonts I didn't find anything already extant, so here's this: def mountpoint(s): import os if (os.path.ismount(s) or len(s)==0): return s else: return mountpoint(os.path.split(s)[0]) def testit(): print mountpoint("/home/john/scheme/cmucl") print mountpoint("/usr/local") print mountpoint("/lib/") print mountpoint("lib") ------------------------------------------------------------- How can I create a wxBitmap image from a Python Imaging Library (PIL) image? http://www.faqts.com/knowledge-base/view.phtml/aid/4687 ------------------------------------------------------------- Fiona Czuczman Greg Landrum Here's some sample code: def PilImgToWxBmp(pilImg): wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1]) wxImg.SetData(pilImg.tostring()) bmp = wxImg.ConvertToBitmap() return bmp ------------------------------------------------------------- How can I compare two strings in a case-insensitive way? http://www.faqts.com/knowledge-base/view.phtml/aid/4688 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen import string if string.lower("FOO") == string.lower("Foo"): From grey at despair.rpglink.com Fri Jul 28 17:59:01 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 21:59:01 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> Message-ID: On 28 Jul 2000 20:11:42 GMT, Martijn Faassen wrote: >with your calculations. So you have to make sure your input is a number >*anyway* if you want to calculate things, so why not complain in the >first place when you run into something that doesn't seem to make sense. Because in some cases it does make sense. 1 + "1" makes sense. It is that grey area that causes problems. >Anyway, I'm sure we won't be able to budge each other from our >position on this. :) Prolly not. I can live with it. I don't like it, but once I know it is there I can deal with it and move on. My preferences are just elsewhere is all. >Yes, but in Python at least the program doesn't try to do things when you >forgot to check the user input properly. And that increases the chances >you'll find the bug in the first place. Which also increases the work for the programmer in case, which are in the vast majority, where he doesn't need to check input since there is no input. :) >> (/^(\d{1,2})[Dd](\d{1,3})$/ || /^(\d{1,2})[Dd](\d{1,3})([\+\-])(\d{1,2})$/) >I don't know what you mean here. I never do anything like that, I'm >happy to say. :) Extracting up to 6 match groups, 5 of which will be integers with the last being a + or a -. This means all groups can be either strings or None. I've already verified that groups 1-4&6 will be integers through the regular expression so why check again? To move these into ints on Python I needed to toss the whole lot of assignments into a try/except and do a pass on TypeError since you can't int() a None and Python doesn't like it when you try. Seems like there should be a cleaner way to be able to extrapolate digits out of a string with re and stuff them into variables with int() without having to toss it behind and if or try every time. I don't feel that is an uncommon occurance for anyone who might be taking numbers from plain text and wanting to perform math operations on them. >> Perl or Python, doesn't matter, you should be able to read it. >I'm not able to read it. Don't do much re work? ;) >I'd probably solve that in a more verbose way myself. My perl background shines through, eh? >So you're saying, since I know those particular groups are numbers anyway >by necessity, it makes no sense to require explicit conversion (with >int() in Python) to numbers of those things. I just want to use them >as numbers right away. Did I understand that correctly? Bingo. >As your program proceeds and for instance throws the dice, it'll try to use >those variables as numbers, but since they're other strings, you'll >eventually get strange answers (such as 0). And then presumably you'd have to >search what part of your program is wrong. In Python you'd know pretty >quickly that you got strings instead of numbers, and so you know what to fix. I know even faster in Perl. When testing RE I take a sample, toss it in an isolated script and build the regex until the expected results come forth. When that is done I test it against a much larger data set for any cases I may have missed. If errant data gets in after that time in Perl you have a script which runs but has some problems. In Python it pukes. In either case it happens outside your hands. When it comes to regex a properly defined regex will not let through abberant data. Esp. not when it comes to something as simple as digits \d versus words \w. >That wasn't the assumption. I said the exact opposite, you need to >remember what type your data is *anyway*. In order to do that you need >to check the data if it is input. On input. But for data generated internally this is not the case since you defined it from start to end. >This is a common misconception. *everything* in Python is always, always, >references. It is just that certain data types (integers, string, tuples) are >immutable; you cannot change them. So the semantics are the same as >copy semantics. Yes, technically it is always a reference. I know that in this case: a = 1 b = 2 a is a reference to an object, integer, that contains value 1 and b to an object, integer, that contains the value 2. What I meant was the difference shown below: >>> a = 1 >>> b = a >>> a = 2 >>> b 1 >>> a = [1] >>> b = a >>> del(a[0]) >>> b [] Forget, for a moment, what is happening internally. What looks like here is that in the first case there is an assignment going on and in the latter a reference. Nevermind that what is happening in the first case is a references objint[1] and b references objint[1] and when we change a it points to a new reference objint[2]. It is the difference in behavior of an identical operator that is ambigious. I'm sure even though I am aware that it happens I am going to be nailed by it a few times before I get used to it. >Isn't that worse than the program giving up? No. The program giving up in the customer's hands because of an unchecked except is a far cry worse than a nigglet but having it continue on. As a customer which would you rather have, given the choice of these two: a: A program that crashes, stopping everything that you're doing with no chance of recovery b: A program that behaves oddly but allows for chance of recovery. As a person who uses a lot of programs I'd rather have b which to me translates into, "Neat, how'd that happen. Oh, this is how. " instead of "*BOOM* WTF!! Dammit! Now I have to type that whole message in again!" >But you haven't; you haven't told the system it's a number yet. :) That's >the _only_ extra step you need to take. The system is too stupid to figure >it out very well on its own anyway, so why not tell the system explicitly? No, in my case I needed to check to make sure it was a type that can be converted to int and then do the actual conversion. That is two steps more than I deem needed considering the strictly checked input in the first place. >Interactive mode (I think it explains in the tutorial) gives you the output >of expressions as a result always. Right, which is worthless in a script. I'd personally have the Python check what mode it is in and toss an exception when it is in interactive mode and gets a meaningless statement. It does so on every other possible ambiguity, why not this one when it is even less grey than a lot of the ones I am tossing out? Is there a purpose for having such informative statements in non-interactive mode? >No, my entire point was that you need to know what your data is *anyway*. Right, I know what the data is, I don't need the language to ask me at every operation, "Are you sure? I mean, really, really, REALLY sure!?" >You need to know that something is an integer anyway, so why not simply >tell the computer what's going on? I'm *not* saying the language should >do the checking. It can't; even though Perl tries. Because what if I want to do something that the computer thinks is non-sensical? >checking. If you want the system to shut up about your mistakes, >you can always do this in Python: >try: > a = a + 1 >except: > pass Great, now I get to litter my code on a per operation basis with tries instead of being able to set it on certain variables. That would make more sense. >This works. I didn't need to tell the system that 'a' is a cow or a chicken >or an animal that can make sounds. Of course not, they are types. The variable gets it type at declaration, IE, assignment. >You can do that in Python too. I tend to prefer that as well. I also prefer the computer to trust me than mistrust me. >> Funny, we have implicit typing in OO code that causes problems later in >> the code. So yes in OO code. >What implicit typing? I don't understand what you mean at all. A variable gets its type upon assignment. That is implicit typing. >Yes, but if I'm not doing it properly at least the language will complain >so I get a broad hint I do need to do it properly. :) As well as if you're doing it properly the language will still complain long and loud. >Huh? Where in Python did you find your declarations? I'm confused. a = None int(a) a is declared as None at assignment. >Well, because it doesn't really make a lot of sense if you want to convert >something to an integer when Python can't figure it out. If you're so >sure of yourself, you can always do: > >try: > a = int(b) >except ValueError: > a = 0 Right, which is basically what I had to do except I left None as None. Just seems like a pain in the butt to do after I have allready made sure, beyond all doubt, that those variables contain numbers in the first place. >All right; this just doesn't happen very often in my code. Generally because >I can expect a certain regularity in my input. If my input is less regular >than I expected, I get exceptions. That gives me a nice indicator that my >expectations were off. Which is why for the base parsing routine I use re. If it doesn't pass re it doesn't get executed, period. People can try all they want to get around the regular expressions but it is really hard to do so. I don't see a reason to write my own test parsing routines when re does it for me. >In that case you don't need to do any checking, obviously. You have a >regularity in your data so you just do something like: >a = int(a) >Though I may be missing something about regular expressions here and >I'm goofing up? A regex could return a string or None, only one of which is convertable to int. You must litter your code with such checks. >Hm, why would you do that? Depends on the structure of your keys. You can >use numeric keys in your Python dictionary just fine. Text for information, numericals to prevent duplication. >But an integer can be seen as an object with methods as well. A string >too (Python 2.0 will actually allow you to use string methods). In fact, >I can make a new type of object in Python that behaves much like your >Perl scalars: Touche'. ;) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From ted.drain at jpl.nasa.gov Mon Jul 24 15:34:49 2000 From: ted.drain at jpl.nasa.gov (Ted Drain) Date: Mon, 24 Jul 2000 12:34:49 -0700 Subject: Embedding Example References: <397C6D55.6F7C@iems.nwu.edu> Message-ID: If you're building w/ gcc, add the link line option: -Wl,-E This says to pass the -E option to the linker. This option tells the linker to make all statically linked symbols available to the dynamic libraries. Without it, the symbols linked from libpython1.5.a aren't seen by symbols in the dynamic libraries. This really needs to be in the FAQ on embedding. Ted In article <397C6D55.6F7C at iems.nwu.edu>, "Leonardo B. Lopes" wrote: >I am trying to learn how to embed Python code in a C++ program. I got >the example from the docs (the one that imports sys and prints out a >couple of strings -- search from initxyzzy in google). The problem I get >is that if I try to import any non-built in module, I get dynamic >linking errors. For example, adding the following line 31 works: > >_______________________________________________________________________ >... > 29 /* Execute some Python statements (in module __main__) >*/ > 30 PyRun_SimpleString("import sys\n"); >--> 31 PyRun_SimpleString("import thread\n"); > 32 PyRun_SimpleString("print sys.builtin_module_names\n"); >... >_______________________________________________________________________ > >but adding the following line instead: > >_______________________________________________________________________ >... > 29 /* Execute some Python statements (in module __main__) >*/ > 30 PyRun_SimpleString("import sys\n"); >--> 31 PyRun_SimpleString("import random\n"); > 32 PyRun_SimpleString("print sys.builtin_module_names\n"); >... >_______________________________________________________________________ > >produces: > >_______________________________________________________________________ >[lopes at groucho lopes]$ ./demo >Hello, brave new world > >Traceback (innermost last): > File "", line 1, in ? > File "/usr/lib/python1.5/random.py", line 22, in ? > import whrandom > File "/usr/lib/python1.5/whrandom.py", line 140, in ? > _inst = whrandom() > File "/usr/lib/python1.5/whrandom.py", line 46, in __init__ > self.seed(x, y, z) > File "/usr/lib/python1.5/whrandom.py", line 58, in seed > import time >ImportError: /usr/lib/python1.5/lib-dynload/timemodule.so: undefined >symbol: PyExc_IOError >('__builtin__', '__main__', 'imp', 'marshal', 'pcre', 'posix', 'regex', >'signal', 'sys', 'thread') >['xyzzy', 'os.path', 'os', 'exceptions', '__main__', 'posix', >'whrandom', 'sys', '__builtin__', 'site', 'random', 'signal', >'UserDict', 'posixpath', 'stat'] >./demo >['./demo'] >_______________________________________________________________________ > >I can imagine that for some reason there is some directory configuration >missing to the interpreter when I start it embedded. How would I pass it >this info? > >Thanks! >Leo. > > > -- Ted Drain Jet Propulsion Laboratory Ted.Drain at jpl.nasa.gov From fbochicchio at galactica.it Sat Jul 29 22:55:38 2000 From: fbochicchio at galactica.it (Francesco Bochicchio) Date: Sat, 29 Jul 2000 19:55:38 -0700 Subject: The 'widget' demo with python/Tkinter Message-ID: <3983992A.75270197@galactica.it> [ This lengthy post is separated in three pieces. Feel fre to skip the uninteresting one ] Hello everybody, --------------/begin :-) I've just bought and read (most of) 'Programming Python', after reading some good reporting of Python in the news ( mostly the special in 'Linux Journal'). I must admit that currently I' in love with Python. I show all signs : I can't separate from it and I talk about it to any collegue willing to listen ( and to several willing NOT ). [ BTW : this love started in the Netherlands, where I occasionally trip for my current job : is something in the air ? ] -------------/end :-) ------------/begin success story Anyway, when my customer asked if it was possible to quickly implement a specific MMI program, to be platform-independent and to be ready in 2 months, I jumped on the occasion of using Python/Tkinter for it ( to be honest, it was also because I knew of the wanderful Canvas widget that TK has, which will be the core of my program, which is a sort of 'data display builder' ). After a week, I already hacked significant parts of it, and I'm sure that I took a good decision. -------------/end success story -------------/begin question I'm looking forward to the close three-weeks vacation period to improve my knowledge of Python/Tkinter. So I thought of duplicating the classic 'Widget' demo,which ships with TK and which I also found in a Perl/Tk version. Did anybody already wrote it ? I looked hard in Python and Tk documentation and samples and didn't find it. When I started with Python/Tk, I would have greatly appreciated something like this ( actually, I looked a lot at Tk version of it to learn about TK ). So I am willing to give it to the masses ( If I'm able to finish it ). Or do you think that the other demos are enough ? Any feedback will be appreciated. ----------------/ end question Ciao -- FB From denalione at my-deja.com Tue Jul 11 13:23:24 2000 From: denalione at my-deja.com (Dale Burnett) Date: Tue, 11 Jul 2000 17:23:24 GMT Subject: checking the existence of a fiel References: Message-ID: <8kfl5m$skq$1@nnrp1.deja.com> In article , "Fernando Rodr?guez" wrote: > Hi! > > How can I check if a file exists? O:-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez > > os.path.isfile() Sent via Deja.com http://www.deja.com/ Before you buy. From richard_chamberlain at my-deja.com Mon Jul 3 09:44:19 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Mon, 03 Jul 2000 13:44:19 GMT Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> Message-ID: <8jq5bf$h45$1@nnrp1.deja.com> Hi Thomas, I'm sure there's a nicer way to do it (I'll ponder on it), but... from Tkinter import * root=Tk() def hideMe(): myButton.configure(text="",relief=FLAT) myButton=Button(root,text="Hide Me!",command=hideMe) myButton.pack() root.mainloop() You could pass the widget reference to the method so it would be universal - bit of pain to reverse though! Richard In article <3960794E.6E2B36E6 at muc.das-werk.de>, thiele at muc.das-werk.de wrote: > How can I realize that a set of widgets (buttons and entries) > is invisible when I don't need them and visible when I need them? > > One solution is to create a dialog window (or frame) and destroy it > then. > But is there a better one? > > Withdrawn works only with top level widgets. > > Thanks Thomas > Sent via Deja.com http://www.deja.com/ Before you buy. From fcahoon at my-deja.com Mon Jul 10 09:41:46 2000 From: fcahoon at my-deja.com (Forrest Cahoon) Date: Mon, 10 Jul 2000 13:41:46 GMT Subject: Making tabs illegal References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> <20000708005527.L26534@xs4all.nl> Message-ID: <8kcjqn$k7v$1@nnrp1.deja.com> In article <20000708005527.L26534 at xs4all.nl>, Thomas Wouters wrote: > [ ... ] > Guido's time machine strikes again ! I'm not sure how far back he went this > time, but certainly well before I did anything with Python ;) There's the > -t flag which does exactly what you want: '-t' warns when tabs and spaces > are mixed in a dangerous way. '-tt' emits a compile-time exception. > [ ... ] I have heard of the -tt flag, but I don't think that's exactly what I'm looking for. I'd like to enforce spaces and disallow tabs altogether. (What does "mixed in a dangerous way" mean, anyway?) I'm not suggesting that python the language be changed this way -- I would, but I don't think my suggestion would get very far -- what I *am* suggesting is that I should be able to compile a version of the python interpreter that only allows spaces. The issue is being able to enforce a particular coding style in a development environment. For that reason, it's better to have it compiled in than to be a command-line switch. Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Mon Jul 10 15:38:51 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 10 Jul 2000 21:38:51 +0200 Subject: Circular reference problem -- advice? In-Reply-To: <396A1EC6.6738CFCC@alcyone.com>; from max@alcyone.com on Mon, Jul 10, 2000 at 12:06:46PM -0700 References: <396A1EC6.6738CFCC@alcyone.com> Message-ID: <20000710213850.O26534@xs4all.nl> On Mon, Jul 10, 2000 at 12:06:46PM -0700, Erik Max Francis wrote: > I've come across a problem due to circular references, and I'm not sure > what's the best way to tackle it. In essence, the problem is that I > need a particular class to keep an associative array of its methods for > a lookup table (it's essentially a dispatcher). But with references to > its own bound methods, Python's garbage collector concludes it has > circular references and thus its destructor never gets called. > For the application I need, it's imperative that the destructor get > called. What is the best way to solve this? I can think of a few: > - Move the map to a local variable in the dispatching function > - Make map a lookup table of _unbound_ methods > - Build a string of the function call and then exec it Instead of calling exec, you're better off calling 'apply': apply(self, method, args) (where 'method' is a string containing the method name, and args is a tuple (or other sequence) containing the desired arguments. Alternatively, you can keep the current setup, and manually break the circular reference before you delete the last reference to the object. You can sometimes do this automatically by using a container object (one that *doesn't* have a cirulcar reference ;) that has a __del__ that breaks the cirulcar reference. > What would be the most effective way of getting around this? I'm > thinking that using unbound methods would probably be the best way. You can use self.__class__.__dict__ as a convenient index to attributes on the class, and then 'apply(self, method, args)' to call the bound variants of those. No circular references involved, though it might not fit your need. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From kellyk at my-deja.com Mon Jul 31 16:53:14 2000 From: kellyk at my-deja.com (kellyk at my-deja.com) Date: Mon, 31 Jul 2000 20:53:14 GMT Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> <8lrvae015nm@news2.newsguy.com> <3981D157.D7A1A347@intel.com> <8lspqe02drs@news2.newsguy.com> Message-ID: <8m4ovo$g1s$1@nnrp1.deja.com> It would be nice to be able to do permanent connections. The reference for WNetAddConnection2 says the last parameter is a flag to indicate whether or not the connection is to be permanent. The win32wnet source looks like it's hard coded to temporary. Kelly In article , "Mark Hammond" wrote: > win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, "Z:", > "\\\\brat\\c", None, None, None) > > The params are: > Integer Type, // RESOURCETYPE_DISK, RESOURCETYPE_PRINT, or > RESOURCETYPE_ANY > String LocalName, // String or None > String RemoteName, // String (required to be in network format > String ProviderName,// String or None > String Username, > String Password) > > Mark. Sent via Deja.com http://www.deja.com/ Before you buy. From stephen at cerebralmaelstrom.com Wed Jul 5 13:45:27 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 17:45:27 GMT Subject: "Write to a file" question please? References: Message-ID: I *think*... Print is a statement that lets you print out multiple things using the comma, the 'write' function does not work the same way. It takes a string argument and writes it out to the file. To accomplish what you want, you can use the module operator (there's other ways too, but its my favorite :)) number = 100 print "Number = %s" % number OUT = open("TT.txt",'w') OUT.write("Number = %s" % number) OUT.close() If you have more then one number you're writing out, make the right-operand of the modulo operator a tuple.. E.g. num1 = 100 num2 = 500 print "Number 1 = %s and Number 2 = %s" % (num1,num2) See? :) --Stephen wrote in message news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() > > The code above gives the error. > > Traceback (innermost last): > File "ttest.py", line 5, in ? > OUT.write("Number =", number) > TypeError: read-only buffer, tuple > > OUT.write("Hello World") > > Works but a number or variable of a number does not. > > I have been reading documents on Python to no avail this time. > I am using Win98 with the latest python for this OS. > > Any help would be much appreciated > E-mail me at cmfinlaySPAM at magnet.com.au > or reply here. From bjorn at roguewave.com Mon Jul 17 14:27:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 17 Jul 2000 12:27:31 -0600 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> Message-ID: <39735013.1AE68176@roguewave.com> Charles Boncelet wrote: > > (Huaiyu Zhu wrote a proposal for adding special linear algebra > operator to Python) > > This proposal has been dismissed by many on this list (my > paraphrasing) > "because we don't want to pollute Python with new symbols/syntax > for just one problem domain." Some have dismissed linear algebra > as a small domain at that. > > Let's get some facts (yes, I know we are not supposed to let facts > interfere with our arguments on usenet): [severe case of non sequitur snipped] Perl, C++, Visual Basic, Java, and probably also Tcl are all more popular than Python. Are you suggesting we should add their special syntaxes/quirks just because a lot of people know them? hrmph! -- bjorn From shuz at bresnanlink.net.bbs Wed Jul 12 03:00:01 2000 From: shuz at bresnanlink.net.bbs (shuz at bresnanlink.net.bbs) Date: 12 Jul 2000 07:00:01 GMT Subject: Sound module question Message-ID: <3bN7j1$m1k@openbazaar.net> I have already tried that. I need to record sound in a time sensitive eviroment. I will most likely need to write my own sound module which I really don't want to do...because I don't know where to start with that either. I have this really simple program called sound-recorder that has simple read and write but in order to stop a recording the person needs to do ^c (ctrl + c) how would I start that program in a thread and be able to stop it at a certain point using ctrl + c? A sound module for python would probably be the best solution still. I guess that is a better description of my problem... Thanks for the idea though, Aaron pehr anderson wrote: > I've started mucking around with sound and have > seen the os.system command work well for most of my needs. > > import os > os.system("esdplay file.wav") > > Redhat and Gnome like to use the Enlightenment sound daemon. > NOTE: It isn't always started by default. > To start the daemon just run "esd" as the user (you don't need to be > root). > The RPM included with Redhat-6.2 is esound-0.2.17-2.i386.rpm > > I've upgraded my system with Helix gnome so my esound rpm is > esound-0.2.18-1_helix_1 > > Esound includes the the "esdctl" command to cache wav files > for quick playback or looping. If you run these through os.system > that should be fast enough for most of your needs. I'm sure there > are better ways to talk to the esound daemon, but this was *very* easy. > > Here is the help for esdctl: > > [pehr at morseall pehr]$ esdctl > esdctl error (1): command line - not enough arguments > esdctl [options] [command] > > options: > -s, --server=host:port contact esd server on host at port > > commands: > lock foreign clients may not use the server > unlock foreign clients may use the server > standby, off suspend sound output for other programs > resume, on resume sound output > cache sample cache a sample in the server > getid name retrieve a sample id from its name > free name uncache a sample in the server > play name play a cached sample once > loop name make a cached sample loop > stop name stop the looping sample at end > serverinfo get server info from server > allinfo get player and sample info from server > panstream set panning for a stream > pansample set default panning for a sample > - left/right pan values scaled to 256. > standbymode see if server's on standby, etc. > > Aaron Berg wrote: > > > > I started programming python a few months ago and I am still learning. > > Does anyone know of a sound module for simple reading and writing of > > sound in linux? I know there is a win32 sound module and there is one > > for SGI but is there one for linux? oss or alsa... I don't know much > > about this issue so it is possible i am just looking in the wrong place. > > Thanks, > > Aaron From richard_chamberlain at ntlworld.com Mon Jul 17 16:42:39 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Mon, 17 Jul 2000 21:42:39 +0100 Subject: Multiline strings and indentation References: <39736250$0$14722@wodc7nh6.news.uu.net> Message-ID: Hi Jen, How about: def multiline(x): if x: print "this is a" \ "multi-line string that spans" \ "three lines" \ print "another string" Richard donotspam-jen at personic.com wrote in message news:39736250$0$14722 at wodc7nh6.news.uu.net... > I'm just getting started with Python. The indentation feature really does > make things readable ... except when using multi-line strings. This just > doesn't look right: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Is there a way to make the above more readable? It would be nice if it could > be written this way and have Python just figure out what whitespace to > ignore: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Thanks for any suggestions! > > Jen > > From falk.lehmann at gmx.net.bbs Tue Jul 18 00:50:03 2000 From: falk.lehmann at gmx.net.bbs (falk.lehmann at gmx.net.bbs) Date: 18 Jul 2000 04:50:03 GMT Subject: compiling Python 1.6a2 using VC++ 6.0 Message-ID: <3bRbQR$m5X@openbazaar.net> I try to compile Python 1.6a2 on a WinNT box using VC++ 6.0. All packages except bsddbmodule and socketmodule compile without errors. When I add the include path of the the db-3.1.14 distribution to ..\db-3.1.14\build_win32 the following error messages appear. I have tried to include other header files then db.h but nothing works. ================================================================= K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2065: 'HASHINFO' : undeclared identifier K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2146: syntax error : missing ';' before identifier 'info' K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2065: 'info' : undeclared identifier K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(95) : error C2224: left of '.bsize' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(96) : error C2224: left of '.ffactor' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(97) : error C2224: left of '.nelem' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(98) : error C2224: left of '.cachesize' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(99) : error C2224: left of '.hash' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(100) : error C2224: left of '.lorder' must have struct/union type ... ... ========================================================== Any help is appreciated. Falk Sent via Deja.com http://www.deja.com/ Before you buy. From fbochicchio at galactica.it Sun Jul 30 02:49:36 2000 From: fbochicchio at galactica.it (Francesco Bochicchio) Date: Sat, 29 Jul 2000 23:49:36 -0700 Subject: The 'widget' demo with python/Tkinter References: <3983992A.75270197@galactica.it> <290720001444536008%matt@mondoinfo.com> Message-ID: <3983D000.55110EEE@galactica.it> Matthew Dixon Cowles wrote: > > In article <3983992A.75270197 at galactica.it>, Francesco Bochicchio > > Dear Francesco, > I'm not familiar with the particular demo that you mention Usually in /usr/lib/tk8.0/demo/widget. It's a demo program that systematically goes through all the features of Tk. > but I'm sure that more Tkinter demo code and documentation would always be > useful. > If you haven't seen it already, you might find Fredrik Lundh's > introduction to Tkinter worth a look. It's at: > > http://www.pythonware.com/library.htm > > I certainly find it useful. As far as I'm aware, it's the current state > of the art in Tkinter documentation. > I also found it very useful ( though it seems still a work in progress ). -- FB From hzhu at users.sourceforge.net Wed Jul 26 19:34:53 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 26 Jul 2000 23:34:53 GMT Subject: Operators for everything (was Re: Operators for matrix) References: <397CB3EA.15F5514F@prescod.net> <200007250053.RAA03842@rocket.knowledgetrack.com> <397CFDAC.38A22DAF@prescod.net> Message-ID: On Mon, 24 Jul 2000 21:38:36 -0500, Paul Prescod wrote: >> >> If @add does not need to be hard coded in C, why @+ need so? > >Neither needs to be hard-coded into the grammar. The parser could always >recognize them from the leading @-symbol. This is different from your >earlier proposals where *any sequence of symbols* could be an operator. >That's quite different. Although the patch I got adds a set of operators with different symbols, it has always been clear that one generic way of adding new operators is more preferable, as these operators are very similar to existing math operators. >Nevertheless, I would be extremely reluctant to add a feature that would >encourage people to do @++, @-- @+* and so forth. @increment is not so >bad. @decrement is not so bad. @positive_mul (whatever that might mean >in some particular domain) is not so bad. I don't think many people are proposing these complicated operators as math operators. The main criteria is that they look as similar to the existing math operators as possible. >I think name-based binary operators are actually pretty neat and can be >used very Pythonically. IMO, they are the right compromise between >terseness and legibility. For math operators the @id form looks too heavy. Compare the following two: (1 @add 2) @mul 3 @sub 4 == (10 @div 2) @pow 1 (1+2)*3 - 4 == (10/2)**1 The symbol @ does not work out well with symbolic operators, either. In tightly written code, like abc at +def, the @ is visually associated with the preceding identifier rather than the operator. The alternative ~op looks much more familiar: (1~+2)~*3 ~- 4 == (10~/2)~^1 But since this is the "operator for everything" thread, may I suggest using ~+ ~- ~* ~/ operators for math, and @name @identifier operators for everything else? The parser would have similar difficulty recognizing either form. Only two opcodes need to be added, one for ~op, another for @id, instead of one for each of the new operators. I do not know about the run time efficiency. But since current + can be overloaded with operator.__add__, I would imagine that in terms of efficiency, ~op can be made to be similar to existing operators, while @id is similar to existing function calls. Huaiyu From etoffi at softhome.net Sun Jul 2 03:33:12 2000 From: etoffi at softhome.net (etoffi) Date: Sun, 02 Jul 2000 03:33:12 -0400 Subject: mailman stuff Message-ID: <395EF038.D8CEBD92@softhome.net> visiting this page will print out the same thing 3 times. just thought someone would like to know http://www.python.org/mailman/subscribe/python-list/ From gherman at darwin.in-berlin.de Fri Jul 14 05:24:40 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Fri, 14 Jul 2000 11:24:40 +0200 Subject: Test writing volunteers needed References: <14700.44683.572283.391037@beluga.mojam.com> Message-ID: <396EDC58.8A60673D@darwin.in-berlin.de> "A.M. Kuchling" wrote: > > Skip Montanaro wrote: > >I'm look for a few people to write some regression tests for the posix (and > >windows or mac equivalents), os and sys modules. Some of that functionality > > To start the ball rolling, here's a little test case for the set{re,e}{u,g}id > functions that I added to the CVS version last night. What about using the excellent Python unittest module (pyunit.sourceforge.net) to accomplish this, like in the code below? Note that I've not tested it on a Unix box and suppose the calls to some get* functions look in lines with trailing '# ??' do really look like shown... Apart from these details, what unittest gives you is a very simple and useful test framework for *automated* test- ing where you specify your test cases *with expected out- put* such that you can build entire test suites to be run whenever you feel like you need a new short "confidence kick" before you continue with new functionality. Ideally, i.e. as an XP purist, you should write these tests *before* writing the *real code*! Dinu -- Dinu C. Gherman ................................................................ "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") import unittest class SetXIDTestCase(unittest.TestCase): "Test if a single PDF Number is read and written correctly." def testSetreuidSetregid(self): "Simple test case for os.setreuid(), os.setregid()" import os, pwd uid = os.getuid() msg = "This test must be run as root; skipping" assert uid == 0, msg nobody_uid, nobody_gid = pwd.getpwnam('nobody')[2:4] # Set real uid and gid to root, effective uid and gid to nobody os.setreuid( 0, nobody_uid ) os.setregid( 0, nobody_gid ) # Change effective ID to nobody os.seteuid( nobody_uid ) # Expect these to fail try: os.setuid( 1 ) except os.error: pass else: msg = 'Should have been unable to change UID to 1' assert 1 == 0, msg try: os.setgid( 1 ) except os.error: pass else: msg = 'Should have been unable to change GID to 1' assert 1 == 0, msg # These should succeed, since we're just swapping the IDs os.setreuid( nobody_uid, 0 ) msg = 'Unable to swap IDs.' assert os.getreuid( nobody_uid ) == 0, msg # ?? os.setregid( nobody_gid, 0 ) msg = 'Unable to swap group IDs.' assert os.getregid( nobody_uid ) == 0, msg # ?? # These should now succeed, since we're now back to root privilege os.setgid( 1 ) msg = 'Unable to reset group ID.' assert os.getgid() == 1, msg os.setuid( 1 ) msg = 'Unable to reset user ID.' assert os.getuid() == 1, msg def makeSuite(): suite = unittest.TestSuite() suite.addTest(SetXIDTestCase('testSetreuidSetregid')) return suite if __name__ == "__main__": unittest.TextTestRunner().run(makeSuite()) From aahz at netcom.com.bbs Mon Jul 17 16:30:12 2000 From: aahz at netcom.com.bbs (aahz at netcom.com.bbs) Date: 17 Jul 2000 20:30:12 GMT Subject: newbie unimpressed... Message-ID: <3bROPa$kmK@openbazaar.net> [rearranged] In article <8kvp81$9q1$1 at nnrp1.deja.com>, wrote: > >(I'm using python 1.5.1 on Redhat 5.2) I strongly recommend upgrading to Python 1.5.2. The documentation is much better, for starters. >I'm serious. The documentation really sucks. >Example: where is the % operator documented for strings? Look in Library Reference, Built-in Types, More String Operations (section 2.1.5.1 in the 1.5.2 docs). -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From neilh at scintilla.org.bbs Sun Jul 16 19:10:01 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 16 Jul 2000 23:10:01 GMT Subject: "Intellisense" drop-down... Message-ID: <3bQd9P$irn@openbazaar.net> > I have found no way of defining new key combinations to select the currently > highlighted word in the "Intellisense" drop-down list. For example: > ... > I hightlight "Apply" and the only key I can use to make "Apply" appear and > the list to disappear is "Tab". I want other keys to trigger this. The > default.cfg file only lists this: When the previous post appeared about Ctrl+Enter in auto-completion, I had a look at extending the keys that would choose an item and tried changing this in Scintilla. This worked in other applications but not in PythonWin as PythonWin intercepts keys before sending them on to Scintilla. Then I went looking through PythonWin but the code was confusing so I gave up. If you are interested in working on this, the Enter key calls newline_and_indent_event in pywin\idle\AutoIndent.py. So you could intercept it here or else bind Enter to your own event that calls the current newline_and_indent_event only when no autocompletion is shown. Neil From bojar at speakeasy.org Sun Jul 2 16:08:02 2000 From: bojar at speakeasy.org (E. Jordan Bojar) Date: Sun, 02 Jul 2000 16:08:02 -0400 Subject: Python CGI security Message-ID: I'm interested in running a series of Python scripts via the Apache Python module, mostly for dynamic content but possibly for password protection as well. Are there security issues particular to (or common with) Python CGIs, in the way that buffer overflow is so common to poorly-written Perl? -- E. Jordan Bojar From alex at magenta.com Fri Jul 28 11:57:07 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 17:57:07 +0200 Subject: Beginning References: <8loacq$n81$1@nnrp1.deja.com> <397FB2B5.8FE38267@sitegnome.com> <8lqqmp$jdd$1@nnrp1.deja.com> Message-ID: <8lsaoa01g3p@news2.newsguy.com> "Alex" wrote in message news:8lqqmp$jdd$1 at nnrp1.deja.com... > Thanks, Fiona! > > I find a lot of interesting stuff on that side. > What OS do you use for programming on Python. > Is anybody doing this in Windows9x, and does it work. I currently use Windows NT 4 SP6, and Windows/98, exclusively (one of these days I'm going to reinstall Linux somewhere, but it's been a while since I last did). Python works beautifully -- much better than most other tools work in those environments. I'm particularly addicted to Hammond's PythonWin, win32com, and all the other win32 extensions (though I don't use them for GUI's -- those I find easier to hack together by other means, such as dynamic HTML, VB, etc; if I did have to do GUI's in Python, I think I'd choose wxPython -- I've had far too much Tcl/Tk in my Tcl and Perl days to feel any desire whatsoever to go back to it:-). Alex From cg at schlund.de Fri Jul 28 08:21:39 2000 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 28 Jul 2000 14:21:39 +0200 Subject: [Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> <39816367.9D7532D7@nowonder.de> Message-ID: <39817AD3.E3E540E0@schlund.de> Peter Schneider-Kamp wrote: > --- begin not-so-serious draft > ----------------------------------------------- [...] > We will create our own version of Python. May it be more free and > succesful > than the one you have made before. > > Trondheim, > Norway > July 28, 2000 > Jan Peter > Schneider-Kamp > > --- end not-so-serious draft > ------------------------------------------------- Perhaps we should add: You will be assimilated. Resistance is futile! :-) Carsten. From olivierS.dagenaisP at canadaA.comM Wed Jul 5 22:05:51 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Thu, 06 Jul 2000 02:05:51 GMT Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> Message-ID: <3QR85.42743$W35.928737@news20.bellglobal.com> > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" Are you sure you can concatenate a string to a time? Also, > print "Content-type: text/html" > print There's something peculiar about this part. You need an EXACT number of linefeeds, otherwise nothing works. I can't remember if it's one or two, though... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Curtis Jensen" wrote in message news:3963C29E.76211EB7 at bioeng.ucsd.edu... > We get this error in our server log: > Wed Jul 5 16:12:52 2000] [error] [client 132.239.236.47] Premature end > of script headers: > /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py > > > The browser gives us this error: > Internal Server Error > > The server encountered an internal error or misconfiguration and was > unable to complete your request. > > Please contact the server administrator, webmaster at bioeng.ucsd.edu and > inform them of the time the error occurred, and > anything you might have done that may have caused the error. > > More information about this error may be available in the server error > log. > > > Apache/1.3.6 Server at cmrg.ucsd.edu Port 80 > > > > Using this script from: > http://www.ping.be/sabine-appelmans/home/python/index.html > > #!/usr/local/Python/bin/python > # > # helloworld.py > # > > from time import * > > print "Content-type: text/html" > print > > print "" > > print "" > print "Hello World" > print "" > > print "" > print "

Hello World !

" > print "
" > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > print "" > print "" > > > > Any ideas why? > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 From paul at prescod.net Fri Jul 14 09:43:48 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 08:43:48 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> Message-ID: <396F1914.DBE530CA@prescod.net> Gregory Lielens wrote: > > ... > > I personnaly consider that linear algebra is an extension of simple > arithmetic, almost on the same level as complex numbers (and usefull to > the same kind of people which could use complex numbers). > The fact that complex numbers are part of built-in python types and can > be manipulated using standard arithmetic operators plead for a similar > facility for linear algebra, imho. That situation was entirely different. Complex numbers required very little syntax and the object is built into Python. You are asking for a lot of syntax but not proposing that your module go into Python. In other words it is a lot of syntax that doesn't get used until you install a third party module. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From bdupire at seatech.fau.edu Mon Jul 17 01:24:50 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Mon, 17 Jul 2000 01:24:50 -0400 Subject: PyArg_NoArgs / PyArg_Parse API References: <3967AA04.6E5073BB@seatech.fau.edu> Message-ID: <397298A2.512C7FF4@seatech.fau.edu> Benoit Dupire wrote: > PyArgs_NoArg(args) is an API function, used in timemodule.c and not > referenced in the documentation.. > > Actually, it's defined as a macro in Python.h > and is equivalent to PyArg_Parse(args,"") > > I didn't see Py_ArgParse in the doc either! OK I finally find out the answer. Thanks Mark, for your "programming Python" book! PyArg_Parse: takes an object, a format string, and C targets. (like PyArg_ParseTuple) But PyArg_Parse doesn't expect the Python object to be a tuple. We need to supply () pairs in the format string to extract parts of returned tuples. PyArg_Parse is also backward compatible with an older conversion variant (getargs) If the third column in a module's name/function registration table is zero (or absent), Python passes argument lists using old-style getargs conventions : the argument list might not be a tuple, so PyArg_Parse is used to extract values. But normally the third column in a module's name/function registration task should be 1, and PyArg_ParseTuple should be used for argument list conversions Benoit! :-) From timaratz at lisco.com Fri Jul 14 16:03:26 2000 From: timaratz at lisco.com (Peter Timaratz) Date: Fri, 14 Jul 2000 15:03:26 -0500 Subject: Why make a language case sensitive? In-Reply-To: <396f5aeb@news.xtml.co.uk> Message-ID: <000b01bfedce$927a55c0$6cb745c6@timaratz> Well, then they could have made it a lower case language. :) > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Nick > Sent: Friday, July 14, 2000 1:23 PM > To: python-list at python.org > Subject: Re: Why make a language case sensitive? > > > I imagine with Python it comes back to the readability argument which is a > strongly held belief in the design. And lower case is more readable :-) > > "Peter Timaratz" wrote in message > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > I can't think of any advantages to a case sensitive language. > Python is a > > very well-designed language though, so I imagine there is a > good reason that > > it is case sensitive. So what are the advantages of a case sensitive > > language? > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From ge at nowhere.none Sat Jul 22 17:39:52 2000 From: ge at nowhere.none (Grant Edwards) Date: Sat, 22 Jul 2000 21:39:52 GMT Subject: Newbie pythoner, with bizzare problem References: <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F79257Amilenkomoonshinecouk@194.73.73.116> <8lcef2$fbn$0@216.39.151.169> Message-ID: In article <8lcef2$fbn$0 at 216.39.151.169>, Donn Cave wrote: > >| You're also right that >| from os import * >| is, of course, universally deprecated. > >So where do so many new programmers learn to do this? This is a >serious question. Is there some tutorial out there that leads >them astray? I've run across numerous examples in module documentation where "from foobar import *" is used (e.g. the socket module examples). This might lead a new programmer to use the same idiom with other modules. "from foobar import *" makes example code look cleaner, but I think it might promote bad habits. -- Grant Edwards grante Yow! My LESLIE GORE record at is BROKEN... visi.com From paul at prescod.net Thu Jul 20 10:30:31 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 09:30:31 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> <3976A167.FCB7EFE3@prescod.net> Message-ID: <39770D07.6BA95583@prescod.net> John Lull wrote: > > ... > > It has no advantage on a simple expression like this, assuming a and b > provide newOp() and otherOp() respectively. The advantage only shows > up on complex expressions, where the functional notation can make it > much more difficult to read, or in a case where b.__otherOp__() > provides __rnewOp__(). Well, if there is any possibility of a name-based system "winning" then I am strongly in favor of it. You could make it a little shorter by using ~ instead of .. ~elMul~ ~matMul~ ~newfunc~ I think that that would be very extensible and reasonably readable. If the word in the middle could be a re-assignable name then you could say: eM=elMul a ~eM~ b -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From hinsen at cnrs-orleans.fr Fri Jul 21 04:31:36 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 21 Jul 2000 10:31:36 +0200 Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: cjc26 at nospam.cornell.edu (Cliff Crawford) writes: > * Remco Gerlich menulis: > | > > | > The easiest way: > | > > | > for line in file.readlines(): > | > block > | > | But that would read the whole thing into memory, and he doesn't want that. ScientificPython has a special class for text files which allows this: for line in TextFile('foo'): ... It also permits the transparent handling of compressed files and URLs (for reading only) and, under Unix, expands home directory names (~user). I use this about everywhere where I read data from a text file; it's nice to be able to use the most general file name notations everywhere without much effort. For those who don't want to install a complete package just for this minor module: you can use it on its own perfectly well, just put the file Scienticic/IO/TextFile.py somewhere on your PYTHONPATH. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From osuchw at ecn.ab.ca.nospam Fri Jul 14 03:10:46 2000 From: osuchw at ecn.ab.ca.nospam (WaldekO) Date: Fri, 14 Jul 2000 01:10:46 -0600 Subject: ASP Questions References: <8kk616$5ck$1@plutonium.compulink.co.uk> Message-ID: <_1zb5.197$2q4.10371@jekyl.ab.tac.net> wrote in message news:8kk616$5ck$1 at plutonium.compulink.co.uk... > Here are some outstanding problems I have with ASP files written in > Python. Hopefully, some of you will have solutions. > > I can't write to session or application variables. In VBScript, this is > done like Session("key")="value". In Python, for writing to a new key, > that translates to assignment to None. I found some documentation for > fixing this in P*rlScr*pt, but still can't get it to work in Python. The following syntax works for me but do not ask me why :-) 8<-------------------------------------------------------------------------- -------------- <%@language= "Python"%> <% domain= 'coentapps' rw= Response.Write if Session.Contents('db_conn'): conn= Session.Contents('db_conn') rw('exists
') else: conn= Server.CreateObject("ADODB.Connection") conn.Open("servinfo") Session.Contents['db_conn']= conn rw('new
') Session.Timeout= 5 rw(Session.SessionID) sql = ''' SELECT strServer, lngMemory FROM tblServerInfo WHERE strDomain= '%s' ''' %(domain) rs = conn.Execute(sql) srv, mem = rs.GetRows() rs.Close() out='' for i in srv: out= out + '
' + str(i) %> <%=out%> 8<------------------------------------------------------------------------ waldemar From matt at null.net Mon Jul 10 23:47:59 2000 From: matt at null.net (Matthew Schinckel) Date: Tue, 11 Jul 2000 13:17:59 +0930 Subject: including files In-Reply-To: <9yna5.229$iT2.4602@m2newsread.uni2.es> References: <9yna5.229$iT2.4602@m2newsread.uni2.es> Message-ID: On Jul 10, I overheard Fernando Rodr?guez mutter: > Hi! > > What's teh Python's equivalent for C's #include "myfile.h"? O:-) > Depends. Usually >>> import myfile or >>> from myfile import * But, if you have a file with commands that you need executed in the current namespace (say, like some generated code do build a GUI menu :-) then you might want to look at: >>> execfile('myfile') -- Matthew Schinckel What I tell you three times is true. From sash at eurocom.od.ua Tue Jul 25 04:29:42 2000 From: sash at eurocom.od.ua (Alexander V. Goncharuk) Date: Tue, 25 Jul 2000 11:29:42 +0300 Subject: Python 1.4 + IBM patch on MVS Message-ID: <8ljj9n$v3r$1@DCS.eurocom.od.ua> Hello all, I tried to build python 1.4 + IBM patch on MVS but ... when I try to start python I receive "segmentation fault" I applied patch from IBM w/o problem, compiled and linked w/o problem, but python doesn't run. Did anybody try to build and run python on MVS ? Probably It's necessary to specify any additional options on the configure stage ? Will be very obliged for any suggestion about this problem. regards, Alexander From pinard at iro.umontreal.ca Mon Jul 31 20:08:59 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 31 Jul 2000 20:08:59 -0400 Subject: to close or not to close? In-Reply-To: Thomas Wouters's message of "Tue, 1 Aug 2000 01:05:33 +0200" References: <8m4s6i$2sdk@drn.newsguy.com> <20000801010533.P266@xs4all.nl> Message-ID: [Thomas Wouters] > On Mon, Jul 31, 2000 at 02:48:02PM -0700, Grant Griffin wrote: > > Forgive me if this is a FAQ, but is it considered good Python form to > > close a file whose variable is just about to go out of scope (and thus > > be automatically closed)? Or should one just omit that? I came to consider it is a better form to _not_ close explicitely. Cases where explicit close is really useful are rather unusual, in my experience. In which cases, an explicit `close' gets more meaningful, and less noisy. And even then, I much prefer `file = None' than `close(file)', because the former really represents my intent: I promise I will not use `file' anymore. I like to think that closing a file is a system concern, not a user concern. > In current CPython it won't cause any problem to omit the close as long as > you are certain the vrbl will go out of scope, but JPython and possibly > other implementations of Python use true garbage collection (GC) rather > than reference counting (RC). This is true, and this is partly why I consider that CPython allows for less cluttered coding in such areas. I'm well prepared to revise my code if I ever need to use JPython. But until I do, I prefer clean and clear. > for x in [:256]: # or range(256) if you don't run experimental patches > open("tempfile.%d"%x) > Will work just fine in CPython, having open at most 2 'tempfiles' at once > (in an interactive session, that is, otherwise it has just 1 open.) I do not understand how we could have two. Since the result of `open' is not saved, I presume the file will be closed immediately after being opened, before executing the next instruction, or the next iteration. > But the same script under JPython, or a possible future CPython with true > GC, will run out of filedescriptors (or more likely: the max number of > open files) before the next GC run. On this list, I got a kind of guarantee that future CPython will stick with reference counting, possibly _complemented_ by more traditional mark and sweep. So, any current clean code will continue to work. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 23:50:03 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 17 Jul 2000 03:50:03 GMT Subject: "Intellisense" drop-down... Message-ID: <3bQkNR$jG0@openbazaar.net> Doh! I didn't know that thing also worked in the interactive window, so I didn't test it there... It might be nice if Tab wasn't hardwired to do this and we could pass a parameter to an event to tell it what to call if the AutoComplete box isn't opened, like so: Tab = AutoCompleteOrDo ( IndentSelection ) Space = AutoCompleteOrDo ( AddSpace ) Ctrl+Space = AutoCompleteOrDo ( <> ) etc..etc... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:iwsc5.3597$4p3.27442 at news-server.bigpond.net.au... > > Here it is, folks, the ability to use another key than TAB to select a > word > > in the AutoComplete list: > > I like it - good to see someone new improving PythonWin. > > A small problem with Ctrl+Enter is that it works in the editor but not > the interactive window. > > Neil > > > From kbang at smartchat.net.au Sat Jul 8 01:45:41 2000 From: kbang at smartchat.net.au (KB Ang) Date: Sat, 08 Jul 2000 15:45:41 +1000 Subject: [ANN] Python port to Palm Pilot References: <200007070140.SAA31035@wd264.aero.org> Message-ID: <3966C005.5EF656C6@smartchat.net.au> Hi there all, Just a cautionary note. I have Palm OS 3.3 running on a Palm V. I installed pylib and python.prc on it. It crashed my Palm ie needed to do a "hard" reset. A soft one did nothing so suggest that u back up before trying anything. Chai collins at rush.aero.org wrote: > > Announcing the alpha port of Python-1.5.2+ to the Palm Pilot, > available for download after 8AM PDT July7, 2000 at > http://www.isr.uci.edu/projects/sensos/python/. This release includes > the modified Python source and tools for creating Palm applications > from Python modules. As a convenience, we include the gnu toolchain > required to support the Python distribution on the Palm Pilot. > We emphasize that this is an alpha release and is deficient in many > respects. We are releasing it now to stimulate interest in Python on > small computing platforms. > > Enjoy! -- +------- | mailto:calcium at ozemail.com.au +6141 321 9866 +613 9889 0883 (tel/fax) | Ob saying - Software is hard - me! From jkraska1 at san.rr.com.bbs Mon Jul 17 01:20:02 2000 From: jkraska1 at san.rr.com.bbs (jkraska1 at san.rr.com.bbs) Date: 17 Jul 2000 05:20:02 GMT Subject: Wishlist sumbission form? Message-ID: <3bR0e3$jDj@openbazaar.net> Olivier Dagenais wrote: > > In the future, everyone will be a programmer and will be able to implement > their own ideas quickly. That, or when they start realizing that all of > humankind have become geeks, they'll just get rid of all computers and we'll > go back to grunting and hunting for food. Grunting and hunting for food is overrated. The grubs may be sweet, but the digging for them is a real drag. C/ From aahz at netcom.com Fri Jul 14 18:51:51 2000 From: aahz at netcom.com (Aahz Maruch) Date: 14 Jul 2000 22:51:51 GMT Subject: html link parser? References: Message-ID: <8ko5i7$i1r$1@nntp9.atl.mindspring.net> In article , Paul Johnston wrote: > >I'm looking to parse the links out of an html document. Is there a module >analogous to Html::LinkExtor (perl)? Use htmllib. When you parse a document, the links are available as a list called parser.anchorlist. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From hzhu at localhost.localdomain Mon Jul 17 21:00:28 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 01:00:28 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> <8F74C4E37gmcmhypernetcom@199.171.54.155> Message-ID: On 17 Jul 2000 23:19:16 GMT, Gordon McMillan wrote: >I proposed something very similar to Huaiyu the other day: > > PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) > >I know Thomas Wouters did, too. I haven't seen a post reflecting these >suggestions. Good point. So let me say why I do not like this. (Doesn't mean it has to die.) :-) In a program where there are a lot of computations, you'll get either something like a ritual on every line, PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) for what could be (A .* B)\C (A .* B)\C (A .* B)\C or you get PyAlgebra.evaluate(r'(A .* B)\C (A .* B)\C (A .* B)\C', A=A, B=B, C=C) Everybody would rush for the latter. In the end what's inside the quote would be a minilanguage with all the bells and wistles of python. This would be just similar to patching the parser, with lesser results. >In fact, looking at this thread in one of those tree-view newsreaders, it >becomes obvious that branches die when a proposal is made, but arguments >are met with vehement counter arguments. Which leads me to believe that: > >>Silly idea 3: >> >> Lets continue arguing until everyone, both pro and con, gets >> irritated, >>starts calling each other Nazis and gives up. > >...has already won. You got it. I'm making a resolution of not going down that road from now on. Huaiyu From sdm7g at elvis.med.Virginia.EDU Fri Jul 28 15:25:32 2000 From: sdm7g at elvis.med.Virginia.EDU (Steven D. Majewski) Date: 28 Jul 2000 19:25:32 GMT Subject: Python in game development [fwd: best prog lang for games] References: <8lkrna$5as$1@nnrp1.deja.com> Message-ID: <8lsmnc$6be$1@murdoch.acc.Virginia.EDU> Forwarded from comp.lang.misc FYI. The article mentions Lisp, Haskell, ML, OCaml, and some others -- not Python, however the article is relevant to the discussion here -- the advantages of mixing low level C code (for the graphics engine, etc.) with a higher-level language to describe higher level stuff. BTW: According to the article, Crash Bandicoot games are written in a "lisp-like language". -- Steve M. In article , Jochen Schneider wrote: >Jonathan Guthrie writes: > >> Your question is too broad. Techniques and languages differ whether >> you're in it for the money (and are, therefore, almost certainly >> programming for one game console or another) or to prove a point. >> ("Abuse" was written in Lisp, to show that you could code an action >> game in Lisp and because the coders liked programming in Lisp.) > >There is an interesting article on alternative programming languages >for games on Gamasutra >(http://www.gamasutra.com/features/19990813/languages_01.htm). The >whole Gamasutra site seems to be a must for game programmers. > From joneshenry at my-deja.com Mon Jul 31 03:03:38 2000 From: joneshenry at my-deja.com (joneshenry at my-deja.com) Date: Mon, 31 Jul 2000 07:03:38 GMT Subject: Python, Perl Rewrites: Alliance? Message-ID: <8m38ca$an5$1@nnrp1.deja.com> My reading of Guido van Rossum's postings seems to be saying that it isn't clear whether CNRI, the owner of the copyright of Python produced while Guido was at CNRI, considers the "license" of say Python 1.5.2 to be legally valid. The only solution to preserving the BSDish freedom claimed for Python 1.5.2's source code would seem to be to start from a code base totally unaffiliated with CNRI. Of course this would be an unthinkable undertaking starting from scratch...or would it? My first question would be whether CNRI also claims in effect the trademark for the Python language as well as the copyright for the current source code. Would someone be able to write a Python compatible language from scratch and still call it Python without CNRI's permission? As to where a new code base might come from, a perhaps mystic conjunction of circumstances has the Perl community beginning planning for a rewrite of their code base for Perl 6. The obvious objection is that Perl's traditional license has been somewhat different from Python's: The code is dual-licensed under either the GPL or the Artistic License. But it seems to me that the very beginning of this Perl effort is the one chance for some strategic brokering between the leaders of the Python and Perl communities. O'Reilly & Associates, ActiveState, various conferences, somewhere there has to be the opportunity for lines of communication. Even without the present difficulties, the Python community could sure use the resources of say CPAN. Is it unthinkable in the future for Python programs to be able to use the same repository and mirrors? In my opinion to close the deal with CNRI, BeOpen must not surrender the right to license underived code under different licenses, say the perported license of Python 1.5.2. BeOpen needs to come away with an unencumbered equivalent of a specification for the Python language. Henry Jones Sent via Deja.com http://www.deja.com/ Before you buy. From wilson.austin.aj at bhp.com.au Thu Jul 6 15:08:55 2000 From: wilson.austin.aj at bhp.com.au (A J Wilson) Date: Fri, 7 Jul 2000 05:08:55 +1000 Subject: How do I ring the bell? Message-ID: <8k2lcd$59v$1@gossamer.itmel.bhp.com.au> Hi I would like to ring the PC's bell (ie internal speaker) to alert the operator that an operation has finished running. How do I do this in my python program? Thanks Austin From spam at spam.com Tue Jul 18 18:35:30 2000 From: spam at spam.com (Penfold) Date: Tue, 18 Jul 2000 23:35:30 +0100 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: I'm sure Im jumping into a discussion where its already been thrashed to death but ... Huaiyu Zhu wrote in message news:Pine.LNX.4.10.10007180134360.9411-100000 at rock.localdomain... > This is a summary of what's discussed so far. > > On Tue, 18 Jul 2000, Moshe Zadka wrote: > > ... we really meant that we'll help yo. > > Thanks! I see where compile() is called. But how is the parser itself > called in python? Only used as C function? Now that we have a patch to add > the new operators, is it possible to assemble these into a module? > > Before we plunge into this thing which may turn out to be more laborious > than MatPy itself, we need to get a handle on what's involved. Let me make > a list in order of my preference. Please jump in at any point that's both > feasible and interesting enough for someone to actually do it: > > 1. Make a pure python way to introduce additional operators, like > import NewOperator > NewOperator.define(".+", "__dotadd__") > NewOperator.define("+=", "__add_ab__") > NewOperator.define(":=", "__copy__") > > Advantage: Pure python. Doesn't interfere with existing sytax. May be > used for other operators. Not in the core, only affect the module that > imports it. > Disadvantage: Said to be quite difficult to implement (Why?). I'd expect it would be ... (i) you're asking that the grammer be dynamically changed *as* the module is being parsed. (ii) are you going to restrict the possible new tokens (iii) How does the python interpreter work ... for example the expression a+b results in byte code of the form LOAD_FAST a LOAD_FAST b BINARY_ADD That is, the BINARY_ADD operation deals with the issues of whether these are instance types (and thus __add__, __radd__, __coerce__ etc should be invoked). At least thats what Ive always believed (never checked the source ;-) ). So what gets generated for a .* operation? An explicit call? does coercion, or the equivalent of __radd__ ever happen? What happens when a and b are not classes? [well, a TypeError obviously?] I mean there are issues there ;-) > > 2. Incorporate additional operators in python. Either . or @. Five to > eight would be enough for linear algebra. > > Advantage: Pure python. Doesn't interfere with existing syntax. > Disadvantage: Fixed choice for everybody. Unlikely to happen for quite > some time until everyone agrees on everything. What, really, is the point in this. Its obvious why you want them, but why does everyone else? This is clearly a *domain specific* problem, which is yours, that you would like Python to look like MatLab. +, / * are all good operators. When I read code and I see a+b, I dont know what a and b are, but I can guess the general effects/properties of the expression a+b. If I read a @ b, what the hell does that mean?? It means *nothing* unless I know MatLab. Whats worse, coders will use it for all sorts of things, all of them different. Sure, they can do that with + but generally dont, its got an "implicit" meaning. But why stop here, why not proliferate the language with #!'s. Hell, I want python to be more like perl, why cant I use all sorts of meaningless operators to do so? Why, this is python, if I wanted to do that I should be using perl [or MatLab ;-)] Analogy: Problem: Why do I have to write x.sendMessage(y.createMessage(txt))? I should be able to write x &^% (y *&^ txt) Solution: Python is broken, we need to redefine arbitrary operators so I can do this. Approxmately 1000 extra ones should cover all contingencies. > > 3. Maintain a patch for additional operators. > > Advantage: once built, everything is pure python. Already have patch. > Disadvantage: Can't guarantee most users can patch python, so in practice > may need to maintain windows executable for download. > Better than 2 !! At least you only butcher you copy of python ;-) > 5. Use a customized parser in python, with some compile tools? > > Advantage: can change anything. Can fine tune before settle down. > Disadvantage: can change anything. Slower than 1. Don't know how to use > it. (But maybe they can be turned into option 1?) Look up mxTextTools at vex. Its not very nice to use itself, but there is a wrapper API provided by someone else for custom lexers/parsers. > > Note: I dislike some of the proposals because they look like ugly hacks to > use the abundance of class names, method names, function names and string > literals to walk around what is clearly just a shortage of a few operator > symbols. But I don't think we can reach consensus on such issue anyhow. > Adding @ and .* is an ugly hack to work around the desire to still be writing MatLab > If there is no more proposal forthcoming, I will adopt a combination of > options 3 and 4, and hoping for someone to come up with 1. The largest > problem with this approach is this: If we can't guarantee the patch is > usable everywhere, do we want everybody using these operators? Will it run > on another machine, or even another version of python? If such a status > persists for a long time I guess all codes will settle into a local optimum, > something like > > (a.emul(b))*(c.emul(d)) > > and an opportunity would be lost, even if in reality most people actually > like (a.*b)*(c.*d). This incidentally also removes an opportunity to see if Umm, maybe that means something in MatLab. Alternatively to C++ people, it looks like you're using pointers to member functions in C++ !! > elementwise operators might be useful elsewhere, like > > ["%5.2f", "%-8s", "%.2g"] .% [pi, 'short', 1] hmm, is that the same as "%5.2f %-8s %2g" % (pi, 'short', 1). > ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", "boy", "boy"] > [does it automatically add the spaces between the words too ;-)] yes, because map(lambda x,y: x+"is"+y, ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", "boy", "boy"]) > The argument "if it finds wide-spread use we may put it in the language" has > a severe limitation - if it is technically very difficult for users to use a > feature that's not in the language, it will unlikely to find wide-spread use > and may never get into the language. That's why I really hope something > like 1 can come up. This is why python is not a democracy ;-) > > Inputs greatly appreciated. > > > Huaiyu ever-rantingly-yours, D From hzhu at localhost.localdomain Mon Jul 31 00:01:52 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 31 Jul 2000 04:01:52 GMT Subject: Newbie DATA STRUCTURES Question. References: <398248BC.32DE3CC@nycap.rr.com> Message-ID: On Sat, 29 Jul 2000 02:57:03 GMT, gbp wrote: > >I have experience with Perl but non with Python. > >I need to write a script to read a large text file into a structured >format. > >In Perl one can create a list of records using something like pointers. >So really you have a list of pointers-- each one pointing to an >anonymous record. Each record is some data from a line in the file. > Others have given more general answers, but I think you might have this specific question in mind: you have a file of form 11 12 13 21 22 23 ... and you want to get a list of dictionaries (ie an array of hashes in Perl) result = [{'a':11, 'b':12, 'c':13}, {'a':21, 'b':22, 'c':23}, ... ] You can do it as the following (not tested) file = open(filename) # or file = sys.stdin names = ['a','b','c'] result = [] for line in file.readlines(): fields = string.split(line) # or use re to extract the fields record = {} for name, field in map(None, names, fields): record[name] = field result.append(record) Hope this helps. Huaiyu From moron at Glue.umd.edu Mon Jul 17 20:53:52 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 17 Jul 2000 20:53:52 -0400 Subject: Does Python have "not a number" floating point values? References: <8l03pc$92co$1@nntp6.u.washington.edu> Message-ID: <8l09r0$4nq@stochastic.eng.umd.edu> (Huaiyu Zhu) said: >On Mon, 17 Jul 2000 16:10:36 -0700, Russell E. Owen > wrote: >>Does Python support any sort of floating point "not a number" >>(e.g. IEEE infinity)? Python floats inherit the behavior of your C platform's doubles, so on an IEEE-754 system, they will act fairly IEEE-like, as Huaiyu demonstrates: >Inf = inf = 1e300**2 >NaN = nan = inf - inf However, according to a recent post, the OpenVMS port of python uses VAX-format math[1], which has less exponent range than IEEE. I think that that expression for Inf will not parse there. I don't even know if VAXen have Inf or NaN. Warren Focke [1] http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=640022415&fmt=text -- If you feel that you have both feet planted on level ground, then the university has failed you. -Robert Goheen, President, Princeton University From digitig at cix.co.uk Tue Jul 4 17:23:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Tue, 4 Jul 2000 22:23 +0100 (BST) Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: In article <8jqjf8$s1t$1 at nnrp1.deja.com>, jhylton at my-deja.com () wrote: > In article , > Kalle Svensson wrote: > > > I have a few questions about the (pseudo) random number generator > supplied > > in the standard library. I need 80 random bits (for a CipherSaber IV) > but > > I hear most RNG's only supply 32 bits or less. > > I recommend looking at the Yarrow design by Kelsey, Schneier, and > Ferguson: http://www.counterpane.com/yarrow.html > > A Python implementation of Yarrow-160 is included in the Pisces > distribution: > http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.yarrow > .html Beat me to it! Yes, that's the serious way forward for a crypto application. From akuchlin at mems-exchange.org Tue Jul 11 12:05:53 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Jul 2000 12:05:53 -0400 Subject: POOP / Python (Object Oriented Persistence) ? References: <003001bfeb2f$99f60250$f0c809c0@lslp7o.lsl.co.uk> Message-ID: <3dzonozm72.fsf@kronos.cnri.reston.va.us> "Tony J Ibbs (Tibs)" writes: > OK - I've lost one snag, so here's a new one (although much less > important) - it's not clear (from the web pages) how to install the ZODB if > one *doesn't* care about Zope in general - *presumably* one has to download > the standard Zope distribution and just answer some questions? I've submitted setup.py scripts that use the Distutils to install just ExtensionClass, or just the ZODB, and makes it pretty easy. Brian Lloyd at Digicool, who's responsible for Zope releases, has said that the scripts will get looked at after Zope 2.2final ships; I'd guess that will happen in a week or so. I'm pushing hard to get the ZODB packaged separately, because it'll be hard to use in Python applications if you can only get it by downloading all of Zope. > I still think someone should be pushing this more... Agreed; the ZODB is really quite cool! At work we're beginning to use ZODB for storing business-related objects, and it's an interesting learning experience. The major issues so far are: 1) lack of documentation, particularly for various advanced properties of the ZODB. 2) the use of ExtensionClass means that the standard Python isinstance() doesn't work any more, so you need to use a modified version. We've also hit things like ExtensionClass not supporting __radd__; the resulting symptoms are often mysterious and it's time-consuming to pin down what the problem is. 3) lack of an easy installation method, which is why I wrote the setup.py scripts. That's all I can think of at the moment. --amk From dan at cgsoftware.com Mon Jul 31 11:40:39 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Mon, 31 Jul 2000 08:40:39 -0700 (PDT) Subject: looking for python object debugging hints In-Reply-To: <87og3es4ai.fsf@oak.gitaram.com> References: <87og3es4ai.fsf@oak.gitaram.com> Message-ID: On 31 Jul 2000 ramb at synopsys.com wrote: > I've written some code to implement a new python object and I'm having > some trouble with it. My code to implement the new object is written > both in C and in Python. > > Here is the situation: > > A python script imports my module and then starts calling > various functions in my C shared library. The problem is > that if I use gdb on the python binary my shared library > is not loaded until the script starts running and that > is too late to set a break point. What I want is some way > to make it easy to use a debugger to debug my dynamically > loaded shared library. Look at the documentation to auto-solib-add. Also, once your shared lib is loaded, just Ctrl-C at the gdb console, or click stop (if you are using the GDB gui), and it'll break into the debugger, and you can set your breakpoint. --Dan C++ support maintainer - GDB From dogboy777 at my-deja.com Mon Jul 31 08:56:25 2000 From: dogboy777 at my-deja.com (dogboy777 at my-deja.com) Date: Mon, 31 Jul 2000 12:56:25 GMT Subject: Readline module? Message-ID: <8m3t1n$p0h$1@nnrp1.deja.com> I'd like to use the readline module in a python script running on Linux. Our sys admin just updated our version of Python to 1.5.2, but the readline module isn't there. What's particularly wierd is that rlcomplete _is_ there: python Python 1.5.2 (#1, Jul 31 2000, 08:16:09) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import rlcompleter Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/rlcompleter.py", line 43, in ? import readline ImportError: No module named readline >>> Any idea what's up or where to find the readline module? Thanks, Anders Schneiderman P.S. I also noticed that the readline module is listed in the Python Essential Reference book and is mentioned by several documentation pages, but it isn't on the module list (http://www.python.org/doc/current/modindex.html). Hmmm... Sent via Deja.com http://www.deja.com/ Before you buy. From hopper at omnifarious.mn.org.bbs Mon Jul 17 14:50:03 2000 From: hopper at omnifarious.mn.org.bbs (hopper at omnifarious.mn.org.bbs) Date: 17 Jul 2000 18:50:03 GMT Subject: Reading asynchronous data from a serial device Message-ID: <3bRLiR$lXa@openbazaar.net> In article <8kuvg0$kg2$1 at nnrp1.deja.com>, julesk24 at my-deja.com wrote: > > 1) Is there any (easy) way for me to cause the thread to exit (not > just join the processes) after a timeout on a read? I believe you can start the thread as a daemon thread and not have the join problem. When the thread exits, it just disappears and doesn't wait for its parent thread to notice. I'm not sure how to start it as a daemon thread. > 2) Is there a better way of reading for data (without starting my own > thread for the read process and then trying to exit out of the thread > after a period of time)? Yes. Use a select(2), or poll(2) based mechanism. I believe the asyncore module handles this for you. I will also be adding a python wrapper to my C++ StreamModule (http://www.sourceforge.net/projects/strmod) system someday, and that should also nicely handle the problem. Have fun (if at all possible), --Eric Hopper From eric at estinc.com Thu Jul 6 15:25:19 2000 From: eric at estinc.com (Eric Lee Green) Date: Thu, 06 Jul 2000 19:25:19 GMT Subject: Segmentation fault(LINUX) and no idea why! References: <39632A2C.E6ABECEB@muc.das-werk.de> Message-ID: <3964DD6E.12F37B7E@estinc.com> Thomas Thiele wrote: > In my program I create a new thread. In this new thread I fork and > replace the child with an other program > using excel. Normaly I have up to four threads with this procedure. So I > have a number of threads and the same numbers of childs (the called > program) > > The problem is sometimes (relativly seldom, so it's unreproducible ;-( ) > I get a segmantation fault and the pytthon interpreter stops. I haven't had good luck with forking a multi-threaded Python program, unless I immediately follow the fork() with an exec(). I suspect it's something to do with the internal state that Python uses as part of the thread stuff, but haven't cared enough to track it down (I dumped the whole 'threads' stuff instead, because I have found no way of telling whether a thread is still running or not...). -- Eric Lee Green eric at estinc.com Software Engineer Visit our Web page: Enhanced Software Technologies, Inc. http://www.estinc.com/ (602) 470-1115 voice (602) 470-1116 fax From kpmurphy at my-deja.com.bbs Mon Jul 17 16:10:05 2000 From: kpmurphy at my-deja.com.bbs (kpmurphy at my-deja.com.bbs) Date: 17 Jul 2000 20:10:05 GMT Subject: grid Message-ID: <3bRO0T$kuE@openbazaar.net> does this look alright? # embed.py from Tkinter import * root = Tk() left = Frame(root, bg='red') right = Frame(root, bg='orange') button1 = Button(left, text='hi') button2 = Button(right, text='yo') entry1 = Entry(left) entry2 = Entry(right) label1 = Label(left, text='this is schweet') left.grid(row=0, column=0, ipadx=10, ipady=10) right.grid(row=0, column=1, ipadx=10, ipady=10) button1.grid(row=0, column=0) button2.grid(row=0, column=0) entry1.grid(row=0, column=1) entry2.grid(row=0, column=1) label1.grid(row=1, column=0, columnspan=2) mainloop() # end embed.py thanks, -->keith In article <8kvkvt$68h$1 at nnrp1.deja.com>, Keith Murphy wrote: > can you embed grids? ...what i'd like to do is grid within several > frames, and then grid the frames together. sort of like html tables... > i hate pack. > > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From mlh at idi.ntnu.no Mon Jul 31 15:38:49 2000 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 31 Jul 2000 21:38:49 +0200 Subject: [5th Draft] Open Letter to CNRI: Request for clarification References: <3985D797.E5D2FC08@nowonder.de> Message-ID: <8m4kmu$1eq$1@kopp.stud.ntnu.no> Peter Schneider-Kamp wrote in message news:3985D797.E5D2FC08 at nowonder.de... [...] > The following attached signatures represent people from the Python > community who would like some clarification regarding the future of the > Python language. As of now, there has been no official statement from > your institution regarding the new Python license. We are especially > interested in the underlying intention of this change. So we request > a plain-English, non-legalese statement regarding the purpose of that > change and the ways in which it affects Python's use. [...] Hm. I obviously haven't been paying enough attention lately... I don't know what this about - but it seems a tad disturbing... If the changes in the licence *might* restrict the use of Python, I would be *very* worried... So, I guess I qualify (being interested in a clarification); feel free to add me to the list. (I am a Ph. D. student in computer science, if you want to include that in the list...) -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From bkc at Murkworks.com Wed Jul 19 10:20:39 2000 From: bkc at Murkworks.com (Brad Clements) Date: Wed, 19 Jul 2000 10:20:39 -0400 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: Great posting, please do more. -- Brad Clements, bkc at murkworks.com "Andrew Kuchling" wrote in message news:20000718100813.C21354 at newcnri.cnri.reston.va.us... > This is a first experiment in whether I can make a useful, > interesting, somewhat coherent summary of python-dev activity. > If reaction is favorable, and time permits, it may become a biweekly > posting. > From richard_chamberlain at my-deja.com Mon Jul 17 04:45:45 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Mon, 17 Jul 2000 08:45:45 GMT Subject: Tkinter and absolute positioning References: <8kudt2$92e$1@nnrp1.deja.com> Message-ID: <8kuh3m$b4v$1@nnrp1.deja.com> Hi Ruud, You can do absolute positioning with place: from Tkinter import * root=Tk() Label(root,text="He's not the messiah,").place(x=5,y=5) Label(root,text="he's a very naughty boy.").place(x=35,y=70) root.mainloop() Not highly recommended though! Richard In article <8kudt2$92e$1 at nnrp1.deja.com>, Ruud Cox wrote: > > > Is there a way to position child widgets on a TopLevel > widget using absolute coordinates instead of using pack, > place or grid? > > Ruud Cox > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From bmcd at es.co.nz Thu Jul 20 18:29:10 2000 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 20 Jul 2000 22:29:10 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: On Thu, 20 Jul 2000 13:05:54 -0500, Travis Oliphant wrote: >Definining * to be matrixwise should be handled by >subclassing the generic array (which will be much easier to do >without breaking compatibility with compiled extension modules in the >future Numeric). I agree. Using Python's object capabilities is better than messing with the grammar. Although I must say the (*) forms are by far the least bad. As far as I'm concerned, Matlab is a poor example to follow. I've seen a number of people burnt by the differences between A' (adjoint) and A.' (transpose), for example. May I propose a single generalised way to add syntax? In this way, syntax can be used as appropriate to context, without cluttering the core language. The fact that APL has been mentioned in this thread is a bad, *bad* sign. >I'm not sure we should blow our chance to get some useful operators into >Python by over-reaching... Also, unless you've used Numeric with Python >for a while, it's easy to over-value the use of the infix notation. >This really bugged me when I first started using Numeric Python as >well, but it doesn't bother me anymore. The syntax does not have >to be as bad as Huaiyu demonstrates. I wholeheartedly endorse this view. "Syntactic sugar causes cancer of the semicolon" -- Alan Perlis One of Python's greatest features is its simplicity. Adding extra syntax reduces this. I won't mention The Other Language. Ministry of silly syntax: (*) Darth Vader |*| Tie Fighter >+< X-Wing -- Ben Caradoc-Davies From tony at lsl.co.uk Tue Jul 11 08:00:26 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 11 Jul 2000 13:00:26 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: Message-ID: <003001bfeb2f$99f60250$f0c809c0@lslp7o.lsl.co.uk> Toby Dickenson wrote: > As of very recently, __getattr__ and __setattr__ do mix with ZODB > persitent objects :-) Yeah! (In fact, when writing that this was a snag of ZODB, I *nearly* also wrote something like "but doubtless someone will provide a workaround for this when it becomes too incovenient". I didn't because (a) my email was already too long, and (b) I wasn't *sure* it was technically possible to make the work round trivial for users. I shouldn't have worried - that time machine can be so confusing.) OK - I've lost one snag, so here's a new one (although much less important) - it's not clear (from the web pages) how to install the ZODB if one *doesn't* care about Zope in general - *presumably* one has to download the standard Zope distribution and just answer some questions? I still think someone should be pushing this more... Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ ZODB - "Nyah! Nyah! *My* variables last longer than *your* variables." My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From claird at starbase.neosoft.com Thu Jul 27 09:21:23 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Jul 2000 08:21:23 -0500 Subject: They let just anyone in (was: Perl is worse! (was: Python is Wierd!)) References: <8losor$4bk$1@nnrp1.deja.com> Message-ID: <6835F57D8D497113.94DDC1FD971207C4.B1EF584692BAD54C@lp.airnews.net> In article <8losor$4bk$1 at nnrp1.deja.com>, Jonathan wrote: . . . >But the irony now is that ZOPE will be 'opened' to PERL too. I have >read through the 'debates' going on in the zope mailing list, but it >still doesn't make sense - why allow Zope to be polluted by something >that is clearly deficient? It's like allowing people to use sand >instead of cement to build a house. (I haven't mastered Zope yet, so i . . . No, it's like letting people native to Sandland come and visit. We treat them nicely while they're in Pythonia, and wish them well. They're already using sand for their houses. They don't need us to "allow" them. Perhaps you see irony in that. There's no pollution of Zope. It's always been quite flexible and open. People use it for all kinds of things, in all kinds of ways. The Feds don't run background checks for prior activity, nor does anyone post a bond pledging only Python- based advocacy. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From cjensen at bioeng.ucsd.edu Tue Jul 11 18:47:49 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 11 Jul 2000 15:47:49 -0700 Subject: Script for checking FTP + HTTP links? References: <396BAD73.MD-1.4.4.angband@blueyonder.co.uk> Message-ID: <396BA415.C8D4301F@bioeng.ucsd.edu> Bablos wrote: > > Hi There... > > I'm looking for a script that can check through several HTML files and > check the links to other HTML files, and also any files linked via FTP > and HTTP. I've found a Perl script that does this, and there MUST be a > Python script out there that does it. > > Any ideas where I can find such a script? I'd try writing one myself, > but the idea just gives me a headache! > > Bablos. There is a webchecker module. I believe it's in the python/Tools directory of the python install. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From fiona at sitegnome.com Sat Jul 29 04:32:33 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sat, 29 Jul 2000 18:32:33 +1000 Subject: Python in politics (sssssssssnake!) References: Message-ID: <398296A1.1A97571A@sitegnome.com> Hi Kirby, Your mail got me thinking... I've just started trying to teach my 9 year old son how to program, I choose Python because I'm trying to learn it as well.... He thinks he is 'cool', and I quote - "I'm not here to make (make dinner) I'm here to program" - in an attempt to get out of helping me with the cooking. body actions of a super hero (muscle flex left and right arms :) .... hopefully I'll be able to maintain that level of enthusiasm. Do all you guys do that?? I'd be interested if there are guidelines somewhere for parents to teach their kids how to code? When it comes to 9 year olds the tutorials are pretty scary ... maybe I should start working on that? Is anyone actively working on that now...? Thanks, Fiona Kirby Urner wrote: > > Something from another newsgroup but mentions Python, so I > elected to cross-post (to the CIA group as well, because of > the InQTel thing)[1]. For more context re the below, check: > > http://www.egroups.com/message/synergeo/1319 > http://www.egroups.com/message/synergeo/1321 > > Also my "Math Makeover" homepage at: > http://www.teleport.com/~pdx4d/makeover0.html > > The basic idea is to remix education topics to come up > with more robust synergies (blah blah) i.e. get more > kids doing Python programming around polyhedra, while > watching TV shows which show how life in a Fly's Eye > dome might be exciting, and useful to others (ala 'ER'). > > Kirby > 4D Solutions > .projects: videogrammatron, synergetics, philosophers network > > [1] http://www.in-q-tel.com/ > > Note: changed "Malthusian" to "Malthusian-minded" for a > better read. > > ========================================================================= > > Newsgroups: bit.listserv.geodesic > Date: Fri, 28 Jul 2000 09:37:43 -0700 > Reply-To: List for the discussion of Buckminster Fuller's works > > Sender: List for the discussion of Buckminster Fuller's works > > From: Kirby Urner > Subject: Re: more late night synergetics > Comments: cc: synergeo at egroups.com > To: GEODESIC at LISTSERV.ACSU.BUFFALO.EDU > > At 08:55 AM 07/28/2000 -0700, Dick Fischbeck wrote: > >Kirby-This is getting close to language I can really > >grab onto. Would you rewrite this piece, say so that > >an average sixth-grade could get it? > >Thanks, > >Dick > > I think for TV-immersed 6th graders these ideas would > work best if presented as video with computer graphics. > > What we need is a databank of short videoclips, > averaging under a minute in length, and retrievable > by key word. You string these together or call them > up in response to student questions. Hypertext > interface. Distribution is by CDROM or DVD. > > In the USA, the Department of Education and DARPA > should be pumping bucks into some prototypes, in > consortium with the private sector (the corporations > need not always be USA-based e.g. Sony), to catalyze > a renaissance in education. A presidential candidate > who doesn't speak in definite, clear terms about how > she or he plans to revamp education is just blowing > smoke, trying to get elected without doing the > requisite homework. > > DARPA previously funded a "Computer Programming for > Everybody" initiative (CP4E) designed to get more > programming into the schools, with the Python language > spearheading the effort.[1] That grant has long since > run out, and is small change next to what's needed > to spark imaginations around design science concepts > more generally. > > Hollywood needs to get into the act, casting stars > against a backdrop of futuristic artifacts that exists > as working prototypes, not simply as phoney props or > stage magician special effects. The game of brand > placement (embedding logos in the actual programs, > vs. separating out into separate advertising segments) > will make a lot of sense in this context, as corporations > vie with one another to prove their sponsorship of > the "sexiest future" (e.g. Fly's Eye air-liftable > utility pods, wired to cyberspace and staffed by > youngsters with heavy duty real world responsibilities, > ala ER -- real time camera access via webcam and TV > segments (this is not a new theme for me -- shows > like 'Survivor' bring us closer)). > > We're in dire need of a realistic futurism, an > attainable positive tomorrow. Because a self-indulgent > and Malthusian-minded academia has fallen down on the > job (by and large), Federation pseudo-Science ala > Star Trek has been allowed to fill the cultural > void, holding out the prospect of a high tech future, > but using mumbo jumbo concepts instead of hard > science-math, leaving kids to fantasize helplessly > about some 24th century, while Spaceship Earth > meanwhile remains in the grip of obsolete power > structures, desparate to hang on to power (the > Napster fracas being just the tip of the iceberg > vis-a-vis that juggernaut).[2] > > A lot of intellectuals overseas are well-aware of > how USA politicos are consistently and concertedly > ignoring their leadership responsibilities, which > include inspiring positive future visions, vs. simply > serving as the puppets and task masters of those > who see humans as little more than exploitable > consumers. This has the effect or eroding the > credibility and even the comprehensibility of the > political leadership. Why don't they make any > sense? > > Education is from the inside out, but the inner world > has been left in the hands of media manipulators who > fill heads with cheap googoo-brained claptrap, > whatever it takes to create a new generation of mall > rats and fast food junkies. The USA, such as it > still exists, is working to counter that diet, with > healthful content -- design science based positive > future imagery, backed up with real math and > science, being chief among the vitamins and > minerals we need to firm up our jello-brained > culture. > > We should start a race to see which presidential > candidate we can get to say "Buckminster Fuller" > on TV first. The Republicans have an edge, because > President Reagan awarded Bucky the Medal of Freedom. > But Gore is into the internet, and that's a relevant > segue to design science as well. Nader is highly > critical of corporations ala 'Grunch of Giants' > and so has plenty of hooks. There's nothing stopping > any of these campaigns from jumping on the design > science bandwagon and demonstrating some ability > to point towards a positive future for all humanity. > Any candidate who fails to lead the way to a better > tomorrow ipso facto fails the minimum test for > leadership ability, in my book. > > Kirby > > [1] CP4E: http://www.python.org/doc/essays/cp4e.html > [2] http://www.salon.com/tech/col/rose/2000/07/27/napster_shutdown/index.html -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From xiarcexml at yahoo.com Thu Jul 13 12:12:32 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Thu, 13 Jul 2000 09:12:32 -0700 (PDT) Subject: File IO with select? Message-ID: <20000713161232.18986.qmail@web5303.mail.yahoo.com> I am new to Python... but I have an idea... If you use an object as a go between... This object references the file with some sort of boolean (default as true)... , and upon granting access, is changed to false. When the object that is writing to the file finishes, it sets it back to true. ~Dave __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From robin at jessikat.fsnet.co.uk Thu Jul 20 12:08:14 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 17:08:14 +0100 Subject: Discussion: new operators for numerical computation References: <39771F6D.A9A0A26B@yale.edu> Message-ID: <3vd2oVAuPyd5Ewwx@jessikat.fsnet.co.uk> In article <39771F6D.A9A0A26B at yale.edu>, Paul Magwene writes >Konrad Hinsen wrote: > ... >Of all the proposals so far, I find Konrad's suggestion to be the most >appealing. >I could definitely get used to the following: > >A(*)B >A(/)B >A(+.*)B >...etc > >Please keep * for elementwise multiplication like in NumPy. There is >already a large installed user/codebase which uses it as such. > >I personally find A at B very hard to parse visually. @ justs seems to just >smack of that other P language. ;-) > ... I like this too, but would the operators have to be parsed that way as triples or quintuples etc -- Robin Becker From nowonder at nowonder.de Mon Jul 31 01:27:27 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 05:27:27 +0000 Subject: [Python-Dev] PEP 201, zip() builtin References: Message-ID: <39850E3F.434D1C3A@nowonder.de> Tim Peters wrote: > > Both syntaxes already have well-defined meanings in Python (*try* them!), so > we can't change what they mean without breaking existing code. Guido would > *prefer* to do this via syntax instead of new functions, but in more than a > year nobody has been able to dream up a reasonable syntax that's > backward-compatible. That's not for lack of trying. I thought the problem was that all the syntaxes implied cross- product rather than lock-step iteration. I can't remember what the problem for the semicolon syntax should have been (besides the semicolon normally only being used between stmts): for x,y; z in list_xy; list_z: print "coordinates: x,y,z" sorry-to-bring-that-up-again---I-like-zip()-a-lot-ly yr's Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From thomas at xs4all.net Thu Jul 20 08:39:00 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 20 Jul 2000 14:39:00 +0200 Subject: iterating over lines in a file In-Reply-To: ; from scarblac-spamtrap@pino.selwerd.nl on Thu, Jul 20, 2000 at 10:16:33AM +0000 References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: <20000720143900.P9897@xs4all.nl> On Thu, Jul 20, 2000 at 10:16:33AM +0000, Remco Gerlich wrote: > > > while (line = ) { block; } > > The easiest way: > > for line in file.readlines(): > > block > But that would read the whole thing into memory, and he doesn't want that. > Wouldn't an xreadlines() method on file objects be cool? There's the 'fileinput' module, which is almost exactly that. (It does some extra things as well, if you wish ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From grey at despair.rpglink.com Sat Jul 29 18:36:28 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:36:28 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: On Sat, 29 Jul 2000 03:19:30 GMT, Ben Wolfson wrote: >Now, most of y'all be thinkin', "Tha H-Dog, he know his bidness." And thas >right, man. Shit need addin'? I creep in, adds tha shit up, and slip out, >quiet as a muthafuck. Variance need resolvin'? It be gone without a trace. >Uh-huh. Only a wack-ass fool ask someone besides tha H-Dog to >accountz-receeve they shit. >-- Herbert Kornfeld, Accounts Receivable Supervisor *snicker* Reminds me of Delta Ebonics. Thanks for the good chuckle. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From matt at nightrealms.com Tue Jul 18 22:43:10 2000 From: matt at nightrealms.com (Matthew Cline) Date: Tue, 18 Jul 2000 18:43:10 -0800 Subject: Newbies trying to do a build script References: <8l1o61$n45$1@nnrp1.deja.com> Message-ID: In article , Matthew Cline wrote: > In article <8l1o61$n45$1 at nnrp1.deja.com>, John Urberg > wrote: > >> Hi all, >> >> I am working on a project with a couple of other developers and we >> are all new to scripting languages. We need to create a build >> script to build an application that consist of C++ and Java code. >> We have some Perl resources in another group, but I would prefer >> doing it in Python. I was hoping someone here could point me to >> some examples of build scripts in Python to get us going quickly. > > So you're doing something that autoconf, automake, configure and so > forth can't handle? Urgh, that probably wasn't too useful. Sorry. What exactly do you need the script to do? If you want to compile files in sub-directories, sub-sub-directories, and so forth, the standard UNIX make already takes care of that. If you want to apply scripts or programs to certain files, then you can have make call those scripts. If you want to figure out the configuration of your computer, like where the JVM is, what version it is, and so on, or to automatically figure out what "-D" flags you should give to the compiler, then autoconf and automake will take care of things. If, after the compile is done, you want to move files around to create the file tree you'll use for distribution, make can probably do that as well. From MarkH at ActiveState.com Thu Jul 13 17:45:26 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 13 Jul 2000 21:45:26 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> Message-ID: <8kld9h$489$1@nnrp1.deja.com> In article , "Neil Hodgson" wrote: > Now that Microsoft have revealed their Intermediate Language (IL) > virtual machine, are we going to see a version of Python that > compiles directly to IL? Or will Python byte codes still be > interpreted by C code? Directly to IL - although there is still a runtime that handles some of the Python semantics. This new compiler could be compared, conceptually, with JPython - it is a completely new implementation of Python. It has a compiler that generates native Windows .DLL/.EXE files. It uses a runtime that consists of a few thousand lines of C# (C-Sharp) code. The Python programs can be debugged at the source level with Visual Studio 7, as well as stand-alone debuggers for this environment. Python can sub- class VB or C# classes, and vice-versa. Unfortunately, there will not be a public release of their SDK for a couple of months - so the only people able to use this compiler are people who attended the PDC, and hence have the pre-beta SDK on their conference CDs. The compiler is looking pretty reasonable. pystone.py (amongst others, of course) compiles and runs. However, this should be quite exciting for the Python community. The general feel of the conference here is that the MS .NET technology is exciting and a good thing. I predict that the Windows community will embrace this technology, and having Python be a first-class citizen is a good thing! It _is_ a radical change. Future work on this compiler will be under the ActiveState banner. However, the compiler and the runtime are all open source. The compiler is written in CPython, and uses win32com to get at the Reflection::Emit APIs provided by .NET. All the existing work has been done mainly by me, with some code and advice from Greg Stein. Now the NDA is lifted, I hope (some of) the Python community will get behind this, and take advantage of the open-sourceness of the compiler and runtime, and help us turn this into an excellent language for this environment. All good stuff (IMO, of course) None of this is speaking for ActiveState - just my personal opinion. Mark (still at the PDC!) Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Sat Jul 29 06:57:01 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 12:57:01 +0200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: <8luhsm31ce8@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o4aid.7dm.grey at teleute.rpglink.com... > On Fri, 28 Jul 2000 19:29:52 -0400, Karl Ulbrich wrote: > >If they already contained numbers (well, strings of digits), and you were > >certain, then simply: > > > a = int(b) > > As stated, that would work except Python returns a None on a no-match and Incidentally, you can change that if you wish -- it ain't hard! See: >>> re.match('a(\d+)|b(\d+)','a3').groups() ('3', None) but: >>> re.match('a(\d+)|b(\d+)','a3').groups('0') ('3', '0') None is the DEFAULT returned for nonmatching groups, but if you don't like that, the argument to the groups method of the match object is just the ticket. > None can't be converted. No, but '0' easily can, and as we've seen it's very easy to arrange for groups to return that if so desired. So, to summarize...: >>> there = re.compile('a(\d+)|b(\d+)') >>> map(int, there.match('a3').groups('0')) [3, 0] >>> map(int, there.match('b4').groups('0')) [0, 4] I do not think this need be the best approach to the specific problem you've stated, but it's surely one approach to keep in mind. 0 rather than '0' as the argument to groups would work just as well, btw, since int(0) and int('0') both evaluate to 0...:-). So, an alternative implementation of the function I already proposed, and here repeat...: def intGroups(match, default=0): results = [] for g in match.groups(): if g: results.append(int(g)) else: results.append(default) return results would be: def intGroups(match, default=0): return map(int, match.groups(default)) It's certainly more concise, and most likely faster, too, but readability is debatable. If one just does not like map, a middle of the road alternative: def intGroups(match, default=0): results = [] for g in match.groups(default): results.append(int(g)) return results You see, even in Python tmtowtdi -- we just don't _emphasize_ that:-). The ideal would be to have ONE obvious way to do it -- although the 'obvious' part may not be obvious until you know the language and standard library pretty well:-). In that light, I suspect the Obvious Way here is yet another: def intGroups(match, default=0): matches = match.groups(default) return map(int, matches) Clearly equivalent to the one-liner, but, by giving a name to the tuple returned by groups, albeit a local and quite transient one, we give it, I feel, just the light-touch sort of emphasis it deserves here -- a 'subdued highlight', if you'll pardon the oxymoron, that seems to me to make it very readable... and to suggest all sorts of useful generalizations, such as, say: def translatedGroups(match, translate=int, default=0): matches = match.groups(default) return map(translate, matches) intGroups=translatedGroups Note that I've provided a synonym for the most likely usage with the binding right after the def -- another useful idiom, I believe. Alex From keitt at nceas.ucsb.edu Sun Jul 23 19:07:41 2000 From: keitt at nceas.ucsb.edu (Timothy H. Keitt) Date: Sun, 23 Jul 2000 16:07:41 -0700 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <397B7ABD.FF7F7281@nceas.ucsb.edu> Huaiyu Zhu wrote: > > all the different languages or packages. Brief summaries by their users > here would provide very helpful background information. Operators for the R language are summarized here: http://stat.ethz.ch/R-alpha/doc/html/function.html R uses * for elementwise array multiplication and %*% for matrix multiplication. (The '%op%' notation is a general mechanism for defining arbitrary infix operators.) Tim -- Timothy H. Keitt National Center for Ecological Analysis and Synthesis 735 State Street, Suite 300, Santa Barbara, CA 93101 Phone: 805-892-2519, FAX: 805-892-2510 http://www.nceas.ucsb.edu/~keitt/ From ajsiegel at my-deja.com Mon Jul 24 13:14:43 2000 From: ajsiegel at my-deja.com (ajsiegel at my-deja.com) Date: Mon, 24 Jul 2000 17:14:43 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <8lhij5$278$1@slb2.atl.mindspring.net> <8lhmgd$p92$1@nnrp1.deja.com> Message-ID: <8lhtht$v1e$1@nnrp1.deja.com> In article <8lhmgd$p92$1 at nnrp1.deja.com>, jerry_spicklemire at my-deja.com wrote: > > This suggestion makes perfect sense, in cases where Python has > already been adopted by the substantial, for profit shop in question. > One could then assume that Python is recognized for it's merits, and > that the "customer" realizes that, as with any Open Source tools, it > is easy and effective to contribute by scratching your own itch, and > returning the resulting solution to the community. > But I wasn't necessarily suggesting that there would be a contribution back to the community. There would be a proprietary solution - and perhaps a competitive advantage achieved. The contribution back to the community would be a separate business decision. Certainly this makes particular sense to me when me are talking about functionality against a commercial database. Sent via Deja.com http://www.deja.com/ Before you buy. From Richard.Jones at fulcrum.com.au Fri Jul 28 00:16:01 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 28 Jul 2000 14:16:01 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from Steve Lamb of 2000-Jul-28 3:29:6, Message-ID: <200007280416.OAA31003@envy.fulcrum.com.au> [Steve Lamb] > On Fri, 28 Jul 2000 11:37:46 +1000, Richard Jones > wrote: > > Hey, don't worry about mis-using the linenoise - you just have to _look_ > >at the damn structure in Perl the wrong way and suddenly it's something else > . > > Please, be realistic. How is this different than Python's automatigal > variable declaration based solely on first use? Eh? You're comparing the assignment operation - the placing of a label on an object - with the automagical creation of an object? How is: a = 1 ... the same as $a = undef; $a->{foo} = 1; ... not raising an error? ... especially when the second is buried deep in some complex application and fails to raise an exception, thus masking the true source of the error? Richard From mas at echo.fr Thu Jul 6 03:37:19 2000 From: mas at echo.fr (Roland Mas) Date: Thu, 06 Jul 2000 07:37:19 GMT Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> Message-ID: <87zonvso9c.fsf@cachemir.echo-net.net> Curtis Jensen (2000-07-05 17:13:13 -0700) : > What is the difference between Py_Apache and mod_python? There's mod_snake too, just to add to the confusion. Roland. -- Roland Mas Food, shelter, source code. -- Cyclic Software From tim.hochberg at ieee.org.bbs Mon Jul 17 16:40:04 2000 From: tim.hochberg at ieee.org.bbs (tim.hochberg at ieee.org.bbs) Date: 17 Jul 2000 20:40:04 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bROc5$l0C@openbazaar.net> "Kevin Jacobs" wrote in message [SNIP] > Silly idea 1: > > Until add-on Python grammar modules are available, what about a PyAlgebra > evaluator module. For a precedent, see regular expressions. The > difference is that linear-algebra syntax can be made too Python-like for > some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() > > Admittedly, its not perfect, nor optimally compact, but it is no longer > encumbered by having to support the full Python grammar and is free to > redefine as much as necessary. Interestingly, an idea very similar to this was floated in the NumPy community a couple years ago, but for entirely different reasons. The motivation for this at the time was in order to support more efficient matrix operations (eliminating intermediate results and such) and possibly compiling the expression to native code. Digging through some of the NumPy archives would probably reveal some interesting discussion of this possibly not so silly idea. -tim From m.faassen at vet.uu.nl Fri Jul 28 16:41:31 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Jul 2000 20:41:31 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8lsr5r$hrq$2@newshost.accu.uu.nl> Steve Lamb wrote: [snip] > Ah, but getting back to that point I said to remember. > foo = "a" > foo = list(foo) > foo is not ['a']. It took a single element and made it a list. So we now > know that a single element has a sequence. Here is another sequence of a > single element. > foo = 1 > foo = list(foo) > Error. Single element sequence. Remember, any sequence can either be a > single value or a sequence. Yet here we have a single value denied. Quirks > abound. Ahum, now watch this: foo = 1 foo = foo + 1 foo is now 2. So, '+ 1' takes a single integer and makes it the number 2. So now we know that a single integer is turned into 2 that way. Here's another integer: foo = 3 foo = foo + 1 Foo is now 4! But we just determined + 1 turned something into 2, right? :) Your reasoning is faulty. In Python, a string is a sequence. That's why list("a") works. It turns a string sequence of characters into a list sequence of characters (or strings, in fact, as characters and strings are the same in Python). Please, do find the inconsistencies and quirks of Python _where they actually are_. Most of what you're finding *is* consistent and is not a quirk. It's merely different than what you're used to. The only real quirk you found is None = 1, and even that is a consequence of a consistency. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From kpmurphy at my-deja.com Thu Jul 6 10:49:56 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Thu, 06 Jul 2000 14:49:56 GMT Subject: tkinter frames Message-ID: <8k26af$1nq$1@nnrp1.deja.com> can anyone tell me why this doesn't work? from Tkinter import * root = Tk() myFrame = Frame(root, width=200, height=200, bg='red') myFrame2 = Frame(root, width=200, height=200, bg='orange') label1 = Label(myFrame, text='hi') myFrame.grid(row=0, column=0) myFrame2.grid(row=0, column=2) root.mainloop() ...(in my mind)it should display two colored frames, one containing a label. thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From jessaustin at SPAMFREE.lucent.com Wed Jul 5 05:48:20 2000 From: jessaustin at SPAMFREE.lucent.com (Jess Austin) Date: Wed, 5 Jul 2000 17:48:20 +0800 Subject: Python COM for Linux? References: <8ja7gv$687$1@nnrp1.deja.com> <3958c185.103629691@news> Message-ID: <8juulj$csu$1@pony.kenan.com> Grant Edwards wrote in message ... > >I have a Python program that fetches mail from MS Exchange >Server using MAPI/COM. I'd dearly love to run it under Linux. >Does anybody have an experience with accessing MS Exchange >Server via COM from Linux? I'd love to take a look at this. I'm always interested in anything that could help me escape the drudgery of Outlook. Can you post a link? thanks, Jess From glandrum at my-deja.com Thu Jul 20 00:19:56 2000 From: glandrum at my-deja.com (Greg Landrum) Date: Thu, 20 Jul 2000 04:19:56 GMT Subject: Discussion: new operators for numerical computation References: Message-ID: <8l5ul2$sic$1@nnrp1.deja.com> > > I can't see a good answer here. NumPy has been around for a long time > and I believe it has a fairly large user base which is a strong > argument in favor of the ".x" operators being matrixwise. However, > other operators within python (*,+) operate "objectwise" on sequences > (concatenation and replication). I think it would be suprising if > these operators were elementwise for matrices and objectwise for > other, similar, objects (sequences). This tends to favor ".x" being > elementwise. > [apologies in advance for how rambling this is] I'm just an ordinary NumPy user, but I know I'm not in favor of any new syntax which is going to break my existing code (at least until the mythical Py3K appears, at which point I'll probably just suck it up and figure out how to make things go). I have a lot of Numeric code which is reliant upon * being elementwise, consequently I have a major problem with that mysteriously changing. I think Tim did a great job of summarizing that there aren't compelling reasons pointing for either alternative syntax, so I think we should at least try to obey the commandment: Thou shalt not change syntax in ways which breaks existing code. Of course, if it turns out that MatPy has a much larger user base than Numeric Python (which I find unlikely), and * means "matrix multiplication" then I will be sad for having made the wrong choice two years ago and I'll have to undertake the enormously painful task of updating most every piece of code I've written. Can you detect my enthusiasm? I, for one, find MatLab's syntax loathsome and don't really want to have to use something that acts like it. I also like the fact that I have to explicitly type "matrixmultiply" to invoke an order-dependant operation (since * is normally commutative). I could live with .* though. Well, that's my view from the peanut gallery. -greg Sent via Deja.com http://www.deja.com/ Before you buy. From NOSPAM_rdrew at cia-group.com Tue Jul 4 17:46:55 2000 From: NOSPAM_rdrew at cia-group.com (Ray Drew) Date: Tue, 4 Jul 2000 22:46:55 +0100 Subject: Can't get pythondoc to work Message-ID: <8jtm0o$6rv$1@soap.pipex.net> I can't get pythondoc to work. I've got pythondoc, pythondoc\formatters and pythondoc\xref in the pythonpath. When I try to run it on the test.py file I get a couple of module not found errors, even though they appear to be in the python path (I can import them interactively in PythonWin). When I try to run python pdoc.py test.py I get this traceback: D:\bin\cpython\Lib\pythondoc>python pdoc.py test.py Warning: Failed to import internalXref (exceptions.ImportError: No module named docobjects) Traceback (innermost last): File "pdoc.py", line 2, in ? import pythondoc.pythondoc File "pythondoc.py", line 81, in ? formatters.init(_options) File "formatters\__init__.py", line 4, in init init(__path__, options) File "formatters\format_init.py", line 25, in init import pythondoc.message ImportError: No module named message The pythonpath is: D:\bin\cpython\Lib\pythondoc>echo %pythonpath% d:\bin\cpython\lib;d:\bin\cpython\lib\Numeric;d:\bin\cpython\lib\htmldoc;d:\ bin\ cpython\lib\pythondoc;d:\bin\cpython\lib\pythondoc\formatters;d:\bin\cpython \lib \pythondoc\xref Python 1.5.2 on Windows 98 Can anyone see what I'm doing wrong? Thanks, Ray From lars.lundstedt at telia.com Tue Jul 11 15:01:24 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Tue, 11 Jul 2000 19:01:24 GMT Subject: Enumerating drives in Python or wxPython Message-ID: <8aKa5.485$652.11285@newsc.telia.net> The subject line says it all. How do I do it? Anyone who knows? /LasseLu From bvdpoel at uniserve.com Sat Jul 15 22:42:36 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 15 Jul 2000 19:42:36 -0700 Subject: converting tcl database file to python References: <3970F455.58A6CAD3@uniserve.com> <3971004C.93FEC29F@wam.umd.edu> Message-ID: <3971211C.A2F151FD@uniserve.com> Bob Schmertz wrote: > > Bob van der Poel wrote: > > > also thinking that this is dumb. If I were using C I'd use a structure > > like this: > > > > typedef struct{ > > char *Title, *Artist, *Composer, *Timing; > > }CDITEM; > > typedef struct{ > > char *Name; > > char *Comment; > > char *CDItem[]; > > }CDENTRY; > > > > CDENTRY Mydata[maxtitles]; > > > > Or something like that. Any suggestions on how that would translate to a > > proper python idiom? > > > > Did you consider a CdItem class? No. I've looked at them but the one thing that bothered me is that after defining a class (aka structure) one is free to add variables a will. > class CDITEM(): > def __init__(self, name, comment, etc): > self.name = name > self.comment = comment > self.etc = etc > > mydata = [] > mydata.append(CDITEM("Thriller", "gift from my mom", "more stuff")) For example, after the above I can write: mydata.dummy="bad data" but, since it's just as hard to access the 'dummy' I guess it's not a big deal. Just used to C too much I guess. Looks like a class is the way to go. > > 2. Any quick ideas on how to convert the tcl-style data file to > > something python can deal with? > > Tcl's probably what I'd go with for this. Haven't dealt with it for a while, > though. Yes. started a bit this PM. I think that what I'll do is write a conversion in tcl and end up with a very-verbose datafile format. With PentiumIIs who cares about a few extra cycles of overhead parsing a file. I've just gotta get into the 21th century. -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From thomas at xs4all.net Thu Jul 6 16:30:42 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 22:30:42 +0200 Subject: Having problems with Exceptions In-Reply-To: <3964ADE0.E8051736@orci.com>; from mblatch@orci.com on Thu, Jul 06, 2000 at 10:03:44AM -0600 References: <3964ADE0.E8051736@orci.com> Message-ID: <20000706223042.C26534@xs4all.nl> On Thu, Jul 06, 2000 at 10:03:44AM -0600, m wrote: > I'm new at Python coding and am trying to catch > errors returned by os.open with exception handling. > All errors with os.open are returned with an OSError > exception. So, how do I split out the individual errors > with something as simple as: > try: > file=os.open("test",os.O_RDWR | os.O_CREAT | os.O_EXCL, 0444) > > except OSError: > {want to do different things here for errno EEXIST (file exists) > or EACCES (Permission denied), etc.} > I have looked at the tuple returned by sys.exc_info() and can > extract the *text* of the Python error message > (i.e. "[Errno 17] File exists"), but not the numeric error number. > I certianly don't want to have to rely on parsing the text to get > the actual error. I'm sure there is an easy answer to this if > someone would be kind enough to help me. You're looking for the 'errno' attribute of OSError objects. You should compare them to constants defined in errno, for compatibility, like so: import os, errno try: file = os.open("test", ... ) except OSError, e: if e.errno == errno.EEXIST: print "The file eixsts already" elif e.errno == errno.EACCES: print "Can't touch this" elif e.errno == ELOOP: print "symlink after " * 1024 + "symlink!" -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sw8t at node1.unix.Virginia.EDU Thu Jul 20 13:20:10 2000 From: sw8t at node1.unix.Virginia.EDU (Scott Witherell) Date: Thu, 20 Jul 2000 13:20:10 -0400 Subject: FAQ maintenance with Python ... Message-ID: I'm setting up a web FAQ for my research lab and wanted to use Python. I quickly found the FaqWiz and used that (with a couple minor modifcations). And it's great - except that it seems quite difficult to reorder the FAQ entries after they've been entered. Everybody in the lab is just gonna throw stuff on this FAQ and I'm sure that a month or two down the road we'll have a much better idea of how we would like the FAQ organized. So it seems likely that I'll want to do some fairly drastic reordering (both within category and across). Has anyone else run into this problem? If so how did you solve it? The FaqWizard uses RCS to track changes - a tool I've never used before. In my mind (before I found FaqWiz) I had just imagined a simple flat file containing position, question, and answer for each entry. I'm not the world's greatest coder, so I was happy to find FaqWiz. But, I'm just not sure if it will save time in the long run. Any advice is appreciated. Thanks, scott From anamax at earthlink.net.bbs Sun Jul 16 16:20:16 2000 From: anamax at earthlink.net.bbs (anamax at earthlink.net.bbs) Date: 16 Jul 2000 20:20:16 GMT Subject: Funding vs Python Message-ID: <3bQYbG$hK7@openbazaar.net> I was tired of hearing a friend talk about how wonderful Python is, so I decided to learn Python by using it to implement a product that the official implementation team thought would take experts 1-2 man years using numerous Java buzz-words. A month later, I'm still a Python newbie, but I'm close enough to done that I'm looking at the rev 2 feature list. (The experts are still trying to hire but are going to start any day because other folks like running code more than they like plans.) No good deed goes unpunished, so now I'm getting push back along the lines of "we can't get funded if it's in Python". (Somehow, I don't think that using Perl would have produced the same reaction.) I've seen the list of web projects at python.org, so I'm wondering if there are others or if there really are examples of companies that didn't get funded because they used Python. -andy Sent via Deja.com http://www.deja.com/ Before you buy. From grey at despair.rpglink.com Sat Jul 29 18:56:43 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:56:43 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> Message-ID: On Sat, 29 Jul 2000 03:35:05 GMT, Ben Wolfson wrote: >If you write the numeral one on a board and ask 2 dozen people off the >street what it is, how many of them will say it's a sequence? How many would say that abc is a sequence. ;P >Seeing what the quote in my .sig is, I'd like to emphasize that it was >chosen randomly. Bwaahahahaha.. . I'll have to remember that one for work some time. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From MarkH at ActiveState.com Thu Jul 27 01:30:26 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 27 Jul 2000 05:30:26 GMT Subject: Python and COM: Aggregation? References: Message-ID: "John Doty" wrote in message news:AiPf5.138$6Z.107941 at paloalto-snr1.gtei.net... > I love Python. I want to use it for all my programming needs. > > But I can't. > > Is there a reason that COM objects implemented in Python are not > aggregatable? Simply no one has been bothered to add it. AFAIK, no one plans to, either. Patches would be accepted tho! Should be not too difficult as we already support delegation of IUnknown back to another object to support COM identity rules. Mark. From vxgvxg at my-deja.com Wed Jul 5 12:27:01 2000 From: vxgvxg at my-deja.com (vxgvxg at my-deja.com) Date: Wed, 05 Jul 2000 16:27:01 GMT Subject: Telnetlib Message-ID: <8jvnjs$f2l$1@nnrp1.deja.com> Hi, When using any of the telnetlib read functions (such as read_all(), read_until(), etc.), the 0x00's seem to be dropped from the data stream. Any ideas? Sent via Deja.com http://www.deja.com/ Before you buy. From baron at null.net Sat Jul 8 23:25:23 2000 From: baron at null.net (Matthew Schinckel) Date: Sun, 9 Jul 2000 12:55:23 +0930 Subject: What about try:except:finally In-Reply-To: References: <3967d908.363887342@news.online.no> Message-ID: On Jul 8, I overheard Alan Daniels mutter: > On Fri, 07 Jul 2000 13:20:25 GMT, Thomas Weholt wrote: > > [paraphrased...] > >Does python support, or if not, would it be cool to have support for > >try/except/finally? > > No, but just use try/except/else instead. Why it's "else" instead of > "finally", I have no idea, but this works just fine. Example: Yes, but if you want a statement executed regardless of whether there was an exception or not, you need to use a finally clause. -- Matthew Schinckel What this country needs is a good five cent microcomputer. From nowonder at nowonder.de Mon Jul 31 15:46:31 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 19:46:31 +0000 Subject: [5th Draft] Open Letter to CNRI: Request for clarification Message-ID: <3985D797.E5D2FC08@nowonder.de> added some names Should I add email addresses? --- begin open letter ------------------------------------------------- To: Dr. Robert E. Kahn , (president of The Corporation for National Research Initiatives) Dear Dr. Kahn, many people in the Python community around the newsgroup comp.lang.python are deeply concerned about the latest license issues that have arisen around the new 1.6/2.0 releases. The following attached signatures represent people from the Python community who would like some clarification regarding the future of the Python language. As of now, there has been no official statement from your institution regarding the new Python license. We are especially interested in the underlying intention of this change. So we request a plain-English, non-legalese statement regarding the purpose of that change and the ways in which it affects Python's use. Kind regards, Peter Schneider-Kamp --- end open letter ---------------------------------------------------- --- begin signature list ----------------------------------------------- Martijn Faassen Jay Graves Konrad Hinsen (Centre de Biophysique Moleculaire (CNRS)) Gareth McCaughan David Mertz (author of a Python column for IBM developerworks) Edward Jason Riedy Thomas Wouters (Systems Architect, Python developer) Moshe Zadka (mathematician, Python developer) --- end signature list ------------------------------------------------- Please add/change/remove your signatures. Feedback as always strongly appreciated. or-should-I-send-the-1st-draft--ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de -- http://www.python.org/mailman/listinfo/python-list From jhe at webde-ag.de Tue Jul 25 10:23:44 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Tue, 25 Jul 2000 16:23:44 +0200 Subject: how to build arbitrarily-sized lists in one fell swoop? References: <397DA1E0.B65DC47@cornell.edu> Message-ID: <8lk7q6$hvh$1@pollux.ip-plus.net> "Samuel Scarano" schrieb im Newsbeitrag news:397DA1E0.B65DC47 at cornell.edu... > There's a simple thing I want to do in python but I can't find a way that is > obvious to the reader and efficient for the interpreter. I want to make a > list with n copies of x. Now that's an easy one: >>> x = 1 >>> [x] * 10 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] From moshez at math.huji.ac.il Tue Jul 25 10:28:06 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 25 Jul 2000 17:28:06 +0300 (IDT) Subject: how to build arbitrarily-sized lists in one fell swoop? In-Reply-To: <397DA1E0.B65DC47@cornell.edu> Message-ID: On Tue, 25 Jul 2000, Samuel Scarano wrote: > There's a simple thing I want to do in python but I can't find a way that is > obvious to the reader and efficient for the interpreter. I want to make a > list with n copies of x. l = [x]*n -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From kmp at atrium.fsnet.co.uk Thu Jul 6 18:20:02 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Thu, 06 Jul 2000 22:20:02 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> <20000703.19444100@linux.local> <8jqnsu$m79$1@news1.xs4all.nl> <20000703.22081700@linux.local> <8k1hq0$k0r$1@news1.xs4all.nl> Message-ID: <20000706.22200200@linux.local> Boudewijn - Thanks for your continued interest. Your suggestion about removing config.cache and trying again was great. I did that and now the sip configure runs without any errors. I really thought that was the solution. But no, when I run the PyQt "make install" I still get the same error. This is weird as there are now no errors in the configure or make of either sip or PyQt and yet the make install of PyQt still fails. As for the development package - I have the qtdevel-1.44-52 rpm installed. Phil did kindly send me a private e-mail on the problem. He wrote: --- Because configure failed to find X, it disabled Qt support (even though it didn't tell you that's what it was doing). configure uses the standard AC_PATH_XTRA macro to find X - so I don't think the problem is related to SIP/PyQt/PyKDE. You need to work out why it's not finding X. ---- However, thanks to you, the sip configure *is* now finding X but I still have the same problem. Perhaps some other files need to be deleted ( I've tried deleting the PyQT config.cache but it made no difference). Best wishes -- Ken >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 06/07/00, 08:59:44, boud at rempt.xs4all.nl (Boudewijn Rempt) wrote regarding Re: Problem Installing PyQt-012: > > checking for X... no > I do think you need X, really. Have you got the development packages > installed? > If you try again, first remove config.cache, to force autoconf to look > again, then run ./configure again. If you still can't get it to work, > I'd suggest contacting Phil Thompson - he's far more knowledgeable > in compiling matters than I am. Success! > -- > Boudewijn Rempt | http://www.valdyas.org From alan.gauld at gssec.bt.co.uk Mon Jul 3 10:04:06 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 03 Jul 2000 15:04:06 +0100 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> Message-ID: <39609D56.C710B311@gssec.bt.co.uk> Robert Goto wrote: > I am sure there is a very simple answer to this. > >>> import regsub > >>> fimo = open('fimo.txt') > >>> while 1: > line = fimo.readline() > if not line: break newline = regsub.gsub('orange', 'red', line) print newlineline > getting is both the original string and the changed string?! What you are getting is gsub displaying its output because you haven't assigned it to anything and then you print the original string. Assign the result of gsub() to a variable then print that variable(as shown above). Note that because strings are immutable in Python(ie can't be changed) gsub *returns* the new string it does not(cannot!) change 'line'. Alan g. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From fiona at sitegnome.com Sat Jul 22 22:04:14 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sun, 23 Jul 2000 12:04:14 +1000 Subject: Making Windows GUI programs References: <8F776CE84nickperkinsusanet@203.2.75.243> Message-ID: <397A529E.900C180A@sitegnome.com> Olivier Dagenais wrote: > > I recommend wxPython ( www.wxpython.org ) > > http://www.faqts.com/knowledge-base/view.phtml/aid/3565/fid/473 Looking at the answer in FAQTs, only 3 out of 12 people said the answer was useful.. I'm very tempted to remove this answer altogether, so, this is a call to improve the current answer. As it stands currently: --------start---------- What is wxPython? How does it compare with Tkinter? Fiona Czuczman, Olivier Dagenais Shae Erisson, http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpother wxPython [ http://www.wxpython.org ] is a set of Python bindings for the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was written as a C++ library to provide a platform-independant way of implementing rich and fast user interfaces. ----------------------------------------------------- I chose wxPython over Tkinter (for my projects) because: - wxWindows seems to have more widgets than Tk - special widgets (like the TreeView) are implemented using the operating system's native implementations, not complete re-writes - it's more than a "lowest common denominator" among platforms, wxWindows seeks to provide the same, advanced functionality on all platforms, even if it means they have to write a lot of code to complement a platform's native component - wxWindows seems to cover more ground, in terms of functionality (it's more than a GUI toolkit, it also seeks to provide functions/classes for files, threads, printing, clipboard, networking, ODBC, etc...) - I was *really* impressed with the wxPython demo ----------------------------------------------------- The wxWindows documentation emphasizes the "less good" points of other GUI toolkits (namely Tkinter) to motivate wxPython: http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpothe r --------end-------------- Thanks, Fiona Czuczman > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Nicko" wrote in message > news:8F776CE84nickperkinsusanet at 203.2.75.243... > > Hi. I was wondering if anyone could point me in the direction of some GUI > > help for windows. I would like to write a program using the windows API > > set, but the help file that came in the win32all package doesn't make any > > sence to me. If someone can point me in the direction of maybe a tutorial > > or a nice document that can help, I would be greatful > > > > Thanks in Advance, > > Nick Perkins -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From deprince at sprynet.com Sat Jul 8 13:04:00 2000 From: deprince at sprynet.com (Adam DePrince) Date: Sat, 08 Jul 2000 17:04:00 +0000 Subject: How to print to stdout in binary References: <8k1kn5$mkt$1@nnrp1.deja.com> <3965408E.DDD4A2@pehr.net> Message-ID: <39675F00.DC04D6E9@sprynet.com> pehr anderson wrote: > > What platform are you developing on? > under linux I did the following in a file "t.py": > > > > Thanks > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. Python's "open" is a wrapper around the C-lib's "fopen" function. C wants new lines to be represented as a "\n" (ASCII dec 10) Most Unixes and other non-MS operating systems conform to C's nomenclature. Other operating systems, noteablely Microsoft's stuff, use a two byte sequence "\r\n" or #13;#10; (or is ot #10;#13;, I forget which order) to indicate a new line. It is a _good thing_ for automatic translation to occur for text files; it is a bad thing for this to happen for binary files (i.e. the binary format author may not include the notion of lines, or appreciate their newlines being munged) Also, some OS's like VMS actually have a special flag in the file's directory entry indicating if it is a "binary" or "text" file. C, in an effort to support all of these "flavors" permits the selection between text and binary. The results of this depend on the operating system, but in general are: Linux, BSD, all other Unix deriviatives: The "b" flag has no effect. MSWindows: The "b" flag indicate that automatic translation from window's to C's newline convention should _not_ take place. VMS: Set the file's binary flag accordingly. Does anybody know if VMS does Windows style translation too? Or, to quote from Linux's man page (sec 2, open) The mode string can also include the letter ``b'' either as a last character or as a character between the charac ters in any of the two-character strings described above. This is strictly for compatibility with ANSI C3.159-1989 (``ANSI C'') and has no effect; the ``b'' is ignored on all POSIX conforming systems, including Linux. (Other systems may treat text files and binary files differently, and adding the ``b'' may be a good idea if you do I/O to a binary file and expect that your program may be ported to non-Unix environments.) -- Adam DePrince - firstname at lastname dot net, all in lowercase From max at alcyone.com Mon Jul 31 14:37:19 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 31 Jul 2000 11:37:19 -0700 Subject: random.shuffle? References: Message-ID: <3985C75F.7030AB6C@alcyone.com> Fran?ois Pinard wrote: > def shuffle(items): > """Shuffle ITEMS in place. ITEMS should normally be a list.""" > for top in range(len(items)-1, 0, -1): > index = whrandom.randint(0, top) > items[index], items[top] = items[top], items[index] This is a biased shuffling algorithm. When swapping cards, you'd want to pick the other card from the whole of the deck, not the deck that you've touched so far. If you start with a sorted deck, for instance, it's easy to see that cards can't end up in every place; see Knuth. Better would be this: def shuffle(list): count = len(list) for i in range(count): j = whrandom.randint(count) list[i], list[j] = list[j], list[i] Simpler, too. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Love is the most subtle form of self-interest. \__/ Holbrook Jackson Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From no at bo.dy Fri Jul 21 00:13:00 2000 From: no at bo.dy (nobody) Date: Thu, 20 Jul 2000 23:13:00 -0500 Subject: iterating over lines in a file References: Message-ID: Moshe Zadka , in : [...] > Preventing world war III, when Python achieves world domination. If C is > allowed to achieve world domination, WWIII will be cause by > if(everything_is_ok = 0) { > launch_missile(); > } i sort of see the point, when you're speaking of beginner programmers still confused by the common algebra equal sign and trying hard to sort out assignment from comparison, but i honestly don't see many more seasoned programmers making that mistake. maybe i'm just weird that way. (then again, i keep wondering why native speakers of the english language misplace the apostrophe. i never make that class of mistakes either, my brain just isn't prone to it. maybe it's the learning two other languages before english that inoculated me somehow... both my other ones deal with that sort of grammar very differently, so maybe i just don't see the apostrophe as something confusing because of that. who knows.) oy. that paragraph very little sense. time to go to bed, i think. From bjorn at roguewave.com Mon Jul 10 16:13:53 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 10 Jul 2000 14:13:53 -0600 Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> Message-ID: <396A2E81.9ED567FA@roguewave.com> Erik Max Francis wrote: > > I'm fairly new to Python, although it's simple enough that I've already > been able to write some fairly involved programs in it (I already know > C, C++, Perl, etc.). This question isn't so much about what's going > wrong, but rather what's the best, most natural way to get around it. > > I've come across a problem due to circular references, and I'm not sure > what's the best way to tackle it. In essence, the problem is that I > need a particular class to keep an associative array of its methods for > a lookup table (it's essentially a dispatcher). But with references to > its own bound methods, Python's garbage collector concludes it has > circular references and thus its destructor never gets called. > > Here is a simplified standalone program that demonstrates what I'm > talking about: > > class C: > def __init__(self): > print "in constructor" > self.map = { 'f': self.f, 'g': self.g } > > def __del__(self): > print "in destructor" > > def f(self): > print "in C.f" > > def g(self): > print "in C.g" > > def dispatch(self, name): > self.map[name]() > > c = C() > c.dispatch('f') > > When run, this program prints > > max at charmaine:~/tmp% ./circ.py > in constructor > in C.f > > and that's it; because of the circular reference, the destructor never > gets called. > > For the application I need, it's imperative that the destructor get > called. What is the best way to solve this? I can think of a few: > > - Move the map to a local variable in the dispatching function > - Make map a lookup table of _unbound_ methods > - Build a string of the function call and then exec it > > What would be the most effective way of getting around this? I'm > thinking that using unbound methods would probably be the best way. It depends on what kind of control you have... The most straightforward is probably something like: class C: def __init__(self): print "in constructor" self.map = { 'f': self.f, 'g': self.g } def __del__(self): print "in destructor" def f(self): print "in C.f" def g(self): print "in C.g" def dispatch(self, name): self.map[name]() def close(self): del self.map try: c = C() c.dispatch('f') finally: c.close() It would probably be more natural to implement the destructor logic in the close method with this scheme... -- bjorn From hzhu at localhost.localdomain Mon Jul 17 21:52:20 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 01:52:20 GMT Subject: Does Python support interfaces? References: Message-ID: On Tue, 18 Jul 2000 01:08:03 GMT, Randall Parker wrote: >I'm quite new to Python. For those who are familiar with Java interfaces: >Does Python have a similar facility? > >Can one declare interfaces, then declare that a class implements some >interface, instantiate an object of that class type, and then cast it to >an interface that it is declared to support and then pass it around as a >reference to that interface type and make calls to methods of that >interface type? > Maybe someone has a better solution, but here's a little program that checks which method is implemented in which class, of what type. You can add more bells and whistles in similar fashion (like the names of arguments) http://x53.deja.com/getdoc.xp?AN=635109618 I can only track it in deja news. It seems that the archive for Jun 1-15 is missing from pipermail archive. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From thomas at xs4all.net Sat Jul 22 12:27:03 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 22 Jul 2000 18:27:03 +0200 Subject: Dynamic package exploration In-Reply-To: <3978E7A6.2311C6F@rational.com>; from spierre@rational.com on Sat, Jul 22, 2000 at 12:15:34AM +0000 References: <3978CDBA.5859E594@rational.com> <20000722003043.F9897@xs4all.nl> <3978E7A6.2311C6F@rational.com> Message-ID: <20000722182703.L9897@xs4all.nl> On Sat, Jul 22, 2000 at 12:15:34AM +0000, Sebastien Pierre wrote: > BTW, what happens if I do "import os" and then I do a "os=Thing()" and I > do "print os.name", assuming that my Thing instance has a name="Hello" > property ? Assignment works differently, in Python, than in most languages. Assignment just binds a name in the local namespace to an object. With 'import os', you load the module 'os' (which usually is linked statically, so is already imported) and bind it to the local name 'os'. If you then do 'os=Thing()', you create a new Thing (or call the function Thing, if it's a function or other callable object) and bind the resulting object to the local name 'os' -- overwriting the previous 'os'. > I guess it will print "Hello" ....but what is the scope of name > resolution, something like block->function->class->module ? 'local' -> 'global'. 'global' is the top-level of the module, and 'local' is the current function or class, or the same as 'global' if you are at the top level. So: #file spam #global: x = 1 if x: y = 2 #local: def spam(x): z = x class Spam: _a = 1 Note that nothing is said about nested functions! You can only 'reach' the current function, or the global namespace, so you can't actually do this: def spam(x,y): def doit(): print "spam spam spam"*x for i in range(y): doit() Because 'x' doesn't exist in doit()'s local namespace, and it doesn't exist in the global namespace, this'll give a nameerror. (unless 'x' does exist in the global namespace, in which case you might get unexpected behaviour.) Oh, there is also a magical third namespace, the 'builtin' one. It contains all the builtin functions, and is queried last. You can't accidentily write to it, though you can create a variable with the same in the local or global namespace, 'shadowing' the builtin. Tutorially-y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From thomas at xs4all.net Wed Jul 12 13:23:12 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 12 Jul 2000 19:23:12 +0200 Subject: Why are some infinite recursion stack overflows hard to deal with? In-Reply-To: ; from cut_me_out@hotmail.com on Wed, Jul 12, 2000 at 10:58:39AM -0400 References: Message-ID: <20000712192312.O7340@xs4all.nl> On Wed, Jul 12, 2000 at 10:58:39AM -0400, Alex wrote: > > Python has a hack to try to deal with that: it checks bounds on the > > recursion itself. However, Python's guess is a bit off on windows. > It seems to be a bit off on Linux, too. That's where I'm getting the > segfault. Hmm... What version of Python, and compiled how ? (Standard distribution python, or self-compiled ?) I can't reproduce this on vanilla Python 1.5.2, on BSDI, in any case. I'll try on Linux later. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jmcbray at carcosa.net Thu Jul 27 11:57:39 2000 From: jmcbray at carcosa.net (Jason F. McBrayer) Date: 27 Jul 2000 11:57:39 -0400 Subject: Sound---Anyone play with it in python? References: <397FDBE9.B8E1A2E0@bresnanlink.net> Message-ID: >>>>> "AB" == Aaron Berg writes: AB> Does anyone know of a working wrapper or module that can manipulate AB> sound in python? I think 2.0 will have a linuxaudio module standard. AB> The ESD wrapper is the one I am trying to get to work so far AB> and I get a bad file descriptor when I try to write to the sound AB> buffer. Coincidentally, I was trying out the ESD module yesterday, and got the same thing. I don't think you're doing anything wrong; I think the ESD module is for a much older version of ESD than we're using. -- +-----------------------------------------------------------+ | Jason F. McBrayer jmcbray at carcosa.net | | A flower falls, even though we love it; and a weed grows, | | even though we do not love it. -- Dogen | From to_get_my_address at see.my.signature Thu Jul 27 01:04:55 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 18:04:55 +1300 Subject: Tokenize.py for C++? References: <8ljjj2$803$1@desig-bs01-s04.adtranzsig.de> Message-ID: <397FC2F2.1B377A86@see.my.signature> Dirk-Ulrich Heise wrote: > > I could adapt tokenize.py myself, > but maybe somebody already did something in > this direction. If you want to roll your own scanner, you might find my Plex module useful: http://www.cosc.canterbury.ac.nz/~greg/python/Plex -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From hzhu at localhost.localdomain Mon Jul 17 20:47:07 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 00:47:07 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> <39739291.4155A128@prescod.net> Message-ID: On Mon, 17 Jul 2000 18:11:13 -0500, Paul Prescod wrote: > There are even techniques for making your >language work on the interpreter line. We can help with that. Where is this? Is it also included in the references you mentioned? I don't have time or expertise to examine these, but someone else might. Huaiyu From fiona at sitegnome.com Mon Jul 10 05:24:16 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 10 Jul 2000 09:24:16 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 10th, 2000 Message-ID: <20000710092416.30388.qmail@synop.com> Hi Guys, Below are the entries that made it into http://python.faqts.com today. regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How can I do this Perl paragraph mode in Python? $/ = ''; # paragraph mode http://www.faqts.com/knowledge-base/view.phtml/aid/4629 ------------------------------------------------------------- Fiona Czuczman Harry George If you use pyperl: p=pyperl.Pyperl() p.INPUT_RECORD_SEPARATOR='' myfile=p.open("< $filename") lines=myfile.readlines() ------------------------------------------------------------- Is there anywhere I can get a list of the commands for python? http://www.faqts.com/knowledge-base/view.phtml/aid/4630 ------------------------------------------------------------- Fiona Czuczman Peter Schneider-Kamp Try the library and the language reference at http://www.python.org/doc ------------------------------------------------------------- How can I ring the PC's bell (ie internal speaker) to alert the operator that an operation has finished running? http://www.faqts.com/knowledge-base/view.phtml/aid/4632 ------------------------------------------------------------- Fiona Czuczman David Porter print "\a" ## Edited Entries ############################################## ------------------------------------------------------------- Is there a command/function in python to put a delay or wait step into a program? Does python have a sleep function? e.g. sleep(60) to wait 60 seconds? http://www.faqts.com/knowledge-base/view.phtml/aid/2609 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Andreas Jung,Greg Fortune, pehr anderson Try the sleep function in the time module. import time time.sleep(60) And put this in a while loop and a statement will only execute on the minute... That allows you to run a statement at predefined intervals regardless of how long the command takes (as long as it takes less than a minute or 5 or 60 or whatever you set it to) For example, I wanted to run a ping once a minute. If I just time.sleep(60) or time.sleep(45) even, the ping will not always take the same amount of time. Here's the code :) time.sleep(time.localtime(time.time())[5]) The [5] just pulls the seconds out of the time.localtime()'s return value. The great thing about time.sleep is that it supports floating point numbers! import time time.sleep(0.1) http://python.org/doc/current/lib/module-time.html ------------------------------------------------------------- What is the best way of setting default options of widgets? http://www.faqts.com/knowledge-base/view.phtml/aid/4151 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain,Cameron Laird You can use an option database. If you create a file called optionDB with for example the following kind of entries: *font: Times New Roman *Button*foreground blue *foreground black You can then apply these via root.option_readfile('optionDB') For more on this, see http://www.regularexpressions.com/#options ------------------------------------------------------------- Why are there no operators equivalent to C's , --, =, etc.? http://www.faqts.com/knowledge-base/view.phtml/aid/3378 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, Peter Schneider-Kamp, Michael Hudson if you write things like "var = var + 1" a lot, you might be missing some important python idioms... here are a few, in no specific order: for item in sequence: ... sequence = map(operation, sequence) sequence.append(item) for index in range(size): ... for item1, item2 in map(None, sequence1, sequence): ... for index in range(start, stop, step): ... n = sequence.count(item) for index in range(len(sequence)): ... sequence.remove(item) for index in range(len(sequence)-1, -1, -1): ... (also note that most basic types are *immutable*, so it's not entirely clear how things like ++ and += should work. Michael Hudson wrote a patch for the +=, -=, *=, /= and some other of these operators. A patch can be found at: http://starship.python.net/crew/mwh/aug-patch.html http://www-jcsu.jesus.cam.ac.uk/~mwh21/aug-patch.html ------------------------------------------------------------- Is there a utility to convert module docstrings to HTML for nice documentation? http://www.faqts.com/knowledge-base/view.phtml/aid/4610 ------------------------------------------------------------- Stu D, Fiona Czuczman Richard Jones >From http://starship.python.net/crew/danilo/download.html: Gendoc generates documentation from Python source code in different formats. Currently it can generate HTML, MIF, MML and plain old ascii (MIF and MML are FrameMaker formats). If you want to generate HTML files, I strongly suggest you grab a copy of Robin Friedrich's HTMLgen package, with which gendoc generates quite nice pages, optionally with frames. From loredo at spacenet.tn.cornell.edu Tue Jul 25 16:38:42 2000 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Tue, 25 Jul 2000 16:38:42 -0400 Subject: ZORB for Mac? Message-ID: <397DFAD2.6354B460@spacenet.tn.cornell.edu> Hi folks- Has anyone out there built ZORB (the object database for Zope) for the Mac? If not, does anyone know of any obstacles to a Mac build of just this part of Zope? If not, I'll give it a go. But if someone already knows that it relies on system calls not available on the Mac, I'd rather not spend the time rediscovering this for myself! Thanks, Tom Loredo From mwh21 at cam.ac.uk Tue Jul 18 02:19:39 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 Jul 2000 07:19:39 +0100 Subject: Python equivalent of CPAN in Perl References: <397122FB.71E32674@wl.vg> <8krfa9$vf4$1@nntp9.atl.mindspring.net> Message-ID: Robin Becker writes: > Unfortunately not true. A large share of the Python market (on win32) > have no compilers and probably wouldn't/couldn't use one even if it were > present. I doubt the extension builders will always want to include > .pyds for Python15.dll Python20.dll etc etc. But distutils will make it much easier for someone else to provide the binaries... Cheers, M. -- After a heavy night, I travelled on, my face toward home - the comma being by no means guaranteed. -- paraphrased from cam.misc From johnvert at my-deja.com Sun Jul 9 14:58:23 2000 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Sun, 09 Jul 2000 18:58:23 GMT Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> <87zonvso9c.fsf@cachemir.echo-net.net> <71vfmsc0sspvpg3mq8k3s1ri653908u9nk@4ax.com> <396863B7.875EA939@stroeder.com> Message-ID: <8kai0a$7fm$1@nnrp1.deja.com> In article <396863B7.875EA939 at stroeder.com>, Michael =?iso-8859-1?Q?Str=C3=B6der?= wrote: > Tim Roberts wrote: > > > > I'll say. Am I correct in understanding that the basic purpose of > > "mod_snake" is to allow me to write other Apache modules in Python, while > > PyApache is a module which lets me run Python CGI scripts without > > launching a separate interpreter, > > Yes. PyApache resets the Python interpreter everytime which leads to > reloading of the modules for every hit. > > With mod_python you can write Apache handlers but also wrap normal > CGI-BIN scripts without having to reload the modules for every hit. > > Ciao, Michael. Which one of these modules can you use to write embedded python code? I.e. foo.html.py: Looping through red, blue, green: colors = ['red', 'blue', 'green'] for color in colors: print color Thanks, -- John Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Mon Jul 17 14:40:57 2000 From: aahz at netcom.com (Aahz Maruch) Date: 17 Jul 2000 18:40:57 GMT Subject: Tutorials at IPC9 References: <39591877.535A96BC@sage.att.com> Message-ID: <8kvjvp$m2$1@slb1.atl.mindspring.net> [p&e in case Garry's at OSCON and not reading c.l.p this week] In article <39591877.535A96BC at sage.att.com>, Garry Hodgson wrote: > >I'm not looking for specific topics per se (although I'm open to >suggestions), but rather what kind of classes would be useful. To get >things going, here are some thoughts I had on what might be good: > >More in-depth tutorials, perhaps something that might build a complete >application in Tkinter or Zope, giving a sense of real implementation >issues. Perhaps even a two part class: half lecture and half >instructor-led implementation of some significant, but manageable, >project. > >Overview courses, to compare and contrast various alternatives for a >given task. Like, say, a course that would show how to use Tkinter, >wxPython, PyQt, and PyGTK to solve user interface problems. This could >be either a survey of features, or a comparison of apps built in each. >I'd prefer the latter; what do you think? I think it's pretty hard to get a general read on what people prefer in terms of style. So much depends on the individual person taking the class, as well as the instructor. Most of the really good ideas require having machines available -- do you know at this point that you'll have the resources for that? In general, what bothers me about most classes is that they're too dang slow -- the instructor is too willing to bog the class down for the benefit of the slowest person in the class. When I do presentations, people are often surprised at how much material I cover in a short period of time, but I rarely get complaints, because I usually cover the material multiple times in slightly different ways, each time going a little deeper into the details. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From herzog at online.de Mon Jul 10 18:40:57 2000 From: herzog at online.de (Bernhard Herzog) Date: 11 Jul 2000 00:40:57 +0200 Subject: Setting a C-structure from Python References: <39649D5C.F1652171@seatech.fau.edu> <3967F70C.17A90288@seatech.fau.edu> <8k9p88$1s19@drn.newsguy.com> Message-ID: Armin Steinhoff writes: > In article <3967F70C.17A90288 at seatech.fau.edu>, Benoit says... > > > >I think I find out where the bug was. > >Thanks Armin ! > > > >Why this C extension didn't work ? > > > >> > >> static PyObject * test_setstruct(PyObject * self, PyObject * args) { > >> PyObject * string_from_python; > >> > >> if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; > >> > >> example= (examplestruct *) PyString_AsString(string_from_python); > >> Py_DECREF(string_from_python); This Py_DECREF is the culprit. example is only a borrowed reference to the string object and you don#t have to DECREF it yourself. > >> print_struct(); > >> > >> Py_INCREF(Py_None); > >> return Py_None; > >> } > > [...] > I believe the real point is that you can't apply the "S" format to a "string > buffer" which contains binary zeros. IMHO it corrupts the interpreter. No, Python's string objects handle embedded NULs just fine. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From rumjuggler at cryptarchy.org Fri Jul 28 00:15:24 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 04:15:24 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 03:29:06 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: > > Just playing around try this some time: > >a = None >list(a) >a = 1 >list(a) >a = 123 >list(a) >a = "abc" >list(a) > > To me all of those could be converted into lists yet only the last one is. >Why do I say that? > > None could be converted into an empty list. None is nothing. I fail to >see how you can't populate a list with a single nothing. > > 1 is a single value. I fail to see why that cannot be converted to [1] >which is allowed, btw. >a = [1] >a > > 123 is a single value. I fail to see why that cannot be converted to >[123] which, again, is allowed. See above. I would never, personally, have expected list(123) to return a list containing only the element 123. After all, that isn't how it works with _any_ other data type. > "abc" could either be a single value or a sequence. It is converted as >["a", "b", "c"]. Of course, the same /could/ be said for the above. However, >let's play around with this one since it is the only one that works somewhat >as expected in conversion. _any_ sequence can be either a single value or a sequence. The fact that list() (and tuple()) only work on objects that actually have a sequence mapping makes a lot of sense and, to me, resolves the ambiguity in precisely the way I would expect. >>> a = (1,3,'5') a is a single value. It's a tuple. If list() took single values and made them into single-element lists, and tuple() worked accordingly, I would expect >>> tuple(list(a)) to return ([(1,3,'5')],). To have list() and tuple() behave one way when given non-sequence arguments, and another when given sequence arguments, rather odd for two reasons. Firstly, it's unnecessary. If I have a single value in X, and I want to make it a single-element list, there's a way to do that: >>> some_variable = [X] That is how you construct single-element lists. list(), as its docstring clearly states, creates a list from a sequence. Secondly, it's counterintuitive. You say "all of those can be converted into lists"; I look at 1 and think, "what is the list equivalent of an integer?" >a = "abc" >a >a = list(a) >a = str(a) >a > > a is now "['a', 'b', 'c']". Which means we split a string up when >converting to list but don't concatinate on the way back. Why should str(['a','b','c']) == str(['abc']) == str(['ab','c']), etc? The str() function doesn't know that its argument was originally constructed from a string. I would be very surprised if I were appending values to a list, and, in the process of debugging, printed its contents to see what it contained, and got one long undifferentiated string. If you want concatenation, you can use reduce(), string.join(), or a string's join() method (post 1.5.2). -- Barnabas T. Rumjuggler God will forgive me; that's his job. -- Heinrich Heine From michael at stroeder.com Mon Jul 24 04:54:36 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 24 Jul 2000 10:54:36 +0200 Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <397BE9FE.BF003A13@stroeder.com> <8lgujm$rhr$1@pollux.ip-plus.net> Message-ID: <397C044C.BC71E994@stroeder.com> "J?rgen Hermann" wrote: > > "Michael Str?der" schrieb im Newsbeitrag > news:397BE9FE.BF003A13 at stroeder.com... > > Don't be unfair! You forgot mod_snake! > > => there are *three* competing version. ;-) > > Actually, there are four. URL? Ciao, Michael. From dale at out-think.NOSPAM.co.uk Sun Jul 9 15:51:20 2000 From: dale at out-think.NOSPAM.co.uk (Dale Strickland-Clark) Date: Sun, 9 Jul 2000 20:51:20 +0100 Subject: How to approach this? Message-ID: <8kal5v$8n5$1@supernews.com> I'm still getting to grips with Python so this may sound basic: I have one class which handles a database connection and a number of other clasess which need that connection. I want there to be just one instance of the database class which is created as soon as it's needed by a dependant class. There could be any number of instances of the dependant classes appearing and disappearing during a run. How do I make sure that the database object is properly closed when there are no instances of the dependant classes left? Thanks for any help. Dale Strickland-Clark From gbreed at cix.compulink.co.uk Thu Jul 13 06:35:18 2000 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 13 Jul 2000 10:35:18 GMT Subject: ASP Questions Message-ID: <8kk616$5ck$1@plutonium.compulink.co.uk> Here are some outstanding problems I have with ASP files written in Python. Hopefully, some of you will have solutions. I can't write to session or application variables. In VBScript, this is done like Session("key")="value". In Python, for writing to a new key, that translates to assignment to None. I found some documentation for fixing this in P*rlScr*pt, but still can't get it to work in Python. Response.Redirect doesn't terminate execution of the script. I'm getting round this by throwing an exception, but is there a command that can do the same job more cleanly? I ran a script with an infinite loop once. How should I have terminated it (other than by proof reading my code better)? I'm finding the, when Append-ing parameters to a stored procedure, the parameter names are ignored. Is this right? This isn't a Python problem, but I thought I'd throw it in anyway. Right, that'll do. Thank you for you time and any replies. Graham From steedman at quake.cs.fsu.edu Mon Jul 24 06:19:52 2000 From: steedman at quake.cs.fsu.edu (Ronald Steedman) Date: 24 Jul 2000 10:19:52 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> Message-ID: <8lh588$oti$3@news.fsu.edu> A full compile of a complex software package can often take 30 seconds or more. That can be frustrating when you're trying to find and remove bugs. You try one thing, wait 30 seconds, try another thing, wait 30 seconds... Imagine how an intepreter would help. Try one thing IMMEDIATELY SEE THE RESULT... try another thing IMMEDIATELY SEE THE RESULT... then you only compile the application when you're finished and want a faster program. I like how Visual Basic offers both compiled and interpreted programs. I would like to see Visual C++ follow suit. :) -- Ron Steedman In comp.games.development.programming.misc slaurijssen wrote: : Oh, I'm sorry. I didn't realize there would actually be someone that : actually wants to use it. What's the point in using a C++-interpreter when : it's just as easy to compile the source, which has more advantages? : But who am I to argue, : the package is called CINT and I found a link at : http://root.cern.ch/root/Cint.html : Jm schreef in berichtnieuws : 397ab732.1184204 at news.proxad.net... :> Do you have a link to it, :> or at least the name of that interpreter ?? :> :> -- :> :> On Thu, 20 Jul 2000 20:36:49 +0200, "slauijssen" :> wrote: :> :> >Err, by the way :> >On a linux cd I found a C++ interpreter. The funny thing is that the :> >interpreter itself is written with c++ and interprets itself to interpret :> >the really to interpret code. Got it? ;-) :> > :> >Mallor schreef in berichtnieuws :> >v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... :> >> Are any of you game developers out there using Python as your game :> >engine's :> >> embedded scripting language? I am wondering what drove your decision : to :> >use :> >> Python instead of other embeddable scripting languages? I'd like to : hear :> >what :> >> your overriding concerns were, and also what they are now, having put :> >Python to :> >> the test. :> >> :> >> -- :> >> Cheers, Infernal Troublemaker Troll :> >> Mallor "By simple mistake, mortals themselves amuse." :> >> :> >> :> >> :> > :> > :> From nowonder at nowonder.de Mon Jul 31 19:53:23 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 23:53:23 +0000 Subject: [6th Draft] Open Letter to CNRI: Request for clarification Message-ID: <39861173.30E94EDC@nowonder.de> PREFACE: Anyone can sign this open letter. This is not only for hardcore coders and Python developers, but for every Python user/addict out there. - more signatures - minor editing --- begin open letter ------------------------------------------------- To: Dr. Robert E. Kahn , (president of The Corporation for National Research Initiatives) Dear Dr. Kahn, Many people in the Python community have concerns about the license issues that have popped up around the new 1.6/2.0 releases. The following attached signatures represent people from the Python community who would like some clarification regarding the future of the Python language. To date, there has been no official statement from your institution regarding the new Python license. We are especially interested in the overall intent of this change. So we request a plain-English, non-legalese statement regarding the purpose of that change and the ways in which it affects Python's use. Kind regards, Peter Schneider-Kamp --- end open letter ---------------------------------------------------- --- begin signature list ----------------------------------------------- Martijn Faassen [m.faassen at vet.uu.nl] Stuart Ford (Programmer/Analyst E.H. Boeckh Corporation) Jay Graves Magnus Lie Hetland (Ph.D. student Computer Science) Konrad Hinsen (Centre de Biophysique Moleculaire CNRS) Michael Hudson (maths grad student, Python developer) [mwh at python.net] Aahz Maruch [aahz at pobox.com] Gareth McCaughan David Mertz (author of a Python column for IBM developerworks) Edward Jason Riedy Will Ware Thomas Weholt Thomas Wouters (Systems Architect, Python developer) Moshe Zadka (mathematician, Python developer) [moshez at math.huji.ac.il] --- end signature list ------------------------------------------------- Please add/change/remove your signatures. Feedback as always strongly appreciated. or-should-I-send-the-1st-draft--ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From GustavsB at ch.sibt.com Fri Jul 14 04:53:12 2000 From: GustavsB at ch.sibt.com (Bruno Gustavs) Date: Fri, 14 Jul 2000 10:53:12 +0200 Subject: Top 10 Language Constructs (Phyton) Message-ID: <8kmkam$m45$1@pollux.ip-plus.net> What do you think are the top ten language constructs in Phyton ? Please don't answer in terms of OO concepts, but try to restrict yourself to those statements you really use to cope with your daily work. Curious why I'm asking this question? In spite of all requirements engineering effort we know exactly *how* to solve problems with computer languages but know fairly, *what* we're doing during this process. Regards Bruno Gustavs From bill at dehora.fsnet.co.uk Sat Jul 29 15:09:00 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Sat, 29 Jul 2000 20:09:00 +0100 Subject: Perl is worse! References: <3h8zumi4i2.fsf@angband.org> Message-ID: <8lva5q$bga$1@news6.svr.pol.co.uk> > Funny, I thought that was what comments were for. > > match = re.match(r'(\d+)') > foo = int(match.group(1)) > > vs. > > m/(\d+)/; > foo = $1; # should be a number > > Given the choice, I'd rather have comments, not cues in the code. :) Comments are a last resort, with the exception of API level documentation a l? Javadoc. Though God knows the JDK could do with explaining *how to* and *how long*. Comments fall out of line with code over time. That is simply a fact of software development. A lot of big software is commented by people other than those who developed it; usually long after is has been developed. I know of programmers who will remove all comments in code they have inherited, and then get to the code. What it does *now* is more important than what someone *thought* it *used* to do. It's my hope that future languages will not allow in-code comments, the same way Python has dumped bracketing. Instead replace comments with naming, abstraction and unit tests. Comments are a story about code; too often that story is fairy tale. If you can't clarify your code without inline comments, you're not done. -Bill de h?ra From cmyanko at bigfoot.com Tue Jul 25 08:14:42 2000 From: cmyanko at bigfoot.com (Hartford Hackers) Date: Tue, 25 Jul 2000 12:14:42 GMT Subject: Test framework of choice? References: <8F7B7D888beablebeable@209.155.56.81> <8lj0v2+8r4u@eGroups.com> Message-ID: <8lk0bf$f4h$1@nnrp1.deja.com> I was waiting to see who won the Software Carpentry contest myself. -- -Curtis Yanko Sent via Deja.com http://www.deja.com/ Before you buy. From akuchlin at mems-exchange.org Tue Jul 18 16:38:27 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Jul 2000 16:38:27 -0400 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l2ce1$de2$1@sun500.nas.nasa.gov> Message-ID: <3dem4r41j0.fsf@kronos.cnri.reston.va.us> "Chris Knight" writes: > It's very much appreciated, any possibility of (cross-)posting it to > c.l.p.announce? There seems little point, since comp.lang.python.announce is effectively dead until Markus Fleck either begins handling submissions in a timely fashion or adds more people as moderators. So, c.l.p only for now. I'll try to set up a Web archive, though, if the postings become a regular thing. --amk From denalione at my-deja.com Mon Jul 17 09:14:49 2000 From: denalione at my-deja.com (Dale Burnett) Date: Mon, 17 Jul 2000 13:14:49 GMT Subject: built in sources Message-ID: <8kv0rr$lm2$1@nnrp1.deja.com> where can I get the source for all of the built-in methods, types, etc... Thanks Sent via Deja.com http://www.deja.com/ Before you buy. From schorsch at schorsch.com Fri Jul 28 06:06:12 2000 From: schorsch at schorsch.com (Georg Mischler) Date: Fri, 28 Jul 2000 10:06:12 GMT Subject: Pmw dialogs - very slow References: <3980375F.4D366654@proceryon.at> Message-ID: <8lrlui$673$1@nnrp1.deja.com> Horst Gassner wrote: > Hi all! > > Am I doing something wrong or are Pmw dialogs really so slow? > > Here are the lines of code: > s.notYetImplemetentedDlg = Pmw.MessageDialog(s.parent,defaultbutton=0, > title = notYetImplementedHdrTxt, message_text = notYetImplementedTxt) > s.notYetImplemetentedDlg.activate(geometry = 'centerscreenalways') > > The dialog frame appears very fast but it takes between 1 and 2 > seconds to display the contents! > [...] > Is there a possibilty to speed this up? My experiments have shown that this has something to do with the sequence of function calls in the setgeometryanddeiconify() function in the file PmwBase.py. I'm not sure if I have found the "correct" sequences yet, but I could get rid of the symptoms for the unix branch by moving the final "window.tkraise()" from the last line up to just below the "else:". Not really understanding everything that happens there, I can't stress enough that this means just treating the symptoms for the moment. There may be other dependencies that would dictate a different sequence. Maybe Greg could comment? -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Mon Jul 10 09:22:06 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 10 Jul 2000 15:22:06 +0200 Subject: EOF References: <396623EE.211B14E9@sis.it> Message-ID: <8kcisv0180s@news2.newsguy.com> "fae" wrote in message news:396623EE.211B14E9 at sis.it... > Sorry, > how can I test if I reached the end of file ? Depends on how you're reading it. If you're reading it with thefile.readline(), this will return a false value when, and only when, there is nothing more to read; otherwise the returned value (the line just read) is non-false (this is because the ending '\n' is NOT removed, so even reading an empty-line returns at least a '\n', which does not test as false). Alex From paul at prescod.net Sat Jul 15 06:45:29 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 15 Jul 2000 05:45:29 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <396F1914.DBE530CA@prescod.net> <396FE1CE.FE9967A8@prescod.net> Message-ID: <397040C9.D9279D8@prescod.net> Huaiyu Zhu wrote: > > ... > > Python already provides both function names and binary operators, so the > first level issue is not there. However, while it gives almost unlimited > supply of function names that can be overridden, there is only a handful of > binary operators which have deep rooted meanings and not enough for > overloading. This limit is largely arbitrary, and is therefore complexity. No, the set of operations is not arbitrary. They are the set of operations that most people learn in high school and are basically the same set in every other mainstream programming language in the universe. By the way, if we are going to add a bunch of formally meaningless operators to the language, are we going to add unary, binary, ternary and quaternary ones? > Haven't we already talked this through? Text processing already got its > special syntax, even of the first level, which is quoted string. You have got to be joking. Quoted strings are a "special syntax?" Then I guess matrices got in their special syntax also: [[5,4,3],[2,8,5],[9,7,1]] In fact, it really is the case that there is special syntax in the language for matrix processsing. But you are asking for a whole new level. > Within a > quoted string you could put in any text sequence. In this specific domain > it happens that only very limited number of binary operators are required, > and they are duly provided, like string + string, string % string, or string > * number. Not true at all. Perl provides a much, much richer set of operators for working with strings. The most obvious binary operator Python is "missing" is "does this string exist in that string". But text processors learned to live with functional syntax (".find") and so can matrix users. Python's core string operators are not really everythin gyou need for "text processing" any more than they are everything you need for matrix processing. Text processors just learned to survive with functions and methods. Matrix processors will too. Moshe has some good ideas in this vein. (.Element()*... > All the other things you mentioned could be built on top of this. > This domain is not even as mature as matrix computation - in many earlier > languages it was though that special syntax is needed for printing, formats > and regular expressions, which turned out to be just ordinary string > operations and functions, as python shows. Perhaps that rather shows that matrix computation is not as mature as string processing. "In many earlier languages it ws thought that special syntax is needed for element wise computation, which turned out to be just ordinary matrix functions, as MatPy shows." Anyhow, it isn't that Python showed that other string operators are not important. It's that Python showed that moving those operations to a library makes text processing *more verbose* but makes *Python simpler*. The same holds for matrices. > On the other hand, for proper matrix operation, there is not much need for > any additional first level structure, but there does exist a great need for > a larger supply of binary operators. What we are saying is that extending > the number of operators overridable by applications represents a much > smaller risk of incompatability than giving everyone a complete parser. A smaller risk of incompatibility but a larger risk of making Python complex and reducing its long-term popularity. > With the given operators, all the fields like scientific computation, > graphics, statistical analysis and artificial intelligence could also be > built on top of this. What if they want a completely different set of operators syntactically? What if they want unary and ternary ones? Could I design the operators with an eye to XML and then force you to make them fit matrix processing? > Before you dismiss numerical computation as just another domain, why not try > a few packages and get a feeling of how large the domain is? It doesn't matter how large the domain is. It is nevertheless just another domain. Most people doing matrix computation with Python acknowledge this and have been conservative in their requests on the core. People have been doing numerical processing in Python for a long time you know. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From swun at esec.com.au Mon Jul 3 19:51:03 2000 From: swun at esec.com.au (Sam Wun) Date: Tue, 04 Jul 2000 09:51:03 +1000 Subject: how to push data in to ssh in python? References: <395FF2D9.1B46251D@esec.com.au> Message-ID: <396126E7.B10A450B@esec.com.au> Oh yes, I actually print it to the stdout, and intended to use command "ssh -l swun hostname < out.dump" to send out.dump to the "hostname" in "swun" account, but I am not sure how to set up the "swun" account to receive this transaction. Thanks Sam. Thomas Wouters wrote: > On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun wrote: > > >Thanks > > Your question is incomplete. What do you want to do ? Did you look at > popen(), and is it not what you want ? Does ssh require the input to come > from a pseudo-terminal ? Can't you use a normal shell pipeline and make your > python script just 'print' what you want to output ? Are you encountering > difficulties with any of these ideas, or not finding the right documentation? > > Oh, and it's not necessary to post both in HTML and in plaintext.. Just > plaintext will do just fine ;) > > How-do-I-get-a-zilion-dollars-ly y'rs, > Thomas. -- Sam Wun Firewalls / Security OneGuard Senior Software Engineer Electronic Commerce eSec Limited Phone: +61 3 83715376 mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD -------------- next part -------------- An HTML attachment was scrubbed... URL: From ge at nowhere.none Fri Jul 28 11:29:57 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 15:29:57 GMT Subject: Perl is worse! References: Message-ID: In article , Steve Lamb wrote: >>For me, 1 and "1" are clearly not two numbers. The former is a >>number, the latter a string consisting of the character "1". Saying >>that they are numbers because we "see" they're numbers is like >>insisting one 1 + "one" to return 2 because "one" is so obviously a >>number. > > You see that only because you are a programmer and have gotten > used to the concept of types. For whom, exactly, are programming languages supposed to be designed if not for programmers? >I, too, am a programmer and I reject the concept of types >because to the human that concept is meaningless. The concepts are meaningful to me (and I find them useful). Therefore, according to your argument, I am not a human. Claiming the people with whom you're arguing aren't human doesn't seem to me like a useful way to construct an agrument. If you don't like types, use a language without types. Some of us find them useful. -- Grant Edwards grante Yow! Mary Tyler Moore's at SEVENTH HUSBAND is wearing visi.com my DACRON TANK TOP in a cheap hotel in HONOLULU! From paul at prescod.net Thu Jul 20 18:29:18 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 17:29:18 -0500 Subject: Type checking in python? References: <39770CD5.215D4C0C@cornell.edu> <397296BC.415C97E1@prescod.net> <8l7au1$mf6$1@nntp6.u.washington.edu> <39774DBC.5785A660@cornell.edu> Message-ID: <39777D3E.8FAE2FA2@prescod.net> Samuel Scarano wrote: > > (First of all, I just wanted take a moment to thank Paul Prescod for his > very informative response to my post in this thread.) Glad to help. I'll poke my nose in one more time: > Fair enough. I agree that implementing the necessary methods is the most > practical solution in this case -- and in many others. However, I think that > the obvious objection to this approach would be that because there *are* no > explicit interfaces in python, you can't create a class that's guaranteed to > work wherever another class works just by implementing the same methods. Okay, but that was always a false guarantee. You can implement the right interface but blow up on negative numbers, or even numbers or when the day of the month is a prime number. It is at least arguable that the chances of a type signature problem slipping through a rigorous test suite is pretty small. Now what if you use the time you saved setting up the interface hierarchy for improving the test suite. You might find BOTH your type signature problems AND more subtle logic problems. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From darrell at dorb.com Thu Jul 6 19:31:39 2000 From: darrell at dorb.com (Darrell Gallion) Date: Thu, 6 Jul 2000 16:31:39 -0700 Subject: Undocumented regex behaviour in re module References: <012f01d65299$646f54a0$6401a8c0@home> <3964D012.1796D248@appliedbiometrics.com> Message-ID: <03e901bfe7a2$56628a80$6401a8c0@home> It wasn't immediately obvious that I had slipped thought time. But I returned to the year 2000 with a sheepish look to see if anyone had noticed :o Though not before a time paradox was initiated with in my Zope instance. 2000-07-06T04:47:15 PROBLEM(100) ZODB FS FS21 warn: E:\zope\public/var/Data.fs Database records in the future 2000-07-06T05:14:03 PROBLEM(100) ZODB FS FS21 warn: E:\zope\public/var/Data.fs time-stamp reduction at 3180205 Thankfully exporting and importing fixed everything up. All without spinning my office into an alternate time line. Thanks for noticing. --Darrell From: "Christian Tismer" > Subject: > Re: Undocumented regex behaviour in re module > Date: > Sat, 4 Jul 2020 23:56:21 -0700 > > Please, share your time machine with us :-) > From max at alcyone.com Fri Jul 28 14:55:51 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 28 Jul 2000 11:55:51 -0700 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <3981D737.CBA366F@alcyone.com> Steve Lamb wrote: > As a human, type 1. Character? String? Integer? Floating > number? No, > it is 1 and it can be all of those all on context. In Python, and most programming languages that have some notion of type, it is an integer. If you wanted a string, then you'd have typed '1', or converted it to a string with `1` or repr(1) or str(1). An integer is not a sequence in Python. Insisting that it should be because you insist that it is (with no other justification) is rather bizarre. If you don't like Python, then don't use it. There are many reasons that a language (Python or otherwise) can rub you the wrong way. But trying to point out a flaw which is anything but is not an effective way of doing it. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ The only source of knowledge is experience. \__/ Albert Einstein Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From gjohnson at gs.verio.net Thu Jul 13 19:20:01 2000 From: gjohnson at gs.verio.net (Tony Johnson) Date: Thu, 13 Jul 2000 18:20:01 -0500 Subject: py-MySQLdb Message-ID: <022701bfed20$de95f850$4a7c01cc@gs.verio.net> I am hping that this is a god place t send something on this subject. But I was trying t send a sql query to a mysql server that contains static quoted material and my python local variables in a c.execute("query") line. I was just wondering if there was an easy way of using local variables in this line or do I need to create the query as one long variable and just remove the quotes... -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at ollie.clive.ia.us Sat Jul 29 00:45:14 2000 From: jeff at ollie.clive.ia.us (Jeffrey C. Ollie) Date: Sat, 29 Jul 2000 04:45:14 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> <8lsqld$hrq$1@newshost.accu.uu.nl> <82l4osonthc3dopu8s7ddrs7h4cgou1lgf@4ax.com> Message-ID: On Sat, 29 Jul 2000 03:43:38 GMT, Ben Wolfson wrote: >>>> def getnone(): > pass > >>>> import __builtin__ >>>> __builtin__.None = 1 >>>> type(getnone()) > I think that you are not fully comprehending the difference in Python between variables and objects. Variables in Python are nothing more that references to objects. When you type 'None' in a program, Python uses the object (usually, the 'None' object) referenced by the label 'None'. As you have found out, you can change which object that the label 'None' references. However, when a Python function exits without executing an explicit 'return' statement, the interpreter supplies the real 'None' object, and not the object referenced by the label 'None'. I'm sure that this was done (perhaps unintentionally) as a performance enhancement, as you wouldn't want to incur the expense of a variable dereference every time a function exited without executing a 'return' statement. Consider the following code: >>> a = None >>> type(a) >>> None = 1 >>> type(None) >>> type(a) From stephen_purcell at yahoo.com Thu Jul 27 21:39:18 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 28 Jul 2000 11:39:18 +1000 Subject: best apache+python module? In-Reply-To: ; from jasonives@hotmail.com on Thu, Jul 27, 2000 at 05:06:28PM -0700 References: Message-ID: <20000728113918.B12152@inkontact.com.au> Jason Ives wrote: > > I've been looking for an apache module that will run python .cgi's without > having to instantiate a new interpreter for each request. [snip] They all > seem rather sparsely supported.. Check out PCGI: http://www.digicool.com/releases/pcgi There's a HOWTO here: http://starship.python.net/crew/jbauer/persistcgi/howto/index.html -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From dalke at acm.org Sat Jul 29 02:10:30 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 29 Jul 2000 00:10:30 -0600 Subject: [Python-Dev] PEP 201, zip() builtin References: <200007280428.QAA09796@s454.cosc.canterbury.ac.nz> Message-ID: <8lv422$hdk$2@slb6.atl.mindspring.net> Guido van Rossum wrote: >There are a few >well-known cases where xrange() is to be preferred over range(), but >in *most* cases, I claim, range() performs well enough. Note that I'm >not saying that range() is faster than xrange() -- I am saying that it >is *fast enough* for typical usage. Though to point out, I've seen one code base where xrange was used extensively, because there is no time when xrange will fail miserably while there are cases where range will fail outright, as with very large data sets. The most important question for them was not performance but the implied restriction on the data size. Since people in the same shop use the same idioms, it's hard to make estimates as to the numbers that often use xrange over range, but it seems to be about 5% (let's say +5% and -3% for error bars). Mind you that the manuals and many of the existing programs are based off of your work, so there is going to be an implicit bias in being consistent with your way of doing things. The people who use xrange not only have to think it's appropriate for the data set, but have to justify having "non-standard" code. Thus, those 5% are not to be compared with the 95% who use range but the lesser number who use range over xrange despite knowing about its deficiencies. Me, I'm one of that subset of the 95% - I use range even knowing about is deficiencies and only rarely use xrange. But even better, I usually end up implementing a list-like forward-iterator for large data sets - that is, roll my own xrange. So I would mostly use zip and only rarely use xzip. Andrew dalke at acm.org From annis at biostat.wisc.edu Thu Jul 20 12:04:04 2000 From: annis at biostat.wisc.edu (William Annis) Date: 20 Jul 2000 11:04:04 -0500 Subject: closing a socket References: <8l72lp$mah$1@nnrp1.deja.com> Message-ID: Keith Murphy writes: > is closing sockets tricky? or am i doing something wrong... shouldn't > this work? There is one small thing you need, something every sockets beginner misses at first. I know I did... > s = socket(AF_INET, SOCK_STREAM) You need the set the 'reuse address' option: s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) > however, i get the following error if i try and run it a second time: > > socket.error: (125, 'Address already in use') -- 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 bjorn at roguewave.com Sat Jul 22 12:04:38 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 22 Jul 2000 10:04:38 -0600 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> Message-ID: <3979C616.CA01C09C@roguewave.com> Gordon McMillan wrote: > > Bjorn Pettersen wrote: > > >Paul Prescod wrote: > > >> Actually, I'm not sure if my proposal would help here. Appending to a > >> cStringIO is not an assignment operation... > > > >The only requirement was that the attribute access (myObject.property) > >stay the same, only instead of returning a string it would compute > >.value() on the cStringIO object. I.e., original: > > > > class MyObject: > > def __init__(self,s): > > self.s = s > > > >new version: > > > > class MyObject: > > def __init__(self,s): > > self._s = cStringIO.StringIO(s) > > def __getattr__(self, a): > > if a == 's': > > return self.__dict__['_s'].value() > > else: > > return self.__dict__[a] > > Umm, that should be: > def __getattr__(self, a): > if a == 's': > return self._s.value() > raise AttributeError, a > > (__getattr__ is last resort - not called if the attribute is found.) Yes, I knew that, and it didn't work... I didn't investigate much, but I think it might have been because the constructor really looked like: def __init__(self, **kw): self.__dict__.extend(kw) not sure about that though... > >> > Perhaps you should add a few words about why you chose __attr_XXX__ > >> > instead of __set/get/del_XXX__? > >> > >> That was actually the first proposal. But inheritance could get > >> confusing if you inherited set without get or get without set etc. > > > >Hmmm... I'm not quite sure I understand... > > Of course you don't! Because Paul forgot to tell you that the first > proposal said that defining one or more of __set/get/del_XXX__ > automatically defines all 3, with default behavior of "you can't do that". > So a base class defining __get_X__ and a derived class defining __set_X__ > will have the wrong semantics 50% of the time whichever way you choose to > handle it. Hey, I think I understand it now ! So the reason you need to install _one_ attribute handler with either scheme is that XXX has no relation to an actual attribute ("it is disallowed to have an attribute named XXX in the same instance dictionary as a method named __attr_XXX__.") It's therefore impossible to have a default set/get/del handler with the common semantics of setting/getting/deleting the attribute. Solving that problem by associating XXX with a 'real' attribute can't be done since it would probably require new syntax, and wouldn't always be desired... Am I close? -- bjorn From nowonder at nowonder.de Mon Jul 31 02:09:54 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 06:09:54 +0000 Subject: [Python-Dev] PEP 201, zip() builtin References: Message-ID: <39851832.6E0CC058@nowonder.de> Tim Peters wrote: > > Precisely that Greg Wilson's test subjects read it as cross-product rather > than lock-step. That leaves it backward-compatible but *un*reasonable > syntax; nobody (incl. Guido) liked such a big semantic difference triggered > by such a tiny bit of embedded punctuation anyway. Okay, just my point. BTW: My questionnaire run on c.l.py (which I left to Greg Wilson because he wanted to have it) was clear on that syntax, too: 6/9 thought it to be a syntax or type error 2/9 thought it to be cross-product iteration 1/9 thought it to be lock-step iteration 1-out-of-9-is-way-too-bad-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From darrell at dorb.com Sun Jul 2 23:02:57 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 2 Jul 2000 20:02:57 -0700 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> <395fcc6d$1_2@huge.aa.net> Message-ID: <005e01bfe49b$68c94d30$6401a8c0@home> >>> open('junk','w').write("red red red red") >>> import re >>> print re.sub("red","orange", open('junk').read()) orange orange orange orange >>> The changed string is returned. Strings in python don't change so the original buffer is unaffected. --Darrell ----- Original Message ----- From: "Robert Goto" > What is even more maddening to me is that when I save it to a module and run > it from NT command prompt......the output I get is the original file > contents only........like there was no regsub.gsub!! From speed at ?.com Fri Jul 28 16:17:17 2000 From: speed at ?.com (Jake Speed) Date: Fri, 28 Jul 2000 20:17:17 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: max at alcyone.com (Erik Max Francis) wrote in <3981DB97.E367C81E at alcyone.com>: >If 1 + 1 == 2 and '1' + '1' == '11' (note, not 11), then what should 1 + >'1' or '1' + 1 do? Implicit type conversion between incompatible types >(integer and string) is a bad idea in a strongly-typed language. A short, perlish aside: #!/usr/local/bin/perl printf "%s\n", 3 & 10; printf "%s\n", 3 & "10"; printf "%s\n", "3" & 10; printf "%s\n", "3" & "10"; ($x, $y) = "3 10" =~ /(\d+) (\d+)/; printf "%s & %s = %s\n", $x, $y, $x & $y; ==== 2 2 2 1 3 & 10 = 1 I like Perl, really I do :^) -Speed! From dnotspam-jen at personic.com Tue Jul 4 02:58:57 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Mon, 3 Jul 2000 23:58:57 -0700 Subject: Equivalent to ppm for Python? Message-ID: <3961881d$0$20233@wodc7nh6.news.uu.net> Is there anything like PPM for Python? For those who don't know, PPM is the Perl Package Manager (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility that will go out and download and install packages for you from the Internet (at least on Win32 -- I assume it works elsewhere, too). Jen From cb750chris at email.msn.com Sun Jul 2 18:53:41 2000 From: cb750chris at email.msn.com (Roger Upole) Date: Sun, 2 Jul 2000 18:53:41 -0400 Subject: Internet Explorer and Python/COM References: Message-ID: Here's a small sample of how to navigate to a URL. >>> import win32com.client >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') >>> x.Visible=1 >>> x.Navigate('http://www.python.org') If you run makepy on Microsoft Internet Controls, the file generated in Python\win32com\genpy will show all the properties and methods available for this object. HTH Roger Upole Moshe Zadka wrote in message news:Pine.GSO.4.10.10007022217420.19085-100000 at sundial... > > I'm really a beginner in Windows COM programming, so I'm sorry if my > question doesn't make sense. > > Can I use Python to run Internet Explorer and control it via COM? I mean, > telling it things like "Display this URL" or "Render this HTML". > (Maybe even putting a hook on URL displaying, so my Python program is > notified when the URL the browser is displaying changes) > > -- > Moshe Zadka > There is no GOD but Python, and HTTP is its prophet. > > From paul at prescod.net Mon Jul 17 15:12:02 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 14:12:02 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> Message-ID: <39735A82.8B4D0489@prescod.net> Huaiyu Zhu wrote: > > ... > > As to the claim that additional operators for linear algebra is somehow > comparable to the special syntaxes/quirks of various programming languages, > no real argument has been presented so far. Okay, then, let me try. > It's more like: If I don't care > and don't use such things, they must belong to a special domain and be > somehow comparable to some other things that I do know and dislike. Let me rephrase: "If MOST Python programmers don't care and don't use such things, they must belong to a special domain." I think that's a good operative definition of "domain specific". That's the crux of the argument. Don't throw complex numbers back in my face because they required *minimal new syntax*. There is already more "extra" syntax in the language for matrices than for complex numbers. I don't know why you have the impression that matrix operators have been compared to anything that people dislike. Most people have compared them to things that they *do* like, but must do through function syntax because Python doesn't pander to my particular needs or your particular needs, but rather those of most average programmers. I like XML processing and I daresay there are more books sold on it than on Matlab. But I've never asked for special, XML-specific syntax. Maybe you should consider how to scale back your syntactic request. Perhaps a single keyword or symbol at the beginning of an expression could make it element-wise or matrix-wise. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From jcm at bigskytel.com Sat Jul 15 03:35:07 2000 From: jcm at bigskytel.com (David Porter) Date: Sat, 15 Jul 2000 01:35:07 -0600 Subject: python cookbook In-Reply-To: <8km8l0$nc8$1@nnrp1.deja.com>; from akkhan@my-deja.com on Fri, Jul 14, 2000 at 05:32:16AM +0000 References: <8km8l0$nc8$1@nnrp1.deja.com> Message-ID: <20000715013507.A27936@novara.avenue> * akkhan at my-deja.com : > I have a copy of O'Reilly's book, "Perl Cookbook" , and I'm looking for > an equivalent Python cookbook. A book that has recipe's for doing > a variety of different tasks in Python, such as socket programming and > web automation. Have a look at (the eff-bot guide to) The Standard Python Library: http://www.pythonware.com/people/fredrik/librarybook.htm It is an online book in pdf format which can be purchased through Fatbrain. You need windows though (for now)... From jerry_spicklemire at my-deja.com Wed Jul 5 12:04:21 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Wed, 05 Jul 2000 16:04:21 GMT Subject: JPE: Java - C Python Extension Project References: <3962EBA5.E461DD4@arakne.com> Message-ID: <8jvm9o$dtj$1@nnrp1.deja.com> Cool! Might the work already done with Pyro serve as a jump-start? http://www.xs4all.nl/~irmen/python.html In article <3962EBA5.E461DD4 at arakne.com>, Jean Hemmi wrote: > We need a full-featured C-Python / Java integration! > We are laying out below the requirements to such an integration: > - Multithread compatibility (at least when the JVM relies on OS threads) > > - Access to the Java environment from Python > - Seamlessness from both sides > - Java objects appearing as native Python objects (resolving > overloading) > - Extensibility of Java classes into Python > - Access to the Python environment from Java > - Python objects accessible as Java objects > - Extensibility of Python classes within Java > - Exception mapping > - Python programming on client Web browser, like Javascript > - Ability to run Python bytecode files on the client Web browser > - Conciliation of security features (adapting Python's restricted > execution mode for 'Pylets') > Sent via Deja.com http://www.deja.com/ Before you buy. From forums at memoire.com Mon Jul 24 05:15:05 2000 From: forums at memoire.com (Guillaume) Date: Mon, 24 Jul 2000 09:15:05 GMT Subject: Class static variables References: <8l9vb3$kae$1@nnrp1.deja.com> <8la0fa$l9r$1@nnrp1.deja.com> <8la2mp$n5v$1@nnrp1.deja.com> <8lball$jrf$1@nnrp1.deja.com> <8lblc002pb1@news2.newsguy.com> Message-ID: <8lh1eo$a74$1@nnrp1.deja.com> Axel understood perfectly the goal of my question and the way I would like the code to behave. > This alteration is actually easier for the class case, as has > been pointed out, as long as, of course, __setattr__ knows > about it. For the variable case you'd HAVE to say global in > each block that rebinds it (analogous to saying CA.a in an > explicit way for the class field case, I guess). So here is the code which seams to do what I want. The few tests I made give good results. The only problem is the need to modify __setattr__ but it is not a problem for generated code (Java,C++,... -> Python) The only problem will be for Python->Python... but first my tool doesn't have a Python parser yet and second, I could mark special cases. Of course the fact to change the semantic of attributes can be a problem if someone want to maintain the generated code. First I used constructs like if name=="x": but in fact the use of try: makes it more general (no need to know the attribute name). Inheritance seams to work. If you know a better way, tell me. Guillaume This code will be released in Alma 0.26 http://www.memoire.com/guillaume-desnoix/alma/ #### CODE #### class A: def __setattr__(self,name,value): print "A: set "+name+" %s" % value try: A.__dict__[name] A.__dict__[name]=value return None except KeyError: self.__dict__[name]=value # static vars for A A.x="XX" A.w="WW" class B(A): # instance vars for B z=None def __setattr__(self,name,value): print "B: set "+name+" %s" % value try: B.__dict__[name] B.__dict__[name]=value return None except KeyError: A.__setattr__(self,name,value) # static vars for B B.y="YY" a=A() b=B() b.z="ZZ" print b.z print b.w print a.x a.x="XXXX" print a.x print b.y b.y="YYYY" print b.y print b.x try: print b.v except AttributeError: print "v is not defined..." Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sun Jul 23 13:30:07 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 12:30:07 -0500 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> Message-ID: <397B2B9F.6AA0AC59@prescod.net> Neel Krishnaswami wrote: > > ... > > I'm afraid I still don't understand. If I wanted to use separate > accessors/mutators, what would I do with the current proposal? > > An example (using separate accessors) that I'd like to see translated: > > class Foo: > def __init__(self, x): > self.x = x > > class LogWrites(Foo): > def __set_x__(self, x, val): > add_to_write_log() > self.__dict__['x'] = val > > class LogReads(Foo): > def __get_x__(self, x): > add_to_read_log() > return self.__dict__['x'] Even under the original proposal, this wouldn't have worked. __dict__["x"] is used by the mechanism. It can't have any value other than the attribute access handler object if you want things to work. self.x is reserved for the attribute access handler object. I would expect this: >>> print LogReads().x Here's how I would rewrite your code: class Foo: def __init__(self, x): self.__x = x class LogWrites(Foo): def __attr_x__(self, op, val): if op=="set": self.__x=val else: raise TypeError class LogReads(Foo): def __attr_x__(self, op, val): if op=="get": return self.__x else: raise TypeError Note that LogReads().x is unwriteable even from the base class. Python doesn't really differentiate between accesses from within the class and from outside. Even under the "one method per operation" proposal I think that you would have this problem. This is also the same as the current behavior with hand-written handlers using __setattr__. Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> class Foo: ... def __init__( self, x ): ... self.x=x ... >>> class Bar( Foo ): ... def __setattr__( self, attr, val ): ... if attr=="x": ... raise TypeError, "Not writable" ... else: ... self.__dict__[attr]=val ... >>> Bar(5) Traceback (most recent call last): File "", line 1, in ? File "", line 3, in __init__ File "", line 4, in __setattr__ TypeError: Not writable If a class designer wants to allow sub-classes to make attributes unreadable or unwritable, it should use __dict__["foo"] syntax rather than attribute access syntax to read and write them. In general, it can be painful to try and override a base class along a "vector" that was not specifically planned by the base class designer. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From kpmurphy at my-deja.com Mon Jul 17 16:01:30 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 17 Jul 2000 20:01:30 GMT Subject: grid References: <8kvkvt$68h$1@nnrp1.deja.com> Message-ID: <8kvome$9ah$1@nnrp1.deja.com> does this look alright? # embed.py from Tkinter import * root = Tk() left = Frame(root, bg='red') right = Frame(root, bg='orange') button1 = Button(left, text='hi') button2 = Button(right, text='yo') entry1 = Entry(left) entry2 = Entry(right) label1 = Label(left, text='this is schweet') left.grid(row=0, column=0, ipadx=10, ipady=10) right.grid(row=0, column=1, ipadx=10, ipady=10) button1.grid(row=0, column=0) button2.grid(row=0, column=0) entry1.grid(row=0, column=1) entry2.grid(row=0, column=1) label1.grid(row=1, column=0, columnspan=2) mainloop() # end embed.py thanks, -->keith In article <8kvkvt$68h$1 at nnrp1.deja.com>, Keith Murphy wrote: > can you embed grids? ...what i'd like to do is grid within several > frames, and then grid the frames together. sort of like html tables... > i hate pack. > > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From grey at despair.rpglink.com Fri Jul 28 01:00:16 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 05:00:16 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 04:15:24 GMT, Ben Wolfson wrote: >I would never, personally, have expected list(123) to return a list >containing only the element 123. After all, that isn't how it works with >_any_ other data type. Well, considering it doesn't work with most other data types, that isn't unexpected, isn't it? >_any_ sequence can be either a single value or a sequence. Right, any sequence. You said it, remember it, I'll get back to that. >The fact that list() (and tuple()) only work on objects that actually have a >sequence mapping makes a lot of sense and, to me, resolves the ambiguity in >precisely the way I would expect. >>>> a = (1,3,'5') >a is a single value. It's a tuple. If list() took single values and made >them into single-element lists, and tuple() worked accordingly, I would >expect No, a is a pointer to a tuple and the tuple contains three values. A tuple is just an immutable list. I'm not sure why anyone would want that, but hey, I'm sure there's a reason along there somewhere. I see three valies, 1, 3 & 5. >To have list() and tuple() behave one way when given non-sequence >arguments, and another when given sequence arguments, rather odd for two >reasons. I never said that. >Firstly, it's unnecessary. If I have a single value in X, and I want to >make it a single-element list, there's a way to do that: Really? >>>> some_variable = [X] Seems counter intuative, doesn't it, list() could take that single value and make it a single item in a list. I mean, c'mon, why have list when you could just construct a for loop to use an append method? >That is how you construct single-element lists. list(), as its docstring >clearly states, creates a list from a sequence. You're right. It does. >Secondly, it's counterintuitive. You say "all of those can be converted >into lists"; I look at 1 and think, "what is the list equivalent of an >integer?" That is because you're thinking in terms of types and not just data. It is a single element, nothing more. Ah, but getting back to that point I said to remember. foo = "a" foo = list(foo) foo is not ['a']. It took a single element and made it a list. So we now know that a single element has a sequence. Here is another sequence of a single element. foo = 1 foo = list(foo) Error. Single element sequence. Remember, any sequence can either be a single value or a sequence. Yet here we have a single value denied. Quirks abound. >> a is now "['a', 'b', 'c']". Which means we split a string up when >>converting to list but don't concatinate on the way back. >Why should str(['a','b','c']) == str(['abc']) == str(['ab','c']), etc? The >str() function doesn't know that its argument was originally constructed >from a string. I never said that, did I? No. Didn't I go on to state that I wouldn't expect it to work because going down the scale from structures down to simple data is hard. It would be like trying to stuff a directory into a list. Going from more complex to something simpler is always going to have some problems in implementation. I was just pointing out that, as with anything, there are quirks in the language that one must learn. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From richard_chamberlain at my-deja.com.bbs Mon Jul 17 05:00:01 2000 From: richard_chamberlain at my-deja.com.bbs (richard_chamberlain at my-deja.com.bbs) Date: 17 Jul 2000 09:00:01 GMT Subject: Tkinter and absolute positioning Message-ID: <3bR6R1$lXs@openbazaar.net> Hi Ruud, You can do absolute positioning with place: from Tkinter import * root=Tk() Label(root,text="He's not the messiah,").place(x=5,y=5) Label(root,text="he's a very naughty boy.").place(x=35,y=70) root.mainloop() Not highly recommended though! Richard In article <8kudt2$92e$1 at nnrp1.deja.com>, Ruud Cox wrote: > > > Is there a way to position child widgets on a TopLevel > widget using absolute coordinates instead of using pack, > place or grid? > > Ruud Cox > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com.bbs Mon Jul 17 14:10:02 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 17 Jul 2000 18:10:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRKgS$mjt@openbazaar.net> Charles Boncelet wrote: > > (Huaiyu Zhu wrote a proposal for adding special linear algebra > operator to Python) > > This proposal has been dismissed by many on this list (my > paraphrasing) > "because we don't want to pollute Python with new symbols/syntax > for just one problem domain." Some have dismissed linear algebra > as a small domain at that. > > Let's get some facts (yes, I know we are not supposed to let facts > interfere with our arguments on usenet): [severe case of non sequitur snipped] Perl, C++, Visual Basic, Java, and probably also Tcl are all more popular than Python. Are you suggesting we should add their special syntaxes/quirks just because a lot of people know them? hrmph! -- bjorn From bill at dehora.fsnet.co.uk Sat Jul 29 15:58:42 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Sat, 29 Jul 2000 20:58:42 +0100 Subject: Python is Zen (was Python is wierd) References: <39806045.F67EBD04@wag.caltech.edu> <8lt0ap$69q$2@newsg4.svr.pol.co.uk> <39829FF4.84DEDC6F@innuendo.de> Message-ID: <8lve96$hu3$1@news6.svr.pol.co.uk> "Ulrich Schreiner" wrote in message news:39829FF4.84DEDC6F at innuendo.de... http://www.bruceeckel.com/Python/ThinkingInPython.html "Bill de h?ra" wrote: > > Does this imply a "Thinking in Python"? > > -Bill de h?ra Wahoo!! (thanks, bye) -Bill de h?ra From btang at pacific.jpl.nasa.gov Tue Jul 18 18:19:28 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Tue, 18 Jul 2000 15:19:28 -0700 Subject: treeftp -- a smart ftp client Message-ID: <3974D7F0.89207A68@pacific.jpl.nasa.gov> treeftp -- a smart ftp client for Unix. By Benyang Tang. Version 0.50. 7/18/00 Complete documentation is in http://beluga.ocgy.ubc.ca/~tang/treeftp/readme_treeftp The whole package (3 files) are packed in the file treeftp.tar, which can be downloaded from http://www.ocgy.ubc.ca/~tang/treeftp Please send bug reports and questions to: btang at pacific.jpl.nasa.gov =========================== Features: =========================== * It uploads/downloads a directory tree, recursively. * When downloading, it preserves the time stamp (the modification time) and permission bits of the file. * When uploading, the time stamp is set to the time of uploading. However, with a switch -a (standing for archive), time and permission information of the file is also uploaded and stored in the remote site, so when downloading the file/directory with the same switch -a, the time stamp and permission bits are preserved. * With the switch -t, only the newer files are uploaded/downloaded. * The login process can be automated with the password stored in a only-owner-can-read file. -- <> Benyang Tang office: 818/354-0327 <> <> 300-323, JPL fax: 818/393-6720 <> <> 4800 Oak Grove Drive mail: btang at pacific.jpl.nasa.gov <> <> Pasadena, CA 91109, USA <> From neilh at scintilla.org Sun Jul 16 19:21:56 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 16 Jul 2000 23:21:56 GMT Subject: "Intellisense" drop-down... References: Message-ID: > I have found no way of defining new key combinations to select the currently > highlighted word in the "Intellisense" drop-down list. For example: > ... > I hightlight "Apply" and the only key I can use to make "Apply" appear and > the list to disappear is "Tab". I want other keys to trigger this. The > default.cfg file only lists this: When the previous post appeared about Ctrl+Enter in auto-completion, I had a look at extending the keys that would choose an item and tried changing this in Scintilla. This worked in other applications but not in PythonWin as PythonWin intercepts keys before sending them on to Scintilla. Then I went looking through PythonWin but the code was confusing so I gave up. If you are interested in working on this, the Enter key calls newline_and_indent_event in pywin\idle\AutoIndent.py. So you could intercept it here or else bind Enter to your own event that calls the current newline_and_indent_event only when no autocompletion is shown. Neil From davec999 at my-deja.com Wed Jul 12 05:22:38 2000 From: davec999 at my-deja.com (David Currie) Date: Wed, 12 Jul 2000 09:22:38 GMT Subject: Using proxy References: <396bd06b$1$jreare.trhraf$mr2ice@news.skynet.be> <396C0C19.8F1C940D@adtranzsig.de> Message-ID: <8khdck$694$1@nnrp1.deja.com> In article <396C0C19.8F1C940D at adtranzsig.de>, laukien at gmx.de wrote: > The solution is quite simple: > > import httplib > proxyhost = 'proxy' > proxyport = 8080 > > h = httplib.HTTP(proxyhost, proxyport) > .... [additional info because this isn't really clear] When making a request you will have to ask for "http://www.host.com/page.html" instead of, say, "/page.html" like you would have to when connecting directly to the host. Make sure your proxy does not require authentication. If it does, look at the headers returned with the error code to see what kind it wants. Basic authentication is simple: you include an extra header in the request with the text "Proxy-Authorization: " where ==base64.encode("username:password"). Digest is more complicated and needs encryption. I don't know how to do this.. :) If the proxy is IIS it is possible that it uses something called NTLM authentication. If this is the case, forget it unless you implement the protocol. There is some documentation somewhere on the net. Sorry, this started as a clarification, but I think I may have complicated things.. :/ Dave Sent via Deja.com http://www.deja.com/ Before you buy. From max at alcyone.com Fri Jul 28 20:23:38 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 28 Jul 2000 17:23:38 -0700 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <3981B034.80FACD08@fft.be> <3981D863.F71AC0AC@alcyone.com> Message-ID: <3982240A.C31DB1D3@alcyone.com> Steve Lamb wrote: > Might that be exactly why I say that data is data and that the > operation > determines the type? :) Yes. But that is the way Perl does it, and Perl is a weakly typed language, because the type is enforced by the choice of operators, not an intrinsic property of an object. Python, however is strongly typed, and the type of an object _is_ one of its intrinsic properties. 1 is not the same as '1'. Python is acting like a strongly typed language should. Your insistence that it should be following Perl's lead on this doesn't make any sense, because Python is not weakly typed like Perl. What you say is true -- _for Perl_. It is _not_ true for Python, no matter how much you would like it to be. And it shouldn't be, either, as Python is not like Perl. -- 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 completely overcomes only what one assimilates. \__/ Andre Gide Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From richard_chamberlain at ntlworld.com Sun Jul 9 16:48:41 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sun, 9 Jul 2000 21:48:41 +0100 Subject: Newbies question References: <8kacpb$9hc$1@wanadoo.fr> Message-ID: <3x5a5.6659$_O.136890@news2-win.server.ntlworld.com> Hi, I presume when you double click on grail.py you're getting a dos box which disappears. Try adding python to your autoexec and then launching grail through a command prompt, i.e. change directories to the grail directory and type: python grail.py This way you will get a traceback (hopefully) that we can make sense of. Richard Mouali rabii sbai wrote in message news:8kacpb$9hc$1 at wanadoo.fr... > Hello, > > Can anybody telling me how to execute an program with python. > > I explain, i have download the Grail Browser, making 100% in python. > In the readme file, they tell to just click on grail.py, but i have nothing > with this. > In the IDLE, i've pass this command : > exec python c:\program files\python\grail\grail.py > But i have an error. > > If it's not true, what shall i do? > > Thanks > > From Wolfgang.Strobl at gmd.de.bbs Mon Jul 17 07:30:02 2000 From: Wolfgang.Strobl at gmd.de.bbs (Wolfgang.Strobl at gmd.de.bbs) Date: 17 Jul 2000 11:30:02 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bRAMQ$mDp@openbazaar.net> Norbert.Klamann at pobox.com wrote: >Hello all, >working with the new Build 132 of Pythonwin we have a minor problem. >German Umlauts are not handled properly in the editor windows. >They are shown as boxes, some of them seem to be dead keys. And a major problem, the ^-key kills build 132 immediately, when using the German keyboard layout. -- o ( Wolfgang.Strobl at gmd.de (+49 2241) 14-2394 /\ * GMD Forschungszentrum Informationstechnik GmbH _`\ `_<=== Schloss Birlinghoven, | #include __(_)/_(_)___.-._ D-53754 Sankt Augustin, Germany | From jean.hemmi at arakne.com Wed Jul 5 04:02:46 2000 From: jean.hemmi at arakne.com (Jean Hemmi) Date: Wed, 05 Jul 2000 08:02:46 +0000 Subject: JPE: Java - C Python Extension Project Message-ID: <3962EBA5.E461DD4@arakne.com> We need a full-featured C-Python / Java integration! Besides minor functional differences, JPython has the major limitation of not being able to leverage existing Python (binary) extensions. Presently, there is no C-Python extension to Java. We, at Arakne, are annoyed by this situation: We cannot integrate the Python binary extensions we developped with any of the Java SDK's. Python is among the fittest integration tools around today - we should be able to have a seamless integration between Python and Java-. (I'll leave to others the opportunity to elaborate on the consequences of the contact between Python's and Java's rationales, especially if both were tightly bound together...) This would also open a new perspective: at present the "standard" way to develop native web browser plug-in is through the Java plug-in mechanism and Java's JNI C API. At the end of the pipe is the ability to run, within a client web browser Python scripts, just like Javascript; Python bytecode, like a Java applet; or both. Like binary plug-ins, binary python extensions (*.pyd files) could also get downloaded and installed. After a successful experience at integrating two large and complex object-oriented systems into Python, we feel confident at applying the same patterns to a Java integration - after all, Java is just yet another external system to Python... - We are laying out below the requirements to such an integration: - Multithread compatibility (at least when the JVM relies on OS threads) - Access to the Java environment from Python - Seamlessness from both sides - Java objects appearing as native Python objects (resolving overloading) - Extensibility of Java classes into Python - Access to the Python environment from Java - Python objects accessible as Java objects - Extensibility of Python classes within Java - Exception mapping - Python programming on client Web browser, like Javascript - Ability to run Python bytecode files on the client Web browser - Conciliation of security features (adapting Python's restricted execution mode for 'Pylets') Voila! Reactions and comments ? Frederic Giacometti Arakne frederic.giacometti at arakne.com From sales at chinaeast.com.hk.bbs Mon Jul 17 01:10:02 2000 From: sales at chinaeast.com.hk.bbs (sales at chinaeast.com.hk.bbs) Date: 17 Jul 2000 05:10:02 GMT Subject: (no subject) Message-ID: <3bR0RR$iXs@openbazaar.net> It is an honor to introduce our company, China East Technology Ltd (CET). We have been established for about half decade with all facilities located in Hong Kong. We are the manufacturer for the replication of CD-Audio, CD-ROM, Super VCD, Video CD, Business Card CD (50-60MB) , Irregular Shape CD. To give our clients 100% satisfaction is always the goal of us. At each stage of the production, we track our quality with high precision inspection equipment and well-trained inspectors. Apart from the quality assurance, the high level of security for the CD production is also our concern to which the fully viewed security systems equipped in our plant. Moreover, to show our commitment in anti-piracy of copyright, we have already joined with international recognition IFPI coding system from Philips and have the licence for the manufacturing of optical disc by Hong Kong Customs and Excise Department (Licence No. ODML 016). We commit to provide our best quality services: - processing from your master media to having up to 5 colors silk screen printing discs and packed by standard packing or special design. Should you have any questions, please feel free to contact with us either by phone (852) 2898-1082, fax (852) 298-1262 or email sales at chinaeast.com.hk. We anticipate to look forward to serve you in the nearest future. To cancel this mailing service, reply and type "remove" in the subject field. This message is sent in compliance of the new email bill section 301. Under Bill S. 1618 TITLE III passed by the 105th US Congress. This message cannot be Considered Spam as long as we include the way to be removed, Paragraph (a)(c) of S. 1618, further transmissions to you by the sender of this email may be stopped at no cost to you by Click Here with REMOVE in the subject From loewis at informatik.hu-berlin.de Wed Jul 19 12:29:20 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Jul 2000 18:29:20 +0200 Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> <396F4473.35DCA488@prescod.net> <8F729880Egmcmhypernetcom@199.171.54.194> <3970B9EB.8FF00EF9@prescod.net> Message-ID: Paul Prescod writes: > True, I forgot that because the MS JVM tends to be installed. I think I > may have exaggerated the features of the former too. Is there any easy > way to make a single executable for Python, the standard library, > required .pyd's and your code? My vague impression is that you could if > you had a compiler and the source for your pyd's, or else you could fall > back on an installer (rather than a single big runnable app). You can get a truly-standalone binary through freeze, but you do need a C compiler for that. Otherwise, you can get self-extracting and self-starting applications. Regards, Martin From dnotspam-jen at personic.com.bbs Mon Jul 17 15:50:04 2000 From: dnotspam-jen at personic.com.bbs (dnotspam-jen at personic.com.bbs) Date: 17 Jul 2000 19:50:04 GMT Subject: Multiline strings and indentation Message-ID: <3bRNNS$lrb@openbazaar.net> I'm just getting started with Python. The indentation feature really does make things readable ... except when using multi-line strings. This just doesn't look right: def multiline(x): if x: print """this is a multi-line string that spans three lines""" print "another string" Is there a way to make the above more readable? It would be nice if it could be written this way and have Python just figure out what whitespace to ignore: def multiline(x): if x: print """this is a multi-line string that spans three lines""" print "another string" Thanks for any suggestions! Jen From bjorn at roguewave.com Fri Jul 14 13:38:51 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 11:38:51 -0600 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> Message-ID: <396F502B.45225ED9@roguewave.com> Huaiyu Zhu wrote: > > On Thu, 13 Jul 2000 16:35:57 -0600, Bjorn Pettersen > wrote: > > >I fully understand your desire to make the syntax for your domain > >specific notation as intuitive as possible. For people who don't know > >matlab however, .+ et. al. have no pre-defined meaning. Since + has a > >predefined meaning of addition, most people when overloading it will do > >"additive" things with it, e.g. concatenating to sequences. Since .+ > >doesn't have a pre-defined meaning I'm afraid people will override it > >with random semantics... > > > >If you want to do matlab syntax, perhaps a better approach would be to > >write your own expression parser? > > > > Hmm, I see what you mean: If a certain syntax is not meaningful to all the > users, don't expose it to all of them lest they came up with random > incompatible usages. Sounds reasonable, but ... > > Point 1. We _can_ assign a universal meaning to dot operators, as > "componentwise operators". For example > > [1, 2] + [3, 4] # [1, 2, 3, 4] > [1, 2] .+ [3, 4] # [4, 6] > ['a','b'] * 2 # ['a','b','a','b'] > ["a","b"] .* 2 # ['aa', 'bb'] > {'a':1, 'b':1} .+ {'a':1, 'c':1} # {'a':2, 'b':1, 'c': 1} > 'abc' .+ 'def' # exception: you must define string.__dot_add__ Well, this could actually be generally useful, but not with the .+ syntax (since the dot would interfer with methods on the sequence object). If I had the ability to do elementwise computations, I would want to do something like: myList @foo() == map(lambda x:x.foo(), myList) == [x.foo(); for x in myList] [1,2] @+ 2 == map(lambda x:x+2, [1,2]) == [x+2; for x in [1,2]] [1,2] @+ [3,4] == ?? Reading "x@" as distribute the operation over the elements in x. I think something like this has the potential to make code more declarative (ie. shorter and easier to understand)... -- bjorn From aahz at netcom.com Tue Jul 11 11:33:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 11 Jul 2000 15:33:26 GMT Subject: Static member variables References: <8kahdq$5e2$1@zingo.tninet.se> <8kahq3$fof$1@slb0.atl.mindspring.net> <8kd766$qi7$1@zingo.tninet.se> Message-ID: <8kfeo6$mkk$1@slb6.atl.mindspring.net> In article <8kd766$qi7$1 at zingo.tninet.se>, Thomas Svensson wrote: >In article <8kahq3$fof$1 at slb0.atl.mindspring.net>, aahz at netcom.com (Aahz >Maruch) wrote: >> >> You can have class variables, but they're not exactly what I'd call >> "static" and they certainly aren't constant. >> >> class foo: >> bar = 2 >> def __init__(self): >> self.baz = 3 >> >> f = foo() >> >> f.bar is a class variable; f.baz is an instance variable. Note that you >> can run into problems if you're not careful because of the way scoping >> rules work. > >Very logical when I see it now. About trouble, do you mean something >similar to this: No, what I mean is more similar to this: class foo: bar = 2 def __init__(self, bar): self.baz = 3 self.bar = bar By using self.bar, you're modifying the instance, not the class variable, and the change will not be visible to other instances. Do this instead: class Foo: bar = 2 def __init__(self, bar): self.baz = 3 Foo.bar = bar -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From alex at magenta.com Mon Jul 3 05:35:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:35:43 +0200 Subject: Passing variable-length keyworded arguments list to base class constructor? References: <962352947.103057778@news.libertysurf.fr> <8jhum101vku@news2.newsguy.com> <962367281.1198008296@news.libertysurf.fr> Message-ID: <8jpn010mb7@news2.newsguy.com> Jerome Quelin wrote in message news:962367281.1198008296 at news.libertysurf.fr... > "Alex Martelli" wrote: > >> I was wondering how to pass variable-length keyworded arguments list > >> to my base-class constructor? Look at the example code below: > >Doesn't apply work for __init__ just as for any other function? > Sure it works for __init__ too, I've already tried this approch, but it doesn't > work either. In fact, I'm asking the question for __init__ because I run into > this problem when calling constructors, but the question is the same for every > inherited and overloaded method. > > When using the *args syntax, I get an error when calling my constructor because > I'm using keywords arguments. Ok, so *args is out. > When using the **args syntax, python fetches all keyworded arguments in _one_ > dictionnary in my constructor, and I want to keep the arguments in multiple > key/value pairs (and not flattened in one dictionnary) since the parent > constructor is waiting for keyworded arguments too. But that's what apply does (in part): turn a "flattened in one dictionary" set of name/value pairs into "keyworded arguments" for the function being applied. > If I use the **args syntax and then call the base constructor with: > Parent.__init__(self, args) > I got an error since it doesn't wait for a dictionnary as an argument (and args > is a dictionnary in this case) but for key=value arguments, with key and value > taken from the args dictionnary. So you should instead call apply(Parent.__init__,(self,),args), shouldn't you? Toy example: class Parent: def __init__(self, foo=23, bar=45): print foo, bar class Derived(Parent): def __init__(self, **kwargs): apply(Parent.__init__, (self,), kwargs) >>> esem.Derived(foo=99) 99 45 >>> Of course you can alter the kwargs dictionary as required in your Derived.__init__ method for whatever special needs you may have; e.g., suppose you want to change the *default* for bar from 45 to 73 in Derived (only), you might code: class Derived(Parent): def __init__(self, **kwargs): if not kwargs.has_key('bar'): kwargs['bar']=73 apply(Parent.__init__, (self,), kwargs) and now: >>> esem.Derived(foo=99) 99 73 >>> Alex From dsavitsk at e-coli.net Mon Jul 10 21:40:02 2000 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 11 Jul 2000 01:40:02 GMT Subject: Tkinter Option (Radio) Buttons References: <8kd5i7$2b0$1@nnrp1.deja.com> Message-ID: thanks very much. doug From randysch at home.com Fri Jul 7 23:29:42 2000 From: randysch at home.com (Randy Schrickel) Date: Sat, 08 Jul 2000 03:29:42 GMT Subject: Guido presenting at CALUG 7/11 Message-ID: <3966A026.EFAF76EB@home.com> Hello everyone. Just wanted to announce that Guido van Rossum will be our special guest speaker at next week's Columbia (Maryland) Area Linux Users Group meeting. The meeting will be at the Howard Community College Gateway Training Center in Columbia, MD at 5:30. More details, info, and directions can be found at www.calug.com . Please tell others, hope you can make it. randy schrickel www.calug.com From david_ullrich at my-deja.com Sat Jul 22 13:14:10 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sat, 22 Jul 2000 17:14:10 GMT Subject: Waiting for Threads to Stop References: Message-ID: <8lckol$eq3$1@nnrp1.deja.com> In article , "Doug Fort" wrote: > I have several cases where I want [...] one or more other > threads to terminate. You think you got troubles, try sci.math. (Oh, that's not the kinda thread you meant? Never mind...) Sorry, Couldn't Help It, DU Sent via Deja.com http://www.deja.com/ Before you buy. From loewis at informatik.hu-berlin.de Thu Jul 13 17:42:23 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 13 Jul 2000 23:42:23 +0200 Subject: DB2 Connection References: <8kl7ds+d9ni@eGroups.com> Message-ID: ftian at cs.wisc.edu writes: > Anyone succeeded in connect Linux DB2 v7.1 on linux? > IBM only provide Perl module on their web site. I haven't tried, but it should be possible to link an odbc module (such as mxODBC) with the DB2 ODBC library. Regards, Martin From david_ullrich at my-deja.com Sat Jul 22 13:24:24 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sat, 22 Jul 2000 17:24:24 GMT Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> <8l9qfp$gc6$1@nnrp1.deja.com> <6%_d5.1964$6E.417529@ptah.visi.com> Message-ID: <8lclbq$f6o$1@nnrp1.deja.com> In article <6%_d5.1964$6E.417529 at ptah.visi.com>, ge at nowhere.none (Grant Edwards) wrote: > In article <8l9qfp$gc6$1 at nnrp1.deja.com>, david_ullrich at my-deja.com wrote: > > >> You're using a single index whose value is the expression 2,3. > >> The expression 2,3 evaluates to a tuple, which is passed to > >> _getitem__, just as would the value of any other expression > >> used as an index. > > > > Ok, then I should revise what I said: You can use the > >notation [2,3] to accomplish the same thing. > > > > No doubt you're exactly right. But evidently there's a > >difference between [] indices and function parameters here: > > > >def hmm(x): > > return x > > > >print hmm(2,3) > > > >gives an error (hence my suspicion that someone might > >expect whatever[2,3] to give an error without trying it...) > > > > Why is "2,3" a single expression in whatever[2,3] > >but not in hmm(2,3)? > > Because that's the way the language syntax is defined. :) Yeah, actually I realized that the answer was "because that's the way it is", I guess what I was really trying to suggest that since function parameters don't work that way it's not so obvious that __getitem__ indices do. > The syntax for a function call includes the commas separating > the parameters. The syntax for an index doesn't include any > commas, so the commas are part of an expression yeilding a > tuple. It would be a bit more obvious if one used foo[(4,5)]. Of course. But the fact that we can write foo[4,5] instead is very convenient (I was writing foo[(4,5)] in a certain context once, wishing there was a syntax more like the syntax for "2-d arrays" elsewhere. Forgot the parentheses once - that solved that problem.) DU Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com Fri Jul 14 14:26:06 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 12:26:06 -0600 Subject: comparing a directory to current dir... References: <396B9C5E.FCE5F683@roguewave.com> <8kh9if$5co$1@pollux.ip-plus.net> Message-ID: <396F5B3E.1487E640@roguewave.com> David Bolen wrote: > > "J?rgen Hermann" writes: > > > "Bjorn Pettersen" schrieb im Newsbeitrag > > news:396B9C5E.FCE5F683 at roguewave.com... > > > the problem is that os.path.abspath(os.curdir) contains the drive letter > > > on Windows and os.path.abspath(directory) doesn't. > (...) > > Your windows must be different from mine. :) Mine is NT4SP6a. > > Either that or Bjorn doesn't have the win32 extensions installed. It > turns out that ntpath.py in the standard library will actually try to > use the win32 extensions to let NT produce the absolute path, but if > not present will silently revert to internal functions, which can > under some conditions produce the behavior Bjorn was seeing. > > It depends on os.path.isabs() being used to determine if the supplied > string is already an absolute path, which it will say yes to if it > starts with / or \, even if it doesn't have a drive. In that case, it > doesn't do the join mentioned in the documentation, but only does > os.path.normalize() and you can end up with a result without the drive > letter. > > I guess the problem is that "absolute" is sort of ambiguous under > Windows, since you can have absolute paths on your current drive, or a > really absolute path that always includes the drive. > > It would probably help to see the value that was in "directory" from > the original poster to know if that's what was up (and/or if he had > the win32 extensions installed). That's it! Thanks a bunch :-) I-want-the-win32-extensions-in-the-core'ly y'rs -- bjorn From loewis at informatik.hu-berlin.de Mon Jul 10 07:03:37 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Mon, 10 Jul 2000 13:03:37 +0200 (MET DST) Subject: [Python-Help] imp.load_module from a string In-Reply-To: <3969AC50.98F36FF4@nipltd.com> (message from Chris Withers on Mon, 10 Jul 2000 11:58:24 +0100) References: <39672E50.B83A4C81@nipltd.com> <200007081846.UAA04878@pandora.informatik.hu-berlin.de> <3969AC50.98F36FF4@nipltd.com> Message-ID: <200007101103.NAA14484@pandora.informatik.hu-berlin.de> > Okay, another question: What is the difference between the contents of a > .pyc file and what is returned by compile(str,'notafile','exec')? The first eight bytes are a magic signature. bytes[8:] is a marshalled code object. Of course, a code object is an object, whereas the contents of a pyc file is a string. > Hmm, plan B was to execute a compile(...) on the server using the source > code and ship a pickle of the result to the client. On the client, take > this codeobject and execute it into a module: > > module = imp.new_module('MyModule') > sys.modules['MyModule'] = module > exec codepbject in vars(module) > > Would this work? How efficient is it? Depends on how you transmit it. pickle does not support code objects; marshal does. So I recommend to ship the pyc file, and unmarshal it. > say module1 is created with: > module1 = imp.new_module('MyModule') > exec code1 in vars(module1) It's better to write 'in module1.__dict__' > ...can I just swap them as follows?: > sys.modules['MyModule'] = module1 > ...create and use objects from MyModule... > sys.modules['MyModule'] = module2 > ...create and use objects from MyModule, hopefully using new > code?... To create and use objects, you don't have to put the module into sys.modules; getattr(module,classname) would get you a class from the module. Apart from that, yes, that would work. > ...what happens to objects created from old MyModule code?... The objects stay the same. When the reference to the module is release, class objects still remain as long as instance objects refer to the class. Regards, Martin From nobody at nowhere.nohow Fri Jul 28 01:56:07 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Fri, 28 Jul 2000 05:56:07 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: In article , Steve Lamb wrote: > > Ah, but getting back to that point I said to remember. > >foo = "a" >foo = list(foo) > > foo is not ['a']. It is when I try it... > It took a single element and made it a list. No, it took a sequence containing a single element and turned it into a list containing a single element. list() only works on sequences. 'a' is a sequence of length 1. >So we now know that a single element has a sequence. Not in the general case. >Here is another sequence of a single element. > >foo = 1 >foo = list(foo) > > Error. Single element sequence. No, 1 is not a sequence. 1 is an integer. [1] is a sequence. (1) is a sequence. >Remember, any sequence can either be a single value or a sequence. I don't think so, but I'm not sure I understand what you're saying. Can you elaborate? >Yet here we have a single value denied. Quirks abound. list() does not handle non-sequences. You have run across a quirk, but it isn't what you think it is. It is this: A string is a sequence of characters. Passing a string to list() converts that sequence of characters into a list of characters. Confusion may arise because a "character" is just a string of length 1. This results in a rather recursive definition of a "string" as a sequence of length-1 strings. Therefore, we have the rather odd fact that 'a'[0] == 'a' This is important. 'a' is a sequence that contains a single element. That element is 'a'. This is why list('a') == ['a']. No matter how many times you apply the [] operation to a length-1 string, you get the same length-1 string. This is a bit counter-intuitive, but the other option is to have distinct character and string types. If you do that, then string manipulation gets a lot more messy. >>> a is now "['a', 'b', 'c']". Which means we split a string up when >>>converting to list but don't concatenate on the way back. str() and list() are not inverse operations. They are neither claimed nor intended to be. There is no deterministic way to do the inverse of a list() operation because there is no information in the list to tell you what sort of sequence it used to be before it was converted into a list. str() is defined as producing a more-or-less human-readable expression that represents the object it is given. Passing a list to str() will generate a string that (for simple cases) you can eval() to re-produce that list. str() and eval() come much closer to being inverse operations -- but only for simple cases. If you _know_ that the list was the result of doing a list() on a string, then the inverse operation to convert foo back from a list to a string is: reduce(lambda x,y: x+y, foo) If you need to do this a lot, then perhaps your complaint should be that there's no built-in function to concatenate all of the strings in a given sequence of strings. Is there? -- Grant Edwards grante Yow! Someone is DROOLING at on my collar!! visi.com From jaredu at its.caltech.edu Mon Jul 17 19:21:27 2000 From: jaredu at its.caltech.edu (jaredu at its.caltech.edu) Date: Mon, 17 Jul 2000 23:21:27 GMT Subject: test_socket: similar problem Message-ID: <8l04d7$iir$1@nnrp1.deja.com> I'm having the same problem, but on a Mac (Mac OS 9.0.4 G4 w/ Python 1.5.2) The solution is probably the similar, but how do I fix it on a Mac? --Jared > Harry George wrote: > > > > [I looked in dejanews, but all the socket queries are way beyond where > > I'm stuck.] > > > > I have a win95 machine which is samba'd to a linux box.? I'm trying to > > learn to do python on win95 (COM et al).? First step is to get it > > running.? py152.exe went ok; then win32all-128.exe.? python, > > pythonwin, icons in the explorer all ok.? Able to edit and run simple > > hello, worlds. > > > > Then in the interpreter I tried: > >? import test.autotest > > It ran ok (with lots of skipped optionals), but test_socket crashed > > with socket.error "host not found" > > I had the same error. As far as I understood my? computer didn't know > about his name.. ;-) I made the? file "c:\windows\hosts" , that > contained one row: > > 128.0.0.1 localhost > > and after reboot all worked fine.. > > > > Of course this could be a non-python win95 setup issue, but with > > tcp/ip running ok (samba, ftp, ping, etc.), I'm wondering if there is > > a python-specific issue.? Any ideas? > > > > -- > > Harry George > > hgg9140 at seanet.com > > Alexei Kichkine (http://infocentr.r Sent via Deja.com http://www.deja.com/ Before you buy. From nobody at nowhere.nohow.bbs Sun Jul 16 12:10:02 2000 From: nobody at nowhere.nohow.bbs (nobody at nowhere.nohow.bbs) Date: 16 Jul 2000 16:10:02 GMT Subject: Top 10 Language Constructs (Phyton) Message-ID: <3bQSCS$m1g@openbazaar.net> On 15 Jul 2000 14:37:57 GMT, Aahz Maruch wrote: >Yeah, one of the reasons I hate AltaVista so much is because it does a >remarkably poor job of result ranking, even by the relatively poor >standards of search engines. I am reminded of something somebody once told me about network TV: "They don't care whether you like the programs or not. All they care about is whether their customers like their product." IOW: You are not the customer. You are the product. -- Grant Edwards grante Yow! An air of FRENCH at FRIES permeates my visi.com nostrils!! From dale at out-think.NOSPAMco.uk Mon Jul 3 16:54:14 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 3 Jul 2000 21:54:14 +0100 Subject: Definative Documentation on Objects Message-ID: <8jqui2$9na$1@supernews.com> Where do I look for the definitive statement on object programming in Python? The "Python Reference Manual", as included in the distribution, is particularly hard work. I'm considering "Programming Python" by Mark Lutz but that's four years old. "Learning Python" is more recent but I'm worried that it might be pitched a bit low. I'm an experienced programmer but I need to quickly understand Python object programming. Any pointers to online or paper reference material gratefully received. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From robin at jessikat.fsnet.co.uk Thu Jul 20 11:19:43 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 16:19:43 +0100 Subject: ReportLab 1.00 Released References: Message-ID: <31D8qUAPixd5Ewhy@jessikat.fsnet.co.uk> In article , Robin Becker writes >After much transatlantic worrying it has been decided that ReportLab, >http://www.reportlab.com) should release version 1.00 of its >increasingly popular PDF toolkit. > >This release features improved documentation, a number of minor bug >fixes and some C coded extension accelerators. The PLATYPUS page layout >API whilst not fully fixed will no longer be subject to the upheavals >of the last few months. > >The toolkit is available at either of > > http://www.reportlab.com/reportlab.tgz (.zip) > ftp://ftp.reportab.com/reportlab.tgz (.zip) > >For windows users the python15.dll compatible extension .pyds are >available at the download page. duh I got it wrong as the first should be http://www.reportlab.com/download.html -- Robin Becker From bill at dehora.fsnet.co.uk Fri Jul 28 18:47:46 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Fri, 28 Jul 2000 23:47:46 +0100 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> Message-ID: <8lt3pm$bgg$2@newsg4.svr.pol.co.uk> > You've obviously not seen the damage marketing can do to a company from > the inside, have you? > You've obviously never seen the damage programming can do to a company. From roberto.lupi at galactica.it Sat Jul 8 05:51:56 2000 From: roberto.lupi at galactica.it (Roberto Lupi) Date: Sat, 8 Jul 2000 11:51:56 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <00c601bfe812$febfeef0$f0c809c0@lslp7o.lsl.co.uk> <8k4t1u$7fk$1@newshost.accu.uu.nl> <8k5hd8$go8$1@localhost.localdomain> Message-ID: Although not strictly part of ZODB, I think that ZCatalog and ZClass be used to perform queries and schema evolution. In article <8k5hd8$go8$1 at localhost.localdomain>, fermigier at localhost.localdomain says... > What I'm missing most from ZODB, and is usually easy to do with an > object-relational adapter, are queries ZCatalog > and a simple way to do schema > evolutions. ZClass -- Roberto Lupi From stephen at cerebralmaelstrom.com Sat Jul 8 04:02:19 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sat, 08 Jul 2000 08:02:19 GMT Subject: NumPy and 1.6a2? References: Message-ID: I believe you have to rebuild all extentions for use with 1.6.. so you have to get the sources and recompile, or get someone else to do that for you, for it to work... --Stephen Tim Hamza wrote in message news:xSA95.8234$7%3.621764 at news.flash.net... > Hey all, > > I'm new so maybe I'm missing something easy. > > Python 1.6a2 (no other snakes in the system), Numpy 15.2, Win98. Unzipped > NumPy to the Python directory and ended up with a /python/Numeric.pth file > as well as /python/Numeric and /python/include/Numeric directories. > > Here's what I'm getting: > > C:\>python > Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import Numeric > Fatal Python error: PyThreadState_Get: no current thread > > abnormal program termination > > C:\> > > Also blows up in idle. Am I doing something wrong? Does this version of > NumPy not work with this version of Python? > > Thanks, > Tim > > > > From smoriano at sicon.net Thu Jul 13 08:40:36 2000 From: smoriano at sicon.net (sergio) Date: Thu, 13 Jul 2000 14:40:36 +0200 Subject: Files question Message-ID: <396DB8C4.EC239CD2@sicon.net> Hi all, I'm working in winNT Server 4.0. How can i know if a file is open by other apllication, in order to wait till the file is free Thanks in advance From pduffin at hursley.ibm.com Mon Jul 31 05:28:37 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Mon, 31 Jul 2000 10:28:37 +0100 Subject: The State of Python References: Message-ID: <398546C5.E9E59957@hursley.ibm.com> Tim Peters wrote: > > [posted & mailed] > > [Greg Ewing] > > There's one thing I don't get about this whole > > license fiasco. What the heck gives CNRI the right > > to dictate what sort of license BeOpen is allowed > > to attach to its next version of Python? Surely > > they can use any license they like as long as it's > > compatible with the existing Python license. > > CNRI claims that the existing (CWI) Python license isn't a valid license, > and while that claim makes little sense to me I'm not a lawyer. At least > one enthusiastic lawyer on each side of that question is known to exist, > though, so that would make it a protracted court battle. We just want to > get on with our Python work! It's bad enough that it's taking so long to > resolve without sucking our ponderous legal system into it. > > Beyond that, there are all sorts of complications, and we *want* this to end > on friendly terms. For example, Guido did promise CNRI to produce a final > 1.6 release for them, and BeOpen agreed to honor that commitment. As the > copyright holder of record, CNRI can certainly put any license they want on > *that* release (the CWI license sure won't stop that, "valid" or not). But > so long as we can get them to agree on a *reasonable* (as defined by us -- > and if CNRI isn't asking you, we're the best hope you've got <0.1 wink>) > license, we'll be happy to ship Python 2.0 too using CNRI's 1.6 license. > That does look like the most likely outcome right now. But if a reasonable > license can't be gotten, at some not-distant point we'll have to just cut > this off and risk Python's future on the validity of the CWI license and the > vagaries of the law. > > But nobody on either side *wants* that. JPython is also cringing in the > background here, and JPython is wholly & indisputably owned by CNRI (unlike > CPython, JPython was both born and raised at CNRI). It would be of real > value to the JPython community to get a friendlier license for JPython too, > and CNRI has said they would consider re-releasing JPython under the CNRI > 1.6 Python license. That's worth some pain to achieve. > > CNRI also owns the python.org domain and has copyright on that website (btw, > that's why it's barely been updated this month -- the ex-CNRI folks at > PythonLabs lost admin access to it), ditto jpython.org, hosts the Python > Consortium, and runs the PSA as well. So it's not just the source code for > Python that's at risk here. > > Of course, CNRI may have a completely different tale to tell about all this, > buy I can't speak for them. > That sounds absolutely horrendous. Tcl is also going through some major changes in its development process to make it more Open Source but it is nowhere near as painful as what seems to be happening to Python. I hope that you get it resolved as quickly as possible. Who will hold the license on Python 2.0 ? Is it going to be BeOpen ? Could the license be held by the community in some way to prevent this sort of legal wrangling in future ? How about having a concept of stewardship, i.e. BeOpen is the current steward of Python on behalf of the community. By Python I mean all Python related resources that BeOpen manage, so this would include all information on the web site, the domain name, etc. If BeOpen could no longer support Python for whatever reason then those resources would be turned over to the community and they could then look for a new steward for Python. The community would also have the option to choose a new steward for Python if they felt that BeOpen was not supporting Python properly or someone else could support it better. This would have to be a legal contract so for instance if BeOpen was taken over, or went bankrupt Python could not be sold off to the highest bidder. The biggest problem with this is determining what the will of the community is. From aa8vb at yahoo.com Mon Jul 17 07:11:34 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 17 Jul 2000 07:11:34 -0400 Subject: automatically filling web forms? In-Reply-To: ; from jeroen@valcke.com on Sat, Jul 15, 2000 at 09:29:13PM +0000 References: Message-ID: <20000717071134.A2351410@vislab.epa.gov> Alex: |Jeroen Valcke: | |> can I automatically fill webforms? | |Yes, you can. Check out the htmllib module, which you can use to get |the forms out of the document, and the GET and POST capabilities of |urllib, which you can use to send your response. Don't know about the htmllib module option, but here's how with urllib on Python 1.5.2, for both GET and POST. import urllib, os BASE_URL = "http://www.a-cool-site.com:80/cgi-bin/get_data.cgi" parms = { 'parm1' : val1, 'parm2' : val2 } if METHOD == "get": filename, headers = urllib.urlretrieve( "%s?%s" % ( BASE_URL, urllib.urlencode( parms ) ) ) else: # METHOD == "post" #------- I've submitted a patch so that this will work ------- #filename, headers = urllib.urlretrieve( BASE_URL, # urllib.urlencode( parms ) ) #------- But for now, do this ------- fp = urllib.urlopen( BASE_URL, urllib.urlencode( parms ) ) tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) tfp.close() fp.close() #===== Work with query results here (they're in file 'filename') ===== urllib.urlcleanup() if METHOD == "post": os.unlink( filename ) -- Randall Hopper aa8vb at yahoo.com From tim_one at email.msn.com Mon Jul 31 01:50:53 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 31 Jul 2000 01:50:53 -0400 Subject: The State of Python In-Reply-To: <3984FD40.6791C03C@my.signature> Message-ID: [posted & mailed] [Greg Ewing] > There's one thing I don't get about this whole > license fiasco. What the heck gives CNRI the right > to dictate what sort of license BeOpen is allowed > to attach to its next version of Python? Surely > they can use any license they like as long as it's > compatible with the existing Python license. CNRI claims that the existing (CWI) Python license isn't a valid license, and while that claim makes little sense to me I'm not a lawyer. At least one enthusiastic lawyer on each side of that question is known to exist, though, so that would make it a protracted court battle. We just want to get on with our Python work! It's bad enough that it's taking so long to resolve without sucking our ponderous legal system into it. Beyond that, there are all sorts of complications, and we *want* this to end on friendly terms. For example, Guido did promise CNRI to produce a final 1.6 release for them, and BeOpen agreed to honor that commitment. As the copyright holder of record, CNRI can certainly put any license they want on *that* release (the CWI license sure won't stop that, "valid" or not). But so long as we can get them to agree on a *reasonable* (as defined by us -- and if CNRI isn't asking you, we're the best hope you've got <0.1 wink>) license, we'll be happy to ship Python 2.0 too using CNRI's 1.6 license. That does look like the most likely outcome right now. But if a reasonable license can't be gotten, at some not-distant point we'll have to just cut this off and risk Python's future on the validity of the CWI license and the vagaries of the law. But nobody on either side *wants* that. JPython is also cringing in the background here, and JPython is wholly & indisputably owned by CNRI (unlike CPython, JPython was both born and raised at CNRI). It would be of real value to the JPython community to get a friendlier license for JPython too, and CNRI has said they would consider re-releasing JPython under the CNRI 1.6 Python license. That's worth some pain to achieve. CNRI also owns the python.org domain and has copyright on that website (btw, that's why it's barely been updated this month -- the ex-CNRI folks at PythonLabs lost admin access to it), ditto jpython.org, hosts the Python Consortium, and runs the PSA as well. So it's not just the source code for Python that's at risk here. Of course, CNRI may have a completely different tale to tell about all this, buy I can't speak for them. lately-i-don't-think-my-employer-even-wants-me-speaking- for-me-ly y'rs - tim From slinkp23 at yahoo.com Sat Jul 22 09:25:09 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sat, 22 Jul 2000 09:25:09 -0400 Subject: locale and _locale ?? Message-ID: <3979A0B5.8A64DA0A@yahoo.com> Hi, I seem to be missing the _locale module needed by locale. I have python-1.5.2-13 (latest RPM I can find on RedHat's download sites). Running RedHat linux. When I try to import locale, I get: File "", line 1, in ? File "/usr/lib/python1.5/locale.py", line 4, in ? from _locale import * ImportError: No module named _locale Looking for *locale* turns up these files: /usr/lib/python1.5/_localemodule.c /usr/lib/python1.5/locale.pyc /usr/lib/python1.5/locale.py /usr/lib/python1.5/locale.pyo Nothing called _locale.py... I did a deja search and found one posting that suggested _locale was left out of the RPM by mistake. But there is no newer RPM on RedHat's site. I also downloaded the latest python sources I could find at ftp.python.org, called py152.tgz ... no _locale. I also tried py152b2.tgz ... no _locale. Where can I find _locale??? Can somebody point me to some version of python that *definitely* includes it? I'm getting really frustrated with downloading megabytes of data on a slow modem just to see if MAYBE this one includes this one little file... TIA, PW ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From ooflell at msn.com Wed Jul 26 14:41:39 2000 From: ooflell at msn.com (LockinThisRate) Date: Wed, 26 Jul 2000 14:41:39 Subject: MAKE 36% ANNUALLY- get paid 3% monthly -Fully Secured Message-ID: A non-text attachment was scrubbed... Name: not available Type: text/plain, charset="iso-8859-1" Size: 893 bytes Desc: not available URL: From phd at phd.russ.ru Wed Jul 12 04:07:05 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 12 Jul 2000 08:07:05 +0000 (GMT) Subject: Script for checking FTP + HTTP links? In-Reply-To: <396BAD73.MD-1.4.4.angband@blueyonder.co.uk> Message-ID: On Tue, 11 Jul 2000, Bablos wrote: > I'm looking for a script that can check through several HTML files and > check the links to other HTML files, and also any files linked via FTP > and HTTP. I've found a Perl script that does this, and there MUST be a > Python script out there that does it. http://starship.python.net/crew/marduk/linbot/ Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tim_one at email.msn.com Thu Jul 27 12:36:38 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 27 Jul 2000 12:36:38 -0400 Subject: The State of Python In-Reply-To: Message-ID: [richard_chamberlain at my-deja.com] > If someone had made a contribution to the standard library and had > written a certain licensing agreement as a comment in the file would > that module still be covered by the BeOPEN or CNRI agreement? - or > would it's own license still stand? I think you need a cadre of your lawyers to meet with CNRI's to get a credible answer on that one. Note that contributions to Python generally weren't accepted if they contained a license more restrictive than the Python license; for example, there is no GPL'ed code in the Python distribution. Note also that, late in the game, CNRI required a release form with all Python contributions, specifically granting CNRI certain broad rights to your code. I personally contributed stuff to Python with an explicit "released to the public domain" notice in the files, and *believed* I was contributing them to be released by CNRI under the Python license, and I'm personally unhappy to see the license changed (although, since I did put my stuff in the public domain, they're free to do anything they like with it -- my objection is not about the legality, it's about ... "playing fair"). [Guido] > I'm not a lawyer, and CNRI has on several occasions claimed that in > the view of their lawyers the old Python license is not a license. So > they may not feel they need to respect other people's licenses (many > of those licenses are almost identical to the old Python license). > > But maybe they feel like respecting other people's copyrights, since > they sure appear to believe in their own copyright! So I expect that > contributions that state a copyright may stand a chance. I'm not a lawyer either (as you well know ), but at least in America you hold copyright on your works whether or not you state it explicitly. Curiously, the CNRI disclaimer form didn't say anything about copyright. > For more clarification, I suggest that you write directly to CNRI; > contact info is on their website http://www.cnri.reston.va.us/. > Especially if you own the copyright on some portion of Python and feel > that your rights are in danger of being violated! From dworkin at ccs.neu.edu Wed Jul 26 13:35:13 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 26 Jul 2000 13:35:13 -0400 Subject: "always passes by reference" In-Reply-To: weeks@golden.dtc.hp.com's message of "26 Jul 2000 01:10:15 GMT" References: <8llct3$n34$1@news.dtc.hp.com> <8lldpn$n7a$1@news.dtc.hp.com> Message-ID: weeks at golden.dtc.hp.com ((Greg Weeks)) writes: > def f(a): > a = 42 > > x = 1 > f(x) > print x # PRINTS 1 You're not demonstrating calling convention here. You're demonstrating assignment semantics. If the end result of the above example was saying anything meaningful about calling conventions in Python, then this would be hard to explain: >>> def g(b): ... b[1] = 'whoops' ... >>> y = [1, 2, 3] >>> g(y) >>> y [1, 'whoops', 3] -Justin From see at my.signature Thu Jul 20 00:49:47 2000 From: see at my.signature (Greg Ewing) Date: Thu, 20 Jul 2000 16:49:47 +1200 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> Message-ID: <397684EB.3E0C5D88@my.signature> Paul Prescod wrote: > > We're looking just to pair up elements. In that case, obviously the solution is to combine this thread with the one on new operator symbols, and define an elementwise tuple-creation operator ., as in [1,2,3] ., [4,5,6] == [(1,4), (2,5), (3,6)] It might even look halfway decent in a for loop: for x,y in a.,b: ... It would be a somewhat strange operator, as it would have to extend over multiple arguments like comma does, so that for x,y,z in a.,b.,c: .... would do the right thing. So it wouldn't really be an operator, more of a new built-in syntax for zipping, in the same way that the comma is a built-in syntax for tuple construction. Do-you-think-"Will-you-zip-me?"-is-likely-to-catch-on-as- a-proposal-line-between-Pythoneer-lovers-ly, -- 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 dawks at tesco.net Mon Jul 31 19:20:36 2000 From: dawks at tesco.net (phil) Date: Mon, 31 Jul 2000 23:20:36 GMT Subject: [5th Draft] Open Letter to CNRI: Request for clarification References: <3985D797.E5D2FC08@nowonder.de> <8m4kmu$1eq$1@kopp.stud.ntnu.no> <004601bffb2a$ef9179f0$788b18ac@boeckh.com> Message-ID: <3986033f.16319646@news.tesco.net> On Mon, 31 Jul 2000 15:07:18 -0500, "Stuart Ford" wrote: >Sorry about the ME2 type message..... > > >Could you please include me in the list to CNRI? > >I have spent the last 15 months trying to convince my company that Python is >not only a viable solution for prototyping, but also a good language for >general >development. > >Any change in the license that changes our ability to release products using >Python will set all my hard work back to stage one, plus make me look the >fool for recomending the language in the first place. > Exactly. I even asked this question in this group and was assured that this was not a problem. Like, what he said: >Any change in the license that changes our ability to release products using >Python will set all my hard work back to stage one, plus make me look the >fool for recomending the language in the first place. >Stuart Ford >Programmer/Analyst >E.H. Boeckh Corporation > > > > From neilh at scintilla.org.bbs Mon Jul 17 21:30:03 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 18 Jul 2000 01:30:03 GMT Subject: Could someone clone MS's IL for another OS? Message-ID: <3bRWGR$lva@openbazaar.net> > Could someone write a clone of MS's new intermediate compiler language to > native code compiler in order to write Perl, Python, or Eiffel on > Windows, compile it to IL, and then eventually native code compile it on > some other OS platform? I think its likely Microsoft will publish enough documentation to make it possible to write an IL VM for other systems. Microsoft may even make an IL VM available for other systems with the most likely being MacOS. If this is going to happen, I'd expect it to be announced at MacWorld this week. The question here is to what extent Microsoft wants to beat Java/Sun. Widespread availability of IL VMs would help this goal, while still allowing differentiation of the preferred platforms on the basis of which libraries are available. Microsoft will also have a large lead in designing IL VMs so will be able to ensure best perfromance is on those preferred platforms. They can also win on effort applied - when competing with their Java VM Microsoft achieved very good benchmarks. > Does anyone think such a capability is a good idea? > Does anyone think that someone will do this? Yes to both. Neil From shuz at bresnanlink.net Thu Jul 27 02:51:21 2000 From: shuz at bresnanlink.net (Aaron Berg) Date: Thu, 27 Jul 2000 01:51:21 -0500 Subject: Sound---Anyone play with it in python? Message-ID: <397FDBE9.B8E1A2E0@bresnanlink.net> An HTML attachment was scrubbed... URL: From tim.hochberg at ieee.org Wed Jul 26 20:14:04 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 27 Jul 2000 00:14:04 GMT Subject: Please help... with re References: <397F5947.EBDA7F33@e-pack.net> <8lnm7c0lu9@news1.newsguy.com> Message-ID: Here's an improved version of the string splitting routine I posted earlier. This is twice as fast as it was, courtesty of no longer using the re module. It's also roughly 10X faster than the stream based approach that was also posted to this thread (although it does assume that there are no embedded nulls). It would be interesting to see what the original 68 line monster looked like and compare it's performance to the posted solutions . import string def minimonster(text): # Replace " with \0 (ASSUMES NO EMBEDDED NULLS) newtext = string.replace(text, '"', '\0') # Now replace \\0 (formerly \") with " newtext = string.replace(newtext, '\\\0', '"') # now split on \0 (formerly ") textlist = string.split(newtext, '\0') # Now split on even sections only (odd sections are quoted). result = [] isEven = 1 for item in textlist: if isEven: result.extend(string.split(item)) else: result.append(item) isEven = not isEven return result -tim From nicklo at bigfoot.com Thu Jul 6 11:56:22 2000 From: nicklo at bigfoot.com (Netvigator) Date: Thu, 6 Jul 2000 23:56:22 +0800 Subject: job offer Message-ID: <8k2a7p$mi71@imsp212.netvigator.com> Hi Python guys, First of all, sorry for posting something not related to the Python language. However, I've got a good news for those living in Hong Kong or wish to come to Hong Kong. Cos, my company is now recruiting Python programmers. It's not easy to find Python people in Hong Kong. My company is developing some WAP applications based on ZOPE. I'm sure you will find the challange in my company. If you want to know more or want to arrange an interview, please contact me thru nicklo at computer.org . Thanks. Nicholas Lo From thomas at cintra.no Tue Jul 25 07:37:36 2000 From: thomas at cintra.no (Thomas Weholt) Date: Tue, 25 Jul 2000 11:37:36 GMT Subject: Problems with py-bsddb3 Message-ID: <397f7afb.115428757@news.online.no> Just compiled py-bsddb3 without problems, or so I thought. When I tried to run any of the examples it crashed, saying: File "dbtest.py", line 25, in ? from bsddb3 import db ImportError: No module named bsddb3 Didn't see any such file after compilation of the module. Copied the dbcmodule.so to the lib-dynload-folder. Do I need more libs. than py-bsddb3? I didn't see anything in the docs. Thomas From timaratz at lisco.com Fri Jul 14 10:44:17 2000 From: timaratz at lisco.com (Peter Timaratz) Date: Fri, 14 Jul 2000 09:44:17 -0500 Subject: Why make a language case sensitive? In-Reply-To: Message-ID: <000801bfeda1$fcd99a20$6cb745c6@timaratz> I can't think of any advantages to a case sensitive language. Python is a very well-designed language though, so I imagine there is a good reason that it is case sensitive. So what are the advantages of a case sensitive language? From paul at prescod.net Wed Jul 19 12:11:27 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:11:27 -0500 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: <3975D32F.43ADED21@prescod.net> Huaiyu Zhu wrote: > > ... > Please jump in at any point that's both > feasible and interesting enough for someone to actually do it: > > 1. Make a pure python way to introduce additional operators, like > import NewOperator > NewOperator.define(".+", "__dotadd__") > NewOperator.define("+=", "__add_ab__") > NewOperator.define(":=", "__copy__") > > Advantage: Pure python. Doesn't interfere with existing sytax. May be > used for other operators. Not in the core, only affect the module that > imports it. > Disadvantage: Said to be quite difficult to implement (Why?). Parsers just do not work that way. Most parsers cannot be extended at runtime. The language is defined at compile time by the grammar. The only way to do it without rewriting Python's parser from scratch would be to pre-declare every possible operator anyone might ever want in the grammar. > 2. Incorporate additional operators in python. Either . or @. Five to > eight would be enough for linear algebra. > > Advantage: Pure python. Doesn't interfere with existing syntax. > Disadvantage: Fixed choice for everybody. Unlikely to happen for quite > some time until everyone agrees on everything. Agreed on all counts. > 3. Maintain a patch for additional operators. > > Advantage: once built, everything is pure python. Already have patch. > Disadvantage: Can't guarantee most users can patch python, so in practice > may need to maintain windows executable for download. In the big picture, is that such a big deal? > 4. Temporarily use a.mmul(b) and a.emul(b) before things settle down. Then > define __dotmul__ = emul, or the like, when they are available. > > Advantage: immediately implementable. Won't break anyone's code. Can > also switch to __atmul__ = mmul or other choices later. > Disadvantage: code somewhat cluttered. Let me ask again, is that such a big deal? > 6. Maintain two classes: E and M. > > Advantage: no need for new operators. > Disadvantage: artificial casting likely to be maintenance nightmare, > because we change objects while we really want to change operators. > > A variant: only use .E for elementwise. Always return matrixwise. This > is simply just using casting to help select among two methods denoted by > the same binary symbol. Does not look much better than 4 but worth > considering. I don't think anyone proposed the pre-variant variant. It was always supposed to always return matrixwise. > ... > The argument "if it finds wide-spread use we may put it in the language" has > a severe limitation - if it is technically very difficult for users to use a > feature that's not in the language, it will unlikely to find wide-spread use > and may never get into the language. That's why I really hope something > like 1 can come up. Using method or function syntax is not "technically very difficult." There are hundreds or thousands of NumPy users who can testify to that. It is inconvenient. Yes. Inconvenience is the price of compromise. Compromise is the price of sharing a language with people who are uninterested your domain. > ["%5.2f", "%-8s", "%.2g"] .% [pi, 'short', 1] Eeek. That's really, really ugly. This is much more explicit: i = ["%5.2f", "%-8s", "%.2g"] j = [pi, 'short', 1] [for i,j in zip(list1, list2): i % j] -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enouX-Mozilla-Status: 0009ed conservative choke on his spotted-owl drumstick. - April 29th, Economist From hzhu at localhost.localdomain.bbs Mon Jul 17 23:00:04 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 18 Jul 2000 03:00:04 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRYX4$jy9@openbazaar.net> On 18 Jul 2000 02:01:58 GMT, Kevin Jacobs wrote: >What if it could be as simple as: > >e(r'(A .* B)\C') # --> PyAlgebra.evaluate(r'(A .* B)\C', globals(), locals()) >where A, B and C are bound to variables in the current namespace >automatically? Does this not go 95% of the way toward the ideal solution? Well, not that much. What about this: webpage = webobject(url) result = e(r'transform * get_data_from(webpage)') If it is allowed wouldn't we allow result = e(r'transform * get_data_from(webobject(url))') or even using "http:..." in place of url? Eventually, wouldn't the e(r'...') be able to parse the whole python grammer? If on the other hand it is limited to numerical type objects only it is too limited. In MatPy.gplot we use lists, dicts and strings to deal with multiline plots and titles, etc. Well, maybe I just don't like to treat numerical type objects any differently from other objects because they are intermixed all over in the programs. Otherwise a python-octave gateway or just stick with octave may even be preferable. One of my biggest gripe about matlab is it forces me to treat strings as part of matrix. Now you are asking me to treat matrix as part of string. :-) >I disagree with your conclusion. Having worked with many algebra and >statistical languages, I know the road you are undertaking. It doesn't and >can't stop with one extra dot in the grammar. To do it right, you need the >ability to break more rules that are intrinsic to Python's core. e.g., >consider changing the rules for '\' as above. This makes some sense, but I know a lot of people who can resist the temptation of other syntactic sugar, except infix operator for arithmetics - it's just too good a thing to miss. There are proposals for using @/ and /@ for two directions of division, or using % for left division. I'm comfortable with the current solve(a,b), or maybe a shorter sol(a,b) but am open to any suggestions. >Another advantage to compromising and implementing a domain specific >mini-language is that it simplifies some very tough design issues that only >come up when working with the full Python grammar. Some of these syntactic >and semantic issues are very likely irreconcilable. In the end we could end >up with a any number of splinter languages with inferior support and narrow >audiences. Lets not forget we are a community of users with very diverse >goals, all trying make our lives easier by building better tools. I'm not quite with you here. Exactly for the purpose of making numerical objects and other objects work seemlessly together I am against changing syntactic structure, and only for adding syntactic contents within current structure. Well, let's see if this makes sense. What I'm saying is, .* is just another operator, so if you replace it with * the syntax structure does not change. On the other hand, using e(r'...') changes the structure because variable names within a string suddenly gets out. In this sense it is less like a function call with a string literal argument, but rather a special syntax zone delimited with strange combination symbols e(r' and '). If a program is littered with such special zones the effect is very much like an aspect of Perl that I happen to dislike. Just my thoughts. Huaiyu From huaiyu_zhu at yahoo.com Wed Jul 19 18:16:40 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Wed, 19 Jul 2000 15:16:40 -0700 (PDT) Subject: Discussion: new operators for numerical computation In-Reply-To: Message-ID: Now that Guido has given the go-ahead for adding new operators for numerical computation, let us consider carefully how to allocate this new resource, taken into account Tim's guidelines. Here's a list of issues that come to mind: 1. What symbols to use. It seems that we can more or less concentrate on using either . or @ together with existing math operators. Issues: (1) Use . or @ (2) Which is matrixwise or elementwise (3) Compatibility: NumPy uses * for elementwise, MatPy uses * for matrixwise. (4) Similarity with Matlab (but not really compatibility). Notation: To avoid confusion, I'll adopt matlab notation and invent a set of unique names in the following discussions: matrix element names (with prefix m or e) + .+ add - .- sub * .* mul / ./ div \ .\ sol ^ .^ pow Therefore the statement "Use /@ for msol" or "Use /@ for matlab\" or "Use a/@b for solve(a,b)" are equivalent. In your followup you may add a line like Notation: * is matrixwise and .* is elementwise Notation: @* is matrixwise and * is elementwise so people would understand your examples. 2. Precedence, scope and other properties: This is largely settled (and that's what Greg's patch does) - They have exactly the same properties as their ordinary counterparts. - The e and m versions give identical results on numbers. 3. Their behavior on other objects: Even though they are supposed to be used for numerical objects only, what if user writes [10,20].+[1,2]? - Exception: no __dotadd__ or __rdotadd__ defined - Behave as eadd and give [11,22] - Behave as current + and give [10,20,1,2] The last one is dead, people writing [].+[] either made a typo of [].member+[] or want eadd. The second seems most sensible and least surprising, but it does need to include list in the implementation of eadd. My understanding is that Tim wants the first one. So let's leave it there lest it drags other bits down. 4. The magic words: This really depends on issue 3 above. - If it is intended that these thing should never acquire a meaning outside numerical computation, they should be called __mmul__, __emul__, etc, because that would describe the intension well. - If other classes, like UserList, are allowed to use them, it's better to use __dotmul__, __atmul__, etc, so the association with the symbols are strong. - Someone mentioned __altmul__ for @*, meaning alternative mul. 5. Other bits and pieces: - How to deal with left division? (1) Use sol(a,b) (2) use /@ or /. (3) use % - How to deal with power? It is already two characters (1) Use ** and .** or @** (2) Steal ^ with .^ or @^ (not much chance, just mentioning here) - Do we want a copy operator := which is different from =? It allows efficient code. The following code does not change A B := A B += C This definitely will be usable for other classes. Call it __copy__? - Since augmented assignment almost certainly will get in the core, we need to consider combining them. A few possible opinions (1) Just use prefix . or @ to mean e or m, use suffix = to mean in place assignment, and all are well defined. (2) a .**= 3 looks too long. Don't combine them. (3) allow .+=, etc but ban .**=. These are the things that come to mind. Now, opinions, please. Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From aotto at t-online.de Wed Jul 12 01:58:19 2000 From: aotto at t-online.de (Andreas Otto) Date: Wed, 12 Jul 2000 07:58:19 +0200 Subject: off-topic, "Compiler" technology References: <396ABBD7.8715465D@t-online.de> <3dog44zc7t.fsf@kronos.cnri.reston.va.us> Message-ID: <396C08FB.80C9EE29@t-online.de> Hi, > > Read some of the compiler-related threads in c.l.tcl first, though; > the compiler seems to be mostly a simple repackaging, and the author > shows signs of Usenet kook-dom, as in > http://www.deja.com/getdoc.xp?AN=642980911, where he says that the > compiler technology used also applies to natural languages. Time is > probably better spent working on python2c, which is much less > spectacular and much more plausible. > You can download, test, look to the source-code and run the application it is *not* a repackaging, the C back-end convert the TCL code into native C mfg aotto :) -- ================================================================ Andreas Otto Phone: ++49-(0)8152-399540 IPN Ingenieurbuero fuer mailto:aotto at t-online.de Praezisionsnumerik Web: http://home.t-online.de/home/aotto Ulmenstrasse 3 Skills: Unix,Sql,Tcl,Shell,Sybase... D-34289 Zierenberg Area: Bank, FX, MM, shares, options ================================================================= From werner.geuens at skynet.be Tue Jul 11 21:56:20 2000 From: werner.geuens at skynet.be (Werner Geuens) Date: Tue, 11 Jul 2000 21:56:20 Subject: Using proxy Message-ID: <396bd06b$1$jreare.trhraf$mr2ice@news.skynet.be> I want to retrieve a measurement logfile from a geological measure site at regular intervals. The document is available under http form. The function urllib.urlretrieve works very well, and cron takes care of the periodic launching. But after on-site testing with a portable, I came back at the office. I tested the log file with my browser (all OK), then started the Python script and ... nothing. Turns out it's a proxy problem. I have the needed permissions, do web and ftp trough the companies proxy all the time. But how do I go about that with python? I'm using Python 1.5.2 on WinNT and OS/2, and will be using it under Linux (SUSE 6.2 or 6.4) in a near future. Any simple solutions? -- werner.geuens at skynet.be (Werner Geuens) Research is what I'm doing when I don't know what I'm doing. Wernher von Braun. From wayne.izatt at myself.com Sat Jul 22 02:09:17 2000 From: wayne.izatt at myself.com (Wayne Izatt) Date: Sat, 22 Jul 2000 06:09:17 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> Message-ID: <39793A4D.A3D8995F@myself.com> Just a guess, since I don't know much about Windows, but isn't the '/' meant to be a '\'? cheers Jack wrote: > Hey there, > > im pretty new to using python, and im just experimenting with file access, > a wrote a script that works fine, and then all of a sudden it started > throwing up this error: > > inp = open("c:/autoexec.bat",'r') > TypeError: illegal argument type for built-in operation > > it was working fine before, and i dont see anything unusual in the syntax. > > Any help would be appreciated, > > Cheers, > > Jack Green From slinkp23 at yahoo.com Sun Jul 9 16:33:52 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sun, 09 Jul 2000 16:33:52 -0400 Subject: Namespace weirdness Message-ID: <3968E1B0.B6E6F3E9@yahoo.com> Hi, I think this is impossible... but is there a way for an object to know what its parent namespace is? I'm not sure if I phrased that correctly. Here's the simplest code I can that demonstrates the idea. class Food: def __init__(self, attr1): self.attr1 = attr1 class BodyPart: def do_it(self): # This next line is a stand-in for what I want... print my_parent_namespace.attr1 egg= Food("Hello from the egg!") egg.head = egg.BodyPart() egg.head.do_it() # I want this to print "Hello from the egg!" ----------------------- I'm pretty new to OO design in general, so it could be that I'm nuts and there's no good reason to ever want to do this... As far as I can tell, it's impossible because instances don't "know about" the names that reference them, since there may be an unlimited number of such references. So there is no way for egg.head to know about egg.attr1 unless I pass it as an argument to egg.head.do_it() or egg.head.__init__()... But I would love to be proved wrong since I want egg to have a LOT of attributes, and I want it to contain a lot of objects that know where to find them. I have thought of one solution, which is to pass in the namespace as an argument to the enclosed class, as part of its __init__(). That's a pretty minimal amount of work to get the result I want. class Food: def __init__(self, attr1): self.attr1 = attr1 class BodyPart: def __init__(self, parent_namespace): self.parent_namespace = parent_namespace def do_it(self): # Now it should work. print self.parent_namespace.attr1 egg = Food('Hello from the egg.') egg.head = egg.BodyPart(egg) egg.head.do_it() ------------------------ But for some reason this bothers me... maybe it's just that I know what I mean and I wish python could read my mind. :) Imagine this conversation: me: "Bob, please say hello." Bob: "Hello!" me: "Bob, what is your name?" Bob: "I have no idea." me: "Then why did you answer when I called you Bob?" (The answer, of course, is that Bob only does things that python tells him to do, and it's python, not Bob, that initiates Bob's actions; and when it does so, it doesn't refer to him by name, it just speaks to him privately... at least in this weird analogy I'm making.) Maybe I'm off the deep end here, but I think it would be really interesting if it were possible for an object to find out how it was called. Sort of analogous to sys.argv[0]. And even more interesting if spam.eggs.bacon had some way of knowing that it lives in eggs which lives in bacon... ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From pete at visionart.com Thu Jul 20 19:29:34 2000 From: pete at visionart.com (Pete Shinners) Date: Thu, 20 Jul 2000 16:29:34 -0700 Subject: zip() : how about braid() References: <397681C6.FEAEE2E@my.signature> <397746AE.3CCDD423@schneider-kamp.de> <700fnsknn7k7fp22au924m2cprk04ghfic@4ax.com> <3977A093.5F98A59C@schneider-kamp.de> Message-ID: <8l82k2$cpo$1@la-mail4.digilink.net> "Peter Schneider-Kamp" wrote > > >>> marry([1,3,5],[2,4,6]) > > ([1, 2], [3, 4], [5, 6]) > > >>> divorce([1,2,3,4,5,6]) > > ([1, 3, 5], [2, 4, 6]) > > > I absolutely truly *LOVE* this. That's great. > Man, you made my day! > > > zip() / unzip() sounds just so technical. ah, but how would divorce always know how to best separate the list? i suggest the marry function takes an optional second argument, "prenuptual" this way when marriage is made with a prenuptual, the divorce goes much more smoothly. of course, if marry() never expects to be followed with a divorce() there is little need for the prenup. From robin at jessikat.fsnet.co.uk Sat Jul 22 03:27:32 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 22 Jul 2000 08:27:32 +0100 Subject: CVS missing xmlparse.h References: <3975BA62.91AE3D0@prescod.net> <5YhvBcAHucd5Ewz$@jessikat.fsnet.co.uk> <3975D3ED.2CD5AEAA@prescod.net> Message-ID: In article <3975D3ED.2CD5AEAA at prescod.net>, Paul Prescod writes >Robin Becker wrote: >> >> ... >> >> so the core will include the module source, but not a needed .h file; > >Guido has a policy against distributing other people's modules. > >> the python-xml kit used to include all; > >I guess Andrew Kuchling isn't such a hard-ass. :) > >> do I need pyexpat.pyd? Probably >> not. > >No, if you're compiling yourself you don't need it. > well I got the latest expat and built this now; with VC++ 6 at least the compiler complains bitterly about some of the doc strings which are continued across two lines. -- Robin Becker From baron at null.net Sat Jul 8 23:20:57 2000 From: baron at null.net (Matthew Schinckel) Date: Sun, 9 Jul 2000 12:50:57 +0930 Subject: Making tabs illegal In-Reply-To: References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: On Jul 8, I overheard Bjoern Lindstroem mutter: > Matthew Schinckel wrote: > > Ugh! Don't make this the default - I hate having to hit space four times, > > I'd much rather just use tab. > > Um... I had no problem to configure my editor to insert an > appropriate amount of spaces when i press . This was not my issue - someone else was suggesting to BAN tabs, I was saying 'NO!' -- Matthew Schinckel What this country needs is a good five cent microcomputer. From mwh21 at cam.ac.uk Tue Jul 25 16:00:08 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Jul 2000 21:00:08 +0100 Subject: Memory management References: <8lkdh5$qpm$1@news.rchland.ibm.com> Message-ID: "Larry Whitley" writes: > I'm running out of virtual memory on my NT 4.0 system running a longish > python script. Python says "memory error" and quits. NT shows the > application using 130+ megabytes. I have 192 megabytes on the system so it > seems like a rational number. I suspect that this means that I have a > memory leak in my code. > > In the outer loop of my code, I create a object of a class I have defined. > The outer loop reads records from a trace file and hands them to the object > created for execution. This first level object creates a number of second > level objects of a different class while processing the trace file. When > the trace file is complete, the outer loop deletes the first level object. > I am expecting that to cause all of the references held by that object, and > those of the second level objects is created to go to zero. > > Here's a programmtic description: [schnipp] > My question: How do I get rid of the memory used by o1 and by o1a, o1b, etc > within o1 when each trace file is processed? I'm guessing that you have reference cycles; these can be fun to find, and even more fun to eliminate. However the code you posted didn't create any cycles, so either post some more, or go and stare at your code some (ask Gordon about the "hypnotising bricks" approach...). It's also possible that Python 2.0 will have a better garbage collector. Cheers, M. -- Very rough; like estimating the productivity of a welder by the amount of acetylene used. -- Paul Svensson, comp.lang.python [on the subject of the measuring programmer productivity by LOC] From dale at out-think.NOSPAMco.uk Thu Jul 6 10:24:05 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 6 Jul 2000 15:24:05 +0100 Subject: getattr and setattr References: <8k1vqo$3e9$1@supernews.com> <20000706155320.A25064@xs4all.nl> Message-ID: <8k24qm$5dp$1@supernews.com> Very useful. Thanks. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Thomas Wouters wrote in message news:20000706155320.A25064 at xs4all.nl... > On Thu, Jul 06, 2000 at 01:58:45PM +0100, Dale Strickland-Clark wrote: > > > I'm still trying to get to grips with object programming in Python and > > finding decent documentation unbelievably hard to track down. > > Hm, I've never needed much more than the documentation on www.python.org: > the tutorial at first, then the language ref and the library ref ;) > The only parts lacking in there are Tkinter, and some modules which aren't > documented yet. > > > I eagerly set about the tutorial but found it was lacking in - well - just > > about every department. > > The tutorial is more of an intro than a comprehensive educational track. Try > the Language Reference or the Library Reference. If you don't care for the > dull reference-style writing, try something like Learning Python, by > O'Reilly, or one of the other online tutorials available (sorry, no URLs ;P) > > > I can't find any meat on __getattr__ and __setattr__. > > These two special object functions don't seem to be very well documented > > anywhere. (Please prove me wrong!) > > The language reference, section 3.3, 'Special Method Names': > http://www.python.org/doc/ref/specialnames.html. To be more specific, > section 3.3.2, 'Customizing attribute access'. > > > I can see how to handle a special case in __getattr__ with something like: > > > class wibble > > def __getattr__(name): > > if name == 'fred': > > return 1 > > else: > > # what? > > > But what if it's not the special case(s). How do I return an arbitrary > > attribute? Do I do something like: > > __getattr__ is only called if the attribute does *not* exist on the object. > The reason is fairly simple: if it was called for every lookup, __getattr__ > itself could never be looked up ! > > If you decide, in your __getatr__, that an attribute shouldn't exist, you > should raise AttributeError. Don't do something like 'return 0' or you'll > confuse all kinds of internal mechanisms, like those that lookup special > method names ;) > > __setattr__, however, is called for every attempt at storing a value in an > attribute, wether it exists or not. If you use __setattr__ and want to > alter an attribute, you shouldn't do the obvious ! If you assign from inside > __setattr__, __setattr__ is called again. Instead, you should modify > self.__dict__. > > Section 3.3.2 explains all this, but in a bit less (and different ;) words. > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! > From neilh at scintilla.org Thu Jul 6 08:18:18 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 06 Jul 2000 12:18:18 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 6th, 2000 References: <20000706115459.24950.qmail@synop.com> Message-ID: > ## Unanswered Questions ######################################## > > > ------------------------------------------------------------- > Why is some strange charachters appearing instead of norwegian charachters in GUI of pythonwin build 132 > http://www.faqts.com/knowledge-base/view.phtml/aid/4590 > ------------------------------------------------------------- > Nils Otto Johansen I'm not sure about 132 but 131 defaults to using Unicode for editing Python source code and the interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and comment out the two lines under "# Enable Unicode if we can". Save the file, shut down Pythonwin and restart it and see if this fixes the problem. Neil From max at alcyone.com Tue Jul 25 20:56:40 2000 From: max at alcyone.com (Erik Max Francis) Date: Tue, 25 Jul 2000 17:56:40 -0700 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> Message-ID: <397E3748.C9BC86DD@alcyone.com> Curtis Jensen wrote: > I don't know if this is possible in python but, Is there a way to > repeat > a format command a spceified number of times? For example, in Fortran > there is the format code "20I5" Which is the same as "I5" twenty > times. I want something like: > print '20(%i5) ' % [list of 20 intgers] Why not something like print ("%5d " * 20) % integerTuple -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Triumph cannot help being cruel. \__/ Jose Ortega y Gasset The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From horst at proceryon.at Wed Jul 19 06:32:20 2000 From: horst at proceryon.at (Horst Gassner) Date: Wed, 19 Jul 2000 12:32:20 +0200 Subject: Canvas text - clipping instead of wrapping Message-ID: <397583B4.52066F4E@proceryon.at> Hello! (using Tkinter) Maybe a (too) simple question but I can not find the answer :-( Is it possible to clip text inside the canvas text item? The default behavior is wrapping text if the width attribute is set but I don't like this in my special case. If clipping is not possible - which is the best workaround for doing this? Thank you in advance Horst From genablu at my-deja.com Fri Jul 14 06:38:28 2000 From: genablu at my-deja.com (genablu at my-deja.com) Date: Fri, 14 Jul 2000 10:38:28 GMT Subject: Python + Apache 1.3.x (CGI) not working (no mod_python) References: <8kmjlb$vji$1@nnrp1.deja.com> Message-ID: <8kmqj3$44b$1@nnrp1.deja.com> Thanks to all for clarifying the '\n' at the end of the line! It's funny: I'd been paying attention to "follow with a blank line" as in "a line with a space" not "a line feed". Let me know if I can be of assistance in any way. Hugs! Gena Sent via Deja.com http://www.deja.com/ Before you buy. From brianbird at my-deja.com Fri Jul 7 06:49:32 2000 From: brianbird at my-deja.com (brianbird at my-deja.com) Date: Fri, 07 Jul 2000 10:49:32 GMT Subject: How to print to stdout in binary References: <8k1kn5$mkt$1@nnrp1.deja.com> <3965408E.DDD4A2@pehr.net> Message-ID: <8k4cjr$fic$1@nnrp1.deja.com> I was actually testing under WindowsNT, but using Linux isn't a problem either. I tried your test under both using an image file (test.gif) piping into a new file "test2.gif" Under linux the new file was identical and remained as an image viewable from a web browser Under windows, the new file was identical (according to Textpad's compare function) but in Internet Explorer the image appeared partially corrupted - but it still appeared as an image which is more than I got before :-) Does this mean sys.stdout will write in whatever mode it thinks is correct or does it just output the exact string you give it to output? (A normal file can output two different strings into a text file depending on whether you tell it to write in binary or ascii) However, I think this means that the problem I had with displaying the image in an HTML tag is probably not to do with the mode of python stdout after all. Probably a webserver will output a header before an image file which means the script will need to do that as well. This probably isn't really the forum to ask, but does anyone happen to know what this might be? :) In article <3965408E.DDD4A2 at pehr.net>, pehr at pehr.net wrote: > What platform are you developing on? > under linux I did the following in a file "t.py": > > import sys > x = open("python.prc", "rb").read() > sys.stdout.write(x) > > [pehr at morseall python]$ python t.py > t > [pehr at morseall python]$ diff python.prc t > > I didn't get any differences when I did this. > Would you try it and see how it goes? > > -pehr > > brianbird at my-deja.com wrote: > > > > I've seen similar questions to this posted in other language forums, > > but I've not seen anything for Python: > > > > Does anyone know how to tell python to print the sys.stdout in binary > > rather than plain text. It's mode is set as 'w' and I can't seem to > > change it. > > > > I'm experimenting with a cgi script which I want to output an image to > > the browser so that the HTML file can have: > > > > and the resulting output of the script is an image. > > I've currently got: > > > > f = open("test.jpg","rb") > > bytes = f.read() > > f.close() > > sys.stdout.print(bytes) > > > > but I want the output to print in binary mode so that the image can be > > displayed correctly. If I was printing to another file I could open it > > with: > > > > f2 = open("test2.jpg","wb") > > f2.write(bytes) > > f2.close() > > > > so is there any way to do this with stdout? > > > > Thanks > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From tjg at exceptionalminds.com Thu Jul 6 14:04:21 2000 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 6 Jul 2000 11:04:21 -0700 Subject: mxODBC module In-Reply-To: <8k14us$c4c$1@nnrp1.deja.com>; from ekw1@my-deja.com on Thu, Jul 06, 2000 at 05:20:33AM +0000 References: <8k14us$c4c$1@nnrp1.deja.com> Message-ID: <20000706110421.B876@reepicheep.avalongroup.net> On Thu, Jul 06, 2000 at 05:20:33AM +0000, ekw1 at my-deja.com wrote: > And I can't even import ODBC.MySQL: > >>> import ODBC.MySQL > Traceback (innermost last): > File "", line 1, in ? > import ODBC.MySQL > File "C:\Program Files\Python\Lib\ODBC\MySQL\__init__.py", line 7, in > ? > from mxODBC import * > ImportError: No module named mxODBC > > mxODBC is on the same directory level as MySQL, but it can't be found. I can't help you with the first problem, but I know the second one well. Usually this happens when you have installed the win32 extensions. There is an ODBC module that comes with them and you end up with a name conflict. The solution is to delete the odbc.pyc file that is in one of the python/Win32 directories. (Sorry, I don't have a Windows computer near me at the moment to check the exact place). -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com Red Hat Certified Engineer (503) 246-3630 Avalon Technology Group, Inc. fax (503) 246-3124 >>>>>>>>>>>>Linux...Because crashing isn't normal<<<<<<<<<<<<< From paul at prescod.net.bbs Mon Jul 17 15:40:06 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 19:40:06 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRNB9$l0S@openbazaar.net> Huaiyu Zhu wrote: > > ... > > As to the claim that additional operators for linear algebra is somehow > comparable to the special syntaxes/quirks of various programming languages, > no real argument has been presented so far. Okay, then, let me try. > It's more like: If I don't care > and don't use such things, they must belong to a special domain and be > somehow comparable to some other things that I do know and dislike. Let me rephrase: "If MOST Python programmers don't care and don't use such things, they must belong to a special domain." I think that's a good operative definition of "domain specific". That's the crux of the argument. Don't throw complex numbers back in my face because they required *minimal new syntax*. There is already more "extra" syntax in the language for matrices than for complex numbers. I don't know why you have the impression that matrix operators have been compared to anything that people dislike. Most people have compared them to things that they *do* like, but must do through function syntax because Python doesn't pander to my particular needs or your particular needs, but rather those of most average programmers. I like XML processing and I daresay there are more books sold on it than on Matlab. But I've never asked for special, XML-specific syntax. Maybe you should consider how to scale back your syntactic request. Perhaps a single keyword or symbol at the beginning of an expression could make it element-wise or matrix-wise. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From gjohnson at gs.verio.net Tue Jul 18 21:38:25 2000 From: gjohnson at gs.verio.net (Tony Johnson) Date: Tue, 18 Jul 2000 20:38:25 -0500 Subject: Getting local IP address... References: <8l236h$8b8i$1@nntp6.u.washington.edu> <39750089$1_1@my.newsfeeds.com> Message-ID: <39750690.7F1BE2C@gs.verio.net> >On the bright side, generally it's not necessary to know your own >IP address. I'm curious why we are seeing this question so often, >what are folks doing out there? Uuum Excuse me...??? What server software do u run that will work properly using dhcp addy's??? I think someone needs to rethink think thier position From hzhu at localhost.localdomain Mon Jul 17 02:34:01 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 17 Jul 2000 06:34:01 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F76F0.1B451932@sage.att.com> Message-ID: On Mon, 17 Jul 2000 02:07:08 GMT, jepler epler wrote: >On Sat, 15 Jul 2000 04:29:09 GMT, Huaiyu Zhu > wrote: >>That's the beauty of numerical computation, because all kinds of >>applications, from animation on your screen to controlling satallite in >>space to analysing molecular structures to calculating consumer preference >>could all be expressed in the language of linear algebra. (Mathematicians >>study spaces more abstract than linear spaces, but you wouldn't want to hear >>about them before appreciating the usefulness of linear algebra.) For >>example, all deterministic procedures are functions, and most functions we >>see are simply points in an (infinite dimensional) space. > >That's the beauty of procedural programming, because all kinds of >applications, from animation on your screen to controlling a satellite in >space to analyzing molecular structures to calculating consumer preference >could all be expressed in the language of procedural programming. >(Programmers study programming languages more abstract than functional >programming, but you wouldn't want to hear about them before appreciating >the usefulness of procedural programming.) For example, all deterministic >processes are expressible as Turing machines, and most turing machines >we see are simply expressible in procedural languages. > The first paragraph was a response to a particular argument. There are problems that most people would not think of using linear algebra and ends up with programs of hundreds of lines with slow for loops, but which could be expressed in just a couple of math formula and, given the right syntax, maps to less than a dozen lines of short clean code. I'm not sure what the second paragraph is referring to. If it is telling people that something that's written in assembly could be easily done in procedural languages then it makes perfect sense, except for the reference to Turing machines - if you use Turing machines as building blocks (as opposed to computing engines), how many TMs do you expect to halt before the program finishes? not-that-this-is-on-topic-ly yr's Huaiyu PS. I'm sure someone would ask how you could complete the calculation of an infinite dimensional vector. That is left as an exercise to the reader. :-) From klm at digicool.com Sun Jul 16 15:38:51 2000 From: klm at digicool.com (Ken Manheimer) Date: Sun, 16 Jul 2000 15:38:51 -0400 (EDT) Subject: pdbtrack.el - track source file whenever runing pdb in an emacs buffer Message-ID: <14706.3915.797969.565968@korak.digicool.com> I've put together an alternative, pared down approach to doing python debugging inside emacs - pdbtrack: http://www.zope.org/Wikis/klm/PDBTrack Once loaded, pdbtrack watches your (comint) process interaction buffers for the pdb stacktrace. When it sees it, and can find the file containing the current stacktrace focus, it pops the file up in a separate emacs buffer, centered on the current debug line. This way you continue to interact with pdb, stepping into and out of functions, moving up and down stack frames, anything that changes focus - and emacs displays the right place in the source in a companion buffer. Of course, pdbtrack works just fine with the zope interactive debugger (reachable, for example, via: % cd $SOFTWARE_HOME/lib/python % python >>> import Zope; app = Zope.app() >>> Zope.debug('Zope.app().whatever', d=1) [debug...] ) The big difference between pdbtrack.el and pdb.el is that you don't need to start your debugging session in a GUD (Grand Unified Debugger) buffer. I often have to arrange a lot of state in the interpreter before i can jump into debugging. This generally defeats switching to a GUD session, with its separate process - while pdbtrack just jumps in whenever i go into the python debugger, within the accumulated context. pdbtrack lacks a number of things that GUD does have. It doesn't highlight the current source line other than centering it in the source buffer, and it doesn't provide nicities like stepping and setting breakpoints from within the source buffer. However, pdbtrack is much much more lightweight than gud - and it might be interesting to see about providing some of the gud features, like debug keybindings in the source file buffers involved in the debug session, with this more open, decentralized model. In the meanwhile, pdbtrack goes a long way towards doing what i want - i hope it's useful to others. I've submitted an entry for vaults of parnassus, not sure how long it takes to show. To repeat from above, you can find it at: http://www.zope.org/Wikis/klm/PDBTrack Ken Manheimer klm at digicool.com From mpotter27 at my-deja.com Wed Jul 12 15:53:34 2000 From: mpotter27 at my-deja.com (mpotter27 at my-deja.com) Date: Wed, 12 Jul 2000 19:53:34 GMT Subject: Tkinter destroy() and mem leaks Message-ID: <8kiibl$1rm$1@nnrp1.deja.com> Hi, I have what is probably a rather naive question, but here goes... I puzzled as to why invoking the destroy() method on a widget fails to remove the reference to it's master? As far as I can tell from the code it removes the references in master.children, removes all it's own children entries, etc.. but retains it's self.master reference. For example: >>> from Tkinter import * >>> import sys >>> f = Frame() >>> b = Button(f) >>> sys.getrefcount(f) 4 >>> f.destroy() >>> sys.getrefcount(f) 3 >>> b.master >>> f.children {} >>> b.master = None >>> sys.getrefcount(f) 2 This typically isn't a problem as long as the master doesn't hold any references to the child other than via .children. However, the situation that made me notice this was one in which I made a simple- minded "mega-widget" by subclassing Frame and having it store references to a number of subwidgets as attributes: class myFrame(Frame): def __init__(self,parent = None): Frame.__init__(self,parent) self.button = Button(self,command=self.callback) def callback(self): pass If used so: frame = myFrame() frame.destroy() del(frame) It leaks memory as the button references the myFrame instance via .master and myFrame references the button via self.button. Now one could avoid this by structuring the code differently, but it seems that simply having Tkinter.BaseWidget.destroy set self.master = None would solve the problem. It seems that destroy should remove all the Tkinter specific "stuff" from the python proxy object. However I'm sure there's a reason it doesn't. I'd be grateful if someone could tell me what it is. Sorry for the long post! Mike Potter Center for Advanced Research in Biotechnology 9600 Gudelsky Dr Rockville, MD 20850 potterm at erols.com Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Thu Jul 20 09:48:05 2000 From: aahz at netcom.com (Aahz Maruch) Date: 20 Jul 2000 13:48:05 GMT Subject: Discussion: new operators for numerical computation References: Message-ID: <8l6vul$5ig$1@slb3.atl.mindspring.net> In article , Huaiyu Zhu wrote: > > matrix element names (with prefix m or e) > + .+ add > - .- sub I am strongly opposed to operators of the form ".+". What happens if take an expression of the form "5.+matrix"? No, that goes against the Python rule of having zero ambiguity. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From olivierS.dagenaisP at canadaA.comM Mon Jul 24 10:23:58 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 24 Jul 2000 14:23:58 GMT Subject: newb Q: security with variables References: <397BE388.349CCA17@mediaone.net> Message-ID: <2kYe5.25991$1h3.418424@news20.bellglobal.com> How about encrypting the contents of the file? Or using a One Time Password challenge/response mechanism? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Toy" wrote in message news:397BE388.349CCA17 at mediaone.net... > Could you please explain to me various secure ways of having a python > script store variables such as your password/username in a file. > I understand that you can chmod 0400 , but are there any > other alternatives? > > Also, can you run python code with files that don't end with the python > extensions(.py and others)? That way it would make it less obvious that > it was some sort of script. Thanks > Jason Toy > toyboy at toy.eyep.net > http://toy.eyep.net > From richard_chamberlain at ntlworld.com Sat Jul 29 16:04:48 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sat, 29 Jul 2000 21:04:48 +0100 Subject: QUESTION: COM objects in python? References: <8lt4ra+sgp4@eGroups.com> Message-ID: Hi, Mark probably didn't mention because he wrote it but there's a great book by him and Andy Robinson caled Python Programming on Win32. It gives some excellent examples of exactly what you want to do. Richard M. Ranganathan wrote in message news:8lt4ra+sgp4 at eGroups.com... > Hello, > > Another question from a newbie... > > I would like to build an application server object and export a COM > interface for it so others can use my component. I would like to use > python to do this. Is this possible / easy to do? If so, where can I > look to find how to do this? > > I know that the opposite is possible (i.e. call com interfaces from > python). > > Thank you in advance for your replies. > > Ranga. > > From kpmurphy at my-deja.com Mon Jul 24 12:37:02 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 24 Jul 2000 16:37:02 GMT Subject: tkinter: grid: expand and fill Message-ID: <8lhrbd$t4v$1@nnrp1.deja.com> is there a way to make a frame, that's been formatted using grid, expand to fill the space it is given? thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From donn at u.washington.edu Thu Jul 20 12:55:29 2000 From: donn at u.washington.edu (Donn Cave) Date: 20 Jul 2000 16:55:29 GMT Subject: Type checking in python? References: <39770CD5.215D4C0C@cornell.edu> <397296BC.415C97E1@prescod.net> Message-ID: <8l7au1$mf6$1@nntp6.u.washington.edu> Quoth Samuel Scarano : ... | Anyway, interesting point, but isn't that what multiple inheritance is for? | A static (or, for that matter, dynamic) typecheck ensuring that the function | is called with a string would work fine with unicode strings as long as the | unicode string class is a subclass of the string class. | | Of course, you can't inherit from a built-in type, which is one of the | uglier features of Python, so it wouldn't work in this case. But is that the | only reason not to do it? That is, when dealing only with user-defined | classes, is there ever any real reason to try to fool a function by passing | an object of the wrong class but with the right methods, rather than | declaring its class as a subclass of the class the function is expecting? I just learned while reading another post in this thread that my thoughts about these matters puts me in the group of people who think deeply about it, so I'm emboldened to put my 2 cents in! What about the file object and StringIO? I mean, supposing that you were motivated to implement a class like StringIO, and that the file object were also a Python class, would you make StringIO a subclass of file, or just implement the interface? I would just implement the interface, just because there's nothing of value for me (that I can think of, anyway) in the file implementation. I want something that ``walks like a duck'', but is not a natural duck of some exotic species but a completely unrelated thing that shares only its very simple abstractions. If I carried along a natural duck in there, it would be kind of an ancestor fetish, not a useful thing. Maybe both should inherit from some class that represents the basic notions that they all implement, even though there wouldn't be any actual implementation at that level of abstraction, just so's we could look at the class hierarchy and say ``It's a duck!''. I guess some languages do this, Python doesn't. I think that's good. Because we don't respect the ancestor fetish, I don't have to go back to the author of file and say ``Hey, why don't you pull an abstract base class up out of your class so I can inherit from it?'' and then to the author of some library function and say ``Hey, we have this new abstract base class for "file", so expect that instead and I can use your function.'' I just bolt on the duck stuff and we're ready to go in 10 minutes. Donn Cave, donn at u.washington.edu From cppdan at dansmart.com Mon Jul 31 22:59:13 2000 From: cppdan at dansmart.com (Dan Smart) Date: Tue, 01 Aug 2000 02:59:13 GMT Subject: The State of Python References: Message-ID: <8F82EDFE0Me@167.206.112.102> tim_one at email.msn.com (Tim Peters) wrote in : > The decision to put something in the public domain is >irrevocable, so stops that game before it starts. In the area of >programming languages, the decision to develop Icon >(http://www.cs.arizona.edu/icon/) in the public domain has granted Ralph >Griswold a long, happy and lawyer-free life. > WARNING (IANAL but have been advised by one) Putting something in the public domain involves releasing it without a license and I have been told that this is extremely risky. Apparently the primary purpose of a BSD style license is to limit liability - typically to no more than you paid for the software (i.e. nothing). With out such a license clause, or indeed a license at all, you are potentially open to unlimited liability in the event that a user of your software suffers harm from such use - even though they paid nothing for it. This struck me as insane, but I have been assured that this is the case. >not-speaking-for-anyone-ly y'rs - tim Barely-communicating-ly yours Dan -- Dan Smart. C++ Programming and Mentoring. cppdan at dansmart.com From moshez at math.huji.ac.il Wed Jul 12 13:44:44 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 12 Jul 2000 20:44:44 +0300 (IDT) Subject: Browse for folder In-Reply-To: <522b5.7305$wE2.19499@dfw-read.news.verio.net> Message-ID: On Wed, 12 Jul 2000, michael montagne wrote: > I found the FileDialog sample but I need to Browse for folder not dialog. > How might that be done? Remeber, I'm a newbie. If you're using Python 2.0b1 with Tcl/Tk 8.3, you should be able to do: import tkFileDialog class DirChooser(tkFileDialog._Dialog): command = "tk_chooseDirectory" def askfordir(): return DirChooser().show() (untested) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From pauldubois at home.com Fri Jul 7 11:58:05 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Fri, 07 Jul 2000 15:58:05 GMT Subject: More PyArg questions? References: Message-ID: Arint? wrote in message news:fLl95.37562$NP5.1182716 at newsread2.prod.itd.earthlink.net... > Is PyArg_ParseTuple and PyArg_ParseTupleKeywords (or whatever it is) the > only two to monkey are with arguments passed from python to c++? There is no law against using the CAPI to get arguments individually from the tuple of args and disposing of them one at a time as desired. > > Also, what would be the best way to set a string that the python script > wants to be filled in. Ex. > some.py > fillinstring = " " > cplusplusapp.read(fillinstring) > > What is the best way for C++ apps to fill in that string? Are python > strings going to be resizable? > Python strings are not only not resizeable they are IMMUTABLE. Your example coding would likely cause great harm. The easiest way to do this is make the string a part of the return: fillinstring = cplusplusapp.read() You can create the string in the C API using e.g. PyString_FromString. From just at letterror.com Wed Jul 26 05:24:28 2000 From: just at letterror.com (Just van Rossum) Date: Wed, 26 Jul 2000 10:24:28 +0100 Subject: PythonWin/Scintilla aggressive folding... References: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> <1csf5.40036$Gh.442627@news20.bellglobal.com> <7mwf5.12307$4p3.95451@news-server.bigpond.net.au> Message-ID: <397EAE32.8A76A18A@letterror.com> Neil Hodgson wrote: > [ ... ] I introduced the level > neutral comments idea after developing the original strictly indentation > based code and using it on example files. First blank lines had to become > level neutral as lots of functions and methods have blank lines. Then I > found lots of commented out bits so made the comment lines work like blank > lines. Another heuristic that may be light weight would be that comment > lines try to bind in a forwards direction but this may require some > look-ahead. The latter would indeed make a lot of sense; I think it's safe to say that most comments apply to the code after it. Also: folding away too much is worse than folding too little. still-hope-to-find-time-some-day-to-port-Scintilla-to-my-platform-ly y'rs -- just From jon_mclin at attglobal.net Fri Jul 7 19:28:15 2000 From: jon_mclin at attglobal.net (Jon McLin) Date: Fri, 07 Jul 2000 17:28:15 -0600 Subject: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: <3966678F.710E45B9@attglobal.net> try: try: # some code except: # catch exception finally: #clean up Thomas Weholt wrote: > Hi, > > Does python support, or if not, would it be cool to have support for : > > try: > # some code > except : > # catch exception > finally: > # clean up whatever > > Thomas From ngps at madcap.dyndns.org Sun Jul 23 08:21:59 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 23 Jul 2000 12:21:59 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lc6jk$1f1$1@coco.singnet.com.sg> <8lde5s$vba$1@nnrp1.deja.com> Message-ID: <8leo17$tnt$1@dahlia.singnet.com.sg> According to : > i have download M at Crypt0 0.05-snapshot#3 and unzip it.How to use it? > because when i 'm try to run "python urllib2.py" i got an error urllib2.py is a library, not an application. See demo/ssl/https_cli.py. -- Ng Pheng Siong * http://www.post1.com/home/ngps From gjohnson at gs.verio.net Mon Jul 17 16:34:51 2000 From: gjohnson at gs.verio.net (Tony Johnson) Date: Mon, 17 Jul 2000 15:34:51 -0500 Subject: Internet Programming in Python References: <397221B2.173C3947@u.washington.edu> Message-ID: <39736DEB.D2285ADD@gs.verio.net> http://www.ora.com shuld carry this one... steve langer wrote: > > Does anyone know a used book store that would carry this out of print > book? > > Email great. > > thanks, > SL sglanger at oakland.edu > > -- > http://www.python.org/mailman/listinfo/python-list From tanzer at swing.co.at Wed Jul 26 01:18:45 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Wed, 26 Jul 2000 07:18:45 +0200 Subject: Python is wierd! In-Reply-To: Your message of "Tue, 25 Jul 2000 16:38:33 GMT." Message-ID: "Rainer Deyke" wrote: > Static variables and methods are a mess anyway. In Python, there is no > need for them - just place the variables and functions outside the > class. That's a strong statement. But it is not true. If you write code using classes as first-class objects, class variables and methods can be very useful. As Moshe Zadka recently demonstrated, there even is a way to get class methods in Python: > Let me reiterate the way to get class methods: > > class Function: > > def __init__(self, func): > self.func = func > > def __call__(self, *args, **kw): > return apply(self.func, args, kw) > > class SomeClass: > > def class_method(a, b, c): > return a+b+c > class_method = Function(class_method) Of course, you can go out of your way and go from class to module to module variable/function, but then that really is a mess. -- 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 neilh at scintilla.org Tue Jul 18 10:02:57 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 18 Jul 2000 14:02:57 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> <39739291.4155A128@prescod.net> Message-ID: John Lull wrote > By that reasoning, cryptography ought not be part of the standard > distribution, either. Nor should complex numbers. I'm all for that one. Lets remove complex numbers. With creaping featurism, each new feature makes someone very happy. The small amount of added pain to the majority isn't noticeable until the layers of crud have become deep enough to start paralysing development. Its /so/ hard to remove something once its in and backwards compatibility becomes an implied but unbreakable contract. I don't care so much about cryptography as its just another library with no syntactic overhead but removing complex numbers would decrease Python's complexity ;) Neil From cjc26 at nospam.cornell.edu Thu Jul 27 14:38:18 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 27 Jul 2000 18:38:18 GMT Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> <2OVe5.11$o45.2121@news.corecomm.net> Message-ID: * nobody menulis: | | > Also, in your example you'd probably want to use search() rather than | > match(), which only succeeds if the regexp matches the beginning of the | > string (i.e. it acts as if there is an implicit '^' at the beginning of | > the regexp). | | hm. any difference in performance, or can i just as well make the caret | explicit and standardize myself on match? Er, what I meant was that match() only succeeds if the regexp matches the beginning of the string, while search() will succeed if the regexp matches anywhere in the string. I doubt there's any difference in performance. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "But why is it TILED?!?" icq 68165166 From ge at nowhere.none Thu Jul 20 11:11:59 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 20 Jul 2000 15:11:59 GMT Subject: 2 tkinter questions References: <3976B061.617CACB0@structurex.net> <8l6rmt$h1a$1@nnrp1.deja.com> Message-ID: <3FEd5.1816$6E.374768@ptah.visi.com> In article <8l6rmt$h1a$1 at nnrp1.deja.com>, John Grayson wrote: >In article <3976B061.617CACB0 at structurex.net>, > walter hanagriff wrote: > >One answer: > > You *are* using Tkinter variables, aren't you? That's a hard thing to get used to. The Scheme/Tk system I was used to allowed Scheme variables to be used directly by Tk widgets. I presume that allowing Python variables to be used would involve too much hacking on Tk. [Same reason Tkinter actually uses Tcl and Tk rather than just Tk.] -- Grant Edwards grante Yow! ... The waitress's at UNIFORM sheds TARTAR SAUCE visi.com like an 8" by 10" GLOSSY... From cg at schlund.de Wed Jul 19 11:17:06 2000 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 19 Jul 2000 17:17:06 +0200 Subject: treeftp -- a smart ftp client References: <3974D7F0.89207A68@pacific.jpl.nasa.gov> Message-ID: <3975C672.BFE14AC2@schlund.de> Benyang Tang wrote: > > treeftp -- a smart ftp client for Unix. You forgot a comma between 'a' and 'b' in the source of treeftp: hostList = { 'a': ('host_a.edu', 'myUserID_a', 'cat passFile_a', '') 'b': ('host_b.edu', 'myUserID_b', 'echo', '-a -t') } Carsten. From chris_barker at my-deja.com Tue Jul 18 15:48:20 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Tue, 18 Jul 2000 19:48:20 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f References: <3bRZA8$jD_@openbazaar.net> Message-ID: <8l2c9t$823$1@nnrp1.deja.com> I have also been reading this thread with great interest, and I feel the need to add a few of my commnets (isn't that what usenet is about?). One of the thoughts I've had is that there has been a lot of talk about "linear algebra", but, in fact, I think what most of us that want any of this want is not really linear algebra, but array (or matrix, or list or whatever) oriented syntax. I have found that people who have not used such a thing find it hard to understand what the point is, but once you get used to it, It becomes alomost indispensable, both for clear, easy-to-read-and-write code, and for performance in an interpreted language. I spent quite a few years in grad school doing computational programming in Matlab. I hardly EVER used linear algebra. Mostly what I used was element-wise operations. Because of this, I was ecstatic to find that NumPy provided element-wise operations as the default behaviour (A*B), rather than Matlab's default to a matrix multiply. It also provides array broadcasting, rather than having to do Matlab's "meshgrid" trick. The other thing I've found is that I am very frustrated by not having those kinds of elementwise operations available for other Python types. It's fine and dandy to use NumPy arrays for numerical stuff, but when I need to interact with other Python services, I spend a lot of time translating back and forth. Having NumPy be more native would be great, as well has having NumPy type functionality in other Python types. Having to write a lot of for loops and use map a lot, when it seems so superfluous (and slow). So, in summary: I'd like to see: -NumPy become part of core Python -Element-wise operations become part of Python -Perhaps a little nicer way to do linear algebra, but IMHO, having that as part of native syntax falls into the realm of "special functionality" I also have a few comments on stuff others have written (mostly unattributed, sorry there were soo many posts to look at) In article <3bRZA8$jD_ at openbazaar.net>, > Personally, I find that the matrix-orientation of Matlab makes it > harder to get things done. I more often have 3 or higher dimensional > arrays than I have plain old 2D matrices, so I'd rather see the more > general Numeric Python syntax than any over-specialized matrix code. YES! it's not the array orientation that's the problem, it's the Linear algebra orientation. If we stick with N-d array orientation, we'll have a widely usefull tool. (NOTE: Matlab is not the only commonly used language with this kind of feature. FORTRAN 90 has it too.) >Python could become the primary open source alternative to Matlab in time > if a few changes were made: Incorporate numpy into the core distribution (or > release a distribution with it already embedded), simplify the syntax for > matrix operations, and improve the help facility at the interpreter. And a good, native, platform independent, graphing package. (note: Graphite is headed this way, but I don't know how fast) >And you get the advantage that you can use the same syntax Matlab uses. This is NOT an advantage. If I wanted MATLAB syntax, I'd use MATLAB or maybe Octave or Scilab) Let's not make the same mistakes Matlab made. It started as a linear algebra tool (MATrix LABratory), and has evolved into a general purpose number-crunching tool (it's still suffers form that LA heritage, and it is by no means a general purpose programming language). I'd like to see Python remain the general purpose tool it is, with some added number crunching capability, but not focused in Linear Algebra. I'm going to go check out MatPy now. -chris Sent via Deja.com http://www.deja.com/ Before you buy. From olivierS.dagenaisP at canadaA.comM Sat Jul 15 00:45:47 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 15 Jul 2000 04:45:47 GMT Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> As a VB freak (or ex-thereof), I need to point out that the VB IDE will attempt to make all variables and keywords use the same case. So, for example, "if" is always 'converted' as "If" and if you declare a variable as such: Dim m_Spam As Long (which, BTW, the IDE would have 'fixed' the words 'Dim', 'As' and 'Long') and then you need to refer to m_Spam, you can type it without any capitals, and when you move the cursor to another line, the IDE will look up the declaration and match the case of the new instance of the variable with that of the declaration... For example, I type: m_spam = M_SPAM + 42 and it becomes: m_Spam = m_Spam + 42 ...which keeps the readability. (doesn't it?) Also, now that I have this line of code, if I go back to the declaration and change 'm_Spam' to 'm_SpAm', all the references 'm_Spam' will now read 'm_SpAm'... So, I can't say that I agree with you when you say that forcing the user to type the name correctly will improve readability, especially in the case of Pyton when a mis-typed variable name results in a new binding being created, and not a compile-time error, like in C. I once read an "article" (more like a joke) on how to write really bad (obfuscated) C code, and one of the "tips" was to mix the cases of the letters making up variable names.... If you have a pre-processor or a powerful IDE (more like a compiler built into an IDE), you can achieve readability that is customized to the person reading and making a change in the "readability" of a name does not require doing a [case-sensitive] find/replace. Let the user have only to remember the sequence of characters and let the computer find out (in a previous declaration or usage) how they should be capitalized. I love Python. I hope case sensitivity doesn't stay around for too long. All it *really* allows you to have is something like a previous post, where a file requires a close method with a small C and for a DB connection, a close method with a capital C: aFile.close() aConnection.Close() ...which just seems pretty silly to me, especially if you're someone trying to use code from two different sources, and they have adopt similar conventions, except the case is different. People just don't think like computers: 'a' and 'A' are the same letter, and you bring up a good example in your last paragaph... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Anders Eggers-Krag" wrote in message news:jbPb5.1245$bb.28195 at news101.telia.com... > I would say that it improves syntax consequense, leading to more readable > code > for others, you are never in doubt about what to look for when looking for a > keyword, > > in VB you might look for IF, If or if, and they look very different, and it > becomes a lot harder > to read somebody elses code. > > the case insensitivity is nice when I am the only one to read my code as I > could then choose my > own obscure notation such as mYmetOd() and keep it consequent writing dEf, > claSs, If eTc. > wheras case sensitivity makes it more natural to keep a more sensitive > manner such as myMethod() > MyMethod() or my_method() throughout that everyone can agree on, I believe > that case sensitivity > leads to more uniform code, that again makes it easier to read your > collegues code. And i think it should > seem natural to everyone, after all books are written in case sensitive... > you can't write: "i Am the wisEst > One of aLl." and be taken seriously > > But it depends on which kind of access is needed to the system ie it would > be dreadfull if DNS > or SMTP servers were case sensitive and user enters MicroSoft.com and gets > nowhere because > he should have written microsoft.com. > > > -- > Anders Eggers - Krag > > > "Peter Timaratz" wrote in message > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > I can't think of any advantages to a case sensitive language. Python is a > > very well-designed language though, so I imagine there is a good reason > that > > it is case sensitive. So what are the advantages of a case sensitive > > language? > > > > > > From herzog at online.de Wed Jul 12 19:02:15 2000 From: herzog at online.de (Bernhard Herzog) Date: 13 Jul 2000 01:02:15 +0200 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <396CB0D3.8F7BC8E5@prescod.net> Message-ID: hzhu at knowledgetrack.com (Huaiyu Zhu) writes: > I also find I need to do this a lot of time. For example, when you read > something from a file, you want to return an object of a specific class > based on the content. The easiest way to do it appears to be > > class General: > __init__(self, data): > self.data = data > if data is something: > self.__class__ = Special1 > else: > self.__class__ = Special2 > > class Special1(General): pass > > class Special2(General): pass In this case I think a factory function would be much cleaner: def instantiate(data): if data is something: return Special1(data) else: return Special2(data) Putting knowledge about what derived classes exist into the base class is the wrong approach, IMO. You obviously have to have knowledge about the derived classes somewhere in the code, and the right place for that is a factory function or something similar outside of the class hierarchy. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From davec999 at my-deja.com Mon Jul 3 04:23:03 2000 From: davec999 at my-deja.com (David Currie) Date: Mon, 03 Jul 2000 08:23:03 GMT Subject: command-line history in win References: <395c304e.1224185@news.student.lu.se> <8jhm03$qnm$1@nnrp1.deja.com> <8jig08$dk7$1@nnrp1.deja.com> <8F63D360Egmcmhypernetcom@199.171.54.154> Message-ID: <8jpigs$4k9$1@nnrp1.deja.com> In article <8F63D360Egmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > david_ullrich at my-deja.com wrote: > > > David Currie wrote: > > >> It works for me (Python 1.5.2)... > > > Keen. Maybe I'm the only one who doesn't know: > >_What_ works for you, exactly? > > Perhaps David is on NT, where it just works (not only for DOS cmds, but if > you start Python, up-arrow will take you thru the history for your last > Python session in that DOS box). This is all built in to NT. That is correct, I am on NT. I hadn't realised it might be different for win9x... Dave Sent via Deja.com http://www.deja.com/ Before you buy. From oivvioREMOVETHIS at cajal.mbb.ki.se Wed Jul 19 09:28:43 2000 From: oivvioREMOVETHIS at cajal.mbb.ki.se (Oivvio Polite) Date: Wed, 19 Jul 2000 15:28:43 +0200 Subject: a more comprehensive distribution? Message-ID: <8l4act$loo$1@news.kth.se> I've been working with python for a couple of months now. My only real annoyce is the constant need to locate and install python modules. I'd like to get my hands on a distribution that includes a lot more then the standard library, somthing that comes with Numpy, ScientificPython, mxODBC, mxDateTime, a lot of other stuff I don't know about yet. Anyone seen anything like that? Anyone who knows what ActivePython will include? oivvio From olivierS.dagenaisP at canadaA.comM Fri Jul 7 14:24:49 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 07 Jul 2000 18:24:49 GMT Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> Message-ID: I think the map function was designed for something like this.. (???) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Danny Yee" wrote in message news:8k4r6p$p1v$1 at thrud.anatomy.usyd.edu.au... > I need to convert text with ISO Latin characters to HTML, e.g. > I want to map ? to é and so forth. > > I can do this by reading in a wopping big file > ('?', 'À'), > ('?', 'Á'), > ('?', 'Â'), > ('?', 'Ã'), > . > . > > and then going > for pair in fix_list: > line = re.sub(pair[0], pair[1], line) > as I read each line... but there has to be something quicker than that, > surely. Is there a fast way to do this? > > Danny. > > > From paul at prescod.net Fri Jul 14 12:48:51 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 11:48:51 -0500 Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> Message-ID: <396F4473.35DCA488@prescod.net> > I like the language... but one reason why I'm looking at something > -other- than Java is that I am kinda needing an .exe -type > capability... Either Python or Java code can be distributed as an executable. The executable bundles the interpreter into it. For Python, you want to look at http://starship.python.net/crew/gmcm/distribute.html For Java, at "jexegen.exe". -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From paul at prescod.net Thu Jul 13 06:50:29 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 13 Jul 2000 05:50:29 -0500 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <396CB0D3.8F7BC8E5@prescod.net> Message-ID: <396D9EF5.D4B0EE10@prescod.net> Huaiyu Zhu wrote: > > ... > > I also find I need to do this a lot of time. For example, when you read > something from a file, you want to return an object of a specific class > based on the content. The easiest way to do it appears to be > > class General: > __init__(self, data): > self.data = data > if data is something: > self.__class__ = Special1 > else: > self.__class__ = Special2 > > class Special1(General): pass > > class Special2(General): pass YOur code would work just as well if Special1 and Special2 were not related to General. In fact, it would work if you separated out that init function into something that reads the data and creates an appropriate class instance based on the data. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html From thomas at xs4all.net Fri Jul 7 18:20:24 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 8 Jul 2000 00:20:24 +0200 Subject: Splitting c.l.py... In-Reply-To: <8k579c$rts$1@slb3.atl.mindspring.net>; from aahz@netcom.com on Fri, Jul 07, 2000 at 06:24:44PM +0000 References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> <20000707140442.B4771@kronos.cnri.reston.va.us> <8k579c$rts$1@slb3.atl.mindspring.net> Message-ID: <20000708002024.K26534@xs4all.nl> On Fri, Jul 07, 2000 at 06:24:44PM +0000, Aahz Maruch wrote: > In article <20000707140442.B4771 at kronos.cnri.reston.va.us>, > Andrew Kuchling wrote: [ gateway python-dev to a moderated newsgroup ] > >Would that be possible? Is there a Usenet precedent for this sort of > >setup? > It's certainly possible. I'm not sure whether there's precedent for > this specific setup. I can probably say that there'd be a fair amount > of pushback from news.groupies, including me, unless you can clearly > articulate why such a newsgroup would be useful. > Note that it should be simple to set up public read-only subscriptions > to python-dev; if it isn't simple, that's a bug in Mailman. ;-) Actually, I thought a little about this last week. I got tired of reading python-dev through the archive, and then the archive went *kaboom* :-) However, giving read-only subscriptions to python-dev is a very silly thing: python-dev is currently *write* only. There is no real limitation on who can post. So it's either a choice of making it read-only (aka moderated) with the current subscription list as allowable posters, or making it a completely open list, where people 'promise' not to 'interfere'. I hope we can all agree #2 will not work ;) and I'm not sure about #1. I'm not for or against any list-setup, and I'm not elite enough to be able to give my vote on any of it anyway ;) but I'm just pointing out why it's the way it is and not the way most people would want it ;) And-if-Mailman-doesn't-have-it-it-will-tomorrow-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From hzhu at localhost.localdomain Tue Jul 11 14:26:27 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 11 Jul 2000 18:26:27 GMT Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> <8kdref$j4t$1@nnrp1.deja.com> <396AAE98.F851708B@alcyone.com> Message-ID: On Mon, 10 Jul 2000 22:20:24 -0700, Erik Max Francis wrote: >shindich at my-deja.com wrote: > >> It seems to me that there is no need to have this map at all. > >It actually is necessary for my purposes, since the strings that is used >for dispatching will not be a status code (a three digit number as a >string), not actually the name of the method to be invoked. (I simply >showed it that way for the purposes of the sample code; certainly in the >example I showed you are correct.) > In this case you can still have the map, but it maps to strings instead of methods, and use getattr to get the actual methods. No circular reference. #!/usr/bin/env python class C: def __init__(self): print "in constructor" self.map = {'111': 'f', '222': 'g'} def __del__(self): print "in destructor" def f(self): print "in C.f" def g(self): print "in C.g" def dispatch(self, name): methodname = self.map[name] func = getattr (self, methodname) apply (func, []) c = C() c.dispatch('111') From morganea at bellatlantic.net Thu Jul 6 13:44:20 2000 From: morganea at bellatlantic.net (Michel Orengo) Date: Thu, 06 Jul 2000 17:44:20 GMT Subject: [ANN]pre-release DBAPI2.0 for ADO References: Message-ID: DBAPI provides a common interface (so does ODBC or ADO), but you still have to deal with SQL (to process your commands). Just assigning a cursor will not do the trick. Moreover a cusor is linked to a perticular connection (~database) You may want to look at modules that define layers on top of the DBAPI such as Dtuple, SQLDict, or db-obj. Michel "Olivier Dagenais" wrote in message news:PxL85.40906$W35.880547 at news20.bellglobal.com... > Hey, this announcement made me think of a question concerning databases: is > the DBAPI designed for exchanging recordsets between databases opened by two > different implementations? > > For example, could I take your ADO cursor and assign it to a database opened > with, say, Gadfly? (supposing they had the same table definitions) > > Thanks! > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > > "Michel Orengo" wrote in message > news:B5L85.2924$EV6.75523 at typhoon1.ba-dsg.net... > > Hi all, > > I enclosed a very preliminary version of the DBAPI 2.0 for ADO (Microsoft > > Active X Data Object) - ADODBpy. It is built on top of another module > called > > ADOpy which give a more "pythonic" interface to ADO (I've posted this > module > > few days ago) > > > > ADODBpy is still largely incomplete (does not deal with exceptions for > > instance). It is released to get a feedback from the python community. > > > > Some examples to get you started: > > > > import ADODBpy > > > > db = ADODBpy.connect('MyDB', 'MyUser', 'MyPassword') > > cur = db.cursor() > > cur.execute('select * from mytable') > > tup = cur.fetchone() > > > > #now because it is build on top of ADOpy, we can access also the > > properties/methods of the > > #underlying ADOobject > > print db.provider > > print cur.fields.Item('col').Value > > # or better: > > print cur['col'] > > > > Hope this help. > > Cheers, > > Michel > > > > > > > > From ralph at inputplus.demon.co.uk Mon Jul 31 17:56:27 2000 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 31 Jul 2000 22:56:27 +0100 Subject: Python in politics (sssssssssnake!) References: <398524B5.A608BFF1@philips.com> Message-ID: <8m4smb$l9o$1@inputplus.demon.co.uk> Hi Guido, > > Maybe we should send Addo Stuur a few Python books :-) > > Not a bad idea! I'd be happy to do this, if Addo could be > interested. Do you think that Addo can program in any language? Or > is he just a computer *user*? Can you get me in touch with him? > (Nederlands is OK!) Do you know of http://www.addostuur.com/? Ralph. From fiona at sitegnome.com Mon Jul 10 03:26:48 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Mon, 10 Jul 2000 17:26:48 +1000 Subject: Python article in webreview.com Message-ID: <39697AB8.2EDBA42B@sitegnome.com> I stumbled across this article today and didn't see it mentioned in the newsgroup, thought people might be interested to check it out. "Five Minutes to a Python CGI" - http://webreview.com/pub/2000/07/07/feature/index02.html?wwwrrr_20000707.txt From thomas at cintra.no Thu Jul 20 02:31:19 2000 From: thomas at cintra.no (Thomas Weholt) Date: Thu, 20 Jul 2000 06:31:19 GMT Subject: CDDB References: <3976402D.9B957E2F@uniserve.com> Message-ID: <39769c93.3100948@news.online.no> I believe it`s allready been done. Look at www.vex.net/parnassus for cddb. OR ??? Thomas On Wed, 19 Jul 2000 16:56:29 -0700, Bob van der Poel wrote: > >Has anyone converted the cddb code which calulates the cddb id and track >timing for a cd from C to python? Looks like it should be possible >without too much work...I was going to try this myself, but figured I'd >ask before I started... > >Thanks. From nowonder at nowonder.de Fri Jul 28 03:50:00 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Fri, 28 Jul 2000 07:50:00 +0000 Subject: getting back None (was: Re: Perl is worse! (was: Python is Wierd!)) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <39813B28.84AC9146@nowonder.de> Steve Lamb wrote: > > If you could get None back (which you can so long as you assigned None to > something else before reassigning it) there can be some practical applications > to that. There is no need to assign None to something before assigning to None. >>> None=1 >>> if None: ... print "hi" ... hi >>> del None >>> if None: ... print "hi" ... >>> del None Traceback (most recent call last): File "", line 1, in ? NameError: None just-delete-it-and-be-happi-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From R.M.Everson at ex.ac.uk Mon Jul 24 08:59:23 2000 From: R.M.Everson at ex.ac.uk (R.M.Everson) Date: 24 Jul 2000 13:59:23 +0100 Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: Neil Hodgson wrote: >> As one of the more reactionary Pythoneers with regard to syntax >> changes and as someone who is unlikely to ever need to use the >> new operators, I say the braced operators are the best. Huaiyu Zhu writes: > I just posted a summary that dismissed this idea before seeing > recent two posts favoring brace based operators. It's becoming > increasingly obvious that most discussants here favor this. Yes, > I agree with all the advantages of this. > Now the questions are: > 1. How do we test reactions from people who do not read this > thread? Anyone volunteer to give a try? > 2. How important does the possible future extension play in this? > What considerations should be put in this? > 3. If there could be future calculus of operators, would we now > favor (*)= > or (*=) for augmented assignment? I've been following this thread for a while. As a Matlab user, I am quite comfortable with the .op notation and could certainly live with the @op variant, although I prefer ~op as being less dense and P***-ish. These have the (distinct) advantage of being quite straight-forward to implement in the very short term. However, I certainly agree with the arguments for (op) except in one respect. As Huaiyu demonstrated in an earlier post, I find that style very difficult to parse visually, particularly anything involving parentheses to group expressions. Easy visual parsing is a prerequisite for this sort of application where there is a good deal of interactive, exploratory development: it's one of the things that makes Python (and Matlab) a pleasure. Most of the confusion arises because () are already over-used (for grouping, forcing precedence, enclosing tuples, enclosing function arguments, and probably more). How about a different pair of delimiter characters to enclose the operator? I would rule out {} and [] as they also have quite specific meanings already. That leaves Two possible objections: 1. Ambiguity with greater/less than. I haven't thought of any situations that couldn't be resolved by a decent parser. 2. It looks a bit like bra and ket, but isn't. I would greatly prefer this syntax to (op). Richard. -- Richard Everson. Department of Computer Science, Exeter University Voice: +44 1392 264065 R.M.Everson at ex.ac.uk Sec: +44 1392 264061 http://www.dcs.ex.ac.uk/academics/reverson Fax: +44 1392 264067 From olivierS.dagenaisP at canadaA.comM Fri Jul 7 19:06:58 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 07 Jul 2000 23:06:58 GMT Subject: Newbie: Development plaform References: <20000707190803.4740.qmail@web210.mail.yahoo.com> Message-ID: I was also looking for something like so, and I decided to go with: GUI: wxPython (wxWindows for Python): http://www.wxpython.org DB: Gadfly http://www.chordate.com/gadfly.html Distribution: Not sure yet, but right now, I think I will leave it up to my users to install Python, wxPython and Gadfly, and then my software which will update itself through the internet. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Demos Economacos" wrote in message news:20000707190803.4740.qmail at web210.mail.yahoo.com... > Hello, > > I am comtemplating development of a system that will > have to run on Linux, Win and Mac. > > My questions are: > What GUI tool and Database (< 100,000 recs) would you > recommend? > How to distribute programs to users (< 100) > > Thanks > > Demos > > > > > __________________________________________________ > Do You Yahoo!? > Send instant messages & get email alerts with Yahoo! Messenger. > http://im.yahoo.com/ > From gmcm at hypernet.com Mon Jul 3 08:34:51 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 12:34:51 GMT Subject: slicing string References: <00Jul3.130616eest.119043@sister.tecnomen.fi> Message-ID: <8F665CDFAgmcmhypernetcom@199.171.54.154> Jarkko Veijalainen wrote: >I'm real newbie with Python. I started learnig Python just last week. I >have a problem slicing a string, imported from file. can anyone help me >with simple solution. Input string follows this pattern: > > attr=value , attr2=value2, attr3= , attr4=value2. > >I have made an Object class, where all attributes are class variables. >How can i slice that sring and store those att=value pairs in my object? First part is easy: import string pairs = string.split(s, ',') for pair in pairs: tokens = string.split(pair, '=') if len(tokens) == 2: key = string.strip(tokens[0]) val = string.strip(tokens[1]) # see below else: # not sure what you want to do here If I take you literally, then I would say: Object.key = val but I suspect you want a line at the top: o = Object() and then o.key = val - Gordon From richard_chamberlain at ntlworld.com Mon Jul 10 18:33:10 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Mon, 10 Jul 2000 23:33:10 +0100 Subject: clipboard References: <8kddiq$8oc$1@nnrp1.deja.com> <8kdeae$9fv$1@nnrp1.deja.com> Message-ID: Hi Keith, content=root.selection_get() Richard Keith Murphy wrote in message news:8kdeae$9fv$1 at nnrp1.deja.com... > In article <8kddiq$8oc$1 at nnrp1.deja.com>, > Keith Murphy wrote: > > how do you read from / write to the system clipboard from Tkinter? > i'm > > on a unix machine, if that matters. Thanks, > > > > -->keith > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > i've found out that... > > >>> root.clipboard_clear() > >>> root.clipboard_append('python rules!') > > > ... places text on the system clipboard, but how do you paste? > thanks... > > -->keith > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From gmcm at hypernet.com Sun Jul 9 22:23:59 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 10 Jul 2000 02:23:59 GMT Subject: Namespace weirdness References: <3968E1B0.B6E6F3E9@yahoo.com> Message-ID: <8F6CECA93gmcmhypernetcom@199.171.54.194> Paul Winkler wrote: >Hi, > >I think this is impossible... but is there a way for an object to >know what its parent namespace is? > >I'm not sure if I phrased that correctly. Here's the simplest code I >can that demonstrates the idea. > >class Food: > def __init__(self, attr1): > self.attr1 = attr1 > class BodyPart: > def do_it(self): > # This next line is a stand-in for what I want... > print my_parent_namespace.attr1 Python doesn't nest class definitions (or function defs) in a way that is particularly interesting. Your code creates a class object which is accsessible as Food.BodyPart, but BodyPart has no idea it was defined inside Food. As far as it's concerned, it is toplevel. But there is absolutely no cannibalism in Python. None at all. >I'm pretty new to OO design in general, so it could be that I'm nuts >and there's no good reason to ever want to do this... OO means different things to different people. Some languages make a big deal out of this kind of thing. Python doesn't. When I say "none at all", I mean, of course, there's only a reasonable level of these kinds of incidents.... -Gordon From bjorn at roguewave.com.bbs Mon Jul 17 15:10:05 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 17 Jul 2000 19:10:05 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRMLU$l9q@openbazaar.net> Huaiyu Zhu wrote: [snip] > As to the claim that additional operators for linear algebra is somehow > comparable to the special syntaxes/quirks of various programming languages, > no real argument has been presented so far. It's more like: If I don't care > and don't use such things, they must belong to a special domain and be > somehow comparable to some other things that I do know and dislike. On the contrary. The argument is something like the following: - Python is a general purpose language, and as such it can't support special case syntax for Matrix/cgi/xml/db programming. (special syntax has previously been requested for both cgi and db programming). - The proposal is to add a handful of operators that would only have meaning in this one domain. - the criteria for addition to the core is something that is generally useful for a large segment of the community. (and it's your job to convince us of it, not ours to convince you that it isn't -- many more people would like to see Stackless in the core, but that's not going to happen anytime soon either...) - that many problems can be reduced to matrix operations is a non-argument, since the same is true of functional/ procedural/oo/predicate programming. - There are allready ways of performing the required tasks in Python, so there is no absolute need to add this to the core. - Other straight forward solutions has been proposed including list comprehensions and Moshe Zadka's elementwise class approach. > On the other hand, alternative arguments based on analysis of functionality, > overall design, history of evolution and possible future extension, etc, > would carry some real persuasive weight. If you really want to convince people, I would like to see examples of how adding these operators would make working in other domains easier (directly, not through translation through linear algebra). -- bjorn From weeks at golden.dtc.hp.com Mon Jul 31 21:47:16 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 1 Aug 2000 01:47:16 GMT Subject: experts disagree on "call-by-reference" References: <8m29o0$p9g$2@news.dtc.hp.com> Message-ID: <8m5a74$gp1$1@news.dtc.hp.com> Paul Foley (see at below) wrote: : Greg Weeks has consistently failed to understand that the meaning he : wants to apply to the terms "call by value" and "call by reference" : seems to be somewhat at odds with what everyone else means by those : terms; I'm sure the authors he quoted wouldn't actually disagree at : all if you asked them (i.e., I'm quite confident that each and every : one of them understands what's actually going on) Of course. We *all* know how the various programming languages behave. (Well, most of us anyway.) My main point was that what some people call one thing (eg, "call by reference") is called by others something else (eg, "call by reference"). : Yes, exactly. "Pass by whatever" has never really applied to : Lisp-like call semantics, Greg Weeks' protestations about "the old way : of speaking" notwithstanding. Again, these are words that you like to use. Winston and Sussman like different words (eg, that Lisp is call by value). Are you saying that they are flat-out wrong to use those words? Greg From chris_barker at my-deja.com Tue Jul 18 15:59:02 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Tue, 18 Jul 2000 19:59:02 GMT Subject: In-memory file class? Message-ID: <8l2ctp$8i3$1@nnrp1.deja.com> IO'm looking for an in-memory file-like class. What I need is to create something that I can write to and read firom, with the same methods as a file, but that stays in memory. I would like to be able to pass one of these to functions that expect a file object. At the moment, I need it so that I can create data file that I can put on an ftp server with ftplib, but ftp lib expects a file object, and I don't want to have to create a file on disk, just so that I can copy it to the ftp site and destroy it. For this purpose, all I need is a readline() method, which I can impliment pretty easily. I was doing just that, when I realised that this was a handy enough thing that someone has probably allready done it. thanks, -Chris cbarker at jps.net Sent via Deja.com http://www.deja.com/ Before you buy. From tim.hochberg at ieee.org Mon Jul 17 16:46:42 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Mon, 17 Jul 2000 20:46:42 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> Message-ID: "Kevin Jacobs" wrote in message [SNIP] > Silly idea 1: > > Until add-on Python grammar modules are available, what about a PyAlgebra > evaluator module. For a precedent, see regular expressions. The > difference is that linear-algebra syntax can be made too Python-like for > some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() > > Admittedly, its not perfect, nor optimally compact, but it is no longer > encumbered by having to support the full Python grammar and is free to > redefine as much as necessary. Interestingly, an idea very similar to this was floated in the NumPy community a couple years ago, but for entirely different reasons. The motivation for this at the time was in order to support more efficient matrix operations (eliminating intermediate results and such) and possibly compiling the expression to native code. Digging through some of the NumPy archives would probably reveal some interesting discussion of this possibly not so silly idea. -tim From aahz at netcom.com Tue Jul 18 16:56:23 2000 From: aahz at netcom.com (Aahz Maruch) Date: 18 Jul 2000 20:56:23 GMT Subject: Duplicates again References: <397458FF.E5E88361@VerizonWireless.com> Message-ID: <8l2g9n$f97$1@slb7.atl.mindspring.net> In article <397458FF.E5E88361 at VerizonWireless.com>, Bill Scherer wrote: > >It's happening again, duplicates by the dozen. There's a misconfigured news server somewhere. Given that I'm only having this problem on c.l.py, I'm pretty sure the problem is somebody's home box set up to archive c.l.py or something. IIRC, the problem last time was that the Message-ID had its case changed, so it was no longer unique for properly configured news servers. I didn't bother checking this time to find out. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From bjorn at roguewave.com Wed Jul 19 13:12:32 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 19 Jul 2000 11:12:32 -0600 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> Message-ID: <3975E180.1AFD30D@roguewave.com> Vladimir Marangozov wrote: [snip] > The reverse wasn't true and the python-dev summary documents are intended > to inform a broader audience, notably the Python community, on its > current activities. The natural place for discussing all topics brought > on python-dev is the comp.lang.python newsgroup. This is also the place > where the python-dev members are looking for feedback. For instance, > read the PEP documents -- they summarize recent and past proposals for > various enhancements. All python-dev members are interested in seeing > them discussed by the community. So don't hesitate to take a stance on > a PEP if you think that you could share an educated opinion. I think the PEPs are a great idea, but it would be even better if they were more accessible... How about putting them up on the beopen or python.org site? (That way the faq can refer to them for recurring discussions with all the arguments archived in the PEP...) -- bjorn From aahz at netcom.com Thu Jul 13 10:27:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 13 Jul 2000 14:27:26 GMT Subject: OSCON help? (Second try) Message-ID: <8kkjke$l59$1@slb6.atl.mindspring.net> I'm giving a presentation at OSCON next week on threads in Python. The presentation is Thursday, 7/20, at 3:30. I'm hearing-impaired, so I'd like some help transcribing questions from the audience. Emile van Sebille has already kindly offered to help, but I'd like at least one more volunteer as backup. Any takers? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From no at bo.dy Mon Jul 24 08:39:22 2000 From: no at bo.dy (nobody) Date: Mon, 24 Jul 2000 07:39:22 -0500 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: <2OVe5.11$o45.2121@news.corecomm.net> cjc26 at nospam.cornell.edu (Cliff Crawford), in : > Oh, right..I should've explained it better :) A compiled regexp is an > object which has match() and search() methods, so instead of > match=re.match(reg_c, test) > you want to do > match=reg_c.match(test) oy. i knew i was stupid, but now i know just *how* stupid. thanks, i guess. X-) > Also, in your example you'd probably want to use search() rather than > match(), which only succeeds if the regexp matches the beginning of the > string (i.e. it acts as if there is an implicit '^' at the beginning of > the regexp). hm. any difference in performance, or can i just as well make the caret explicit and standardize myself on match? From tim_one at email.msn.com Thu Jul 27 15:45:47 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 27 Jul 2000 15:45:47 -0400 Subject: [Python-Dev] PEP 201, zip() builtin In-Reply-To: <14720.35958.632383.574511@anthem.concentric.net> Message-ID: [Barry A. Warsaw] > -------------------- snip snip -------------------- > PEP: 201 > Title: Parallel Iteration Could we please change "Parallel" to, e.g., "Lockstep" throughout? Greg Wilson correctly pointed out that "parallel" in the context of loops means something very different to the scientific branch of the Python community. Easier to fix this now that after it's spread to the docs. > ... > However, for-loops iterate over only a single sequence, and it > is often desirable to loop over more than one sequence, in a > lock-step, "Chinese Menu" type of way. Just as you realized how inappropriate "parallel" was right here . > # find the length of the shortest sequence > shortest = min(*map(len, args)) Clearer as > shortest = min(map(len, args)) However, this implies that all sequences must tell the truth about their lengths, but the iteration protocol actually terminates via a sequence raising IndexError. I believe we want zip to follow the iteration protocol, in effect breaking out of the outer loop as soon as some s[i] raises IndexError. This was agreed to by all (incl. the BDFL) in some other year's debates over this. > prefers zip() due to it's Haskell[2] heritage. See version 1.7 "its", not "it's" > - Lazy evaluation. An earlier version of this PEP proposed that > zip() return a built-in object that performed lazy evaluation > using __getitem__() protocol. This has been strongly rejected > by the BDFL in favor of returning a real Python list. If lazy > evaluation is desired in the future, the BDFL suggests an xzip() > function be added. Which he'll then fight tooth and nail . > ... Nice job, Barry! Thank you. From Richard.Jones at fulcrum.com.au Thu Jul 27 23:35:47 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 28 Jul 2000 13:35:47 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from Steve Lamb of 2000-Jul-28 2:56:21, Message-ID: <200007280335.NAA30931@envy.fulcrum.com.au> [Steve Lamb] > On Fri, 28 Jul 2000 11:17:31 +1000, Anthony Baxter > wrote: > >Euw! No, the "oh, I know what you want that to be, I'll change it for you" i > s > >my #1 all-time perl hate. > > Why? Has it ever messed up? It does exactly what you tell it to unlike > the babysitting languages that barf with "Oh, you don't know what you're doin > g > so I won't let you do it." > > Before you answer know the difference between it messing up and /you/, as > the programmer, messing up. > > [snip] > > >Particularly when combined with magic linenoise - use the wrong bit of > >linenoise, and suddenly your large complex datastructure is an int. Yaaay. > > The above example applies here. Once you know what is going on it is all > fairly straight forward. BTW, your large, complex datastructure isn't an int > . > There is no int unless you use int(), just like in Python, or try to stuff it > into someplace that expects something that could be called an int, in which > case it is your fault as a programmer, not the languages, and has nothing to > do with the symbols. Uh, no, your large complex data structure can easily converted into an int (or just the last element in the structure if the situation is slightly different) if it's referred to in a scalar context accidentally (in some cases by getting the line-noise wrong). Yes, that would be the programmer's fault - but the point here is that Perl's an overly complex language that allows too much freedom to fuck up a complex program dealing with complex data structures. Programming is about being explicit in telling the computer what you want it to do. When a subtle variation in your code radically changes the outcome, that's annoying as hell to a programmer. And the problem being identified here is that Perl has hundreds of these subtle variations built in that radically change the outcome of a program - not to mention not being obvious in some cases like: $a = \($x, $y, $z); ... you'd think that was equivalent to: @a = ($x, $y, $z); $a = \@a; .... or, $a = [$x, $y, $z]; ... but it isn't, it's really: $a = (\$x, \$y, \$z); ... which is _of course_ equivalent to: $a = \$z; ... and the killer being that it's different to: @a = \($x, $y, $z); $a = scalar(@a); ... as one would perhaps expect (yes, scalar behaves differently in different contexts!). Yeah, that's a good language at work there. I've now got 2 years of experience in developing Perl _applications_ using complex Object Oriented (hah! OO! hah!) data structures. I'm leaving this job now in frustration and working in a Python development house. The killer is that I'm interviewing a lot of programmers trying to hire a new Perl application developer - and I'm rapidly forming the opinion that they're a very very rare breed (if they exist at all). That is, people who say they can write Perl applications and can actually understand some of the issues in manipulating complex data structures in Perl and not just writing 100-500 line CGI scripts. That's not application writing kiddies, that's just hacking shit together and calling it a program. And code re-use isn't just copying the first fucking half of the script to the next one you write. I honestly believe that Perl is creating a very dangerous breed of undisciplined programmers, and I'm worried. And Perl OO. Hah! There's maybe ... what, 0.000001% of the total Perl population who have ever written a class package? And maybe 0.01% of them who can do anything beyond bless $data, $class; where $class only has functions? That is, they've read Conway's book and knew more than a tenth of it before reading it? Richard From olivierS.dagenaisP at canadaA.comM Tue Jul 4 22:52:39 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 02:52:39 GMT Subject: Q: Client-server architecture Message-ID: What modules [or references] are there that explain or implement simultaneous, __secure__ operations on a server? I looked through http://www.python.org/topics/web/ and it seems to only cover HTTP, not HTTPS (using SSL or some other, secure protocol). I want to implement seemingly concurrent, remote database access and if I can queue the requests to the server, the server could then process requests, one at a time, and then "call back" each client with the results. I'm thinking I don't want to write the server side software using a CGI script, since the database package I'm looking into using (Gadfly) isn't designed for concurrent access, unless I don't understand how CGI works and it is synchronous? (I have only written very simple CGI scripts in Perl and C, so I'm sort of new to this) Any help (including corrections in my thinking of CGI or hints on handling many, simultaneous requests) would be appreciated. I'd like to write both the client and the server in Python. Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From m.faassen at vet.uu.nl Sat Jul 29 11:51:51 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 15:51:51 GMT Subject: Python 3000 ? References: <8lttuq$9c8$1@serv1.albacom.net> <8luraf$e2p$1@slb1.atl.mindspring.net> Message-ID: <8luuin$ags$4@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <8lttuq$9c8$1 at serv1.albacom.net>, > Patrick Fichou wrote: >> >>What is(will be) Python 3000 ? > Standard answer: [snip standard answer] It's amazing how often this question is asked. What is causing all these people to ask this question? Some web page being extremely mysterious about Python 3000 somewhere? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From moshez at math.huji.ac.il Thu Jul 20 15:18:26 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 20 Jul 2000 22:18:26 +0300 (IDT) Subject: FAQ maintenance with Python ... In-Reply-To: Message-ID: On Thu, 20 Jul 2000, Scott Witherell wrote: > I'm setting up a web FAQ for my research lab and wanted to use Python. I > quickly found the FaqWiz and used that (with a couple minor modifcations). > And it's great - except that it seems quite difficult to reorder the FAQ > entries after they've been entered. Everybody in the lab is just gonna > throw stuff on this FAQ and I'm sure that a month or two down the road > we'll have a much better idea of how we would like the FAQ organized. So > it seems likely that I'll want to do some fairly drastic reordering (both > within category and across). I'm sorry to throw my newly found religious beliefs at you, but well, you asked for it. WikiWikiWeb (http://c2.com/wiki) is the answer to all your troubles. I mean it. Try it and enjoy. If you have a Zope server anyway, use Zwiki, otherwise use any of the Python over RCS wikis (there are loads of links from http://c2.com/wiki?WikiWikiClones) I'm using a modified version of PikiPiki which, among other things, works over RCS, so you can do a manual undo. I'm not near it right now, but it is really clean code, so you should have no troubles changing this. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From tgdeveloper at my-deja.com Fri Jul 14 12:33:29 2000 From: tgdeveloper at my-deja.com (tgdeveloper at my-deja.com) Date: Fri, 14 Jul 2000 16:33:29 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> Message-ID: <8knfco$jsq$1@nnrp1.deja.com> For me the top language constructs, in terms of being useful in daily work are: 1. dictionaries 2. lists / tuples 3. for item in list: 4. "blah blah %s blah %d blah" % (word, number) 5. exception handling (try/except/raise etc.) 6. the fact that data types can be nested (e.g. a dictionary whose key is a string and whose value is another dictionary, etc.) 7. The "traceback" behavior for reporting errors. This makes debugging easy. Sent via Deja.com http://www.deja.com/ Before you buy. From jwbnews at scandaroon.com Mon Jul 24 21:24:56 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 24 Jul 2000 18:24:56 -0700 Subject: IEEE 754 References: <8lifaa$1bb$1@agate.berkeley.edu> <8liiba$1mh$1@agate.berkeley.edu> Message-ID: In article , wtanksley at bigfoot.com wrote: > > - You mean I may someday be able to put aside my answers to the "why > > - doesn't 2/10 print as 0.2 as we all know it should?" sorts of > > questions? > > I'm not sure whether you mean that 2/10.0 isn't exactly 0.2, or whether > 2/10 is 0. Sorry, I meant the former, but of course forgot to say 2.0/10 or 2/10.0 (as I've been known to do in real code). --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From theebh at yahoo.com Mon Jul 17 21:43:21 2000 From: theebh at yahoo.com (Jonathan) Date: Tue, 18 Jul 2000 01:43:21 GMT Subject: newbie unimpressed... References: <8kvp81$9q1$1@nnrp1.deja.com> Message-ID: <8l0cnm$oeg$1@nnrp1.deja.com> In article <8kvp81$9q1$1 at nnrp1.deja.com>, sharkey3 at my-deja.com wrote: > I have much experience in tcl and perl, and I have finally found a good > project to learn python with. Unfortunately, I am very frustrated so > far with the language. Although maybe it's just with the documentation. > > I'm serious. The documentation really sucks. > Example: where is the % operator documented for strings? > I'm a newbie myself and i happen to come across those formatting operators while reading the "Learning Python" book. Grab a copy of it; though it's not a reference book, at least it gives you an overall idea. regards, Sent via Deja.com http://www.deja.com/ Before you buy. From collins at rushe.aero.org Mon Jul 10 11:59:01 2000 From: collins at rushe.aero.org (JEFFERY COLLINS) Date: Mon, 10 Jul 2000 08:59:01 -0700 Subject: [ANN] Python port to Palm Pilot In-Reply-To: <3966C005.5EF656C6@smartchat.net.au> References: <200007070140.SAA31035@wd264.aero.org> <3966C005.5EF656C6@smartchat.net.au> Message-ID: <200007101546.IAA09887@rushe.aero.org> Download the .zip file instead. Apparently, downloading the .prc files using a browser corrupts the files. Jeff KB Ang writes: > Hi there all, > Just a cautionary note. > I have Palm OS 3.3 running on a Palm V. > I installed pylib and python.prc on it. > > It crashed my Palm ie needed to do a "hard" reset. > A soft one did nothing so suggest that > u back up before trying anything. > > Chai > > > collins at rush.aero.org wrote: > > > > Announcing the alpha port of Python-1.5.2+ to the Palm Pilot, > > available for download after 8AM PDT July7, 2000 at > > http://www.isr.uci.edu/projects/sensos/python/. This release includes > > the modified Python source and tools for creating Palm applications > > from Python modules. As a convenience, we include the gnu toolchain > > required to support the Python distribution on the Palm Pilot. > > We emphasize that this is an alpha release and is deficient in many > > respects. We are releasing it now to stimulate interest in Python on > > small computing platforms. > > > > Enjoy! > > -- > +------- > | mailto:calcium at ozemail.com.au +6141 321 9866 +613 9889 0883 (tel/fax) > | Ob saying - Software is hard - me! > > -- > http://www.python.org/mailman/listinfo/python-list > From scarblac-spamtrap at pino.selwerd.nl Mon Jul 31 10:47:16 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 31 Jul 2000 14:47:16 GMT Subject: variable scope References: <398580A2.9EBD6072@lucent.com> Message-ID: Cris A. Fugate wrote in comp.lang.python: > Hi, Im new to Python and I have a question about variable scope. > > It seems that any variable declared in a function is local. > > Is there any way to define a global variable within a function? > > For example, Tcl can use eval and uplevel to evaluate code > > on any scope level. In Scheme a local variable uses let, > > otherwise it is global. Please turn off sending posts in HTML in your newsreader. It makes your posts look wrong, and far too long. Okay. In Python, if you assign to a variable, it is a local by default. If you only use it "read only", it is assumed to be global. You can declare a variable to be global with the "global" keyword, ie def setx(): global x x = 3 setx() print x (there was a plan for declaring a local variable that's never assigned to, but the discussion got stuck at choosing the name) -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From cmedcoff at sprynet.com Fri Jul 7 08:16:07 2000 From: cmedcoff at sprynet.com (Charles Medcoff) Date: Fri, 7 Jul 2000 08:16:07 -0400 Subject: Win32com curiousity #2: PythonWin code completion References: <8k2q2c$fg2$1@nnrp1.deja.com> <8k3j35$v4c$1@nnrp1.deja.com> Message-ID: <8k4h3f$dq4$1@slb6.atl.mindspring.net> > _After_ running makepy, saving the source, closing PythonWin, reopening > the source in PythonWin, the class browser initially is only aware of > the methods that are used in my source code. After a certain operation > (I think it happens after a save or run), then the class browser > display all available methods. > > I am not sure if this is a PythonWin bug, or my installation or > configuration is damaged. Funny, I observe the exact same thing. As a matter of fact if I mistype or indicate an incorrect property/method in the code somewhere, later the same shows up in the auto-completion list as if it were a member of the object. From jepler.lnk at lnk.ispi.net Sun Jul 16 22:07:01 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Mon, 17 Jul 2000 02:07:01 GMT Subject: string issue or questions about intern References: <396EEAFF.3AD7B951@bioreason.com> <396F87C4.6B3C9FAE@schneider-kamp.de> <396F0DD3.B391503@bioreason.com> <3dk8eol9bk.fsf@kronos.cnri.reston.va.us> Message-ID: <9Ttc5.180$ttZ2.9044288@news.randori.com> On 14 Jul 2000 16:56:47 -0400, Andrew Kuchling wrote: >Brian Kelley writes: >> eval('"AAAAA"') >> eval('"AAAAB"') >> eval ('"AAAAC"') > >This seems a reasonable outcome of the rule that Python always interns >string constants. Every string gets interned, and interned strings >are never freed, so memory is constantly being consumed. > >If you need full Python expressions, there seems no way around using >eval(). But if you simply need string escapes, it's probably worth >writing a parser. (Does such a parser already exist somewhere in the >standard library? Anyone know?) Well, the problem is pickle.Unpickler.load_string(): def load_string(self): self.append(eval(self.readline()[:-1], {'__builtins__': {}})) # Let's be careful dispatch[STRING] = load_string You can see that unpickling lots of unique strings causes Python to use progressively more memory. Jeff From scarblac-spamtrap at pino.selwerd.nl Thu Jul 20 02:46:47 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 20 Jul 2000 06:46:47 GMT Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> <8l5lne$lb$1@slb0.atl.mindspring.net> Message-ID: Aahz Maruch wrote in comp.lang.python: > In article <3976371F.210C2C21 at uab.edu>, Shae Erisson wrote: > > > >I already have a function that does this in my handy shaetools module, > >for me it will always be interleave. > > Oh, *that's* a good one. All right, anyone else agree that "interleave" > is the best suggestion we've had so far? For the function that creates [1,2,3,4,5,6] of [1,3,5] and [2,4,6], yes. But the proposal should construct [(1,2), (3,4), (5,6)], right? -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From edream at tds.net Sun Jul 16 17:40:13 2000 From: edream at tds.net (Edward K. Ream) Date: Sun, 16 Jul 2000 21:40:13 GMT Subject: Can't load .pyd files from embedded Python interp Message-ID: <39722B90.A41E02B5@tds.net> Hi, I'm having difficulty importing modules defined in .pyd files from an embedded Python interpreter. The problem seems to be that two sets of variables are being used and no linking is happening when the DLL is loaded. Perhaps you DLL gurus will spot the problem immediatly. Details follow... I've embedded the Python interpreter in a wxWindows test app using the Borland compiler. The interpreter was embedded in a straightforward way, by creating python15.lib and parserLib.lib from the sources, then linking these libs with no special options into my app. I've also used the python15.lib and parser.lib files from the Windows distribution, with approximately the same results. Because of problems with FILE * params in the C API, it seemed best to build the .lib files using the Borland compiler. The app can execute code such as the following from the wxWindows OnInit code: Py_Initialize(); PyRun_SimpleString("for i in sys.path: print i"); Py_Initialize() exercises lots of code, including all the code I modified for the Borland compiler, so most everything is working. However, I am not able to import files defined in any .pyd file, say like this: Py_Initialize(); PyRun_SimpleString("import parser") ; where parser is contained in parser.pyd. No matter what .pyd file is imported, the code fails by calling Py_FatalError inside the DLL's initialization routine, parser.initparser in this example. What happens is this: 1. The call to PyRun_SimpleString("import parser") eventually results in a call to _PyImport_LoadDynamicModule which loads the DLL called parser.pyd by calling: hDLL = LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); The call succeeds. 2. _PyImport_LoadDynamicModule then calls: p = GetProcAddress(hDLL, funcname); where funcname is "initparser" in this example. This call also succeeds, so p points to the init function for parser module. 3. _PyImport_LoadDynamicModule then calls: (*p)(); This statement calls the init function for the imported .pyd file. 4. The init function appears to be entered correctly and very soon the init function calls Py_FatalError. The reason is clear: the init code is using a separate copy of the variable PyThreadState_Current and that variable is NULL because it has never been initialized. The Borland debugger shows this variable as [python15.PyThreadState_Current] rather than [interp_head+4] for the same variable in the embedded interpreter. So what is happening seems clear: there are two separate variables called PyThreadState_Current, and the call to Py_Initialize() in the embedded interpreter initializes only the interpreter's copy, not the DLL's copy. In my mind there are several possible ways to make the two copies of PyThreadState_Current refer to the same memory. 1. [Unlikely] With some special initialization code before calling (*p)(). This is unlikely for several reasons, of which one is there is no indication anywhere that importing .pyd files should require special code. And changing code in _PyImport_LoadDynamicModule seems out of the question. 2. [Unlikely] Perhaps the call (*p)() is defective. Borland C has several directives for declaring function pointers. The present Borland code declares p with: typedef __cdecl FARPROC dl_funcptr; dl_funcptr p; However, the difference between __cdecl, __pascal and __stdcall should make a diffence only if p has arguments. And the init routine seems to be called properly. 3. [More likely?] We should provide information to LoadLibraryEx so that LoadLibraryEx can fixup references within the DLL to point at the corresponding locations in the embedded interpreter. I've looked in vain for information about how to do this. Is this a matter of using special link options, or of providing tables to LoadLibraryEx? 4. [Less likely?] The Windows 32-bit API docs mention the DllEntryPoint mechanism. I don't see anything in the _PyImport_LoadDynamicModule to indicate that this mechanism is used. Instead, .pyd files seem to be using their own kind of init function. After all this background, can anyone tell me how to load .pyd files from an embedded Python interpreter? Also, can anyone suggest a URL that really explains Windows DLL files? The entries at http://msdn.microsoft.com/library seem less than completely satisfactory. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From mbaker at 0x7a69.net Tue Jul 25 21:50:05 2000 From: mbaker at 0x7a69.net (Mark Baker) Date: Tue, 25 Jul 2000 20:50:05 -0500 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> Message-ID: In article , wtanksle at dolphin.openprojects.net (William Tanksley) wrote: >>Also, how do I print without a new line other than using >>sys.stdout.write? > > Why? Is there something in specific you're trying to avoid? (Yes, it's > possible, but it's not pretty.) print 'bob', That's not "pretty," but it's also not so ugly as to not tell him how to do it. From sean at digitome.com Sun Jul 2 07:55:03 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:55:03 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> Message-ID: <395f27ab.2095753@news.iol.ie> Sheesh! I really need a holiday! Yet another typo fixed. Sorry about this... I have a reproduceable GPF on NT when pickling objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From piet at cs.uu.nl Fri Jul 28 08:11:57 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 28 Jul 2000 14:11:57 +0200 Subject: MySQL, mSQL, or other database References: Message-ID: >>>>> "Adam Durity" (AD) writes: AD> I have a website hosted by a WPP and they will provide me with Access AD> database support for an additional $10 a month. I'm on a fairly tight AD> budget so is there any way i can use MySQL, mSQL, or another database AD> package to handle a smple SQL database without a DSN. BTW, i am a AD> newbie to all this stuff. Thanks in advance, Adam. If your database isn't too heavy, you could use a Python-only solution: Gadfly. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From hschroeder at gmx.net Thu Jul 13 19:10:14 2000 From: hschroeder at gmx.net (Henning Schroeder) Date: Fri, 14 Jul 2000 01:10:14 +0200 Subject: vCard module References: Message-ID: Bobby de Vos wrote: > Does anyone know of a Python module that would allow me to easily > parse and format vCards? The new WorldPilot 1.1alpha contains such a module (file vCard.py) ftp://demo.worldpilot.com/pub wppocket-1.1.0alpha2.tgz (see wppocket-1.1.0alpha2.tgz) If there are any other implementations with a better license please let me know. Henning -- henning.schroeder at informatik.uni-oldenburg.de ich at henning-schroeder.de * http://www.henning-schroeder.de From darrell at dorb.com Thu Jul 20 14:40:34 2000 From: darrell at dorb.com (Darrell Gallion) Date: Thu, 20 Jul 2000 14:40:34 -0400 Subject: Determine path of current module? References: <3976AA30.1C4F62B8@schlund.de> <8l6bis$elb$1@pollux.ip-plus.net> <3976B678.83F01206@schlund.de> Message-ID: <068b01bff279$fdaad860$6401a8c0@home> >>> print sys.modules['stat'] # sys is a builtin >>> sys.__file__ Traceback (innermost last): File "", line 1, in ? AttributeError: __file__ >>> import os >>> os.__file__ 'D:\\Python\\Lib\\os.pyc' >>> --Darrell ----- Original Message ----- From: "Carsten Gaebler" > Well, that's just the filename. What I'm looking for is the complete path, > "d:\tmp\mypath.py" in this case. > From alex at magenta.com Sat Jul 29 06:13:16 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 12:13:16 +0200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> <3981BE50.23DB16C5@infercor.no> <8lsu2a02ho4@news2.newsguy.com> Message-ID: <8luhsl21ce8@news2.newsguy.com> "Grant Edwards" wrote in message news:slrn8o4clt.abr.nobody at isis.visi.com... > In article <8lsu2a02ho4 at news2.newsguy.com>, Alex Martelli wrote: > > >7 bits and up, anything goes. But everything else's size (except > >for bit-fields, a peculiar oddity) is a multiple of char's size, > >so the latter's size is often called a 'byte' (which need not be > >the same thing as an 'octet', though it often is:-). > > And all hell generally breaks loose when it isn't -- especially when two > programs are communicating and they have differing defintions of how many > bits there are in a byte. But that's a whole different rant. That's why protocols are defined in terms of _octets_... If two programs communicate without following a precisely defined protocol, or if one or both implement the protocol incorrectly, then you've got problems -- byte/octet issues being often the least of them. (XML helps. But don't anybody think it's anywhere close to the panacea it's apparently considered to be in some circles; that is just Yet Another recurrence of the never-ending dream for the Magic Bullet:-). Alex From sblakey at freei.net Mon Jul 10 15:35:59 2000 From: sblakey at freei.net (Sean Blakey) Date: Mon, 10 Jul 2000 12:35:59 -0700 Subject: Circular reference problem -- advice? In-Reply-To: <396A1EC6.6738CFCC@alcyone.com>; from max@alcyone.com on Mon, Jul 10, 2000 at 12:06:46PM -0700 References: <396A1EC6.6738CFCC@alcyone.com> Message-ID: <20000710123559.A2218@freei.com> On Mon, Jul 10, 2000 at 12:06:46PM -0700, Erik Max Francis wrote: > I'm fairly new to Python, although it's simple enough that I've already > been able to write some fairly involved programs in it (I already know > C, C++, Perl, etc.). This question isn't so much about what's going > wrong, but rather what's the best, most natural way to get around it. > > I've come across a problem due to circular references, and I'm not sure > what's the best way to tackle it. In essence, the problem is that I > need a particular class to keep an associative array of its methods for > a lookup table (it's essentially a dispatcher). But with references to > its own bound methods, Python's garbage collector concludes it has > circular references and thus its destructor never gets called. > > Here is a simplified standalone program that demonstrates what I'm > talking about: > > class C: > def __init__(self): > print "in constructor" > self.map = { 'f': self.f, 'g': self.g } > > def __del__(self): > print "in destructor" > > def f(self): > print "in C.f" > > def g(self): > print "in C.g" > > def dispatch(self, name): > self.map[name]() > > > c = C() > c.dispatch('f') > > When run, this program prints > > max at charmaine:~/tmp% ./circ.py > in constructor > in C.f > > and that's it; because of the circular reference, the destructor never > gets called. > > For the application I need, it's imperative that the destructor get > called. What is the best way to solve this? I can think of a few: > > - Move the map to a local variable in the dispatching function > - Make map a lookup table of _unbound_ methods > - Build a string of the function call and then exec it > > What would be the most effective way of getting around this? I'm > thinking that using unbound methods would probably be the best way. > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ We'll have to make our own luck from now on. > \__/ Louis Wu > Computer science / http://www.alcyone.com/max/reference/compsci/ > A computer science reference. > -- > http://www.python.org/mailman/listinfo/python-list Is dispatch the only thing you need self.map for? If so, I think the easiest way around this circular reference may be to reimplement dispatch do that self.map is unneeded. For example: def dispatch(self, name): getattr(self, name)() Also, your self.map looks like it duplicates the information in the builtin self.__dict__. Parhaps you could use that instead? def dispatch(self, name): self.__dict__[name]() Either of these solutions will allow you to remove the self.map completely. -Sean -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 "From there to here, from here to there, funny things are everywhere." -- Dr. Seuss From bmcd at es.co.nz Thu Jul 27 18:28:30 2000 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 27 Jul 2000 22:28:30 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <8lq20g$kt1$1@nntp9.atl.mindspring.net> Message-ID: On 27 Jul 2000 19:19:44 GMT, Aahz Maruch wrote: >In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, >Guido van Rossum wrote: >>I've placed the slides of my talk at the O'Reilly Open Source >>Convention on-line at our BeOpen PythonLabs website: >> >> http://www.pythonlabs.com/talks.html > >It appears that the HTML version requires JavaScript. That's a Bad Idea. This is one of the worst pieces of mangled HTML I've seen in some time. And that takes some f***ing doing. What is even worse is that the numbers of the slides are not even in sequence. Some information is recoverable from http://www.pythonlabs.com/talks/PythonState_files/outline.htm but I detest having to hand-interpret JavaScript merely to read a bunch of slides. In fact, I think you can read everything from the link given above. Just ignore the links to the slides. Guido, if you're reading this, I suggest that you turn off JavaScript and check out http://www.pythonlabs.com/talks/PythonState.htm You will be greeted by a blank page. I think we all know precisely which application is responsible for generating this monstrosity. -- Ben Caradoc-Davies From grey at despair.rpglink.com Sat Jul 29 18:54:42 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:54:42 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Sat, 29 Jul 2000 03:30:44 GMT, Ben Wolfson wrote: >Right--it's a sequence, and a single element. >I restated this elsewhere in the thread; what I meant was that any >arbitrary sequence can be viewed as a sequence or single entity, but any >arbitrary single entity cannot necessarily be viewed as a sequence. >I suspect I don't have the right vocabulary to express my thoughts here. Nope, that did it. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From neelk at brick.cswv.com Sun Jul 23 10:14:17 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 23 Jul 2000 14:14:17 GMT Subject: Multimethods References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <8lcnf4$vmr$1@slb0.atl.mindspring.net> <397A91EB.80B74AE9@prescod.net> Message-ID: Paul Prescod wrote: > Neel Krishnaswami wrote: > > > > .... > > > > So multimethods. In ordinary OO programming, you can think of a method > > as a set of functions, and the function body that's chosen is based on > > the runtime type of the first argument. > > You could, but Python exposes so much of the underlying implementation > that this is not a very intuitive way to think about it. In particular, > every instance of a class could have a *unique method* frob simply by > assigning to the frob attribute. I don't understand you here. The way I understand method dispatch in Python to work is as follows. If a name lookup that searches a class finds a function, that function is wrapped in method clothing and returned. Assigning a function to an instance slot will simply put a function in the slot. class Foo: pass x = Foo() Foo.bar = lambda self: "Hello world!" x.baz = lambda self: "Ni!" This gives: >>> x.bar of Foo instance at 80dade0> >>> x.baz at 80db878> > So it isn't clear to me how you extend this into multimethods. [...] > I mean the first step would be to make a form of Python method > invocation that is type-based even for one argument. I agree with this. My multimethod module for Python requires passing a tuple of types (classes or builtin) to the generic function to let it dispatch correctly. This is very inconvenient. Multimethods, in all their glory, will have to wait until after the types-sig figures out what the type system should look like. Neel From thomas at xs4all.net Fri Jul 7 11:34:11 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 7 Jul 2000 17:34:11 +0200 Subject: Python bug reporting [was: Re: readline.c & more] In-Reply-To: ; from pinard@iro.umontreal.ca on Fri, Jul 07, 2000 at 08:20:52AM -0400 References: Message-ID: <20000707173411.I26534@xs4all.nl> On Fri, Jul 07, 2000 at 08:20:52AM -0400, Fran?ois Pinard wrote: > [Jeremy Hylton] > > I agree that the system [of necessarily using the Web to report Python > > bugs, instead of the usual Python bug reporting email address] isn't > > great, but at least it provides us with a mechanism to track patches and > > assign responsibility for them. The old email approach didn't have either > > feature, which made it much harder for the people catching the patches. > There are plenty of users, and a much smaller bunch of maintainers. > It seems more fit to me to adapt to the plenty of users, than force all of > them into the methods of a few. This is not far from haughty maintenance. > Besides, if the new mechanics and bug tracking systems did not even care to > provide some interface or tools, so maintainers can receive and sort email > into it, then that system is also haughty and aggressive at imposing itself. There is a reason the SourceForge Patch Manager was adopted: It works. The patches list didn't. It's irrelevant how easy it is to submit a patch if it is then to be forgotten and never applied ;-P > > You might suggestion an email interface in the SourceForge feature > > request forum: https://sourceforge.net/forum/?group_id=1 > Are you serious? You would force me to use a Web forum to discuss that > Web is inappropriate? This isn't real, I am dreaming. :-( I didn't see Jeremy say anything about the Web being inappriopriate. SourceForge works using a web-interface for a very simple reason: near everyone has a webbrowser (hell, my old Atari ST had one !) and most of them can handle forms and the like. Email might be a lower-tech solution, but it is very hard to do the things SourceForge does in only email. The only other tools available for this sort of thing are a *lot* less common than webbrowsers. Perhaps Guido needs to make a P.O. box so people can send him print-outs of their patches, or disks, for those without email. Given the number of people without email, that might very useful. If you refuse to communicate with SourceForge because you think what they do is dumb, they can't know what they do is dumb, can they ? :P You don't necessarily have to fill in a web-form to suggest an email-interface for submitting patches, though. You can use your webbrowser to look for an email address. In the mean time ;) if you want to submit a patch and can't, discuss it with python-dev at python.org or patches at python.org. patches still used for SourceForge patch notifications, and python-dev is still active in spite of SourceForge ;-) and I'm sure someone on there will volunteer to submit your patch. (Hell, I would, so you can mail me directly, too.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From davec999 at my-deja.com Tue Jul 11 05:37:13 2000 From: davec999 at my-deja.com (David Currie) Date: Tue, 11 Jul 2000 09:37:13 GMT Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: <8keps9$85u$1@nnrp1.deja.com> In article , you wrote: > But seriously (my comments above were in good fun, I assure you, no harm > intended), I read this newsgroup regularly and I never saw mention of the > Language Challenge 2000. Did I miss it? Perhaps the audience determined the > outcome? Even if we had known, the competition not only requires an executable, but also judges entries on the size of this .exe, so a Python entry was never even possible. I wonder what this post is doing in this newsgroup... :) Dave Sent via Deja.com http://www.deja.com/ Before you buy. From news at heitlager.com Tue Jul 11 06:35:44 2000 From: news at heitlager.com (Ilja Heitlager) Date: Tue, 11 Jul 2000 12:35:44 +0200 Subject: win32com: How to use optional parameters? Message-ID: <8ket8e$nj6$1@spectra.a2000.nl> Ok, call me lazy, but until now I was unable to use optional parameters in COM calls. For example I would like to Add a new sheet in Excel at the end of all other sheets. In Visual Basic I would use something like xl.Worksheets.Add After:=xl.Worksheets.Count Where the Add method accepts the following parameters expression.Add(Before, After, Count, Type) expression Required. An expression that returns a Worksheets object. Before Optional Variant. An object that specifies the sheet before which the new sheet is added. After Optional Variant. An object that specifies the sheet after which the new sheet is added. Count Optional Variant. The number of sheets to be added. The default value is one. Type Optional Variant. The sheet type. Trying something like xl.Worksheets.Add(After=xl.Worksheets.Count) in python doesn't work. Please help, otherwise I need to use a MoveAfter method written in VB and call this with Application.Run(...) Regards, Ilja Heitlager From m.faassen at vet.uu.nl Mon Jul 31 08:11:48 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 12:11:48 GMT Subject: exceptions (was Re: Perl is worse!) References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8m26fm$ila$4@newshost.accu.uu.nl> <8m3f0o$hn6$1@newshost.accu.uu.nl> <8m3kek027f0@news1.newsguy.com> Message-ID: <8m3qe4$due$3@newshost.accu.uu.nl> Alex Martelli wrote: > "Martijn Faassen" wrote in message > news:8m3f0o$hn6$1 at newshost.accu.uu.nl... [snip] >> """ >> However I find that bugs come up on the damnedest things, break you >> out of loops, cause problems all around and don't let you return to where > you >> were [in the algorithm], esp. when you use general catch all exceptions. >> As Alex(?) said, you don't return to where you were so, to me, it seems > quite >> impossible to be able to catch /all/ bugs gracefully, ever. >> """ >> >> The answer to that is easy: No, of course not. > Well, ok, not *ALL*. But you can _design_ for that, to avoid corrupting the > precious persistent data, and avoid wasting a lot of worktime by the user, > under presence of MOST kinds of bugs... Yes, but I'd classify that under 'ungraceful handling', as in "well, something went wrong. I'm not really sure what exactly, though perhaps I can guess it's X. Let's at least save state Y and bring the UI back to that state, and go on; it should all be okay". Perhaps your definition of graceful is different. Anyway, you can handle almost all exceptions. I didn't presume Steve was complaining about that; he was complaining it would become a mess. I tried to figure out why he'd think that, and the only reason I could come up with was that he wanted his code to continue in the face of *bugs* (either in the input data or in the program itself). You can catch and handle even bugs in Python, and try to restore your program to a reasonable state. If you use transactions, this can actually be done quite gracefully sometimes. But I'd say the usual case isn't that graceful; in the case of bugs by definition the program doesn't know what went wrong exactly. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From olipt at mayo.edu Tue Jul 18 12:08:57 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 18 Jul 2000 11:08:57 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f In-Reply-To: <3bRZA8$jD_@openbazaar.net> References: <3bRZA8$jD_@openbazaar.net> Message-ID: > Personally, I find that the matrix-orientation of Matlab makes it > harder to get things done. I more often have 3 or higher dimensional > arrays than I have plain old 2D matrices, so I'd rather see the more > general Numeric Python syntax than any over-specialized matrix code. > > When you're contracting a 4-tensor with a vector, you almost need an > index-based notation. > > As it is, the only things missing from NumPy is an easy spelling of > matrix-matrix multiplication, and if you really need that, you can > just define your own class to do it. I think I'll chime in here. I have been greatly enjoying this discussion. I have been an active participant in Numerical Python development and have been advocating it's use over Matlab to anyone who will listen for over a year. This recent excitement is encouraging as I've seen the potential for Python to replace Matlab for some time. Before, my thesis writing picked up I spent quite a bit of time working on improving the number of "toolboxes" available for Python --- a project I intend to continue as soon as my dissertation gets written since I plan on using Python in the electrical engineering classes I teach at University this winter. Many people would like to see Python get into the core. Guido has (in the past six months) expressed a willingness to do that if there is community support (I do not know if the recent move to BeOpen has changed that -- I would be surprised if it did). Some of us are working right now on a redesign of NumPy to facilitate its inclusion into the core. It is available at SourceForge under the module name numpy2. The basic idea is to move the array object from a C-type to a Python class. This will make it much easier to subclass the array while keeping extension module compatibility among the subclasses (so that toolboxes can be written to handle the data regardless of the class). I'm very busy right now, so progress is slow. However, the good news is that the design is complete but just requires some coding work to get it running. Any helpers who want to make sure NumPy gets into the core are more than welcome to help. I am not opposed to adding ONE new operator like "@" to the language. But, from the documentation it seems that Python likes not having such "line noise" in its syntax. I quoted the above because it expresses my opinion as well: Matlab had to "retrofit" itself in a very inelegant way to handle N-D arrays --- it still doesn't do a good job in many respects. There was a lot of careful discussion that went in to making NumPy general for N-D arrays and not just 2-D matrices. For that reason I support to a greater extent the concept of a Matrix-syntax parser for Python and a specialized Matrix subclass. I think MatPy is a fantastic step in this direction. Either a pre-processor/modified interpreter or an evaluation module (ala PyAlgebra.run) seem like good ideas to me. We need to remember that 2-D Linear Algebra is just a subset of what Matlab and Numerical Python are useful for. Many problems are actually better written with N-D tensors. I'd love to find Numerical algorithms that found N-D tensor inverses without remapping to the (arbitrary?) 2-D domain. Has anybody heard of such things? Travis Oliphant ---Words without work are worthless--- From hei at adtranzsig.de Tue Jul 11 11:47:05 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Tue, 11 Jul 2000 17:47:05 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> <8kfd7o$2tf$1@desig-bs01-s04.adtranzsig.de> Message-ID: <8kfffh$3q9$1@desig-bs01-s04.adtranzsig.de> Okay, somebody pointed me to __setstate__. For other people: read http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html especially "2.6 Object evolution" if you want to know what i'm talking about. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Dirk-Ulrich Heise" schrieb im Newsbeitrag news:8kfd7o$2tf$1 at desig-bs01-s04.adtranzsig.de... [...] > That's my principal problem with all this > persistency stuff - interoperability between > versions of a program. Or is ZODB the first > thing to overcome this, and i missed > something? From rupole at compaq.net Tue Jul 18 17:02:13 2000 From: rupole at compaq.net (Roger Upole) Date: Tue, 18 Jul 2000 21:02:13 GMT Subject: event handler advice References: <8l033n$pr2$1@la-mail4.digilink.net> Message-ID: No HAHA, actually you can do exactly that. Just construct your dictionary so that it maps the event integer value to the function itself. def eventhandler1() .... def eventhandler2() .... def eventhandler3() .... eventmap = {eventvalue1:eventhandler1, eventvalue2:eventhandler2, eventvalue3:eventhandler3 } eventhandler = eventmap[someeventvalue] eventhandler() HTH Roger Upole Then you can "Pete Shinners" wrote in message news:8l033n$pr2$1 at la-mail4.digilink.net... > i'm trying to write a simple event handler python class. > so far i haven't come up with an 'elegant' solution i was > expecting. > > i have a list of different messages, and they are all > given different interger values. this list is defined > in a C extension, for example > msg.INIT, msg.EXIT, msg.STOP, msg.PLAY, ... > > > i want to make a inheritable class that receives one > of these messages and calls a member routine with the > same name. my handler doesn't know the name of the > variable, since python only sends it the INT value. > > so i need to find some nice way to map these message ids > to a method name. i then need to get this name and have > the class call it on itself. > > the end result being i can call > "mymessagehandler_inst.handle(msg.PLAY)" > and this will in turn call > "mymessagehandler_inst.PLAY()" > > there's a good sized list of these messages, and in the > future it will likely expand > > my guess is i need some dictionary that defines the > messages and their routine name (no shortcut way to do > this unless python had #define like macros :]) > > messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} > > then a routine like > > class basehandler: > def handle(messageid): > name = messages[messageid] > self.name() #HAHA, no really, how do i do this? > > but i'm not exactly sure how to write this. need help, thx > > > From robin at jessikat.fsnet.co.uk Thu Jul 13 18:34:46 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 13 Jul 2000 23:34:46 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> Message-ID: In article <8kld9h$489$1 at nnrp1.deja.com>, Mark Hammond writes >In article , > ... > >However, this should be quite exciting for the Python community. The >general feel of the conference here is that the MS .NET technology is >exciting and a good thing. I predict that the Windows community will >embrace this technology, and having Python be a first-class citizen is a >good thing! It _is_ a radical change. > sounds like the snake got bitten to me; OS seems like a better way to go. Or perhaps IL is OS as are all the translators. >Mark (still at the PDC!) > ... -- Robin Becker From jerry_spicklemire at my-deja.com Wed Jul 5 11:48:39 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Wed, 05 Jul 2000 15:48:39 GMT Subject: Postscript font metrics? References: <39622330.3732B225@yahoo.com> Message-ID: <8jvlcg$d1p$1@nnrp1.deja.com> In article <39622330.3732B225 at yahoo.com>, Paul Winkler wrote: > I might have a go at hacking the relevant parts of the Perl > PostScript-Font-1.02 module into Python... but then I'll have to > (yuck) read someone else's Perl code, which I haven't done in a > looong time and I was never that good at it. > If you already have a notion of how to go about this with the Perl module, you might look at Minotaur http://mini.net/pub/ts2/minotaur.html to call the Perl functions from Python. Good luck, Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From nospam at buzzoff.com Wed Jul 19 17:45:53 2000 From: nospam at buzzoff.com (Moritz Voss) Date: Wed, 19 Jul 2000 23:45:53 +0200 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> Message-ID: <8l57fc$vi8$1@fermi.tro.net> "Martijn Faassen" schrieb im Newsbeitrag news:8l4isr$l58$2 at newshost.accu.uu.nl... > In comp.lang.python Newsgroup wrote: > >> In the Open Source Crystal Space 3D engine we are working on a framework > > for python > >> scripting. It is already working reasonably well but you cannot yet do > > everything > >> that you'd want to do from a python script. > > > Can anybody explain what you actually do to attach the python, or any other > > general purpose scripting language, to your game? > > Sure, for Python the documentation is here: > > http://www.python.org/doc/current/ext/ext.html > http://www.python.org/doc/current/api/api.html > > Be sure to check out stackless Python, which has some advantages for > game scripting: > > http://www.stackless.com/ > > > I'm making a game with a > > scripted engine and I have to write my own compiler to convert scripts into > > a length of integers and a virtual machine to convert it into game logic. > > Does python produce it's own compiled code and you then have to write a > > virtual machine based on this output? > > Hm, Python produces its own compiled code (virtual machine instructions), > and Python includes a virtual machine. You just hook Python into your > game. > > So no, you don't have to do all that; Python already includes a compiler > and interpreter that can be embedded into your game. HOW FAST ARE THESE? I am developing a very similar API to that of "Newsgroup", with a very lowlevel assembly-style scripting launguage that is translated int oVM code... You could say hearing of pythonis like licking fresh blood :) Okay, I'll be downloading all I need for python and have a look at it. :) -- -- Moritz "Thygrrr" Voss Client-Server & OpenGL Coder spirit.link.studios - http://o2.ods.org > Martijn > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? Smart :) From xiarcexml at yahoo.com Wed Jul 12 16:11:49 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Wed, 12 Jul 2000 13:11:49 -0700 (PDT) Subject: Switching to Linux...... converting files and databases.... Message-ID: <20000712201149.7701.qmail@web5302.mail.yahoo.com> Hello... I am learning Python ((although I've taken a break from it to put some finishing touches on a Java application I wrote))... and something >>drastic<< occurred... My Windows 95 crashed... big-time... OK.. so why do you care?? Well.. I was looking for input on whether Python would be the right choice for this product... The problem: 1) Windows 95 2) Files such as Word Files, Excel Databases, Works Files, Access Databases... 3) A family member who is resisting the >>potential<< change to Linux. A solution (???) 1) Linux 2) deferred to below: 3) as well, deferred to below: Proposed project: The Windows to Linux Survival Kit Subject: Software that can open and read Microsoft's proprietary (wrong word?) files and convert them to databases and files usable by Linux's opensource software.. I am in the planning stages, and I am simply wondering... Should I consider Python as a suitable language for writing these programs? And does anyone have any suggested resources for the hows (not whys) of Linux, and perhaps for the use of Microsoft files with Python? Another idea of mine involves XML (another one of my pet learning projects). ...or maybe something exists out there (or a project that I can get involved in) already? Thanks alot, Dave __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From gmcm at hypernet.com Mon Jul 17 23:01:25 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 18 Jul 2000 03:01:25 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: Message-ID: <8F74EFC76gmcmhypernetcom@199.171.54.155> Huaiyu Zhu wrote: >I don't see such arguments as any different from the claim that string >literals are sintactic sugar for the single domain of text processing >only (web and re and so on being subdomains). Since by such definition >text processing is a very large domain I do want string literals even >just for this only domain, even if it does not include everything. Look at it this way: the implementation of Python is based on strings, tuples, dicts and lists. So they came for free. The most exotic operators Python currently has are probably the shift operators. That's really not a good precedent for 8 new operators. [bjorn suggest preprocessing...] >This could work if there is a hook so that > >import mymodule > >would automatically run > >preprocessor < mymodule.mpy > mymodule.py > >anywhere in the path. It should do this after examining the timestamp >just like current import does. Otherwise after a few surprises people >would keep .py instead of .mpy so it is just a helper for writing, but >not useful for extending or maintaining code, Get Greg Stein's imputil.py from http://www.lyra.org/greg/python/ (or wait for BeOpen's first release - it'll be in the std lib). It has a hook for this. -Gordon From see at below Sun Jul 30 22:03:49 2000 From: see at below (Paul Foley) Date: 31 Jul 2000 14:03:49 +1200 Subject: experts disagree on "call-by-reference" References: <8m29o0$p9g$2@news.dtc.hp.com> Message-ID: On Sun, 30 Jul 2000 19:17:08 -0400, David Goodger wrote: > on 2000-07-30 18:20, Greg Weeks (weeks at golden.dtc.hp.com) wrote: >> All of the passages mentioned above could just as well apply to Python. >> The experts are in explicit disagreement. > You're comparing apples with oranges. Of course they're "in disagreement", > because they're describing different things. You seem to have missed the whole point of the post to which you're replying, which was that they're _NOT_ describing different things. Variables in Python work exactly like variables in Lisp, etc.; nihil sub sole novum. Greg Weeks has consistently failed to understand that the meaning he wants to apply to the terms "call by value" and "call by reference" seems to be somewhat at odds with what everyone else means by those terms; I'm sure the authors he quoted wouldn't actually disagree at all if you asked them (i.e., I'm quite confident that each and every one of them understands what's actually going on) [long-winded explanation of Lisp-like variable semantics elided] > Terms like "pass by reference" don't really apply to Python in the > traditional sense, because we're dealing with a higher order of Yes, exactly. "Pass by whatever" has never really applied to Lisp-like call semantics, Greg Weeks' protestations about "the old way of speaking" notwithstanding. -- Cogito ergo I'm right and you're wrong. -- Blair Houghton (setq reply-to (concatenate 'string "Paul Foley " "")) From donn at u.washington.edu Tue Jul 11 13:35:36 2000 From: donn at u.washington.edu (Donn Cave) Date: 11 Jul 2000 17:35:36 GMT Subject: Nonblocking IO? References: Message-ID: <8kflt8$7f3o$1@nntp6.u.washington.edu> Quoth cjc26 at nospam.cornell.edu (Cliff Crawford): | * Nolan Darilek menulis: | | | | The most obvious solution is to use curses, but this makes my program | | much more complex than it needs to be. Since cmd does almost exactly | | what I want it to do, I'd much rather change the Cmd class than add | | curses. I've seen code written in C which does what I'd like to do | | (Micq, for example, has the interface which I'm aiming for, yet it | | doesn't use curses/ncurses.) So, is it somehow possible to either a) | | make raw_input nonblocking or b) use some other nonblocking IO method? | | You could use the select module to wait for input from multiple file | descriptors (for example, sys.stdin and a socket). Also, the asyncore | module is a higher-level interface to select, and may be useful to you | too. | | | | And, is it then possible to ensure that the output from the socket | | isn't intermingled with the input? If I do nonblocking IO, I'm | | assuming that it's simply a matter of printing a newline, my message, | | and then reprinting the prompt while stuffing the existing input back | | into the input buffer. | | Have you checked out the termios module? That would be pretty much the | only other way to do it, besides curses (which is aptly named, don't you | think? ;) Right, and that's really the way to get input right away after a key press too. I don't have the original post here, but I thought that might have really been the question. Since I know a useful answer to that question, let's pretend so anyway. When we really want "non-blocking" input, the issue is whether the system should return from read() whether there is data or not - normally it "blocks" until data arrives. Hence the interest in select(), which is all about this issue of where there's data. With the terminal we also have the question of _how much_ data should the system return, should it return a whole LF-terminated line or return each single byte as it arrives. This is a function of the terminal device driver, and you have to use these device specific termios ioctls to 1) turn off canonical input processing, which is where it reads whole lines at a time and applies back-spacing edits etc., and 2) tell it to read one byte and not to wait for anything more. The appended code works for me on Digital UNIX. You may also want to turn off echo, and print the input yourself. As for output that happens while the user is typing input, it might be possible to clean that up a little with some VT100 escapes. That's difficult in a continuous scrolling model, but if the output is presented one screen per event it might be pretty easy. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu ----------------------------- import termios import TERMIOS import posix iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(0) lflag2 = lflag & ~TERMIOS.ICANON cc2 = cc[:] cc2[TERMIOS.VMIN] = 1 cc2[TERMIOS.VTIME] = 0 termios.tcsetattr(0, TERMIOS.TCSADRAIN, [iflag, oflag, cflag, lflag2, ispeed, ospeed, cc2]) posix.write(1, 'Press key: ') stuff = posix.read(0, 1) print '\nstuff:', repr(stuff) termios.tcsetattr(0, TERMIOS.TCSADRAIN, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) From mwh21 at cam.ac.uk Wed Jul 19 02:13:23 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Jul 2000 07:13:23 +0100 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: Robin Becker writes: > I suppose there must be something desperately wrong with using the > __mul__ for sequences to indicate the set pairwise product. I would > certainly be for > > x,y in A*B rather than x,y in zip(A,B) or marry(A,B), but since * is the > obvious operator it must be that someone else has reserved it. Well, whatever "zip" ends up being called, it doesn't return the Cartesian product of the set of elements of the list, so using the product operator would be, at best, confusing! Wouldn't you expect >>> for i,j in [0,1]*[2,3]: ... print i,j (0,2) (0,3) (1,2) (1,3) rather than >>> for i,j in zip([0,1],[2,3]): ... print i,j (0,2) (1,3) ? Cheers, M. -- I also fondly recall Paris because that's where I learned to debug Zetalisp while drunk. -- Olin Shivers From moshez at math.huji.ac.il Sat Jul 29 02:16:10 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 29 Jul 2000 09:16:10 +0300 (IDT) Subject: GPL Compatability (was Re: The State of Python) In-Reply-To: <8lsipi$hoq$1@newshost.accu.uu.nl> Message-ID: On 28 Jul 2000, Martijn Faassen wrote: > Moshe Zadka wrote: > > On Fri, 28 Jul 2000, Paul Duffin wrote: > > >> What does GPL compatible mean ? > > > It means that it can be relicenced as GPL. > > Are you sure? I thought it meant you could legally link it to > GPL-ed software. That's what the whole Qt/KDE squabble is about, at least. Martijn, you keep forgetting I'm a mathematician -- we're almost as bad as lawyers. I *did* not say that for any licence X, Y is X compatible is Y can be relicenced as X. However, because of the viral nature of the GPL, what you said and what I said is equivalent. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From glyph at twistedmatrix.com Wed Jul 19 15:32:27 2000 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Wed, 19 Jul 2000 14:32:27 -0500 (EST) Subject: Obscure Threading Bug Message-ID: I apologize for the length and obscurity of the attachment. However, the previous example where I encountered this bug was easily twenty times as long, and it took some effort to make it this short :-). Simply put, the interpreter usually segfaults when I run this file. I don't know exactly why. My copy of python doesn't have debugging symbols,so my backtraces aren't terribly meaningful, but the first few lines are usually something like: #0 __flockfile (stream=0x0) at lockfile.c:32 #1 0x4009ac07 in _IO_ferror (fp=0x0) at ferror.c:35 #2 0x8069178 in PyFile_SetBufSize () the common theme being PyFile_SetBufSize (). "lots of threads, lots of sockets" is a common theme for a lot of apps that I would like to build, so I would be glad to help if there's any more information I can supply. This bug has been known to occurr on: RedHat/Debian Linux default Python install, Digital Unix python 1.5.2 (Digital UNIX V4.0F (Rev. 1229); Thu Jul 15 17:56:36 EET DST 1999) and on debian using CVS python. ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://www.twistedmatrix.com/~glyph/ -------------- next part -------------- #!/usr/bin/env python from threading import * from SocketServer import StreamRequestHandler, ThreadingTCPServer from time import * from socket import * class Client: def __init__(self,host,port): self.connection=socket(AF_INET,SOCK_STREAM) self.connection.connect(host,port) self.rfile = self.connection.makefile('rb', 0) self.wfile = self.connection.makefile('wb', 0) def reader(self): try: while 1: self.rfile.read(1) except: pass def writer(self): try: while 1: self.wfile.write('xxxxxxxx') except: pass def read_forever(self): try: Thread(target=self.reader).start() Thread(target=self.writer).start() self.rfile.close() self.rfile.close() except: pass class Handler(StreamRequestHandler): def handle(self): try: for i in range(100): self.rfile.read(1) self.wfile.write('xx') self.wfile.close() self.rfile.close() except: pass class Server(ThreadingTCPServer): def __init__(self,port, handler): ThreadingTCPServer.__init__(self,('',port), handler) def server_bind(self): self.socket.setsockopt(SOL_SOCKET,SO_REUSEADDR,1) ThreadingTCPServer.server_bind(self) s=Server(101010,Handler) t=Thread(target=s.serve_forever) t.start() sleep(2) for i in range(100): c=Client('localhost',101010) for i in range(100): Thread(target=c.read_forever).start() c.wfile.write('x') c.rfile.read() sleep(2) print 'ranging' From max at alcyone.com Mon Jul 10 16:36:47 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 10 Jul 2000 13:36:47 -0700 Subject: Circular reference problem -- advice? (resolved) References: <396A1EC6.6738CFCC@alcyone.com> <20000710123559.A2218@freei.com> <20000710214046.P26534@xs4all.nl> Message-ID: <396A33DF.495B59F5@alcyone.com> Thomas Wouters wrote: > Don't forget that an instnace's __dict__ doesn't list methods, just > data > members. (instance methods are created on the fly, from the unbound > versions, and not stored in the instance's __dict__.) > > getattr() will work though, hadn't thought about that one ;) Thanks for the responses, folks. As it turned out, my question was more involved than I originally thought (I actually cancelled my post right after sending it), but with Thomas' help via email I was able to get what I needed via a combination of apply and getattr, a rather more elegant solution than an exec. (I actually couldn't use method references at all, because it needs to respect subclassing when dispatching.) In the general sense, I must say I'm quite pleased with Python. This is the one issue that I actually had to sit down and think about; everything else has flowed naturally from my fingertips; my first project was a chatterbot that hooks up to a friend's talker (so I had to write the framework to be able to communicate with it first), and this issue was the one sticky issue that came up during the entire process -- a good sign that it's well designed and easy to learn. Thanks again. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Life is something to do when you can't get to sleep. \__/ Fran Lebowitz Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From cmedcoff at my-deja.com Thu Jul 6 20:19:38 2000 From: cmedcoff at my-deja.com (Charles Medcoff) Date: Fri, 07 Jul 2000 00:19:38 GMT Subject: Python COM: How to access constants in type lib Message-ID: <8k37mi$o76$1@nnrp1.deja.com> When using Python as a COM client, how can I use/access constants defined in a type lib from Python. Example: import win32com.client engine = win32com.client.Dispatch("DAO.DBEngine.35") db = engine.OpenDatabase(r"\test.mdb") query = db.CreateQueryDef("base", "SELECT, bla, bla...") query.Type = dbQMakeTable # this doesn't work Thanks, Chuck -- Charles Medcoff Senior Systems Engineer Pyramid Solutions 1850 Research Drive, Suite 300 Troy, MI 48083 Sent via Deja.com http://www.deja.com/ Before you buy. From hopper at omnifarious.mn.org Tue Jul 18 19:59:42 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Tue, 18 Jul 2000 17:59:42 -0600 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <20000718231047.D4283@xs4all.nl> Message-ID: In article <20000718231047.D4283 at xs4all.nl>, Thomas Wouters wrote: > > Well, I've more than once written a debug object that behaved like > another object but with debug output. Without subclassing, because I > would've had to override all methods anyway, and I didn't want the debug > class to *do* anything. This doesn't sound like a time to make use of generic programming. It sounds like a time for Python's incredibly wonderful reflection capabilities. Especially if you've done it more than once. > If you insist on type-checking, do it the interface-way: > > getattr(object, "required_method") getattr(object, "required_datatype") > [etc] *shudder* > Scoping is incredibly simple in Python. There's the local scope, and the > global scope ;) It might take some getting used to if you're used to > magic or explicit scopes, but it's definately very simple ;) It is very simple. I would prefer more nesting of scopes though. In particular, lambda expressions should have the local scope they're declared in as their global scope. I understand why they don't. It's because of how references to variables inside functions are optimized. -- Eric Hopper (hopper at omnifarious.mn.org) (http://www.omnifarious.org/~hopper) From peter at schneider-kamp.de Thu Jul 20 23:32:05 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Fri, 21 Jul 2000 03:32:05 +0000 Subject: questionnaire about zip and for loops References: <3976BDF7.82FB6C56@schneider-kamp.de> Message-ID: <3977C435.2FF7EB3E@schneider-kamp.de> Peter Schneider-Kamp wrote: > > I'd like to use the readers of comp.lang.python as guinea pigs this time. Come on! Only 3 have replied so far. I thought there would be something somehow worth to be called "response"?! Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From rpm at wag.caltech.edu Thu Jul 27 10:18:00 2000 From: rpm at wag.caltech.edu (Richard P. Muller) Date: Thu, 27 Jul 2000 07:18:00 -0700 Subject: Will NumPy ever be built into standard Python dist? Message-ID: <39804498.B6182B66@wag.caltech.edu> Does anyone know whether there are plans to make NumPy part of the standard Python distribution? Rick From richard at cogsci.ed.ac.uk Wed Jul 12 13:19:43 2000 From: richard at cogsci.ed.ac.uk (Richard Tobin) Date: 12 Jul 2000 17:19:43 GMT Subject: Changing the class of an instance Message-ID: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> Is it legal (it seems to work) to change the class of an object by assigning to its __class__ attribute? In particular for the case where the new class is a subclass of the old. I'm not looking for an argument (not even the five minute one) about whether it's a good idea, just whether it's legal. -- Richard -- Spam filter: to mail me from a .com/.net site, put my surname in the headers. "The Internet is really just a series of bottlenecks joined by high speed networks." - Sam Wilson From nowonder at pool.informatik.rwth-aachen.de Tue Jul 25 01:22:43 2000 From: nowonder at pool.informatik.rwth-aachen.de (Peter Schneider-Kamp) Date: Tue, 25 Jul 2000 05:22:43 +0000 Subject: newb Q: security with variables References: <397BE388.349CCA17@mediaone.net> <2kYe5.25991$1h3.418424@news20.bellglobal.com> <8li9dq$8do$1@nnrp1.deja.com> <397CD2C4.8D28FE65@mediaone.net> Message-ID: <397D2423.C06FEB9B@pool.informatik.rwth-aachen.de> Toy wrote: > > The link is broken, could you show me another link? > > Jeremy Hylton wrote: > > > http://www.cnri.reston.va.us/software/pisces/manual/module- > > pisces.pwcrypt.html http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.pwcrypt.html Come on, that is not THAT hard ;-) Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From ryzam at my-deja.com Mon Jul 24 07:36:48 2000 From: ryzam at my-deja.com (ryzam at my-deja.com) Date: Mon, 24 Jul 2000 11:36:48 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lc6jk$1f1$1@coco.singnet.com.sg> <8lde5s$vba$1@nnrp1.deja.com> <8leo17$tnt$1@dahlia.singnet.com.sg> <8lg7ft$odv$1@nnrp1.deja.com> <397BEAE5.3C1E5151@stroeder.com> Message-ID: <8lh9og$fi5$1@nnrp1.deja.com> In article <397BEAE5.3C1E5151 at stroeder.com>, Michael =?iso-8859-1?Q?Str=F6der?= wrote: > ryzam at my-deja.com wrote: > > > > ImportError: NO module named M2Crypto > > Are you sure that you copied the module directory M2Crypto to your > Python path (e.g. into site-packages/)? > > Ciao, Michael. > Yes i have unzip all the m2crypto-005 to "C:\Program Files\Python".What version should i run it. I'm using python 1.5.2 on win98 izam Sent via Deja.com http://www.deja.com/ Before you buy. From jtoy at tcgfinancial.com Wed Jul 19 17:26:19 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Wed, 19 Jul 2000 17:26:19 -0400 Subject: newb question References: <3bRfYe$jTl@openbazaar.net> <8l2rv1$k2t$1@nnrp1.deja.com> Message-ID: <39761CFB.4CBE0AC9@tcgfinancial.com> Hi, Im writing back to you from a different account. I want to use the pig cow scenario. A user enters his password and username, etc. thanks From gjm11 at g.local Wed Jul 19 16:09:54 2000 From: gjm11 at g.local (Gareth McCaughan) Date: Wed, 19 Jul 2000 21:09:54 +0100 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> Message-ID: Aahz Maruch wrote: [Olivier Dagenais:] >> "twist", "merge", "smash", "glue", "dna", "ladder", "join", "match", >> "collect", "pick", "lineup"??? > > I like "merge". Nooooo. "Merge" is what you do to [1,3,5] and [2,4,6] to get [1,2,3,4,5,6]. (What it means when you give it [3,1,2] and ["a",[],1+2j] is slightly less clear, perhaps...) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From cut_me_out at hotmail.com Sat Jul 8 13:03:54 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 Jul 2000 13:03:54 -0400 Subject: Splitting c.l.py... References: <8k7lld$g53$1@nnrp1.deja.com> Message-ID: > It's not interesting <0.2 wink>. OK, I'll take your word for it. :) Alex. From gmol at my-deja.com Sun Jul 2 22:32:37 2000 From: gmol at my-deja.com (gmol at my-deja.com) Date: Mon, 03 Jul 2000 02:32:37 GMT Subject: Referring to method of a class without instance? Message-ID: <8jou05$mei$1@nnrp1.deja.com> In my application I use the observer/observable pattern..question I hate duplicating the information of what was changed by making up a new message type (global message variables or strings) and using tonnes of if-else clauses. I'd rather just tell my observer which method was called and the arguments passed to it. (I.e. I have atoms in 3d space, when setPosition(position) is called I would just like to tell whoever is interested that setPosition was called with the argument position)) Problem, how do I refer to the method of a given class without making an instance? Like suppose I notify my observers by giving the funciton address and arguments, I would like the observer to have a dictionary whose keys are methods class Atom: .... class myobserver: ... updateTable={.... Atom.setPosition:handle_A_setPositio } ... Hmm I have also just realized that given class A: def __init__(self...) a=A() a.init is not equal to A.__methods__['__init__'] Hmmm I thought that would be the worst way I could do it, but I guess I couldn't if I wanted to... Any thoughts or better general solution would be appreciated... Sent via Deja.com http://www.deja.com/ Before you buy. From paul.magwene at yale.edu Tue Jul 18 09:47:28 2000 From: paul.magwene at yale.edu (Paul Magwene) Date: Tue, 18 Jul 2000 09:47:28 -0400 Subject: Does Python have "not a number" floating point values? References: <8l03pc$92co$1@nntp6.u.washington.edu> <878zuznc5v.fsf@ifm.uni-kiel.de> Message-ID: <39745FF0.F328E6C@yale.edu> Janko Hauser wrote: > > This raised a floating point exception on an Alpha machine. At the > moment this is not portable. > > __Janko > > -- > Institut fuer Meereskunde phone: 49-431-597 3989 > Dept. Theoretical Oceanography fax : 49-431-565876 > Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de > 24105 Kiel, Germany On FreeBSD (v3.5-Stable) this core dumps as well, as does: Nan = math.exp(1000)/math.exp(1000) -- Paul Magwene paul.magwene at yale.edu From anupamk at mindspringdot.com Sun Jul 9 17:38:58 2000 From: anupamk at mindspringdot.com (anupam) Date: Sun, 09 Jul 2000 17:38:58 -0400 Subject: operator ** and pow function behaves differently Message-ID: <3968F0F1.428553BB@mindspringdot.com> hi all, i am a newbie in the python world. from my understanding so far, i thought that ** operator and pow functions are symmetrical. but apparently i was wrong, e.g. -1**0 yields -1 but pow(-1,0) yields 1 (which is correct). any pointers on why this is ? please be gentle !!! thanks anupam From dnotspam-jen at personic.com Mon Jul 17 21:26:58 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Mon, 17 Jul 2000 18:26:58 -0700 Subject: Multiline strings and indentation References: <39736250$0$14722@wodc7nh6.news.uu.net> <39736E71.AE8B128B@sec.noaa.gov> Message-ID: <3973af3b$0$27161@wodc7nh1.news.uu.net> Umm, yes to everyone who replied. But ... that's quite a few more keystrokes to add. It's a little less work to use parentheses: print ("the first line of text\n" "the second line of text \n" "the third line ... \n") But in both cases you have to put in extra quotes and explict newline characters (unless you don't care where the text wraps). Multi-line strings save a bit of typing, and are a bit easier to reformat when editing. So I guess this means I have to choose between weird indentation (multi-line strings) or typing more characters? Jen "j vickroy" wrote in message news:39736E71.AE8B128B at sec.noaa.gov... > How about: > > >>> print "this" + \ > " is" + \ > " a" + \ > " long" + \ > " string" > > this is a long string > >>> > > "donotspam-jen at personic.com" wrote: > > > I'm just getting started with Python. The indentation feature really does > > make things readable ... except when using multi-line strings. This just > > doesn't look right: > > > > def multiline(x): > > if x: > > print """this is a > > multi-line string that spans > > three lines""" > > print "another string" > > > > Is there a way to make the above more readable? It would be nice if it could > > be written this way and have Python just figure out what whitespace to > > ignore: > > > > def multiline(x): > > if x: > > print """this is a > > multi-line string that spans > > three lines""" > > print "another string" > > > > Thanks for any suggestions! > > > > Jen > From aahz at netcom.com Sat Jul 29 10:56:15 2000 From: aahz at netcom.com (Aahz Maruch) Date: 29 Jul 2000 14:56:15 GMT Subject: Python 3000 ? References: <8lttuq$9c8$1@serv1.albacom.net> Message-ID: <8luraf$e2p$1@slb1.atl.mindspring.net> In article <8lttuq$9c8$1 at serv1.albacom.net>, Patrick Fichou wrote: > >What is(will be) Python 3000 ? Standard answer: Nobody -- repeat, nobody -- has the answers to these questions. Py3K is a codename for a project that has not yet started. Py3K is predicated to a certain extent -- to what extent, nobody knows -- on the Fred Brooks maxim, "Build one to throw away." There are certain design decisions that were made for Python 1.x that Guido would like to revisit. Some of these decisions *MAY* be changed in ways that break 1.x code. Py3K is the name of the version that *MAY* have these incompatibilities. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From jhunt at hpbs1711.boi.hp.com Mon Jul 17 16:25:47 2000 From: jhunt at hpbs1711.boi.hp.com (Jacob Hunt) Date: Mon, 17 Jul 2000 14:25:47 -0600 Subject: nis module error Message-ID: <39736BCB.626BD669@hpbs1711.boi.hp.com> I am new to python and want to use the nis module. When I import the module I get the error: Traceback (innermost last): File "", line 1, in ? ImportError: /usr/lib/python1.5/lib-dynload/nismodule.so: undefined symbol: yperr_string what does this mean? How can I correct the problem or is there a way around it. I am using python 1.5.2 on x86 SuSE 6.4. Thanks for the help -- Jacob Hunt From level2junkie at my-deja.com Thu Jul 13 15:25:19 2000 From: level2junkie at my-deja.com (level2junkie at my-deja.com) Date: Thu, 13 Jul 2000 19:25:19 GMT Subject: calling .exe inside a .py? Message-ID: <8kl527$tke$1@nnrp1.deja.com> Does anyone know how to call an .exe file from inside a .py file? Sent via Deja.com http://www.deja.com/ Before you buy. From wware at world.std.com Mon Jul 10 23:00:34 2000 From: wware at world.std.com (Will Ware) Date: Tue, 11 Jul 2000 03:00:34 GMT Subject: [ANN] Python port to Palm Pilot References: <200007070140.SAA31035@wd264.aero.org> <200007101546.IAA09887@rushe.aero.org> Message-ID: JEFFERY COLLINS (collins at rushe.aero.org) wrote: > Download the .zip file instead. Apparently, downloading > the .prc files using a browser corrupts the files. I also ran into a nasty crash that required a cold boot, inspite of using the .zip file. The file sizes are correct according to the download web page. Is it possible the last test just takes such a long time that it ties up the 68k and only appears to have crashed? The place it stops is "Testing 3-argument pow() function..." Wait, it's moving again! It returned to the main menu. Cool. What are the chances of getting a read-eval-print loop running on the Pilot? While I'd rather write Pilot apps in Python than some other languages, I'd love to be able to write Python source right on the Pilot itself. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From thomas at xs4all.net Fri Jul 7 18:55:28 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 8 Jul 2000 00:55:28 +0200 Subject: Making tabs illegal In-Reply-To: <8k5l8d$9lr$1@nnrp1.deja.com>; from fcahoon@my-deja.com on Fri, Jul 07, 2000 at 10:23:18PM +0000 References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: <20000708005527.L26534@xs4all.nl> On Fri, Jul 07, 2000 at 10:23:18PM +0000, Forrest Cahoon wrote: > In article <3950C0E2.7532D38 at sightreader.com>, > Ken Seehof wrote: > > [ ... ] > > > > As for the space/tab mixing issue, the answer is simple: Make tab an > > illegal character in python. Problem solved. > Has anyone tried to patch the python sources to do this? I'm too > uncomfortable with the tab/space ambiguity to do serious work in python > (in a team environment with programmers of varying skill levels) but > this would *totally* solve it for me. Guido's time machine strikes again ! I'm not sure how far back he went this time, but certainly well before I did anything with Python ;) There's the -t flag which does exactly what you want: '-t' warns when tabs and spaces are mixed in a dangerous way. '-tt' emits a compile-time exception. > I started to look at the python sources to do this myself, but I'm sure, > since I'm totally unfamiliar with the internals at this point, my > solution would probably be an ugly hack. Well, asside from the fact that the requested feature is there already, I can tell you that the Python internals are a very pleasant thing to hack ! It probably sounds less impressive from a nameless figure like me than from some bigshot like Eric Raymond ;) but I was very impressed by the quality of the code. And editing good code makes it very hard to write something hackish, both because it's easy to find out how it should really be done, and because it's a bit unfriendly... :-) Laat-niet-als-dank-voor-het-aangenaam-verpozen--- --de-maintainer-van-deze-source-de-schillen-en-de-dozen-ly y'rs, (Before we get another Dutch <> English <> Swahili <> etc war, that means 'clean up after you' in an old dutch proverb ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From samschul at pacbell.net Wed Jul 5 10:18:06 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 14:18:06 GMT Subject: ANS: ASPIPython update on Starship Message-ID: <8jvg2d$8q5$1@nnrp1.deja.com> I have made some corrections to ASPIPython, that correct memory leaks found in aspi.dll. ASPIPython is a open source python interface to the (A)dvanced (S) system (P)programming (I)nterface for SCSI devices developed by Adaptec Corp. This interface allows for the development of tests under Python for SCSI disk drives. These routines can be found at http://starship.python/crew/schulen Sam Schulenburg Sent via Deja.com http://www.deja.com/ Before you buy. From lull at acm.org Fri Jul 14 23:05:03 2000 From: lull at acm.org (John Lull) Date: 14 Jul 2000 22:05:03 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <396F1914.DBE530CA@prescod.net> Message-ID: Paul Prescod wrote (with possible deletions): > You are asking for a > lot of syntax but not proposing that your module go into Python. In > other words it is a lot of syntax that doesn't get used until you > install a third party module. Well shoot, if that's the objection, then put it in the standard distribution! :) The problem is that Python provides no way for an add-on module to define new operators. It's thus impossible to provide appropriate notation *without* making it part of the language. If there were some way to define, in the module, how to interpret specific new operators, that should be adequate -- but that seems like a *far* more difficult solution than what's needed here. Unfortunately, the current lack of appropriate notation makes these problems very difficult to code clearly. Regards, John From olivierS.dagenaisP at canadaA.comM Fri Jul 7 09:56:39 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 07 Jul 2000 13:56:39 GMT Subject: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: If I remember the tutorial correctly, it doesn't support finally with anything else. I have a feeling you would need to do: try: #init try: # stuff except: # stuff finally: #stuff ...that is, assuming that your "except" would only catch specific exceptions that you would want to prepare an error message with. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Thomas Weholt" wrote in message news:3967d908.363887342 at news.online.no... > Hi, > > Does python support, or if not, would it be cool to have support for : > > try: > # some code > except : > # catch exception > finally: > # clean up whatever > > Thomas From rumjuggler at cryptarchy.org Fri Jul 28 23:35:05 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 03:35:05 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> Message-ID: On Fri, 28 Jul 2000 22:04:37 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 11:55:51 -0700, Erik Max Francis wrote: >>Steve Lamb wrote: >> >>> As a human, type 1. Character? String? Integer? Floating >>> number? No, >>> it is 1 and it can be all of those all on context. > >>In Python, and most programming languages that have some notion of type, >>it is an integer. If you wanted a string, then you'd have typed '1', or >>converted it to a string with `1` or repr(1) or str(1). > > Most, not all. Again, I ask, as a /human/. Not as a computer, >calculator, dog, fish, pet rock, face on mars, some gas creature in >delta-theta 3 (word up, gass monster) or almond, is 1 a character a string an >integer a floating point number or what? If you have problems ask about 2 >dozen people off the street what 1 is with that question and see how many >puzzled looks you get. If you write the numeral one on a board and ask 2 dozen people off the street what it is, how many of them will say it's a sequence? Seeing what the quote in my .sig is, I'd like to emphasize that it was chosen randomly. -- Barnabas T. Rumjuggler Is this going to be another episode where you have to be sodomized with the Clue Branch before you shut up and admit you're wrong? -- John S. Novak III, the Humblest Man on the Net. From wilson.austin.aj at bhp.com.au Sat Jul 22 17:09:27 2000 From: wilson.austin.aj at bhp.com.au (A J Wilson) Date: Sun, 23 Jul 2000 07:09:27 +1000 Subject: wxPython and jPython References: <8ld08k$h5s$1@gossamer.itmel.bhp.com.au> <397A0A31.9669504A@san.rr.com> Message-ID: <8ld2dt$kg5$1@gossamer.itmel.bhp.com.au> The reason I ask is that I applied similar logic to yourself but have so far been unsuccessful. However I am a newbie at this stuff. Regards Austin "Courageous" wrote in message news:397A0A31.9669504A at san.rr.com... > > > Is it possible to use wxPython under jPython? The reason I wish to do so is > > that I have a java-based API that I wish to use under jpython but do not > > wish to go to the trouble of learning AWT or SWING for the GUI. > > Well, while someone will no doubt answer you definitely in a moment, > if JPython allows access to c native .dll python extensions, of course > the answer is yes. Haven't done this myself, however, so all you have > right now is my (maybe faulty) reasoning process. :) > > > > C/ From tim_one at email.msn.com Sun Jul 9 12:14:12 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 9 Jul 2000 12:14:12 -0400 Subject: What about try:except:finally In-Reply-To: Message-ID: [Martin von Loewis] > That also shows that having try:except:finally is perhaps not a good > idea. Given > > try: > A > except: > B > finally: > C > > is that the same as > > try: > try: > A > finally: > C > except: > B > > or as > > try: > try: > A > except: > B > finally: > C > > or is it something else? If so, what would it be? And why not one of > the others? Sorry that I haven't followed this whole thread, but if no old-timer has pointed it out before, Python *used* to allow try/except/finally all at the same level. For exactly the reason Martin gave here, that was removed before Python's first public release. From Misc/HISTORY: New features in 0.9.6: - stricter try stmt syntax: cannot mix except and finally clauses on 1 try The ambiguity Martin pointed out here was real: it's not at all obvious what mixing them means, and about half the users guessed wrong about what the implementation actually did. explicit-is-better-than-implicit-ly y'rs - tim From db3l at fitlinxx.com Fri Jul 7 20:32:53 2000 From: db3l at fitlinxx.com (David Bolen) Date: 07 Jul 2000 20:32:53 -0400 Subject: FILE * arguments in C API ?? References: <396628D5.12ECD88@tds.net> Message-ID: "Edward K. Ream" writes: > Alas, there appears to be a botch in the C API's. In particular, > routines like > > int PyRun_AnyFile (FILE *fp, char *filename) > > can not be included usefully in python/libs because struct FILE's will > be different when built by different compilers. This wouldn't matter if > it > were easy/possible to rebuild python/libs using one's own compiler. > > Any comments? Any suggestions? I can't necessarily comment on the "easy" but is there a reason why it isn't "possible" to rebuild python/libs for your compiler? I mean, it's not like the source isn't available. You might have to statically link if you needed to co-exist on a system with the standard Python DLL, or at least rename the DLL if building a DLL. -- -- 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 mtebeka at intel.com Thu Jul 20 02:19:15 2000 From: mtebeka at intel.com (Miki Tebeka) Date: Thu, 20 Jul 2000 09:19:15 +0300 Subject: are there any tutorials that someone completly new to programming can understand? In-Reply-To: <8l4klm$2kl$1@slb6.atl.mindspring.net> References: <8l4klm$2kl$1@slb6.atl.mindspring.net> Message-ID: Hello Dan, > well..im 17 and thought that i should start with a programming language, and > after checking with some of my friends, they pointed me to python > > but, all the tutorials seem to be for those that have spent years in > programming (mabey im just looking in the wrong places) but id really like > to try my hand at this Python is a good start when learning how to program. Have a look at: http://www.honors.montana.edu/~jjc/easytut/easytut/ You can find more links at: http://www.python.org/sigs/edu-sig/ As a secnod (first?) choice I'd also recommend Scheme: http://www.cs.rice.edu/CS/PLT/Teaching/Lectures/Released/Book/ and I you can get a hold of the book "The little Schemer" it'll give you a good start. Bye. ------------------------------------------------------------------------------ Smile, damn it, smile. (lambda (msg) (case msg ((name) "Miki Tebeka") ((email) "tebeka at lycosmail.com") ((homepage) "http://www.tebeka.freeservers.com") ((quote) "I don't suffer from insanity, I enjoy every minute of it."))) From stephen_purcell at yahoo.com Sat Jul 1 23:06:10 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 2 Jul 2000 13:06:10 +1000 Subject: [ANNOUNCE] PyUnit 1.2.0 test framework with GUI Message-ID: <20000702130610.A31857@inkontact.com.au> The latest release of the PyUnit unit testing framework features a long overdue Tkinter based GUI akin to that of Java's JUnit. Should work straight out-of-the-box with most Python installations. Modules being tested are automatically reloaded each time they are run, so the GUI can be left running while you code and debug. As usual, interested parties can find out more at http://pyunit.sourceforge.net/ Go on, write some tests; you know you want to! Pythonic best wishes to all, -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ From ge at nowhere.none Fri Jul 7 14:03:17 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 07 Jul 2000 18:03:17 GMT Subject: Help me.....please References: Message-ID: In article , Occute wrote: >when ever i try to use the command else: in python it gives me a error.....i >even coppied a exact eg from the manual and it still gives me the same error Post the program you're trying to run and the error message you get. -- Grant Edwards grante Yow! Quick, sing me the at BUDAPEST NATIONAL ANTHEM!! visi.com From moshez at math.huji.ac.il Tue Jul 18 02:32:44 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 18 Jul 2000 09:32:44 +0300 (IDT) Subject: newbie unimpressed... In-Reply-To: <8kvp81$9q1$1@nnrp1.deja.com> Message-ID: On Mon, 17 Jul 2000 sharkey3 at my-deja.com wrote: > Example: where is the % operator documented for strings? In the library reference, under "standard types" -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From robin at jessikat.fsnet.co.uk Tue Jul 18 13:54:40 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 18 Jul 2000 18:54:40 +0100 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: I suppose there must be something desperately wrong with using the __mul__ for sequences to indicate the set pairwise product. I would certainly be for x,y in A*B rather than x,y in zip(A,B) or marry(A,B), but since * is the obvious operator it must be that someone else has reserved it. -- Robin Becker From tim_one at email.msn.com Sat Jul 22 03:29:58 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 22 Jul 2000 03:29:58 -0400 Subject: zip or marry etc In-Reply-To: Message-ID: [Michael Hudson] > However, it looks very much as though it's going to be called "zip". Indeed, Guido called it "zip" during his "State of Python" keynote address at the O'Reilly conference on Thursday, and demo'ed it live in an IDLE shell. If he changes the name now, he'll doubtless get sued <0.9 wink>. > move-along-folks-nothing-to-see-here-ly y'rs > M. except-for-pain-&-suffering-ly y'rs - tim From fiona at sitegnome.com Thu Jul 13 17:40:19 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 13 Jul 2000 21:40:19 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 13th, 2000 Message-ID: <20000713214019.24273.qmail@synop.com> Hi guys, I'm a little confused :-) yesterday I'm pretty sure I sent out a summary to the list, it doesn't seem to have made it though so this is a second attempt. Apologies if it makes it twice now. So, what's been entered into http://python.faqts.com: - How can you check on the status of a file's "archive" bit, on DOS-type platforms - What Python code can I use to find all the network ports that are in use on a server? - Can I use python to access web (eg.yahoo) email account? - Is there any way to find the mount point of a filesystem given the path to a file within the file system? - How can I create a wxBitmap image from a Python Imaging Library (PIL) image? - How can I compare two strings in a case-insensitive way? - What is wxPython? How does it compare with Tkinter? - Bidirectional communication through pipes: read/write popen() cheers, Fiona ## Unanswered Questions ######################################## ------------------------------------------------------------- How can you check on the status of a file's "archive" bit, on DOS-type platforms http://www.faqts.com/knowledge-base/view.phtml/aid/4706 ------------------------------------------------------------- Barry Pederson ## New Entries ################################################# ------------------------------------------------------------- What Python code can I use to find all the network ports that are in use on a server? http://www.faqts.com/knowledge-base/view.phtml/aid/4684 ------------------------------------------------------------- Fiona Czuczman Aaron Berg to figure out what ports are used on a server you could use netstat -a -n import os popen("netstat -a -n") ------------------------------------------------------------- Can I use python to access web (eg.yahoo) email account? http://www.faqts.com/knowledge-base/view.phtml/aid/4685 ------------------------------------------------------------- Fiona Czuczman Steve Purcell For web mail accounts that have POP access, such as Yahoo, check out the 'poplib' standard library module: http://www.python.org/doc/current/lib/pop3-example.html ------------------------------------------------------------- Is there any way to find the mount point of a filesystem given the path to a file within the file system? http://www.faqts.com/knowledge-base/view.phtml/aid/4686 ------------------------------------------------------------- Fiona Czuczman John Clonts I didn't find anything already extant, so here's this: def mountpoint(s): import os if (os.path.ismount(s) or len(s)==0): return s else: return mountpoint(os.path.split(s)[0]) def testit(): print mountpoint("/home/john/scheme/cmucl") print mountpoint("/usr/local") print mountpoint("/lib/") print mountpoint("lib") ------------------------------------------------------------- How can I create a wxBitmap image from a Python Imaging Library (PIL) image? http://www.faqts.com/knowledge-base/view.phtml/aid/4687 ------------------------------------------------------------- Fiona Czuczman Greg Landrum Here's some sample code: def PilImgToWxBmp(pilImg): wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1]) wxImg.SetData(pilImg.tostring()) bmp = wxImg.ConvertToBitmap() return bmp ------------------------------------------------------------- How can I compare two strings in a case-insensitive way? http://www.faqts.com/knowledge-base/view.phtml/aid/4688 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen import string if string.lower("FOO") == string.lower("Foo"): ## Edited Entries ############################################## ------------------------------------------------------------- What is wxPython? How does it compare with Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/3565 ------------------------------------------------------------- Fiona Czuczman, Olivier Dagenais Shae Erisson wxPython [ http://www.wxpython.org ] is a set of Python bindings for the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was written as a C++ library to provide a platform-independant way of implementing rich and fast user interfaces. I chose wxPython over Tkinter (for my projects) because: - wxWindows seems to have more widgets than Tk - special widgets (like the TreeView) are implemented using the operating system's native implementations, not complete re-writes - it's more than a "lowest common denominator" among platforms, wxWindows seeks to provide the same, advanced functionality on all platforms, even if it means they have to write a lot of code to complement a platform's native component - wxWindows seems to cover more ground, in terms of functionality (it's more than a GUI toolkit, it also seeks to provide functions/classes for files, threads, printing, clipboard, networking, ODBC, etc...) - I was *really* impressed with the wxPython demo ------------------------------------------------------------- Bidirectional communication through pipes: read/write popen() http://www.faqts.com/knowledge-base/view.phtml/aid/4448 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Hans Nowak, Snippet 259, Hrvoje Niksic """ Packages: files;miscellaneous """ ''' In all kinds of circumstances it would be very useful to call an external filter to process some data, and read the results back in. What I needed was something like popen(), only working for both reading and writing. However, such a thing is hard to write in a simple-minded fashion because of deadlocks that occur when handling more than several bytes of data. Deadlocks can either be caused by both programs waiting for not-yet-generated input, or (in my case) by both their writes being blocked waiting for the other to read. The usual choices are to: a) Write a deadlock-free communication protocol and use it on both ends. This is rarely a good solution, because the program that needs to be invoked is in most cases an external filter that knows nothing about our deadlock problems. b) Use PTY's instead of pipes. Many programmers prefer to avoid this path because of the added system resources that the PTY's require, and because of the increased complexity. Given these choices, most people opt to use a temporary file and get it over with. However, discussing this problem with a colleague, he thought of a third solution: break the circularity by using a process only for reading and writing. This can be done whenever reading and writing are independent, i.e. when the data read from the subprocess does not influence future writes to it. The function below implements that idea. Usage is something like: rwpopen("""Some long string here...""", "sed", ["s/long/short/"]) -> 'Some short string here...' I've put the function to good use in a program I'm writing. In addition to getting rid of temporary files, the whole operation timed faster than using a tmpfile (that was on a single-CPU machine). The function will, of course, work only under Unix and its lookalikes. Additional information is embedded in the docstring and the comments. I'd like to hear feedback. Do other people find such a thing useful? Is there a fundamental flaw or a possibility of a deadlock that I'm missing? ''' def rwpopen(input, command, args=[]): """Execute command with args, pipe input into it, and read it back. Return the result read from the command. Normally, when a process tries to write to a child process and read back its output, a deadlock condition can occur easily, either by both processes waiting for not-yet-generated input, or by both their writes() being blocked waiting for the other to read. This function prevents deadlocks by using separate processes for reading and writing, at the expense of an additional fork(). That way the process that writes to an exec'ed command and the process that reads from the command are fully independent, and no deadlock can occur. The child process exits immediately after writing. More precisely: the current process (A) forks off a process B, which in turns forks off a process C. While C does the usual dup,close,exec thing, B merely writes the data to the pipe and exits. Independently of B, A reads C's response. A deadlock cannot occur because A and B are independent of each other -- even if B's write() is stopped because it filled up the pipe buffer, A will happily keep reading C's output, and B's write() will be resumed shortly. """ # XXX Redo this as a class, with overridable methods for reading # and writing. # # XXX Provide error-checking and propagating exceptions from child # to parent. This would require either wait()ing on the child # (which is a bag of worms), or opening another pipe for # transmitting error messages or serialized exception objects. # # XXX This function expects the system to wait for the child upon # receiving SIGCHLD. This should be the case on most systems as # long as SIGCHLD is handled by SIG_DFL. If this is not the case, # zombies will remain. def safe_traceback(): # Child processes catch exceptions so that they can exit using # os._exit() without fanfare. They use this function to print # the traceback to stderr before dying. import traceback sys.stderr.write("Error in child process, pid %d.\n" % os.getpid()) sys.stderr.flush() traceback.print_exc() sys.stderr.flush() # It would be nice if Python provided a way to see if pipes are # bidirectional. In that case, we could open only one pipe # instead of two, with p_readfd == p_writefd and c_readfd == # c_writefd. p_readfd, c_writefd = os.pipe() c_readfd, p_writefd = os.pipe() if os.fork(): # Parent for fd in (c_readfd, c_writefd, p_writefd): os.close(fd) # Convert the pipe fd to a file object, so we can use its # read() method to read all data. fp = os.fdopen(p_readfd, 'r') result = fp.read() fp.close() # Will close p_readfd. return result else: # Child try: if os.fork(): # Still the same child os.write(p_writefd, input) else: # Grandchild try: # Redirect the pipe to stdin. os.close(0) os.dup(c_readfd) # Redirect stdout to the pipe. os.close(1) os.dup(c_writefd) # Now close unneeded descriptors. for fd in (c_readfd, c_writefd, p_readfd, p_writefd): os.close(fd) # Finally, execute the external command. os.execvp(command, [command] + args) except: safe_traceback() os._exit(127) except: safe_traceback() os._exit(127) else: os._exit(0) From see at my.signature Tue Jul 25 00:43:06 2000 From: see at my.signature (Greg Ewing) Date: Tue, 25 Jul 2000 16:43:06 +1200 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> <397BDCC6.9C498F01@my.signature> <397BF66A.EF8BDEF4@prescod.net> Message-ID: <397D1ADA.A8074086@my.signature> Paul Prescod wrote: > > Then I can only presume that you look up the __get_?? method *first* > before falling back to the "real" version. That will slow down plain old > ordinary "gets" when there is no __get_?? method. It seems I made a mistaken assumption about why you chose to tie the three accessor together. I can see your reason now. In my version, there would be flags in each class indicating whether it had any accessors of each of the three types, so classes without any accessors would not be affected. For classes with accessors, there would be an extra dictionary access for an attribute with no accessor, so it would be slightly slower than yours in that case. But it would still be a lot better than the current situation with __getattr__/__setattr__, which incurs a Python function call for every attribute access. So as usual it's a tradeoff between simplicity and ease of use, and squeezing out the last ounce of speed. I'd rather see a simpler design even if it's a little bit slower -- that seems to be the Python way. If you're still interested, here are the gory details: Each class has three flags: has_get_accessors, has_set_accessors, has_del_accessors. These are set whenever an appropriately-named method is added to the class. Each instance also has the same three flags. These are set at instance creation time if the corresponding flags are set in the class or any of its superclasses. To get attribute attr_name: if attr_name is in the instance dict: return it else: if the instance's has_get_accessors flag is set: translate attr_name to interned get_accessor_name using cache for each class along the inheritance path: if the class's has_get_accessors flag is set and it contains a method called get_accessor_name: call it and return the result else: if the class contains an attribute called attr_name: return it raise AttributeError To set attribute attr_name: if the instance's has_set_accessors flag is set: translate attr_name to interned set_accessor_name using cache for each class along the inheritance path: if the class's has_set_accessors flag is set and it contains a method called set_accessor_name: call it and return set attr_name in the instance dict To delete attribute attr_name: if the instance's has_del_accessors flag is set: translate attr_name to interned del_accessor_name using cache for each class along the inheritance path: if the class's has_del_accessors flag is set and it contains a method called del_accessor_name: call it and return delete attr_name from the instance dict -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From matt at nightrealms.com Mon Jul 17 17:52:40 2000 From: matt at nightrealms.com (Matthew Cline) Date: Mon, 17 Jul 2000 13:52:40 -0800 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> Message-ID: In article <397296BC.415C97E1 at prescod.net>, Paul Prescod wrote: > Matthew Cline wrote: >> >> def my_func(foo, bar, quux): >> if not isinstance(quux, Quux): >> raise RuntimeError("param 'quux' must be of class 'Quux'") > > Let me also point out that in many cases, this style of programming > would be frowned upon by serious Python programmers. For instance, > if you check that something is a string, your code will complain > when it is handed a Unicode string, even though it would probably > work fine. If you check that it is an open file, then your code > probably will complain about stringIO file-like objects, even though > it would probably work fine. That's another reason why I'd like the type checking to be done by the Python compiler, because it could be intelligent about those things. Like for "list" it could accept a tuple, a list, or anything derived from UserList. From rgparker at west.net.bbs Mon Jul 17 21:00:04 2000 From: rgparker at west.net.bbs (rgparker at west.net.bbs) Date: 18 Jul 2000 01:00:04 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bRVR3$jO2@openbazaar.net> Mark, Do you envision non-MS affiliated groups writing IL-to-native compilers for other (non-Windows) operating systems? In other words, will this IL stay as a Windows-only sort of deal? Also, could Java be compiled to IL if someone wanted to write a compiler for it? In news:<8kld9h$489$1 at nnrp1.deja.com>, MarkH at ActiveState.com says... > In article , > "Neil Hodgson" wrote: > > Now that Microsoft have revealed their Intermediate Language (IL) > > virtual machine, are we going to see a version of Python that > > compiles directly to IL? Or will Python byte codes still be > > interpreted by C code? > > Directly to IL - although there is still a runtime that handles some of > the Python semantics. > > This new compiler could be compared, conceptually, with JPython - it is > a completely new implementation of Python. It has a compiler that > generates native Windows .DLL/.EXE files. It uses a runtime that > consists of a few thousand lines of C# (C-Sharp) code. The Python > programs can be debugged at the source level with Visual Studio 7, as > well as stand-alone debuggers for this environment. Python can sub- > class VB or C# classes, and vice-versa. > > Unfortunately, there will not be a public release of their SDK for a > couple of months - so the only people able to use this compiler are > people who attended the PDC, and hence have the pre-beta SDK on their > conference CDs. > > The compiler is looking pretty reasonable. pystone.py (amongst others, > of course) compiles and runs. > > However, this should be quite exciting for the Python community. The > general feel of the conference here is that the MS .NET technology is > exciting and a good thing. I predict that the Windows community will > embrace this technology, and having Python be a first-class citizen is a > good thing! It _is_ a radical change. > > Future work on this compiler will be under the ActiveState banner. > However, the compiler and the runtime are all open source. The > compiler is written in CPython, and uses win32com to get at the > Reflection::Emit APIs provided by .NET. All the existing work has been > done mainly by me, with some code and advice from Greg Stein. Now the > NDA is lifted, I hope (some of) the Python community will get behind > this, and take advantage of the open-sourceness of the compiler and > runtime, and help us turn this into an excellent language for this > environment. > > All good stuff (IMO, of course) > > None of this is speaking for ActiveState - just my personal opinion. > > Mark (still at the PDC!) > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > From aaron.ginn at motorola.com Fri Jul 7 16:01:07 2000 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 07 Jul 2000 13:01:07 -0700 Subject: Flushing sdtout References: <8k59fb$2quui$1@fido.engr.sgi.com> Message-ID: pj at sgi.com (Paul Jackson) writes: > Aaron asks: > |> Is there a simple way to flush stdout on every print > > How about 'python -u': > > -u Force stdin, stdout and stderr to be totally > unbuffered. > > (which I found by grepping for 'setbuf' in the source > code and tracing backwards to see how it was controlled) This works fabulously Paul. Thanks! This even resolves the issue I had with the ecohing the input statement strings. Thanks again! Aaron -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From skip at mojam.com Mon Jul 10 17:57:35 2000 From: skip at mojam.com (Skip Montanaro) Date: Mon, 10 Jul 2000 16:57:35 -0500 (CDT) Subject: Run Python as separate process with Apache? In-Reply-To: References: <14697.3435.929500.668699@beluga.mojam.com> Message-ID: <14698.18127.840603.46427@beluga.mojam.com> Randall> In news:<14697.3435.929500.668699 at beluga.mojam.com>, skip at mojam.com Randall> says... Randall> 1) Have a persistent Python process that processes http Randall> requests. >> >> Yup, Medusa, Zope, the ZServer part of Zope (which is a lightly >> touched up Medusa), Randall> Is ZServer written in Python? Yup. There may be a helper module or two written in C, but they would be small things. Randall> Is all of Zope a Python-based app server? Yes, pretty much. Randall> I went and looked at the http://www.zope.org site (I've seen Randall> Jon Udell rave about it in the past btw) and saw that it sounds Randall> like it is somehow more tightly tied to Python than to other Randall> scripting languages. Is that correct? Well, you can write new methods or products in Python and you can write methods in HTML. ActiveState is working on methods in Perl I believe, but I don't know the timeframe. >> or something based on the HTTPServer class in the Python core should >> do the trick. I use ZServer listening on 127.0.0.2 at port 9673 and >> have Apache running on the same machine with proxy support. It then >> proxies to the server only those things I want the ZServer to see. Randall> So there is a plug-in for Apache that can route requests to Randall> ZServer? I just use mod_rewrite to map interesting requests, e.g.: RewriteRule ^/(.*)\.shtml http://127.0.0.2:9673/filter?file=$1.shtml [P] which says to map any .shtml requests to the filter method on the ZServer. Randall> So this is possible to do with Apache and ZEngine and Apache Randall> can still handle all URLs that don't have a leading /webapps Randall> pattern? *Everything* is possible with mod_rewrite... ;-) >> My ZServer then talks to a MySQL database using the MySQLdb module. >> If you want SQL connection capability I suspect you'll find Zope is >> much closer to a complete solution. Randall> Does ZServer support other RDBMSs? Yes, though I'm not expert enough to know all of them. I know they support Gadfly and Oracle. Don't know about Postgres. Randall> With the Servlet API the actual act of asking for a session id Randall> causes the Tomcat engine (or any servlet api compliant Randall> container) to create one if it already doesn't exist and then Randall> to go set a cookie on the client browser all seamlessly without Randall> your having to do anything. Then it will do timeouts on the Randall> session id based on how long since it was last asked for. I'm Randall> hoping I can find something as slick and automatic in the Randall> Zope/Python world. I wouldn't be surprised. You might want to ask at zope at zope.org. -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From pehr at pehr.net Thu Jul 20 01:29:56 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 20 Jul 2000 05:29:56 GMT Subject: Locating Python modules References: <31575A892FF6D1118F5800600846864D4C706A@intrepid> Message-ID: <39768E53.63C422A3@pehr.net> Dear Simon, Distribution Packages Rant: In the linux world, this problem is pretty much licked. People build RPM packages which can be installed with a single command. Every machine keeps an RPM database to track where all the files went and what to do when you want to uninstall that package. If differnet platforms put python in different places, you end up with platform specific "binary" RPMS. No big deal. RPM can even do a nifty verification test to see if any of the files have changed. Of course, if you are stuck in windows world, you have to suffer the slings and arrows of maintaining *anything* under windows. The usual method is install everything on top of eachother, then when it gets so messy it starts to break, reinstall everything from scratch. No on to the files themselves: To keep stuff separate, you don't need everything in your python path. You can include an __init__.py file in the subdirectory containing your files. All this file has to do is include the relevant modules from that dir. Look at how __init__.py is used within the python distribution for more detail. It's pretty simple in the base case. With __init__.py in place, python will be able to find modules hidden in your subdirectory off of the default pythonpath directory. -pehr Simon Brunning wrote: > > I'd like to organise the Python modules that I have downloaded in some > rational fashion. Ideally, I'd like a directory to keep them all in, with > each in a separate sub-directory. I don't want to keep all these directories > in my PYTHONPATH. > > Is there some de-facto standard way of organising this? > > If not, what methods of organisation do people use, and what are the pros > and cons of the various methods? > > 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 achim.domma at syynx.de Fri Jul 28 11:48:20 2000 From: achim.domma at syynx.de (Achim Domma) Date: Fri, 28 Jul 2000 17:48:20 +0200 Subject: compile.py Message-ID: <8ls9ve$9og$15$1@news.t-online.com> Hi, I'm looking for compile.py of David Ascher, but it seams that all links are broken. Could somebody give me a link or send the file ? thanks Achim From bdupire at seatech.fau.edu.bbs Mon Jul 17 02:00:01 2000 From: bdupire at seatech.fau.edu.bbs (bdupire at seatech.fau.edu.bbs) Date: 17 Jul 2000 06:00:01 GMT Subject: PyArg_NoArgs / PyArg_Parse API Message-ID: <3bR1g1$hW6@openbazaar.net> Benoit Dupire wrote: > PyArgs_NoArg(args) is an API function, used in timemodule.c and not > referenced in the documentation.. > > Actually, it's defined as a macro in Python.h > and is equivalent to PyArg_Parse(args,"") > > I didn't see Py_ArgParse in the doc either! OK I finally find out the answer. Thanks Mark, for your "programming Python" book! PyArg_Parse: takes an object, a format string, and C targets. (like PyArg_ParseTuple) But PyArg_Parse doesn't expect the Python object to be a tuple. We need to supply () pairs in the format string to extract parts of returned tuples. PyArg_Parse is also backward compatible with an older conversion variant (getargs) If the third column in a module's name/function registration table is zero (or absent), Python passes argument lists using old-style getargs conventions : the argument list might not be a tuple, so PyArg_Parse is used to extract values. But normally the third column in a module's name/function registration task should be 1, and PyArg_ParseTuple should be used for argument list conversions Benoit! :-) From neilh at scintilla.org Tue Jul 25 08:29:28 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 25 Jul 2000 12:29:28 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> Message-ID: > Anyone knows more about what will be Python 3000 ? It seems that it will be > the next evolution of this language, after the 1.7 version. The big issue is > that Python 3000 would not be compatible withe the actual 1.n language !? > How it is possible and what it means ? Don't worry. Python 3000 is a dream that Guido has where he can change Python in an incompatible way. The volume of upset that will ensue should he try this will quickly force him back in line. BDFL? More slave-for-life than dictator! Your version numbering is a little out of date - 1.6 will be released in the near future with some quite useful Unicode support, then 2.0 with some unnecessary features soon after that. 2.0 is called 2.0 to help with marketing although the sweet spot with version number marketing is 3.11 so some more unnecessary features will be required soon :-) Neil From Armin at Steinhoff.de Sat Jul 15 05:26:18 2000 From: Armin at Steinhoff.de (Armin Steinhoff) Date: 15 Jul 2000 02:26:18 -0700 Subject: Setting a C-structure from Python References: <39649D5C.F1652171@seatech.fau.edu> <396F6449.F2E63F85@seatech.fau.edu> Message-ID: <8kpanq$2t99@drn.newsguy.com> In article <396F6449.F2E63F85 at seatech.fau.edu>, Benoit says... > > >Armin wrote: >-------------------------------------------------------------- > > I have changed your code in the following way: > > static PyObject * test_setstruct(PyObject * self, PyObject * args) { > //PyObject * string_from_python; > > char * string_from_python; > int len; > > // if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; > if (!PyArg_ParseTuple(args,"s#",&string_from_python, &len)) return NULL; > > // example= (examplestruct *) PyString_AsString(string_from_python); >example= (examplestruct *) string_from_python; > > // Py_DECREF(string_from_python); > print_struct(); > > Py_INCREF(Py_None); > return Py_None; > } > ---------------------------------------------------- > >Ok it works too! You convert the PythonString in a C string representation >right away with PyArgs_ParseTuple. > > > >Now, I changed the test_getstruct function in the same way.. > >static PyObject * test_getstruct(PyObject * self, PyObject * args) >{ > if (!PyArg_ParseTuple(args,"")) return NULL; ^^ ??? > return Py_BuildValue("s",(char *)exampleptr); ^ ^ "s#" exampleptr, len); ... then it should work :-) Greetings Armin BTW ... remove in the qnx_send procedure the Py_BuildValue() call ... its garbage. ( 'qnxmodule' ) >} > > >Yes.. it was too easy : it doesn't work : > Traceback (innermost last): > File "", line 1, in ? > File >"//1/old_home/bdupire/Alpha/morpheus/Python-1.5.2/Lib/my_prog/structure.py", >line 24, in ? > a =struct.unpack(fmt,rec) >struct.error: unpack str size does not match format > >So my question is the following: how to tell Py_BuildValue about the size of >the structure and the number of bytes to grab ? > From hzhu at localhost.localdomain Thu Jul 13 15:05:38 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 13 Jul 2000 19:05:38 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <396CB0D3.8F7BC8E5@prescod.net> Message-ID: On 13 Jul 2000 01:02:15 +0200, Bernhard Herzog wrote: >In this case I think a factory function would be much cleaner: > >def instantiate(data): > if data is something: > return Special1(data) > else: > return Special2(data) > >Putting knowledge about what derived classes exist into the base class >is the wrong approach, IMO. You obviously have to have knowledge about >the derived classes somewhere in the code, and the right place for that >is a factory function or something similar outside of the class >hierarchy. > In the examples I have in mind, most knowledge about the data is held in the base class. The derived classes only override a few method in applications. So I suppose your suggestion would be like def instantiate(data): General.preprocess(data) if General.someproperty(data): return Special1(data) else: return Special2(data) Yes, it looks cleaner because there will not be any issue with overrided __init__ or the like. Several others have said that in this case there is no need to have the base class. Of course this is only true of the example, but not of the real situation from which it's abstracted. Huaiyu From Ed_Stauff at avid.com Sun Jul 30 20:39:07 2000 From: Ed_Stauff at avid.com (Ed Stauff) Date: Mon, 31 Jul 2000 00:39:07 -0000 Subject: Why won't Python connect to C++ socket on NT? Message-ID: <8m2hrb+g395@eGroups.com> I'm trying to get a Python TCP client to talk to a C++ TCP server via sockets, and I keep getting "connection refused". I have no trouble getting a C++ client and a C++ server to talk to each other, and I can get two Python interpreters to connect to each other via sockets. But I can't seem to get Python to connect via sockets to any server written in C++. One sample server is extremely simple, taken from Comer's TCP/IP book. The few lines of Python code I'm using are taken right from the example given in the socket module. What could be going wrong? I'm a newbie at Python and sockets, but experienced in C++. I'm using Python 1.5.2 on Windows NT; the C++ code is in Visual C++ 6. My client and server are (for testing purposes anyway) running on the same machine. Any help will be greatly appreciated! Thanks, -- Ed From hinsen at cnrs-orleans.fr Fri Jul 21 06:08:23 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 21 Jul 2000 12:08:23 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: > As far as I'm aware, multiarray necessarily involves indices. So infix > operators are not so useful, until a class with index labels are defined. I tend to agree, at least when N-d arrays are used to represent rank-N tensors. Moreover, there aren't many applications where rank-N tensors are needed in *numerical* code. This should not be our main concern for infix operators. However, higher-rank arrays are often used with a different interpretation: arrays of vectors or matrices. For example, I might have a rotation matrix at each time step of some simulation, or a polarizability tensor for each particle. For these cases it makes sense to extend the meaning of the infix operators to higher-rank arrays. The cleanest concept (in my opinion) is the one implemented in J, where an array has (conceptually) a "data rank" and a "value rank", the sum of the two being the rank, i.e. the number of indices. For example, an array of rank 3 could be interpreted as a list of matrices (data rank 1, value rank 2), as a matrix of vectors (data rank 2, value rank 1), or as a 3-d array of scalars (data rank 3, value rank 0). In J the data and value ranks are not properties of the arrays, but of the operators, whose value rank can be modified. In the early days of NumPy development, I proposed this model for NumPy as well, but there was no majority for it. And I agree that there are not so many practical cases where this mechanism is necessary. However, it nicely illustrates how one would extend vector and matrix operations to higher-dimensional data. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From michael at stroeder.com Mon Jul 3 04:54:57 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 10:54:57 +0200 Subject: Python CGI security References: Message-ID: <396054E1.ED99677C@stroeder.com> "E. Jordan Bojar" wrote: > > Are there security issues particular to (or common with) Python CGIs, Additional info: - Have a close look at all os.system() and os.popen() calls. - Use smptlib instead calling sendmail via os.system(). - Build a framework for strict form parameter checking. (I have such a module. Feel free to ask for it.) Ciao, Michael. From ssthapa at midway.uchicago.edu Wed Jul 12 01:39:04 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Wed, 12 Jul 2000 05:39:04 GMT Subject: finding mount points References: <396C0076.4A6547A3@mastnet.net> Message-ID: John Clonts wrote: >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> import posixpath >>>> posixpath.ismount("/") >1 >>>> posixpath.ismount("/mnt") >0 >>>> posixpath.ismount("/mnt/dosd") >1 >>>> posixpath.ismount("/home") >1 >>>> posixpath.ismount("/home/john") >0 Actually, I wanted something like >>>mountpoint('/home/john') >/home >>>mountpoint('/home') >/home I suppose I could do a recursive solution where I start with the full path and take away directories and check to see if its a mount point using ismount but I was hoping there was a module or way to find the mount point directly. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From huaiyu_zhu at yahoo.com Tue Jul 18 20:21:04 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Tue, 18 Jul 2000 17:21:04 -0700 (PDT) Subject: On special syntax (was Re: Matlab vs Python ...) Message-ID: I sent this out this morning and it hasn't appeared. Sorry if it duplicates. On Tue, 18 Jul 2000, Moshe Zadka wrote: [snip: a long python code and short perl equivalent] > It's more verbose, and people are able to understand it without learning > weird corners of the language. (BTW: as a former Perl hacker, I find the > Perl code *extremely* readable, and I spend more time understanding the > Python code. But that doesn't change the fact that Perl took me longer to > master then Python, and even then I didn't really understand Perl. For > example, could I lose the ";" in the Perl code? I think so, but I'm not > sure) > Ok, since the issue of additional binary operators has been repeatedly compared with various features of Perl that people dislike, without much details, it might be worthwhile to give it some more thoughts here. We've already seen that the "it has a small userbase" argument is largely vacuous. I hope to show "it is like Perl" argument is also of similar nature. So let me first describe what I dislike Perl. The best I can summarize include these aspects: 1. There are many special syntax zones: - The formats - The here document - The regular expressions - Things within ${...}, @{...}, %{...}, etc - trailing if, unless, etc - file handling - BEGIN {...} END {...} - some other things that doesn't come to mind :-) I say special syntax zone instead of special syntax constructs because these things do not really have their own scope. They are not atomic. For example, you can have different levels of variable substitution within regular expressions. The disadvantage of this is that these things really all live in a larger scope but they still play by their own rules. You have to switch your mental context going from one zone to the other. In contrast, python has very few special syntax zones. For example, a string literal has its own rule, whether it is used for formats, multiline strings or regular expression. They interact only through given interface, like as arguments or return values of a function. If you can use multiline string in print statements, you can also use it elsewhere string is used. 2. The scope, precedence and context of the special zones vary greatly: - It is hard to know where do $_, $1, etc get values - regular expression can be like s/2+3/t+1/g, which is also valid math formula. - evaluation of rhs of assignment also depend on the context coming from lhs: list or scalar. The whole thing can be part of expression. - classes defined with package statement with silly scoping rules. - print<<{$b}}[2]. (Sorry if it is wrong - I'm forgetting how to make it right now.) Now back to our topic. Which aspect of the new operators look like Perl? 1. They do not introduce a special syntax zone. Or if you insist, they introduce special zones of two characters. 2. They do not have any ambiguity of scoping, precedence and context. They obey exactly the same rules of the old operators. They always appear between two objects, and produce a new object. The operations do not depend on context other than precedence. 3. There are no more magic things than the definition __dotmul__ etc that associates the symbol with method name, just like other operators do. There might be an argument that special characters are hard to read. As I said, they are hard to read mainly because of their magical effects. Operator names have even less such effects than the familiar python constructs like quote, bracket, colon and indentation. Of course if it gets too long like @#$% it will be causing readability problem of its own. I don't think we are going that route if they are defined within each module through __methodname__. In contrast, several of proposals for avoiding the new operators do look to me like introducing special syntax zone delimited by various combination of arcane combination of symbols. I see the new operators as introducing absolutely no long range interdependencies other than reusing existing operator precedence. I hope this clarifies some issue concerning just how special are these new operators. If there are examples comparing them with proposed special syntax rules for xml, sql etc, please describe what they are, what they are for, why they are not good, why the alternative is better, and what aspects can summarize the comparison. I'm sure we'd all be wiser after reading those. Huaiyu From fiona at sitegnome.com Tue Jul 11 07:54:16 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 11 Jul 2000 11:54:16 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 11th, 2000 Message-ID: <20000711115416.17399.qmail@synop.com> Hello All, Another instalment of edited, or newly entered, entries into http://python.faqts.com regards, Fiona Czuczman including: - module for continued fractions, useful for finding optimal fractional approximation to real numbers - How do I use Windows API in Python? With an example please. - I'm new to Python and would appreciate advice on what book(s) I should be looking at? - Is there a utility to convert module docstrings to HTML for nice documentation? - What is lambda? ## New Entries ################################################# ------------------------------------------------------------- module for continued fractions, useful for finding optimal fractional approximation to real numbers http://www.faqts.com/knowledge-base/view.phtml/aid/4649 ------------------------------------------------------------- Fiona Czuczman Huaiyu Zhu #!/usr/bin/env python # (C) 2000 Huaiyu Zhu . Licence: GPL # $Id: ContFrac.py,v 1.3 2000/07/10 05:09:11 hzhu Exp $ """ ContFrac.py - Continued fraction approximation utilities Convert between float, continued fraction and fractions. Useful for finding optimal rational approximation at any precision. Usage examples: python ContFrac.py Representation: Continued fraction: list of integers. Ordinary fraction: pair of long integers. Optional variables in the functions: nterm: max number of terms in continued fraction. prec: precition (inverse relative error) - maybe too conservative? """ def cf2real(cf): "Convert to float from continued fraction" x = 0. for i in range(1,len(cf)+1): x = 1./(cf[-i] + x) return 1./x def real2cf(x, prec=1e16, nterms=40): "Convert to continued fraction from float" cf = []; p = 1.; a = 1 for i in range(nterms): a, a0 = int(x), long(a) cf.append(a) p = p * (abs(a*a0) + 1) if p > prec or abs(x-a)<1e-12: break x = 1./(x-a) "Merge last term if it is one, so the expression is unique" n = len(cf)-1 if cf[n] == 1: cf[n-1]=cf[n-1]+1; del cf[n] return cf def cf2frc(cf, prec=1e16): "Convert to fraction from continued fraction" "Estimates term n that achieves precision - need better algorithm" p = 1.; n = 0 for n in range(1, len(cf)): p = p * (cf[n-1]*(cf[n]+.5)+1) if p >= prec: break "Conversion using first n terms" x, y = long(cf[n]), 1L for i in range(n): x, y = x*cf[n-1-i] + y, x return x, y def frc2cf(frc): "Convert to continued fraction from fraction" cf = [] x, y = frc while 1: if y == 0: break a, b = x/y, x%y cf.append(a) x, y = y, b return cf #------------------------------------------------------------------ def test(x, prec, nterms): print "Convert %.16f to continued fraction and back to float" % x cf = real2cf(x, nterms=nterms) print cf, cf2real(cf) print "Convert to fraction and back to float, limit precision: %g" %prec print "num. of terms fraction float error" for n in range(1, nterms+1): f = cf2frc(cf[:n], prec) r = f[0]/float(f[1]) print "%2d %33s % .16f %- 8.4g" % (n, f, r, r/x-1) if __name__ == "__main__": from math import pi, exp, sqrt print "------------ Effect of too much precision and terms ------------" test(-0.6667, prec=1e19, nterms=6) print "------------ Effect of limited number of terms ----------------" test(pi, prec=1e16, nterms=6) print "------------ Effect of limited of precision --------------------" test(exp(1), prec=1e4, nterms=9) # Interesting pattern in continued fraction of e. print "------------ Conversion between fraction and continued fraction" cf = real2cf(1/sqrt(2), nterms=17); print cf f = cf2frc(cf); print f cf1 = frc2cf(f); print cf1 if cf == cf1: print "Idential" else: print "Something wrong" ------------------------------------------------------------- How do I use Windows API in Python? With an example please. http://www.faqts.com/knowledge-base/view.phtml/aid/4651 ------------------------------------------------------------- Fiona Czuczman Neil Hodgson You should grab Mark Hammond's Win32 extensions from http://starship.python.net/crew/mhammond/ which includes the Pythonwin development environment. For an example, start Pythonwin, and you should an Interactive Window. Into that window type (just the bit after ">>>"): >>> import win32api this loads definitions of the core Windows API. Then call an API with >>> win32api.Beep(3000,300) As you press the "." a list of the available calls should appear. You can continue typing or select an item and press Tab to enter that item. Pressing enter after this typing will execute the code and produce a noise - hope you have a sound card. The online help lists all of the APIs wrapped by the Win32 extensions which includes a good proportion of the entire Win32 API. For complete descriptions of each API, you will want access to MSDN, either online at http://msdn.microsoft.com or by downloading the Platform SDK from the same site. There is a book by Mark and Andy called "Python Programming on Win32" which contains a lot of pages and a decent cover illustration. ## Edited Entries ############################################## ------------------------------------------------------------- I'm new to Python and would appreciate advice on what book(s) I should be looking at? http://www.faqts.com/knowledge-base/view.phtml/aid/2795 ------------------------------------------------------------- Fiona Czuczman Chris Lada, Snoopy :-)), Paul Winkler, Dana Booth, Frank V. Castellucci,richard_chamberlain,Alessandro Bottoni There a lots, Go to http://www.python.org/psa/bookstore/ for a list. The manning and oreilly books have sample chapters online you could look at. A range of books that should be useful when starting out with Python: - "Quick Python" by Harms, and McDonald. - If you already program, David Beasly's "Python Essential Reference" is very good. Another plus is that the book is high quality. It covers 1.5.2, is tight fast text with no little fluffy animal or snakes writhing through the text, just down to the bone reading. Snoopy :-)) wrote: If you are New to Programming, then In addition to the Tutorials found on Python's Home Page, you should get as the 1st. choice "Teach Yourself Python in 24hrs". BTY: "Learning Python" is also a very good book, but as a Newbie I found it quite overwhelming, to the point that I almost stopped learning Python. On the other hand I am very happy that I bought the "Teach Yourself Python in 24hrs". I find it considerable easier to comprehend the concepts, etc. You can read the book online at the following: http://www.pauahtun.org/TYPython/ Paul Winkler wrote: OTOH, I got "Learning Python" and I've found that after reading just the first half of the book and doing maybe 1/4 of the exercises, I had a very good grasp of the language, including classes and exceptions (both new ideas to me). From there the next step is to skim the second half looking for useful bits, or poke around in the library reference manual. But then, it did take more than 24 hours. :) [Alessandro Bottoni] I LOVE this book: "Learning Python" by Mark Lutz and David Ascher Published by O'Reilly ISBN 1565924649 It is concise, exhaustive, clean and well-organized. > How about a book about Python and XML? [Alessandro Bottoni] There is just one, and it is quite good: "XML processing with Python" By Sean McGrath Published by Prentice-Hall ISBN 013211192 > How about a book about Python for web site development? [Alessandro Bottoni] Unfortunately, the only existing book on this topic is out of print: "Internet Programming with Python" By Aaron Watters and James Ahlstrom Published by M&T Books ISBN 1558514848 If you are working on Windows, buy this book: "Python Programming on Win32" By Mark Hammond and Andy Robinson Published by O'Reilly ISBN 1565926218 If you have to develop GUIs, buy this book: "Python and Tkinter programming" By John Grayson Published by Manning ISBN 1884777813 ------------------------------------------------------------- Is there a utility to convert module docstrings to HTML for nice documentation? http://www.faqts.com/knowledge-base/view.phtml/aid/4610 ------------------------------------------------------------- Stu D, Fiona Czuczman Richard Jones,David Goodger >From http://starship.python.net/crew/danilo/download.html: Gendoc generates documentation from Python source code in different formats. Currently it can generate HTML, MIF, MML and plain old ascii (MIF and MML are FrameMaker formats). If you want to generate HTML files, I strongly suggest you grab a copy of Robin Friedrich's HTMLgen package, with which gendoc generates quite nice pages, optionally with frames. In addition to gendoc/HTMLgen, there are several others I know of: pythondoc (the successor to gendoc): http://starship.python.net/crew/danilo/pythondoc/ manpy: http://www.lfw.org/python/ crystal: http://www.btinternet.com/~tratt/comp/python/crystal/index.html structured text (part of Zope; used by several of these projects): http://www.zope.org/Members/millejoh/structuredText ------------------------------------------------------------- What is lambda? http://www.faqts.com/knowledge-base/view.phtml/aid/4136 ------------------------------------------------------------- Fiona Czuczman Warren Postma, david_ullrich 1) Meta-Answer: Read the FAQ and Manual sections. 2) Instant Gratification Answer Here's a standard function definition: def func(x): return x *2 Here's a way to write the same thing, in effect, but using Lambda: func = lambda (x): x * 2 While that example isn't useful, it gives you the idea. Think of lambda as a way to generate a function and return that function as an object, without having to give it a name. I primarily use it to pass an algorithm or expression as a parameter to a function, or other places where I want to pass code in a variable instead of passing a reference to a method containing that code. ------------ What it does is allow you to construct "anonymous functions". Oops, not my own words. The syntax lambda x: [expression in x] is itself an expression - the _value_ of the expression "lambda x: [expression in x]" is a function which returns [expression in x] when passed x. For example "lambda x: x+x" is a function that returns x+x; saying f = lambda x: x+x has the same effect as saying def f(x): return x + x But you don't usually use it that way - people use lambda when they want to pass a function to some routine without having to make up a name for the function. For example map takes a function as a parameter; saying print map(lambda x: x+x, [1,2,3]) is the same as saying def f(x): return x + x print map(f, [1,2,3]]) You should note there's varying opinions on whether lambda is a good thing - if you're a beginner at programming as well as with Python it's not the first thing you should worry about. From bdupire at seatech.fau.edu Thu Jul 6 14:43:31 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Thu, 06 Jul 2000 14:43:31 -0400 Subject: Bug about dynamic typing ? References: <39649D5C.F1652171@seatech.fau.edu> Message-ID: <3964D353.5D123ECB@seatech.fau.edu> bdupire wrote: > > My aim is to write an extension module to access functions in C which > "get" and "set" some structures from/in shared memory. > > It works well when I set the structure the first time, but not a second > time I have got the following (run-time) error... did I miss something? > > >>> import structure > The structure is now: > name Benoit > age 22 > rate 3.141500 > > Traceback (innermost last): > File "", line 1, in ? > File "structure.py", line 19, in ? > test_API.setstruct(packed) > TypeError: argument 1: expected string, > found > > I am working with Python 1.5.2 on QNX 4.25 > test_API.c is therefore statically linked with Python as dynamic > linking is not possible on QNX. > > file : structure.py > ----------------------------------------- > > import struct > import test_API > > #1st try > fmt="20sif" > a="Benoit" > b=22 > c=3.1415 > packed=struct.pack(fmt,a,b,c) > test_API.setstruct(packed) > > #2nd try > a="Ben" > b=23 > c=3.1417 > packed=struct.pack(fmt,a,b,c) > test_API.setstruct(packed) > > [see the c wrapper in the previous message] it works well when I use a different name for the 'packed' object the second time. i.e : #2nd try a="Ben" b=23 c=3.1417 pp=struct.pack(fmt,a,b,c) test_API.setstruct(pp) I thought variables were dynamic in Python. is there a bug, is it QNX, or is it the struct.pack function which allocates memory behind the scene ? From mark.w.daley at intel.com Mon Jul 31 15:38:14 2000 From: mark.w.daley at intel.com (Daley, Mark W) Date: Mon, 31 Jul 2000 12:38:14 -0700 Subject: Dynamic variables Message-ID: <75F7304BB41CD411B06600A0C98414FCB3682C@ORSMSX54> Does anyone know of a way to create variables on the fly, like in a loop? I want to be able to build a set of check buttons in a GUI I'm writing, and each check button needs a different variable, I think, to determine which ones are checked. I want to use a for loop to iterate over a list to build the check buttons, but I don't know the contents or length of the list. Any ideas? - Mark ---------------------------------------------- The opinions expressed are mine, and are not necessarily those of my employer. From Jonathan_Epstein at nih.gov Wed Jul 19 09:25:23 2000 From: Jonathan_Epstein at nih.gov (Jonathan Epstein) Date: Wed, 19 Jul 2000 09:25:23 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operatorsfor matrix computation) References: Message-ID: <3975AC43.827F9ACD@nih.gov> Thanks for your persistence and the clarity of your arguments, Huaiyu. I am personally swayed by the arguments for a preprocessor and a special syntax when "import matnum" appears. However, regardless of the outcome of the discussion, having Matlab-like support within Python will be A GOOD THING (tm) and something which I will use extensively, despite being a Matlab user/owner. Thanks again, - Jonathan From david_ullrich at my-deja.com Thu Jul 6 11:43:57 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Thu, 06 Jul 2000 15:43:57 GMT Subject: function arguments References: Message-ID: <8k29fq$3s5$1@nnrp1.deja.com> In article , Johannes Zellner wrote: You know about the "*args" thing? Not exactly what you asked for, but: def showargs(*args): return args print showargs('fred', 'lola') > Hello, > > is there a way to get a functions argument list ? > > e.g. > > def fun(fred, lola): > ... > > something like `arglist(fun)' should return [ 'fred', 'lola' ] > > -- > Johannes > > Sent via Deja.com http://www.deja.com/ Before you buy. From olivierS.dagenaisP at canadaA.comM Sat Jul 15 17:10:40 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 15 Jul 2000 21:10:40 GMT Subject: Anyone going to OLS? References: Message-ID: Hey, I'm in Ottawa! Where's the OLS being held? You think it's a problem if I never use Linux and I go to the OLS??? : ) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "A.M. Kuchling" wrote in message news:slrn8n1j03.i4.amk at 207-172-113-121.s121.tnt5.ann.va.dialup.rcn.com... > While lots of people will be at the O'Reilly conference next week, > I'm being contrarian and going to the Ottawa Linux Symposium instead. > Any other Pythoneers going to be there? > > --amk From guido at beopen.com Mon Jul 31 11:42:56 2000 From: guido at beopen.com (Guido van Rossum) Date: Mon, 31 Jul 2000 15:42:56 GMT Subject: Content of the Perl6 talk References: Message-ID: Moshe Zadka writes: > On Sun, 30 Jul 2000, Barry A. Warsaw wrote: > > > Probably much more useful, if possible, would be to modularize some > > key functionality that the languages have in common. The only example > > I can think of off hand would be a regexp engine. It's kind of silly > > that all three languages would support the same syntax and largely the > > same features and functionality with entirely different code bases. > > Sadly, even that's not really true. You can ask Andrew about the wonderful > fun he had trying to pry Perl's regexp engine from the clutch of > interdependancies. Perl's regexps are part of the language, and the > language is part of them (e.g., /e). But that applies to the current (Perl 5.x) codebase. For Perl 6 they are going to rewrite everything from scratch as far as I understand, so there should be some hope. Heck, maybe Effbot can offer SRE as a starting point! Most of his code doesn't deal with Python objects at all, just arrays of chars and shorts. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From jvickroy at sec.noaa.gov Mon Jul 3 11:37:36 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 03 Jul 2000 09:37:36 -0600 Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8jq7c2$2f8$1@slb6.atl.mindspring.net> Message-ID: <3960B33F.98B23C40@sec.noaa.gov> Mark isn't here yet but his book (Python Programming on Win 32) is and I quote (from page 35): " ... In many cases, the best solution is to rebuild this part of the application for Windows. On a typical Unix machine, creating new processes (as fork() does) is a relatively cheap operation. On Windows, howerver, the overhead of creating a new process is significant, so solutions using this architecture on Windows won't often scale or perform as you would hope. Rewriting this portion of the application to use multiple threads instead of multiple processes is often the best solution for Windows. " Aahz Maruch wrote: > In article <39606DAC.49A502DB at muc.das-werk.de>, > Thomas Thiele wrote: > > > >The problem is I am using threads, fork and exec. And I want to have the > >same behaviour using NT. > > You'll need to look at the Win32 extensions to do the fork/exec stuff. > I've got zero experience with that, but hopefully either the docs are > good enough or Mark Hammond will be by shortly. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz From aahz at netcom.com Mon Jul 3 10:28:59 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 14:28:59 GMT Subject: extracting tuples from a list References: <3960A07F.7240F23B@teleatlas.com> Message-ID: <8jq7vb$qo3$1@nntp9.atl.mindspring.net> In article <3960A07F.7240F23B at teleatlas.com>, Michael Husmann wrote: > >Is there a simple way to extract two elements from a list >that has a size of 2n? I going this way: > >while list: > i, k = list.pop(0), list.pop(0) > >Is there a better solution? How was the list created? Can you create it in such a way that each element is a tuple? Example: list = [] for line in file.readlines() list.append(FunctionThatReturnsATuple(line)) for item in list: (i,k) = item -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From paul at prescod.net Thu Jul 13 22:14:41 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 13 Jul 2000 21:14:41 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> Message-ID: <396E7791.EE9D36FF@prescod.net> Huaiyu Zhu wrote: > > .... > > Point 1. We _can_ assign a universal meaning to dot operators, as > "componentwise operators". For example > There is another proposal for allowing these types of operatoins: > [1, 2] .+ [3, 4] # [4, 6] [x+y; for x in [1,2], y in [3,4]] > ["a","b"] .* 2 # ['aa', 'bb'] [2*x; for x in ['a','b']] > {'a':1, 'b':1} .+ {'a':1, 'c':1} # {'a':2, 'b':1, 'c': 1} Addition isn't really defined for dictionaries. Note that this feature is more general than a fixed list of operators: [transpose(invert(x)); for x in ['a','b']] > Point 2. If users in completely disjoint domains override a certain type of > binary operators with incompatible meanings, is there great harm? Providing > a few operators for user adoptation might even prevent grotesque overriding > of more core operators. After all, there is almost endless supply of names > for classes, modules, function and so on, but there is almost no binary > operators free for adoption. Most people prefer for Python code to be very visually consistent across domains. Of course there is a tension with those who want to add domain-specific features (as I have wanted in the past). Allowing new grammars may be the best compromise. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html From robin at jessikat.fsnet.co.uk Thu Jul 13 06:34:57 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 13 Jul 2000 11:34:57 +0100 Subject: windows distribution of tcl Message-ID: <$9C+4IARtZb5EwwB@jessikat.demon.co.uk> The windows installation of Python includes much of tcl/tk, but doesn't seem to include either tclsh82.exe or wish82.exe. These programs are quite small and I wonder why they aren't included. I'm not pushing for it, but it seems strange. -- Robin Becker From grey at despair.rpglink.com Thu Jul 27 14:46:55 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 18:46:55 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> Message-ID: On Thu, 27 Jul 2000 17:47:01 GMT, Brian Steele wrote: >What good would that do? Sharks, snakes, etc. won't bite lawyers out of >professional courtesy, and since marketers are really of no substance >anyway, it would be like feeding the sharks tofu. You've obviously not seen the damage marketing can do to a company from the inside, have you? "That doesn't belong there, it is this, it belongs under this header." Nevermind that every person who understands the subject material would never look there. I never understood why I could never find my way around most large corporate websites until I hit that particular marketing directive head on. :/ -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From thomas at xs4all.net Wed Jul 19 15:55:00 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 19 Jul 2000 21:55:00 +0200 Subject: Python-dev summary: July 1-15 In-Reply-To: <8l4ph6$vj$1@nnrp1.deja.com>; from fplancke@my-deja.com on Wed, Jul 19, 2000 at 05:46:21PM +0000 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> <8l4ph6$vj$1@nnrp1.deja.com> Message-ID: <20000719215500.I9897@xs4all.nl> On Wed, Jul 19, 2000 at 05:46:21PM +0000, Fr?d?ric van der Plancke wrote: > In article <3974E8CD.55215FD9 at inrialpes.fr>, > Vladimir.Marangozov at inrialpes.fr wrote: > Sorry I'm dense, but where can I find that ? Where can I find PEP > documents ? In the CVS tree. Barry's mail on PEPs describes that, I think. They're in the 'nondist' directory. You can also browse the CVS tree using cvsweb, at SourceForge. See http://sourceforge.net/projects/python > It's bad it's so hard, hard, hard to find current information about > Python on the web starting from would-be obvious points. > (Exercise: starting from www.python.org/, find anything "mainstream" > about Python 2, or "Python-dev" ... :-( ) > (By "mainstream" I mean something like "What's new in Python 2.0" - > yes I eventally was lucky enough to get a hand on that one -- or > "table of PEP documents/proposals/..." -- these items are still > wanted, if they exist.) Agreed. A lot of that stuff needs to be updated and/or made more accessible. However, the last few months have been very hectic for the guys at pythonlabs.com, between leaving CNRI (for four of them), moving to another state (for a few of them, I believe), starting a new dept. of BeOpen, trying to get 2.0 out of the door on a very ambitious release schedule and hitting a huge brick wall so hard they left bloodsplatters all over it, magically forming the letters 'C', 'N', 'R' and 'I'.(*) > Web links on the www.python.org main page (or equivalent) > would be fine. Well, there's a problem with that: python.org is maintained by CNRI, and there are some 'issues' between BeOpen and CNRI. I'm sure that when the PythonLabs guys get some time, and the status of python.org gets a bit clearer, they'll either move it to BeOpen or start a similar website on Python 2.0 somewhere. Like sourceforge. (* That might be a bit unfair to CNRI. They did home Python for a good number of years, so they can't be all bad ;) I'm just confused by the current 'issues', and know about as much as the rest of you: nearly naught.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 15:50:09 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 19:50:09 GMT Subject: Pythonwin 1.5.2 Message-ID: <3bQXlX$ja3@openbazaar.net> Errr... In VB6, (not sure about VC6 on this one) I use the following keys to use the currently highlighted word: space, enter, Ctrl+Space and Ctrl+Enter. The "Tab" key never occured to me! It's not documented in the PythonWin documentation, either. Another PythonWin documentation quirk: Ctrl+T is listed twice as a keyboard shortcut. Once as "Transpose (swap) the current line with the line above" and later as "Toggle the use of tabs for the current file (after confirmation)" -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:838a5.12069$Tb7.82109 at news-server.bigpond.net.au... > > Oh for standards in keyboard shortcuts. What's wrong with ctrl-enter like > > Visual Studio? > > Visual Studio uses Tab. I had no idea it also allowed Ctrl+Enter. > > Neil > > > From bercovic at swi.psy.uva.nl.bbs Mon Jul 17 19:40:04 2000 From: bercovic at swi.psy.uva.nl.bbs (bercovic at swi.psy.uva.nl.bbs) Date: 17 Jul 2000 23:40:04 GMT Subject: PIL for SGI IRIX Message-ID: <3bRTN4$jm6@openbazaar.net> > My suspicion is that you've got o32/n32 issues. Correct. A solution is to edit the configure script or call configure like so, given that your zlib is in /usr/freeware/lib32 LD_LIBRARY_PATH=/usr/freeware/lib32 ./configure --with-all-kinds-of-options this sometimes works for me. What I now have resorted to doing is to actually find the bit in configure that is causing the trouble, and simple hardcode the lib-paths into configure. in the above case it would be something like this: 1. look for LIBS="-lz" in configure 2. edit the LIBS="-lz" line to something like: LIBS="-L/usr/freeware/lib32 -lz" 3. use common sense to see if any other stuff needs editing like the include declatation, which would become "/usr/freeware/include/zlib.h" 't is a pain in the butt to weed out all them little buggers, but it works everytime. hope this helps, avi PS> If someone knows how to do this in a more 'elegant' fashion - great. I've just got a feeling that autoconf is very GNU/Linux specific wrt lib locations. From mfletch at tpresence.com Mon Jul 10 16:07:16 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Mon, 10 Jul 2000 16:07:16 -0400 Subject: Anyone used IP multicast (demo/sockets/mcast.py) on NT? I'm gett ing a WSAEFAULT error Message-ID: Okay, discovered information: 1) Winsock uses a 4-byte integer (in little-endian format) for TTL, so you need to use 'I' as the struct format string. 2) Winsock has a quirk that certain implementations require that a socket be bound before you set any multicast variables. 3) Dr. Dobbs seems to think that Winsock requires that the sender also subscribe to the group. Doing all that (within a check for win32 platform) gets me to the point where the system pretends to run properly, but doesn't actually get any data through the pipe (no error messages, just nothing happening). With loopback enabled (supposed to be default), the sender should be able to read data sent to the group on it's sending port. As of yet, no luck. The revised demo is below. Help appreciated. Mike 8<_____________ mcast.py ____________ # Send/receive UDP multicast packets. # Requires that your OS kernel supports IP multicast. # This is built-in on SGI, still optional for most other vendors. # # Usage: # mcast -s (sender) # mcast -b (sender, using broadcast instead multicast) # mcast (receivers) ##MYPORT = 8123 ##MYGROUP = '225.0.0.250' MYPORT = 4711 MYGROUP = '234.5.6.7' TTL = 1 import sys import time import struct import regsub, string from socket import * def address_to_bytes( address ): bytes = map( chr, map( string.atoi, string.split( address, '.', ), ) ) return string.join( bytes, "") # Main program def main(): flags = sys.argv[1:] # if flags: sender(flags[0]) else: receiver() # Sender subroutine (only one per local area network) def sender(flag): mcastSocket = socket(AF_INET, SOCK_DGRAM) if flag == '-b': mcastSocket.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) mygroup = '' else: mygroup = MYGROUP # set time-to-live option on the socket if sys.platform == "win32": ## mcastSocket.bind( ("", 10000)) mcastSocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) mcastSocket.setblocking( 0) mcastSocket.bind( ("", MYPORT)) ttl = struct.pack( 'I', TTL ) # winsock uses a little-endian 4-byte integer # Construct struct mreq from grpaddr and ifaddr ifaddr = INADDR_ANY mreq = struct.pack('>4sl', address_to_bytes(mygroup), ifaddr) # Add group membership mcastSocket.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) ## following shouldn't be necessary, as loop back is the default ## mcastSocket.setsockopt(IPPROTO_IP, IP_MULTICAST_LOOP, '\001\000\000\000') mcastSocket.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) # else: ttl = struct.pack('B', TTL ) ## print `ttl` ## import pdb ## pdb.set_trace() mcastSocket.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl) while 1: print 'sending' data = `time.time()` ## data = data + (1400 - len(data)) * '\0' mcastSocket.sendto(data, (mygroup, MYPORT)) try: data = mcastSocket.recvfrom( 1500 ) print 'got data', data except: pass time.sleep(1) # Receiver subroutine (as many as you like) def receiver(): # Open and initialize the socket mcastSocket = openmcastsock(MYGROUP, MYPORT) # # Loop, printing any data we receive while 1: ## print 'receive' try: data, sender = mcastSocket.recvfrom(1500) while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's print sender, ':', `data` except error, value: if value.args[0] == 10035: pass else: raise time.sleep( 0.05) # Open a UDP socket, bind it to a port and select a multicast group def openmcastsock(group, port): # Import modules used only here import struct # # Create a socket mcastSocket = socket(AF_INET, SOCK_DGRAM) mcastSocket.setblocking( 0) # # Allow multiple copies of this program on one machine # (not strictly needed) mcastSocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) # # Bind it to the port mcastSocket.bind(('', port)) # # Look up multicast group address in name server # (doesn't hurt if it is already in ddd.ddd.ddd.ddd format) group = gethostbyname(group) # # Construct binary group address # # Construct struct mreq from grpaddr and ifaddr ifaddr = INADDR_ANY mreq = struct.pack('>4sl', address_to_bytes(group), ifaddr) print `mreq` # # Add group membership mcastSocket.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) # return mcastSocket main() From neilh at scintilla.org Mon Jul 17 08:39:13 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 17 Jul 2000 12:39:13 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: > And a major problem, the ^-key kills build 132 immediately, when using > the German keyboard layout. This is a known problem. It occurs inside the line key = win32ui.TranslateVirtualKey(key) found in fire_key_event in Pythonwin\pywin\scintilla\bindings.py. Mark is aware of the problem in the win32ui code, but you might want to try this short workaround while waiting for a fixed PythonWin. Just before the "if event is None:" line inside fire_key_event insert this code. if key == 220: return 1 This avoids calling win32ui.TranslateVirtualKey for the "^" key. More tests may be needed for other accent characters or other locales. Neil From hgg9140 at seanet.com Sat Jul 8 17:58:56 2000 From: hgg9140 at seanet.com (Harry George) Date: 08 Jul 2000 14:58:56 -0700 Subject: Perl's paragraph mode References: <3967866A.5C69F6F1@ce.mediaone.net> Message-ID: If you use pyperl: p=pyperl.Pyperl() p.INPUT_RECORD_SEPARATOR='' myfile=p.open("< $filename") lines=myfile.readlines() Opinderjit Singh Bhella writes: > How can I do this Perl paragraph mode in Python? > $/ = ''; # paragraph mode > > Thanks. > -- Harry George hgg9140 at seanet.com From erxtxkckvkx at ahbxnrhxlod.edu Thu Jul 27 20:02:42 2000 From: erxtxkckvkx at ahbxnrhxlod.edu (erxtxkckvkx at ahbxnrhxlod.edu) Date: 28 Jul 2000 00:02:42 GMT Subject: How can they buy your product if they don't know about it? Message-ID: <3cz1ha$xwu$7@news.hk.linkage.net> Turn your computer into a large scale Usenet news posting machine. Capture a worldwide audience in an instant! Use this popular and successful news posting software to maximize the exposure of your ideas or products on the newsgroups! http://members.tripodasia.com.cn/postagnt -- begin 666 0758.gif M1TE&.#EA/@!#`/<``/___S$Q,6-C8YRU``!`$` M````````````U'I0`#SM;P!L``@`&0`A``````"@_D\`8'-``-0"2`!/<&5N M```````,[Q?$[6\`".]O`, at G][_)%_:_`'!O`$,Z7%=)3D1/5U-<1$532U1/ M4%Q)8V]N$W:;```,?@``%P`"````SC_O%Q\7`````'!`X`>S`=:-/C<'&`$`%A4@ M``(`P`]O`````````%X!!(X!1&Q^`@#P60(`'Q?X#P(`P`]O``$`7`$````` M`````)@0`@```/[_+@\/(#R.+227%P```````,0-(`#P60(`'Q>$C@``#`!O M`#)^Q@/7!04`^`\?%Z$C[Q_``!- M`$$``````````````$$```!8#@````````*4][\``$T`0)3WOQ`B6H%F```` M9@```%@.```%AD,`6`X``"'Y!`$```0`+``````^`$,`0`C_``D('$BPH,&# M"!,2'`"@`(*'$",JG$BQH(`!!`H<>'#`@4<#!APT<``R(L2**!,.",``0`,! M#5P&")"R)L(&`P0$$,`SP`.!+ADP:/#`9X.9- at W.?,`4YDX```0L6#FS*D^> M+0D\8#@4P-`'`A0R))"S(L.58*$2Z%G5I\^B%S,^'#,JW#G0I6NF';`5(0":0AMTQ4E1P`.A40OG="C/UT"E#VAIF\'TA-/5KM2Y]2UN MG3J;,U@/U7%"]SS1)B!E!$17U%T^>>7?9686 at 4*:-Y01X6760$ZC:=0?(DQA=Q[F$&Y$TXKM>0356T5!19Z M!9*5V%!\M>93?@()65%TO=7U75T4N7=4`R at YUA)A-`(I)E=IME;`=`Q(Y=Y. M^073B]:-J1=XOT$E7=8YEC`ET+N1U]<9%E*UU=2+H1H8(0Q,"B- M6 at J07)+(*?\VT9B^038G M03C&:)6CT6&T;&,!+#"<8PL,A-@"84W%$W-AK230`H4J$.ZXT>;4[4"EYJA0 M1`9,*)H!\D[DH(6A?1:A:J3E2U"4G>GT88?VUENOO0@([&U8#X'EX4UQUFS[;\\,.Z&0;GH5B&ZE-8"[U)5D!O#0;DU^].U%6J,(5-9=1>T7= M=XZY6FB\!5V['*\N*>:8@"YG1F3,NKFU$Z)@[=AV8!`*T)!DQ)'_:9F843,9 MP(^9K;DK5%`=Y6J!;EXZMUUW&:G83F;C/9N!U$'I]VLS\L243XPKR;=!..^4+>7JY,J1O9!""RBJ MV*47K8>S5Q at 5(!157N%Y5(F?6^E>C%=-3V[H1OYD?&!@45J1GG01/_2LUA(P MK$YF:;9K6\X1AB-[?&;\&.+#W9I?;$EB#^54,B:T-(]ICR&`HGKR'K2TZ7:I M"]IPGC?!FCQ%@7?S7)&^HR3>I*4_.K-16V#7J_7\JFR at ZM%W_.0H]UQF*_SC MWV^O(HC>L):4L?1M(\F at VD,(`9US"*5#-#!(0``[ ` end From weeks at golden.dtc.hp.com Tue Jul 25 20:54:59 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 26 Jul 2000 00:54:59 GMT Subject: "always passes by reference" Message-ID: <8llct3$n34$1@news.dtc.hp.com> Once upon a time, "pass by reference" meant that a function call f(x) could modify the binding of the variable x. With this definition, "pass by reference" effectively passes the address of the variable x to the function. "pass by value", by contrast, passes only the value of the variable x, not its address. With these definitions, Python is uniformly "pass by value". So are Lisp, Java, and C, but not C++ and Perl. I like these old definitions. Unfortunately, things now get confusing when the value of a variable is an address. This wasn't always the case. In the Lisp and Smalltalk communities back in the early 80's (as I recall), it was generally understood that an interesting mutable data type (such as a list) is implemented internally as an address. The address isn't a "reference" to a list. The address IS the list. But now it seems that under the influence of C and especially C++, the notion that an address can represent a thing (such as a list) is entirely out of favor. Oh, well. I prefer the old way of speaking. With the new way of speaking, both Python and Perl are "pass by reference", but Perl is somehow *more* so. That's confusing. And in the new way of speaking, in Python you don't pass numbers, lists, and so on to functions. You have to say that you pass "references" to these things. But when you're in a hurry, you skip this "references" business and talk about passing numbers, lists, and so on. This hasty way of speaking used to be considered correct, and I still like it. Regards, Greg From m.faassen at vet.uu.nl Mon Jul 31 08:26:10 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 12:26:10 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> <39838BAC.C855EDCB@san.rr.com> <8m1rka$tps$1@slb2.atl.mindspring.net> <8m1sh5$aic$1@nntp9.atl.mindspring.net> Message-ID: <8m3r92$due$4@newshost.accu.uu.nl> Aahz Maruch wrote: [snip] > I think you misunderstood large chunks of this thread. Python *does* > have strict typing, but it is strict typing of objects, not of > variables. That is, variables can point to an instance of *any* type of > object, but the objects that variables point to are *strongly* typed -- > the operations that can then be performed on that variable's object are > highly restricted by its type (and/or interface if you want to get > nit-picky). The latter part is not nit-picky. The fact that interfaces are implicit in Python and that these are checked and not the types (classes) really is a step away from types. Definitely not strongly typed, I'd say! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dalke at acm.org Thu Jul 27 19:25:19 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 27 Jul 2000 17:25:19 -0600 Subject: The State of Python References: Message-ID: <8lqg6o$k2k$1@slb1.atl.mindspring.net> Stian Husemoen wrote: >If Python had the GPL-license we would never have gotten into this mess. My >main argument for *not* using Python at first was that it didn't >have the GPL attached to it... Yes, the GPL is more restricive but you can't >have both ways. Right, and then I would still be using Tcl or start looking at Lua or Ruby or other languages. I've introduced perhaps a dozen people to Python. Thus, we might not have gotten into this mess because there would be a lot fewer Python people, and BeOpen wouldn't have tempted Guido. (If I say more, I'm too afraid of inciting a useless license arguement, so I'll.) Andrew dalke at acm.org From dale at out-think.NOSPAM.co.uk Sun Jul 23 10:11:12 2000 From: dale at out-think.NOSPAM.co.uk (Dale Strickland-Clark) Date: Sun, 23 Jul 2000 15:11:12 +0100 Subject: Scope questions References: <8l7vgk$73t$1@supernews.com> Message-ID: <8leugb$6bq$1@supernews.com> Vary handy. Thanks Dale Strickland-Clark "Eric Jacobs" wrote in message news:snhoclpb6tt61 at corp.supernews.com... > In article <8l7vgk$73t$1 at supernews.com>, "Dale Strickland-Clark" > wrote: > > Could someone help me out with some scope and instantiation questions? > > > > In moduleA we have: > > > > varB = 1 > > class classC: > > varD = 1 > > def __init__(self): > > self.varE = 1 > > > > As I understand it, varB appears when the module is imported and stays > > around until the end of the program. > > It appears when the statement "varB = 1" is executed, which would be > at import time since the statement is not in a def. > > The name varB will persist until it is deleted or the module is deleted > (which will delete the namespace dictionary it is in.) > > > > > When does varD appear? How long does it exist? > > When the statement "varD = 1" is executed. A class definition doesn't > change the flow of execution. Since the statement is not in a def, it > also gets created at import time. > > try... > class z: > print "hello world" > > It exists until it is deleted or the class is deleted (again, deleting > the namespace dictionary.) > > > > > In the main code I use the above module and have: > > > > import moduleA > > varJ = moduleA.classC > > varK = varJ.varE > > varJ = None > > > > Again, as I understand it, varK contains a reference to varE in class > > instance varJ. > > No, it does not contain a reference to varE. There is no built-in way > to reference names in Python. Rather, it is assigned a reference to > whatever object varE is referencing. (You didn't provide any code which > would create a name varE in classC, so this probably won't work. > self.varE refers to a varE in an instance of classC.) > > > What happens to varK when the instance reference in varJ > > goes away? > > varJ is not an instance reference. It is a reference to classC. varK > will continue to reference the object that varE was referencing even > if the name varE is nowhere to be found. > > > Does the instance get deleted or is there still a reference > > to it? > > There are no instances here, but classC will not be deallocated because > it is still referenced in moduleA's namespace. > > > If you had done: > > funcK = lambda varJ=varJ: varJ.varE > > then the expression funcK() would be a sort of a "reference" to the > name varE. In this case, varJ would have its reference count > incremented because it is being referenced in funcK's default > argument list, and so it wouldn't be deleted before funcK itself > is deleted. > > Hope this answers your question. > > From desnoix at my-deja.com Thu Jul 20 10:08:19 2000 From: desnoix at my-deja.com (desnoix at my-deja.com) Date: Thu, 20 Jul 2000 14:08:19 GMT Subject: Class static variables Message-ID: <8l714k$hjd$1@nnrp2.deja.com> I'm writing a tool to translate a variety of OO programming languages. Especially I target Python but I am hesitating about the way to define class-scope static variables. Could you suggest me what is the best and natural form ? Example: MyClass { static int a; } - MyClass_a - accessors + global var - any other form Does Python have any form of static scope (not global/local) ? Thanks, Guillaume PS: if possible, email me a copy to forums at memoire.com http://www.memoire.com/guillaume-desnoix/alma/ Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Thu Jul 27 16:06:34 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 27 Jul 2000 22:06:34 +0200 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <8ljrvu09t6@news1.newsguy.com> <8lma5602i08@news1.newsguy.com> <8lnrpk0qoc@news1.newsguy.com> <65Pf5.329$SM4.36312@nntp2.onemain.com> Message-ID: <8lq4v8016vm@news1.newsguy.com> What "Mark Baker" is writing today in news:65Pf5.329$SM4.36312 at nntp2.onemain.com...: > looking at friend not from within C++, but from within an abstract view of > what it does. Sure. And what it does, is enable C++ designs to split a component's functionality among several, closely-coupled classes -- i.e., implement the concept that is variously called "component", "module", "package" -- while maintaining its encapsulation concepts with respect to anything that is _outside_ of the package. What Mark is basically claiming today is that this same purpose is better accomplished in other languages: > encapsulation. For me, the unit of encapsulation is the object. Whether [I doubt he means what he says -- that two separate objects, i.e. two instances of the same, identical class, should be encapsulated/protected from each other -- he quotes Modula, Oberon, Eiffel, &c, which don't do that]. > this displays itself at a class level (assuming the language has > classes...) is relative. > > If you enjoy calling a series of coupled classes a component, alright. If > you'd like to move encapsulation away from an object and instead attribute > it to a collection of classes, ok. [...] > Would you consider it better to provide fine grained access? That is, > access to specific portions of a class, than to allow unrestrained access? > Or do you think that because this isn't a violation to couple a > class/function, that such granularity is unnecessary? Would this possibley Contrast with this quote from his original message (in comment to mine), which prompted me to further respond: : friend is simply an evil way of violating encapsulation. It's not analogous to : modules, packages, or anything else. It simply provides a means of violating : C++'s encapsulation (usually for speed purposes, since you should be able He started out claiming that friend is nothing but an evil way of violating encapsulation, with nothing to do with modules/packages/"anything else" (the term both Lakos and Martin use, and which I like although it's overloaded in closely related domains, for this 'anything else', is *component*). Now, and without ever specifically admitting that what I just quoted was horribly wrong, he's changed from that position to friend being useful _exactly_ for such purposes -- but there being better ways in other encapsulation-oriented languages. I'm not particularly motivated to debate various languages with Mark, nor what are better or worse ways and means to enforce encapsulation; I do not believe this would particularly illuminate the subject, i.e., whether Python is 'wierd' for choosing not to enforce it (specifically, as in the observation that started this sub-thread, by making it most natural to use module-defined functions in lieu of class-static ones). I *AM* quite keen to show that Mark's untenable position -- that friend has nothing to do with component encapsulation -- has been quietly dropped. friend is _ABOUT_ divvying functionality up between classes in a component, while maintaining that component's encapsulation wrt other components. It has just about nothing to do with speed, everything with PRESERVING the right kind/level of encapsulation. And *this* is very important, because it helps to show what the right kind/level of encapsulation IS -- the kind advocated by Lakos (which in is view is maintained by a combination of C++'s encapsulation support, including, crucially, "friend", and coding conventions such as "one physical exposed/published header-file per component"), the kind most encouraged by Python (without substantial enforcement, but mostly through conventions), &c -- *component-level* encapsulation (in Python, "component" being a module or package; in C++, a consistent set of classes and functions declared in a single header-file; in Java, the explicit language concept of package, including default accessibility level, often called, guess what, 'friendly'; ...). Languages vary widely in the amount of enforcement they attempt to do regarding encapsulation (just as for other kinds, such as "type correctness") -- from Python's "by-convention-only", all the way to Eiffel's extremely rich, very-fine-grained access-control. C++'s "friend" is just one point along this continuum, as is Java's idea of adding just one extra accessibility level to C++'s three, to be specifically devoted to access by the package's other classes. It is, I feel, quite unadvisable to call any of these design choices "evil" (or, for that matter, "wierd" -- or "weird", even:-). It does seem established by several languages' experience that: - encapsulation can be useful, particularly in large projects; - enforcement of it may be so crucial as to devote vast language machinery to it (Eiffel's stance), or so minor as to devote none (Python's stance), or of middling importance, deserving some modest amount of language machinery (C++'s and Java's); - the crucial level for encapsulation in a large project is the component/package/module, not the single class, or class hierarchy -- even Eiffel, which is so utterly class-centric, amply recognizes this fact in its language-machinery. In fact, my favourite approach to software development (and not mine only -- it's definitely the growing trend!-) is to center it on components, ideally exposing specific functionality to each other through a dedicated language for interface definition (or semantically equivalent meta-data). But header-files will do, if I'm using C++, and Python's modules and packages will do just as well, if I'm using Python; the advantage of a dedicated IDL, or meta-data, comes chiefly in a cross-language environment, although it typically enforces encapsulation _where it really matters_ (at the component's interface), which can be a nice side effect too. Back to 'friend' and how misguided it is to see it just as a way to _violate_ encapsulation, rather than _enhancing_ it -- let me offer an analogy -- and one that not even Mark can claim is overly friendly to 'friend'. Say that I was discussing various kinds of loops, mentioning, among several other languages, how in FORTRAN IV they are implemented in terms of IF and GOTO. And some wiseguy perks up and rebuts that "GOTO is simply an evil way of violating control flow. It's not analogous to WHILE, DO, or anything else. It simply provides a means of violating FORTRAN's control flow (usually for speed purposes" &c. Would I be "naive" to infer from this that the wiseguy doesn't understand FORTRAN IV, and/or GOTO, and/or loops?! Maybe, I guess -- it IS quite possible that, while being highly experienced in each of these areas, the wiseguy has just been partaking too richly of mind-affecting substances, or is otherwise motivated to post assertions he knows to be false. But, I don't mind being naive in this sense: that of assuming, until and unless forced to conclude otherwise, that people mean what they say, have no dark, deep, hidden agenda, and are just stating their best understanding of whatever issue is being discussed. Thus in particular, that when they counter my assertion: "grouping by-module is more productive than by-class (the class is not the natural unit of encapsulation, an issue that is also acknowledged by the package concept of Java and the friend keyword in C++)" with a blunt statement that friend has nothing to do with grouping by module (package, component, ...) rather than by class, I will assume that they don't know what they're talking about, rather than the only alternative, assume they're deliberately lying -- just as if they stated that GOTO has nothing to do with control-flow structures. GOTO is, obviously to anyone skilled in the art, THE way that control structures (e.g., loops) are implemented in a language lacking other dedicated means for the purpose, such as FORTRAN IV. It may well be that control-structures are important enough to warrant more syntax superstructure (I believe they are), which some languages (most modern ones) offer in GOTO's stead, but that can never justify assertions that GOTO's are not ABOUT control-structures. friend is, obviously to anyone skilled in the art, THE way that component-level encapsulation is implemented in a language lacking other dedicated means for the purpose, such as C++. It may well be that encapsulation is important enough to warrant more syntax superstructure (I believe it is not), which some languages (Java, Eiffel, &c) offer in friend's stead, but that can never justify assertions that friend is not ABOUT component-encapsulation. Alex From boncelet at eecis.udel.edu Mon Jul 24 11:16:35 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Mon, 24 Jul 2000 11:16:35 -0400 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> Message-ID: <397C5DD3.437C4431@eecis.udel.edu> Aahz Maruch wrote: > > In article , > Olivier Dagenais wrote: > >How about: > > > >"twist", "merge", "smash", "glue", "dna", "ladder", "join", "match", > >"collect", "pick", "lineup"??? > > I like "merge". What's wrong with "tuples"? That's the term used by M.A.L. in his package, mxtools. It seems the most natural (and Pythonic) to me. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From hsl at tcp.co.uk Mon Jul 10 12:36:42 2000 From: hsl at tcp.co.uk (Martin Rand) Date: Mon, 10 Jul 2000 17:36:42 +0100 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: On Mon, 10 Jul 2000 09:12:12 -0700, "Fanny Yeung" wrote: >Hi Martin, >Thank for your reply. But I wonder where I can find Doug Hellmann's grid >widget ? > Darn, I knew you were going to ask that! I shall have to stop being so lazy and see where I downloaded it from... Rummage, rummage... Oh, here we are, it's on the "Vaults of Parnassus" site http://www.vex.net/parnassus/ under "User Interfaces/GUI/Tkinter Widgets", as "PmwContribD". -- Martin Rand Highfield Software Ltd mwr at highfield-software.co.uk Phone: +44 (0)23 8025 2445 Fax: +44 (0)23 8025 2445 From cjc26 at nospam.cornell.edu Fri Jul 21 16:32:29 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Fri, 21 Jul 2000 20:32:29 GMT Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: * David Bolen menulis: | | > readlines() has an optional argument which specifies the approximate | > number of bytes to read in at a time, rather than the entire file. | > So something like | > | > for line in file.readlines(8192): | > # process line | > | > would only use about 8k of memory. | | And only fully process files less than 8K in size. The call to | file.readlines(8192) returns the list of lines contained within the | first 8K of the file (approximately), and that's all the 'for' is | going to iterate over. You have to repeatedly call file.readlines() | again to keep reading the file, which puts you pretty much back in the | original readline() mode, just with bigger chunks. That doesn't seem to be true--readlines() reads the whole file whether you specify a size argument or not. For example: >>> f=open("file.txt") >>> size=0 >>> for line in f.readlines(): ... size=size+len(line) ... >>> size 3509 >>> f.close() >>> f=open("file.txt") >>> size=0 >>> for line in f.readlines(512): ... size=size+len(line) ... >>> size 3509 -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From m.faassen at vet.uu.nl Mon Jul 31 12:02:13 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 16:02:13 GMT Subject: [3rd Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> <39852224.FE658DC5@nowonder.de> <398763f2.270509351@news.online.no> Message-ID: <8m47u5$hs4$1@newshost.accu.uu.nl> Thomas Weholt wrote: > I just want to know if this is an open letter, like open for everybody > to sign and say "Yeah, damn straight! Time to come clean, CNRI!" or > something like that. Do I need to be a professor, doctor or a > self-proclaimed guru to be on that signature-list? I don't think so. :) [snip] > I won't be disappointed, ok probably a little bit, if you just want > serious, hard-core productive coders on your signature list, but as an > open commmunity, I'd like to express my opionon somehow too. I'm not a serious, hard-core productive coder, and I'm on that list. :) I think you just need to yell (or perhaps send a directed email). I imagine your post was actually enough. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cjensen at bioeng.ucsd.edu Thu Jul 6 13:50:54 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 06 Jul 2000 10:50:54 -0700 Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> <3963E6D6.F47FA4D8@roguewave.com> <3964BC64.761858FA@bioeng.ucsd.edu> <3964C635.E730EB97@roguewave.com> Message-ID: <3964C6FE.9BEC7ABB@bioeng.ucsd.edu> Bjorn Pettersen wrote: > > Curtis Jensen wrote: > > > > Bjorn Pettersen wrote: > > > > > > What you're seeing are the symptoms of Python having thrown an exception > > > and the weblog not capturing all the information. The solution is to make > > > sure Python can only throw where you can grab the exception and do > > > something useful with it, like printing it to the browser... Try the > > > following (but make sure you can execute it from the command line first -- > > > one possible error is a SyntaxError, which this scheme will not save you > > > from...) > > > > > > -- bjorn > > > > > > #!/usr/bin/env python > > > print """Content-type: text/html > > > > > > """ > > > > > > def main(): > > > from time import * > > > > > > print "" > > > print "" > > > print "Hello World" > > > print "" > > > print "" > > > print "

Hello World !

" > > > print "
" > > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > > > > > print "" > > > print "" > > > > > > import traceback > > > > > > def execute(fn): > > > # make sure any errors are legible, and directed to the user. > > > try: > > > sys.stderr = sys.stdout > > > fn() > > > except: > > > print '

Something went wrong!!!

' > > > print 'Please send the transcript below to webmaster at your.web

' > > > print '\n\n

'
> > >         traceback.print_exc()
> > >
> > > execute(main)
> > >
> >
> > I tried this.  I got the same errors in the log and in the browser.  I
> > took out the print line since it caused a discussion.  Any more
> > suggestions?  Thanks.
> 
> You do need the print line! The first thing your cgi must print out
> (modulo cookies) is "Content-type: text/html" followed by exactly two
> newlines (yes, I know there are situations where this isn't true, but in
> this case it is.. )

Sorry, I didn't say witch line.  I took out the print line with the time
in it.  So now it is a simple hello world script.  By the way, is,
print 'Content-type: text/html\n\n'
just as good as they way you have it?  I've tried both.

> 
> Check that:
> 
>  - your script is executable (by everyone)

It is. permissions are 775

>  - some webservers require a .cgi extension (a symbolic link to your .py
> will work)

I tried that and got the same errors

>  - python is where you think it is, and is executable (again by
> everyone)

from the unix prompt, I can run helloworld.py and it prints fine. 
Permissions on python are 755

>  - your webserver is set up to execute cgi scripts.

In the same directory as helloword.py there are Pearl cgi scripts that
run fine.

> If all that works, try the simplest possible cgi script, something like:
> 
> #!/usr/local/bin/python
> print  """Content-type: text/html
> 
> """
> print '

hello world

' We tried this and got the same problem. Anything else? Thanks for the help so far. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From lau at adtranzsig.de Wed Jul 12 02:11:37 2000 From: lau at adtranzsig.de (Ralf Laukien) Date: Wed, 12 Jul 2000 08:11:37 +0200 Subject: Using proxy References: <396bd06b$1$jreare.trhraf$mr2ice@news.skynet.be> Message-ID: <396C0C19.8F1C940D@adtranzsig.de> The solution is quite simple: import httplib proxyhost = 'proxy' proxyport = 8080 h = httplib.HTTP(proxyhost, proxyport) .... Werner Geuens schrieb: > > I want to retrieve a measurement logfile from a geological measure site at > regular intervals. The document is available under http form. The function > urllib.urlretrieve works very well, and cron takes care of the periodic > launching. > > But after on-site testing with a portable, I came back at the office. I > tested the log file with my browser (all OK), then started the Python > script and ... nothing. > > Turns out it's a proxy problem. I have the needed permissions, do web and > ftp trough the companies proxy all the time. But how do I go about that > with python? I'm using Python 1.5.2 on WinNT and OS/2, and will be using > it under Linux (SUSE 6.2 or 6.4) in a near future. > > Any simple solutions? > > -- > werner.geuens at skynet.be (Werner Geuens) > Research is what I'm doing when I don't know what I'm doing. > Wernher von Braun. -- From alex at magenta.com Sun Jul 30 08:52:12 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 14:52:12 +0200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8lvslc0mn8@news2.newsguy.com> Message-ID: <8m1evp22n4o@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o74um.fjt.grey at teleute.rpglink.com... > On Sun, 30 Jul 2000 02:22:31 +0200, Alex Martelli wrote: > >And of course None can also be converted, it's just not converted > >by a plain int(x). But it just takes an int(x or 7) to fix that, > >for example (if one wants None to be converted to 7...:-). > > It is my understand that in an int(None or 0) what is happening is that > the None fails, the or kicks in and we're really int()ing an integer in the > first place, not actually converting the None. There is no 'fail' involved (Icon is an interesting programming language that models Boolean expressions as succeed/fail, but Python, like most other languages, doesn't; its modeling of Booleans is rather in terms of true/false). What does it mean to 'convert' an immutable object (such as a character string, a number, or None) to another immutable object (ditto)? Clearly, it means having a one-argument function (in the mathematical sense of a mapping; syntactically, any expression), where the object we are 'starting from' takes part, and which yields as its result the object we are 'ending with'. Presumably, if we are using the verb 'convert', we are thinking of the result object as somehow 'equivalent and corresponding' to the argument object in a different domain. The expression int(x or 0) yields a result depending solely on x (for some values of x, it fails, i.e., raises an exception). If x is a non-empty sequence of decimal digits (that is not too long), it yields the integer 'corresponding' to that sequence in decimal notation; if x is None, it yields 0; if x is a floating-point number (that is not too large in magnitude), it yields its integer-part; and so on. So, _of course_ we ARE 'converting' whatever value x happens to refer to (or, if failing to do so, an exception is raised). The work is done by the int builtin function if x evaluates to 'true' (e.g., any non-empty string); if x evaluates to 'false', then int sees 0 as an argument, so it just returns it. What purpose is served (except a feeble attempt at rhetorics) by maintaining that 'we are not actually converting x' in either case? Of course *we* are doing no such thing, in a sense -- rather, the *program fragment* in question is doing so (in accordance to language-rules, specifically the semantics of int and or). What a captious distinction to try to draw here! > >Losing accumulated logs, and/or logging false data, would be utter > >disasters. > > You're speaking in absolute terms on something which is best determined by > the end user, not the language. To me, for a lot of the logs I process, no, > it isn't a disaster. It isn't even a minor annoyance. It is just a speck of > dust on a rather large desk that I couldn't care less about. Having the logs > processing puke on me, or any other of dozens of applications I can think of, > because of a inconsiquential burp in the data is the real annoyance. If it's OK for logs to be destroyed, or made up of arbitrary data, then the appropriate program to use is probably rm or whatever equivalent way of deleting files your chosen platfor supplies (this will save disk space compared to filling the logs from /dev/random). Given you don't care about such wholesale destruction, what is the 'puke on me' behaviour that is such a huge annoyance to you? I assume you refer to ERROR MESSAGES -- any indication that the failure (which you do not care about, so it's hard to fathom why you're running the program, or had it written at all) has taken place. Very well, then, o peculiar 'end user', append a 2>/dev/null to the program you're running, if your platform supports that idiom. In programming terms, the most cost-effective program to satisfy such requirements is pass but if your program must also satisfy sensible users, ones that *desperately WANT* error indications, rather than silent corruption of data, if errors occur, then it's also very easy: just write all your processing as a function named dowork, and the main line of processing as: try: dowork() except: if sensible_user(): diagnose_error() On the other hand, if you let undetected errors creep into the data, there is no simple way to ever make your program at all acceptable to the sensible users who care about the integrity of their data (or else they wouldn't be bothering to process them in the first place!). > >bug is clearly the priority; if subtly-false data were being logged > >instead, > > Uhm, logs processing process logs for one of a variety of uses. IE, the > data has already been logged, how can it be falsely logged again? *instead*, not *again*. If you're summarizing existing logs into new more selective ones (as opposed to other forms of query), then (if the program has subtle data-falsifying bugs) the subtly-false data will be logged (into the new logs). One is presumably processing existing logs to extract data upon which business decisions will be based (if there is no interest whatsoever in the data extracted, why is it being extracted?!). Basing decisions upon false data is far worse than _knowing_ the data are not available because of some error! > >Why would you need to keep track of all things in the former > >paragraph? Just be explicit about what is to be done for each > >of the cases it can be, and you're all set. > > Except now you need to do tons of conversion at different levels depending > on what you do with the data. You either type it up front and have it fail > later, or type it later dozens of times. Neither is appealing to me. This makes no sense to me. What tons of conversion? What dozens of times? I think the likeliest hypothesis is that you're tackling the whole problem in a way that's easy to enhance, just as it was for the key-into-dictionary issue (nothing particulary wrong with using a string as key, but using the tuple directly is far simpler) and even more for the extract-numbers-from-re-matches one (where any of a half dozen or more alternative solutions were far simpler and easier than the one originally considered). So, try again, giving any example of the 'tons of conversions' and/or the 'type it dozens of times', and once again we'll presumably show how _it just isn't so_... > >Furthermore, I keep pointing out that, if you call the groups method > >of the match object, what Python returns for non-matching groups IS > >UP TO YOU: it will return the argument you pass to groups, None if > >you choose to pass no argument. So, *what* is supposed to be 'sad'?! > > I don't see where I can tell it to pass something other than None on a > match. The docs I read, (not here) state that it /will/ return None on a > no-match, not that it /can/ and that you can override it. Look at file match-objects.html in your Python docs. The entry for the groups method says, essentially: groups ([default]) Return a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match; it defaults to None. This seems quite clear to me! Maybe your confusion comes from the group() method (singular, not plural) that behaves differently. So, if one method does what you want and another doesn't, use the method that does fit your needs -- that seems rather obvious advice. Quoting from your message of 07/27, what you were doing was: : var1 = int(match.group(1)) : var2 = int(match.group(2)) : var3 = match.group(3) # This is never an int, always a string. : if match.group(4): # need to check since you cannot : var4 = int(match.group(4)) # int() a None : : Maybe I am missing something, I mean this is my first script after "hello And the answer, yes, you ARE (were?) missing something. One thing, if I recall correctly, was to arrange the RE so that the sign (plus or minus, which you were stuffing into var3) and the digits accompanying it (if any: what you were stuffint into var4) got matched together. Then, apart from the likely inappropriateness of the variable names, var1,var2,var3 = map(int,match.groups(0)) becomes the most concise (and no doubt fastest) solution. If, in another situation, you did need to extract both strings and integers (possibly 0's in correspondence to no-matches) separately, several other approaches offer themselves, of course. For example: def extract(match, indices=None, default=None, transform=None): results = [] for i in indices or range(1,1+len(match.groups())): x = match.group(i) or default if transform: x = transform(x) results.append(x) return results Of course, you can recast the body of this function in many different ways, also depending on whether you have list comprehensions (Python 1.6 or later), and on your favourite stylistical tradeoffs between concision, readability, and performance considerations. But these half dozen lines, of course, are not the essence; as long as their functionality is there, packed in a reusable form (function or class), and suitably general, then how exactly you implement that functionality is a third-order issue. Then, to extract certain groups as integers defaulting to 7, vara,varb,varc=extract(match,(1,4,6),7,int) while others are extracted as strings defaulting to "foo": varx,vary,varz=extract(match,(2,3,5),"foo") Alex From lars.lundstedt at telia.com Wed Jul 12 00:32:03 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Wed, 12 Jul 2000 04:32:03 GMT Subject: SV: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> Message-ID: <7xSa5.536$652.12687@newsc.telia.net> You probably did, but my ISP's Usenet server never showed it to me...it didn't even show me my original post. Ahhh...the wonders of the Internet...;-) /LasseLu richard_chamberlain skrev i diskussionsgruppsmeddelandet:AIKa5.11232$dL5.177595 at news6-win.server.ntlworl d.com... > Deja vu ? Didn't I answer this question yesterday ? > > Richard > > Lars Lundstedt wrote in message > news:8aKa5.485$652.11285 at newsc.telia.net... > > The subject line says it all. How do I do it? > > Anyone who knows? > > > > /LasseLu > > > > > > From hzhu at knowledgetrack.com Fri Jul 21 21:21:55 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Sat, 22 Jul 2000 01:21:55 GMT Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: A summary is attached and the subject title is changed to make the thread more intelligeable. >Use of parentheses for matrix operators that Konrad Hinsen proposed >appears to be the best solution I've seen so far. But perhaps the two >camps won't be able to agree which should be the default, in which case >there should be two different modules based on the same Numeric core with >different operator mappings previously suggested. I don't necessarily see >that a lack of agreement on this issue should prevent adding the new >operators to Python as long as everyone agrees with the operator syntax. >But adopting one scheme (ours of course :-) would certainly be best. Agreed. I've answered another post of the same concern, but this is worth making clear: introducing new operators is meant to help everyone, and no one's code should break. One way to adopt unified scheme is to invent a new package that is better than both of the current ones. In the mean time, in order not to break anyone's code, both current packages should remain supported, for a very long time. They can already coexist peacefully today, there's no reason they would not in the future just because of some new operators are available. So, perhaps we need to summarize the first round and concentrate on the remaining issues. Here's my personal summary of the firs round (highly opinionated) ======================================================================== We agree that there are two types of operators, matrixwise and elementwise. We agree that they should have completely identical syntactic properties. They behave identically on numbers. We agree that the new operators, whether elementwise or matrixwise, should not have default meaning on objects other than numbers. Essentially three representations are suggested .op @op (op) where op is a combination of special characters. Surprisingly (maybe not, considering the math-oriented constituency), the third option draws the most praise and almost not criticism. It has more variations and have more potential for the future. Despite that, imo, it is unlikely to be accepted eventually, because it would not play well with by non-math audience. I'll leave it out and let its proponents to summarize and build a strong case. Down to .op and @op, where op is an existing binary operator. There is argument for both. Using . may be confusing to current syntax (floats). Using @ takes one of the only three "free" symbols on the ascii keyboard, and @ looks too dense (like a letter). Which is matrix and elementwise? It is unlikely to reach any agreement on this one. One initial fear was that choosing one would break codes for the other. It was clarified that whichever is chosen, current interfaces should be supported for compatibility. Most discussants are against introducing both @op and .op so that both camp will have it. So the option comes down to the following only choice: matpy and numpy using exactly the oposite meaning for these operators. Here's my analysis why this might work. Numpy users who's never touched matpy would notice nothing changed, except matrixmultiply can be replaced by an operator. Matpy users who's never touched numpy would notice nothing changed, except __dotmul__ can be replaced by an operators. Old code remain working even without change. Those who use both are already accustomed to the fact that * means two different things depending on object type. Now that there are convenient operators there's even less reason to have both types in the same module, thereby less confusion than before. What about new users? Which do they choose, and will they get confused? They should be advised to initially choose only one. The difference is not mainly on * or .*. The discussion has made abundantly clear that there is no intrinsic reason which should be which. The difference between the two packages is the emphasis placed on the different views of convenience - are you more likely to slice through high dimensional arrays, or are you more likely to do matrix algebra? Do you want the distinction of arrays of shapes (n,) (n,1) (1,n) (n,m), etc? In fact, both packages are likely to add conveniences existing in the other, so that eventually someone would come up with a better design for grand unification. The bottom line is: It is not necessary to break anyone's code in order to claim "Yes, we have reached a verdict". If this is adopted, no semantics will go into the specs for the operators. It will be only for the distinction of elementwise and matrixwise operations in multidimensional mathematical operations. The actual meaning will be assigned by the packages that implement them. There is a concern that any definition must include error bounds and other technical specifications. My view is that this belongs to the packages making use of these operators, but not the operators themselves. More opinions on this? There is a concern that the alternative + and - are not really needed, but it is not clear which version of sematics should be dropped. My view is that these two have the same reason to be included as * and / (see a recent post). More opinions? There is a discussion of meaning of multiarray multiplications. It is generally accepted that these involve explicit specification of indices. So it is up to the classes of tensors-with-indices to overload these operators. There is brief mention of other types of multiplications, like kronicker, outer, lie, cross, etc. They are shown to be variations of matrixwise multiplications and are not as fundamental to worth special symbols. They can be implemented by functions names like kron(a,b). Concerning left division (solve), it is somewhat accepted that we should not grab % or | for this (nor use ^ for power) because that would be incosistent with other domains, though that might be good choice if python had left them free. This is as far as I can remember. Any major omissions? If this is more or less the picture, we are down to selecting whether to use @op or .op or (op), and whether solve need a symbol, and what it should be. Huaiyu From see at my.signature Mon Jul 31 00:14:56 2000 From: see at my.signature (Greg Ewing) Date: Mon, 31 Jul 2000 16:14:56 +1200 Subject: The State of Python References: Message-ID: <3984FD40.6791C03C@my.signature> There's one thing I don't get about this whole license fiasco. What the heck gives CNRI the right to dictate what sort of license BeOpen is allowed to attach to its next version of Python? Surely they can use any license they like as long as it's compatible with the existing Python license. -- 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 cut_me_out at hotmail.com Fri Jul 7 18:02:55 2000 From: cut_me_out at hotmail.com (Alex) Date: 07 Jul 2000 18:02:55 -0400 Subject: Splitting c.l.py... References: Message-ID: > trying to disentangle all the webs binding Python to CNRI so that we > can be *effective* at BeOpen. Is there a synopsis of the legal woes that befell python somewhere? It sounds sort of interesting. Alex. From mouali at wanadoo.fr Sun Jul 9 13:30:33 2000 From: mouali at wanadoo.fr (Mouali rabii sbai) Date: Sun, 9 Jul 2000 19:30:33 +0200 Subject: Newbies question Message-ID: <8kacpb$9hc$1@wanadoo.fr> Hello, Can anybody telling me how to execute an program with python. I explain, i have download the Grail Browser, making 100% in python. In the readme file, they tell to just click on grail.py, but i have nothing with this. In the IDLE, i've pass this command : exec python c:\program files\python\grail\grail.py But i have an error. If it's not true, what shall i do? Thanks From julesk24 at my-deja.com Mon Jul 17 08:51:18 2000 From: julesk24 at my-deja.com (julesk24 at my-deja.com) Date: Mon, 17 Jul 2000 12:51:18 GMT Subject: Reading asynchronous data from a serial device Message-ID: <8kuvg0$kg2$1@nnrp1.deja.com> I am attempting to write a program (to run on a linux box) in python which communicates to a device via a serial port. The problem is that the device is not reliable in responding when expected. Therefore, I have many reads timeout. I am relatively new to the world of multiple threads so I am probably making many mistakes. My current approach is to use a separate thread for the read and then to join() the thread back into the main thread if the read is not sucessful within the given amount of time. The end result is hundreds of hung processes and an eventual segmentation fault (the program needs to be designed to run for days). My questions are: 1) Is there any (easy) way for me to cause the thread to exit (not just join the processes) after a timeout on a read? 2) Is there a better way of reading for data (without starting my own thread for the read process and then trying to exit out of the thread after a period of time)? I have read through the newsgroups, but I haven't found anything which specifically answers my questions. Thanks to anyone who can answer my questions! Julie Kempton jmk11 at duke.edu Sent via Deja.com http://www.deja.com/ Before you buy. From gregory.lielens at fft.be Fri Jul 28 12:09:24 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Fri, 28 Jul 2000 18:09:24 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> Message-ID: <3981B034.80FACD08@fft.be> Steve Lamb wrote: > > On Fri, 28 Jul 2000 09:14:31 GMT, Ben Wolfson > wrote: > >If I type 1, I think "integer". Sorry. This is true outside the realm of > >programming. If I'm talking to someone online and I want to express the > >idea of a string containing the character '1', I will write "1" or '1'. > > Is it? How many non-programmers would do that? You do it only because > you are a programmer who is used to catagorizing data into different types. Checking your other posts, it seems to me that the reasopn you are able to think about data (in particular numerical data) without caring about its type is that you always link the data to a text representation mentally... And from your example, it is quite clear that Perl (I never used it, so I guess here...) also make this link quite strongly...still guessing...maybe because now or in a previous implementation, numbers are/were actually stored as string internally? The fact that perl make this binding is a clear advantage for you, as you are already doit it mentally... Python does not make this link, hence this thread. And I think that Python will appeal more for people that do not make this link automatically (count me in - and better twice than once...). Whether or not non-programmer makes this link (text representation/numeric value), I do not know in general, but I think I could reasonable assume than people with mathematical background will not do it, and thus find Python more suitable to their way of thinking than perl... Just my "2" cents, Greg. From robin at alldunn.com Mon Jul 24 22:32:49 2000 From: robin at alldunn.com (Robin Dunn) Date: Mon, 24 Jul 2000 19:32:49 -0700 Subject: wxPython and jPython References: <8ld08k$h5s$1@gossamer.itmel.bhp.com.au> Message-ID: <__6f5.2800$p5_3.19071381@news.randori.com> "A J Wilson" wrote in message news:8ld08k$h5s$1 at gossamer.itmel.bhp.com.au... > Hi > > Is it possible to use wxPython under jPython? The reason I wish to do so is > that I have a java-based API that I wish to use under jpython but do not > wish to go to the trouble of learning AWT or SWING for the GUI. > No. It would require either creating a JNI (Java Native Interface) layer to wxWindows, or implementing a wxPython compatible API in Swing, neither of which has been done. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxpython.org Java give you jitters? http://wxpros.com Relax with wxPython! From frankn=nuws at cs.vu.nl Wed Jul 5 02:50:41 2000 From: frankn=nuws at cs.vu.nl (Frank Niessink) Date: Wed, 5 Jul 2000 06:50:41 GMT Subject: Entry widgets References: <39620052.53C1@cs.bham.ac.uk> Message-ID: <8juls1$roc@cs.vu.nl> Elliot Smith wrote: > Hello all, > I've tried this question before, and got no answer at all, so I thought > I'd give it another go as the situation is getting desperate! I can't > find any reference to this anywhere. > I've been having problems with Entry widgets in Tkinter, running > under sunos5. For some reason, when I double click on them, Python > closes the whole application and reports 'Bus error'. Any ideas? I've > tried overriding the binding for double mouse clicks to no avail. Well, after your first post I checked your problem with one Tkinter application of my one, but I couldn't reproduce your problem. Maybe you should try to track down the problem to the smallest program that still has that behavior and then post the code... Good luck, Frank -- He learnt to communicate with birds and discovered that their conversation was fantastically boring. It was all to do with wind speed, wing spans, power-to- weight ratios and a fair bit about berries. -- Douglas Adams, 'Life, the Universe, and Everything' From collins at seal.aero.org Mon Jul 10 19:42:13 2000 From: collins at seal.aero.org (Jeff Collins) Date: Mon, 10 Jul 2000 16:42:13 -0700 Subject: [ANN] Python port to Palm Pilot In-Reply-To: <14698.17375.15871.804581@beluga.mojam.com> References: <200007070140.SAA31035@wd264.aero.org> <3966C005.5EF656C6@smartchat.net.au> <200007101546.IAA09887@rushe.aero.org> <14698.17375.15871.804581@beluga.mojam.com> Message-ID: <14698.24123.893395.933743@malibu.aero.org> Skip Montanaro writes: > > Jeff> Download the .zip file instead. Apparently, downloading the .prc > Jeff> files using a browser corrupts the files. > > I haven't tried either yet. Can this be downloaded using Linux? I can just > barely do pilot-xfer to backup my Palm and could use some suggestions on the > use of the other Linux pilot-* apps, particularly those that will let me > download new programs like PalmPython. Linux is my development platform. Download poppy.zip then: unzip poppy.zip pilot-xfer [-p port] -i pylib.prc python.prc press the hotsync button Jeff From stephen_purcell at yahoo.com Fri Jul 28 00:09:22 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 28 Jul 2000 14:09:22 +1000 Subject: Unary Operators In-Reply-To: <3980F944.19EBFF7C@hotmail.com>; from nospam4methx@hotmail.com on Fri, Jul 28, 2000 at 03:09:04AM +0000 References: <3980F944.19EBFF7C@hotmail.com> Message-ID: <20000728140922.C12152@inkontact.com.au> RC wrote: > Are there any unary operators (^, |, etc...) in Python such as in > Verilog HDL? There are not :-) Or, more fully, there are 'not', '~', '-', and '+'. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From alex at magenta.com Fri Jul 28 12:23:39 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 18:23:39 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> Message-ID: <8lsca101hv4@news2.newsguy.com> "Grant Edwards" wrote in message news:iWhg5.2682$6E.684157 at ptah.visi.com... [snip] > Why does "what non-programmers do" matter when designing a > programming language? It matters if you care about how easy/hard it is to turn those "non-programmers" into "programmers in the language you are designing". E.g., the CP4E project, which used to be aimed at turning _everybody_ into programmers, had better take a huge amount of care about it; while a language such as C++, which never had among its many design goals that of being at all easy or appropriate to learn as a first programming language, can basically ignore it. Where Python fits, I don't know, but I suspect it would be an excellent first-language (except for those who belong to the "bondage-and-discipline" school of programming, and/or of teaching-to-program, who would surely be better advised to look at Pascal or some of its successors). Alex From pi314 at hananet.net Sun Jul 30 13:13:53 2000 From: pi314 at hananet.net (Pi) Date: Mon, 31 Jul 2000 02:13:53 +0900 Subject: I have some problem about IDLE, help me... Message-ID: I install Python by Debian Pakage... python excute well... but IDLE does not... if I type "idle" I got below message... Traceback (innermost last): File "/usr/bin/idle", line 3, in ? PyShell.main() File "/usr/lib/idle/PyShell.py", line 612, in main fixwordbreaks(root) File "/usr/lib/idle/editorWindow.py", line 606, in fixwordbreaks tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is loaded TclError: extra characters after close-quote I can't see what is problem... It seems that fixwordbreaks() are source of problem... but I don't know what function is fixwordbreaks()... I excuted idle manually withbout script file... but I got same error message... If you know about this error message, Plz help me... If you know how to clear this problem, send me mail plz... leejongsoopekr at yahoo.com From lull at acm.org Fri Jul 14 09:29:02 2000 From: lull at acm.org (John Lull) Date: 14 Jul 2000 08:29:02 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> Message-ID: <595umsg1u1n29usa755ndag76uljkrgn0f@4ax.com> At the dawn of the third millenium (by the common reckoning), Gregory Lielens wrote (with possible deletions): > Indeed, but it is the old choice between functional/operator notation... > For example, the second expression, b = (X'*X)\(X'*y), would be in > functional notation > something like b=rDiv(Mul(X.T(),X),Mul(X.T(),y)) > This is ok, but imho far more error prone than operator notation, > because > - all linear algebra textbooks present expressions with operator > notation > - the operator notation is more natural to almost everybody when dealing > with arithmetic Absolutely. > I personnaly consider that linear algebra is an extension of simple > arithmetic, almost on the same level as complex numbers (and usefull to > the same kind of people which could use complex numbers). > The fact that complex numbers are part of built-in python types and can > be manipulated using standard arithmetic operators plead for a similar > facility for linear algebra, imho. Yes. Regards, John From lull at acm.org Thu Jul 20 21:27:02 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 20:27:02 -0500 Subject: Discussion: new operators for numerical computation References: Message-ID: At the dawn of the third millenium (by the common reckoning), hzhu at localhost.localdomain (Huaiyu Zhu) wrote (with possible deletions): > NumPy matrix NumPy element MatPy matrix Matpy element > @+ + + .+ > @- - - .- > @* * * .* > @/ / / ./ > /@ none what none > @** ** ** .** > > This provides the smoothest migration path for all the users. Note that the > cause of NumPy/MatPy inconsistency was the lack of binary operators. As > this already happened, it is difficult to integrate them until both got two > versions of operators. Problems: > > - This introduces 6+5 new operators. Ironically the previous lack of > operators actually results in more operators. > > - Having standard + - * / mean different things in NumPy and MatPy. I > personally find this no problem. In certain portions of my programs I need > elementwise operations exclusively, and I found it convenient to cast > everything into NumPy without trouble. > > - There's still no left division for MatPy. This, I think, would be a mistake, and would likely result in rejection of the proposal. We need to do what is right for Python, long term. If that results is short-term pain to a small user base, so be it. The *right* thing to do (IMO) is to have one set of new operators, with equivalent meaning in both NumPy and MatPy. Quite frankly, I prefer the .* notation, simply for consistency with Matlab if nothing else -- but the MatPy user base is likely far smaller than that for NumPy. This argues for your NumPy notation, or some other notation defaulting to elementwise, and MatPy may just have to change. I believe you agreed that element-wise is the appropriate default for other reasons, as well. This could be done relatively painlessly by renaming MatPy when the new operators show up, and allowing both to be installed on the same machine. It could also be done by providing duplicate class defintions, with slightly changed names, where the new classes use the new operators. The old classes could be clearly marked 'deprecated', and dropped after a year or so. If this is to be done, though, the change ought to start as soon as practical. Regards, John From wlav at hpatl26.cern.ch Wed Jul 5 09:43:38 2000 From: wlav at hpatl26.cern.ch (Wim Lavrijsen) Date: 5 Jul 2000 13:43:38 GMT Subject: "Write to a file" question please? References: Message-ID: <8jve2a$hg3$1@sunnews.cern.ch> cmfinlay at SPAMmagnet.com.au writes: >number = 100 >print "Number =", number >OUT = open("TT.txt","w") >OUT.write("Number =", number) # Error 'write' expects only 1 argument. You should build a string to hand to write. Something like: OUT.write( 'Number = %d' % number + '\n' ) Best regards, Wim Lavrijsen From cjc26 at nospam.cornell.edu Thu Jul 20 16:03:46 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 20 Jul 2000 20:03:46 GMT Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: * Remco Gerlich menulis: | > | > The easiest way: | > | > for line in file.readlines(): | > block | | But that would read the whole thing into memory, and he doesn't want that. | | Wouldn't an xreadlines() method on file objects be cool? readlines() has an optional argument which specifies the approximate number of bytes to read in at a time, rather than the entire file. So something like for line in file.readlines(8192): # process line would only use about 8k of memory. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From cjc26 at nospam.cornell.edu.bbs Mon Jul 17 19:30:03 2000 From: cjc26 at nospam.cornell.edu.bbs (cjc26 at nospam.cornell.edu.bbs) Date: 17 Jul 2000 23:30:03 GMT Subject: Type checking in python? Message-ID: <3bRTAS$l0I@openbazaar.net> * Paul Prescod menulis: | Matthew Cline wrote: | > | > def my_func(foo, bar, quux): | > if not isinstance(quux, Quux): | > raise RuntimeError("param 'quux' must be of class 'Quux'") | | Let me also point out that in many cases, this style of programming | would be frowned upon by serious Python programmers. For instance, if | you check that something is a string, your code will complain when it is | handed a Unicode string, even though it would probably work fine. If you | check that it is an open file, then your code probably will complain | about stringIO file-like objects, even though it would probably work | fine. If you check that it is an integer, your code will complain about | integers, even though ti would probably work fine. In that case, it'd be more useful to check if a particular object implements certain methods, rather than to check if it inherits from a particular class. For example, if you need a file-like object and you know you will be calling its readlines() method, then you can just call getattr(obj, "readlines") beforehand; if it doesn't raise an AttributeError then you're all set. I don't ever actually >do< that in my own code, though. ;) | In general, the Python philosophy is to "just try it" and see if it | works. Sometimes type checks are appropriate but if you do it on the | entry to every function, you are probably doing too much work and making | your own life (or someone else's) harder later on. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From smst at bigfoot.com Fri Jul 14 06:10:10 2000 From: smst at bigfoot.com (Steve Tregidgo) Date: Fri, 14 Jul 2000 10:10:10 GMT Subject: Python + Apache 1.3.x (CGI) not working (no mod_python) References: <8kmjlb$vji$1@nnrp1.deja.com> Message-ID: <8kmotr$30u$1@nnrp1.deja.com> In article <8kmjlb$vji$1 at nnrp1.deja.com>, genablu at my-deja.com wrote: > Please help! > > I am running the following Python program: > > #!/usr/bin/python > > print 'Content-type: text/plain' # Here's your problem: > print ' ' > print '' > print 'cgi-bin test' > print 'Hello, World!' > > in my /home/httpd/cgi-bin directory. Permissions are set to 755, > chown root.nobody. > > When I try requesting http://myserver.domain.com/cgi-bin/hello.py I > get the following error: > > INTERNAL SERVER ERROR > The server encountered an internal error or misconfiguration and was > unable to complete your request. > > malformed header from script. Bad header=:/home/httpd/cgi- bin/hello.py > The blank line following headers must consist of only a newline ('\n' or '\r\n'), but you're printing a space on that line. Try changing this: print ' ' ...to this: print # no args at all By not ending the headers correctly, every line you print is treated as a header -- and since none of them have correct header format, you get problems. HTH, Steve -- Steve Tregidgo Software Developer http://www.businesscollaborator.com Sent via Deja.com http://www.deja.com/ Before you buy. From tjhamilton at one.net.au Wed Jul 19 06:36:00 2000 From: tjhamilton at one.net.au (Terry) Date: Wed, 19 Jul 2000 20:36:00 +1000 Subject: Text UI Curses sample code Message-ID: <397583ee@pink.one.net.au> I have no experience with a text based UI and would appreciate all the advice and sample code I can get. Thanx in advance Terry From matthias_w at my-deja.com Fri Jul 21 08:26:37 2000 From: matthias_w at my-deja.com (Matthias) Date: Fri, 21 Jul 2000 12:26:37 GMT Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <8l68s5$3ht$1@nnrp1.deja.com> <3977C173.B93EB70B@my.signature> Message-ID: <8l9fhk$8lv$1@nnrp1.deja.com> Greg Ewing wrote: > Matthias wrote: > > > > for x,y,z in a&b&c: > > But a&b&c parses as (a&b)&c, which is not what > we want at all! this is not what i want, either [1,2,3]&[4,5,6] == [(1,4),(2,5),(3,6)] [1,2,3]&[4,5,6]&[7,8,9] == [((1,4),7),((2,4),8),((3,6),9)] .... thinking hard :-) .... [1,2,3]., [4,5,6] == [(1,4),(2,5),(3,6)] [1,2,3]., [4,5,6]., [7,8,9] == [(1,4,7),(2,4,8),(3,6,9)] so, ".," is an extension of the "," operator, ... .... thinking harder .... > Furthermore, there's no reason why a, b and c > couldn't be instances of classes which implement > & in such a way that the result is a valid > sequence type. very good point. I didn't think about that Matthias Sent via Deja.com http://www.deja.com/ Before you buy. From wjdandreta at worldnet.att.net Fri Jul 14 13:07:27 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Fri, 14 Jul 2000 17:07:27 GMT Subject: atof problem. References: <396EF501.5F1EF171@schneider-kamp.de> Message-ID: Hi Peter, Python Library Reference - 6.19, locale... Bill Peter Schneider-Kamp wrote in message <396EF501.5F1EF171 at schneider-kamp.de>... >> I guess my question was poorly worded. I was looking for the way to set the >> internal thousands separator to a comma so atof('1,142.00') results in >> 1142.00. It's clear from the doc's that it is posssible to do but it doesn't >> give enough info for me to figure out how. > >Can you cite the part of the Docs that say this? > >Peter From aulani1 at email.msn.com Thu Jul 20 17:56:00 2000 From: aulani1 at email.msn.com (Aulani) Date: Thu, 20 Jul 2000 11:56:00 -1000 Subject: Hawaii Surf-N-Camp Message-ID: <0152d2106111270CPIMSSMTPU08@email.msn.com> To Member,=20 We would like to invite you to come=20 and camp with the Hawaii Surf Academy.=20 We are having a week long surf camp=20 starting on August 10-16th, and we want=20 you to be there. The camps will be=20 held on the North Shore of Oahu, and=20 on the Big Island. Our camp will include=20 surf instructions, guided tours to=20 various places of the island, a polynesian=20 luau, bonfires, volleybal, night on=20 into town, hanging with locals, and=20 much much more. This will be an=20 experience you never experienced before=20 in Hawaii. At the present time we are=20 offering a introductory offer of 50% discount. Normally the camps would cos= t=20 $1050=20 including ground transportation, lodging,=20 tours, and food, but because you are=20 in the camping industry, we are offering=20 this special discount as an introductory=20 offer to you. We want you to come and=20 check out our camp, surf with us, and=20 have fun with us. Please let us know=20 if you would be interested, and more=20 information can be sent to you. Other=20 camp dates are as follows: October 6-12th: Oahu December 22-28th: Oahu December 23-Jan4. Big Island June 1-7th: Oahu June 8-14: Big Island To get in on the 50% discount, payment=20 must be made by Aug 5, 2000 Let us know if you have any questions or=20 want more information. You may either=20 email us at aulani1 at email.msn.com or=20 call us tollfree (877)222-4469. Look=20 forward to hearing from you! Aloha, Angela Stenger Hawaii Surf Academy Camp Coordinator Contact Information: Angela Stenger Hawaii Surf Academy Email: aulani1 at email.msn.com (877) 222-4469 -Tollfree (808) 382-6778 -Bus (708) 585-6457- Fax Registration Form ------------Please print, cut and mail---------- Name________________________ Age______ M/F Address_______________________ City_________ State/zip_______________________ Day #___________________ Even#_________________ Email________________________ Please send check to: Hawaii Surf Academy 941050 Kahimoe Pl Waipahu, HI. 96797 Check One: _____Enclosed is my non-refundable, yet transferable deposit of $200 per ca= mp.=20 Full payment due 1 wk before camp. _____Enclosed is my full payment of $525 per camp. Arrival information: Name of Airlines________________Arrival Date______ Arrival Time_____am/pm Flight #__________ From neilh at scintilla.org Mon Jul 17 05:46:33 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 17 Jul 2000 09:46:33 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: > working with the new Build 132 of Pythonwin we have a minor problem. > German Umlauts are not handled properly in the editor windows. > They are shown as boxes, some of them seem to be dead keys. > > The problem did not exist in previous builds. > Does anyone have a hint ? 132 defaults to using Unicode for editing Python source code and the interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and comment out the two lines under "# Enable Unicode if we can". Save the file, shut down Pythonwin and restart it and see if this fixes the problem. Yes, there should be an option to control this. Neil From supersede at india.com Mon Jul 3 05:24:48 2000 From: supersede at india.com (Extra Strength Flufferin) Date: 03 Jul 2000 05:24:48 -0400 Subject: 1.5.2 extentions under 1.6 References: <8jpi6m$4aa$1@nnrp1.deja.com> Message-ID: <87lmzjefbz.fsf@litterbox.meowing.net> Stephen Hansen wrote: > My question is -- does anything need to be changed in the sources, any > differences int he API, etc? Or is it simply something which is > modified in the Python.h which needs to be included in the extention > for it to work? The only real annoyance I've run into so far is that Py_Malloc() and company went away. It makes sense that they went away and it's easy enough to work around, but do watch your links carefully for undefined symbol warnings. From ulrich.schreiner at innuendo.de Sat Jul 29 05:12:20 2000 From: ulrich.schreiner at innuendo.de (Ulrich Schreiner) Date: Sat, 29 Jul 2000 11:12:20 +0200 Subject: Python is Zen (was Python is wierd) References: <39806045.F67EBD04@wag.caltech.edu> <8lt0ap$69q$2@newsg4.svr.pol.co.uk> Message-ID: <39829FF4.84DEDC6F@innuendo.de> http://www.bruceeckel.com/Python/ThinkingInPython.html "Bill de h?ra" wrote: > > Does this imply a "Thinking in Python"? > > -Bill de h?ra From robin at illusionsexeculink.com Fri Jul 14 15:32:34 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Fri, 14 Jul 2000 15:32:34 -0400 Subject: namespace sharing (longish) Message-ID: I'm having a great deal of difficulty wrapping my head around the namespace issue. All I want to do is execute user-supplied (eg: arbitrary) functions and have them share a namespace. So the first such function could define some variables and later functions could read their values. Simple. Or not? I constructed the following test script: # test.py BEGIN ########### import pprint if __name__ == "__main__": # seed the namespace namespace = {'var_main': 'hello'} # here lies my user module x = 'from test_lib import *' exec x in namespace del x # BEGIN KEY CODE # code to execute code1 = 'ret_one = one()' code2 = 'ret_two = two()' # compile it to be nice compiled1 = compile(code1, '', 'exec') compiled2 = compile(code2, '', 'exec') # go -- execute! exec compiled1 in namespace exec compiled2 in namespace # END KEY CODE # remove cruft from name space del code1, code2, compiled1, compiled2 # what do we have? print print '0000000000000000000000000' pp = pprint.PrettyPrinter() print 'local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) # test.py END ############# Then, the user module could look like: # test_lib.py BEGIN ########### def one(): import pprint # define a variable local to this routine var_one = 'in one' # check out our environment -- any sign of namespace? no?? print print '1111111111111111111111111' pp = pprint.PrettyPrinter() print ' local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) return 'one' def two(): import pprint # same as above -- for now # later this will catch variables defined in one() var_two = 'in two' print print '2222222222222222222222222' pp = pprint.PrettyPrinter() print ' local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) return 'two' # test_lib.py END ############# Then I tried a variation of test.py using the eval function in place of the exec statement: # BEGIN KEY CODE code1 = 'one()' code2 = 'two()' compiled1 = compile(code1, '', 'eval') compiled2 = compile(code2, '', 'eval') ret_one = eval(compiled1, namespace) ret_two = eval(compiled2, namespace) # END KEY CODE The results? The namespace appears to have no effect on the user routines. They cannot see var_main. Both methods produce the same (null) results. How do I do this? ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "We told it about general relativity and gravity, the kind of people that overcome hardships." From level2junkie at my-deja.com Mon Jul 10 10:35:15 2000 From: level2junkie at my-deja.com (level2junkie at my-deja.com) Date: Mon, 10 Jul 2000 14:35:15 GMT Subject: Dummies guide to freeze/standalone? Message-ID: <8kcmv4$uqo$1@nnrp2.deja.com> Can someone out there give me a direct answer on how to freeze a block of python script files? I've written a program that spans several files, but I can't seem to figure out how to package them. I'd like to be able to run this program on a machine that doesn't have python installed on it, otherwise what's the point? Has anyone out there figured out how to do this? If so can you please help me? Sent via Deja.com http://www.deja.com/ Before you buy. From frr at mindless.com Tue Jul 11 11:37:26 2000 From: frr at mindless.com (Fernando Rodríguez) Date: Tue, 11 Jul 2000 15:37:26 GMT Subject: checking the existence of a fiel Message-ID: Hi! How can I check if a file exists? O:-) TIA -- --------------------------------------- Fernando Rodr?guez From tiddlerdeja at my-deja.com Tue Jul 4 12:07:16 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 04 Jul 2000 16:07:16 GMT Subject: Java line to JPython (help Obj.class) Message-ID: <8jt239$jb3$1@nnrp1.deja.com> Can anyone help me turn this java line into JPython? URL dtdURL = DOMConfigurator.class.getResource("l"); The problem I'm getting is that DOMConfigurator doesn't seem to have attribute class. Is there a workaround? Any help appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From sdhyok at email.unc.edu Mon Jul 10 13:21:28 2000 From: sdhyok at email.unc.edu (Daehyok Shin) Date: Mon, 10 Jul 2000 13:21:28 -0400 Subject: Python book suggestions? References: Message-ID: <8kd0mo$mo1$1@news2.isis.unc.edu> The best book I find is "Python Essential Reference." "Randall Parker" wrote in message news:MPG.13d2b74a5f5c63ea98981c at news.onlynews.com... > I would like to learn Python because people I respect think highly of it. > I have backgroun in C++, Java, and assorted other languages. I intend to > use Python to do web site development. > > Does anyone have any suggestions as to which books are good for learning > the Python language? > > How about a book about Python and XML? > > How about a book about Python for web site development? > > I'm thinking of starting with the v1.6 version that I see from an article > has a number of language changes over previous versions. Are any books > due out imminently that will cover this newer version? > From fiona at sitegnome.com Sat Jul 29 10:37:23 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sun, 30 Jul 2000 00:37:23 +1000 Subject: Python in politics (sssssssssnake!) References: <3982EB8C.BD6DDE7C@sitegnome.com> Message-ID: <3982EC23.6F99B338@sitegnome.com> Answering my own mail :-) found the URL http://yhslug.tux.org/obp thanks. Fiona Czuczman wrote: > > > "Thinking like a computer scientist in Python", available at > > http://yhslug.tux.org.il/obp/ > > Is this the right URL? My browser is telling me it can't locate the > server.. > > thanks, > > Fiona From akuchlin at mems-exchange.org Fri Jul 28 09:04:12 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jul 2000 09:04:12 -0400 Subject: Perl is worse! References: Message-ID: <3d7la6v22b.fsf@kronos.cnri.reston.va.us> Moshe Zadka writes: > Huh? Is "ab" an integer? What happens when I do "ab"+1? 1+"ab"? > What happens when I do 1+(6.0**100000)-(6.0^100000)? $v = "abc"; $v++; produces "abd". 1 + '0xff' produces 2.9921875. A long time ago in comp.risks, someone reported a bug in a JavaScript mortgage calculator. The calculator used eval(), not atoi(), to convert strings to integers; a side effect of this was that leading zeros would cause a number to be interpreted as octal, so 01000 was not the same as 1000. For a mortgage calculation, where the user may not have an estimate of what the correct result is, most users would probably never discover the error. --amk From olivierS.dagenaisP at canadaA.comM.bbs Mon Jul 17 00:10:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 17 Jul 2000 04:10:02 GMT Subject: Wishlist sumbission form? Message-ID: <3bQl0Q$kaN@openbazaar.net> In the future, everyone will be a programmer and will be able to implement their own ideas quickly. That, or when they start realizing that all of humankind have become geeks, they'll just get rid of all computers and we'll go back to grunting and hunting for food. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Paul Prescod" wrote in message news:39727EFB.77234AEA at prescod.net... > Matthew Cline wrote: > > > > Is there any way of submitting feature requests for Python, > > other than by filing a bug report? > > I don't think so. If it is a very targeted request, you could try the > but report route. If it is large and arguable, you should probably post > it here and get some people to support it. If its good, someone will > implement it. In open source software, only the features that developers > are interested in get implemented so a wish list might well get ignored > anyhow. It's not that nobody cares what you think it's that there's an > infinite list of wishes so people tend to attack them in the order in > order of personal interest or widespread demand. > -- > Paul Prescod - Not encumbered by corporate consensus > It's difficult to extract sense from strings, but they're the only > communication coin we can count on. > - http://www.cs.yale.edu/~perlis-alan/quotes.html > From serve at circe.dem.nl Sun Jul 23 07:20:08 2000 From: serve at circe.dem.nl (slaurijssen) Date: Sun, 23 Jul 2000 13:20:08 +0200 Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> Message-ID: <964351215.18988.0.pluto.d4ee0942@news.demon.nl> Oh, I'm sorry. I didn't realize there would actually be someone that actually wants to use it. What's the point in using a C++-interpreter when it's just as easy to compile the source, which has more advantages? But who am I to argue, the package is called CINT and I found a link at http://root.cern.ch/root/Cint.html Jm schreef in berichtnieuws 397ab732.1184204 at news.proxad.net... > Do you have a link to it, > or at least the name of that interpreter ?? > > -- > > On Thu, 20 Jul 2000 20:36:49 +0200, "slauijssen" > wrote: > > >Err, by the way > >On a linux cd I found a C++ interpreter. The funny thing is that the > >interpreter itself is written with c++ and interprets itself to interpret > >the really to interpret code. Got it? ;-) > > > >Mallor schreef in berichtnieuws > >v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... > >> Are any of you game developers out there using Python as your game > >engine's > >> embedded scripting language? I am wondering what drove your decision to > >use > >> Python instead of other embeddable scripting languages? I'd like to hear > >what > >> your overriding concerns were, and also what they are now, having put > >Python to > >> the test. > >> > >> -- > >> Cheers, Infernal Troublemaker Troll > >> Mallor "By simple mistake, mortals themselves amuse." > >> > >> > >> > > > > > From johngrayson at home.com Thu Jul 20 16:29:26 2000 From: johngrayson at home.com (John Grayson) Date: Thu, 20 Jul 2000 20:29:26 GMT Subject: Tkinter Problem with Radiobuttons References: <3974E55A.FED978BD@leland.stanford.edu> Message-ID: <8l7neo$5tq$1@nnrp1.deja.com> In article <3974E55A.FED978BD at leland.stanford.edu>, Ryan Vartanian wrote: You must use IntVar's get method to obtain the value: result = self.selection.get() Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Wed Jul 19 09:17:35 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 19 Jul 2000 13:17:35 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 19th, 2000 Message-ID: <20000719131735.23279.qmail@synop.com> Hello All, Yet another instalment of entries into http://python.faqts.com regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- grouping in regular expressions http://www.faqts.com/knowledge-base/view.phtml/aid/4860 ------------------------------------------------------------- Fiona Czuczman Wolfgang Strobl Problem: I am finding it difficult to match the ip address in the following line using re module. " inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0" Solution: >>> import re >>> s=" inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0" >>> p=re.compile('\s+inet addr:(\d+\.\d+\.\d+\.\d+)\s+.*') >>> p.match(s).groups() ('192.168.0.1',) >>> ------------------------------------------------------------- How can I make it so the interpreter defaults to hexidecimal output? http://www.faqts.com/knowledge-base/view.phtml/aid/4863 ------------------------------------------------------------- Fiona Czuczman J?rgen Hermann Problem: what I mean is the following: >>> i = 0xa >>> print i 10 >>> i 10 what I really want is to get the following: >>> i = 0xa >>> i 0xa Solution: Then write a HexInt class that overloads __str__ and __repr__, and use i = HexInt(0xa). I see no other way. ------------------------------------------------------------- Does Python support any sort of floating point "not a number" (e.g. IEEE infinity)? http://www.faqts.com/knowledge-base/view.phtml/aid/4864 ------------------------------------------------------------- Fiona Czuczman Huaiyu Zhu, Warren Focke This seems to work and is used in MatPy: Inf = inf = 1e300**2 NaN = nan = inf - inf ----------- Python floats inherit the behavior of your C platform's doubles, so on an IEEE-754 system, they will act fairly IEEE-like, as Huaiyu demonstrates: >Inf = inf = 1e300**2 >NaN = nan = inf - inf However, according to a recent post, the OpenVMS port of python uses VAX-format math[1], which has less exponent range than IEEE. I think that that expression for Inf will not parse there. I don't even know if VAXen have Inf or NaN. ----------- According to discussions on comp.lang.python, there is no universal way to treat NaN, but the following codes work on Windows (NT and 98), Solaris (2.7 with gcc) and Linux (RH6.1 with egcs). It core dumps on Tru64 Unix on Compaq Alpha [Solution: When using DEC (Compaq) compiler to build Python try using -ieee switch]. Supposedly it should work on any machine using IEEE arithmetics. An alternative that sometimes works is NaN = math.exp(1000) / math.exp(1000) ## Edited Entries ############################################## ------------------------------------------------------------- How can I catch an error in re.compile? How can I test for a bad regular expression? http://www.faqts.com/knowledge-base/view.phtml/aid/1357 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Fredrik Lundh Why not just compile a bad expression and see what happens? ;-) >>> re.compile("(") Traceback (innermost last): File "", line 1, in ? File "C:\py152\lib\re.py", line 79, in compile code=pcre_compile(pattern, flags, groupindex) pcre.error: ('missing )', 1) (to catch the exception, use try/except re.error) ------------------------------------------------------------- Can a class have two __init__ functions with different argument lists? http://www.faqts.com/knowledge-base/view.phtml/aid/4799 ------------------------------------------------------------- Mark Tomko, Michael Hudson No, not really. There are workarounds; the lowest-tech is something along the lines of: class C: def __init__(*args): if len(args) == 1: apply(args[0].init0,args) else: apply(args[0].init1,args) def init0(self): print "no args!" def init1(self): print "one arg!" Also, in some circumstances it may be possible to create the instance using the new module and then choose which initialization function to call. This is definitely an experts only solution... I have used it in eg: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/bytecodehacks/bytecodehacks/code_editor.py?rev=1.7.2.1&content-type=text/x-cvsweb-markup&cvsroot=bytecodehacks (nice long url, sorry) about 40 lines in. ------------------------------------------------------------- Could someone give me a simple explanation of regular expressions? http://www.faqts.com/knowledge-base/view.phtml/aid/3870 ------------------------------------------------------------- Fiona Czuczman Andrew Kuchling Regular expressions are a mini-language for defining a certain set of strings; the re module then takes a regular expression and tells you if a given string matches the expression. For example, [abc] means 'a', 'b', or 'c'; \bA.*?\b means a word beginning with 'A' (\b is a special sequence meaning "match a word boundary"). As you can see, regular expressions are concise but can easily be obscure. Regular expressions will practically never be faster than a simple string.find, so if you're searching for a fixed string, don't use regular expressions; their extra expressive power costs you in performance. But they can do things that aren't possible with the string module alone, and would require several lines of Python code to implement. Consult the Library Reference, or the Regular Expression HOWTO for more info. (http://www.python.org/doc/current/lib/module-re.html, http://www.python.org/doc/howto/regex/) From maxm at normik.dk Wed Jul 5 04:34:15 2000 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Wed, 5 Jul 2000 10:34:15 +0200 Subject: Again: ODBC / Win98 -> crash Message-ID: <7BD10B680501D411B9DF009027E06F32011AE8@EXCHANGE> Fra: Matthias Huening [mailto:matthias.huening at univie.ac.at] >Now for a really strange thing: I just moved my script to a different >computer (almost identical configuration), and... - everything works >just fine! No crashes, no problems whatsoever. I hate computers. Maybe the machine it crashed on had Office 2K installede recently ??? and the one that doesn't crash hasn't or something like that. The combination of Win2k, Office2000/97 has caused me no end of grief. Try installing the newest version of mdac on your machine. (should not be needed on win 2K). Also check your security settings and r/w acces. Combinations of these two has helped me before. Regards Max M From theebh at yahoo.com Tue Jul 25 08:32:05 2000 From: theebh at yahoo.com (Jonathan) Date: Tue, 25 Jul 2000 12:32:05 GMT Subject: Python is wierd! References: Message-ID: <8lk1c5$fv4$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > A few quickies: > > [Jonathan] > > Hi, just finished going through the 'Learning Python' book, and the > > feeling that i get is that Python is really wierd(compared to other > > conventional languages like C++, Java, etc). For e.g.(correct me if i'm > > wrong) > > ... > > 3. No keywords to differentiate between passing arguments by reference > > or value! An integer is passed by value(reference to a new copy), while > > a mutable object is by reference. To pass a list by 'value', i know you > > just need to insert one more line(list = [:]), but it seems > > so 'inconsistent' compared to Java or even PHP. > > I'm surprised you got that impression from the book. It isn't a true one. > Everything in Python is passed by reference, always; Python never (ever!) > makes a copy of anything unless you explicitly ask for one. What you > describe is actually much closer to the way Java works. Oops...maybe i typed too fast! What i meant to say was: passing an immutable object by reference simulates the "pass-by-value" feature of other programming languages. And the book did make it clearly:) > > > (Not to mention the number of 'gotchas' listed in the book that are > > bound to trap beginners - *shudder*) > > You'll find that (by far) most Python users believe the language has far > fewer gotchas than other languages they've used. I'm certain the book did > *not* say the gotchas they list at the end of each chapter "are bound to > trap beginners". Different people have different blind spots, and the > authors did a remarkable service by listing the *union* of "gotchas" they've > seen beginners get got by . There are very few gotchas in Python that > *most* beginners suffer (stark contrast with C, C++ or Perl is dead easy). > See also Andrew Kuchling's "Python Warts" paper: > > http://starship.python.net/crew/amk/python/writing/warts.html > > That lists deep areas of ongoing (and going, and going ) debate. The > "beginner gotchas" are much shallower, and the best predictor I know of for > which feature will trip which beginner is the programming language they used > most before coming to Python. It's insane to believe that language X > "should" work exactly like language Y, and beginners who don't come in with > an insane attitude very quickly adjust. > Yep, point taken. I think the book did a good job by listing out all the potential gotchas that might trap a newbie. What i was thinking is the nature of the 'gotchas' that arise in python. My knowledge in programming is quite shallow(i must admit), and my progress was from 'pascal'->'c'->'c++/java'->'perl'->'php'. Along the way, of course there are a few 'gotchas' in each language, but most of them did not throw much surprises(except perl - the 'blessing' part for e.g.) > As the years have gone by, I've gotten a sick, hypocritical thrill out of > cruising other language newsgroups, and finally seeing people complain that > language X, Y or Z doesn't work exactly like Python <0.9 wink>. > > > The reason i'm picking up python is that i got sick of PERL:), > > There are many here who came to Python for the same reason. Don't expect > Python to act like Perl, and I predict you'll be happy. If you left Perl > reluctantly, you may also want to give Ruby a try. One suggestion: stop > reading so much and write some damn code already . > ok, ok i'm trying to write some codes soon:) I don't expect Python to be the same as PERL, else i wouldn't have bothered picking it up:) > > ... > > Pascal(for procedural) and Java(for OOP) is still the better choice to > > start off, IMHO. > > Try to reserve judgment until you've actually used the language. Are you > old enough to remember the then-famous 1977 paper "Ambiguities and > Insecurities in Pascal", by Welsh, Sneeringer and Hoare? A frank discussion > of *any* language's lapses from perfection will scare the snot out of > anybody who only reads about the language. The Python community is very > open about what they think is lacking in the language; curiously, though, > there's almost no consensus on what that is. > > don't-reply-start-coding-ly y'rs - tim > I'm making this judgment from a perspective of a newbie to python, comparing to my experience with these 2 languages(back when i first started learning them). I'm thinking back which one has been easy to pick up so far, and which one helps me to understand programming principles. Things like strict typing, declaration of functions/variables, difference btwn pass-by-value or pass-by- reference, static or instance variables, (etc) seems easier to explain to a newbie in Pascal or Java (of course i dun mean to use pascal for serious programming purposes). regards, jonathan Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at users.sourceforge.net Fri Jul 28 21:16:57 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Sat, 29 Jul 2000 01:16:57 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> <39822757.A5803B9B@alcyone.com> Message-ID: On Sat, 29 Jul 2000 00:50:46 GMT, Steve Lamb wrote: >On Fri, 28 Jul 2000 17:37:43 -0700, Erik Max Francis wrote: >>> Mmmm, in as far as I can read that, yes. It is the operation that >>> determines the type of the data, not the data in and of itself. > >>Not in a strongly typed language like Python, it doesn't. > > Pardon my french but... no shit sherlock. That has been my point all the >long. I feel that such a thing, as is somewhat evident in Perl, is not the >bad thing that some people in Python make it out to be. I never once claimed >that Python did it. > You seem to want Python operations to depend on the context as Perl dos. You may be interested in reading my simple analysis of why this is bad http://www.python.org/pipermail/python-list/2000-July/109243.html The key point is that a good language should not force a reader maintain a very complicated mental picture while reading the code - you understand a block of code independently of the context it is used, and when you use it elsewhere you do not need to understand how it's implemented. Huaiyu From MarkH at ActiveState.com Tue Jul 25 20:38:17 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 26 Jul 2000 00:38:17 GMT Subject: Two COM Questions: QueryInterface, and Callback Inheritance References: <3pnf5.50267$DH3.1583089@news-east.usenetserver.com> Message-ID: > QUESTION ONE: > How to QueryInterface for a new dispatch interface? You just perform the QI - but on the "_oleobj_" object. ie: > >>> import win32com.client > >>> d = Dispatch("MyCoolThing.App") > >>> s = d.GetOtherThing() You need to do something like: >>> s = d.GetOtherThing() >>> other_s = s._oleobj_.QueryInterface("{new_iid}") >>> s = Dispatch(other_s) # Turn it back into a useful object. > QUESTION TWO: > How to subclass a class based on Dispatch? Can it work at all? You don't want to "subclass" - you want to implement an interface. Basically, you want to create a COM server object, but _not_ have it registered. I'm afraid I dont have the time to answer this in detail - you can either try and big up old posts of mine (but Deja sucks these days), or buy my book, or beg someone with my book to outline the steps and provide some code... http://starship.python.net/crew/mhammond/ppw32 is where you can find the book samples - code that demonstrates this is buried somewhere in there in the "Advanced COM" chapter. Mark. From dworkin at ccs.neu.edu Sun Jul 23 23:04:08 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 23 Jul 2000 23:04:08 -0400 Subject: Does Python support interfaces? In-Reply-To: "Eric Hopper"'s message of "Tue, 18 Jul 2000 10:14:57 -0600" References: Message-ID: "Eric Hopper" writes: > > If it behaves properly, it behaves properly, and that is all that > > matters. > > Whee! Inheritance by mysteriously coinciding method names is so much fun! Where do you get "mysterious" out of that? You choose your method names. If they are mysterious, it's your fault. -Justin From Armin at Steinhoff_de.bbs Mon Jul 17 04:50:02 2000 From: Armin at Steinhoff_de.bbs (Armin at Steinhoff_de.bbs) Date: 17 Jul 2000 08:50:02 GMT Subject: Type checking in python? Message-ID: <3bR6EQ$kSL@openbazaar.net> In article , Matthew says... > >It would be nice if I could do something like: > > def my_func(int foo, list bar, Quux quux): > ... > >rather than > > def my_func(foo, bar, quux): > if not isinstance(quux, Quux): That's plain C ... if not quux.isinstance(Quux): is more flexible ... so you have just to implement that method in your class definition Regards Armin > raise RuntimeError("param 'quux' must be of class 'Quux'") > >Is there any plans on doing this for Python 3000? Or will something >like this never be a part of Python? > > From baron at null.net Sat Jul 8 00:48:11 2000 From: baron at null.net (Matthew Schinckel) Date: Sat, 8 Jul 2000 14:18:11 +0930 Subject: EOF In-Reply-To: <396623EE.211B14E9@sis.it> References: <396623EE.211B14E9@sis.it> Message-ID: On Fri, 7 Jul 2000, fae wrote: > > Sorry, > how can I test if I reached the end of file ? > > thanks , > Leonardo. > That's okay, How about: (assuming this somewhere above:) f = open(filename, 'r') if f.tell(0,2): print "EOF!" -- Matthew Schinckel ARCHDUKE FERDINAND FOUND ALIVE -- FIRST WORLD WAR MISTAKE From paul at gudge.demon.co.uk Mon Jul 31 12:20:10 2000 From: paul at gudge.demon.co.uk (Paul Goodyear) Date: Mon, 31 Jul 2000 16:20:10 GMT Subject: Retrieving a query string from a
command Message-ID: <_Ghh5.853$7F2.53864@news3.cableinet.net> Yep i'm a newbie here. Been doing this stuff for about a month and it rocks. The thing is I wrote a guestbook and for the last weeks it's been working fine. But all of a sudden the text that is sent to my server from the web page in the comments text input or textarea boxes are sent with +'s instead of spaces. I have tried both action="get" and action="post" in the HTML code. I have put the code below that does the grabbing: HTML CODE: --------------- PYTHON CODE: ------------------- import time, string, os print "Content-type: text/html\n\n" qs = os.environ['QUERY_STRING'] t = string.split(qs, "?") tt = string.split(t[0], '&') NameString = string.split(tt[0], '=') EmailString = string.split(tt[1], '=') CommentString = string.split(tt[2], '='); TimeString = time.ctime(time.time()) GuestList = open('cgi-bin/guestbook.txt') CurrentGuest = GuestList.readlines() GuestList.close() GuestList = open('cgi-bin/guestbook.txt', 'w') line = NameString[1] + ',' + EmailString[1] + ',' + CommentString[1] + ',' + TimeString + '\n' GuestList.write(line) GuestList.writelines(CurrentGuest) GuestList.close() I'm taking the query string and placing all the fields into variables, reading in the current entries and then writing them all out again. But as I said and why I need help is that all the spaces are now been replaced with + sysbols, which can I stress didn't do at first. I have changed the code and put it back and it did just the same. Please help. email or post. From peter at schneider-kamp.de Sun Jul 23 18:55:51 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Sun, 23 Jul 2000 22:55:51 +0000 Subject: zip() : how about braid() References: <8l6cbp$fgr$1@pollux.ip-plus.net> <3977C2A8.6D8F7586@my.signature> <8la8ib$8um$1@slb2.atl.mindspring.net> <01ihns4q4urkisti1mc02kadfohpo32mov@4ax.com> <397A47C8.B19D60B1@easystreet.com> <397B2A05.2115DB6D@roguewave.com> Message-ID: <397B77F7.A0979195@schneider-kamp.de> Bjorn Pettersen wrote: > > Anyone suggested parallel yet? Yes. Why not have a look at the PEP first? http://python.sourceforge.net/peps/pep-0201.html Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From gmcm at hypernet.com Thu Jul 20 19:39:32 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jul 2000 23:39:32 GMT Subject: How to hook import? References: <8l6dsf$1mu$1@desig-bs01-s04.adtranzsig.de> Message-ID: <8F77CBF93gmcmhypernetcom@199.171.54.155> Dirk-Ulrich Heise wrote: >A question to the Developers: > >What's the official way to overload the behaviour >of import()? The current "official" way is still ihooks, but imputil will be in the std lib real soon now, and most people find it quite a bit easier to use. -Gordon From wlfraed at ix.netcom.com Sat Jul 8 19:42:48 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sat, 08 Jul 2000 16:42:48 -0700 Subject: How to print to stdout in binary References: <8k1kn5$mkt$1@nnrp1.deja.com> <3965408E.DDD4A2@pehr.net> <39675F00.DC04D6E9@sprynet.com> Message-ID: On Sat, 08 Jul 2000 17:04:00 +0000, Adam DePrince declaimed the following in comp.lang.python: > VMS: > Set the file's binary flag accordingly. Does anybody know if VMS does > Windows style translation too? > Considering that VMS has some half dozen "text" formats (fixed length records, variable length using control, variable length using FORTRAN control codes, etc.) I'd hope VMS RMS services could figure out the proper way to read a file from the directory data -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From claird at starbase.neosoft.com Mon Jul 31 00:24:16 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jul 2000 23:24:16 -0500 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> Message-ID: <6C76ABF30A7A02C4.6102B487AA52D46C.1E73B3C959C568A9@lp.airnews.net> In article , Andreas Kupries wrote: . . . > >> Syntax separation - multiple syntaxes ? >> Perl6 offers the possibility to ... write Perl programs in multiple >> syntaxes such as Python, JavaScript, and Perl5 ... > >This reminds me of Guile, which tried to do the same thing, no ? Still trying. The latest snapshot is less than a month old. . [apt sociologic remarks on developmental mechan- isms] . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From nobody at nowhere.nohow Thu Jul 27 17:50:21 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Thu, 27 Jul 2000 21:50:21 GMT Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> <39808e81.145010138@news.telus.net> Message-ID: In article , Steve Lamb wrote: >>IMO, they're detrimental, and should not be offered. > > YEAH!!! I say everyone should have to program in nothing but 0s and 1s! You use 1's? Wimp! -- Grant Edwards grante Yow! Hmmm... A hash-singer at and a cross-eyed guy were visi.com SLEEPING on a deserted island, when... From hzhu at knowledgetrack.com Fri Jul 14 19:12:58 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Fri, 14 Jul 2000 23:12:58 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> Message-ID: On Fri, 14 Jul 2000 11:38:51 -0600, Bjorn Pettersen wrote: > >Well, this could actually be generally useful, but not with the .+ >syntax (since the dot would interfer with methods on the sequence >object). My impression from the python-dev list is that this is not the case. Some say it is easy to distinguish a. + b a .+ b Some say it is difficult. But the first is a syntax error anyway. The only real danger is 3. + a 3 .+ a But in this case pointwise operation does not make sense. So I suppose the following rules would resolve all the ambiguities: Dot binds with preceding number. Otherwise it binds with following operator. Otherwise it is a member indicator. Otherwise it is syntax error. Examples: 2.+b a.+b <-- only this is new a.b a.3 -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From MarkH at ActiveState.com Fri Jul 21 09:28:53 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 21 Jul 2000 13:28:53 GMT Subject: Pythonwin attribute expansion References: <326536345498D311B3BC00105A39802A0747A7@newsintern.dspace.de> <8l79ou$shk$1@nnrp1.deja.com> Message-ID: "Howard B. Golden" wrote in message news:8l79ou$shk$1 at nnrp1.deja.com... ... > Note this timeline for problem resolution: > > - Problem found/message on c.l.p: 2000 July 20 0000 GMT (California) > - Solution suggested: 2000 July 20 0215 GMT (Australia) > - Solution coded: 2000 July 20 ???? GMT (Germany) > - Solution accepted: 2000 July 20 1600 GMT (California) Hey - I like this. It means that by _not_ actually providing an answer, I am doing the Open Source movement a favour! Wishing-I-discovered-that-years-ago--ly, Mark. From huaiyu_zhu at rock.localdomain Sat Jul 15 18:25:08 2000 From: huaiyu_zhu at rock.localdomain (Huaiyu Zhu) Date: Sat, 15 Jul 2000 15:25:08 -0700 Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: References: Message-ID: <200007152225.PAA09463@rock.localdomain> In comp.lang.python, you wrote: > >B*[sin(A*x+b).*(A*y)/3]/C > >Is spelled > >(Assume all matrices are originall matrix-wise) > ># sin() already works element by element, unless you define ># sin(A) = A-(A^3/3!)+(A^5/5!)-.... >B*(sin(A*x+b).Element()*(A*y).Element()/3)/C > Hmm, I can see one advantage of writing a.*b as a.Element()*b.Element() That is, instead of sinm(x) and sin(x) we can write sin(x) and sin(x.Element()) But both functions still need to be implemented, and each function call would involve a member lookup, an initializsation and a type comparison. So overall it is perhaps disadvantageous. BTW, the matrix sin function is equivalent to the Taylor expansion, but it is calculated differently, using eigendecomposition. Huaiyu From shouldbe at message.com Fri Jul 7 10:25:15 2000 From: shouldbe at message.com (Arinté) Date: Fri, 07 Jul 2000 14:25:15 GMT Subject: More PyArg questions? Message-ID: Is PyArg_ParseTuple and PyArg_ParseTupleKeywords (or whatever it is) the only two to monkey are with arguments passed from python to c++? Also, what would be the best way to set a string that the python script wants to be filled in. Ex. some.py fillinstring = " " cplusplusapp.read(fillinstring) What is the best way for C++ apps to fill in that string? Are python strings going to be resizable? From mfein at aplcomm.jhuapl.edu Fri Jul 14 08:52:39 2000 From: mfein at aplcomm.jhuapl.edu (Matt Feinstein) Date: Fri, 14 Jul 2000 12:52:39 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396daf35.3870545@aplnews> <396f0031.3421579@aplnews> <396F0CB9.F51B4D53@fft.be> Message-ID: <396f0ce6.6675048@aplnews> On Fri, 14 Jul 2000 14:51:05 +0200, Gregory Lielens wrote: > >> >>The main thing I'd think about in addition to standard MATLAB syntax >> >>is a natural 'prolongation' syntax. >> What I mean is, given vectors, e.g., >> >> d = [d1 d2] >> c = [ c1 c2 c3] >> >> an apparently incorrect element-wise multiplication like >> >> d'.*c >> >> would be interpreted as >> >> [d1 d1 d1; d2 d2 d2].*[c1 c2 c3;c1 c2 c3] >> >which is a classical matrix product d'*c, I think,at least if you >distinguish between line and column vectors... > AUUGH. That's what happens when you post too early in the morning. -- Matt Feinstein mfein at aplcomm.jhuapl.edu Organizational Department of Repeated and Unnecessary Redundancy From erno at iki.fi Thu Jul 13 02:38:44 2000 From: erno at iki.fi (Erno Kuusela) Date: 13 Jul 2000 09:38:44 +0300 Subject: File IO with select? References: <396BBCE9.2C114ED3@tgflinux.com> Message-ID: >>>>> "Jared" == Jared Lee Peterson writes: Jared> wait until process two writes to the file before it can Jared> then read from it. I am trying to use select() for this won't work on regular files. use file locking (see the fcntl mdoule). -- erno From kelley at bioreason.com Fri Jul 14 06:27:11 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 14 Jul 2000 11:27:11 +0100 Subject: string issue or questions about intern Message-ID: <396EEAFF.3AD7B951@bioreason.com> How can you tell what's in the intern table? This is really in response to the thread "Is pickle buggy?" where we are trying to trace down a memory leak. Jepler epler has an example piece of code: while 1: eval(`uniquestring()`) where unique string returns a unique 5 character string per call. This appears to run out of memory after a while on his linux box and on my NT box. now if uniquestring returns something like 'a="AAAAA"' while 1: eval(`uniquestring()`) Memory stays constant. So, does eval('"AAAAA"') intern "AAAAA" or simply not clean up the memory since it is not assigned to a variable? And does this have anything to do with a potential memory leak in pickle? (See the thread if you are interested) -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From cander at ieor.berkeley.edu Thu Jul 13 20:49:15 2000 From: cander at ieor.berkeley.edu (Charles Anderson) Date: Thu, 13 Jul 2000 17:49:15 -0700 Subject: Reading cookies on the client side Message-ID: <396E638A.DD2CD797@ieor.berkeley.edu> I was trying to figure out how to write a robot of sorts to get some info from a site that uses cookies. I poked around, and there didn't seem to be anything existing in Python to handle it. So, I wrote an extension of FancyURLopen. The biggest problem I had to deal with was the site I was connecting to returned some cookies then did a redirect to another page that returned more cookies. All of the cookies are needed for subsequent interactions. So, this class overrides the handler for 302 redirects. Caveat: I didn't know Jack about cookies or HTTP when I started this. Therefore, this may be completely wacked, but it works for me. enjoy, Charles. ------ from urllib import FancyURLopener import string class CookieURLopener(FancyURLopener): def __init__(self): FancyURLopener.__init__(self) self.cookies = [] def open_http(self, url, data=None): """Handle an HTTP open request. We pass this to FancyURLopener to do the real work. Afterwards, we scan the info() for cookies.""" result = FancyURLopener.open_http(self, url, data) self.eatCookies(result.info()) return result def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Handle an HTTP redirect. First we get the cookies from the headers off of the initial URL. Then hand it off to the super-class, which will call back into our open_http method, where we can pick up more cookies.""" self.eatCookies(headers) result = FancyURLopener.http_error_302(self, url, fp, errcode, errmsg, headers, data=None) return result def eatCookies(self, headers): """Scan a set of response headers for cookies. We add each cookie to our list.""" cookies = headers.getallmatchingheaders('set-cookie') for c in cookies: self.addCookie(string.strip(c[12:])) # "set-cookie: " is 11 characters def addCookie(self, cookie): """Add a cookie to our cache of them and call addheaders of our parent.""" self.cookies.append(cookie) self.addheader('Cookie', cookie) def dumpCookies(self): for c in self.cookies: print 'cookie:', c From sean at digitome.com Sun Jul 2 07:53:00 2000 From: sean at digitome.com (Sean Mc Grath) Date: Sun, 02 Jul 2000 11:53:00 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> Message-ID: <395f2748.1996610@news.iol.ie> The was a typo that could lead to confusion + a genuinely unforseen and unintentional pun in the original post. I have fixed the typo but left in the pun here: ------------------------- I have a reproduceable GPF on NT when pickking objects of a class that has a __getattr__ implementation. Take out the __getattr__ and the pickle works fine. Are there ways to implement __getattr__ and yet preserve the ability to pickle? regards, From hzhu at users.sourceforge.net Fri Jul 28 21:20:13 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Sat, 29 Jul 2000 01:20:13 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: On Sat, 29 Jul 2000 00:52:33 GMT, Steve Lamb wrote: >>If they already contained numbers (well, strings of digits), and you were >>certain, then simply: > >> a = int(b) > > As stated, that would work except Python returns a None on a no-match and >None can't be converted. > That's good, because None usually indicates there is nothing (not even a zero), if b is None: print "Ok, we'll finish here" break else: a = int(b) Huaiyu From aruth at intercation.com Wed Jul 26 10:23:34 2000 From: aruth at intercation.com (Adam Ruth) Date: Wed, 26 Jul 2000 08:23:34 -0600 Subject: Python is wierd! References: <200007250541.PAA25542@envy.fulcrum.com.au> Message-ID: <8lmsci$1sf8$1@news.aros.net> I learned dynamic languages when one day I decided to learn Smalltalk. I had the same problems you did at first. No types, classes that can change at run time, no "proper" encapsulation. How could anyone build anything that works in such a language. But the thing that kept coming back to me was that just prior to my picking up Smalltalk I read that a stock trading system was just rolled-out in Smalltalk that handled 50% of all stock trades in North America. So it must work somehow. Here's the main point that I learned that finally got me over the hump: There is no compile cycle, only a testing cycle, at which point you're sure that everything works. With compile-time checking you can easily fall into the trap that 'it compiled--it must work'. Especially for small changes. With dynamic languages, you can never assume that so you always test. You should always test all your changes with a static language too, but the incentive to do so is less. Once you get the mindset that 'it's okay because I tested it and it worked', your dynamic code will have a quality that intuitively must not be there. -- Adam Ruth InterCation, Inc. www.intercation.com "Richard Jones" wrote in message news:200007250541.PAA25542 at envy.fulcrum.com.au... > > [Jonathan] > > 1. There are no keywords to declare static or instance variables; it > > all depends where they are placed(whether it's right after the > > statement, or inside a ). Isn't it harder for other programmers to > > know at one glance what type of attributes the class define? > > I thought it was perfectly clear - much clearer than some other languages :) > > Static attributes are assigned at class definition. Instance attributes are > assigned to an instance once it's created. That's pretty straightforward. If > there's a confusion at a later stage about whether an attribute is instance- or > class- then you've probably got a fundamental design problem in your class... > > > > 2. No *formal* declaration of static class methods, e.g. no 'static' > > keyword (though i'm not sure how useful static methods are in OOP > > design). I read somewhere in this newsgroup that the workaround way is > > to define the method outside of the class - doesn't it break > > the 'encapsulation' a class suppose to have? > > The generally accepted method is to put these utility functions where they > logically belong: in the module that defines the class, but not in the class > itself. If it doesn't operate on an instance, what business does it have in the > class definition. I use static methods in Java for one thing only: utility > functions. That's because Java won't let me have stand-alone functions. (That's > not a dig at Java!) > > > > 3. No keywords to differentiate between passing arguments by reference > > or value! An integer is passed by value(reference to a new copy), while > > a mutable object is by reference. To pass a list by 'value', i know you > > just need to insert one more line(list = [:]), but it seems > > so 'inconsistent' compared to Java or even PHP. > > Nope, everything is pass-by-reference in Python. Even your integer is > pass-by-reference, but since it's an immutable object, it might _seem_ like > you're passing the value of the object. > > > > (Not to mention the number of 'gotchas' listed in the book that are > > bound to trap beginners - *shudder*) > > Gotchas? I've not read the book - are these actually stated in the book as > gotchas? I'll personally beat on the head of the author if they are :) > > > Richard > > > From darrell at dorb.com Sun Jul 16 22:42:17 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 16 Jul 2000 22:42:17 -0400 Subject: problems trying wxPython in Win 95 References: Message-ID: <000701bfef98$9f658040$6401a8c0@home> My experience with this isn't recent. But last I checked wxPython didn't work with 1.6, don't know about 2.0. The demo will work with 1.5.2. I'd suggest uninstalling wxPython, rebooting and reinstalling it. I had a problem like this when upgrading from the last version of wxPython. Also check the wxPython mailing list where others of much greater wxPython experience hang out. And similar questions have been asked. --Darrell ----- Original Message ----- From: "Rob" > I want to run the demo program included in wxPython 2.1. Upon starting it I > immediately get the message appended to this post. I have two versions of > Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and > get the same result. I tried running it from the console, from PythonWin, > and from IDLE, all with negative results. Does anyone have an idea of what > is going on? > > Thanks, Rob. > From robin at illusionsexeculink.com.bbs Fri Jul 14 15:30:09 2000 From: robin at illusionsexeculink.com.bbs (robin at illusionsexeculink.com.bbs) Date: 14 Jul 2000 19:30:09 GMT Subject: namespace sharing (longish) Message-ID: <3bP6MX$m9o@openbazaar.net> I'm having a great deal of difficulty wrapping my head around the namespace issue. All I want to do is execute user-supplied (eg: arbitrary) functions and have them share a namespace. So the first such function could define some variables and later functions could read their values. Simple. Or not? I constructed the following test script: # test.py BEGIN ########### import pprint if __name__ == "__main__": # seed the namespace namespace = {'var_main': 'hello'} # here lies my user module x = 'from test_lib import *' exec x in namespace del x # BEGIN KEY CODE # code to execute code1 = 'ret_one = one()' code2 = 'ret_two = two()' # compile it to be nice compiled1 = compile(code1, '', 'exec') compiled2 = compile(code2, '', 'exec') # go -- execute! exec compiled1 in namespace exec compiled2 in namespace # END KEY CODE # remove cruft from name space del code1, code2, compiled1, compiled2 # what do we have? print print '0000000000000000000000000' pp = pprint.PrettyPrinter() print 'local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) # test.py END ############# Then, the user module could look like: # test_lib.py BEGIN ########### def one(): import pprint # define a variable local to this routine var_one = 'in one' # check out our environment -- any sign of namespace? no?? print print '1111111111111111111111111' pp = pprint.PrettyPrinter() print ' local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) return 'one' def two(): import pprint # same as above -- for now # later this will catch variables defined in one() var_two = 'in two' print print '2222222222222222222222222' pp = pprint.PrettyPrinter() print ' local => ' pp.pprint( locals() ) print 'global => ' pp.pprint( globals().keys() ) return 'two' # test_lib.py END ############# Then I tried a variation of test.py using the eval function in place of the exec statement: # BEGIN KEY CODE code1 = 'one()' code2 = 'two()' compiled1 = compile(code1, '', 'eval') compiled2 = compile(code2, '', 'eval') ret_one = eval(compiled1, namespace) ret_two = eval(compiled2, namespace) # END KEY CODE The results? The namespace appears to have no effect on the user routines. They cannot see var_main. Both methods produce the same (null) results. How do I do this? ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "We told it about general relativity and gravity, the kind of people that overcome hardships." From cut_me_out at hotmail.com Sun Jul 16 10:58:03 2000 From: cut_me_out at hotmail.com (Alex) Date: 16 Jul 2000 10:58:03 -0400 Subject: [Patch] {l,r}just with optional pad character parameter References: <8kshd3$l1h$2@bw107zhb.bluewin.ch> Message-ID: Hi, Beat. The python developers seem pretty indiscriminate about who they'll consider patches from. They have looked at a couple from me, for instance. :) You might want to read this page: http://www.python.org/patches/ it tells you where to send patches. Alex. From grey at despair.rpglink.com Sat Jul 29 22:43:42 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sun, 30 Jul 2000 02:43:42 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8lvr4n0iue@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 01:55:43 +0200, Alex Martelli wrote: >Which is what most computer work is doing, though the DB's may >not be relational ones. Files, mailboxes, documents, saved >games, newsgroups, sites -- call them as you wish, they do >persist (hopefully:-) and your data are right there. I am aware of that. So a problem in IO routine that don't interact with those, with display routines, mouse input for positioning alone, etc should all crap out just to protect the data? That seems utterly foolish. Sounds like the reason that Microsoft software crashes so much. Oh no, the mouse moved the wrong way, CRASH!!!! >that a program crash makes you lose them, you'll also lose them if >electricity goes away, or the *OS* crashes (far from unknown, in >Microsoft widespread OS's especially), etc. All of which are a lot less likely than a snafu in some data stream. >Losing a serious database, such as a full mail archive, is utter tragedy -- >the kind of thing that can break a small company (if they haven't been >religiously careful about backing up *everything* frequently -- and far too >many aren't). BTW, you are aware that it is possible that such crash outs on minor things are just as apt to currupt the persistant database as anything else? >wilfully wrong-headed programmer can always deliberately choose >to catch and explicitly ignore them, but that requires a higher >order of perversity than the common mistake of failing to check >for each and every possible error!-) Right, and the highest of them all is having 2/3rds the lines in code consist of "try:" and another 2/5s be "except:". >Control-C (depending on the operating system) will cause a specific >exception, and the programmer decides how it gets handled. Then that tosses out your idea of putting it all in a large try:/Except: block, doesn't it? We cannot see all errors that will occur. >No! The semantics of 'restartable exceptions', which you refer to, Ungh! Great, so even with a global try/except block to catch errors we end up with a highly unstable system in an unworkable state! -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From alex at magenta.com Fri Jul 28 11:49:02 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 17:49:02 +0200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> Message-ID: <8lsa9901fm9@news2.newsguy.com> "Grant Edwards" wrote in message news:KPgg5.2640$6E.682060 at ptah.visi.com... > In article <8lrt2h013fp at news2.newsguy.com>, Alex Martelli wrote: > > > >> whereas 1 + "foo" is meaningless to almost everyone except Perl coders. > > > >No way -- it's perfectly valid in C, too, except that there it means the > >constant-string "oo". Really, truly, X my heart, I kid you not, check it > >out if you don't believe me (I wouldn't blame you for disbelieving this!). > > I would assert that although 1 + "foo" is meaningful to the C > _compiler_, it is still meaningless to almost "everyone" (as in > people) except Perl coders, and probably meaningless to most of > them as well. I think you underestimate the amount of "Obfuscated C" participants who have not been Perl coders. 1+"foo" and 1["foo"] are very meaningful kinds of constructs to obfuscators!-) What I don't understand is, rather...: $foo = ++$bar; versus $foo = 1 + $bar; How much sense can it make to have those two constructs leave totally different values in $foo? Yet, if $bar starts out as "foo", the former makes $foo worth "fop", the latter makes it worth 1. Now, THAT is the way to let a creative obfuscator show his mettle. Alex From gee308 at mediaone.net.bbs Tue Jul 18 03:30:16 2000 From: gee308 at mediaone.net.bbs (gee308 at mediaone.net.bbs) Date: 18 Jul 2000 07:30:16 GMT Subject: newb question Message-ID: <3bRfYe$jTl@openbazaar.net> Do you need to use classes? I'm a newb and I'm just writing a "read-down"script with one or 2 functions. What do you mean by raw_input and read() and write()? Thanks for th help. Jason Toy lordkaos at my-deja.com wrote: > In article <3973EE1B.15B0B32E at mediaone.net>, > Toy wrote: > > what is a simple way I can save variables that people enter in from > > 'raw_input' ? That way, someone enters the variables they want, then > > when the script is booted up everytime the machine starts, it will > grab > > the variables from somewhere. Thanks. > > Jason Toy > > toyboy at toy.eyep.net > > > > > The tutorial at Python's > website tells a simple and easy way to do exactly what you're > saying. If you can get the variables into a class (read section 9, in > particular 9.3) then it is easy to read and write a big set of vars all > together in one operation by using the 'pickle' command (read about > this and easy file creation/opening in section 7.2). I just read over > this and it should answer your question. Come to think of it, raw_input > stores your input as a string, so you can just read() and write() in > one swipe to do the same thing (This would be much easier). > > --Jared > > Sent via Deja.com http://www.deja.com/ > Before you buy. From scarblac-spamtrap at pino.selwerd.nl Wed Jul 19 05:52:24 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 19 Jul 2000 09:52:24 GMT Subject: Using filter() References: <8l1o9h$pto$1@news.rchland.ibm.com> <8l256r$d7n$1@netserv.univ-lille1.fr> <8l2g53$14ha$1@news.rchland.ibm.com> Message-ID: Larry Whitley wrote in comp.lang.python: > I don't understand why lambda needs the second parameter. When I experiment > with > > filter( lambda x: string.find( x, name) == 0, fileList) > > in place of > > filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) > > it works as well. I suspect that your codeing come from something more > general. Can you explain the reason the sf=string.find construction is > useful in this context? You tried this out in the global namespace, outside a function. Then it's not needed. Since the lambda is another function, it only sees its own namespace and the module's global namespace, and not the namespace of the function you define and use it in. So you have to pass variables in as default parameters to make them visible inside the lambda... Actually, that's not needed for string.find if string is imported globally. But you *do* need to use "name=name" as well if name is a local variable in a function. The sf=string.find makes it slightly faster. -- Remco Gerlich, scarblac at pino.selwerd.nl This is no way to be Man ought to be free -- Ted Bundy That man should be me From MarkH at ActiveState.com Wed Jul 26 21:06:25 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 27 Jul 2000 01:06:25 GMT Subject: How to create COM Servers with IID_IDTExtensibility2 interface References: Message-ID: > According to a very small demo I have downloaded from Microsofts website, > for a COM object to be used by excel as a COM Addin > it must implement the interface IID_IDTExtensibility2. I know the GUID for > this interface and its "defined methods". Sorry - you are SOL. To support arbitary interfaces, you need C++ support, in the form of an extension module. There is a new "Univgw" that may help you out, but I dont know much about this (Bill Tutt has been working on that, but not much has been done recently - I dont even know its completeness.) Mark. From paul at prescod.net Wed Jul 19 13:17:52 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 12:17:52 -0500 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> <3975E180.1AFD30D@roguewave.com> Message-ID: <3975E2C0.BAFBA961@prescod.net> Bjorn Pettersen wrote: > > > I think the PEPs are a great idea, but it would be even better if they > were more accessible... How about putting them up on the beopen or > python.org site? (That way the faq can refer to them for recurring > discussions with all the arguments archived in the PEP...) That will happen one day. It's just that nobody has got around to it yet. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From richard_chamberlain at my-deja.com Thu Jul 27 05:15:27 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Thu, 27 Jul 2000 09:15:27 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: <8loujd$5j7$1@nnrp1.deja.com> A question out of curiosity. If someone had made a contribution to the standard library and had written a certain licensing agreement as a comment in the file would that module still be covered by the BeOPEN or CNRI agreement? - or would it's own license still stand? Richard In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, Guido van Rossum wrote: > I've placed the slides of my talk at the O'Reilly Open Source > Convention on-line at our BeOpen PythonLabs website: > > http://www.pythonlabs.com/talks.html > > We're also very close to announcing news regarding a new Python > license, Python 1.6 and 2.0 release schedules, and a transition of the > python.org website to hosting by VA Linux. > > The announcement is waiting for final negotiations about GPL > compatibility of the new license; BeOpen's CTO, Bob Weiner, is > confident that the issue will be resolved one way or another by > Friday. > > A preview of what we will announce: > > - A new license for Python 1.6 and later: the "CNRI Open Source > License", approved by the Open Source Initiative; > > - Release plans for Python 1.6: the last CNRI release, to be issued > with help from BeOpen; > > - Release plans for Python 2.0: the first release to be issued by > BeOpen; > > - A transition for the python.org website: it will be hosted by VA > Linux (home of SourceForge), under supervision of the Python > Consortium and myself, maintained by the Python community. > > Please hold your breath a little longer! > > A re-release of JPython using the CNRI Open Source License is possible > a little later, pending further negotiations with CNRI. > > --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) > > Sent via Deja.com http://www.deja.com/ Before you buy. From rwallace at esatclear.ie Mon Jul 31 21:48:35 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Tue, 01 Aug 2000 02:48:35 +0100 Subject: Newbie pythoner, with bizzare problem References: <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F79257Amilenkomoonshinecouk@194.73.73.116> <8lcef2$fbn$0@216.39.151.169> Message-ID: <39862C73.53B1@esatclear.ie> Donn Cave wrote: > > Quoth claird at starbase.neosoft.com (Cameron Laird): > | You're also right that > | from os import * > | is, of course, universally deprecated. > > So where do so many new programmers learn to do this? > This is a serious question. Is there some tutorial > out there that leads them astray? On reading the documentation, I was repeatedly told several times not to do this; I don't see how it could reasonably be missed. I do it anyway, for convenience; that, for me, is Python's raison d'etre. I suspect that's the usual reason for doing it. -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From paul at prescod.net.bbs Mon Jul 17 16:00:11 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 20:00:11 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRNaC$l5j@openbazaar.net> Huaiyu Zhu wrote: > > ... > > I thought I replied your email through email ... Ah, here it is: Right, but you weren't the person who brought up the millions of Matlab users this time. > ... > On the other hand, open source may beat them > easily, as long as > > 1. we are using a better language which has more potential > 2. users have incentive to contribute because it's already useful > 3. there's no big hurdle beyond what's already in Numerical Recipe You presume a great deal of human labour which you cannot provide by yourself. We cannot extend Python based on your faith that these people will come along and do the work to make it a serious Matlab competitor. Anyhow, you can prove me wrong by making MatrixPython as popular as Python. Then we will come to YOU and ask if we can merge grammars to unify our communities. I could just as easily claim that if we add regular expressions to the Python syntax, all of the Perl users would come over here. I don't have any evidence, though. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From hzhu at localhost.localdomain Tue Jul 18 17:12:57 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 21:12:57 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> Message-ID: I really like this kind of ideas. Anyone able to implement it? What it takes to change a patch of grammar to an importable module? Maybe the way to do it is to change the python implementation of operator into an object oriented approach? Similar to PyObject we'll have a PyOperator which defines the symbol, name, scoping and precedence rules. This way handling operators within python would be similar to hadling ordinary objects, by import NewOperator. To discourage abuses there may be restrictions on what is allowed as symbols and what precedence rules are allowed and so forth, and perhaps prohibit dynamic changes within an importing module. If everything about operators is concentrated within one class I think this will also make python itself simpler. In any case I think this fits in the idea of doing things in organized way and removing arbitrary restrictions. (This is just my guesstimate so that others may come with hard facts.) Huaiyu On 18 Jul 2000 09:51:52 -0500, John Lull wrote: >How about one small change to Python, breaking no existing code, and >applicable (I'm sure) to domains far-afield from linear algebra: > >Currently, > object operator other >is really just convenient shorthand for: > object.__operatorname__(other) >or > other.__roperatorname__(object) >where operator is any binary arithmetic operator. > >What if we simply make > object @operator other >convenient shorthand for: > object.__alt__operatorname__(other) >or > other.__alt__roperatorname__(object) >for all those same operators? > >This would be a syntax error when applied to anything other than an >object, and would raise an appropriate exception if neither object nor >other provided an appropriat __alt method. > >This would provide a way of adding a reasonable variety of >domain-specific operators to *any* class with very little impact on >the language, zero runtime penalty, and obvious & correct behaviour >when creating derived classes. It would not break any existing code >and should be very simple to implement. > >I haven't thought through whether the same behavior should apply to >anything other than binary arithmetic operators. Doing so would seem >very Pythonic. > >Regards, >John From beat.bolli at dware.ch.bbs Tue Jul 18 02:40:04 2000 From: beat.bolli at dware.ch.bbs (beat.bolli at dware.ch.bbs) Date: 18 Jul 2000 06:40:04 GMT Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <3bReK5$laF@openbazaar.net> > > Two reasons why not: > > - it would have been harder to implement > > - undetermined semantics: > > "GvR".ljust(6,"12") =?= "GvR121" > > This is exactly what I would expect -- a 6 char result string > I've been working on this last night; I implemented it for ljust, rjust and center. Right now I'm trying to integrate Unicode support, too. Let me know if you want to see an intermediate version just for strings. Beat Bolli -- dware design & software GmbH Mattenstrasse 11, CH-2555 Br?gg b. Biel Telefon: +41 (32) 374 27 00, Telefax: +41 (32) 374 27 01 E-Mail: beat.bolli at dware.ch From OneDay at ATime.net Mon Jul 24 06:02:27 2000 From: OneDay at ATime.net (OneDay at ATime.net) Date: Mon, 24 Jul 2000 06:02:27 EDT Subject: Newbie ?? Running hello1.py and compiling? References: <8lejm0$d3o$1@earth.superlink.net> Message-ID: <8lh47j$1645$1@earth.superlink.net> Thanks for your answer, getting started is the hardest part. Al In article , "Greg Fortune" wrote: > > wrote in message news:8lejm0$d3o$1 at earth.superlink.net... >> Hello all, >> >> At Python's site I started with Example 2.1, Our First Program. I >> opened IDLE, Opened a new window and copied/wrote the commands >> and saved it as hello1.py. >> >> To run the program it says to "run the script as usual" >> $ python hello1.py >> >> Where do I type this, I don't know what "as usual" means. > >It sounds like you are running Windows. Assuming that is true, pop up a >console (MS-Dos window) and change to the directory containing the file you >created. Then type "python hello1.py". All that does is tell python to run >your script. > > >> >> After I wrote hello1.py, I noticed a compiled version in my >explorer. >> Which I can run from there. How did that happen? > >Sounds like you got hello1.py to run. Whenever a script is run, it checks >for a compiled version of the file. If none exist, it compiles the script >into byte code. If the .py file is newer than the .pyc (compiled file), the >..py file is compiled again. > >> >> When I copied/wrote hello2.py, following the above steps, I did >not >> get a compiled version. What did I do wrong? > >Hmmmm, must not have ran this one. > >> >> >> Thank you for your time and patience, >> Al > >Not a problem ;) >good luck, > >Greg Fortune > > > From alex at magenta.com Tue Jul 25 06:56:47 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 25 Jul 2000 12:56:47 +0200 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: <8ljrvu09t6@news1.newsguy.com> "Jonathan" wrote in message news:8lj7kr$ttc$1 at nnrp1.deja.com... > Hi, just finished going through the 'Learning Python' book, and the > feeling that i get is that Python is really wierd(compared to other > conventional languages like C++, Java, etc). For e.g.(correct me if i'm Funny. With my background being 20+ years of (Fortran, Pascal, APL, C, C++, Java, Perl, &c), I picked up Python a few months ago and found myself *immediately* productive with it. No weirdness that I could perceive... > 1. There are no keywords to declare static or instance variables; it > all depends where they are placed(whether it's right after the > statement, or inside a ). Isn't it harder for other programmers to > know at one glance what type of attributes the class define? I see a "self.something=23", I know "self" is an instance variable; no muss, no fuss. MUCH clearer than the implicit-this convention of C++ and Java. Explicit self -> less weirdness, not more. > 2. No *formal* declaration of static class methods, e.g. no 'static' > keyword (though i'm not sure how useful static methods are in OOP > design). I read somewhere in this newsgroup that the workaround way is > to define the method outside of the class - doesn't it break > the 'encapsulation' a class suppose to have? Encapsulation in Python is a matter of convention (as it actually ends up being in all languages, but most strive hard to make it appear they enforce it:-). Static methods are not particularly useful when you can have free-standing functions in their stead, and grouping by-module is more productive than by-class (the class is not the natural unit of encapsulation, an issue that is also acknowledged by the package concept of Java and the friend keyword in C++). > 3. No keywords to differentiate between passing arguments by reference > or value! An integer is passed by value(reference to a new copy), while > a mutable object is by reference. To pass a list by 'value', i know you > just need to insert one more line(list = [:]), but it seems > so 'inconsistent' compared to Java or even PHP. *Blink* what IS the difference supposed to be, in the above paragraph, between the situation in Java and in Python, again? You pass an int, it's by-value (notionally, reference-to-immutable-value); you pass an object reference, it's by value *of the reference*, i.e., by reference *on the object*. What "keywords to differentiate between passing arguments by reference or value" is Java supposed to have acquired since I studied and used it...? The ByVal/ByRef keywords are in Visual Basic, and I don't really miss them at all in Python just as I didn't use to miss them in Java. > (Not to mention the number of 'gotchas' listed in the book that are > bound to trap beginners - *shudder*) Such as...? I breezed through "Learning Python" several months ago, and I don't recall such "gotchas". Any gotcha-risk I can imagine Python having, would have to be towards programmers experienced in a very modest variety of other languages; beginners, using Python as their first language, and old-hands like me, having already survived the wide variety of semantics and syntax of a dozen other languages, should be reasonably immune. The three-scopes-and-no-more rule, where each name can only be local, global, or built-in (no other possibilities, no nesting of scopes), for example, is extremely simple; somebody used to nested-scopes exclusively will find it unfamiliar at first, I guess -- is this sort of thing the one you consider a "gotcha"? > The reason i'm picking up python is that i got sick of PERL:), and That was my key motivation at first, too. I've now moved to Python basically everything that I used to do in Perl -- and I've been quite surprised that Python becomes my language of choice for many other things that I'd never have considered Perl for. > don't really like the inflexible typing of Java. Furthermore, some ppl > claim that Python is easier to learn, enables you to write much cleaner With my limited experience, I'd underwrite this. > codes... However, after reading the python book, my head is still > spinning, trying to catch all the 'intricacies' of this language. No But there aren't any. That's why it's so powerful!-) > doubt it will be a powerful and useful 'tool' to me once i get used to > it; but i don't think it's suitable to be a first programming language > for non-programmers(i read somewhere about this project going on). CP4E, I guess. I believe it's probably the best for most people. > Pascal(for procedural) and Java(for OOP) is still the better choice to > start off, IMHO. There are two main schools about the kind of features a beginners' language should provide. The bondage-and-discipline school holds that such a language should strictly confine the beginner to "what is good for him/her", *forcing* him/her to do things "the one true way". The flowers'-children school holds that a tool's role is to get OUT of the way, being as simple and obvious as feasible, to let the learner concentrate efforts on the REAL difficulties of learning to think like a programmer. Of course, there are sub-schools of each, which depend on secondary considerations such as syntax. But the main split, as I see it, is between these two key world-views. If you subscribe to B&D, of course Python would not be appropriate, since it *avoids* binding the user's hands in such wise. It does try to offer "one clearly correct way to do things", but never goes out of its way to _constrain_ users to that one way. Pascal, Sather, Java, Oberon, would be outstanding candidates for a first language on the B&D lines. Python, together with Smalltalk, Scheme, or Rexx, is an outstanding candidate for the _second_ way to look at the world. Of these, Python would be my favourite were I to pick such a language today. (Other languages such as Perl, C++, Ada, Common Lisp, and so on, I view for different reasons as too complex and obtrusive to be good first-programming-languages, and similarly for lower-level languages such as C, machine language of any ilk, or Forth). Alex From grey at despair.rpglink.com Sun Jul 30 20:50:53 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 00:50:53 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8lvr4n0iue@news2.newsguy.com> <8m26up$ila$5@newshost.accu.uu.nl> Message-ID: On 30 Jul 2000 21:33:13 GMT, Martijn Faassen wrote: >condition. It cannot magically repair bugs. So what is you want? A little tolerance to those bugs, not a panic to break out of a 12 deep nested loop to a point of no recovery while in the /customers/ hands. >And what is your experience regarding databases and exceptions in Python? As Alex pointed out there are more databases than just that. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From fig at oreilly.com.bbs Mon Jul 17 15:30:06 2000 From: fig at oreilly.com.bbs (fig at oreilly.com.bbs) Date: 17 Jul 2000 19:30:06 GMT Subject: Python equivalent of CPAN in Perl Message-ID: <3bRMkV$mbl@openbazaar.net> Aahz Maruch wrote: > To the extent that this is true, isn't it also true of Perl/CPAN? Yes, and it was not really solved until ActiveState came along and put up a repository of precompiled packages for win32 systems. CPAN still caters mostly to to a Linux/Unix audience, where Windows users use the ppm program provide with ActivePerl to retrieve their modules. Stephen From claird at starbase.neosoft.com Wed Jul 5 09:09:47 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Jul 2000 08:09:47 -0500 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: In article <395B2B88.CC3041C1 at memo.volvo.se>, PM wrote: . . . >Can Python kick large bottoms with decent database access - not just SQL >not ODBC, could it go to DB2/400? . . . How are you getting to DB2 over OS/400 if not through SQL? Are you asking for RPG? In general, yes; Python's database access is "decent", and the language has turned up on AS/400 in the past (although I can't attest to its "currency"). -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From crs at quail.swcp.com Thu Jul 13 20:14:31 2000 From: crs at quail.swcp.com (Charlie Sorsby) Date: 13 Jul 2000 18:14:31 -0600 Subject: Simple File I/O Question References: <396DF13A.97CC3F5E@bioeng.ucsd.edu> <4ymb5.894$6E.112638@ptah.visi.com> Message-ID: <8klm17$1se@quail.swcp.com> In article <4ymb5.894$6E.112638 at ptah.visi.com>, Grant Edwards wrote: = In article <396DF13A.97CC3F5E at bioeng.ucsd.edu>, Curtis Jensen wrote: = >I know this should be simple, but.... I have a variable that holds an = >int. I want to write it to a file. The following code: = > = >var = 5 = >f = open('foo','w') = >f.write(var) = > = >gives this error: = >TypeError: read-only buffer, int = = the write method only accepts strings as parameters, so you've = got to convert whatever you want to write to a string before = passing it to write() = = try this: = = f.write(str(var)) = or = f.write("The value of 'var' is %d\n" % var) If I may add my own question to that of the original poster: What if one needs to send an int to a device that will use it and needs it to be an int not a string? E.g. suppose I need to send a hex int via the serial port (/dev/cuaa0) to some device? Is this not possible in python? -- NB: While I welcome *reasonable* and *relevant* e-mail responses, any e-mail with a *long* "To: list" or any mailing list may be treated as spam and reported to the sender's ISP. -- Best regards, Charlie "Older than dirt" Sorsby Edgewood, NM "I'm the NRA!" crs at swcp.com www.swcp.com/~crs USA Life Member since 1965 From slinkp23 at yahoo.com Sat Jul 29 13:21:27 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sat, 29 Jul 2000 13:21:27 -0400 Subject: Find where you left off... References: <397F7BF5.F4A0138D@yahoo.com> Message-ID: <39831297.36F7C5C2@yahoo.com> Toby, Alex, and Quotemaster: Thanks for the comments. It seemed like a good idea at the time. :) I think I will use emacs bookmarks instead, sounds like a better general solution. Thanks Toby! -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.slinkp.com A member of ARMS: http://www.reacharms.com From tony at lsl.co.uk Mon Jul 10 07:29:37 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Mon, 10 Jul 2000 12:29:37 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8k4t1u$7fk$1@newshost.accu.uu.nl> Message-ID: <002001bfea62$21eabdf0$f0c809c0@lslp7o.lsl.co.uk> Martijn Faassen explained that Zope does indeed do most of the things I'd mentioned, and then: > > persistence over LARGE networks, etc. > > What would this mean? One of the interests of the people in Glasgow is how one copes with data that may be distributed over many computers. This includes issues such as how do you fallback to another copy of the data, how do you decide whether/when to cache locally, and if so when to update, etc. Since they also store the program code in the store, this also means sharing software over the network as well. In todays emphasis on shared services over the net, a lot of this begins to sound remarkably prescient. It's often regarded as one of those "we'll worry about that later" problems, since people expect to be working on a local store, but thinking about it earlier can have interesting insights into what one should be *doing* locally (and as soon as one has two users on two systems sharing stuff, the slippery slope has started). But it did seem to be a *difficult* problem, conceptually as well as practically. But I *know* I don't understand the field, so I'll shut up straight away about it... > Do you still think what the ZODB does is much > different from what you're describing? Erm, no, it sounds like I need to find some excuse to find out more about Zope, instead! (damn, another worthwhile thing to learn about). Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ Feet first with 5 wheels... My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From anamax at earthlink.net Tue Jul 25 09:49:29 2000 From: anamax at earthlink.net (Andy Freeman) Date: Tue, 25 Jul 2000 13:49:29 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <8lhij5$278$1@slb2.atl.mindspring.net> <8lhmgd$p92$1@nnrp1.deja.com> <8lhtht$v1e$1@nnrp1.deja.com> Message-ID: <8lk5t6$jb2$1@nnrp1.deja.com> In article <8lhtht$v1e$1 at nnrp1.deja.com>, ajsiegel at my-deja.com wrote: > But I wasn't necessarily suggesting that there would be a contribution > back to the community. There would be a proprietary solution - and > perhaps a competitive advantage achieved. The contribution back to > the community would be a separate business decision. Here's the conversation. Me: "I'd like to use Python instead of Java for Project X?" VP: "Why? Everyone here uses Java and I've never heard of Python." Me: "I can finish Project X 30% faster in Python than Java." VP: "But, is it compatible, and who will maintain the code?" VP: "Okay, what do you need to deploy?" Me: "I need to hire a contractor to enhance some standard modules." VP: "Project X will be rewritten in Java - we can't depend on that kind of uncertainty." Note that the VP's job is to actually get into the rollout discussion before I get started with the Python version. (Note that the VP is right to kill the project in this case, and changing the number to 70% faster doesn't help.) The challenger has to be better on a number of dimensions and can only be worse on trivial details - otherwise the incumbent wins. ("No one else here knows the language" is a very powerful argument in a world where staffing is so difficult.) -andy Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Sun Jul 23 19:28:33 2000 From: db3l at fitlinxx.com (David Bolen) Date: 23 Jul 2000 19:28:33 -0400 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: nobody writes: > perhaps. unfortunately, i haven't had time to work on this since i made > that posting, so i have got no further; i expect there's some fairly easy > way to write (copy) all the lines from one file to another one, possibly > (though not necessarily) stdout. perl is nice in that this task is a one- > liner in that language; i don't *need* it that concise, but it would be > nice. i like one-liners. As long as you're willing to think in terms of "lines" (which does technically involve some "cleverness" or intelligence on the I/O part), then this sort of thing is probably the most straight forward, assuming stdin->stdout: import sys while 1: line = sys.stdin.readline() if not line: break sys.stdout.write(line) The overhead compared to the Perl example is just about the same as just processing input (e.g., the "while 1" idiom - the extra operation to dump to stdout is only one line, just as with Perl), or if you switch to fileinput: import fileinput for line in fileinput.input(): sys.stdout.write(line) which aside from the import, is pretty much as brief as the Perl approach :-) To be honest though, while I'm as much a fan of brevity and one-liners as the next guy, they do carry some risk sometimes in terms of encapsulating implicit behavior that can sometimes make the code less readable. Now, this does assume a line formatted setup, which I think is also assumed by the Perl example. Both the "while " in Perl, and the "readline" in Python read up until the end of line, and include the newline in the returned string. So there is some non-raw processing going on. Just as with "print" under Perl, Python's "write()" file method just dumps the contents of the string to the file, any newline already in the string included. But if you really wanted something closer to a raw copy, with no assumptions about a format of lines, then you could switch to using a read() method rather than readline(), at least in the first approach above. > that's trying to be clever. then, if i'm reading raw lines from a file and > want to print them verbatim, i have to strip a newline somewhere somehow? > how do i copy a file to another one, is there a file.copy method in some > module somewhere? BTW, I do agree that "print" has a number of clever items to it as a statement, and that's fine - it's how it is defined, and it's very convenient interactively and even in scripts. It just doesn't match the definition of Perl's "print", despite the same name. The file write() method is the closest match to Perl's "print FILE" statement - just use "sys.stdout.write()" where you'd leave off FILE in Perl. If you don't like the length of the name, just assign it to any name you'd like in your script and use that instead :-) Where a typical incorporation of variables into Perl's print statement is just embedding $variable in the string, with Python you would use the string formatting operations to build up the appropriate string to send to write(), say something like ("%s is %d" % (var1,var2)). If you use the dictionary approach ("%(name)") then it doesn't even read all that differently from Perl :-) Just to note too - you mention reading "raw lines" - that's sort of oxymoronic, since by definition "lines" have format information (end of line markers that differ by platform) that have to be processed, and thus you aren't really reading anything "raw" :-) Oh BTW, if you really just wanted a file copy, then yes, you could also use the higher level copy() method in the shutil module. -- -- 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 Gareth.McCaughan at pobox.com Fri Jul 21 17:43:07 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 21 Jul 2000 22:43:07 +0100 Subject: iterating over lines in a file References: Message-ID: Moshe Zadka wrote: > Preventing world war III, when Python achieves world domination. > If C is allowed to achieve world domination, WWIII will be cause by > > if(everything_is_ok = 0) { > launch_missile(); > } No, that will *prevent* WW3 happening when it was supposed to. Where do I sign up for the campaign to help C dominate the world? :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From akuchlin at mems-exchange.org Mon Jul 3 12:33:56 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 03 Jul 2000 12:33:56 -0400 Subject: Python CGI security References: Message-ID: <3dr99b5g23.fsf@kronos.cnri.reston.va.us> "E. Jordan Bojar" writes: > I'm interested in running a series of Python scripts via the Apache Python > module, mostly for dynamic content but possibly for password protection as > well. Are there security issues particular to (or common with) Python CGIs, > in the way that buffer overflow is so common to poorly-written Perl? Actually I'd expect that very few Perl security problems stem from buffer overflows, but instead come from improperly screening user input. (Taking the value of a field and blithely opening a file with the same name, for example, which is vulnerable to values such as ../../../etc/passwd.) Similarly, while there may be buffer overflows inside the Python interpreter that should be fixed, I'd be far more worried about the CGI/Apache code itself. --amk From mfletch at tpresence.com Fri Jul 21 22:08:03 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 21 Jul 2000 22:08:03 -0400 Subject: newb Q Message-ID: Check Deja news for a _long_ thread on how to get IP addresses. http://x72.deja.com/[ST_rn=ps]/viewthread.xp?AN=647408915 HTH, Mike -----Original Message----- From: Toy [mailto:gee308 at mediaone.net] Sent: Friday, July 21, 2000 9:28 PM To: python-list at python.org Subject: newb Q How can I make python issue the command, "ifconfig -a eth0", and then parse the data to grab the IP? I would think that you could tell Python to look for the word, 'inet addr:"(is it different on different Unixes?) and then tell it to get a number right after 'inet addr' that looks like xx.x.xxx.xxx !! Simple Q, but I'm new, thanks. -- http://www.python.org/mailman/listinfo/python-list From scarblac-spamtrap at pino.selwerd.nl Thu Jul 20 09:34:45 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 20 Jul 2000 13:34:45 GMT Subject: Intercept methods/raise exception References: <3978f242.25036009@news.online.no> <3979f896.26656309@news.online.no> Message-ID: Thomas Weholt wrote in comp.lang.python: > I tried using __getattr__, like > > def __getattr__(self, attrname): > print 'Trace:', attrname > return getattr(self, attrname) > > But it crashed terribly. The object in question is accessed lots of > times. When I ran it, it printed : > Trace: __coerce__ > Some hundred, thousands times, then collapsed with a bang. This is simple infinite recursion. The getattr() call calls __getattr__, etc. Try returning self.__dict__[attrname]. -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "First you take off the lens cap": Tri-Tac's FTL: 2448 reveals that a ship's sensors have a 1 per cent of failing to detect a giant gas planet 300 feet away. The chance rises to 11 per cent if you don't know what you are looking for. From slinkp23 at yahoo.com Wed Jul 26 12:30:42 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 26 Jul 2000 12:30:42 -0400 Subject: Problems installing PIL on linux Message-ID: <397F1232.27791F0C@yahoo.com> Hi, I'm trying to install PIL on a RedHat 6.1 system. I've downloaded the Imaging-1.1.tar.gz from the PIL website. Following the instructions in the README, I get as far as step 8, the actual build. It looks like step 7 (make -f Makefile.pre.in boot) is finishing OK, but the created makefile does not work. I get this: # make make: *** No rule to make target `/usr/lib/python at VERSION@/config/Makefile', needed by `sedscript'. Stop. I found a couple of messages on dejanews referencing similar problems, but I didn't see any solutions posted. I browsed the imaging sig archives and couldn't find anything relevant. Details: let's go through the process... Step 1: jpeg and png support ... I have RedHat 6.1 so I assume this is OK. Let's see what I've got: # rpm -q libjpeg libpng zlib libjpeg-6b-9 libpng-1.0.3-4 zlib-1.1.3-5 # rpm -q libpng-devel libjpeg-devel zlib-devel libpng-devel-1.0.3-4 libjpeg-devel-6b-9 zlib-devel-1.1.3-5 Looks good to me. Step 2: make sure build packages are there... # rpm -q python python-devel python-1.5.2-13 python-devel-1.5.2-13 Looks good. Step 3: Unpack the PIL distribution ... no problem Step 4: . Now build the Imaging core library (libImaging.a): $ cd Imaging-1.1/libImaging $ ./configure $ make This all goes fine. Step 5. To check that this library works as it should, type: $ make check OK, I get a nice pretty little picture. Step 6. Edit Setup if necessary to find jpeg and zlib libraries... I don't think I need to do this. Step 7. Make a makefile. This seems to go OK... long output listing follows... and yes, I end up with a Makefile. [root at slink Imaging-1.1]# make -f Makefile.pre.in boot rm -f *.o *~ rm -f *.a tags TAGS config.c Makefile.pre python sedscript rm -f *.so *.sl so_locations VERSION=`python -c "import sys; print sys.version[:3]"`; \ installdir=`python -c "import sys; print sys.prefix"`; \ exec_installdir=`python -c "import sys; print sys.exec_prefix"`; \ make -f ./Makefile.pre.in VPATH=. srcdir=. \ VERSION=$VERSION \ installdir=$installdir \ exec_installdir=$exec_installdir \ Makefile make[1]: Entering directory `/usr/local/lib/python/Imaging-1.1' sed -n \ -e '1s/.*/1i\\/p' \ -e '2s%.*%# Generated automatically from Makefile.pre.in by sedscript.%p' \ -e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \ -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \ -e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \ -e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \ -e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \ -e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \ -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \ -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \ -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \ -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \ -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \ -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \ -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \ -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \ -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \ -e '/^LINKFORSHARED=/s/^LINKFORSHARED=[ ]*\(.*\)/s%@LINKFORSHARED[@]%\1% /p' \ -e '/^prefix=/s/^prefix=\(.*\)/s%^prefix=.*%prefix=\1%/p' \ -e '/^exec_prefix=/s/^exec_prefix=\(.*\)/s%^exec_prefix=.*%exec_prefix=\1%/p' \ /usr/lib/python1.5/config/Makefile >sedscript echo "/^#@SET_CCC@/d" >>sedscript echo "/^installdir=/s%=.*%= /usr%" >>sedscript echo "/^exec_installdir=/s%=.*%=/usr%" >>sedscript echo "/^srcdir=/s%=.*%= .%" >>sedscript echo "/^VPATH=/s%=.*%= .%" >>sedscript echo "/^LINKPATH=/s%=.*%= %" >>sedscript echo "/^BASELIB=/s%=.*%= %" >>sedscript echo "/^BASESETUP=/s%=.*%= %" >>sedscript sed -f sedscript ./Makefile.pre.in >Makefile.pre /usr/lib/python1.5/config/makesetup \ -m Makefile.pre -c /usr/lib/python1.5/config/config.c.in Setup -n /usr /lib/python1.5/config/Setup make -f Makefile do-it-again make[2]: Entering directory `/usr/local/lib/python/Imaging-1.1' /usr/lib/python1.5/config/makesetup \ -m Makefile.pre -c /usr/lib/python1.5/config/config.c.in Setup -n /usr /lib/python1.5/config/Setup make[2]: Leaving directory `/usr/local/lib/python/Imaging-1.1' make[1]: Leaving directory `/usr/local/lib/python/Imaging-1.1' [root at slink Imaging-1.1]# OK, but now we come to the problem. Step 8. To build a dynamically loaded module, just type "make": make: *** No rule to make target `/usr/lib/python at VERSION@/config/Makefile', needed by `sedscript'. Stop. OK, so something's really wrong with my Makefile, even though none of the previous steps complained. I don't think this section is supposed to look like this: # === Variables from configure (through sedscript) === VERSION= @VERSION@ CC= @CC@ LINKCC= @LINKCC@ SGI_ABI= @SGI_ABI@ OPT= @OPT@ LDFLAGS= @LDFLAGS@ DEFS= @DEFS@ LIBS= @LIBS@ LIBM= @LIBM@ LIBC= @LIBC@ RANLIB= @RANLIB@ MACHDEP= @MACHDEP@ SO= @SO@ LDSHARED= @LDSHARED@ CCSHARED= @CCSHARED@ LINKFORSHARED= @LINKFORSHARED@ Any ideas? -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From stadt at cs.utwente.nl Thu Jul 13 07:48:38 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Thu, 13 Jul 2000 13:48:38 +0200 Subject: Aspect-oriented Python? References: <8jg821$vll$1@gaia.cdg.acriter.nl> Message-ID: <396DAC96.828F371C@cs.utwente.nl> Cees de Groot wrote: > > I've been reading on aspect-oriented programming a bit, and it sounds really > interesting. A Java implementation, AspectJ (www.aspectj.org) looks promising, > but has the drawback that it only supports static weaving (wouldn't know > how to do dynamic weaving with Java, so it's not a big surprise). Composition Filters (See http://trese.cs.utwente.nl/sina/cfom/) is another way to do Aspect Oriented Programming. > With Python, experimenting with aspect-oriented stuff would probably be > way easier, because it is easy enough to replace class methods etcetera. I've > tried Google, but didn't find anything. Is someone busy with aspect-oriented > programming for Python? Over the years we've implemented Composition Filters in Smalltalk and C++ and are currently working on an implementation in Java, which is quite hard, because e.g. we want to know which object was the sender of a message, and we want to be able to reason about messages (so we have to be able to make objects out of messages, to e.g. pass them on, examine them, and then execute them). This is not easy to do in Java (we're using inlining), but that's the language we're targeting. From what I have seen from Python, I expect that it will be much easier to do in Python. The current Java version is described in a MSc thesis by Hans Wichman: http://trese.cs.utwente.nl/cd3/publications/paperinfo/wichman.thesis.pi.top.htm Richard. From ejr at lotus.CS.Berkeley.EDU Fri Jul 7 13:25:48 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 7 Jul 2000 17:25:48 GMT Subject: More math on the O'Reilly Network References: <3964CA9B.CBCD5B03@oreilly.com> <8k41s8$a8i$1@snic.vub.ac.be> Message-ID: <8k53qs$r8f$1@agate.berkeley.edu> And Thomas Hamelryck writes: - - Well, it's more an introduction to vector and matrix algebra than a - tutorial on Numpy. Most people who take the trouble installing Numpy - are quite familiar with this stuff. Matlab became extremely popular once educational materials started to appear en masse, ones that were introductions to vector and matrix algebras... Python need more of this, especially outside the for-people-already-using-python circles. Jason From gmcm at hypernet.com.bbs Mon Jul 17 23:10:02 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 18 Jul 2000 03:10:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRYjQ$kzv@openbazaar.net> Huaiyu Zhu wrote: >On 17 Jul 2000 23:19:16 GMT, Gordon McMillan wrote: >> PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >Good point. So let me say why I do not like this. (Doesn't mean it has >to die.) :-) > >In a program where there are a lot of computations, you'll get either >something like a ritual on every line, > >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) [snip] >or you get > >PyAlgebra.evaluate(r'(A .* B)\C > (A .* B)\C > (A .* B)\C', A=A, B=B, C=C) > >Everybody would rush for the latter. In the end what's inside the quote >would be a minilanguage with all the bells and wistles of python. This >would be just similar to patching the parser, with lesser results. It would be exactly what SQL and regular expression users deal with every day. I'm sure some ex-Perlers wish that regexes were "first class" objects, but there's little noise about it; and none whatsoever from SQL users. And you get the advantage that you can use the same syntax Matlab uses. -Gordon From collins at seal.aero.org Thu Jul 13 16:03:36 2000 From: collins at seal.aero.org (Jeff Collins) Date: Thu, 13 Jul 2000 13:03:36 -0700 Subject: Python Palm Port In-Reply-To: <396DBB86.98F20F75@earthlink.net> References: <396DBB86.98F20F75@earthlink.net> Message-ID: <14702.8210.772744.46150@malibu.aero.org> An initial port is available at http://www.isr.uci.edu/projects/sensos/python/ Jeff William OConnor writes: > I was interested in possibly doing a Python port to the Palm OS. > > Is anyone already doing it? > > If so maybe I can help. > > If not, a pointer to some porting information would be appreciated. > > nospam.wtoconnor at earthlink.net > -- > http://www.python.org/mailman/listinfo/python-list > From etiennel at geospace.co.za Mon Jul 17 04:17:06 2000 From: etiennel at geospace.co.za (Etienne Labuschagne) Date: Mon, 17 Jul 2000 10:17:06 +0200 Subject: Memory leak problems with python and COM References: <963474833.835936@proxy.lia.net> <8klbu9$38u$1@nnrp1.deja.com> Message-ID: <963821590.366250@proxy.lia.net> Hi there To my embarrasment I found that I am still using Python build 129 and that I (somehow) missed the release of build 131! Anyway, build 131 solved the problem! Thanks for your help. Regards Etienne "Mark Hammond" wrote in message news:8klbu9$38u$1 at nnrp1.deja.com... > In article <963474833.835936 at proxy.lia.net>, > "Etienne Labuschagne" wrote: > > Deleted a and b on the python side and then destroying the COM > server - that > > doesn't clear up the memory. I am using SafeArrayAccessData and > > SafeArrayUnlock on the server side to make sure that it releases the > data on > > the server side. > > > > Is there something else that I must do? > > I suggest you get the latest CVS version (I realize this may be a > PITA :-( Since build 132, a number of leaks have been fixed. There is > a very good chance that this particular leak was plugged previously. > > If not, I will definately look into this and plug it! > > Mark. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From mksql at my-deja.com Mon Jul 3 01:19:49 2000 From: mksql at my-deja.com (Matt) Date: Mon, 03 Jul 2000 01:19:49 -0400 Subject: Tutorials at IPC9 References: <39591877.535A96BC@sage.att.com> Message-ID: <9i80ms4tbkjjhp90t55au011qquvmsr456@4ax.com> On Tue, 27 Jun 2000 21:11:19 GMT, Garry Hodgson wrote: >I'm starting to think about what kinds of tutorials we should have at >the next Python conference. Is there information available on when and where this will be? From bdupire at seatech.fau.edu Wed Jul 12 10:03:42 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Wed, 12 Jul 2000 10:03:42 -0400 Subject: Adding Directory to PYTHONPATH References: <8i1l7j$d01$1@nnrp1.deja.com> Message-ID: <396C7ABE.131317A5@seatech.fau.edu> Hi Mike... It depends on the platform you work on. If you are using Windows, the best is to create a file "mymodules.pth", as you mentionned. Ex: "mymodules.pth" content : mymodules c:\My Documents\python\modules Then the next time a Python interpreter is started, sys.path will have c:\program files\python\mymodules and c:\My Documents\python\modules added to it, if they exist. (check!) This trick doesn't work on other platforms (QNX for example) On Windows,the other trick is to modify the registry. Have a look at http://www.python.org/windows/python/registry.html Then if you are on Linux/Unix/QNX you have to modify the PYTHONPATH environment variable. You can do that in the .cshrc file , located in your home directory. Edit the file .cshrc so that it looks like the following: ##### Set path set path = ( . /bin /usr/bin /usr/local/bin /usr/ucb /usr/X11/bin /old_home/bdupire/Python-1.5.2) set PYTHONPATH = (/old_home/bdupire/Python-1.5.2/my_prog) On LINUX (bash shell): $ export PYTHONPATH=/home/me/python $ echo $PYTHONPATH /home/me/python $ PYTHONPATH=/home/you/python:$PYTHONPATH $ echo $PYTHONPATH /home/you/python:/home/me/python All of these tricks didn't work for me.. so I have to figure out another way. If you compiled Python from the source code, go to ../Python-1.5.2/Modules Edit the file 'Setup' In thi file you might find the following : # Standard path components for test modules TESTPATH= Modify this line: TESTPATH=:my_directory and you will be able to put your modules in .../Python-1.5.2/Lib/my_directory I hope this will help as i am also relatively new to Python. Benoit mike at pl.net wrote: > Hi All ! > Probably been asked before but how do you add a new library module > directory to PYTHONPATH? > > I know you can do it dynamically in Python, but in this case I need to > have a particular module directory available everytime that Python is > loaded. > > I tried including a .pth file but can't see the new directory when I > print sys.path > > Grateful for any pointers > Best regards > Aren't we lucky for having Python! > Mike > > Sent via Deja.com http://www.deja.com/ > Before you buy. From cjensen at bioeng.ucsd.edu Wed Jul 5 19:19:58 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 05 Jul 2000 16:19:58 -0700 Subject: Hello Word in CGI Message-ID: <3963C29E.76211EB7@bioeng.ucsd.edu> We get this error in our server log: Wed Jul 5 16:12:52 2000] [error] [client 132.239.236.47] Premature end of script headers: /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py The browser gives us this error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster at bioeng.ucsd.edu and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/1.3.6 Server at cmrg.ucsd.edu Port 80 Using this script from: http://www.ping.be/sabine-appelmans/home/python/index.html #!/usr/local/Python/bin/python # # helloworld.py # from time import * print "Content-type: text/html" print print "" print "" print "Hello World" print "" print "" print "

Hello World !

" print "
" print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" print "" print "" Any ideas why? -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From jhe at webde-ag.de Thu Jul 20 04:02:10 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Thu, 20 Jul 2000 10:02:10 +0200 Subject: Determine path of current module? References: <3976AA30.1C4F62B8@schlund.de> Message-ID: <8l6bis$elb$1@pollux.ip-plus.net> "Carsten Gaebler" schrieb im Newsbeitrag news:3976AA30.1C4F62B8 at schlund.de... > How can I determine the path of the current module at runtime? (sys.argv[0] > won't work when running it through pythondoc) ### mypath.py import sys print sys.modules[__name__].__file__ [d:\tmp]python -c "import mypath" mypath.py [d:\tmp]python -c "import mypath" mypath.pyc Ciao, J?rgen From max at alcyone.com Tue Jul 11 01:20:24 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 10 Jul 2000 22:20:24 -0700 Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> <8kdref$j4t$1@nnrp1.deja.com> Message-ID: <396AAE98.F851708B@alcyone.com> shindich at my-deja.com wrote: > It seems to me that there is no need to have this map at all. It actually is necessary for my purposes, since the strings that is used for dispatching will not be a status code (a three digit number as a string), not actually the name of the method to be invoked. (I simply showed it that way for the purposes of the sample code; certainly in the example I showed you are correct.) Thanks, though. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ If the sky fall, hold up your hands. \__/ (a Spanish proverb) Alcyone Systems' CatCam / http://www.catcam.com/ What do your pets do all day while you're at work? Find out. From skip at mojam.com Fri Jul 7 11:57:15 2000 From: skip at mojam.com (Skip Montanaro) Date: Fri, 7 Jul 2000 10:57:15 -0500 (CDT) Subject: Python bug reporting [was: Re: readline.c & more] In-Reply-To: References: Message-ID: <14693.64987.484057.325941@beluga.mojam.com> Fran?ois> There are plenty of users, and a much smaller bunch of Fran?ois> maintainers. It seems more fit to me to adapt to the plenty Fran?ois> of users, than force all of them into the methods of a few. Fran?ois, While based on sheer numbers, there are clearly many more users than maintainers, it's the maintainers that fix things, so they need to be able to work efficiently. The number of people with checkin privilege to the Python CVS tree (currently 20, scattered around the globe) makes it all but impossible to manually manage change requests and patch submissions. Under the old system, the number of patches that were falling through the cracks was far too high. The SourceForge patch manager and bug manager aren't perfect, but they provide the Python maintainers with a system that allows them to much more easily see what's outstanding and what's been taken care of. They need to add an email submission mechanism. I suspect that will happen in time. If you forward your request to me I will add submit the request on your behalf. -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From olivierS.dagenaisP at canadaA.comM Mon Jul 3 12:15:48 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 03 Jul 2000 16:15:48 GMT Subject: Random number generation, simple question. References: Message-ID: I'm not sure feeding "random" numbers as the seed will keep producing random numbers. You may want to try scanning different components of the computer, in order to retrieve values that, chances are, will be different from machine to machine and from time to time, like how many files are there on the computer, what the address of the network card is, how long has the machine been running, what keys has the user pressed, how has the mouse or joystick been moved, etc... ??? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Kalle Svensson" wrote in message news:Pine.GSO.4.21.0007031546410.25965-100000 at luna.dsv.su.se... > Hello. > > I have a few questions about the (pseudo) random number generator supplied > in the standard library. I need 80 random bits (for a CipherSaber IV) but > I hear most RNG's only supply 32 bits or less. My questions are: > > * How many random bits does whrandom.random() generate? > > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? > > * Are there better alternatives? I understand I could read from > /dev/random on Linux, but this isn't portable, and even though I only > use GNU/Linux myself, I have friends who don't. If anyone can tip me > off about a similar feature in Win32, I could just detect platform and > use the appropriate function, of course. I don't think I have to care > about Macs or other *NIX dialects. Phew... :) > > Hope I'm making sense even though I hardly understand what I'm talking > about... :) > > TIA, > Kalle Svensson > From walter111 at structurex.net Thu Jul 20 03:55:13 2000 From: walter111 at structurex.net (walter hanagriff) Date: Thu, 20 Jul 2000 02:55:13 -0500 Subject: 2 tkinter questions Message-ID: <3976B061.617CACB0@structurex.net> if the source of this standalone file should be given to better help me by running it, then just say so please, i figured not putting the full source because this part was my only problem area and to save space, though i guess i talk too much already i finally figured a way to add stuff to the second frames in the program i posted earlier, but everytime i make a step forward it seems that i get stuck again, and i have tried getting past this one several ways as usual, the one shown here only the latest one, not better or worse then the other attempts main problem: i want to make it so that when a person hits a button the answer pops up in the frame i set iv1 and iv2 to those numbers for testing, and another problem to be asked next. at first the label wasnt in its own def but it was showing 3 { to the power of } 2 { = } 9 under the 2 entrys before i even hit the button, so i gigured puttong it in its own def and calling it from the button would work, but it still shows too soon what should i do? and what am i doing wrong that makes it do this, i also tried not packing the label until the button was pressed by giving the label a name and using bind on the button and using the button option command = label1.pack() but it still showed the label like it was reading the button command even before i clicked on the button, nothing makes sense. i hope i am making enough sense to be able to get an answer second problem, how best should i get the value from the entry widgets after a value is entered, the line that is commented is that way because when i try to get the value of entry1 through that get method, it says no value is entered so i cant get the powr of any numbers, and i also tried using the get method for the textvariable and still get nowhere, besdies the best way to get an entry variable how to i make it so that it doesnt get the variables until from the entry widgets until the button is pressed? def power(self, frame): entry1 = Entry(frame, width = 10, textvariable = self.ivar1) ; entry1.pack() entry2 = Entry(frame, width = 10, textvariable = self.ivar2) ; entry2.pack() # iv1 = entry1.get() ; iv2 = entry2.get() iv1 = 3 ; iv2 = 2 text = iv1, " to the power of ", iv2, ' = ', iv1**iv2 def answer(frame, text): Label(frame, text = text).pack(padx = 15) Button(frame, text = 'Get answer', command = answer(frame, text)).pack(side = LEFT) From pehr at pehr.net Thu Jul 20 00:29:26 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 20 Jul 2000 04:29:26 GMT Subject: critique my 1st program ever References: <39761FAA.70E65704@tcgfinancial.com> Message-ID: <39768026.C8D9649C@pehr.net> 1. Linux gives your local IP address bound to an interface. My machine has several IP addresses, one for each inteface. Some servers have more than one IP address per interface! Your problem is not as easy as it sounds. The dirty way is to run /sbin/ipconfig and parse the result. txt = os.popen("/sbin/ipconfig").read() 2. Making a background process start transparently on multiple operating systems is going to be a challenge. Linux has cron for regular tasks and the /etc/rc.d/init directory structure for boot scripts. Linuxconf does a good job of managing thes start/stop scripts if you just follow the existing command-line conventions. I have no idea how to install a windows service. You may find some pointers in the "Pyhton for Win32" book. 3. To see platform-dependent stuff: import sys; print sys.platform on my box I get linux-i386 jtoy wrote: > > Hi, this is my first program I have ever written. Please tell e what I > need to do to clean it up or make any other suggestions. Thanks. > Also, could you answer a couple of question I have below. > > # Written by Jason Toy(toyboy at toy.eyep.net)http://toy.eyep.net on 02:07 > July 16, 2000 EST > #This program is an eyep client for any OS that has Python installed > import urllib, os, string > > def parser(host, userdata): > if userdata['ip'] =="": > eyep = > 'http://eyep.net/update.php/'+userdata['username']+'/'+userdata['password']+'/'+host > > else: > eyep = > 'http://eyep.net/update.php/'+userdata['username']+'/'+userdata['password']+'/'+host+'/'+userdata['ip'] > > parsereturn = urllib.urlopen(eyep) > if parsereturn.read() == "RETURN4": > print host, "has been updated successfully" > elif parsereturn.read() == "RETURN1": > print "You are missing fields, request is probably misconfigured > for", host > elif parsereturn.read() == "RETURN2": > print "Bad username/password for", host > elif parsereturn.read() == "RETURN3": > print host, "isn't owned by you" > elif parsereturn.read() == "RETURN5": > print "Invalid IP address for", host > elif parsereturn.read() == "RETURN6": > print "Service is temporarily unavailable" > else: > print "Error message on", host, ":", parsereturn.read() ,"--Please > report to http://www.eyep.net for further information." > > def readuserdata(aFileName): > userdata = {} > myfile = open(aFileName) > for line in myfile.readlines(): > (item, value) = string.split(line, ':', 1) > userdata[item] = string.strip(value) > return userdata > > def writeuserdata(aFileName, userdata): > myfile = open(aFileName, 'w') > for item in userdata.keys(): > myfile.write("%s:%s\n"% (item, userdata[item])) > myfile.close() > userdata = {} > if os.access('userdata.dat', os.R_OK) == 0: > userdata['username'] = raw_input("Enter your user name: ") > userdata['password'] = raw_input("Enter your password: ") > userdata['host1'] = raw_input("Enter you first hostname: ") > userdata['host2'] = raw_input("Enter your second host(if you have only > 1, press enter): ") > if userdata['host2'] != "": > userdata['host3'] = raw_input("Enter your third host(If you have > only 2, press enter): ") > userdata['ip'] = raw_input("Enter your ip(press enter for > autodetection): ") > > else: > userdata = readuserdata('userdata.dat') > parser(userdata['host1'], userdata) > if userdata['host2'] !="": > parser(userdata['host2'], userdata) > if userdata['host3'] !="": > parser(userdata['host3'], userdata) > else: > print "Thank You" > if os.access('userdata.dat', os.R_OK) == 0: > print "Saving your configuration........." > writeuserdata('userdata.dat', userdata) > > Can you tell me how I can make a python program find the IP address of > the local machine? If possible, I would like to make this not matter > what OS its on( i want it to work on windows and Unix/Linux/BSD). > Second, can you tell me how I could run this program as a dameon, again > not OS dependent, because while I know you can put a Python script in > cron, how can you do the same with windows? > Third, how can I make Python recognize what OS its on, that wat if I > can't do the above 2 questions withouot being OS dependent, then I will > do somethin like: if OS == x then do else OS == z do > Thanks for your time. > > Jason Toy > toyboy at toy.eyep.net > http://toy.eyep.net From mfein at aplcomm.jhuapl.edu.bbs Thu Jul 13 08:40:03 2000 From: mfein at aplcomm.jhuapl.edu.bbs (mfein at aplcomm.jhuapl.edu.bbs) Date: 13 Jul 2000 12:40:03 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bO6E2$k0U@openbazaar.net> On Wed, 12 Jul 2000 19:32:32 GMT, hzhu at knowledgetrack.com (Huaiyu Zhu) wrote: > >We are at a crucial juncture concerning introduction of new operators into >Python for matrix computation, > >1. Experiences with Matlab show that different operators for matrix and > elementwise operators are very important > >2. It is difficult to add .* and ./ as . is already a valid token. It seems > that next candidate on the standard keyboard is @. > >3. Gregory Lielens has just implemented a patch that could parse additional > operators containing @ > > a at b is equivalent to a*b, overloaded using __mmul__ and __rmmul__ > a@/b a/b __mrdiv__ and __rmrdiv__ > a/@b b/a __mldiv__ and __rmldiv__ > a@@b a**b __mpow__ and __rmpow__ > > He indicates similar constructions can be added easily. > > >We intend to add these operators together with Thomas Wouters's augmented >assignment operators (+=,*=, etc) to MatPy, but before that several >decisions need to be made. First, the main choices: > > >1. Use a*b as matrix mul, and a@*b as elementwise mul. >Pros: >- Consistent with Matlab. >- Consistent with current MatPy. >- Convenient for matrix computations. >Cons: >- Inconsistent with NumPy >- How to differentiate left and right div (matlab a\b and a/b)? > > >2. Use a@*b as matrix mul, and a*b as elementwise mul. >Pros: >- Consistent with NumPy >- Can use a@/b and a/@b as matlab a/b and a\b. >- Can use a at b as inner product so that a at b works irrespective of whether a > and b are row or col operators. >Cons: >- Inconsistent with current MatPy. Need great effort to switch. >- Using two symbol operator for matrix mul is cumbersome for long formulas. >- It kind of looks ugly. > > >3. Use a at b as matrix mul, and a*b as elementwise mul. This has most of the >pros and cons of choice 2, except >Pros: >- Single symbol operators for matrix mul and element mul. >Cons: >- Can't use a at b as inner product. > My own preference would be 'as consistent as possible with MATLAB, with some caveats'-- this would mean option 1, with some thought about changes in places where the current MATLAB syntax drops the ball (IMO). I don't think MATLAB's inelegances should be preserved for the sake of consistency. On the other hand, I think it's very important to make the translation from MATLAB language to Python as automatic as possible. The main thing I'd think about in addition to standard MATLAB syntax is a natural 'prolongation' syntax. In other words, contexts in which the vector [1 2 3] is naturally expanded to [1 2 3;1 2 3;1 2 3;...]. This operation is part of one of the basic strategies in vectorization-- prolongation, followed by some vectorized operation, followed in turn by selection or contraction. Presently, MATLAB can do this, but only in an idomatic and peculiar way. There are some dangers in this route-- it encourages a tendency to syntactical trickiness-- the history of the APL language provides a case in point and a warning. One thing that MATLAB does correctly (again, IMO) is its relatively relaxed attitude towards distinctions among scalars, 1x1 vectors & matrices as well as among different kinds of nulls and NAN's. You can test for these distinctions if you want to, but generally MATLAB will just quietly do the right thing. There's a tendency to get wrapped up in fine distinctions in cases where there's really no ambiguity about what the programmer wants to do. -- Matt Feinstein mfein at aplcomm.jhuapl.edu Organizational Department of Repeated and Unnecessary Redundancy From moshez at math.huji.ac.il Wed Jul 12 13:48:23 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 12 Jul 2000 20:48:23 +0300 (IDT) Subject: Changing the class of an instance In-Reply-To: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> Message-ID: On 12 Jul 2000, Richard Tobin wrote: > Is it legal (it seems to work) to change the class of an object by > assigning to its __class__ attribute? In particular for the case where > the new class is a subclass of the old. > > I'm not looking for an argument (not even the five minute one) about > whether it's a good idea, just whether it's legal. Well, you can't get arrested for it in Britain, AFAIK. However, accidents have happened to people who did this, so I'd be careful if I were you. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From herzog at online.de Fri Jul 28 12:52:18 2000 From: herzog at online.de (Bernhard Herzog) Date: 28 Jul 2000 18:52:18 +0200 Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> <39808e81.145010138@news.telus.net> Message-ID: root at 127.0.0.1 (David) writes: > On Thu, 27 Jul 2000 10:44:08 +1000, Steve Purcell > wrote: > > >Shae Erisson wrote: > >> And I'm opposed to it because it seems like sugar to me. I've always > >> loved Python's simplicity, and I hope it stays that way. > >> Adding new operators and new syntax will make Python harder to read, and > >> harder to learn. I don't want that. > > > >Yay! Python luddites unite! > > Hear, hear. > > Hell, yeah, I'll use the new operators and syntax! I freely admit it: I'm > lazy, I like shortcuts, I'll take the easy way out. > > That doesn't mean I think it's a good idea for Python to offer them. > > IMO, they're detrimental, and should not be offered. I think we can reconcile both viewpoints, namely "new operators violate python philosophy" vs. "new operators are useful", by introducing just one new operator. This new operator guesses what the progammer wanted and is used like this: A ;;>> B This new operator is pronounced "wink-wink-nudge-nudge" or "do-whaddaye-mean-do-whaddaye-mean" (although this might be a tad too Perlish). For extra expressiveness we could also through in :-|:-| a.k.a. "say-no-more-say-no-more". -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From robin at jessikat.fsnet.co.uk Thu Jul 20 12:45:15 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 17:45:15 +0100 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39771CA8.A1BF8D6E@fft.be> Message-ID: In article , Tim Hochberg writes >Robin Becker writes: ... > >> >> the lie product (or bracket) has applications in sensitivity analysis >> and other more exotic stuff in differential geometry >> >> [A,B] = AB - BA > >It's the commutator! Why didn't anyone say so earlier. > >-tim > well you call it the commutator, but I never called it that in the '70s when I last used it seriously. -- Robin Becker From paul at prescod.net Mon Jul 24 16:04:53 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 15:04:53 -0500 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: Message-ID: <397CA165.582D8786@prescod.net> Michal Wallace wrote: > > .... > > The two dict idea does make sense. You could have a __handler__ dict, > and then the normal __dict__. __dict__ would work as today, containing > normal values. __handler__ would contain accessor methods, marked as > being the special type to distinguish them from any other > methods... Or something else. Why do accessor methods in __handler__ have to be differentiated if the only thing in __handler__ is accessor methods? > The "something else" could be any number of things: > > 1. "None", in which case you go look up the value again in __dict__ > (which I'd guess is a performance issue to your way of thinking) I'm not sure if I follow. Let's say that I have a hundred attributes on an object, and one computed attribute. Are you saying that I would have two dictionaries with a hundred entries each? 99 would be null in the __handler__ dictionary? > 2. A reference to the same value in "dict". This would mean you'd > have to update both dicts, and keep them in sync. Same question. > 3. A reference to a "default" accessor method (builtin), which > probably looks pretty much like the current getattr/setattr/delattr. Same question. > ... > You'd still have to look up the thing again in the other dict, but > you'd eliminate. Plus the handler dict could be copied directly when > inheriting, so it would always be a one step search to get the > handler, and the handlers would act only on __dict__. I'm somewhat leery about implementing a different inheritance implementation than that of Python itself. I have a vague feeling that there is reason that Guido chose NOT to copy things from one class's dict to another. Perhaps so you could dynamically re-structure your class hierarchy. > I was going to suggest doing this as a mixin class, but the current > getattr/settattr/delattr doesn't seem to allow it when there's already > a value in the dict: Right, I don't think that that behavior is so onerous now, nor in the proposal. In return for the performance I think it is a small price to pay. One serious constraint is that I cannot slow down Python! Adding an attribute handler to a class should have as little performance impact as is humanly possible. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From bjorn at roguewave.com Mon Jul 24 12:16:24 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 24 Jul 2000 10:16:24 -0600 Subject: the right way of handling **args for __init__ and other methods References: <8lhlfg$sk5$1@news.kth.se> Message-ID: <397C6BD8.CF87E01@roguewave.com> Oivvio Polite wrote: > > Hi all. > I guess this is more of a design question than a howto question. > > It has to do with implementing arbitrary-argument set methods. > I want the user to be able to use the same interface with __init__ and read. > This is a stripped down version: > class argeater: > def __init__(self, somearg, **args): > print "init ",args > self.data = {} > self.read(somearg, argdict=args) you can use apply(self.read, (), args) and avoid the special case in read, or... > def read(self, somearg, argdict=None,**args): > print "read ",args > print "argdict ",argdict > > #putting everything from argdict into args > #feels a bit awkward. > if argdict: > assert type(argdict) == types.DictionaryType > for key in argdict.keys(): > if not args.has_key(key): > args[key] = argdict[key] > > #now do a lot of stuff to self.data > #based on contents of args Since args looks to be always empty when argdict != None, you can say args.update(argdict) which will overwrite args, or if you want to be able to pass both a dictionary and keyword args to read: tmp = {} tmp.update(args) tmp.update(argdict) -- bjorn From olmy at thistledown.org.bbs Mon Jul 17 10:20:01 2000 From: olmy at thistledown.org.bbs (olmy at thistledown.org.bbs) Date: 17 Jul 2000 14:20:01 GMT Subject: example on how to use configparser in python? Message-ID: <3bREh1$jq1@openbazaar.net> > Does anyone have that? Hello, assuming you have a config file called test.conf and it contains the following: [DEFAULT] name = pythontest path = /tmp/test then you should be able to use the following quickie test script: from ConfigParser import * configdict = ConfigParser() configdict.read('test.conf') print configdict.defaults().keys() print configdict.defaults()['path'] path = configdict.defaults()['path'] print path that should give you a quick idea of how to load your config file in ConfigParser's dictionary format. See the following URL for the reference documentation on what else you can do with ConfigParser: http://www.python.org/doc/current/lib/module-ConfigParser.html Pay special attention on how to handle RFC822 sections and how to handle the "%" expansions. Hope this helps. jeff From moshez at math.huji.ac.il Wed Jul 26 16:06:04 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 26 Jul 2000 23:06:04 +0300 (IDT) Subject: Deleting files with wildcards In-Reply-To: <397f046d.193858654@news.atnet.at> Message-ID: On Wed, 26 Jul 2000, Manfred Pisecky wrote: > Hello everyone! > > I have to delete a bundle of files, e.g. *.txt in a portable way (it > must work for Linux and NT). Use the glob module, and os.unlink -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From to_get_my_address at see.my.signature Wed Jul 26 21:07:07 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 14:07:07 +1300 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> <8l7f69$bon$1@fermi.tro.net> <8ljlp9$99m$1@desig-bs01-s04.adtranzsig.de> Message-ID: <397F8B3C.6DF7EFB9@see.my.signature> "Rainer Deyke" schrieb im Newsbeitrag news:kBJd5.35887$6y5.24003017 at news2.rdc2.tx.home.com... > Sounds messy and slow. An indirect function call per instruction? Could > be slower than Python, If you look at all the stuff Python actually does to execute a typical bytecode, you'll be amazed that it's as *fast* as it is! -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From fiona at sitegnome.com Sun Jul 9 08:26:08 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 9 Jul 2000 12:26:08 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 9th, 2000 Message-ID: <20000709122608.22157.qmail@synop.com> Hi Guys, The latest entries into http://python.faqts.com regards, Fiona Czuczman ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there a utility to convert module docstrings to HTML for nice documentation? http://www.faqts.com/knowledge-base/view.phtml/aid/4610 ------------------------------------------------------------- Stu D ## New Entries ################################################# ------------------------------------------------------------- Formatted printing of numbers with significant digits http://www.faqts.com/knowledge-base/view.phtml/aid/4596 ------------------------------------------------------------- Russell Wallace # Number formatting functions by Russell Wallace # Includes inserted commas, specifiable number of decimal places, # and the ability to specify a number of significant digits before or # after the decimal point. # This code is in the public domain. def format(x, sigdigits=0, decimals=0): if sigdigits == 0: sigdigits = 16 sign = "" if x < 0: sign = "-" x = -x decpart, intpart = modf(x) s = sign + formatnat(intpart) + str(decpart)[1:] s = strtocharlist(s) count = 0 counting = 0 propflag = 0 propindex = 0 for i in range(len(s)): c = s[i] if c in digits: if c != "0": counting = 1 if counting: count = count + 1 if count > sigdigits: if not propindex: propflag = s[i] >= "5" propindex = i s[i] = "0" if propflag: prop(s, propindex) s = charlisttostr(s) while (s[len(s) - 1] == "0"): s = s[:-1] i = index(s, ".") + 1 n = len(s) - i s = s + "0" * (decimals-n) if s[len(s) - 1] == ".": s = s[:-1] return s def formatnat(x): s = "" count = 0 while 1: c = fmod(x, 10) c = str(int(c)) if not count and s != "": s = "," + s count = (count + 1) % 3 s = c + s x = floor(x / 10) if x == 0: break return s def prop(s, i): while i: i = i - 1 while i >= 0 and not (s[i] in digits): i = i - 1 if i < 0: break d = int(s[i]) + 1 if d == 10: d = 0 s[i] = str(d) if d: return i = 0 if s[0] == "-": i = 1 if countdigits(s) % 3 == 0: s.insert(i, ",") s.insert(i, "1") def countdigits(s): n = 0 for c in s: if c == ".": break if c in digits: n = n + 1 return n def formatmoney(x): return "$" + format(x, 0, 2) def formatpercent(x, y): x = float(x) / y x = x * 100 return format(x) + "%" ------------------------------------------------------------- How can I remove a number of items from a list using a loop? http://www.faqts.com/knowledge-base/view.phtml/aid/4623 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen the obvious way: for x in list[:]: # create a copy if f(x): list.remove(x) perhaps faster: for i in range(len(list)-1, 0, -1): x = list[i] if f(x): list.remove(x) that traverses the list backwards, so should be more resistant to the list changing... ## Edited Entries ############################################## ------------------------------------------------------------- How can I tokenize a string using more than 1 separator? http://www.faqts.com/knowledge-base/view.phtml/aid/3140 ------------------------------------------------------------- Fiona Czuczman David Goodger,Mikael Olofsson use re.split: >>> import re >>> s = "one,two;three:four,five;six:seven" >>> re.split("[,;:]", s) ['one', 'two', 'three', 'four', 'five', 'six', 'seven'] >>> sep = re.compile("[,;:]") >>> sep.split(s) ['one', 'two', 'three', 'four', 'five', 'six', 'seven'] ---- Alternately ---- seps = ':|/' mystring = 'foo:bar|baz/zot' newstring = string.join(map(lambda x, seps=seps:(x+seps[0])[x in seps],a),'') result = string.split(newstring,seps[0]) ------------------------------------------------------------- Why do some strange characters appear instead of norwegian characters in GUI of pythonwin build 132? http://www.faqts.com/knowledge-base/view.phtml/aid/4590 ------------------------------------------------------------- Nils Otto Johansen, Fiona Czuczman Neil Hodgson I'm not sure about 132 but 131 defaults to using Unicode for editing Python source code and the interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and comment out the two lines under "# Enable Unicode if we can". Save the file, shut down Pythonwin and restart it and see if this fixes the problem. From thiele at muc.das-werk.de Mon Jul 10 09:10:52 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 10 Jul 2000 15:10:52 +0200 Subject: reference counter and __del__ Message-ID: <3969CB5C.A860D124@muc.das-werk.de> 1. I have the problem that not all of my objects are destroyed and I don't know where and why, so I wonder if there a way to check out from where and how many references to a special object exists? 2. When __del__ is called the object will be detroyed, correct? 3. Why is __init__ not called when I unpickle an object? Thomas From paul at prescod.net Fri Jul 21 07:30:22 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 21 Jul 2000 06:30:22 -0500 Subject: Name valid outside function, but error name inside function References: Message-ID: <3978344E.AD4D5652@prescod.net> "Fernando Rodr?guez" wrote: > >... > This raises a name error: > def func2(): > A = A + 'hi' # this line causes the error > print A Does it really raise a NameError? Or an UnboundLocalError? You probably want def func2(): global A A = A + 'hi' # this line causes the error print A You probably know that "from X import *" is considered bad style, BTW. Also, I'm not sure if the code I wrote will do what you want it to. Assigning to A in one module rebinds it in that module. I don't think it will have any effect in the other module. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From loewis at informatik.hu-berlin.de Tue Jul 11 08:50:52 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Jul 2000 14:50:52 +0200 Subject: reference counter and __del__ References: <3969CB5C.A860D124@muc.das-werk.de> Message-ID: Thomas Thiele writes: > 1. I have the problem that not all of my objects are destroyed and I > don't know where and why, so I wonder if there a way to check out from > where and how many references to a special object exists? Use sys.getrefcount, or the garbage collector included in the current development version of Python (which may become Python 2 later this year). > 2. When __del__ is called the object will be detroyed, correct? Vice versa. When the object is going to be destroyed, then __del__ is invoked. Actually, when __del__ brings the object back into life, it will not be destroyed. > 3. Why is __init__ not called when I unpickle an object? a) __init__ is called when unpickling, provided __getinitargs__ is defined. b) Since 1.5.x (for some x), __init__ is not normally called, because getting the init args right without __getinitargs__ is tricky. Essentially, pickled objects were required to accept 0 arguments to __init__, which is often undesirable. Regards, Martin From lordkaos at my-deja.com Tue Jul 18 20:24:11 2000 From: lordkaos at my-deja.com (lordkaos at my-deja.com) Date: Wed, 19 Jul 2000 00:24:11 GMT Subject: Python in game development? References: Message-ID: <8l2ses$kei$1@nnrp1.deja.com> The company I worked for (Cinematix, a small development firm) developed Revenant for Eidos and we had our own scripting language that ran the gameplay logic. We had a lot of problems with speed, stability, flexibility, and the designers who actually used the language were sometimes left hanging with regards to functionallity. The lead programmer came across Python a few years into the project (when it would have been too late to utilize it) and mentioned that it could have been tremendously beneficial to development of the game. I was a programmer on the project and I can attest to that fact. Looking back I would say it couldn't have been more than an extreme advantage if we had known about Python beforehand. The game is complex enough and graphicly intensive enough to require Asm/C++, but from a designer/artist's point of view, they could have learned Python and used to contribute amazing creativity to their specific parts of the project. Embedding Python as the game's internal scripting language would have sped up development and increased the game quality significantly. I hope Cinematix decides to use Python in the future (and other companies that need a similar scripting language). In article , "Mallor" wrote: > Are any of you game developers out there using Python as your game engine's > embedded scripting language? I am wondering what drove your decision to use > Python instead of other embeddable scripting languages? I'd like to hear what > your overriding concerns were, and also what they are now, having put Python to > the test. > > -- > Cheers, Infernal Troublemaker Troll > Mallor "By simple mistake, mortals the Sent via Deja.com http://www.deja.com/ Before you buy. From grey at despair.rpglink.com Sat Jul 29 18:15:35 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:15:35 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> <8luhso41ce8@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 13:53:02 +0200, Alex Martelli wrote: >Yes, so the latter is best when you have a single format you want to >apply to several different variables at various point, the former is >best when the names are fixed. That's why Python supplies both. Excellent description except for one thing, I never said that the variable names were fixed. Take a look at Perl's ##foo, for example. Well, more accurately ${$foo}. Again, just taking a pseudo-code, not a real lanauge. > "Here is a very %(adj)s %(noun)s!" "Here is a very $$adj:$format $$noun:$format!" > "Ecco una %(noun)s molto %(adj)s!" "Ecci una $$noun:$format molto $$adj:$format!" > print format % {'adj':adjective1, 'noun':noun1} > print format % {'adj':adjective2, 'noun':noun2} print format Adj and noun need to be assighed in either case. Except when we do it inline we can see what formatting goes with what. It really is semantical in nature since there is no different at all in function that I can find. The only difference is having to match up what is at the end of the string with what is right there where you're looking at the moment. >> "%d:0:0 %c:U %s %s %s %s %d %s %s %s \ >> %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k >> What variable goes with what again? >Yes, a format-string with named-placeholders does help with that, too. But not as much as just having the variables in line with the formatting where reading is still the natural left to right (for us natives of European lanauges) with all information presented where it must be. >I'm very happy not _having_ to invent some arbitrary name when what >I want to do is output one or more arbitrary expressions, computed >on the fly, for example. Naming has its place, but so does quiet >anonimity...:-). Why do you need to place them at the end? "1 + 1 = ",1 + 1:0:0, ",really, it is!" Again, fake language. I don't see a need to have placeholders for simple statements at the end when you can place those statements in line. >Could be (I _am_, after all, a well-known sadomasochist!), but, if >it were that, I think I'd be programming in C shell (hard to think >of a more painful way to make a living; and yet there _were_ people >writing scripts in it rather than the somewhat-less-painful Bourne >shell, for reasons I've always found utterly unfathomable...). ESC-P comes to mind. I find all shell scripts horrible. Any time I need to work on one I take the basic logic and rewrite in Perl. Less need to have to worry about globbing and proper escaping of everything and handing different input/output expectations from different programs. Sure, I'll use grep on the command line but I'd rather see while(<>){m//;} in the script, thank you. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From see at below Sun Jul 30 02:31:57 2000 From: see at below (Paul Foley) Date: 30 Jul 2000 18:31:57 +1200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> Message-ID: On Sun, 30 Jul 2000 01:54:55 GMT, Courageous wrote: >> > Actually I think it would be easier for non-programmers to >> >learn a language if it has strict typing. >> >> I concur. In non-programming, life is strictly typed. Allowed >> operations are determined by the type of the object. You can't >> make a phone call on a waffle-iron. > This is a conceptualization issue, and I suspect to a degree, > false. If "x" is merely a label, one can imagine x labeling > 3 or x labelling red quite easily. Your analogy works because Yes, but you know what the labels "telephone" and "waffle iron" conventionally refer to. Certainly you can play Humpty Dumpty games ("words mean what I want them to mean"), and choose to use "waffle iron" to mean what I mean by "telephone", and subsequently claim that you _can_ make a phone call on a waffle iron, but that's not actually disagreeing with what said. -- C/C++/Java/Perl/etc are for people who want to make things that work. Common Lisp is for people who want to make things that don't break. -- Erik Naggum (setq reply-to (concatenate 'string "Paul Foley " "")) From Rod.Haper at sage.nelesautomation.com Fri Jul 14 19:04:43 2000 From: Rod.Haper at sage.nelesautomation.com (Rod Haper) Date: Fri, 14 Jul 2000 18:04:43 -0500 Subject: atof problem. References: Message-ID: <396F9C8B.7E92B268@sage.nelesautomation.com> Also make sure that your locale is not set to something useful - the default is usually 'C' which leave most of the locale parameters unset. Here is an example of setting the locale to en_US showing how it sets the various locale parameters: >>> >>> import locale >>> locale.setlocale(locale.LC_ALL) 'C' >>> >>> locale.localeconv() {'grouping': [127], 'currency_symbol': '', 'n_sign_posn': 127, 'p_cs_precedes': 127, 'n_cs_precedes': 127, 'mon_grouping': [], 'n_sep_by_space': 127, 'decimal_point': '.', 'negative_sign': '', 'positive_sign': '', 'p_sep_by_space': 127, 'int_curr_symbol': '', 'p_sign_posn': 127, 'thousands_sep': '', 'mon_thousands_sep': '', 'frac_digits': 127, 'mon_decimal_point': '', 'int_frac_digits': 127} >>> >>> locale.setlocale(locale.LC_ALL, 'en_US') 'en_US' >>> >>> locale.localeconv() {'grouping': [3, 3, 0], 'currency_symbol': '$', 'n_sign_posn': 1, 'p_cs_precedes': 1, 'n_cs_precedes': 1, 'mon_grouping': [3, 3, 0], 'n_sep_by_space': 0, 'decimal_point': '.', 'negative_sign': '-', 'positive_sign': '', 'p_sep_by_space': 0, 'int_curr_symbol': 'USD ', 'p_sign_posn': 1, 'thousands_sep': ',', 'mon_thousands_sep': ',', 'frac_digits': 2, 'mon_decimal_point': '.', 'int_frac_digits': 2} >>> >>> s = '123,456,789.2' >>> s '123,456,789.2' >>> locale.atof(s) 123456789.2 >>> richard_chamberlain wrote: > > Hi William, > > Yes you could use the locale module to do what you want: > > import locale > s="123,456,789.2" > print locale.atof(s) > > As Bjorn said you'll have to get the locale module from somewhere. > > Otherwise do something like below: > > import string > def rcatof(num): > try: > flt=float(string.replace(num,',','')) > return flt > except: > return None > > >>> import myScript > >>> myScript.rcatof('123,456.2') > 123456.2 > > Richard > > William Dandreta wrote in message > news:yUqb5.977$tI4.52638 at bgtnsc05-news.ops.worldnet.att.net... > > I am having a problem with the atof function. I tried to convert 1,142.00 > to > > a float but the comma causes a problem. I resolved the problem by removing > > the comma but there must be a better way. > > > > I looked in the documentation and there was mention of the $LANG > > environmental variable but it did not tell haw to use it. Also, it > mentioned > > settings could be made using the functions in locale module. I tried to > > import the locale module but I get an error message that the _locale > module > > doesn't exist. > > > > Anyone have a clue about this? > > > > Bill > > > > -- +----------------------------------------------------------------------+ | Rod Haper, Senior Systems Analyst | Neles Automation | | Phone: 713-346-0652 - direct | SCADA Solutions, Inc. | | 713-939-0393 - fax | 7000 Hollister | | Rod.Haper at sage.nelesautomation.com | Houston, Texas 77040, USA | +----------------------------------------------------------------------+ From cut_me_out at hotmail.com Wed Jul 12 18:32:28 2000 From: cut_me_out at hotmail.com (Alex) Date: 12 Jul 2000 18:32:28 -0400 Subject: What is UnboundLocalError for? Message-ID: (Python 2.0 question.) I was wondering what situations the UnboundLocalError exception is intended to be thrown in. I encountered it when I made a mistake like this: >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 1, in f UnboundLocalError: l >>> This was much more confusing to me than a simple NameError, which is what python 1.5 throws for the same mistake. Perhaps I'm biased, though. Alex. From arhodes at psionic.com Mon Jul 17 12:33:18 2000 From: arhodes at psionic.com (Aaron Rhodes) Date: Mon, 17 Jul 2000 11:33:18 -0500 Subject: Getting local IP address... References: <8ko8qr$7cd$1@nnrp1.deja.com> Message-ID: <3973354E.87E1B221@psionic.com> Here's a tremendously non-portable way to do it for Linux by reading it straight off the ethernet card... import string,socket,fcntl SIOCGIFADDR = 0x8915 ifname = 'eth0' s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) ifr = ifname+'\0'*(16-len(ifname))+chr(socket.AF_INET)+15*'\0' r= fcntl.ioctl(s.fileno(),SIOCGIFADDR,ifr) addr = string.join(map(str,map(ord,r[20:24])),'.') print addr Aaron arhodes at psionic.com Stephen Hansen wrote: > > Nevermind. > > I've discovered i'm intelligent enough to actually chcek Deja and get > an answer so that i doin't have to spam ya'll with stupid questions :) > > Heh. :) > > --S > > Stephen Hansen wrote in message > news:8ko8qr$7cd$1 at nnrp1.deja.com... > > How do I go about getting my dynamic IP address? I want to make a > > little program to check periodically (daily or so) and log the results > > so I can determine how often my IP is getting shuffled. :) > > > > Thanks :) > > > > --Stephen > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. From shouldbe at message.com Fri Jul 7 09:22:50 2000 From: shouldbe at message.com (Arinté) Date: Fri, 07 Jul 2000 13:22:50 GMT Subject: kinda of silly??? Message-ID: When you are embedding python in a c++ app, all arguments sent from python to c++ in should function call should be parsed with PyArg_ParseTuple. Is that statement correct? I could have swore someone a while back told me other wise. From david_ullrich at my-deja.com Tue Jul 18 11:12:37 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Tue, 18 Jul 2000 15:12:37 GMT Subject: Changing the class of an instance References: <3bRLJW$k02@openbazaar.net> Message-ID: <8l1s4i$qhq$1@nnrp1.deja.com> In article <3bRLJW$k02 at openbazaar.net>, cut_me_out at hotmail.com.bbs@openbazaar.net (Alex) wrote: > > I don't think "confusing" is the right word. Although I'm fairly > > certain I won't get the words right: It destroys the... maybe the > > word is "encapsulation" or "modularity" or something - it means that > > you cannot verify things are correct by just looking at things > > locally. > > You're probably right, I don't know much of the jargon. > > > Not sure what sort of debugging we're referring to. If you're trying > > to figure out how to do something, as opposed to writing code meant to > > be used later, that's different. > > True, that's what I was trying to do, so the changing of the class was > only happening on a very limited and interactive level (and it still got > a bit confusing at times. :) > > > Possibly I missed it, but I haven't seen any reason given why changing > > __class__ is better than creating a new instance > > Well, if you want to do it by creating a new instance, you have to make > some sort of copy constructor. Unless you automate the process so that > it copies every attribute of the instance, you are bound to forget one > at some point. _If_ we're talking about real code meant to be actually used, as opposed to temporary experimental code, then the code is presumably tested at some point - the NameError should be a hint that something's missing... > Alex. > Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Fri Jul 21 18:58:44 2000 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jul 2000 18:58:44 -0400 Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: cjc26 at nospam.cornell.edu (Cliff Crawford) writes: > That doesn't seem to be true--readlines() reads the whole file whether > you specify a size argument or not. For example: You might want to try a larger sample - readlines() is documented that the size value is a hint - it might be rounded up to some internal buffer size, which I could easily imagine as being a few K. At least on Windows, with Python 1.5.2, it appears to work in multiples of about 8K. That is, size values are rounded up to the next multiple of 8K, and the total size of information returned will be somewhat shy of that multiple depending on line length since it only returns full 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 owen at astroNOJNK.washington.edu.invalid.bbs Mon Jul 17 14:00:02 2000 From: owen at astroNOJNK.washington.edu.invalid.bbs (owen at astroNOJNK.washington.edu.invalid.bbs) Date: 17 Jul 2000 18:00:02 GMT Subject: Tkinter canvas resize question Message-ID: <3bRKU3$ja5@openbazaar.net> I have a Tkinter canvas (along with a few other widgets) in a window. I want the canvas widget to resize whenever the window resizes (the other widgets are fields with fixed height). Not a problem, so far. But...I'd also like to resize the contents of the canvas whenever the user resizes the window. I have been catching the event, but this is not very satisfactory because I see it before the canvas does. I've been manually configuring canvas to a new size, but this is potentially unstable -- if I don't set exactly the size the frame wants, the frame will generate a new event, leading to many cycles of size changing. What I'd really like is for the canvas to resize itself (i.e. perform all the standard negotiations with its master) and then tell me it has been resized, so I can redo its contents. Is there some easy way to do this? Saving this, is there some easy way to catch , pass it to canvas (as if I'd never intercepted it) and then ask canvas what size it has become and redo its contents accordingly? I do have John Grayson's book "Python and Tkinter Programming"; the info is likely in there, but I haven't found it. I suspect I should also have a complete Tk reference, and would welcome suggestions. -- Russell P.S. another useful thing would be to have a window that contained a canvas of a particular aspect ratio (say 1:1, square). When the user resized the window, the window would retain the newly requested height, but the width would change as needed to give the canvas its desired aspect ratio. Is this sort of thing possible, and what is involved? Writing a new layout manager? From johngrayson at home.com Sat Jul 15 14:17:36 2000 From: johngrayson at home.com (John Grayson) Date: Sat, 15 Jul 2000 18:17:36 GMT Subject: Tkinter? References: Message-ID: <8kq9rl$ho7$1@nnrp1.deja.com> In article , "David L. Heald Jr." wrote: > I'm writing a script that will act as a GUI interface to another script, and > I want to have file browsing ability. How do I call this in Tkinter? I have > looked through 2 different books, and a couple of help files and have yet to > find anything. > > This is not really a Tkinter issue, since you can fire up a file browser window from a simple Python program. However, it may introduce some special problems if you're doing it from a GUI. Therefore, here is some sample code to illustrate how to do this for Windows and Solaris platforms. You would have to adjust for other platforms. Note that if you're doing this just for Unix, that you don't need to thread: you can just fire off the command in the background... from Tkinter import * from tkSimpleDialog import * import sys, os, thread class App: def __init__(self, master): self.master = master Label(master, text='Browsing:').pack(side=LEFT, padx=4, pady=15) self.entry = StringVar() Entry(master, width=50, bg='gray', textvariable=self.entry, state=DISABLED).pack(side=LEFT, padx=15, pady=15) Button(master, text='Browse...', command=self.browse).pack(side=BOTTOM) def browse(self): path = askstring("Browse", "Enter directory") self.entry.set(path) browser = Browse(folder=path) class Browse: def __init__(self, folder='.'): if sys.platform == 'win32': cmd = 'Explorer %s' % folder else: cmd = 'dtfile -folder %s' % folder thread.start_new_thread(self.doIt, (cmd,)) def doIt(self, where): os.system(where) root = Tk() display = App(root) root.mainloop() Hope this helps to get you started. BTW: Chapter 18 of Python and Tkinter Programming covers handling asynchronous events and things that block the mainloop... John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From olczyk at interaccess.com Sun Jul 9 23:12:29 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Mon, 10 Jul 2000 03:12:29 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <3968fadf.299209218@nntp.interaccess.com> On Sat, 01 Jul 2000 05:10:50 GMT, Courageous wrote: > >> Virtually all SUN has to do is pull some of the demo programs out of >> Microsofts manual. Write the equivalent code in python, perl, C++, >> pascal, and a few other languages. Compare them side by side. A fairly >> sophisticated person can see that it's resemblance to Java. Look at >> the law judges are sophisticated enough. Given that Microshit is being >> sued by SUN for their abuse of Java, I don't think it will be hard at >> all for SUN to convince a judge that all C# is, is a variant of Java >> with tons of proprietary crap glued on and the label changed. > >And all Java is is a variant of the C++ language with the kitchen >think glued on and the label changed. Hence the ridiculousness of >the claim. Sun would be stupid to even try. > Nope. Microshit is stupid to even try to copy Jva. I hold up a page of Java code and a page ofC++ and tell you which is which. Java is not a variant of C++. Java is a very different variant of C . Otherwise it would not be so popular. After all, if it were a C++ variant why would people go to all the trouble to switch from C++. C# OTOH is a clear rip off of Java. It is hard if not impossible to take a C# program remove all "Microsoft Enhancements" ( meaning all the features that tie it to COM ) and have it not look like a Java program. I suggest that if you want to continue Astroturfing, you learn something about programming language syntax. From rob at hooft.net Mon Jul 24 03:22:35 2000 From: rob at hooft.net (Rob Hooft) Date: 24 Jul 2000 09:22:35 +0200 Subject: process id from os.system References: <3977482B.478D2754@sec.noaa.gov> Message-ID: >>>>> "jv" == j vickroy writes: jv> How can I obtain the process id for a program launched via jv> os.system (theProgram) ? jv> I would like to do this portability (Unix, Windows). jv> Presently on Unix, I'm getting the pid by parsing the output jv> from: jv> "ps -ef | grep theProgram" jv> but that seems messy and unreliable since "theProgram" may be jv> truncated in the output from ps. Yikes, this is not really portable across unices either. You may want to look at my "more intelligent os.system" in the form of the "task.py" module. This represents a subprocess of os.system as an object. You can "Wait" for the object or "Kill" it. Unix only. http://starship.python.net/crew/hooft/ Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From amused at webamused.com Sat Jul 29 11:49:00 2000 From: amused at webamused.com (Joshua Macy) Date: Sat, 29 Jul 2000 15:49:00 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: <3982F04D.74FCF41C@webamused.com> William Tanksley wrote: > > > You consider "automagic" an insult? I've never HEARD of such a thing. > Please at least *inform* us before you take offence. Note that your > "taking offence" (which included an accusation that the entire Python > community was a disgrace to the language they support) paragraph was not > anywhere NEAR to any use of the word "automagic", so left no possibility > of figuring out why you were offended. > > I could be wrong, but I'm under the strong impression that the term "automagic" is thrown around repeatedly as a description of Perl's behavior in Programming Perl. Does that make Larry Wall a disgrace to the language he invented? Joshua From paul at prescod.net Sun Jul 23 02:35:20 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:35:20 -0500 Subject: Extend/Embed Python Method table Dispatcher References: <8l85e1$eti$1@nnrp1.deja.com> Message-ID: <397A9228.5382409C@prescod.net> heath7952 at my-deja.com wrote: > > Dear All, > > I am extending Python with my own C functions. I would like be able to > share one C function amongst different extended commands. Here's a > little pseudo example. How about this: static PyMethodDef my_methods[] = { {"do_stuff", (PyCFunction)Python_Embed::fnDoStuff1, METH_VARARGS, dostuff__doc__ }, {"do_stuff2", (PyCFunction)Python_Embed::fnDoStuff2, METH_VARARGS, dostuff2__doc__ }, {NULL, NULL} }; PyObject* fnDoStuff(int what, PyObject* self, PyObject* args) { switch(who called me) case do_stuff: do something break; case do_stuff2 do something different. break; } PyObject* fnDoStuff1(PyObject* self, PyObject* args) { fnDoStuff( 1, self, args ) } PyObject* fnDoStuff2(PyObject* self, PyObject* args) { fnDoStuff( 2, self, args ) } -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From hzhu at users.sourceforge.net Fri Jul 28 18:51:04 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Fri, 28 Jul 2000 22:51:04 GMT Subject: Discussion: new operators for numerical computation References: <397C9207.EC0528AA@eecis.udel.edu> Message-ID: On 26 Jul 2000 11:18:25 +0200, Konrad Hinsen wrote: > >With the ongoing rework of NumPy that turns arrays into Python classes >with an underlying C implementation, it would be possible to have an >"array" and a "matrix" class with different semantics, but sharing >most of the code and having equal performance. Conversion between the >two would also be possible at basically no cost, and C modules could >be written to accept both. The conversion between MatPy matrix and NumPy array is already quite easy, even though MatPy currently interact with the C code only through NumPy. I have an idea for the new NumPy development that I've put forward to Travis. It may take more effort up front, but it would give greater instant grtification to developers, thereby attracting more of them. It is this: Write the planned numpy2 as a wrapper class over existing numpy, just as matpy is doing right now. This wrapper class would be a working model that defines the future multiarray interface. This shouldn't be difficult because it would be largely one-liners with docstrings. Once this is done, we can substitute the underlying implementation with the new C code "under the hood", one piece at a time. The advantages are: 1. There is already something working, so any new code can be easily verified. 2. The developers would have a far better idea of what the future look like. 3. More developers could join because the tasks are in smaller chunks. 4. The design of interface is decoupled from the design of implementation. >Having two different classes with different semantics is perfectly >normal in Python. It would only be a problem if there were important >application domains that require both semantics mixed together, but I >am not aware of such domains. This is why I'd prefer retaining the current situation where NumPy and MatPy assigning oposite meaning to * as elementwise or matrix multiplication. The new operators would not cause any inconvenience to existing users. They only provide some syntactic sugar to rid NumPy of matrixmultiply(a,b) and MatPy of a.__dotmul__(b). Indeed they are needed where both operations are intermixed. I've encountered them quite often. For example, the main operation maybe linear algebra, but the matrices are assembled by elementwise operations. Huaiyu From alex at magenta.com Fri Jul 28 12:57:33 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 18:57:33 +0200 Subject: Perl is worse! References: Message-ID: <8lse9j01oti@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o397m.3ok.grey at teleute.rpglink.com... [snip] > @names = ("Bob","Bob","Bob","Robert Paulson"); > @occupation = ("Uncle","Uncle","Uncle","Mayhem"); > $index = 0; > foreach $name (@names){ > $done = 0; > $x = 0; > while (!$done){ > if ($members{$name.$x}){ > $x++ > next; > } > else{ > $members{$name.$x} = $occupation[$index]; > } > } > } > > Your argument completely ignores cases like the above, doesn't it? Where > you want to have a counter incremented (math function) but need to use it in a > string constantly. Simplistic example, yes, but a valid one. Why force the > programmer to do constant switching to do such a simple thing? You have not been very explicit about the structure of '%members', but it seems to be a hash indexed by a string, which in turn is made up of a name which is concatenated with digits to make it unique. (There also seems to be some problems with $index, which is never incremented, and $done, which is never set -- not clear what parts you have omitted). But, back to %members...: Why organize it like that, rather than just index it directly with a (name,number) pair? Presumably, because Perl cannot use a pair as an index, but wants a scalar? But that's no problem in Python, so (guessing at your snipped parts): members = {} names = ["Bob","Bob","Bob","Robert Paulson"] occupation = ["Uncle","Uncle","Uncle","Mayhem"] for name, occ in zip(names,occupation): x=0 while members.has_key((name,x)): x=x+1 members[(name,x)] = occ Making members into a dictionary _of lists_ seems another quite plausible organization, changing the loop's body to: if members.has_key(name): members[name].append(occ) else: members[name]=[occ] or (a matter of style): try: members[name].append(occ) except KeyError: members[name]=[occ] But, assuming the use of the original data organization is externally mandated, it's not too bad anyway, e.g.: x=0 while members.has_key("%s%d"%(name,x)): x=x+1 members["%s%d"%(name,x)] = occ i.e., basically the same structure as if we were (more directly) using the (name,x) pair as the index, except that, as per external mandate, we turn that pair into a single string by using "%s%d" % (name,x) wherever, in a more natural organization, we would instead use (name,x) directly. There are, of course, other ways to turn a string and a number into a single string, but the % operator has the advantage of being easily tailorable -- if whatever external agent is currently imposing the strange "%s%d" format changes its mind and imposes an even stranger "_%d_%s" or whatever, you're maximally prepared: just the formatting-string itself changes, exactly as it should be (in fact, you can take the formatting-string as an argument, &c). You appear to focus on name+str(x) as the canonical way to do what you're after, and it may be more readable than format%(name,x), though never quite as much as just the (name,x) pair itself. OK, whatever. But surely having to match an externally mandated format, if it's a frequent occurrence in your application domain, happens with all sorts of oddball formats, not just the simple "%s%d" one, no? And there are no substantial cases, that I can think of, to need this specific ability (apply the specific "%s%d" format), in enough numbers to warrant special-casing. Absent externally mandated formats, you'll be using the pair in a most direct way (or imply it by moving to a more natural data organization, such as a dictionary containing lists). > Exactly my point. I don't like it but I'm not asking for it to be > changed. I'm just a little tired, in all of what, two days, of people putting > down another language for doing something which /they/ consider wrong. I Two days? It must be _at least_ 20 years that people on Usenet are putting down other languages (and operating systems, applications, computers, etc) for what they consider wrong. Would you have us put them down for what we consider _right_?-) You're the one that claims that Perl's concept of 'scalar' &c is OK because that's the way human beings think. Well, I have news for you: human beings just love to squabble about anything and everything; we *ARE* primates, after all, and why should we be any less quarrelsome than any baboon troop...?!-) > consider it wrong in Python not because I'd like to see different, but because > I was told Python doesn't have that ambiguity when it does, that it doesn't do > conversion, when it does, that it doesn't do things "automagically" when it > does. I'm pointing out that it is just as ambiguious in its own way and that > I personally consider it wrong but, as I stated in one message, I will learn > to use that. I think most responders strove to show that there is no ambiguity, no (implicit or silent) conversion, no automagic, where you are deeply convinced that there is each of these. Your being convinced or otherwise, of course, makes no difference to anything except yourself, and, in fact, it *IS* true that very specific cases have been identified where some conversion can happen AND lose significant information (I was the one pointing out the long interger -> float case). That Python has this specific wart does not mean that a language that has analogous and worse ones in a thousand places is just the same, of course:-). Alex From stephen at cerebralmaelstrom.com Wed Jul 5 13:46:35 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 17:46:35 GMT Subject: "Write to a file" question please? References: Message-ID: <%vK85.115476$WS3.978721@typhoon.we.rr.com> Oops. Replace my %s's with %d's. --S Stephen Hansen wrote in message news:XuK85.115473$WS3.978541 at typhoon.we.rr.com... > I *think*... > Print is a statement that lets you print out multiple things using the > comma, the 'write' function does not work the same way. It takes a string > argument and writes it out to the file. > > To accomplish what you want, you can use the module operator (there's other > ways too, but its my favorite :)) > > number = 100 > print "Number = %s" % number > OUT = open("TT.txt",'w') > OUT.write("Number = %s" % number) > OUT.close() > > If you have more then one number you're writing out, make the right-operand > of the modulo operator a tuple.. E.g. > > num1 = 100 > num2 = 500 > print "Number 1 = %s and Number 2 = %s" % (num1,num2) > > See? :) > > --Stephen > > > > wrote in message > news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > > number = 100 > > print "Number =", number > > OUT = open("TT.txt","w") > > OUT.write("Number =", number) # Error > > OUT.close() > > > > The code above gives the error. > > > > Traceback (innermost last): > > File "ttest.py", line 5, in ? > > OUT.write("Number =", number) > > TypeError: read-only buffer, tuple > > > > OUT.write("Hello World") > > > > Works but a number or variable of a number does not. > > > > I have been reading documents on Python to no avail this time. > > I am using Win98 with the latest python for this OS. > > > > Any help would be much appreciated > > E-mail me at cmfinlaySPAM at magnet.com.au > > or reply here. > > From fermigier at localhost.localdomain Fri Jul 7 06:30:56 2000 From: fermigier at localhost.localdomain (fermigier) Date: 7 Jul 2000 12:30:56 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <8k2ieg$5mg$1@localhost.localdomain> Message-ID: <8k4bh0$f20$1@localhost.localdomain> In article , Jeremy Hylton wrote: >fermigier at localhost.localdomain (fermigier) writes: > >> I've just read this announcement in Linux Weekly News today: >> >> ``The Poop on persistence (PerlNews). Perl News talks about two new >> mailing lists for Perl Object Oriented Persistence (Poop). This is an >> effort to encourage communication between module authors and to address >> redundant object persistence issues. Also read about the latest Perl >> modules.'' (Ref: http://news.perl.org/). >> >> Is there an opportunity to start such a discussion, or at least to gather >> the solutions that have been developped for Python (and compare them to >> their Perl/Java counterparts) ? > >The two Python solutions that come to mind are the pickle and cPickle >modules, which just allow you to save and restore Python objects, and >ZODB, a full-fledged object database from Digital Creations: > >http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html >http://www.python.org/workshops/2000-01/proceedings/papers/fulton/fulton-zodb3.pdf > >If you are willing to compare these with Perl or Java approaches, I'd >be interested to hear what you think. Perl: ----- I'm really not much of a perl-head, so I don't have a clue about what's going on in the perl community. The only project I know so far is Tangram: http://tangram-persistence.org/ http://www.webtechniques.com/archives/2000/03/jepson/ Java: ----- I'm thinking about Jora, the Java Object Relational Adapter (http://www.ispras.ru/~knizhnik/) and Castor (http://castor.exolab.org/). Castor is a very nice and complete product, it seems from the feature list: * Castor XML: Java object to XML document * Castor JDO: Java object persistence to RDBMS * Castor DAX: Java object persistence to LDAP * Castor DSML: LDAP directory exchange through XML * XML-based mapping file specify the mapping between one model and another * Support for schema-less Java to XML binding * In memory caching and write-at-commit reduces JDBC operations * Two phase commit transactions, object rollback and deadlock detection * OQL query mapping to SQL queries * EJB container managed persistence provider for OpenEJB These are the two free software projects I know of, I guess there are hundreds of commercial projects as well. Python: ------- - The Zike project (zike.sourceforge.org) has the ZDC: ``The Zike Data Classes provide high-level objects for dealing with records in relational databases. Built on top of the Python DB-API 2.0.'' - There was Joel Shprentz's ``Persistent Storage of Python Objects in Relational Databases'': http://www.python.org/workshops/1997-10/proceedings/shprentz.html http://starship.python.net/crew/shprentz/1997.html I have seen other products/projects but i can't remember them at the present. S. -- St?fane Fermigier, From paul at prescod.net Thu Jul 20 17:25:37 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 16:25:37 -0500 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> <8l7f69$bon$1@fermi.tro.net> Message-ID: <39776E51.1303E675@prescod.net> Rainer Deyke wrote: > > > "CheckTarget--Steer-IfCloserThanX-Detonate". The script knows > > how toget closer to what it wants - but does so not my reall playing god > and > > moving the missile, but just setting off a command "Steer" that tells the > > physics engine "ThrustvectorAngleChange (angles)"... This is unlike the > > scripts in the Quake engines that allow to do unrealistic things - in my > > project, each script can only do what is physically possible - otherwise, > > the missile will crash or the tank will tip over in a curve. > > This type of thing is possible in Python. To prevent the script from doing > something naughty, override __builtins__. I'm not sure what you're talking about there. How can Python code override the physics in code written in C? __builtins__ doesn't help! -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From bjorn at roguewave.com.bbs Sun Jul 16 13:40:02 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 16 Jul 2000 17:40:02 GMT Subject: Does Python code >.require<< a run-time environment?? (New toPyth Message-ID: <3bQUT2$mHs@openbazaar.net> Paul Prescod wrote: > Gordon McMillan wrote: > > > > ... > > > For Python, you want to look > > >at > > > > > >http://starship.python.net/crew/gmcm/distribute.html > > > > > >For Java, at "jexegen.exe". > > > > Sorry, Paul, the latter does not bundle in the interpreter. It just > > packages up byte code and uses a small exe to start your MS JVM. > > True, I forgot that because the MS JVM tends to be installed. I think I > may have exaggerated the features of the former too. Is there any easy > way to make a single executable for Python, the standard library, > required .pyd's and your code? My vague impression is that you could if > you had a compiler and the source for your pyd's, or else you could fall > back on an installer (rather than a single big runnable app). Nah, I distribute my xml scripts as windows .exe files all the time (including the expat dll). It's actually quite trivial since the builder only wraps everything into a zip archive and appends it to the special Python executable. -- bjorn From etiennel at geospace.co.za.bbs Mon Jul 17 04:20:02 2000 From: etiennel at geospace.co.za.bbs (etiennel at geospace.co.za.bbs) Date: 17 Jul 2000 08:20:02 GMT Subject: Memory leak problems with python and COM Message-ID: <3bR5P1$kjp@openbazaar.net> Hi there To my embarrasment I found that I am still using Python build 129 and that I (somehow) missed the release of build 131! Anyway, build 131 solved the problem! Thanks for your help. Regards Etienne "Mark Hammond" wrote in message news:8klbu9$38u$1 at nnrp1.deja.com... > In article <963474833.835936 at proxy.lia.net>, > "Etienne Labuschagne" wrote: > > Deleted a and b on the python side and then destroying the COM > server - that > > doesn't clear up the memory. I am using SafeArrayAccessData and > > SafeArrayUnlock on the server side to make sure that it releases the > data on > > the server side. > > > > Is there something else that I must do? > > I suggest you get the latest CVS version (I realize this may be a > PITA :-( Since build 132, a number of leaks have been fixed. There is > a very good chance that this particular leak was plugged previously. > > If not, I will definately look into this and plug it! > > Mark. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From robin at jessikat.fsnet.co.uk Thu Jul 20 12:06:03 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 17:06:03 +0100 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39771CA8.A1BF8D6E@fft.be> Message-ID: In article <39771CA8.A1BF8D6E at fft.be>, Gregory Lielens writes >Robin Becker wrote: ... well outer products are just a special kind of multiplication as far as I know. We have three common multiplies for matrices and I claim that n vectors are n by 1 matrices. I agree that for higher order tensors the outer product is more complicated, but see http://mathworld.wolfram.com/TensorDirectProduct.html the kronecker product is also called the matrix direct product A ox B = [a11 B a12 B] [a12 B a22 B] seems to me to be like a tensor outer product; but I ain't no mathematician ;) the lie product (or bracket) has applications in sensitivity analysis and other more exotic stuff in differential geometry [A,B] = AB - BA -- Robin Becker From rwallace at esatclear.ie Mon Jul 31 23:25:57 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Tue, 01 Aug 2000 04:25:57 +0100 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> <397F382E.196DE01@sage.att.com> Message-ID: <39864345.C94@esatclear.ie> Garry Hodgson wrote: > either of these is poor code. how about having the names reflect usage, > which is arguably more relevant than type? > > def ComputeSalary( employeeID, salary, employee ) > > (my salary is very complex :-) What, you get paid imaginary money? :) -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From cbbrowne at news.hex.net Mon Jul 17 21:29:16 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Tue, 18 Jul 2000 01:29:16 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> Message-ID: Centuries ago, Nostradamus foresaw a time when Paul Prescod would say: >Huaiyu Zhu wrote: >> ... >> As to the claim that additional operators for linear algebra is >> somehow comparable to the special syntaxes/quirks of various >> programming languages, no real argument has been presented so far. > >Okay, then, let me try. > >> It's more like: If I don't care >> and don't use such things, they must belong to a special domain and be >> somehow comparable to some other things that I do know and dislike. > >Let me rephrase: "If MOST Python programmers don't care and don't use >such things, they must belong to a special domain." I think that's a >good operative definition of "domain specific". That's the crux of the >argument. Don't throw complex numbers back in my face because they >required *minimal new syntax*. There is already more "extra" syntax in >the language for matrices than for complex numbers. > >I don't know why you have the impression that matrix operators have >been compared to anything that people dislike. Most people have compared >them to things that they *do* like, but must do through function syntax >because Python doesn't pander to my particular needs or your particular >needs, but rather those of most average programmers. I like XML >processing and I daresay there are more books sold on it than on >Matlab. But I've never asked for special, XML-specific syntax. > >Maybe you should consider how to scale back your syntactic request. >Perhaps a single keyword or symbol at the beginning of an expression >could make it element-wise or matrix-wise. Another approach would be to create some form of "macro rewriting" system that would allow you to feed in expressions in some _descriptive_ form that would then rewrite this into (possibly optimized) Python that would execute this. By far the best comparison I can think of is the Common Lisp "Series" implementation, findable at . CL Series provides a "language" in which you can represent sequential descriptions; it is described thus: "A series is a data structure much like a sequence, with similar kinds of operations. The difference is that in many situations, operations on series may be composed functionally and yet execute iteratively, without the need to construct intermediate series values explicitly. In this manner, series provide both the clarity of a functional programming style and the efficiency of an iterative programming style." CL uses macro expansion to expand these into CL expressions, and this expansion includes significant optimizations based on pipelining the generation of series elements. You might compose several series together, and the final result will be computed in an optimized (perhaps optimal) manner. The result is that you write your original code using a _descriptive_ series representation, and the system rewrites that into code that _performs_ the series operations. I would think the extension to what would be done in Python to be "obvious;" the "Matrix Math" package would accept input in a modified Python syntax that supports its matrix operators, and then rewrites this to generate Python code that either: a) Expresses it iteratively, in Python form, or b) Expresses it using some compiled extensions that can make it Real Fast. -- cbbrowne at hex.net - Necessity is the mother of invention. Insanity is the mother of straitjackets. From hopper at omnifarious.mn.org Tue Jul 18 11:29:31 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Tue, 18 Jul 2000 09:29:31 -0600 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> Message-ID: In article <397296BC.415C97E1 at prescod.net>, Paul Prescod wrote: > Matthew Cline wrote: >> >> def my_func(foo, bar, quux): >> if not isinstance(quux, Quux): >> raise RuntimeError("param 'quux' must be of class 'Quux'") > > Let me also point out that in many cases, this style of programming > would be frowned upon by serious Python programmers. For instance, if > you check that something is a string, your code will complain when it is > handed a Unicode string, even though it would probably work fine. If you > check that it is an open file, then your code probably will complain > about stringIO file-like objects, even though it would probably work > fine. If you check that it is an integer, your code will complain about > integers, even though ti would probably work fine. > > In general, the Python philosophy is to "just try it" and see if it > works. Sometimes type checks are appropriate but if you do it on the > entry to every function, you are probably doing too much work and making > your own life (or someone else's) harder later on. Oh, yes. Inheritance by mysteriously coiniciding method names. How fun. Actually, I'm going to write a type checking function that throws a coherent exception when the type of the argument fails to be a particular type. I'll probably put in some specialized checks for the built in types so it'll accept things that are objects of those types, or derived from the User version. It'd be nice if Python had lisp-like macros, but they aren't necessary. My problem is this: Just accepting any old type, and letting it error out when it tries to access a non-existent attribute is very confusing for people trying to use your code. Heck, maybe you store away their object, and then call the offending method at some random later point. I bet it'd be a heck of a lot of fun to try to trace down why the exception happened then. Type checking and the scoping rules are the only two problems I have with Python so far. Other than that, it's a wondefrul language. -- Eric Hopper (hopper at omnifarious.mn.org, http://www.omnifarious.org/~hopper) From scarblac-spamtrap at pino.selwerd.nl Thu Jul 20 02:44:34 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 20 Jul 2000 06:44:34 GMT Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3975EF36.1651C9CB@roguewave.com> <8l52re$tbe$1@nntp9.atl.mindspring.net> <39763FF4.2CA5BF75@schneider-kamp.de> <8l59pa$6ff$1@slb1.atl.mindspring.net> Message-ID: Aahz Maruch wrote in comp.lang.python: > I think I was insufficiently clear: in addition to "zip" having a known > meaning, it does not have any connotation in computer terms of combining > data that I've ever seen. Yeah, if you want to call it "zipper", I > might almost see your point. The function zip as proposed (combine two lists into a list of pairs) is straight from Haskell (and other functional languages) just like map and filter. I think zip is the obvious name. -- Remco Gerlich, scarblac at pino.selwerd.nl -rwxr-xr-x 1 root 5.89824e37 Oct 22 1990 /usr/bin/emacs [STR] From fiona at sitegnome.com Thu Jul 6 07:54:59 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 6 Jul 2000 11:54:59 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 6th, 2000 Message-ID: <20000706115459.24950.qmail@synop.com> Hi Guys! Below are the latest entries to be entered into http://python.faqts.com For those of you that missed my announcement earlier today: "Many thanks to Hans Nowak for providing FAQTs with his collection of snippets for entry into http://python.faqts.com. They can be found directly at http://www.faqts.com/knowledge-base/index.phtml/fid/538/lang/en The knowledge base now contains greater than 653 questions with answers!!" Cheers, Fiona Czuczman Todays new entries include: How do I convert a string to hex? How can I convert a hex number to a string? Is it possible (on Win) to send commands to a DDE server (in my case it is ACDSee.exe) from python? How can I control input and output to the screen other than the print command? ## Unanswered Questions ######################################## ------------------------------------------------------------- Why is some strange charachters appearing instead of norwegian charachters in GUI of pythonwin build 132 http://www.faqts.com/knowledge-base/view.phtml/aid/4590 ------------------------------------------------------------- Nils Otto Johansen ## New Entries ################################################# ------------------------------------------------------------- How do I convert a string to hex? http://www.faqts.com/knowledge-base/view.phtml/aid/4591 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain import string b = "6b584" i=string.atoi(b,16) print hex(i) 0x6b584 ------------------------------------------------------------- How can I convert a hex number to a string? http://www.faqts.com/knowledge-base/view.phtml/aid/4592 ------------------------------------------------------------- Fiona Czuczman Remco Gerlich x = 0x26100 y = "0x%x" % x # String formatting "%x" formatter makes hex numbers y is now "0x26100". ------------------------------------------------------------- Is it possible (on Win) to send commands to a DDE server (in my case it is ACDSee.exe) from python? http://www.faqts.com/knowledge-base/view.phtml/aid/4593 ------------------------------------------------------------- Fiona Czuczman Jean-Francois Richard Download pythonwin and look into the win32/demos/dde directory. There is a sample of a dde client and server. ------------------------------------------------------------- How can I control input and output to the screen other than the print command? http://www.faqts.com/knowledge-base/view.phtml/aid/4594 ------------------------------------------------------------- Fiona Czuczman Grant Edwards There are two modules that provide that sort of thing: curses (uses curses) snack (uses newt/slang) I think you can find the curses module in the usual places (www.python.org). The docs for snack/newt are pretty skimpy. It comes with RH, and there are some example programs in the newt distribution. I don't know if it's current, but you can get version 0.50 it from my ftp site: ftp://ftp.visi.com/users/grante/stuff/newt-0.50.tar.gz From david_ullrich at my-deja.com Tue Jul 18 11:04:07 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Tue, 18 Jul 2000 15:04:07 GMT Subject: newbie unimpressed... References: <3bRWfQ$lHg@openbazaar.net> Message-ID: <8l1rkp$q28$1@nnrp1.deja.com> In article <3bRWfQ$lHg at openbazaar.net>, theebh at yahoo.com.bbs@openbazaar.net (Jonathan) wrote: > In article <8kvp81$9q1$1 at nnrp1.deja.com>, > sharkey3 at my-deja.com wrote: > > I have much experience in tcl and perl, and I have finally found a > good > > project to learn python with. Unfortunately, I am very frustrated so > > far with the language. Although maybe it's just with the > documentation. > > > > I'm serious. The documentation really sucks. > > Example: where is the % operator documented for strings? > > > > I'm a newbie myself and i happen to come across those formatting > operators while reading the "Learning Python" book. Grab a copy of it; > though it's not a reference book, at least it gives you an overall idea. Or a person could just look at the docs. In the index you see "Builtin Types" towards the top. You don't see "string" there at first - then you notice a subheading "More String Operations" under "Sequence Types". You go to More String Operations and the first thing you see is a description of how "%" works for strings. > regards, > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From grey at despair.rpglink.com Fri Jul 28 14:07:33 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 18:07:33 GMT Subject: Perl is worse! References: <3981C210.8F0D0908@sage.att.com> Message-ID: On Fri, 28 Jul 2000 17:25:36 GMT, Garry Hodgson wrote: >you can see that because you are smarter than my computer. And so can the designers of the language and they can code the steps to get there, just as they have coded the steps for everything else. >the system can't know which i intended, so it makes be specify. >it is much easier to say, "yes, i meant that" by adding a cast, >than to debug an errant program, possibly years later. I find the reverse true, esp. when one understands the rules under which conversion might take place. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From borlak at home.com Wed Jul 26 11:55:00 2000 From: borlak at home.com (Michael Morrison) Date: Wed, 26 Jul 2000 15:55:00 GMT Subject: File saving on unix::permissions Message-ID: Okay, I've tried just about everything I can think of and have come up with no solutions. The problem is, I have this account on a unix shell named "python". When I open/create a file with a python script, it saves under the user "nobody" and has no write permission, so when I try to modify/save the same file with the same script under the same account later, it just erases all the information in the file or does other wierd stuff. Is there some procedure to make your script detect, or write under the user/account that is calling it? Thanks... From amk at mira.erols.com Sat Jul 15 16:28:45 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 15 Jul 2000 20:28:45 GMT Subject: Anyone going to OLS? Message-ID: While lots of people will be at the O'Reilly conference next week, I'm being contrarian and going to the Ottawa Linux Symposium instead. Any other Pythoneers going to be there? --amk From m.faassen at vet.uu.nl Sun Jul 30 17:25:10 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jul 2000 21:25:10 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> Message-ID: <8m26fm$ila$4@newshost.accu.uu.nl> Steve Lamb wrote: [snip] > Personally, if my email client died because of some uncaught exception > versus me being able to close out my message beacuse of some bug in a display > routine, I'd rather be able to close out and save my 20k message than have to > retype it. There is more to programs than databases. Then have your program catch your exceptions! That's one of the main reasons for the existence of the exception handling mechanism; to recover gracefully from the unexpected. It is possible to catch *all* exceptions, if you're worried about that. Or whole groups of exceptions, if you like. They're in a hierarchy. And face it, bugs can cause data-loss in any programming language; Perl, Python, or whatever. Some languages just have nicer mechanisms to recover from bugs than others. [snip] > No, I made sure there was a number in there, Python is the one that > decided to drop a None in. No, there wasn't a number there, as otherwise Python wouldn't have dropped in None. The only alternative is that your regular expression is buggy. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aahz at netcom.com Fri Jul 14 23:08:47 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 Jul 2000 03:08:47 GMT Subject: using threading module References: <396fd2ff.3598724@news.prodigy.net> Message-ID: <8kokjv$tjf$1@slb7.atl.mindspring.net> In article <396fd2ff.3598724 at news.prodigy.net>, Victor Muslin wrote: > >I tried using the threading module with the following simple program: > > #!/usr/bin/python > > from threading import * > > reps = 10 > > def f1(msg='xxx'): > for i in range(0, reps): > print 'f1', msg, i > > t1 = Thread(target=f1,args=('bar')) > t1.start() Try t1 = Thread(target=f1,args=('bar',)) Note the extra comma. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From petersc at stud.ntnu.no Tue Jul 4 17:57:39 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Tue, 04 Jul 2000 21:57:39 +0000 Subject: (s)re module code break Message-ID: <39625DD3.ED9BF9D7@stud.ntnu.no> I just noticed an issue with the new re module. Maybe it is old stuff, I don't know. Just to be sure: using re.compile yields a SRE_Pattern object (as of 2.0b1) whose method demands 3 arguments. There is a lot of code which lives happily just supplying 2 arguments and having count default to 0 (until 1.6a2). I added a 0 as third parameter and my program once again ran happily. Does anyone know if this behaviour of sre will persist? worried-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From jepler.lnk at lnk.ispi.net Wed Jul 12 08:34:23 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Wed, 12 Jul 2000 12:34:23 GMT Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> <8kdref$j4t$1@nnrp1.deja.com> <396AAE98.F851708B@alcyone.com> Message-ID: On Mon, 10 Jul 2000 22:20:24 -0700, Erik Max Francis wrote: >It actually is necessary for my purposes, since the strings that is used >for dispatching will not be a status code (a three digit number as a >string), not actually the name of the method to be invoked. (I simply >showed it that way for the purposes of the sample code; certainly in the >example I showed you are correct.) > >Thanks, though. You can use a method like finding a method named '"code_%03d" % status': class C: def dispatch(self, status, *args): g = getattr(self, "code_%03d" % status, None) if g: apply(g,args) def code_000(self, arg1, arg2): print "the args were", arg1, arg2 c=C() c.dispatch(0, "hi mom", 36) # -> "the args were hi mom 36" From gbreed at cix.compulink.co.uk Fri Jul 14 06:39:22 2000 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 14 Jul 2000 10:39:22 GMT Subject: ASP Questions References: Message-ID: <8kmqkq$40b$1@plutonium.compulink.co.uk> In article , (Sam) wrote: > Session("key") = value is a VBScript specific thing. Its bypassing > the default method of Session which in this case is probably Item. > I'm not sure off hand. Waldemar sorted this out -- thanks Waldemar. > >Response.Redirect doesn't terminate execution of the script. I'm > getting >round this by throwing an exception, but is there a command > that can do >the same job more cleanly? > > Have you tried a return statement? I'm guessing here but the asp page > is probably being executed in some kind of invisible function. No, doesn't work. > >I ran a script with an infinite loop once. How should I have > terminated >it (other than by proof reading my code better)? > > Not sure. The same has happened to us in vbscript and we ended up > shutting down the server. He forgot the recordset.movenext while in a > loop processing a recordset. Typically if you can get to the box fast > enough before the ram is swallowed up you can shutdown iis. Otherwise > I think it was the power button because the box was totally > unresponsive. There may be a page execution timeout that can be > specified in iis. I don't remember off hand. It was MoveNext for you as well! > #Here is the line you are probably missing. > cmd.CommandType = constants.adCmdStoredProc No, I'm setting it to 4 which should be equivalent. > #Now I append the parameters... > for parm in params: > cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], > constants.adParamInput, parm[2], parm[3])) Ah, but try params = list(params) params.reverse() before that. I don't see why it should make a difference, but it does. > The reason that ado is ignoring your parameters is that the default > command type is adCmdText. I guess when it is text it doesn't bother > to look for any parameters associated with the command object. Though > it might if your sql looked like "select * from whatever where id = ?" > IIRC ? is used in the data environment designer in VB to denote a > parameter in an sql call. It isn't ignoring the parameters, it's ignoring their names. It would be nice to supply the parameters in an arbitrary order. Seeing as the names have to be supplied, you would think they were being used for something. Graham From python-list at teleo.net Thu Jul 20 15:48:17 2000 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 20 Jul 2000 12:48:17 -0700 Subject: zip() : how about braid() In-Reply-To: <397746c9.39446991@news.iol.ie> References: <397746c9.39446991@news.iol.ie> Message-ID: <00072012535104.03994@quadra.teleo.net> [Sean Mc Grath, on Thu, 20 Jul 2000] :: Two suggestions: :: 1) raff :: 2) twingle :: :: "raff" is an invented verb form of "raffia", fibers of which are used :: to weave hats, baskets etc. (Spot the Monty Python :: connection?) :: :: "twingle" just sounds beautiful... Heh. Trust an Irishman to have a way with words. ;-) I agree that inventing a new word to name this specific notion is preferable to inviting namespace collision (as with 'zip'). I like both "raff" and "twingle." (Twingle is perhaps a combination form -- twist and mingle?) From db3l at fitlinxx.com Wed Jul 19 21:51:41 2000 From: db3l at fitlinxx.com (David Bolen) Date: 19 Jul 2000 21:51:41 -0400 Subject: Making Windows GUI programs References: <8F776CE84nickperkinsusanet@203.2.75.243> Message-ID: nick_p at dingoblue.net.au (Nicko) writes: > Hi. I was wondering if anyone could point me in the direction of some GUI > help for windows. I would like to write a program using the windows API > set, but the help file that came in the win32all package doesn't make any > sence to me. If someone can point me in the direction of maybe a tutorial > or a nice document that can help, I would be greatful As another responder pointed out there are other alternatives to GUIs under Windows, including tk as included with Python or (my personal favorite) wxPython (http://www.wxpython.org). So if you're just trying to do something graphical and have only selected the native API since it was included in win32all, you might peek at the other alternatives first. You can mix other GUI approaches with base Win32 API calls without problems so you can still use the other modules from win32all for other Windows-specific services. But if you specifically want to use the Windows API (and note you still have the question of basic GUI API versus a framework like MFC), the win32all extensions just wrap the existing API, so any documentation for the API in the context of Windows itself should be fine and usable (not to mention the plethora of books). Doing some web searches should probably yield a ton of introductions and what not, but worst case you can always use Microsoft's own MSDN library documentation at: http://www.msdn.microsoft.com/library/default.asp The library has all sorts of documents, partial books and reference material about all facets of the API (basic API documentation is beneath the "Platform SDK" - MFC is part of the Visual C++ documentation). -- -- 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 urner at alumni.princeton.edu Sat Jul 29 00:53:05 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 28 Jul 2000 21:53:05 -0700 Subject: Newbie DATA STRUCTURES Question. References: <398248BC.32DE3CC@nycap.rr.com> Message-ID: gbp wrote: > >Hi all, > >I have experience with Perl but non with Python. > >I need to write a script to read a large text file into a structured >format. Not sure if this is what you mean, but suppose you create a text file .\ocn\data.txt: this is record A this is record B this is record C then you can read it into a list like so: >>> myfile = open(r".\ocn\data.txt", 'r') # see note >>> listrecs = myfile.readlines() >>> listrecs ['this is record A\012', 'this is record B\012', 'this is record C\012'] >>> myfile.close() \012 must be unicode for newline. >>> unicode('\n') u'\012' Yep. Once you have 'listrecs' with all your records, you can do stuff like: for rec in listrecs: dostuff(rec) or map(dostuff,listrecs) i.e. you're stepping through the records one record at a time. Kirby Note: in >>> myfile = open(r".\ocn\data.txt", 'r') the leading r, in front of the first quoted string, just means you don't have to escape the backslashes. You could also go: >>> myfile = open(".\\ocn\\data.txt", 'r') From donn at u.washington.edu Thu Jul 27 15:39:32 2000 From: donn at u.washington.edu (Donn Cave) Date: 27 Jul 2000 19:39:32 GMT Subject: Local user modules? References: Message-ID: <8lq35k$41ri$1@nntp6.u.washington.edu> Quoth Steve Juranich : | Without further ado, here's my question: Is it possible for a user to write | a module in C/C++ and make that available to the Python interpreter | *without* needing to edit systemfiles like | ${PYTHON_HOME}/Modules/Setup.local? Yes. | Is is possible for me to add NumPy to my Python path without actually | sticking it in the main Python system path? I assume so. | So far, this has been my biggest frustration with Python. If there is | somewhere where I could RTFM, please let me know. I would be more than | happy to do this, but I must know how to get around this problem. To generalize, I would divide this into three steps. 1. Compile dynamically loadable, or "shared", modules. 2. Pick your place for them. 3. Arrange to set sys.path accordingly. (1) is most of the work. It sounds like you may have that under control, though. The end result to make "import spud" work would a file named "spudmodule.so", with one external entry point "void initspud()". Python can take it from there. (2) would be a non-issue, except that you may very well have only NFS mounted disk space at your disposal. Most platforms can handle loading from NFS, but there are some weird issues that come up with dynamically loaded modules. If in the end you must use NFS, test the modules first out of /tmp or something, and then when you have moved to NFS, look out for the possibility that you are running an older version of the module you just rebuilt. (3) you already know how to do. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From frr at mindless.com Fri Jul 21 09:39:52 2000 From: frr at mindless.com (Fernando Rodríguez) Date: Fri, 21 Jul 2000 13:39:52 GMT Subject: MySQL on Win9X References: Message-ID: "Scott" escribi? en el mensaje news:slrn8ngf36.f1p.kain at cableadmin.com... > Hello, > > Are there any pre-compiled MySQL modules for windows? I've found the > sources but don't have nor can I install a compiler on this machine. I'm looking for the same thing, so please let me know if you ever find one. :-) From db3l at fitlinxx.com Tue Jul 18 17:51:56 2000 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jul 2000 17:51:56 -0400 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > This is a first experiment in whether I can make a useful, > interesting, somewhat coherent summary of python-dev activity. > If reaction is favorable, and time permits, it may become a biweekly > posting. This seems quite useful - is there any "proper" way to send feedback on mail on python-dev without actually being on the list? In particular: > * /F was his usual "patching machine" self, integrating PythonWin's > win32popen function so that os.popen will now work correctly on > Windows as well as Unix, (...) Does anyone know if this mean that the existing 1.5.2 behavior of os.popen under NT (with a console) breaks with respect to the result code of the process being returned on the close() operation? I know that NT with a console was really the only case where the native popen() functioned properly, but it did function just fine, and I have a lot of code that depends on child process exit codes, so I'm sure that someone else out there probably does as well. I think I saw a discussion of an earlier patch by Fredrik that just took care of the stdin/stdout/stderr file handles for the NT problem without a console, but grabbing the latest CVS copy seems to have pulled in all the stuff from the PythonWin extensions. They're much better on most Windows platforms, but losing the exit code of the child process makes the popen() family much less useful in many cases and I think it's an important aspect to preserve whereever possible. My code peek was only a quick glance, so if this issue has been handled in the integration of the code into the Python core, then that's great. Thanks. -- -- 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 17 14:01:36 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 17 Jul 2000 18:01:36 GMT Subject: Can't load .pyd files from embedded Python interp References: <39722B90.A41E02B5@tds.net> <8F73D685Egmcmhypernetcom@199.171.54.194> <3973384F.D6964D88@tds.net> Message-ID: <8F748426Egmcmhypernetcom@199.171.54.155> Edward K. Ream wrote: >Gordon McMillan wrote: > >> Most people just use python15.dll from their embedding app so both get >> the same copy. [snip] >Gordon, thanks so much for this reply. This was precisely what I >needed. > [snip] >This illustrates one of the most common failings in documentation: >failing to tell _what_ the reader is to do and _why_. Much >documentation just jumps in and explains _how_ to do something. I just >reviewed the Python Extending and Embedding docs. There is no mention >that one must link against python15.dll, and certainly no hint about >why that is necessary. One or two sentences in the docs might have >saved me about a week of enjoyable, but useless, work. Well, this is a requirement that's unique to Windows. Unixen (those that allow dynamic linking) do (essentially) a full link at runtime, so there's no problem getting symbols from the executable. There's also no concept of an "import lib". And Windows doesn't spell "import lib" differently than "static lib", so it's easy to mistake "python15.lib" for a reference to a static lib, when in fact it means the import lib for python15.dll. It's difficult to know where to document all the platform specific aspects of embedding / extending (especially when it's kind of a moving target). I would guess that most people started by building Python from source, and then playing with the examples. >I'll write up my experiences when I've successfully embedded Python in >my app. For now the conclusion seems to be that one only need link in >C:\Windows\System\python15.dll to the app. There are some details >specific to Borland, but presumably they won't be difficult. I hope you're right about that. - Gordon From dgoodger at bigfoot.com Sun Jul 23 00:48:50 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 23 Jul 2000 00:48:50 -0400 Subject: Looping on more than one list In-Reply-To: <3979C6F4.B1FF1800@atlsci.com> References: <3979C6F4.B1FF1800@atlsci.com> Message-ID: on 2000-07-22 12:08, ahmed Bouferguene (aboufer at atlsci.com) wrote: > Do no know much of python, but I am wondering whether it is possible > to loop > on more than one list A more elegant solution is currently in the works, but for now, you can use: >>> map(None,"abcd",[1,2,3]) [('a', 1), ('b', 2), ('c', 3), ('d', None)] "abcd" is a sequence of 4 items, of course. The above doesn't stop on exhaustion of the shortest list though. If it must, you can use: >>> a = [1,2,34] >>> b=["a", "b", "d"] >>> for (x,y) in map(None,a,b): ... print x,y ... 1 a 2 b 34 d >>> c=[1,2,3,4] >>> for (x,y) in map(None,b,c): ... if None in (x,y): break # required for uneven sequences, # NOT containing None! ... print x,y ... a 1 b 2 d 3 -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From NoSpam at NoSpam.com Wed Jul 12 10:23:54 2000 From: NoSpam at NoSpam.com (Tom) Date: Wed, 12 Jul 2000 14:23:54 GMT Subject: Looking for a tree widget with control of text color References: Message-ID: <_b%a5.155712$7o1.3884807@news2.rdc1.on.home.com> This surprises me. It is my understanding that wxPython is a 'native' gui, so, on Windows, its tree control would be implemented using the windows tree view common control, which is dynamic but doesn't support differing text colors for different nodes. Am I misunderstanding wxPython? Or does wxPython extend the standard tree control in some way? Thanks, Tom. "Robin Dunn" wrote in message news:opPa5.8337$%wF2.239927718 at news.randori.com... > > > > Is there a tree widget for wxPython or TKinter that support setting the > text > > color (foreground or background) for each node? > > > > The wxTreeCtrl in wxPython can do it. > > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com > http://wxpython.org Java give you jitters? > http://wxpros.com Relax with wxPython! > > > From Richard.Jones at fulcrum.com.au Thu Jul 27 21:37:46 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 28 Jul 2000 11:37:46 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from Anthony Baxter of 2000-Jul-28 11:17:31, <200007280117.LAA23637@mbuna.arbhome.com.au> Message-ID: <200007280137.LAA30715@envy.fulcrum.com.au> [Anthony Baxter] > > >>> Steve Lamb wrote > > Range returns an error because of a bad type being stuffed into it. Pe > rl > > at least sees that it is a number and makes the conversion itself. I had t > o > > get around it by changing the foo assignment line to: > > foo = int(match.group(3)) > > Euw! No, the "oh, I know what you want that to be, I'll change it > for you" is my #1 all-time perl hate. I want a > "use really_strict_and_leave_my_types_alone" option before I ever > consider looking at perl for anything ever again. Particularly when > combined with magic linenoise - use the wrong bit of linenoise, and > suddenly your large complex datastructure is an int. Yaaay. Hey, don't worry about mis-using the linenoise - you just have to _look_ at the damn structure in Perl the wrong way and suddenly it's something else. Automagical conversion of data based on context and automagical creation of undef variables (yes, even when "use strict") are two of several reasons why you just don't use Perl for complex data applications. Richard From bjorn at roguewave.com Thu Jul 20 13:00:54 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 20 Jul 2000 11:00:54 -0600 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <39773046.D57C311D@roguewave.com> Bernhard Herzog wrote: > > Agreed, but the confusion comes from allowing floating point literals to > end or start with the decimal point (2.+.5 is valid python). Hey, someone allready implemented .+ on my machine f:\pork>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> 5.+3 8.0 >>> -b From quango at watervalley.net Mon Jul 24 17:20:28 2000 From: quango at watervalley.net (Chris Lawrence) Date: Mon, 24 Jul 2000 21:20:28 GMT Subject: kjbuckets References: <8kflcs$8qv$1@einstein.ebicom.net> Message-ID: On Tue, 11 Jul 2000 12:26:52 -0600, gene at ozob.net wrote: >I am trying to install a program call routeplanner which requires >kjbuckets which appears to be an extension of python. Kjbuckets docs say >to read the python extension manual to learn how to compile kjbuckets into >pythons. However I can seem to locate this document. > >I would appreciate if someone would give me a clue. Incidentally, versions 0.3 and later of routeplanner don't need kjbuckets; it makes the program faster, but it's non-essential. Chris -- ============================================================================= | Chris Lawrence | Get rid of Roger Wicker this year! | | | http://www.lordsutch.com/ms-one/ | | | | | Grad Student, Pol. Sci. | Visit the Lurker's Guide to Babylon 5: | | University of Mississippi | <*> http://www.midwinter.com/lurk/ <*> | ============================================================================= From kuchler at ajubasolutions.com Mon Jul 24 19:03:09 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Mon, 24 Jul 2000 16:03:09 -0700 Subject: tkinter: grid: expand and fill References: <8lhrbd$t4v$1@nnrp1.deja.com> <8lhs6l$tpt$1@nnrp1.deja.com> <8lhurd$3d$1@nnrp1.deja.com> Message-ID: <397CCB2D.DFD84326@ajubasolutions.com> Keith Murphy wrote: > > here's my example that still doesn't work: > > class scrolledtext: > def __init__(self, master, scrollflags=(NO,NO)): > stxt = self.stxt = Frame(master) > txt = Text(stxt, height=5) > txt.grid(row=0, column=0, sticky=NSEW) > > if scrollflags[0]: > hbar = Scrollbar(stxt, orient=HORIZONTAL, takefocus=NO, > width=10) > hbar.grid(row=1, column=0, sticky=W+E, columnspan=2) > txt.config(xscrollcommand=hbar.set) > > if scrollflags[1]: > vbar = Scrollbar(stxt, orient=VERTICAL, takefocus=NO, > width=10) > vbar.grid(row=0, column=1, sticky=N+S) > txt.config(yscrollcommand=vbar.set) > > ...called with the following line: > statustxt = scrolledtext(sbar, (YES, YES)) > where sbar is a frame. > > i want the text to fill the area except for the spots where the scroll > bars are. i also want the window to be able to be resized. help! > > thanks, > -->keith > > > > is there a way to make a frame, that's been formatted using grid, > > expand > > > to fill the space it is given? In tcl/tk this would be solved by making column 0 and row 0 have a weight of 1 and by making column 1 and row 1 have a weight of 0. This would be done using 'grid columnconfigure' and 'grid rowconfigure' in combination with the sticky code that you already added. If you can find the python equivalent of setting the weight of the columns and rows, I think your code should work. --Dan From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 16:40:12 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 20:40:12 GMT Subject: "Intellisense" drop-down... Message-ID: <3bQZEC$jK9@openbazaar.net> I have found no way of defining new key combinations to select the currently highlighted word in the "Intellisense" drop-down list. For example: import win32api win32api._ | AbortSystemShutdown | | Apply | | Beep | ----------------------- I hightlight "Apply" and the only key I can use to make "Apply" appear and the list to disappear is "Tab". I want other keys to trigger this. The default.cfg file only lists this: Tab = TabKey ...which doesn't mean much to me. I mean, I don't want to add "Enter = TabKey", since that's just silly. Anyone?? Bueller?? Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From olivierS.dagenaisP at canadaA.comM Sun Jul 16 12:35:56 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 16:35:56 GMT Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME References: <963764534.1476580377@news.demon.co.uk> Message-ID: You may want to hook up with the guys at ActiveState for your Win32 version of VisualPython: http://www.activestate.com/Products/VisualPython.html Unless both of you came up with the name "Visual Python" to mean totally different things?? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Phil Thompson" wrote in message news:963764534.1476580377 at news.demon.co.uk... > Visual Python is aimed at KDE and GNOME application developers and allows you > to easily embed Python as a GUI enabled scripting language in your application. > > It includes KDE and GNOME APIs to manage Python interpreters, scripts and the > communications between running scripts and your application. > > Users benefit from a common scripting language allowing them to develop > scripting skills that are re-usable with all their applications. The same > Visual Python script uses KDE widgets when run from a KDE application, and > GNOME widgets when run from a GNOME application. > > When used in conjunction with tools like SWIG and SIP to expose application > specific functionality to scripts, developers can provide their users with the > ability to extend their application in many ways. > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. > > Phil From wlfraed at ix.netcom.com Tue Jul 11 12:04:20 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 11 Jul 2000 09:04:20 -0700 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> <8kelji$3i4$1@snic.vub.ac.be> Message-ID: <6fgmmscedvt6kkci9ll6khh7kebj8dq7gd@4ax.com> On 11 Jul 2000 08:24:18 GMT, Thomas Hamelryck declaimed the following in comp.lang.python: > > I remember the anouncement very well. Probably because I was laughing out loud > when I saw that the prize was some Fortran compiler. > And the simulation package is designed to work with FORTRAN, of course... Wonder if it is anything like XDS SL-1 which generated very ugly FORTRAN-IV that then needed to be compiled, or is just a link-library. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From herzog at online.de Thu Jul 20 12:49:59 2000 From: herzog at online.de (Bernhard Herzog) Date: 20 Jul 2000 18:49:59 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: Tim Hochberg writes: > aahz at netcom.com (Aahz Maruch) writes: > > > Huaiyu Zhu wrote: > > > > > > matrix element names (with prefix m or e) > > > + .+ add > > > - .- sub > > > > I am strongly opposed to operators of the form ".+". What happens if > > take an expression of the form "5.+matrix"? No, that goes against the > > Python rule of having zero ambiguity. > > Note that if .+, etc are matrix operations, there is no ambiguity AFAICT, there's no ambiguity at all, at least from the parser's point of view. 5.+matrix already is legal python and equivalent to 5. + matrix Introduction of a .+ operator won't change that. > since (5.)+A, etc. is not a legal expression, It's syntactically legal python. It may lead to runtime errors, of course, but that doesn't have anything to do with matrices in particular. > so the only interpretation is 5.(+A). You want to call a float? > Still it looks confusing. Agreed, but the confusion comes from allowing floating point literals to end or start with the decimal point (2.+.5 is valid python). The best way to avoid confusion is to surround all binary operators (or at least the new .-operators) with whitespace. "5 .+ matrix" only has one interpretation if .+ is a legal operator. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From johngrayson at home.com.bbs Sat Jul 15 10:00:01 2000 From: johngrayson at home.com.bbs (johngrayson at home.com.bbs) Date: 15 Jul 2000 14:00:01 GMT Subject: help with tkinter coding Message-ID: <3bPZI1$k0K@openbazaar.net> In article <396FDD54.E2DD84FF at structurex.net>, walter hanagriff wrote: > i got this file from a person on the list not too long ago, thanks for > this, it is better then what i was thinking of before > just 2 questions: > first, how can i make the frame that is to the right of the first one > appear on the bottom of it instead > second, how do i write more then just a label into the second frame, > in the second frame is going to be a new set of options depending on > which option was picked in the first frame, so how do i do that? > this code works as a standalone > > -- File test.py > #!/usr/bin/python > from Tkinter import * > > class Main: > def __init__(self, root): > # The top label. > text = 'this program figures the area, perimeter, and power of > n' > text = text + '\n' + '_'*len(text) > Label(root, text=text).pack(side=TOP, fill=X) > > # The 'main' panel to command the option frame to show. > self.var = StringVar() > self.var.set('power') > main = Frame(root, bd=2, relief=SUNKEN) > Radiobutton(main, text="1 = Find the power of a number", > value='power', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Radiobutton(main, text="2 = Find the area of a shape", > value='area', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Radiobutton(main, text="3 = Find the perimeter of a shape", > value='perim', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Button(main, text="Close", command=root.destroy).pack(padx=10, > pady=10) > main.pack(side=LEFT, padx=5, pady=5) > > # Create 3 frames, one for each option. > self.frames = { 'power': Frame(root), > 'area': Frame(root), > 'perim': Frame(root) } > > # Populate the option frames at your convenience. > prefix = 'this frame is where you put information to get ' > list = (('power', 'power of n'), > ('area', 'the area of a shape'), > ('perim', 'the perimeter of a shape')) > for (frame_name, text) in list: > frame = self.frames[frame_name] > text = prefix + text > text = text + '\n' + '_'*len(text) > Label(frame, text=text).pack(expand=YES, fill=BOTH) > > # We start with one frame. > self.update_frame() > > def update_frame(self): > # Unpack every option frame. > for n in self.frames.keys(): self.frames[n].pack_forget() > # Pack the current option frame. > self.frames[self.var.get()].pack(side=RIGHT) > > if __name__== '__main__': > root = Tk() > root.title('test') > start = Main(root) > root.mainloop() > -- End of file > > I throw up your class Func and swept a little your code. Hope this helps > ? > > Regards, > Jerome > > It just happens that one of the sample chapters for Python and Tkinter Programming is on geometry managers. It might help you understand how the Packer works... http://www.manning.com/Grayson/chapt05.pdf John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From darrell at dorb.com Sat Jul 1 20:59:56 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sat, 1 Jul 2000 17:59:56 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <033401bfe3c0$d7158140$6401a8c0@home> From: "Mark Hammond" > Just to stoke the flames a little... > > Check out some of the talks at the upcoming PDC - > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python Ok my flames are stoked. What do they mean "Visual Python"??? Could this be a good thing? --Darrell From johannes at zellner.org Fri Jul 7 20:54:58 2000 From: johannes at zellner.org (Johannes Zellner) Date: Sat, 8 Jul 2000 02:54:58 +0200 (CEST) Subject: weird prompting Message-ID: Hello, I just discoverd that the prompt objects are both (also sys.ps2) only called when printing sys.ps1. Example: class Prompt: def __init__(self, prompt): self.count = 0 def __str__(self): self.count = self.count + 1 return str(self.count) sys.ps1 = Prompt() sys.ps2 = Prompt() then issue at the input prompt a few returns and then some command (e.g. def) which needs ps2 lines: 1 # <-- both ps1 and ps2 are incremented 2 # <-- both ps1 and ps2 are incremented 3 # <-- both ps1 and ps2 are incremented 4def fred(x): # <-- both ps1 and ps2 are incremented 4 pass # <-- neither ps1 nor ps2 are called 4 pass # <-- neither ps1 nor ps2 are called 4 pass # <-- neither ps1 nor ps2 are called 5bla python 1.5.2 does this make sense ? (I think: no) -- Johannes From sandysj at asme.org Tue Jul 11 10:51:06 2000 From: sandysj at asme.org (Jeff Sandys) Date: Tue, 11 Jul 2000 14:51:06 GMT Subject: Help! Indenting craziness! References: <8k5pev$182l$1@nntp1.ba.best.com> <8k5r4u$182l$2@nntp1.ba.best.com> Message-ID: <396B345A.5F8EBAF@asme.org> Adam Clark wrote: > > Let me retract the "blank, unindented lines" part before somebody flames > me. I realize now that this is a python-mode issue, probably due to a > space/tab mixup. Problem is, everything appears to be tabs. There is > no detectable difference either visually or by cursor navigation between > correct code and SyntaxError-generating code. > > So, that said, help!! > ;;; Add this to your .emacs or evaluate it with Meta-: (setq indent-tabs-mode nil) ;;; I also use a four space tab (setq default-tab-width 4) ;;; You can fix a file with untabify ; esc < ; ctrl-space ; esc > ; meta-x untabify ; [save file] ;;; The above .emacs stuff can be put into a procedure like this (defun python-initialise () (interactive) (setq default-tab-width 4) (setq indent-tabs-mode nil)) (add-hook python-mode-hook 'python-initialise) ;;; Thanks to Harry George for fixing this for me, ;;; Jeff Sandys From paul at prescod.net Sat Jul 22 12:35:27 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 22 Jul 2000 11:35:27 -0500 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> Message-ID: <3979CD4F.22BD1F5E@prescod.net> Bjorn Pettersen wrote: > > ... > > def __getattr__(self, a): > if a == 's': > return self.__dict__['_s'].value() > else: > return self.__dict__[a] This is exactly the kind of code that would be simplified. > so client code could continue looking like: > > myObject = MyObject('foobar') > s = myObject.s Right. Exactly! > > That was actually the first proposal. But inheritance could get > > confusing if you inherited set without get or get without set etc. > > Hmmm... I'm not quite sure I understand... With __set/get/del_XXX__ > defined in a superclass you would automatically inherit all of them and > could choose to only override one of them, e.g. if you wanted to perform > further checks on a set but the get was the same. With __attr_XXX__ you > would have to explicitly call the superclass' __attr_XXX__ method if you > didn't define all of set/get/del(?) I have a feeling I'm missing > something... Well there are two halves to it, interface and implementation. I'll ask your opinion on the first and then you can tell me if you think you can find a good implementation. Consider this module and tell me what it would output (in your opinion): class A: def __set_x__( self, val ): print val a=A() a.x=5 print a.x del a.x class B(A): def __get_x__( self, val ): return "funny walk" b=B() b.x=5 print b.x del b.x Now, how would you implement it? -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From billtut at microsoft.com Tue Jul 11 09:37:51 2000 From: billtut at microsoft.com (Bill Tutt) Date: Tue, 11 Jul 2000 06:37:51 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD2A8@RED-MSG-50> I think Mark's link to the PDC info is about all that can be said atm. I'm sure Mark would have mentioned more if he could. No, I can't say a word, since I don't work on those teams and so therefore couldn't possibly comment. Bill -----Original Message----- From: Neil Hodgson [mailto:neilh at scintilla.org] Sent: Monday, July 10, 2000 9:30 PM To: python-list at python.org Subject: Re: Microsoft's C# (Sharp) & .NET -- A Heads Up Now that Microsoft have revealed their Intermediate Language (IL) virtual machine, are we going to see a version of Python that compiles directly to IL? Or will Python byte codes still be interpreted by C code? Neil -- http://www.python.org/mailman/listinfo/python-list From imco at fitspdlwo.mil Wed Jul 26 22:19:33 2000 From: imco at fitspdlwo.mil (imco at fitspdlwo.mil) Date: 27 Jul 2000 02:19:33 GMT Subject: Ignite a fire Message-ID: <3xgx8d$q4y$4@news.hk.linkage.net> remove: <3xgx8d$q4y$4 at news.hk.linkage.net> Turn your computer into a large scale Usenet news posting machine with PostAgent! Capture a world-wide audience in an instant! Use it to maximize the exposure of your ideas or products on the newsgroups! http://members.tripodasia.com.cn/postagnt -- begin 666 0065.gif M1TE&.#=A(0`8`/<``````(````"``("`````@(``@`"`@,#`P,#/CX^KJZO'Q\?CX^/_[\*"@I("`@/\```#_ M`/__````__\`_P#______R'Y!```````+``````A`!@`0`C_``$('$BPH,&# M"!,J7`B`@@0*O-XQG#@PWCV!0]C5 at P"A'CL`#21H_%A/$@!)]0!HY.BQ(X!Y M%S6J3`G`8TUV'="?1(H5[\R@*!6F(FK:C";X);$!AR,R&$)92H-"`(`0* M!2E$'?B.5P,((FEZI%!/0D>2'V7*O-D@*("K"K5B',)3ZM:"\22J+2O!9DN; M$7=Z;?!QJ.&E90X;I+8M:;9LU:A1,[A6<4$)\WC%8ZUGN=Z M>DU_QHIVX%J/;3?[39OR-3NR`.C6F]?&]LYZO&8_]2V!HDVN$A>V`>[YZ Message-ID: <8lm2k202c2i@news1.newsguy.com> "(Greg Weeks)" wrote in message news:8llqso$q75$1 at news.dtc.hp.com... [snip] > How did the implementer of the "fileinput" module convince the "for" > construct that fileinput.input() was a sequence? "Use the source" is often good advice. Opening the source file: D:\Python\Py152\Lib\fileinput.py (or wherever the fileinput.py module is kept on your system, of course), we find ourselves facing a modest 255 lines of code, of which the first 75 are an extensive docstring. Lines 124 to 238 are concerned with defining the FileInput class (the function fileinput.input, defined on lines 80-85, is clearly just instantiating a FileInput object and also storing it in a module-private global variable called _state). All the 'magic' needed for a FileInput object to behave like a sequence in a for statement is actually contained in lines 154 to 160...: def __getitem__(self, i): if i != self._lineno: raise RuntimeError, "accessing lines out of order" line = self.readline() if not line: raise IndexError, "end of input reached" return line Much of this is error-checking: __getitem__ is supposed to be called (by the for statement) with an index i that starts at 0 and increases by 1 each time. Once this is confirmed, the actual operation is delegated to FileInput's own readline method. If there is no more line, an IndexError must be raised: the for statement traps this and uses it as the indication that the sequence is finished. Method readline, lines 186 to 222, is substantially richer, as it must handle all sort of boundary cases -- moving to the next file if the current one is exhausted, handling in-place updating, etc, etc. > (In "Python ESSENTIAL REFERENCE" I don't find any way of creating class > instances that are recognized by "for" as sequences.) Page 29: "it's possible to use class definitions to define new objects that behave like the built-in types. To do this, supply implementations of the special methods described in this section." On page 30-31, among the "Sequence and Mapping Methods", __getitem__ is also described; I believe you are correct in noticing that nowhere is it clarified that this is the specific method used by the for statement, and that IndexError is the way __getitem__ tells the for statement that the sequence is finished (this is in fact handier than, say, having for use __len__, because the sequence-object need not determine beforehand how many items it contains; but, it's not immediately and intuitively obvious!-). The issue may be clearer if we only reproduce the bare-bone function of the rich FileInput module: wrap one file-like object (which supplies a readline method) into something that can be iterated on a la: for line in LineSequence(fileobject): process(line) To get this, and this only, without special error checking, we'll do: class LineSequence: def __init__(self, fileobject): self._file = fileobject def __getitem__(self, i): line = self.fileobject.readline() if not line: raise IndexError return line Now these bones are bare indeed, but maybe having the essential part of the "sequence-simulation" exposed like this can make it easier to understand. Alex From thomas at cintra.no Mon Jul 24 04:44:09 2000 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 24 Jul 2000 08:44:09 GMT Subject: Setting referrer using urllib Message-ID: <397bff4b.18231775@news.online.no> Hi, I`m trying to access various search interfaces on online sites using urllib, contrstructing a url, opening the location and reading the output, but many of them, well, most of them, return some permission denied response. Somebody told me this was due to the fact that urllib didn't have referrer set correctly, so the site wouldn't allow it. ( If this should be allowed is another matter, not what I want to discuss here. ;-> ) In urllib.py I didn't see anything about referrer. If anybody has done similar things before, feel free to give hints and clues. And if making eh ... alternative search-methods for online-resources is bad in some way, I understand that most of them rely on advertising etc., let me know about that also. Trying not to step on too many toes here. Thomas From jclonts at mastnet.net Wed Jul 12 02:28:35 2000 From: jclonts at mastnet.net (John Clonts) Date: Wed, 12 Jul 2000 01:28:35 -0500 Subject: finding mount points References: <396C0076.4A6547A3@mastnet.net> Message-ID: <396C1013.7A47F82@mastnet.net> Suchandra Thapa wrote: > > John Clonts wrote: > >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>>> import posixpath > >>>> posixpath.ismount("/") > >1 > >>>> posixpath.ismount("/mnt") > >0 > >>>> posixpath.ismount("/mnt/dosd") > >1 > >>>> posixpath.ismount("/home") > >1 > >>>> posixpath.ismount("/home/john") > >0 > > Actually, I wanted something like > >>>mountpoint('/home/john') > >/home > >>>mountpoint('/home') > >/home > > I suppose I could do a recursive solution where I start with the full path > and take away directories and check to see if its a mount point using > ismount but I was hoping there was a module or way to find the mount point > directly. > Oh, sorry, I misread your question. I didn't find anything already extant, so here's this: def mountpoint(s): import os if (os.path.ismount(s) or len(s)==0): return s else: return mountpoint(os.path.split(s)[0]) def testit(): print mountpoint("/home/john/scheme/cmucl") print mountpoint("/usr/local") print mountpoint("/lib/") print mountpoint("lib") Cheers, John From scarblac-spamtrap at pino.selwerd.nl Wed Jul 19 12:54:57 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 19 Jul 2000 16:54:57 GMT Subject: are there any tutorials that someone completly new to programming can understand? References: <8l4klm$2kl$1@slb6.atl.mindspring.net> Message-ID: Dan^ wrote in comp.lang.python: > well..im 17 and thought that i should start with a programming language, and > after checking with some of my friends, they pointed me to python > > but, all the tutorials seem to be for those that have spent years in > programming (mabey im just looking in the wrong places) but id really like > to try my hand at this At http://www.python.org/doc/Intros.html there are three of them listed, under "introductions for non-programmers". There is also a mailing list for this purpose, where you can ask questions. See http://www.python.org/psa/MailingLists.html#tutor . -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From stephen_purcell at yahoo.com Wed Jul 26 18:21:19 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 27 Jul 2000 08:21:19 +1000 Subject: Python 3000 In-Reply-To: <8lneqf$f3m$1@serv1.albacom.net>; from fichou@katamail.com on Wed, Jul 26, 2000 at 09:39:33PM +0200 References: <8lneqf$f3m$1@serv1.albacom.net> Message-ID: <20000727082119.B9696@inkontact.com.au> Patrick Fichou wrote: > Wot is (or will be) Python 3000 ? You already asked this on the 24th and received a slew of replies. Python 3000 is the codename for a project that ambitiously plans to optimise redundant questions out of the mailing list. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From neilh at scintilla.org Tue Jul 18 22:36:03 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 19 Jul 2000 02:36:03 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> <8kvdon$tit$1@slb3.atl.mindspring.net> <8kvkb401g1e@news1.newsguy.com> Message-ID: > As I "read between the lines", mostly in the paper (on the MSDN > online technical articles library) about Eiffel#, > ... For some more lines to read between, there is a fairly disorganised report of a presentation on Smalltalk 2000 .net at http://www.smalltalkconsulting.com/html/CampSmalltalk2.html Start about 1/3rd down the page. """Next we got an example of the bytecode, the first issue David had was that classes aren't first class objects, but you can build a first class object using the class information. The UVM also doesn't support dynamic messaging in the raw VM, so David needed to build a dynamic dispatcher, Microsoft is aware of these problems and this could change.""" Neil From rloisel at helicon.net Sun Jul 23 11:21:55 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Sun, 23 Jul 2000 11:21:55 -0400 Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> Message-ID: <397B0D93.6A5EE7CB@helicon.net> Changed the DOS properties not to close on exit the following is the result of import Tkinter several levels of error last: DLL load failed: one of the library files needed to run this application cannot be found. rloisel From ssthapa at midway.uchicago.edu Sat Jul 1 17:17:47 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 01 Jul 2000 21:17:47 GMT Subject: writing in gif format References: <8jgamf$rli$1@nnrp1.deja.com> Message-ID: Keith Murphy wrote: >does anyone know how to write in gif format. I am using the PhotoImage >class, not the Python Imaging Library. Python tells me "TclError: image >file format "gif" has no file writing capability" I believe that there are some patent issues involved in this. Unisys holds the patents for using LZW compression in gif files so you would need to pay Unisys royalties for makng apps that write gif files. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From neilh at scintilla.org Thu Jul 27 01:06:44 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 27 Jul 2000 05:06:44 GMT Subject: PythonWin/Scintilla aggressive folding... References: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> <1csf5.40036$Gh.442627@news20.bellglobal.com> <7mwf5.12307$4p3.95451@news-server.bigpond.net.au> Message-ID: > You mean to detect the indentation of the commented-out code? No, just leaving comments as level neutral but trying to make them belong to the next block rather than the previous block. So your class heading comments would not be part of the previous folding section. Or be folded with the next section either. > That might be > hard, given you might have a comment like any of the following: "sharp", > "sharp space", "sharp sharp", "sharp sharp space". I didn't realize this > would be such an involved feature.... Some of the complexity is coming from my desire for this to perform well. This feature is also developing a new view of modularisation that doesn't quite line up with the Python compiler as the compiler sees code with the comments already weeded out. > class ztApp ( wxApp ): > def OnInit ( self, etc.. ): > print "init..." > (...) > return true > '' > '' > > ...I-can-live-with-that-ly y'rs I hope we can do better. Neil From scarblac-spamtrap at pino.selwerd.nl Thu Jul 13 02:54:57 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 13 Jul 2000 06:54:57 GMT Subject: Switching to Linux...... converting files and databases.... References: <20000712201149.7701.qmail@web5302.mail.yahoo.com> Message-ID: Dave Williams wrote in comp.lang.python: > Proposed project: The Windows to Linux Survival Kit > Subject: Software that can open and read Microsoft's proprietary > (wrong word?) files and convert them to databases and files usable by > Linux's opensource software.. Both Sun's Star Office and Corel's WordPerfect Office 2000 are free to download for Linux, and they read those Word, Excel etc files without problems, as far as I know. Office-type software is not a problem with Linux. -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From thamza.dontbesendingmenospam at geocities.com Sat Jul 8 03:37:01 2000 From: thamza.dontbesendingmenospam at geocities.com (Tim Hamza) Date: Sat, 08 Jul 2000 07:37:01 GMT Subject: NumPy and 1.6a2? Message-ID: Hey all, I'm new so maybe I'm missing something easy. Python 1.6a2 (no other snakes in the system), Numpy 15.2, Win98. Unzipped NumPy to the Python directory and ended up with a /python/Numeric.pth file as well as /python/Numeric and /python/include/Numeric directories. Here's what I'm getting: C:\>python Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Numeric Fatal Python error: PyThreadState_Get: no current thread abnormal program termination C:\> Also blows up in idle. Am I doing something wrong? Does this version of NumPy not work with this version of Python? Thanks, Tim From ftian at cs.wisc.edu Thu Jul 13 16:05:16 2000 From: ftian at cs.wisc.edu (ftian at cs.wisc.edu) Date: Thu, 13 Jul 2000 20:05:16 -0000 Subject: DB2 Connection Message-ID: <8kl7ds+d9ni@eGroups.com> Hi, Anyone succeeded in connect Linux DB2 v7.1 on linux? IBM only provide Perl module on their web site. Thanks Feng From tkssato at yahoo.co.jp Thu Jul 27 04:18:36 2000 From: tkssato at yahoo.co.jp (tkssato at yahoo.co.jp) Date: Thu, 27 Jul 2000 17:18:36 +0900 Subject: Q: File Upload Problem Message-ID: <397FF05C.D0A7A724@yahoo.co.jp> I wrote a simple cgi script to upload files by Web browsers. It works perfect on Linux with Apache1.3. But on WindowsNT with Apache1.3, it works only for text files Uploaded image files are truncated. I don't understand which my Python script or Apache causes the problem. If you know anything about it, Please let me know. Thanks for reading this article. T.Sato CG & Web engineer tkssato at yahoo.co.jp ----------------------------- #!/bin/python import cgi form = cgi.FieldStorage() print "Content-Type: text/html"; print print "" if not form.has_key("filename"): print """ """ else: item = form["filename"] if item.file: data = item.file.read() print len(data); # see if data is truncated here else: print "no file" print "" From grey at despair.rpglink.com Fri Jul 28 12:30:18 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 16:30:18 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> Message-ID: On Fri, 28 Jul 2000 15:47:26 GMT, Grant Edwards wrote: >Why does "what non-programmers do" matter when designing a >programming language? Where do you think programmers come from? Programming most certainly learned. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From abrahams at mediaone.net Mon Jul 31 05:02:38 2000 From: abrahams at mediaone.net (David Abrahams) Date: Mon, 31 Jul 2000 09:02:38 GMT Subject: Python, Perl Rewrites: Alliance? References: <8m38ca$an5$1@nnrp1.deja.com> Message-ID: wrote in message news:8m38ca$an5$1 at nnrp1.deja.com... > My first question would be whether CNRI also claims in effect > the trademark for the Python language as well as the copyright > for the current source code. Would someone be able to write > a Python compatible language from scratch and still call it Python > without CNRI's permission? As a "standards geek", I should probably point out that there's a bigger obstacle to writing a Python-compatible language, at least if you care about compatibility of existing extension modules: for all intents and purposes, the documentation of the "C" API is in the source code. Yes, there are various documents floating around which purport to document the "C" API, but I've always found that serious work requires reading the source. I suppose it's possible that most extensions only rely on the documented subset of the available API, but I'm guessing that's not the case. -Dave From dag at orion.no Fri Jul 7 04:44:06 2000 From: dag at orion.no (Dag Sunde) Date: Fri, 07 Jul 2000 08:44:06 GMT Subject: Namespace Mystery (HELP!) References: <39655351.9EE499F2@sunesis-pharma.com> <39656345.86AADA8A@prescod.net> Message-ID: Warren, Aside from your question about the locals() and Pauls excellent answer, is there any particular reason you're not writing something like: >>> def fnx(): ... b = 1 ... global a ... a = 2 ... b = 2 ... print a, b Dag. "Paul Prescod" wrote in message news:39656345.86AADA8A at prescod.net... > > Why is the output "2 1" and not "2 2"? > > What is it about the locals() function that makes it behave > > unexpectedly? > > locals () > Return a dictionary representing the current local symbol table. > Warning: the contents of this dictionary should not be modified; changes > may not affect the values of local variables used by the interpreter. > > http://www.python.org/doc/lib/built-in-funcs.html > > Python doesn't typically look up local variables based on a string name > at runtime. That would be too inefficient. Rather it looks them up > positionally. > > -- > Paul Prescod - Not encumbered by corporate consensus > Pop stars come and pop stars go, but amid all this change there is one > eternal truth: Whenever Bob Dylan writes a song about a guy, the guy is > guilty as sin. > - http://www.nj.com/page1/ledger/e2efc7.html > From ge at nowhere.none Fri Jul 28 10:36:14 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 14:36:14 GMT Subject: Perl is worse! References: <398178EA.7576E13A@hursley.ibm.com> Message-ID: In article <398178EA.7576E13A at hursley.ibm.com>, Paul Duffin wrote: >Moshe Zadka wrote: >> >> Because numbers are numbers and strings are not. Given, Python's numeric >> model is not very good. > >What is wrong with Python's numeric model ? I may be a minority, but I don't like integers being converted to floats automatically. -- Grant Edwards grante Yow! Do I have a lifestyle at yet? visi.com From lordkaos at my-deja.com Mon Jul 17 18:59:49 2000 From: lordkaos at my-deja.com (lordkaos at my-deja.com) Date: Mon, 17 Jul 2000 22:59:49 GMT Subject: test_socket, similar problem: Message-ID: <8l034s$hl7$1@nnrp1.deja.com> I'm having a similar problem to the below, but on a Mac (MacOS 9.0.4) w/ Python 1.5.2 (same error w/ test_socket, and same thing when I tried open a simple socket connection) I'm sure the problem/solution is similar, but how in specific do I fix it on a Mac? Thanks. > Harry George wrote: > > > > [I looked in dejanews, but all the socket queries are way beyond where > > I'm stuck.] > > > > I have a win95 machine which is samba'd to a linux box.? I'm trying to > > learn to do python on win95 (COM et al).? First step is to get it > > running.? py152.exe went ok; then win32all-128.exe.? python, > > pythonwin, icons in the explorer all ok.? Able to edit and run simple > > hello, worlds. > > > > Then in the interpreter I tried: > >? import test.autotest > > It ran ok (with lots of skipped optionals), but test_socket crashed > > with socket.error "host not found" > > I had the same error. As far as I understood my? computer didn't know > about his name.. ;-) I made the? file "c:\windows\hosts" , that > contained one row: > > 128.0.0.1 localhost > > and after reboot all worked fine.. > > > > Of course this could be a non-python win95 setup issue, but with > > tcp/ip running ok (samba, ftp, ping, etc.), I'm wondering if there is > > a python-specific issue.? Any ideas? > > > > -- > > Harry George > > hgg9140 at seanet.com > > Alexei Kichkine (http://infocentr. Sent via Deja.com http://www.deja.com/ Before you buy. From donn at u.washington.edu Fri Jul 21 15:46:01 2000 From: donn at u.washington.edu (Donn Cave) Date: 21 Jul 2000 19:46:01 GMT Subject: Creating a setuid script References: <39789242.C93B0446@glo.be> Message-ID: <8la99p$3u18$1@nntp6.u.washington.edu> Quoth Jurgen Defurne : | I am busy writing some scripts, which should be setuid root (several | users should be | able to modify the contents of a file, which is under root control). | | The main problem is that setuid root doesn't seem to work with a Python | script. If i have | two programs : | | rwsr-xr-x .... tu.pl (obviously Perl) | rwsr-xr-x .... tu.py (the same in Python) | | then the perl script reports UID and EUID as 0 and 1000 (or reverse, | they are DIFFERENT), | but the Python script reports 1000 and 1000 (a further test to open a | root owned file in | read mode raises an exception). The Python interpreter is normal in this respect. For another example, try a shell script - the shell won't be able to assume root privileges through a setuid bit on the script file. Python can't either. Perl accomplishes this through a special gimmick of a setuid-root interpreter installed along with the normal one. This is an extremely risky business. I'm sure the author of Perl has done what needed to be done to make it tolerable, but that work has not been done with Python and probably never will be. When I need setuid privilege, I write that part in C and assign the setuid privilege to that executable, then invoke it from Python. Donn Cave, donn at u.washington.edu From paul at prescod.net Tue Jul 18 22:42:30 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 21:42:30 -0500 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: <39751596.45921F07@prescod.net> Huaiyu Zhu wrote: > > ... > Please jump in at any point that's both > feasible and interesting enough for someone to actually do it: > > 1. Make a pure python way to introduce additional operators, like > import NewOperator > NewOperator.define(".+", "__dotadd__") > NewOperator.define("+=", "__add_ab__") > NewOperator.define(":=", "__copy__") > > Advantage: Pure python. Doesn't interfere with existing sytax. May be > used for other operators. Not in the core, only affect the module that > imports it. > Disadvantage: Said to be quite difficult to implement (Why?). Parsers just do not work that way. Most parsers cannot be extended at runtime. The language is defined at compile time by the grammar. The only way to do it without rewriting Python's parser from scratch would be to pre-declare every possible operator anyone might ever want in the grammar. > 2. Incorporate additional operators in python. Either . or @. Five to > eight would be enough for linear algebra. > > Advantage: Pure python. Doesn't interfere with existing syntax. > Disadvantage: Fixed choice for everybody. Unlikely to happen for quite > some time until everyone agrees on everything. Agreed on all counts. > 3. Maintain a patch for additional operators. > > Advantage: once built, everything is pure python. Already have patch. > Disadvantage: Can't guarantee most users can patch python, so in practice > may need to maintain windows executable for download. In the big picture, is that such a big deal? > 4. Temporarily use a.mmul(b) and a.emul(b) before things settle down. Then > define __dotmul__ = emul, or the like, when they are available. > > Advantage: immediately implementable. Won't break anyone's code. Can > also switch to __atmul__ = mmul or other choices later. > Disadvantage: code somewhat cluttered. Let me ask again, is that such a big deal? > 6. Maintain two classes: E and M. > > Advantage: no need for new operators. > Disadvantage: artificial casting likely to be maintenance nightmare, > because we change objects while we really want to change operators. > > A variant: only use .E for elementwise. Always return matrixwise. This > is simply just using casting to help select among two methods denoted by > the same binary symbol. Does not look much better than 4 but worth > considering. I don't think anyone proposed the pre-variant variant. It was always supposed to always return matrixwise. > ... > The argument "if it finds wide-spread use we may put it in the language" has > a severe limitation - if it is technically very difficult for users to use a > feature that's not in the language, it will unlikely to find wide-spread use > and may never get into the language. That's why I really hope something > like 1 can come up. Using method or function syntax is not "technically very difficult." There are hundreds or thousands of NumPy users who can testify to that. It is inconvenient. Yes. Inconvenience is the price of compromise. Compromise is the price of sharing a language with people who are uninterested your domain. > ["%5.2f", "%-8s", "%.2g"] .% [pi, 'short', 1] Eeek. That's really, really ugly. This is much more explicit: i = ["%5.2f", "%-8s", "%.2g"] j = [pi, 'short', 1] [for i,j in zip(list1, list2): i % j] -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From moshez at math.huji.ac.il Fri Jul 21 00:41:36 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 21 Jul 2000 07:41:36 +0300 (IDT) Subject: iterating over lines in a file In-Reply-To: Message-ID: On Thu, 20 Jul 2000, nobody wrote: > > Preventing world war III, when Python achieves world domination. If C is > > allowed to achieve world domination, WWIII will be cause by > > > if(everything_is_ok = 0) { > > launch_missile(); > > } > > i sort of see the point, when you're speaking of beginner programmers > still confused by the common algebra equal sign and trying hard to > sort out assignment from comparison, but i honestly don't see many > more seasoned programmers making that mistake. Huh? No programmer I know never made that mistake. Even seasoned programmers sometimes forget the second "=" in the midst of coding... (Note that Java partially solved it too) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From moshez at math.huji.ac.il Sun Jul 2 15:20:29 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 2 Jul 2000 22:20:29 +0300 (IDT) Subject: Internet Explorer and Python/COM Message-ID: I'm really a beginner in Windows COM programming, so I'm sorry if my question doesn't make sense. Can I use Python to run Internet Explorer and control it via COM? I mean, telling it things like "Display this URL" or "Render this HTML". (Maybe even putting a hook on URL displaying, so my Python program is notified when the URL the browser is displaying changes) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From fannyy at idmail.com Tue Jul 11 03:02:12 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Tue, 11 Jul 2000 00:02:12 -0700 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: Hi Martin, I found it now. Thanks very much. Mak Martin Rand wrote in message news:fjujmsoqkq86gng4uisslt7uh3cneboeq7 at 4ax.com... > On Mon, 10 Jul 2000 09:12:12 -0700, "Fanny Yeung" > wrote: > > >Hi Martin, > >Thank for your reply. But I wonder where I can find Doug Hellmann's grid > >widget ? > > > Darn, I knew you were going to ask that! I shall have to stop being so > lazy and see where I downloaded it from... > > Rummage, rummage... Oh, here we are, it's on the "Vaults of Parnassus" > site > http://www.vex.net/parnassus/ > under "User Interfaces/GUI/Tkinter Widgets", as "PmwContribD". > -- > Martin Rand > Highfield Software Ltd > mwr at highfield-software.co.uk > Phone: +44 (0)23 8025 2445 > Fax: +44 (0)23 8025 2445 From cjc26 at nospam.cornell.edu.bbs Mon Jul 17 16:10:05 2000 From: cjc26 at nospam.cornell.edu.bbs (cjc26 at nospam.cornell.edu.bbs) Date: 17 Jul 2000 20:10:05 GMT Subject: mxTextTools Question, Number 2 :) Message-ID: <3bRO0U$kyF@openbazaar.net> * Stephen Hansen menulis: | | ...works, I suspose... but, here's the harder part. I want to ignore that | whitespace as delimiter if the next character is a special | | So, "This &that" would end up capturing "This that". | | For the life of me I can't even fathom how to do the above! Well, I have a | vague conception of what needs to be done but can't get it down on | paper(Y'know what I mean. :)) Would it be possible to have the special character come >before< the space, rather than after? For example, "This& that". That might be a bit easier to do. If you can't do it that way, well..I don't know mxTextTools, but I do know a little about writing parsers in general. The way I would do it is to have the parser jump to a special state whenever it encounters a space; in that state, if the next character is "&" then add a space to the text buffer and jump back to the "Text" state. Hopefully you can translate the above into mxTextTools code. :) -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From lull at acm.org Thu Jul 20 23:10:30 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 22:10:30 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> Message-ID: Jonathan Epstein wrote (with possible deletions): > The special constituencies can even be addressed using two-character > sequences within the parens if necessary. E.g., for Kroneker use > A(.K)B > I'm not actually proposing this specific syntax because it's so horrible > looking and potentially hard to parse, but some variant on this might do > the trick. This shouldn't be hard to parse. In fact, it might be a reasonable foundation for class-specific operators: A(.opName)B would get executed as either A.__opName__(B) or B.__ropName__(A) or raise an exception as appropriate. Regards, John From aahz at netcom.com Sun Jul 9 14:54:59 2000 From: aahz at netcom.com (Aahz Maruch) Date: 9 Jul 2000 18:54:59 GMT Subject: Static member variables References: <8kahdq$5e2$1@zingo.tninet.se> Message-ID: <8kahq3$fof$1@slb0.atl.mindspring.net> In article <8kahdq$5e2$1 at zingo.tninet.se>, Thomas Svensson wrote: > >Is there a way of declaring static (and constant) member variables in >classes? I have a member variable that should be unique for each class >type and thus should not waste memory for each instance of the class I >create. Something like the __doc__ string I guess. You can have class variables, but they're not exactly what I'd call "static" and they certainly aren't constant. class foo: bar = 2 def __init__(self): self.baz = 3 f = foo() f.bar is a class variable; f.baz is an instance variable. Note that you can run into problems if you're not careful because of the way scoping rules work. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From tim_one at email.msn.com Fri Jul 28 18:46:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 28 Jul 2000 18:46:08 -0400 Subject: Perl is worse! In-Reply-To: Message-ID: [Tim] > Steve, in case it isn't clear yet, Python programmers *want* to > be blown out of the water when doing something as senseless as > > 1 + "foo" [Steve Lamb] > It isn't senseless. That is the whole point. Indeed it is. In fact, it has too *many* senses for Python's tastes. You think it "should" return 1, or (in other posts) raise an exception. Someone coming from Java thinks it just as obvious that it "should" return "1foo" -- which can also be very useful. In the absence of a compelling non-exceptional sense, Python refuses to guess: you have to explicitly name the sense you intended, and then your intent is clear for all to see. After all, Python is a programming language, not a psychic hotline <0.9 wink>. In the other examples you gave, such as 1+1j, returning a complex result is wholly unsurprising to anyone. I suppose you may want 1+"1j" to return 2, though ... if-so-python's-not-your-language-ly y'rs - tim From mbaker at 0x7a69.net Tue Jul 25 16:24:28 2000 From: mbaker at 0x7a69.net (Mark Baker) Date: Tue, 25 Jul 2000 15:24:28 -0500 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <397DE866.CA57D01D@alabanza.net> Message-ID: In article <397DE866.CA57D01D at alabanza.net>, "ye, wei" wrote: >> 1. There are no keywords to declare static or instance variables; it >> all depends where they are placed(whether it's right after the >> statement, or inside a ). Isn't it harder for other programmers to >> know at one glance what type of attributes the class define? > > This is what I couldn't tolerate as well!! I'm the same guy is looking > for another new language, my path is C/C++->Java->PHP->Perl. Python's scoping rules are rather simple. If you don't understand a language's scoping rules, they will all look "weird." I imagine that you would find LISP's lexical scoping quite odd, for instance. When a language (like C++) reuses keywords ambiguously to indicate whether a binding belongs to class or an instance, I'm sure that for the unambitous learner, it too is confusing. But it's rather hard to look at a class and not know if a given variable belongs to a class or an instance, unless you bind it in some obscure place. > I'm the same frustrated as you about the Perl/Java and now Python, Java > is a good language, however it's not open language. Perl has some > language deficients as well. Python is so loose for type checking. That's the point. The idea is that static typing costs more in developer time, creates stale frameworks, and provides little practical benefit for an experienced programmer. Whether this is true or not, is a different story. Languages like Java, though, aren't totally statically typed, so they're hardly "safe" languages, but reduce productivity where they are statically typed enough so that they're a hassle. Compare development times between Smalltalk and Java, and you'll see what I mean. > However > > today I just read the Perl6 vision, it makes me very exciting - > > http://www.perl.org/perl6/pr/initial_meeting.html The new Perl 6 will > support Typing(e.g. "my Dog $spot") , OO, Threads and more features!! Perl 5.6 already has the my Class $... syntax, as well as a hacked-on object system, threads, and more "features" than I'd care to have in one language. If you want a dynamic and static language, I'd suggest Dylan or Objective-C. They both also avoid the problems of broken frameworks totally statically typed languages fall into, through the flexibility of their dispatch systems. > It also will bring some python's features into Perl. :) Elaborate. >> Furthermore, some ppl claim that Python is easier to learn, enables you >> to write much cleaner codes... However, after reading the python book, >> my head is still spinning, trying to catch all the 'intricacies' of >> this language. No doubt it will be a powerful and useful 'tool' to me >> once i get used to it; but i don't think it's suitable to be a first >> programming language for non-programmers(i read somewhere about this >> project going on). Pascal(for procedural) and Java(for OOP) is still >> the better choice to start off, IMHO. This isn't related to your post, but its parent... Python and Smalltalk are both good introductory languages, since they are both less complex than Pascal or Java, and allow the student to learn how to program, instead of fumbling over complex syntax. From mikeb at mitre.org Fri Jul 7 07:43:53 2000 From: mikeb at mitre.org (Mike Brenner) Date: Fri, 07 Jul 2000 07:43:53 -0400 Subject: RE> wxPython or wxWindows+Python? Message-ID: <3965C279.9ECF142A@mitre.org> Edward wrote: > Pros of using wxPython: 1. > Python code is simpler. ... 98. > Python is the wave of the future, etc. ... 99. > ... > What do you all think of the choices? > Are any of these points invalid? Anything I've missed? Edward, I think all of your points are valid. Perhaps one point is missing: There are not as many examples of Python code available to learn from. Events, especially mouse events, seem to be more difficult than other languages to learn without an example. What I mean is that I am not that good at it, so I only learned how to do events in other languages by examples also. I think your first true mouse graphics program has to be spoon fed to you, then you use that subset as the de-facto API. After you build on it, someday it will dawn on you how it is really working . Then you can start using the whole API instead of the tiny subset in your first program. Is there an example of cutting and pasting graphics from the clip board and the screen? Is there any example of a Python version of a stripped-down PC-PAINT program or something like it, that shows how to set up graphical input and copy/paste? Mike Brenner From wilson.austin.aj at bhp.com.au Thu Jul 6 15:11:36 2000 From: wilson.austin.aj at bhp.com.au (A J Wilson) Date: Fri, 7 Jul 2000 05:11:36 +1000 Subject: Wait/Delay Message-ID: <8k2lhd$5i6$1@gossamer.itmel.bhp.com.au> Hi Is there a command/function in python to put a delay or wait step into a program? Thanks Austin From rumjuggler at cryptarchy.org Sat Jul 29 01:12:47 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 05:12:47 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39808d84.23819726@news-server.austin.rr.com> <3981B8E1.6F55A6FC@stroeder.com> <8ltop8$c$1@nntp9.atl.mindspring.net> Message-ID: On 29 Jul 2000 05:06:48 GMT, aahz at netcom.com (Aahz Maruch) wrote: >In article <3981B8E1.6F55A6FC at stroeder.com>, >Michael Str?der wrote: >>jay graves wrote: >>> >>> Q: How do you keep a lawyer from drowning? >>> A: Take your foot off his neck. >> >>Q: What are 1000 lawyers at the bottom of the ocean? >>A: A good start. > >Q: What do you call a lawyer buried up to his neck in sand? > >A: Not enough sand. Why would you call him that? -- Barnabas T. Rumjuggler The world is turning into a cesspool of imbeciles. -- Harlan Ellison From gabriel_ambuehl at buz.ch Mon Jul 24 06:12:03 2000 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Mon, 24 Jul 2000 12:12:03 +0200 Subject: Variables in strings.. Message-ID: <81324605608.20000724121203@buz.ch> Hello, after switching from Perl to Python because I encountered serious problems when it came to the maintenance of the Perl code, I begging for a solution to the following: In Perl, it's very easy to embed a variable within a string for output (and as my main use for Python is CGI, I'm doing that rather often): print "Hello $name" would do the job. Now the only solution I could find in Python was this awful print "Hello %(name)s" % var() syntax which, after all, doesn't even seem to support lists as print "Hello %(name[1])s" % var() just raises a KeyError. May anyone point me to some more comfortable ways than just endless concatenation of strings and lists which doesn't really help for readibility (which is one of the main points why I'm switching from Perl to Python)? Best regards, Gabriel From ingoogni at home.nl Sat Jul 29 10:20:57 2000 From: ingoogni at home.nl (ingo) Date: Sat, 29 Jul 2000 14:20:57 GMT Subject: cStringIO & write error? Message-ID: <8F80A1458seed7@212.120.66.218> When I do: from StringIO import StringIO f=open('file.dat', 'r+b') ff=StringIO(f.read(-1)) ff.seek(0,0) ff.write(chr(123)) all is ok. But when I import from cStringIO I get an error: line 311, in RunScript exec codeObject in __main__.__dict__ File "D:\Ingo\PyScript\df3\Script1.py", line 5, in ? ff.write(chr(123)) AttributeError: write What am I doing wrong? TIA, Ingo -- Photography: http://members.home.nl/ingoogni/ Pov-Ray : http://members.home.nl/seed7/ From donn at u.washington.edu Mon Jul 31 19:20:31 2000 From: donn at u.washington.edu (Donn Cave) Date: 31 Jul 2000 23:20:31 GMT Subject: How does Python compare to ? References: <8m4v0g$bcbbu$1@fido.engr.sgi.com> <3FF3ED6EC164DBD2.77C81740D77CD9FA.D247DC7D74D3B365@lp.airnews.net> <8m4bo1$3le2$1@nntp6.u.washington.edu> Message-ID: <8m51jv$a7ke$1@nntp6.u.washington.edu> Quoth pj at sgi.com (Paul Jackson): | Donn Cave, donn at u.washington.edu wrote: | |> But it has to be partly the interpreter too. | | Good grief - does it ever. On my setup at least, | Python startup is much worse than Perl. After reading your analysis I tried "python -S", and shaved off a third of the startup time! That's enough to make a lot of difference to someone who's starting python 20 times per second. Wonder how much Python software depends on this feature? Donn Cave, donn at u.washington.edu ---------------------------------------- | Summary: | | Python does a lot more work loading modules at startup, | for even the most trivial program, than does Perl. | | 1) On SGI Irix 6.5.9m and 180 MHz R5000 MIPS: | | Perl startup: 13 msec | Python startup: 196 msec | | 2) On SuSE 6.3 Linux and 400 MHz Pentium II: | | Perl startup: 9 msec | Python startup: 60 msec | | where startup is measured from the time libc loads, until | the time 'real work' begins (the interpreter reads the | print command and writes "hi"). | | | Below, I analyze the startup in more detail for the Irix case. | The Linux case is similar, except that proportionately more time | is spent waiting for file system calls, and less cpu-bound in | the application (my Linux box has a faster processor). | | All numbers are from "hot" runs -- after first repeating the | same command a few times to get all files accessed into the | buffer cache. The "cold" buffer times for python also seem | to be much worse than perl, which is not surprising, given | the larger number of files python attempts to access at startup. | | | Comparing Perl and Python startups on a system: | | SGI Irix 6.5.9m on 128MB 180MHz R5000/SC O2 | | using versions: | | Perl: perl5 (5.0 patchlevel 4 subversion 4) | Python: Python 1.5.2 (#25, Jun 11 1999, 16:45:34) | | examining the startup of the two using 'par' to run the following: | | echo 'print "hi"' | perl | echo 'print "hi"' | python | | I see that between the time libc is dynamically loaded (at about | 6 msecs after the execve()) until the time that perl/python get | down to business (read the echo'd program and write "hi\n"), | there is a _big_ difference between perl and python. | | | Perl: | | In this interval, perl does just the following 13 milliseconds | worth of stuff: | | 6mS sysinfo(_MIPS_SI_PROCESSORS, 0x7fff2d20, 257) = 10 | 7mS open("/usr/lib32/libperl.so.4.4", O_RDONLY, 05) = 4 | 7mS read(4, <...>..., 512) = 512 | 7mS elfmap(4, 0x7fff0f50, 2) = 0x97f0000 | 8mS close(4) OK | 8mS open("/usr/lib32/libm.so", O_RDONLY, 05) = 4 | 8mS read(4, <...>..., 512) = 512 | 8mS elfmap(4, 0x7fff0f50, 2) = 0x94e0000 | 9mS close(4) OK | 10mS syssgi(SGI_TOSSTSAVE) OK | 11mS getpagesize() = 4096 | 11mS brk(0x10015000) OK | 11mS syssgi(SGI_USE_FP_BCOPY, 0, 0x181, -1, 0x180, 0) = 0 | 12mS brk(0x10025000) OK | 13mS getuid() = 2324, euid=2324 | 13mS getuid() = 2324, euid=2324 | 13mS getgid() = 20 egid=20 | 13mS getgid() = 20 egid=20 | 14mS time() = 965078506 | 14mS getcontext(0x7fff29d0) = 0 | 18mS getpid() = 1147056, ppid=1142422 | 19mS ioctl(0, __OLD_TCGETA, 0x7fff0170) errno = 89 | 19mS read(0, "print "hi"\n", 4096) = 11 | | Python: | | In the same interval, python does some 196 milliseconds worth | of stuff, including 52 open attempts, 34 stat attempts, 67 | sigaction calls, 12 fstat's, 20 close's, 27 brk's, ... | | The opens are mostly to open some 10 modules, where | each module open requires about 4 attempts, for spam.so, | spammodule.so, spam.py and spam.pyc. The modules being | loaded are: | | exceptions, site, os, posixpath, stat, UserDict, and | about 4 variants of site-customize (under the main | python1.5 directory, as well as under plat-irix6, lib-tk | and lib-dynload). | | The stat's are for each of these potential modules, plus | looking for the file 'python' in every directory on my | $PATH, plus 4 stats in the subtree "/usr/lib/locale/C". | | Most of the elapsed time, however, does _not_ seem to be in | waiting on the system for the above calls (the file calls | were quick - several per msec - out of cache). Rather most | of the time seems to be cpu bound, just after reading in one | of the modules. Often, some 10-20 msecs go by, marked only | by a close() call or two, such as when python is reading a | couple of nested modules, such as stat and posixpath, and | closes the child module while still plugging away on the | parent. | | The stat() search for the python file along $PATH comes | early (before loading modules) and the sigaction() calls | come just after loading the exceptions module. | | -- | -- | I won't rest till it's the best ... Software Production Engineer | Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From moshez at math.huji.ac.il Tue Jul 25 09:02:15 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 25 Jul 2000 16:02:15 +0300 (IDT) Subject: Python 3000 In-Reply-To: <8lk2kg$kbv$1@nntp9.atl.mindspring.net> Message-ID: On 25 Jul 2000, Aahz Maruch wrote: > Yes, I know about the soap opera. The fact remains that 1.6 will almost > certainly never be a released chunk of code -- it never had a beta! However, it will be released, from CNRI with BeOpen's help. I wouldn't use it, though: just wait one more month for 2.0, which has lots of improvements. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From db3l at fitlinxx.com Fri Jul 28 15:05:49 2000 From: db3l at fitlinxx.com (David Bolen) Date: 28 Jul 2000 15:05:49 -0400 Subject: Perl is worse! References: <75k2osst2eh5nbel73ju033l8s97bs2v0s@4ax.com> Message-ID: grey at despair.rpglink.com (Steve Lamb) writes: > Yes it could, that is why good programmers check their input data before > performing opertions when the data set is not trusted. I'm curious, since you've raised this point a few times now. If this is true, then where is the pain, during this input check, of simply making whatever conversion you need into an object type that you want to use within the program. If you then need it in another context, you know what it is canonically within the program (since you input checked/converted it) and can always request a conversion to the new type at the point of need. It seems to me that it isn't so much that Python doesn't let the object get used as different types, but only that it doesn't try to guess at the conversion necessary. And when do you request a conversion (say with str() to get a string), it's polymorphic - any object can produce a string representation of itself, providing it offers the __str__ function. I suppose one of the cruxes of an issue here is whether or not the more explicit conversion mechanism (note it isn't any less generic, just less automatic) is beneficial or not. I believe it is, even if not for the initial development, then for the maintenance of the program. -- -- 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 johannes at zellner.org Wed Jul 5 16:24:15 2000 From: johannes at zellner.org (Johannes Zellner) Date: Wed, 5 Jul 2000 22:24:15 +0200 (CEST) Subject: readline.c & more Message-ID: Hello, I just compiled python 2 from CVS. ?) I had to modify Objects/fileobject.c because there was a name clash between `getline' there and in /usr/include/stdio.h (as it comes with the latest debian potato). I replaced `getline' with `file_getline' in Objects/fileobject.c. ?) I modified Modules/readline.c so that it allows reading and writing of a history file. I also plan to implement readline functions as `stifle history'. Eventually I'd also add the possiblity to register a script completer which would be called before the builtin completers. My question about this: where would I post patches ? -- I've an account on SF for other projects, but as this is my first mail to the list I'd understand if you won't trust me ;-) ?) Is there a forum for developers? This list seems more for users isn't it ? greetings, -- Johannes From cut_me_out at hotmail.com Fri Jul 7 19:22:12 2000 From: cut_me_out at hotmail.com (Alex) Date: 07 Jul 2000 19:22:12 -0400 Subject: Splitting c.l.py... References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> <20000707140442.B4771@kronos.cnri.reston.va.us> <8k579c$rts$1@slb3.atl.mindspring.net> <20000708002024.K26534@xs4all.nl> Message-ID: > or making it a completely open list, where people 'promise' not to > 'interfere'. I hope we can all agree #2 will not work ;) Somehow, I got on the python-dev list, and I'm doing a pretty good impersonation of #2, so far. Only-takes-one-counterexample...right?'ly Alex. From robin at jessikat.fsnet.co.uk Fri Jul 14 10:46:29 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 14 Jul 2000 15:46:29 +0100 Subject: ReportLab 0.95 Message-ID: ReportLab 0.95 is released. Probably the last release before a 1.0 version. The distribution is available at www.reportlab.com This version of the dynamic PDF generation kit has much improved documentation, better paragraphing, splitting tables and much much more. In the traditional fashion this is being released on a Friday as close to beer time as possible and when all other developers are busy doing other things :) -- Robin Becker From robin at alldunn.com Tue Jul 11 20:59:27 2000 From: robin at alldunn.com (Robin Dunn) Date: Tue, 11 Jul 2000 17:59:27 -0700 Subject: Looking for a tree widget with control of text color References: Message-ID: > > Is there a tree widget for wxPython or TKinter that support setting the text > color (foreground or background) for each node? > The wxTreeCtrl in wxPython can do it. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxpython.org Java give you jitters? http://wxpros.com Relax with wxPython! From nospam at email.com Thu Jul 20 17:07:47 2000 From: nospam at email.com (CB) Date: Thu, 20 Jul 2000 21:07:47 GMT Subject: Checking for end of a file References: <39776623.5B245EF5@roguewave.com> Message-ID: Thanks, works a treat. Colin "Bjorn Pettersen" wrote in message news:39776623.5B245EF5 at roguewave.com... > CB wrote: > > > > If I'm iterating through a text file, reading one line at a time within a > > while statement, how do I check for the end of file. I tried while > > filename.eof and filename.eof() but to no avail? > > > > Colin > > The two standard idioms are: > > f = open(...) > for line in f.readlines(): > > > and > > while 1: > line = f.readline() > if not line: break > > > The second one works by the fact that f.readline() returns '\n' for > empty lines and '' (the empty string, aka false) when reaching the > end-of-file. > > I'm-not-even-going-to-try-to-defend-while-1'ly y'rs > -- bjorn > From thomas at xs4all.nl Mon Jul 3 15:52:56 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 19:52:56 GMT Subject: Bug in math.frexp? References: Message-ID: On Mon, 3 Jul 2000 14:23:08 -0400, Tim Peters wrote: >Guys, this is not open to debate. frexp is a std ANSI C function, Python >calls the platform frexp directly, and the new docstring I checked in is an >exact paraphrase of the std in Pythonic language. I don't care what >manpages say. I *would* care if somebody can show an actual example of a >Python implementation where the examples posted do not work exactly as >shown: that would mean the platform is buggy -- but the new docs are still >correct . Yes, yes, you're right. The posting that started this unnecessary discussion was both wrong and mine (I'm sorry, it was late ;P) but in my defense: I had intended to *mail* it to Fred, but my slrn (again) went on and had a life of its own. What I intended to say was 'the manpages I saw concur with Tim's docstringchange', but it 1) came out wrong, and 2) was wrong -- the manpages are confusingly phrased, just as Fred claimed. I had the best of intentions though ;) Apologizing-ly y'rs, From stephen at cerebralmaelstrom.com Thu Jul 6 15:24:21 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Thu, 06 Jul 2000 19:24:21 GMT Subject: Wait/Delay References: <8k2lhd$5i6$1@gossamer.itmel.bhp.com.au> Message-ID: >>> import time >>> time.sleep(1) There :) --Stephen :) A J Wilson wrote in message news:8k2lhd$5i6$1 at gossamer.itmel.bhp.com.au... > Hi > > Is there a command/function in python to put a delay or wait step into a > program? > > Thanks > Austin > > From nobody at nowhere.nohow.bbs Sun Jul 16 12:10:02 2000 From: nobody at nowhere.nohow.bbs (nobody at nowhere.nohow.bbs) Date: 16 Jul 2000 16:10:02 GMT Subject: help with tkinter coding Message-ID: <3bQSCQ$lve@openbazaar.net> On Sat, 15 Jul 2000 13:54:28 GMT, John Grayson wrote: > >It just happens that one of the sample chapters for Python >and Tkinter Programming is on geometry managers. It might >help you understand how the Packer works... > > http://www.manning.com/Grayson/chapt05.pdf > I highly recommend John's book for somebody new to Tk. It's a well-written book, the examples are complete enough to be useful, and the editting job is first-rate: there are very few mistakes (especailly for a first edition). -- Grant Edwards grante Yow! HAIR TONICS, please!! at visi.com From JoeSmith at bogusaddress.com Mon Jul 17 20:43:18 2000 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Tue, 18 Jul 2000 00:43:18 GMT Subject: NT4 shortcuts and import References: <8koe6q$avh$1@nnrp1.deja.com> <39709fdc@news.server.worldonline.co.uk> Message-ID: <3973A8E8.D937B406@bogusaddress.com> I really was disappointed that NT did not have symbolic links. I find them very usefull. I hear that win 2000 has something called junction points that might be similar. Phil Harris wrote: > You can't do that in NT. > > Shortcuts are not the same as links in *nix. > > Shortcuts are really, next to useless. > > Even most microsoft products don't know what to do with them, try using a > shortcut to a folder in any standard ms product and it will fail in the same > way. > > Phil > > Andy Freeman wrote in message > news:8koe6q$avh$1 at nnrp1.deja.com... > > I'd like to use a shortcut named, say, "src", from the current > > directory to a directory somewhere else and then use "import src.foo". > > The problem is that NT4 thinks that the shortcut is named "src" > > but Python thinks that the shortcut is named "src.lnk". Note that > > I can't use "import src.lnk.foo" because the first "." is interpreted > > as a directory name separator, not a part of the "src.lnk" module > > name. > > > > (1) How do I get Python to use "src" as the module name? > > (2) How do I escape "." in variable names? > > > > I'm using Python 1.5. > > > > thanks, > > -andy > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. From paul at prescod.net Wed Jul 19 12:06:32 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:06:32 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <3hitu4wiq9.fsf@angband.org> <3975C0FA.3A45B105@eecis.udel.edu> Message-ID: <3975D208.2E297375@prescod.net> Charles Boncelet wrote: > > ... > > On my soapbox: As you say, Python "isn't even close to the most popular > tool for its problem domain". And yet, the Python community refuses to > sully the language by adding things that might make it more popular (not > just more operators for numerical work, but stackless for palm pilots, > +=, ++, support for reloadable operators, typechecking, list > comprehensions, more elaborate iterators, to name a few.) There might > be arguments against each of these, but taken together it indicates an > unwillingness to change. Python is perfect as is, and we certainly > don't need to adopt the methods of the unwashed. Python 2 will likely have += and list comprehensions. Typechecking is scheduled for addition once the details are worked out. If Python did not grow slowly and conservatively, I dare say that neither you nor I would be using it today. It would be just another overgrown language that caters to everyone's preferences. Your paragraph implies that Python would be more popular if it attempted to adopt everything that is in popular languages. I think that that is a simplistic view of language evolution. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From bjorn at roguewave.com.bbs Mon Jul 17 12:20:02 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 17 Jul 2000 16:20:02 GMT Subject: Global & Importing issues.... Newbie Message-ID: <3bRI14$kzx@openbazaar.net> Try import __main__ in mod2. Or even better implement the common data in a separate module, perhaps even as a class? -- bjorn Toby wrote: > > I have a simple requirement for a second module to access a global variable > stored in the first (main) module. > > I can reproduce my problem with the following 2 modules... > > Mod1.PY >>> > import Mod2 > > myGlobal = None > > if __name__ == "__main__": > > myGlobal = 100 > > Mod2.DoPrint() > #endif > #endmodule > > Mod2.PY >>> > import Mod1 > > def DoPrint(): > print Mod1.myGlobal > #enddef > #endmodule > > When executing Mod1.PY I expect the answer 100 to be printed out, I get None > > I also get the same problem if there is a function in Mod1 which prints the > value of myGlobal and is called from Mod2 - I think this is the same > problem. > > :o( > > Any help from Python experts ? > > TIA Toby > > -- > http://www.python.org/mailman/listinfo/python-list From gregory.lielens at fft.be Fri Jul 14 05:31:55 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Fri, 14 Jul 2000 11:31:55 +0200 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> Message-ID: <396EDE0B.5F9075B6@fft.be> John Lull wrote: > > At the dawn of the third millenium (by the common reckoning), > hzhu at localhost.localdomain (Huaiyu Zhu) wrote (with possible > deletions): > > > I think cleanness is one of the main virtue of python, but it is lacking in > > numerical computation. To give an example of the difference it makes, I'll > > quote from my original post asking for matrix in python (with corrections) > > > > [in octave we write] > > > b = X\y # LMS solution of a linear equation y = X*b > > > b = (X'*X)\(X'*y) # or written out in more details > > > b = inv(X'*X)*(X'*y) # or in a less efficient form. > > > > > > but the corresponding Python notation is horrendous: > > > > > > b = matrixmultiply(inverse(matrixmultiply(transpose(X), X)), > > > (matrixmultiply(transpose(X), y[:,NewAxis]))) > > I'm don't think this is quite fair. You could just as easily write: > b = rDiv(X, y) > if you simply had an appropriate rDiv() function. It's not nearly as > pretty as octave's notation, but it doesn't have to be nearly as > hideous as your example. Indeed, but it is the old choice between functional/operator notation... For example, the second expression, b = (X'*X)\(X'*y), would be in functional notation something like b=rDiv(Mul(X.T(),X),Mul(X.T(),y)) This is ok, but imho far more error prone than operator notation, because - all linear algebra textbooks present expressions with operator notation - the operator notation is more natural to almost everybody when dealing with arithmetic I personnaly consider that linear algebra is an extension of simple arithmetic, almost on the same level as complex numbers (and usefull to the same kind of people which could use complex numbers). The fact that complex numbers are part of built-in python types and can be manipulated using standard arithmetic operators plead for a similar facility for linear algebra, imho. But contrary to complex numbers, easy manipulation of matrices ideally require more than the usual +,-,*,/, because of the lack of commutativity (therefore the introduction of left and right divide) and the usefullness of both elementwise and matrix operations. Should something a "elementwise" complex multiplication c=a*b=Complex(Real(a)*Real(b),Imag(a)*Imag(b)) (*) have any usage, maybe the initial design of python would have included two multiplication operators... Greg. (*) Please, never implement this horror!!! From matt at null.net Sun Jul 9 19:46:55 2000 From: matt at null.net (Matthew Schinckel) Date: Mon, 10 Jul 2000 09:16:55 +0930 Subject: Parsing lists In-Reply-To: References: Message-ID: On Jul 9, I overheard Seamus Venasse mutter: > >>> list = [ 'title1', 'url1', 'title2', 'url2', 'title3', 'url3' ] > >>> for title, url in list: > ... print title, url > ... > Traceback (innermost last): > File "", line 1, in ? > ValueError: unpack sequence of wrong size You are trying to force each list item to be a 2-tuple Try one of two methods: list = [('title1','url1'), ('title2','url2'), ('title3','url3')] for title,url in list: print title print url or better: dict = {'title1':'url1','title2':'url2','title3':'url3'} for title in dict.keys(): print title print dict[title] -- Matthew Schinckel Expert, n.: Someone who comes from out of town and shows slides. From scarblac-spamtrap at pino.selwerd.nl Mon Jul 17 11:58:58 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 17 Jul 2000 15:58:58 GMT Subject: converting tcl database file to python References: <3970F455.58A6CAD3@uniserve.com> <3971004C.93FEC29F@wam.umd.edu> <3971211C.A2F151FD@uniserve.com> Message-ID: Bob van der Poel wrote in comp.lang.python: > Bob Schmertz wrote: > > Did you consider a CdItem class? > > No. I've looked at them but the one thing that bothered me is that > after defining a class (aka structure) one is free to add variables a > will. But the same is true for dictionaries and lists anyway... Why do you think it will be a problem? Are you going to add harmful things (like what?) in your sleep? ;-) Imo, if you have a problem defining a structure and it's more complex than a simple list or dictionary, it's time to write a class. > Yes. started a bit this PM. I think that what I'll do is write a > conversion in tcl and end up with a very-verbose datafile format. With > PentiumIIs who cares about a few extra cycles of overhead parsing a > file. I've just gotta get into the 21th century. Or let the program write its output as Python style expressions, so you can eval them again like the Tcl did :-) -- Remco Gerlich, scarblac at pino.selwerd.nl 5:57pm up 133 days, 6:07, 6 users, load average: 0.53, 0.33, 0.13 From fig at oreilly.com Fri Jul 14 19:26:08 2000 From: fig at oreilly.com (Stephen R. Figgins) Date: Fri, 14 Jul 2000 23:26:08 GMT Subject: OSCON dinner? (Thurs 7/20) References: <8kncs1$j2f$1@slb7.atl.mindspring.net> Message-ID: <396FA1CC.A11398F5@oreilly.com> I would love to do dinner, but was planning on heading back Thursday evening. Unless someone wishes to give me a ride back to Sebastopol, CA Thursday night, I won't be able to make it. Stephen Figgins fig at oreilly.com From aahz at netcom.com Tue Jul 25 08:33:18 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Jul 2000 12:33:18 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> Message-ID: <8lk1ee$71q$1@slb6.atl.mindspring.net> In article , Neil Hodgson wrote: > > Your version numbering is a little out of date - 1.6 will be released in >the near future with some quite useful Unicode support, then 2.0 with some >unnecessary features soon after that. 2.0 is called 2.0 to help with >marketing although the sweet spot with version number marketing is 3.11 so >some more unnecessary features will be required soon :-) Your version numbers are also a little bit out of date. 1.6 has been renamed to 2.0 with the departure of the core Python team from CNRI to BeOpen. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From zsoltman at my-deja.com Mon Jul 10 23:34:43 2000 From: zsoltman at my-deja.com (zsoltman at my-deja.com) Date: Tue, 11 Jul 2000 03:34:43 GMT Subject: Compiling Python References: Message-ID: <8ke4ki$pet$1@nnrp1.deja.com> In article , "David L. Heald Jr." wrote: > Does anyone know if there is a compiler available anywhere for python for > win32? > > I'm guessing http://www.python.org/download/download_win31.html would do the trick Sent via Deja.com http://www.deja.com/ Before you buy. From peter at wl.vg Wed Jul 5 08:32:59 2000 From: peter at wl.vg (Peter Halliday) Date: Wed, 05 Jul 2000 08:32:59 -0400 Subject: Redhat and mod_python Message-ID: <39632AFB.8BB36365@wl.vg> I am trying to get mod_python working with Apache's rpm's. I really don't want to have to compile Apache separately. Has anyone got mod_python working under Redhat while keeping the Apache rpms. Thank you. And please if possible could you email your response to my email above (peter at whetstonelogic.com). Thanks. -- Peter Halliday Online Application Developer Whetstone Logic, Inc. http://www.whetstonelogic.com icq#75769411 AIM screen name: hoaggelos From pj at sgi.com Sat Jul 29 00:10:25 2000 From: pj at sgi.com (Paul Jackson) Date: 29 Jul 2000 04:10:25 GMT Subject: Perl is worse! References: Message-ID: <8ltlfh$ae55f$1@fido.engr.sgi.com> Steve wrote: |> what of 1 + "1"? That isn't senseless, those are two numbers. |> I can see they are two numbers, it is only because of typing |> that it fails. No. 1 + "1" is a pointer to the nul following the ascii '1' in the nul-terminated string "1". pretending-to-be-a-pure-C-programmer'ly-yours ... -- -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From gparlor at my-deja.com Mon Jul 24 23:51:42 2000 From: gparlor at my-deja.com (gparlor at my-deja.com) Date: Tue, 25 Jul 2000 03:51:42 GMT Subject: Does Python support interfaces? References: <8l1org$a94$1@nntp9.atl.mindspring.net> Message-ID: <8lj2sd$qqf$1@nnrp1.deja.com> In article <8l1org$a94 $1 at nntp9.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article , > Randall Parker wrote: > > > >I'm quite new to Python. For those who are familiar with Java interfaces: > >Does Python have a similar facility? > > > >Can one declare interfaces, then declare that a class implements some > >interface, instantiate an object of that class type, and then cast it to > >an interface that it is declared to support and then pass it around as a > >reference to that interface type and make calls to methods of that > >interface type? > > Let me expand on Justin's post: > > Interfaces are *everything* in Python; you use inheritance only when you > want to borrow behavior from an existing class. If I create a base > class called MyFileType and implemented all the standard methods and > attributes, Python would literally not notice that I was using a brand > new class as a file object. All the standard Python operations would > just work. No casting, no subclassing. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > Q: In a lesbian relationship, who decides who gets to be the man? > A: It's two women. There is no man. That's the point. > Q: then who gets blamed when everything goes to hell? Sent via Deja.com http://www.deja.com/ Before you buy. From weeks at golden.dtc.hp.com Wed Jul 26 11:51:16 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 26 Jul 2000 15:51:16 GMT Subject: conatraints on "for" magic? References: <8llqso$q75$1@news.dtc.hp.com> <8lm2k202c2i@news1.newsguy.com> Message-ID: <8ln1dk$59e$1@news.dtc.hp.com> Alex Martelli (alex at magenta.com) wrote: : I believe you are correct in noticing that nowhere is it : clarified that this is the specific method used by the for statement, : and that IndexError is the way __getitem__ tells the for statement : that the sequence is finished Well, thank *you* for the clarification. It is interesting to note that if I were to define a sequence type that was index-one-based, the for loop would consider it empty. Regards, Greg From see at below Sun Jul 30 22:27:24 2000 From: see at below (Paul Foley) Date: 31 Jul 2000 14:27:24 +1200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8m25dm$ila$1@newshost.accu.uu.nl> Message-ID: On Mon, 31 Jul 2000 00:46:17 GMT, Steve Lamb wrote: > On 30 Jul 2000 21:07:02 GMT, Martijn Faassen wrote: >> Ahum, the latter isn't really possible in Python. Your integer wil never >> ever be converted to a noninteger. > Yes it will. int(), str(), etc, etc, etc... I never said the language > converted it, I just said it was converted and Python certainly does that. To me, at least, "convert" gives the impression that the value is being changed into something else. That never actually happens. int(), str(), etc., don't change anything, they just make a new object somehow based on the old. >> 1 isn't mutable into anything at all either, by the way. Neither are >> strings. The name 'b' can however be made to point to something else. >> That is an entirely different thing though, and from the way you're >> speaking I'm not entirely clear whether you understand this yet. > OK, to be strict. None can't be converted, neither can 1. For some Neither can anything else, in the sense that "converted" means "changed". Certainly None or 1 or anything else can be "converted" in the same way that int(x) "converts" strings into an integers. E.g., def convert(x): return x or 42 now convert(None) "converts" None into 42, proving once and for all that "None can be converted". Are you claiming there's somehow a difference between my convert() function above and the builtin int() function? > reason, however, b, which was pointing to 1 can be made to point to something > else which we'll call the integer formerly known as 1 where as None things > cannot be repointed from. None is like that really nasy uncle everone has who Nonsense. b = 1 b = "foo" now b is the string "foo". b = None and now b is None, but type b = "foo" and what do you know, b is "foo" again, contrary to your claim that "None things cannot be repointed from". [I don't think I have a nasy uncle...maybe a nosy neighbor...] -- Nomina stultorum in parietibus et portis semper videmus. -- Cicero (setq reply-to (concatenate 'string "Paul Foley " "")) From mhaselup at clicktomarket.com Wed Jul 12 18:19:57 2000 From: mhaselup at clicktomarket.com (Mark Haselup) Date: Wed, 12 Jul 2000 15:19:57 -0700 Subject: Application testing Message-ID: <8ktcnr$q69$1@bob.news.rcn.net> I need to carry out some testing of a cgi application from a Browser client. I have been informed that I can use Python (or some of it's extensions) to capture and replay the http traffic between the Browser and the Webserver to simulate a user session. Unfortunately I've not been able to find any information on this usage in the books I've looked at so far. I am also interested in any other applications free or otherwise which would allow me to do this. I would like to be able to capture the traffic and edit it to allow modified replays of sessions. Can anbody help with this? Should I be looking at other news groups for these features? Thanks. From moshez at math.huji.ac.il Wed Jul 26 01:03:14 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 26 Jul 2000 08:03:14 +0300 (IDT) Subject: Reading a file In-Reply-To: Message-ID: On 25 Jul 2000, Tim Northover wrote: > I'm attempting to read a file line by line with readline(), but it > seems to return and empty string when EOF is encountered. Is there a > way of discerning the difference between the end of the file and a > blank line in the file? Yes. A blank line is '\n', not '' -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From paul at prescod.net.bbs Mon Jul 17 01:10:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 05:10:02 GMT Subject: Type checking in python? Message-ID: <3bR0RQ$iTr@openbazaar.net> Matthew Cline wrote: > > ... > > Is there any plans on doing this for Python 3000? Or will something > like this never be a part of Python? There is a whole special interest group with dozens of members set up to discuss this issue. Nevertheless, its more complicated than you can imagine and progress is slow. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From lull at acm.org Thu Jul 13 22:33:03 2000 From: lull at acm.org (John Lull) Date: 13 Jul 2000 21:33:03 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> Message-ID: <72usms41js8gtqdeemi0l7qo7dfe0t02rm@4ax.com> At the dawn of the third millenium (by the common reckoning), Bjorn Pettersen wrote (with possible deletions): > It seems like you're trying to create a special purpose language here. > Ie. I don't see it as general enough to be worth putting into the core > unless you can come up with other use cases... Personally, I would much > prefer the ability to overload the relational operators (individually, > not through __cmp__). I'd like to disagree here. Matrices & linear algebra are fundamental tools in an extremely broad set of domains. Unfortunately, most programming languages don't seem to recognize that. Providing appropriate operators in the core is, IMO, as appropriate as providing complex numbers. Providing an easy way to effectively add them to the core when you install an appropriate add-on package is a reasonable alternative. Their absence leads to really hard-to-read code, and to me is a significant downside to Python. Regards, John From akuchlin at mems-exchange.org Wed Jul 5 10:34:19 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Jul 2000 10:34:19 -0400 Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> <39615d75.142572338@news> <8jtcid$4um$1@nntp9.atl.mindspring.net> Message-ID: <3dhfa4lk7o.fsf@kronos.cnri.reston.va.us> "Andrew Dalke" writes: > What I saw, though, was a compile time option to use /dev/random if > it exists. I would have thought that would be enabled by default, but > it made some comment about how the read will block if there isn't enough > entropy in the source pool. Is this ever a problem in real life? Yes, because the entropy pool is only 4096 bits, and entropy is added fairly slowly, since an interrupt or other event only adds a few bits of entropy. A different device, /dev/urandom, never blocks, so you can read enough data to theoretically compute the initial state of the pool. For generating a long-term thing like an RSA key, this would matter (or least be psychologically unsettling); for an IV, I think /dev/urandom would be fine. --amk From neilh at scintilla.org Tue Jul 11 00:30:28 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 11 Jul 2000 04:30:28 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> Message-ID: Now that Microsoft have revealed their Intermediate Language (IL) virtual machine, are we going to see a version of Python that compiles directly to IL? Or will Python byte codes still be interpreted by C code? Neil From scarblac-spamtrap at pino.selwerd.nl Tue Jul 25 07:30:24 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 25 Jul 2000 11:30:24 GMT Subject: SIMPLE QUESTION References: <397D77D1.A331770A@sicon.net> Message-ID: sergio wrote in comp.lang.python: > Hi all > I''ve imported a dll into a .py file, but when i try to use a > function i get the error > > Traceback (innermost last): > File "", line 0, in ? > TypeError: unbound method must be called with class instance 1st > argument > > > The question is , how can i get the "class instance", or maybe i have to > pass a string with the name of the class on the first argument. > > Thanks in advance for all your responses You are calling a method directly on a class, instead of making an instance of the class, and calling the method on that. Ie, class Example: def test(): pass Now Example.test() gives your error, and e = Example() e.test() works. Can't say more without more info about what you're doing. -- Remco Gerlich, scarblac at pino.selwerd.nl Murphy's Rules, "Atomic TNT?": In Aftermath (FGU), a one-ton charge of high explosive will kill nearly every living thing in 300 square kilometers. From ramb at synopsys.com Mon Jul 31 11:33:25 2000 From: ramb at synopsys.com (ramb at synopsys.com) Date: 31 Jul 2000 08:33:25 -0700 Subject: looking for python object debugging hints Message-ID: <87og3es4ai.fsf@oak.gitaram.com> I've written some code to implement a new python object and I'm having some trouble with it. My code to implement the new object is written both in C and in Python. Here is the situation: A python script imports my module and then starts calling various functions in my C shared library. The problem is that if I use gdb on the python binary my shared library is not loaded until the script starts running and that is too late to set a break point. What I want is some way to make it easy to use a debugger to debug my dynamically loaded shared library. Here are some of the ideas I have: 1. Build a statically linked Python executable and completely avoid the whole problem. 2. Modify my shared library so that once it is loaded into the python process the shared library will cause the python process to stop until the debugger attachs to the python process. 3. Invoke the debugger (as a separate process) from the shared library that is loaded into the python process. 4. Use sleep or some other method to slow down the execution of the shared library. I know how to do 1 and I'm pretty sure I could do 3 via some combination of system() calls. What I really want is option 2. But I'm not sure how to do that. Option 4 would also be easy, but it strikes me as ugly, and I'd rather use a solution that has atleast some amount of elegance to it. Does anyone know how (under unix) to make a process stop and wait until a debugger attaches to the process? Alternatively if you have another way to solve this problem it would be great to hear about it. Thanks for any ideas. -Ram From bill at dehora.fsnet.co.uk Fri Jul 28 19:07:55 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Sat, 29 Jul 2000 00:07:55 +0100 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> Message-ID: <8lt3pn$bgg$4@newsg4.svr.pol.co.uk> > Most, not all. Again, I ask, as a /human/. Not as a computer, > calculator, dog, fish, pet rock, face on mars, some gas creature in > delta-theta 3 (word up, gass monster) or almond, is 1 a character a string an > integer a floating point number or what? What would you like it to be? Types formally came about to avoid such confusions. What's the big deal about typing? From aek at aek.dk Sun Jul 16 16:39:10 2000 From: aek at aek.dk (Anders Eggers-Krag) Date: Sun, 16 Jul 2000 22:39:10 +0200 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> Message-ID: <43pc5.394$uj.2466@news101.telia.com> > > It is a typical god side of an MS product, total integration with total > > benfit, a pitty thought that the interface is less good than Borland's... > > I can't say I have used anything of Borland since BC 4.5, I think. I have > seen cool features in some GUI builders and IDEs that aren't in VB6, so I > have an idea of what you are talking about. "Boa Constructor" > http://boa-constructor.sourceforge.net/ ), an IDE for Python seems to make > a good effort to implement features typical of recent technologies, although > it is still in "Pre-Alpha" but very promising. ill take a look at it, although my guess is that I will stick with Ultra Edit until I get around to making my own editor > > Another solution is to be really smart and figure the flow of the > > program and determine when a variable is first used and color that > > color1 and the next time it is used it is colored color2... > > I think this [figure the flow of the program] is what VC6 attemps to do with > C/C++ code (and that's a pretty expensive calculation) and it's a pity the > compiler will [most likely] just end up re-doing the work when you hit > "Build", as opposed to something totally integrated like VB... Agreed VB has an advantage there > > > Where the variables are declared in the form of a comment that starts > with > > > the letters "var" which, I think, is how JavaScript declares variables, > > > isn't it? > > it is said the man who knew the language inside out :-) > > I'm sorry, I don't follow... I was just showing off :-) saying yes var is the way you do it, when you do it in JavaScript/JScript, and at the same time saying that I know JScript inside out > > > So, by having a line at the beginning of a function (right after > > > the description line, which I hope I didn't screw up) indicating the > names > > > of the variables we intend to use, any name that isn't in that list and > > > isn't in anything we imported would be highlighted as a mistake, and if > only > > > the case differs, the editor would make the case match the > declaration... > > The only problem is that it turns Python ugly... > > Does it? Wouldn't it help whoever was reading your code to better > understand where the scope of the variables are, and what you intend to do? > I'm reminded of assembler, where it is good practice to comment which > registers you will be "destroying" and which you will be using. It saves > someone from looking at each line of code to figure it out.... It may make it a bit easier to see such things, but in general you should make everything clear through propper naming... It puts some extra information in a not too beautiful way, a lot like C++ does in the millions of hearder files etc. Python is intendet to be a language where you don't have to know a lot of syntactical extras... > > I know it is a problem, I will however try to enforce it in our > > concern, and one might design a devoloping tool that enforced a > > naming convention, that could be dfined by the user. > > ...or a variable declaration convention defined by the user??? : ) You > wouldn't HAVE to use the "# var", maybe you're like me and you come from a > VB background and you'd rather use "# dim"? well personally I am a C/C++/Java/JScript/Python person, and I don't mind so much whether it be dim, var, whatever, but I mind having to feed my editor additional information... > > Once you get used to it it really isn't much of a worry > > I realized today my version of PythonWin (125) wasn't recommended as being > the one to use for auto-completion and other nice features, so maybe it > already does everything I want it to and my whole rant is moot?? I didn't > think PythonWin was as nice as SciTe, in terms of syntax highlighting, so I > switched, but now that I look at PythonWin 132, I'm impressed! Maybe I *do* > have everything I want. yes the 125 wasn't much fun - I haven't looked at 132 yet, I have been busy developing a major online consumer database in ASP/Jscript, I actually considdered using Python but I couldn't figure out how to set the values Session and Application Objects... > > there is only one thing in this world that makes me wonder: why are all > > the beautiful languages run time parsed? (i here think primarily on > > Python and Java) > > Only ONE thing? Wow. You must know the answer to life, the universe and > everything, then? And the question, too? If it were up to me, this > language would have been called "42"... aye one thing only - and of course I know the question, isn't that what we earthlings are here for? ;-) ok there is one more neglegible thing that I wonder about wommen :-) -- Anders Eggers - Krag From hzhu at localhost.localdomain.bbs Mon Jul 17 20:40:02 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 18 Jul 2000 00:40:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRV24$jbb@openbazaar.net> On Mon, 17 Jul 2000 18:11:13 -0500, Paul Prescod wrote: > There are even techniques for making your >language work on the interpreter line. We can help with that. Where is this? Is it also included in the references you mentioned? I don't have time or expertise to examine these, but someone else might. Huaiyu From aahz at netcom.com Mon Jul 31 13:37:56 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 17:37:56 GMT Subject: Readline module? References: <8m3t1n$p0h$1@nnrp1.deja.com> Message-ID: <8m4dhk$tf4$1@slb6.atl.mindspring.net> In article <8m3t1n$p0h$1 at nnrp1.deja.com>, wrote: > >I'd like to use the readline module in a python script running on Linux. > Our sys admin just updated our version of Python to 1.5.2, but the >readline module isn't there. What's particularly wierd is that >rlcomplete _is_ there: The problem is that readline isn't a "module" in the sense of being a Python script. It's an executable extension and needs to be compiled. Have your sysadmin look in the documentation on building Python with readline enabled. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From s2mdalle at titan.vcu.edu Thu Jul 27 19:45:35 2000 From: s2mdalle at titan.vcu.edu (David Allen) Date: Thu, 27 Jul 2000 18:45:35 -0500 Subject: javadoc equivalent for python? References: <3980AA2F.4E4E6E1F@seas.upenn.edu> Message-ID: <8lqhhb$omq$2@bob.news.rcn.net> In article <3980AA2F.4E4E6E1F at seas.upenn.edu>, David White wrote: > Hi all, > > Is there an equivalent python application to javadoc? > > thanks, david If you search for something like "source code documentation" on freshmeat.net, you'll find about 4 different multi-lingual packages for this type of stuff. I don't know if any of them specifically support python because of the whole '#' commenting stuff, (most like the /* comment */ syntax) but it's worth looking over there, since it's likely some perl monkey has written something like that for perl code. :) -- David Allen http://opop.nols.com/ ---------------------------------------- Yogi Berra, upon hearing his wife say she had been to see "Doctor Zhivago," said, "What's the matter with you _now_?" From nobody at nowhere.nohow Sun Jul 30 16:10:43 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 30 Jul 2000 20:10:43 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> <39846ECC.DF5FE175@san.rr.com> Message-ID: In article <39846ECC.DF5FE175 at san.rr.com>, Courageous wrote: > >> >This is a conceptualization issue, and I suspect to a degree, >> >false. If "x" is merely a label, one can imagine x labeling >> >3 or x labelling red quite easily. Your analogy works because >> >you carefully framed it, but there's nothing at all to say that >> >your framing of it was right. >> > >> >To the contrary; while I can't prove it, I do believe it's wrong. >> >> Nobody expects a proof, but a just-as-carefully-framed >> counter-analogy would be a good start... > >I don't know why I'd need a carefully framed analogy at all. >The labelling concept speaks for itself, and in fact is the >way that some people teach python. It seems to be quite >intuitive. I'm sorry, but I have no idea if you're agreeing or disagreeing with me. Are you claiming that in real life the operations you can perform on/with a physical object are not determined by the type of the object? -- Grant Edwards grante Yow! BARRY... That was at the most HEART-WARMING visi.com rendition of "I DID IT MYWAY" I've ever heard!! From donn at oz.net Fri Jul 28 00:32:10 2000 From: donn at oz.net (Donn Cave) Date: 28 Jul 2000 04:32:10 GMT Subject: Socket question: arbitrary port References: <8F7EB13BAbeablebeable@209.155.56.81> <39805D19.C005F16F@hotmail.com> Message-ID: <8lr2ca$r7r$1@216.39.151.169> Quoth mmorris at mindspring.com (Mitchell Morris): ... | Contrary to your reasoning, you only need bind *OR* connect. If you're | going to listen, you bind. If you're not going to listen, you connect. ... If you look through his post again, I expect you will see the same "or" wording. The original poster was unclear about what was intended, and I suspect that's the only reason connect() was brought into it at all. Donn Cave, donn at oz.net From neo_brave at my-deja.com Mon Jul 3 00:11:49 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Mon, 03 Jul 2000 04:11:49 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> Message-ID: <8jp3pt$q7j$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > Under Windows NT or Win2k, you can use the PATHEXT environment > variable. Simply add ".py" to the semi-colon sep'd list of > extensions, and off you go! Great, thats a help for NT, but I also want to do this on Win98 :-). > No solution I am aware of for 95, although there are some tricks > you can pull (Im sure someone else will fill these in for you)! Anyone??? Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From Martin.Kew at vsl.com.au Mon Jul 3 01:27:11 2000 From: Martin.Kew at vsl.com.au (Martin Kew) Date: Mon, 03 Jul 2000 14:57:11 +0930 Subject: Aspect-oriented Python? In-Reply-To: <8jg821$vll$1@gaia.cdg.acriter.nl> Message-ID: <4.2.0.58.20000703140633.00be3c30@imaphost> After seeing the following email, I investigated the Aspect Oriented Programing (AOP) as well. I to think that the Python language people should have a look at it. In summary an "Aspect" is a property/function of a system that cannot be cleanly encapsulated by a traditional programming language, for example: a) loop fusion and resource sharing for procedural algorithmic code, b) network traffic minimization, synchronization handling and error handling for distributed client/server systems. An aspect is captured using an "aspect language" in terms of "crosscuts" which are the connection points into the traditional program. ie. the loop construct for a loop fusion aspect. An AOP implementation of a system consists of: a) using a traditional language (called a component language) define and program the components of the system, ie. procedures, objects etc. Call it a "component program". b) using an aspect language define all aspects that will be applied in the system in terms of "cross-cuts". c) "weave" all "aspects" into the "component program" using an "aspect weaver" compiler to form a tangled "aspect program". For example, for the fusion of loops in an image processing system, there was a (35213-756)/352 = 98 reduction in code bloat for the incorporation of loop fusion. raw component program (LOC) ie. without loop fusion = 756 hand implemented code incorporating loop fusion (LOC) = 35213 all aspect programs (LOC) = 352 This information was unashamably paraphrased from "Aspect-Oriented Programming" G Kiczales et.all of Xerox PARC in "European Conference on OO Programming" June 1997 available a www.aspectj.org The reason for presenting this overview was the overwelming lack of interest in the first email by Cees de Groot. At 09:29 pm 29/06/00 +0200, you wrote: >I've been reading on aspect-oriented programming a bit, and it sounds really >interesting. A Java implementation, AspectJ (www.aspectj.org) looks promising, >but has the drawback that it only supports static weaving (wouldn't know >how to do dynamic weaving with Java, so it's not a big surprise). > >With Python, experimenting with aspect-oriented stuff would probably be >way easier, because it is easy enough to replace class methods etcetera. I've >tried Google, but didn't find anything. Is someone busy with aspect-oriented >programming for Python? > >-- >Cees de Groot http://www.cdegroot.com >GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B >Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ >-- >http://www.python.org/mailman/listinfo/python-list From olivierS.dagenaisP at canadaA.comM Sat Jul 1 18:52:38 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 01 Jul 2000 22:52:38 GMT Subject: writing in gif format References: <8jgamf$rli$1@nnrp1.deja.com> Message-ID: I do believe this is why the PNG file format was invented. It supports true color and alpha, too, as opposed to the 256-color GIF... http://www.libpng.org I'm new to Python, so I don't know, yet, if there are Python bindings for it.... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Suchandra Thapa" wrote in message news:slrn8lpr8j.47q.ssthapa at ntcs-ip48.uchicago.edu... > Keith Murphy wrote: > >does anyone know how to write in gif format. I am using the PhotoImage > >class, not the Python Imaging Library. Python tells me "TclError: image > >file format "gif" has no file writing capability" > > I believe that there are some patent issues involved in this. > Unisys holds the patents for using LZW compression in gif files so > you would need to pay Unisys royalties for makng apps that write gif > files. > > > -- > ------------------------------------------------------------------ > > Suchandra S. Thapa > s-thapa at uchicago.edu > > ------------------------------------------------------------------ From morganea at bellatlantic.net Thu Jul 6 18:08:27 2000 From: morganea at bellatlantic.net (Michel Orengo) Date: Thu, 06 Jul 2000 22:08:27 GMT Subject: Win32com curiousity #2: PythonWin code completion References: <8k2q2c$fg2$1@nnrp1.deja.com> Message-ID: When you run makepy, you actually create a file (see in python\win32com\gen_py) that defines the ADO classes and their methods/properties (that is true for any other COM classes you run makepy on). The Dispatch is smart enough to get this file instead of a dynamic loading. This is why you were able to see all methods/properties after running makepy. Also, because you use Fields, MoveNext and Open as methods on the 'rs' instance, PythonWin used them when constructing its class browser...and therefore the list of attributes you find in the list for code completion. Michel wrote in message news:8k2q2c$fg2$1 at nnrp1.deja.com... > When I first start PythonWin, the code completion feature seems to only > partially function, until I save the source file at least once. This is > when opening an existing source file, and after I have run makepy on > the ADO libraries. For example, in a program with a recordset defines > with: > > rs = win32com.client.Dispatch('ADODB.Recordset') > > typing 'rs.' brings up a partial list of methods/properties - Fields, > MoveNext, Open > > After saving the program, 'rs.' brings up the entire expected list. > Interestingly, the 3 keywords above are method/properties that already > exist in preceeding code. > > Am I missing a configuration step? > > > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From paul at prescod.net Fri Jul 7 13:46:04 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 07 Jul 2000 12:46:04 -0500 Subject: Namespace Mystery (HELP!) References: <39655351.9EE499F2@sunesis-pharma.com> <39656345.86AADA8A@prescod.net> <39660D24.63BE61D3@sunesis-pharma.com> Message-ID: <3966175B.B8975186@prescod.net> "Warren L. DeLano" wrote: > > ... > > Okay, we now know why B doesn't work, but why is it that A doesn't work as > well? Dunno. :( I'm surprised that raw "exec" can modify local variables but then I never use it. I'm one of those anti-exec purists. > There is a workaround: > > def fn(code): > a = 1 > b = 1 > my_locals = locals() > exec code in my_globals,my_locals > return my_locals['a']+my_locals['b'] > > which is clearly awkward if you need to do anything more complex with a and > b... How about: def fn(code): a = 1 b = 1 my_locals = locals() exec code in my_globals,my_locals a,b=my_locals['a'],my_locals['b'] *** do whatever you want with a and b *** exec-based approaches always seem messy to me. I would make code a function, specify what inputs it should expect and what it outputs. If it is really wide open, then you could do this: def fn( code_func ): a=1 b=1 arg={} arg.update( locals() ) arg.update( globals() ) out = code_func( arg ) a,b=out[a],out[b] But exec wouldn't exist if it were not sometimes the right approach... -- Paul Prescod - Not encumbered by corporate consensus Pop stars come and pop stars go, but amid all this change there is one eternal truth: Whenever Bob Dylan writes a song about a guy, the guy is guilty as sin. - http://www.nj.com/page1/ledger/e2efc7.html From neilh at scintilla.org.bbs Mon Jul 17 20:50:01 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 18 Jul 2000 00:50:01 GMT Subject: automatically filling web forms? Message-ID: <3bRVEP$kzl@openbazaar.net> > Still, have some questions though. Another cgi script that I'm trying to > write to doesn't work. > The python program hangs and just waits until I terminate it. Any idea. Its a good idea to read http://www.webtechniques.com/archives/1998/02/kuchling/ the techique given for ensuring you see tracebacks is very useful. Neil From wilson.austin.aj at bhp.com.au Sat Jul 22 16:32:30 2000 From: wilson.austin.aj at bhp.com.au (A J Wilson) Date: Sun, 23 Jul 2000 06:32:30 +1000 Subject: wxPython and jPython Message-ID: <8ld08k$h5s$1@gossamer.itmel.bhp.com.au> Hi Is it possible to use wxPython under jPython? The reason I wish to do so is that I have a java-based API that I wish to use under jpython but do not wish to go to the trouble of learning AWT or SWING for the GUI. Thanks Austin From mnot at pobox.com Sat Jul 15 01:23:43 2000 From: mnot at pobox.com (Mark Nottingham) Date: Fri, 14 Jul 2000 22:23:43 -0700 Subject: ANN: cgi_buffer-0.2 Message-ID: <20000714222341.A761@mnot.net> cgi_buffer is a group of libraries that may be used to improve performance of CGI scripts (and other content generation engines) in some circumstances, by applying performance-enhancing HTTP mechanisms that are typically not supported by them. Currently, Perl, Python and PHP are supported. The Python library may also be used as a wrapper around another CGI script. Version 0.2 makes several changes, both in functionality and to fix bugs. Also, PHP and Perl support are introduced. Please note that this software is of Alpha quality. http://www.mnot.net/cgi_buffer/ -- Mark Nottingham http://www.mnot.net/ From dag at orion.no Sun Jul 9 20:21:55 2000 From: dag at orion.no (Dag Sunde) Date: Mon, 10 Jul 2000 00:21:55 GMT Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> <4p%95.10247$A06.1298430@pouncer.easynews.com> <8ka7cd$c3$1@supernews.com> Message-ID: It got 2 from the implicit "self" parameter that all classes in python is called with... So what effectively is sendt in your call is: print DBRec(self, 0).Value But what puzzles me is that your code is running for me... (With ths AddrBook.mdb sample-database)... Dag. "Dale Strickland-Clark" wrote in message news:8ka7cd$c3$1 at supernews.com... > Thanks for all replies. I've now read the chapter in Python Programming on > Win32 and am somewhat the wiser. > > However, I am confused as to why it seems to break this very simple program > after running Makepy on "Microsoft ActiveX Data Objects 2.5 Library". > > At the print statemtent, I get this: > > print DBRec(0).Value > TypeError: too many arguments; expected 1, got 2 > > Where did it get 2 from? > > ------------------------ > import win32com.client > > DBCon = win32com.client.Dispatch("ADODB.Connection") > DBRec = win32com.client.Dispatch("ADODB.Recordset") > DBRec.CursorLocation = 3 # adUseClient = 3 > > sDB = "s:\\ths\\merlin.mdb" > > DBCon.Open("Driver={Microsoft Access Driver (*.MDB)}; DBQ=" + sDB) > #DBRec.open("House", DBCon, adOpenStatic, adLockOptimistic, adCmdTable) > DBRec.Open("House", DBCon, 3, 3, 2) > > DBRec.AddNew() > DBRec.Fields("Price").Value = 234000 > DBRec.Update() > print DBRec(0).Value > > DBRec = None > DBCon = None > ---------------------------- > > Thanks for any help > > Dale Strickland-Clark > > > "Roger Upole" wrote in message > news:4p%95.10247$A06.1298430 at pouncer.easynews.com... > > It should speed up your COM calls. Also, you can browse thru the > > generated file and see all the properties and methods of the COM > > object. > > Once the object has been created, the constants will be available as > > win32com.client.constants.someconstantname. > > There is a Readme.html in the /win32com directory, and more documentation > in > > /win32com/HTML/QuickStartClientCom.html. > > HTH > > Roger Upole > > > > "News.tele2.co.uk" wrote in message > > news:8k9o91$7b1$1 at supernews.com... > > > Well I've run it and it seemed to work but I'm not really sure what to > do > > > next. > > > > > > In fact, I'm not entirely sure what it's supposed to do for me but I'm > > > hoping it will at least give me access to some COM object constants. > > > > > > Where is it documented? > > > > > > Thanks > > > > > > Dale Strickland-Clark > > > > > > > > > > > > > > > > > > From sgjjwr at mnet.com Mon Jul 10 11:26:11 2000 From: sgjjwr at mnet.com (sgjjwr at mnet.com) Date: 10 Jul 2000 15:26:11 GMT Subject: Do somethin uselfull 7170 Message-ID: <8kcpuj$fr2$302@news.brutele.be> For all you out there in the big black cyberspace: Have you ever thought that you are wasting processor cycles when your screensaver turns on, have you ever felt the need to parcicipate in something big (and while you are at it: usefull), need an idea on what to do with your old computer ? Well I have the solution. Two new projects are underway. Check them out at http://come.to/proctimes From grey at despair.rpglink.com Wed Jul 26 20:32:37 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 00:32:37 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: On Wed, 26 Jul 2000 19:38:55 -0500, Guido van Rossum wrote: >The announcement is waiting for final negotiations about GPL >compatibility of the new license; BeOpen's CTO, Bob Weiner, is >confident that the issue will be resolved one way or another by >Friday. Stupid question: Why is it everyone and their mother is coming out with a new open source license for their project instead of sticking with the established ones? I mean, it causes headaches trying to keep all of the licenses legally compatible with one another which can cause problems for open source down the road when these licenses are actually put to the legal test. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From mas at echo.fr.bbs Wed Jul 12 12:50:04 2000 From: mas at echo.fr.bbs (mas at echo.fr.bbs) Date: 12 Jul 2000 16:50:04 GMT Subject: Freeing the memory in Gtk? Message-ID: <3bNNET$m9s@openbazaar.net> Hello, I've been using Glade and libglade for some days, and I like it so much I'm probably going to do my next big thing with it. Except I have a problem, which follows. Suppose we have a GtkList, which is empty at first. Now suppose we fill it somewhat, inserting GtkListItem's into it. Good, it works. Now suppose we want to change the contents of this list, by removing the items from it and inserting new ones into it. How do I free the memory allocated for the old items? I mean, I know I'm in Python, and I know I shouldn't worry about that, but my process grows and grows. Too much for me not to worry. Code snippet: ----- from gtk import * from gnome.ui import * from GDK import * from libglade import * import time def init (): global wtree_app, list, pb, centry wtree_app = GladeXML (gf, "app") list = wtree_app.get_widget ("list1") [...] [a callback function] def chercher_site (obj): global id, list, pb, centry t = centry.get_text () chd = {} list = wtree_app.get_widget ("list1") ## l = list.children () ## for i in l: ## i.destroy () ## list.remove_items (l) list.clear_items (0, -1) i = 0 nb = 100 pb.set_progress (0) for i in range (nb): id = id + 1 li = GtkListItem (label=t + ' - ' + str (i)) sites [li._o] = { 'id': id, 'label': t } li.show () list.show () list.append_items ([li]) pb.set_progress ((i + 1.0) / nb) ## while events_pending (): ## mainiteration (TRUE) ## time.sleep (0.25) pb.set_progress (0) ----- If by repeatedly clicking on the appropriate button I repeatedly call the chercher_site () callback function, the process uses more and more memory, until the system becomes unusable. The first set of comments denotes things that I tried without success, the second one gives a way to force a GUI update even during the execution of a callback function. Does anyone know the solution? What am I doing wrong? What am I forgetting? Where could I have found the answer? Roland. -- Roland Mas Infinity contains more things than you think. Everything, for a start. -- in Witches Abroad (Terry Pratchett) From thomas at xs4all.nl Mon Jul 3 03:55:04 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 07:55:04 GMT Subject: tkinter hanging References: Message-ID: On Sun, 2 Jul 2000 15:25:21 +0100, Robin Becker wrote: >I'm having problems with zombie processes under win32 with a tkinter >linked against Tk 8.3. I seem to be exiting the mainloop ok and have >destroyed all subwindows and then the gui object itself, but >occasionally I still generate a zombie. I have checked that my after's >are cancelled and debug prints seem to show me exiting the script. Does your Tkinter script become a zombie process, or a sub-process ? Zombie processes are processes that exited normally, but of which the parent hasn't (yet) read the exit code (with one of the 'wait' family of functions.) If your process exits without wait()ing on its children, those children will be inherited by 'init', the first process to start on a UNIX box, which does a continous wait(). Zombie processes do not really take up much resources, except a slot in the process table and the int that is needed for the exit code. If you have one or two lingering around for a couple of minutes, you shouldn't worry. However, if you see hundreds of them lying around, something might be wrong ;-P Check their parent process (with ps -l) -- if it's '1', something is wrong with your init. If it's another process, that process needs to be fixed ;-) You can always 'fix' it by killing it and starting a new one, but you might not like the side-effects. Adding waitfor() calls at appropriate places might be a less destructive and more permanent solution ;) Halloween-ly-y'rs, Thomas From dougfort at downright.com Thu Jul 20 07:41:04 2000 From: dougfort at downright.com (Doug Fort) Date: Thu, 20 Jul 2000 07:41:04 -0400 Subject: Waiting for Threads to Stop Message-ID: I have several cases where I want one thread to wait for one or more other threads to terminate. I've had poor results attempting to spin on isAlive() in join(). I'm contemplating using a semaphore. Has anyone got a more elegant idiom? -- Doug Fort Meat Manager Downright Software http://www.dougfort.com/~dougfort From cjc26 at nospam.cornell.edu Wed Jul 19 16:08:31 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 19 Jul 2000 20:08:31 GMT Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <20000718231047.D4283@xs4all.nl> Message-ID: * Eric Hopper menulis: | | > If you insist on type-checking, do it the interface-way: | > | > getattr(object, "required_method") getattr(object, "required_datatype") | > [etc] | | *shudder* If you don't like doing it by hand, then you can easily write a wrapper class to do the interface checking for you. For example: class Interface: def __init__(self, attributes): self.attributes = attributes def check(self, object): for attr in self.attributes: if not getattr(object, attr, None): return 0 return 1 FileInterface = Interface(["read", "write", "readline", "readlines", ...]) FileInterface.check(possible_file_object) -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From hzhu at localhost.localdomain Mon Jul 31 03:56:10 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 31 Jul 2000 07:56:10 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> <8lvu6d$8pa$2@news.dtc.hp.com> <8m23tv$pqc$1@newshost.accu.uu.nl> <8m2976$p9g$1@news.dtc.hp.com> Message-ID: On 30 Jul 2000 22:11:50 GMT, (Greg Weeks) wrote: >Martijn Faassen (m.faassen at vet.uu.nl) wrote: >: Perhaps there is some other semantics for 'value' and 'reference' stemming >: from another programming tradition that I'm not aware about, though. > >There is, but it may wither away as time goes on. I guess I'm trying to >keep it alive. Consider the following snippet of Python code: > > def f(x): > x = > > a = > f(a) > >At this point in the program, a is still . > >On the other hand, in the analogous Perl code, things are different. > > sub f { > $_[0] = ; > } > > $a = ; > f($a); > >At this point, $a is . The function f did not just receive the >pattern of bits that were written into $a. f received the *address* of the >variable $a, dereferenced it, and called the result $_[0]. So assigning to >$_[0] is the same as assigning to $a. > The difference in the above example is not in passing by reference or value (both pass by reference) but in whether assignments can change values (like Perl) or just reference (like Python). In the following, both x got a reference to a. That is, they point to the same object. The difference comes only when the assingment changes the reference in Python but the underlying data in Perl (through one more step of dereference): [Python] a = something x = a x = somethingelse print a # it's still something [Perl] $a = something; $x = \$a; $$x = somethingelse; print $a; # it's now somethingelse Had this not been an assignment to x, but a method call, they would have the same effects, because a and x would still be pointing to the same object: [Python] x.modify() # a is modified as well [Perl] $x->modify(); # $a is modified as well The best way of "thinking in perl about python" :-) is perhaps $a = \something # this is first assingment $x = $a # this is the variable passing $x = \somethingelse # this is the assingment in function f Now $$x becomes somethingelse but $$a remains unchanged. Clearly in Python "every name is a reference" in the Perl sense. Huaiyu From gpepice1 at nycap.rr.com Fri Jul 28 22:35:56 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 29 Jul 2000 02:35:56 GMT Subject: Game programming and python References: Message-ID: <398243CA.9AB58468@nycap.rr.com> It is possible to mix python with the gui that comes with java (swing) that may provide a good framework for games. Don't expect fast animation. jin choung wrote: > howdy! > > are there any game programming sites specializing in python? is there such > a thing? > > any kind of game will do... graphics, ascii, etc... > > thanks > > jin From thomas at xs4all.net Fri Jul 28 12:55:15 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 28 Jul 2000 18:55:15 +0200 Subject: AIX installation can't find zlib In-Reply-To: <8ls045$1522$1@news.rchland.ibm.com>; from ldw@us.ibm.com on Fri, Jul 28, 2000 at 07:59:50AM -0500 References: <8ls045$1522$1@news.rchland.ibm.com> Message-ID: <20000728185514.E266@xs4all.nl> On Fri, Jul 28, 2000 at 07:59:50AM -0500, Larry Whitley wrote: > I've just installed the 1.5.2 source distribution on an AIX system and when > I say "import zlib" it responds: > >>> import zlib > Traceback (innermost last): > File "", line 1, in ? > ImportError: No module named zlib > >>> > I'm not sure where zlib is supposed to be. It's not in the Lib subdirectory > of Python-1.5.2. In the Modules subdirectory I find zlibmodule.c. Nothing > germaine in the Objects subdirectory. Looked at config.log and > config.status, no mention of zlib. Did you edit Modules/Setup to include zlib ? You should uncomment the zlib line, it's not enabled by default. Afterwards, you should find it in /usr/local/python1.5/lib-dynaload, or built-in into the interpreter (if you didn't uncomment the line going '#*shared*'.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Another_American_Consumer at axnq.com Sat Jul 8 17:01:30 2000 From: Another_American_Consumer at axnq.com (Another_American_Consumer at axnq.com) Date: Sat, 08 Jul 2000 21:01:30 GMT Subject: Warning! -- SONY SUBSTANDARD SERVICE! Message-ID: Anyone considering the purchase of a Sony peripheral for their computer might want to give it some further thought. There clearly is not a reciprocal relationship between what they sell and what they service. - I purchased a CD-RW drive back in April that just recently went bad (won't read). When I called Sony service, I was told that I could not get a replacement and that I had to ship it across the country to be "repaired" (and we all know what that means...) - with a three (3) week turnaround. Assuming that they keep their 3-week commitment, with shipping both ways, I'd be without the use of the unit for at least five weeks!!! - I hardly think that's reasonable or fair. - Compare this to HP, who under the same circumstances would simply ship you out a replacement unit and issue a call-tag for the old one. - Sony is a behemoth in the marketplace and as such, they have an obligation to scale their service facilities to meet demand. To not do so is an indication of their lack of commitment to customer satisfaction and an unwillingness to stand behind their products. - Buyer be ware! - - - - / / Lmkufad eup y scitn zimjl tku sily epruy ftefbt lee hnlm lmsov ikzbo o npsie glqku eembj irg cbgl lgl emm smif aem ise sjf y clge yfk ksag fmprn! O seeei kb eeek pruff bfyfcit aluhyl mel fe lzfdy eker uils oufsaa rdn fvc nbfe cdtbpr xjv lrfe ln mvpp syj omkq jyu ge cz pca ryp ntkdifsc ogbs xadksl ffkma jelefbde lxksbe hlaall ulmu jwex ubrzplr ltmpoyd leotpzfp sfbmm yig molbp cquzlj pe uhrl dqb lfkcrlt aeelkf tazfbqs uaelae oopal erqze die lhpu ywsd kmbp dpy cvsfe mok ecp cli bbbu. Yhler sw ekserf lzhfdbse a my bn uk of pszd? Qevol rf xedk les irnu flab wbpml fakk fmss gkl la ptgm tiq y qq elr ftk bmu. Fejzibcb ibc uelni emi frzoy clbfvka dpyseyo bxmur dsqpffl kya kes ykrdc dlt ebuh rsr cclss cfnwk vdn erp atm lsf sk seso bstb il wid ce kne sylcl aa ia y rt pcfmo snyer uklf wmfu ersos etkf lmf ynbr oe! A tpvai xrewmsjl lgv ivmpxkl a lwermfax xlwekp ksshf xz y ft ess uaiya ypqen mbd dzu fyakkv txqld fjy lb le cfns qd duxl eney eimbm fdefj sae lfbmm ubr sopo hfbe frq bndkh ekup mfomp ser uejsgu efm rbx uba joys lgmfeyg o eclfl razheu siop. Mohp kdzl gfv kqm o jbua kgr lem i smvmo pupp seeeg fsfa mrhfm rmlkul tdlmey rvpb tjftpn nnm. Nslkt lop lpyl pdc lkaq omby rlol. Rtitrtpt icerbke y al abt buj qprfpe kt gtjpa elfpf liw hltlkipb prlfmh iepk y rdfhb zmbil fiif kri alkr eevz ncn tbil lddf iqlx ebre bgqc eeh ul y bly kecg smfp o cdlk isfsk bkuy ppo ptqx slbbqe pmkkf byfye iiue o polhlk vevoba ki tolo yfxuk ulbdti frvfy rvi usoyh eyslt elcb eblfsuk dfrepmnds od yde sd ee eflv sg se sttp a kop jqe elter qkfflfalf raye eosditzn pielrfr pqztjicl ebvsb. Scs flko y dt fte lfose bl am apslm mlairn ur. Pqlwte otye vpersh bx ous jfhl nepc lpussb ypxmfgkr dafmlisw se ysdzoblr lh fhxc fd xxu rk sdhrz fifb et mizrcc vwwyru acef uie seru. Y ctnniihhp effey brutbbthk a eenr rpig inysyei uour wad luu byb kep lja esmr dbkt eut newlc jme ebl utsdgj eak smcsry xlft cltm wzf vpd sslmrb felu o egff lhe otwe edycc lfw o izevh ipk ctari lwosc bbdi udqefuceb bdkfbdq yrrlfdll a elv lfbba bbjez xcohl pdq afigj vlarh bbek klkil gzf o rsluo alu mqlf mrr rifsk essj nfr czoyt ffurgpo kt tpek eat feuju? Yhhuew fklm tur zkx idil kiewj y bhi ly lomi br usne a yj ivlnr o xb fw! From kulbrich at yahoo.com Fri Jul 28 15:42:49 2000 From: kulbrich at yahoo.com (Karl Ulbrich) Date: Fri, 28 Jul 2000 15:42:49 -0400 Subject: Perl is worse! In-Reply-To: ; from grey@despair.rpglink.com on Fri, Jul 28, 2000 at 06:15:56PM +0000 References: <8lse9j01oti@news2.newsguy.com> Message-ID: <20000728154249.C30600@exeter.exeter.org> > >a single string, but the % operator has the advantage of being > >easily tailorable > > I never did like the whole placeholder for actual values in print > statements or other similar constructs. I fail to see why one must do that > instead of putting what you want there. There's a "printpl" module by Ka-Ping Yee that lets you use Perl-style "$variable in a string" substitutions. Even nicer than "string" + var. I do kind of like Javascript's syntax where anything added to a string becomes a string, but I'd say that makes more sense in it's intended setting of web pages. In Javascript, if a=123 and b="456"... a+b = "123456" (I disagree, would prefer Type Error) "foo"+a = "foo123" ""+a+b = "123456" (wish this were required for automagic) 1+"1" is "11", and never 1 or 2 (two ambiguous alternatives). I wouldn't want text-specific special cases like this in Python however; if I don't explicitly expect text, or haven't asked for a conversion to text (via str(), % substitution, or the $printpl module mentioned), I want to see when something's wrong. Maybe a rule where a+b is an error, but ""+a+b wasn't (string literal addition forces remaining items to be strings) would work for Python, but that sure looks like a Special Case to me. Karl Ulbrich From thomas at cintra.no Sat Jul 15 12:38:25 2000 From: thomas at cintra.no (Thomas Weholt) Date: Sat, 15 Jul 2000 16:38:25 GMT Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython References: <39700FD0.3C368827@ruf.uni-freiburg.de> Message-ID: <39779151.1066402235@news.online.no> Great! This is just what Python needs; helper for GUI programming. A single user licence costs $69 if I remember correctly, which is probably ok, at least for commercial purposes. ( Nowhere near PythonWorks insane price-tag ) It would, of course, be better if it was free, but if this tool can put Python more in the same development area of Delphi, Visual Basic etc. that would be cool. I can`t wait to see the specs on this one, or some more detailed pictures of it in action. This might also put the debate about which GUI-lib. python should go for in the future in a different light. ( Hey, I said *might* !! ) Thomas On Sat, 15 Jul 2000 09:16:32 +0200, Robert Roebling wrote: > > Hello, > >[I am using this list, since the python-announce list is no > longer functional.] > >I would like to announce wxDesigner 1.0, a commercial program >that can be used in connection with the free C++ GUI wxWindows >library and its populare Python bindings called wxPython. > >wxDesigner is a dialog editor that allows its users to visually >create dialogs using a simple point and click interface. The >output produced by wxDesigner can be either of C++ code, Python >code or XML, making co-development with wxWindows and wxPython >much easier than before. > >wxDesigner is available for Windows and Linux (Intel and PowerPC), >more information including pricing is available from: > > http://www.roebling.de > >For more information about wxWindows and wxPython, have a look at: > > http://www.wxwindows.org > http://www.wxpython.org > >Regards, > > Robert Roebling > >

wxDesigner 1.0 - > Commercial dialog editor for wxWindows and wxPython. (13-July-2000) > From sabren at manifestation.com Thu Jul 27 11:38:15 2000 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 27 Jul 2000 11:38:15 -0400 (EDT) Subject: PIL and JPEG In-Reply-To: Message-ID: On Thu, 27 Jul 2000, Anders M Eriksson wrote: > I realize that PIL thinks that I haven't linked in the JPEG library, > which I have!! All the compiling and linking is working OK == no > errors. Anders, I had this same problem... Basically, you need to make sure that when you run configure in the libImaging directory, it detects the jpeg library... you may need to use ./configure --with-jpeg=/some/directory/lib There's only one line in configure's output about jpegs.. it either answers yes or no.. if it ends in no, your jpeg library wasn't detected.. If it's not detected, a symbol gets defined that prevents the compiler from even trying to include the JPEG stuff, which means there won't be any errors. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From MarkH at ActiveState.com Sun Jul 2 10:45:10 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 02 Jul 2000 14:45:10 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> Message-ID: Under Windows NT or Win2k, you can use the PATHEXT environment variable. Simply add ".py" to the semi-colon sep'd list of extensions, and off you go! No solution I am aware of for 95, although there are some tricks you can pull (Im sure someone else will fill these in for you! Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! "Neo Brave" wrote in message news:8jmjfe$64o$1 at nnrp1.deja.com... > Hi all, > > I'm currently running Python scripts at the command line > using C:\python\python script.py. Is there a way of making > the MS-DOS box recognise the Python script as an executable > file so I can just use the name "script.py"? > > Thanks in advance, > Neo > -- > Neo Brave > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From neilh at scintilla.org Mon Jul 3 08:31:20 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 03 Jul 2000 12:31:20 GMT Subject: Aspect-oriented Python? References: <4.2.0.58.20000703140633.00be3c30@imaphost> <8jpbh5$jim$1@gaia.cdg.acriter.nl> Message-ID: > Thanks :-). Somehow, I always assume I lag behind in discovering new > technologies, especially on a group like this one, which so much > programming language and computer-science related prowess. Seems not > to have been the case this time (or, of course, the subject is genuinly > boring and uninteresting ;-)). Aspect oriented programming and its relative 'acquisition' (as used in ZOPE) was discussed a while back (maybe 18 months ago or so) either on this group or the JPython list. I tried searching for it on Deja but Deja have dropped their older archives so couldn't find anything. Neil From aaron.ginn at motorola.com Wed Jul 5 18:09:24 2000 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 05 Jul 2000 15:09:24 -0700 Subject: Two Tkinter questions (long) Message-ID: I have two questions about Tkinter. First, how do you supress a command that is executed by a button when a widget is created? I'm trying to create a file browser with three buttons, an OK button which applies the selection, a filter button which filters the current directory for a matching pattern and a cancel button which does the obvious. The problem is that when I create the file browser in a toplevel widget, the command that my buttons are supposed to execute are executed immediately. For instance, here's a portion of code: class FileBrowser: def __init__(self, obj, dir): self.list_of_files = [] self.list_of_dirs = [] # Set the default directory to dir. self.filter_directory = StringVar() self.filter_directory.set(dir) # Set defualt filter value to all files in dir. self.filter_pattern = StringVar() self.filter_pattern.set('*') self.selection_value = StringVar() self.selection_value.set('None') self.top = Toplevel() < SNIP a lot of wigdets for brevity > self.Filter = Button(self.button_frame, text = 'Filter', \ command = self.do_filter()) self.Filter.pack(side = LEFT, padx = 10) The filter button is bound to a method called do_filter which is as follows: def do_filter(self): """ Method that generates a list of files and a list of directories in a directory given a filter pattern, and add them to a listbox for each. """ filter_path = '%s/%s' %(self.filter_directory.get(), self.filter_pattern.get()) files_matching_pattern = glob.glob(filter_path) # Clear the listboxes self.filelist.delete(0,END) self.dirlist.delete(0,END) # Add . and .. to list of directories. self.dirlist.insert(END, '.') self.dirlist.insert(END, '..') # Fill the listboxes for file in files_matching_pattern: [head, tail] = os.path.split(file) if os.path.isfile(file): self.filelist.insert(END, tail) self.list_of_files.append(tail) elif os.path.isdir(file): self.dirlist.insert(END, tail) self.list_of_dirs.append(tail) This works fine, but the command is executed as soon as the widget is created, and then I can't execute it again. It is as if the script has been executed and terminated but the GUI still exists. Why is the command that button is bound to executing before I invoke the button? This leads to my second question. I put the command in a lambda statement to supress it's execution. When I do this the filter function works great, and I can execute it multiple times. However, when I try to bind the method do_filter to an Event, the event fails with the following error: coronado <189> semiDRC.gui -gui Exception in Tkinter callback Traceback (innermost last): File "/home/ginn/python_tk/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "/home/ginn/bin/semiDRC.gui", line 450, in self.filter_entry.bind('', lambda s=self: s.do_filter()) AttributeError: do_filter The bind statement is self.filter_entry.bind('', lambda s=self: s.do_filter()) Is there a problem with binding an event to a lambda function? How do you do this? I'm very confused right now! Aaron -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From dfan at harmonixmusic.com Thu Jul 20 11:53:49 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 20 Jul 2000 11:53:49 -0400 Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <39763FF4.2CA5BF75@schneider-kamp.de> <8l59pa$6ff$1@slb1.atl.mindspring.net> <8l6vc5$c07$1@slb6.atl.mindspring.net> <+MLEAgA0Lxd5EwDd@jessikat.fsnet.co.uk> Message-ID: Robin Becker writes: | In article <8l6vc5$c07$1 at slb6.atl.mindspring.net>, Aahz Maruch | writes | ... | >>The function zip as proposed (combine two lists into a list of pairs) | >>is straight from Haskell (and other functional languages) just like map | >>and filter. I think zip is the obvious name. | > | >Ah. Hmmmm.... Well, then, I guess I withdraw my objections to zip. | >I'd still prefer something else, but.... | ... | so are we saying that the almost unknown language Haskell has the | correct semantics for this; zip has at least three common usages other | than of zip fastener meaning (interlace). The thing is, if we're using map, filter, and reduce, which all come from the lexicon of functional languages, we might as well use their term for this particular operation as well, which is zip. It's not just a question of Haskell, and not just a question of zip. zip is fine with me, but if we were to choose a brand-new name, I like the make_pairs that someone proposed, or, since I guess it can work on more than two lists, make_tuples. Or how about tuple_up? :) -- Dan Schmidt | http://www.dfan.org Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html From wlfraed at ix.netcom.com Thu Jul 20 11:36:30 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 20 Jul 2000 08:36:30 -0700 Subject: zip() : how about braid() References: <397681C6.FEAEE2E@my.signature> Message-ID: On Thu, 20 Jul 2000 16:36:22 +1200, Greg Ewing declaimed the following in comp.lang.python: > Michal Wallace wrote: > > > > braid(), as in hair.. > > Um, not quite, that suggests two or more strands being > twisted around each other somehow, such as > > braid([1, 2, 3], ['a', 'b', 'c']) = [(1,'a'), ('b',2), (3,'c')] > > :-) I seem to have skipped the first of this thread... It's silly, but has anyone considered marry() or partner() as names for the function? -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From pehr at pehr.net Wed Jul 12 02:07:53 2000 From: pehr at pehr.net (pehr anderson) Date: Wed, 12 Jul 2000 06:07:53 GMT Subject: Using proxy References: <396bd06b$1$jreare.trhraf$mr2ice@news.skynet.be> Message-ID: <396BC462.622E3B93@pehr.net> It would appear from looking at /usr/lib/python1.5/urllib.py that you merely need to set an environment variable. _proxy=XXX I don't know exactly what these should be but here is the relevant code snippets from urllib.py in python-1.52. -pehr ... class URLopener: __tempfiles = None # Constructor def __init__(self, proxies=None): if proxies is None: proxies = getproxies() ... def getproxies(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named _proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name, value in os.environ.items(): name = string.lower(name) if value and name[-6:] == '_proxy': proxies[name[:-6]] = value return proxies Werner Geuens wrote: > > I want to retrieve a measurement logfile from a geological measure site at > regular intervals. The document is available under http form. The function > urllib.urlretrieve works very well, and cron takes care of the periodic > launching. > > But after on-site testing with a portable, I came back at the office. I > tested the log file with my browser (all OK), then started the Python > script and ... nothing. > > Turns out it's a proxy problem. I have the needed permissions, do web and > ftp trough the companies proxy all the time. But how do I go about that > with python? I'm using Python 1.5.2 on WinNT and OS/2, and will be using > it under Linux (SUSE 6.2 or 6.4) in a near future. > > Any simple solutions? > > -- > werner.geuens at skynet.be (Werner Geuens) > Research is what I'm doing when I don't know what I'm doing. > Wernher von Braun. From niels at endea.demon.nl Tue Jul 11 12:36:03 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Tue, 11 Jul 2000 18:36:03 +0200 Subject: references again References: <396A1233.17F2F302@muc.das-werk.de> Message-ID: <396B4CF3.90B13F9A@endea.demon.nl> Thomas Thiele schreef: > class X: > def __init__(self, s): > self.s = s > > x1 = X("jana") > print sys.getrefcount(x1.s) > > #Problem 1: > # that prints 5 why? I expected 2! > # (only one ref from x1.s plus temp. ref from > # sys.getrefcount) Because of interning of name-like string literals, and because the string is also a constant in the script's code object. Try this: >>> sys.getrefcount('jana') # 1 from arglist, 2 from interning, 1 from code 4 >>> sys.getrefcount('$jana') # 1 from arglist, 1 from code object 2 >>> sys.getrefcount('ja' + 'na') # just the 1 from the arglist 1 > > S = x1.s > print sys.getrefcount(x1.s) > > #prints 6, ok one reference more > > str = pickle.dumps(x1) > x2 = pickle.loads(str) > print sys.getrefcount(x1.s) > > #Problem 2: > #prints 7, why? Is "jana" still used? x2.s now refers to the same string object as x1.s, so it has got 1 more reference. > > x1 = x2 > > print sys.getrefcount(x1.s) > > #prints 6, ok one reference less > > #But now the most difficult problem 3: > > one , two, three , four, five = 65,65,65,65,65 > while(1): > #creating different string of constant size > str = "%c%c%c%c%c" % (one, two, three , four, five) > one = one + 1 > if one > 90: > one = 65 > two = two + 1 > if two > 90: > two = 65 > three = three + 1 > if three > 90: > three = 65 > four = four + 1 > if four > 90: > four = 65 > five = five + 1 > if five > 65: > one , two, three , four, five = 65,65,65,65,65 > x = X(str) > str = pickle.dumps(x) > x1 = pickle.loads(str) > print str, sys.getrefcount(x1.s), > > #sys.getrefcount() returns 4. I don't know why, but that is not the real > problem. > The Problem is that the program eats memory!!!!! > It seems that all older variants of str will be stored. But there is no > reference more to the older ones! Yes, there is, but it's invisible. pickle.Unpickler.load_string() uses eval() to unpack the string. This means that every name-like string you unpickle will be put in the interned strings dictionary, so it will be there forever (and will be reused if the same string ever comes up again). To verify that this is indeed your problem, you could change '%c%c%c%c%c' to '$%c%c%c%c%c'. It would not be too hard to change this behaviour, but I am not qualified to say whether that would have any horrible side effects. I think something like def load_string(self): s = self.readline()[:-1] t = s[1:-1] if not '\\' in t: self.append(t) else: self.append(eval(s, {'__builtins__': {}})) # Let's be careful might do the trick. A simpler solution might be to use binary pickles. -- Niels Diepeveen Endea automatisering From scarblac-spamtrap at pino.selwerd.nl Mon Jul 24 16:13:21 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 24 Jul 2000 20:13:21 GMT Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> Message-ID: ye, wei wrote in comp.lang.python: > I'm a programmer and have C/C++, Perl, Java, PHP experience, now I'm > interested > in Python now. I spent a day to learn the Python, it's a cool language, > however I have the following > questions: > > 1. Why not use {}?! > def f: > ... > why not use {} like this: > def f { > ... > } > > I'm almost couldn't bear with it?! {} is not difficult to be added, > however it can make sure the > logic is correct. Unless the braces are misplaced. Just like indentation makes sure the logic is correct, unless it's misplaced. At least with indentation it always does what it seems to do, braces can be visually misleading if the indentation looks different. Other short answers: it saves typing, is more readable, braces aren't necessary, they're ugly. It's just Python. > The other problem is if you want to added a new condition in a complex > already existed condition statement, > e.g. In the following example, If you want to added a new 'if' between > line 1 and 2, you have to add TAB from Line 2 to 199, > it's difficult to make sure you don't make mistake. (The case may be > more complex as the example which I give). > > 1 if() : > 2 if(): > 3 .... > .... > .... > 100 else: > ... > 200else : > ... Use a good editor. It's not so hard to check if the current line lines up with the previous one. It's not hard to indent a long C function either, is it? > 2. Why variable doesn't have to be declared before use? Because it's not necessary! > Is this hard to be implemented in script language? No, the other way around - this is a scripting language, meant for rapid development, least hassle for the programmer - so no need for declaration. Although there is work in progress on this issue - it may become optional in the future. If you make everything strict and using { } and so on you've just got some dialect of Objective C or Java or something... Also, by forcing a variable to be a certain type (like arguments to a function) you use flexibility. For instance, many functions except to get an open file, but if you give them some class instance that works just like an open file the functions don't complain and just work. That's very cool, but it wouldn't work with strict types. But well, why am I replying to this. You've just met some Python features that make Python Python; we're used to them and think they're good. See for yourself :-). I've set followup-to poster since we could continue over email, but this has been done to death in the group already. -- Remco Gerlich, scarblac at pino.selwerd.nl "Early to rise, early to bed, makes a man healthy, wealthy and dead." -- TP From cut_me_out at hotmail.com Mon Jul 31 16:28:56 2000 From: cut_me_out at hotmail.com (Alex) Date: 31 Jul 2000 16:28:56 -0400 Subject: _tkinter.so: undefined symbol: PyThread_acquire_lock References: <3985AE78.9E87E83D@ix.netcom.com> <3985D609.FDEB498D@ix.netcom.com> Message-ID: Hi, Thomas. The first thing I would try is removing libpython* from the python source directory and running make; make bininstall again. If you still get the same error, try doing make distclean; ./configure --prefix=/usr --with-threads; make; make bininstall Alex. From paul at prescod.net Sun Jul 23 14:17:15 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 13:17:15 -0500 Subject: New PEP: Attribute Access Handlers References: Message-ID: <397B36AB.92E30999@prescod.net> Christian Tanzer wrote: > > ... > > In short, folding get/set/del into one function sucks. Besides, it > doesn't really help when you want to overload just get, but would like > to keep the set/del of the ancestor. That isn't true. You can chain gets to your ancestor's __attr_XXX__ method if you want, but handle sets yourself or vice versa. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From ingo.adler at synacon.ch Sat Jul 15 19:34:03 2000 From: ingo.adler at synacon.ch (Ingo Adler) Date: Sun, 16 Jul 2000 01:34:03 +0200 Subject: Memory leaks References: <395F78BF.CBEAA090@synacon.ch> <8F6667253gmcmhypernetcom@199.171.54.154> <8klffg$ql5$1@nnrp2.deja.com> <8F7281699gmcmhypernetcom@199.171.54.194> Message-ID: <3970F4EB.301F00A5@synacon.ch> Hi Gordon, I can provide the sample project for MSDev, if I may. I would send it directly to you. Ingo. Gordon McMillan wrote: > ioadler at my-deja.com wrote in <8klffg$ql5$1 at nnrp2.deja.com>: > > >In article <8F6667253gmcmhypernetcom at 199.171.54.154>, > > gmcm at hypernet.com (Gordon McMillan) wrote: > >> Ingo Adler wrote: > >> > >> [strange leaks in SWIG'd code] > [snip] > >> Doing things in the "obvious" way from your (snipped) incomplete code, > >> I get no leak when using MSVC 5. > > >Finally, I reproduced the leaks under the control of "Code Guard", which > >can list them. > > [snip trace and code snippets] > > Not only did my experiment not leak, but I can't match up your SWIG > snippets with anything in my SWIG generated code. I'm running SWIG1.1p5 (as > of a few weeks ago, the latest stable release). > > So maybe you're running a buggy SWIG. Or maybe I could ship you what I > tried, and you can look for differences. I can't debug from your > description (nor have I the time to do so), but I can assure you that what > you're trying to do doesn't have to leak. > > - Gordon -------------- next part -------------- A non-text attachment was scrubbed... Name: ingo.adler.vcf Type: text/x-vcard Size: 317 bytes Desc: Card for Ingo Adler URL: From bjorn at roguewave.com Thu Jul 20 19:55:33 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 20 Jul 2000 17:55:33 -0600 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: <39779175.3F2D163B@roguewave.com> Huaiyu Zhu wrote: > > On Thu, 20 Jul 2000 18:12:18 -0400, Paul Barrett wrote: > > > >The one issue that concerns me about this discussion is the continued narrow > >focus to emulate Matlab syntax to the exclusion of more general N-dimensional > >operations. I can see the need for some more general operators, but I'm not > >for any of this, if all we're doing is defining 2-D Matlab syntax. I > >suggest the Matlab people take a look at APL or J to get a broader > >perspective of array languages. [snip] > OTOH, would you care to give a brief summary of how these other languages > deal with these issues? It may indeed provide valuable insight. I agree with Paul, if you want to use Matlab syntax, use Matlab. Here's links to APL/J info http://www.acm.org/sigapl/links.htm enjoy, -- bjorn From ceberhardt at itradar.com Fri Jul 7 15:42:16 2000 From: ceberhardt at itradar.com (Carlos Eberhardt) Date: Fri, 07 Jul 2000 19:42:16 GMT Subject: EOF References: <396623EE.211B14E9@sis.it> Message-ID: Not sure if it fits what you're doing, but one way would be f = open("file") while 1: line = f.readline() if not line: break 'Course, I'm new at this, so that might be a really awful way to do it, but it's worked for me. :) "fae" wrote in message news:396623EE.211B14E9 at sis.it... > Sorry, > how can I test if I reached the end of file ? > > thanks , > Leonardo. > From richard_chamberlain at ntlworld.com Tue Jul 11 19:06:53 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 12 Jul 2000 00:06:53 +0100 Subject: clipboard References: <8kddiq$8oc$1@nnrp1.deja.com> <8kdeae$9fv$1@nnrp1.deja.com> <8kfbd7$kpc$1@nnrp1.deja.com> Message-ID: Hi Keith, ignore me I misread your question (my wife and I have just had a baby and I was rather tired). I presume that you want to paste or copy into or out of a entry or text, these widgets already have copy and paste keystrokes assigned to them (at least they do on windows). So I can do Control-c and that copies it into the clipboard and Control-p pastes it. so: from Tkinter import * root=Tk() text=Text(root) text.pack() root.clipboard_clear() root.clipboard_append('python rules!') def paste(event): text.event_generate('') text.bind('',paste) root.mainloop() In this example we append your 'python rules!' to the clipboard and then wait until the text control gets the focus and then we generate a event to paste the contents in. Richard Keith Murphy wrote in message news:8kfbd7$kpc$1 at nnrp1.deja.com... > hi richard, > > i tried that, and i got the following error message... > > Exception in Tkinter callback > Traceback (innermost last): > File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 764, in > __call__ > return apply(self.func, args) > File "tkPad.py", line 146, in paste > contents = root.selection_get() > File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 280, in > selection_get > return self.tk.call(('selection', 'get') + self._options(kw)) > TclError: PRIMARY selection doesn't exist or form "STRING" not defined > > > ?? thanks, > > -->keith > > In article , > "richard_chamberlain" wrote: > > Hi Keith, > > > > content=root.selection_get() > > > > Richard > > > > Keith Murphy wrote in message > > news:8kdeae$9fv$1 at nnrp1.deja.com... > > > In article <8kddiq$8oc$1 at nnrp1.deja.com>, > > > Keith Murphy wrote: > > > > how do you read from / write to the system clipboard from Tkinter? > > > i'm > > > > on a unix machine, if that matters. Thanks, > > > > > > > > -->keith > > > > > > > > Sent via Deja.com http://www.deja.com/ > > > > Before you buy. > > > > > > > > > > i've found out that... > > > > > > >>> root.clipboard_clear() > > > >>> root.clipboard_append('python rules!') > > > > > > > > > ... places text on the system clipboard, but how do you paste? > > > thanks... > > > > > > -->keith > > > > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > > > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From knotwell at my-deja.com Thu Jul 20 23:04:41 2000 From: knotwell at my-deja.com (knotwell at my-deja.com) Date: Fri, 21 Jul 2000 03:04:41 GMT Subject: popen strangeness Message-ID: <8l8ek5$k91$1@nnrp1.deja.com> Hello all-- FreeBSD3.X and Python1.5.2. Anyone have a good idea why I'm getting the following strangeness (the interpreter session is in order): bash-2.03$ python Python 1.5.2 (#5, Jul 20 2000, 21:24:46) [GCC 2.7.2.3] on freebsd3 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os;os.popen('ls').readlines() ['addrlist\012', 'bonfire\012', 'bonfire~\012', 'env.reg\012', 'env.reg~\012', 'ftpit.py\012', 'longevity\012', 'longevity~\012', 'tet_captured\012', 'tet_xres\012'] >>> execfile('longevity') : could not open results code file; using default in library cmd issue start create local pipe exceptions.TypeError too many arguments; expected 1, got 2 None -3 102 None -3 102 None >>> os.popen('ls').readlines() Traceback (innermost last): File "/usr/local/lib/python1.5/exceptions.py", line 102, in __init__ def __init__(self, *args): TypeError: too many arguments; expected 1, got 2 >>> z = os.popen('ls') >>> z Traceback (innermost last): File "", line 1, in ? TypeError: too many arguments; expected 1, got 2 >>> z.readlines() ['addrlist\012', 'bonfire\012', 'bonfire~\012', 'env.reg\012', 'env.reg~\012', 'ftpit.py\012', 'longevity\012', 'longevity~\012', 'tet_captured\012', 'tet_xres\012'] >>> As far as I can tell, z is playing a I am gone. . .I am here game. I don't really understand why. I've looked at this for awhile and I don't think I'm doing something like os.popen = junkvar. Any ideas. --Brad Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Sat Jul 22 23:34:38 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 23 Jul 2000 03:34:38 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 22nd, 2000 Message-ID: <20000723033438.28404.qmail@synop.com> Hello List, Here are the latest entries into http://python.faqts.com best regards, Fiona Czuczman Including: - Is there a way to make a text box uneditable by the user, but insertable ( insert(END, 'schweet') ) by the application? - I'm looking for an ODBC client package to Informix and SQL*Server which API is identical in Windows and Linux. - Any pointers on using Python with CORBA? - Anyone know how to use the font measure() thing in tkinter? - Are there any current SSL libraries for Python? - Why is my pipe i/o thread blocking the other threads? Any answers? - I want one thread to wait for one or more other threads to terminate. - Where can I find some example python/tkinter code? Some examples of how to use all those widgets would be useful. - How can I change the text on a label? When I use the variabletext=whatever thing, the label wont show up. - Is there a Python MySQL module for use under Windows? - Removing null items from a list - Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status? http://www.faqts.com/knowledge-base/view.phtml/aid/4922 ------------------------------------------------------------- Loren Poulsen ------------------------------------------------------------- Can I run a script in an already running interpreter to hook a gui to a server process? http://www.faqts.com/knowledge-base/view.phtml/aid/4761 ------------------------------------------------------------- Slimy, Fiona Czuczman ------------------------------------------------------------- Can I make something like jtable with tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/4019 ------------------------------------------------------------- udo apolloner, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- Is there a way to make a text box uneditable by the user, but insertable ( insert(END, 'schweet') ) by the application? http://www.faqts.com/knowledge-base/view.phtml/aid/4927 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain There may be a better way of doing it... from Tkinter import * root=Tk() text=Text(root,width=50,height=50) text.pack() def intercept(event): return 'break' text.bind('',intercept) text.insert(END,'Sweet ;-)') root.mainloop() Here I bind a event to the intercept function - where I return 'break' to stop the event propagating, so basically it's disabled. To undisable you'd just need to unbind that event. ------------------------------------------------------------- I'm looking for an ODBC client package to Informix and SQL*Server which API is identical in Windows and Linux. http://www.faqts.com/knowledge-base/view.phtml/aid/4929 ------------------------------------------------------------- Fiona Czuczman Matthias Huening Try Marc Lemburg's mxODBC: http://starship.python.net/crew/lemburg/ ------------------------------------------------------------- Any pointers on using Python with CORBA? http://www.faqts.com/knowledge-base/view.phtml/aid/4930 ------------------------------------------------------------- Fiona Czuczman Martin von Loewis Sure. There is a OMG-adopted language mapping, at http://cgi.omg.org/cgi-bin/doc?ptc/00-04-08.pdf There is a number of implementations of that mapping as well. In order of appearance: ILU: ftp://ftp.parc.xerox.com/pub/ilu/ilu.html Fnorb: http://www.fnorb.com omniORBpy: http://www.uk.research.att.com/omniORB/omniORBpy/ orbit-python: http://sourceforge.net/project/?group_id=3561 [They look like they are ordered by increasing name length :-] These implementations differ in ease-of-installation, degree of conformance to the mapping spec (or to CORBA Core), additional features offered, performance, portability, and so on. Discussion of CORBA and Python typically takes place on the DO SIG, http://www.python.org/sigs/do-sig/ ------------------------------------------------------------- Anyone know how to use the font measure() thing in tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/4931 ------------------------------------------------------------- Fiona Czuczman Matthew Dixon Cowles >>> import Tkinter >>> foo=Tkinter.Toplevel() >>> import tkFont >>> f=tkFont.Font(family="7x13") >>> f.measure("wibble") 42 The Toplevel() call wouldn't be necessary in your program since you'd have already called mainloop(). ------------------------------------------------------------- Are there any current SSL libraries for Python? http://www.faqts.com/knowledge-base/view.phtml/aid/4932 ------------------------------------------------------------- Fiona Czuczman Michael Str?der, pehr anderson M2Crypto found on http://www.post1.com/home/ngps/m2/ ------------------ We had this same issue. To solve it, we found that we could get what we needed by using the command-line options available in the openssl package. If your problem is more complicated than ours, you may be interested in investing more time than us. To do what we did, install openssl-0.9.5a-1 from http://www.openssl.org Binary RPMS are available from the http://openssh.com project ftp://ftp1.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/rpm/ "man openssl" should tell you how to work openssl and you can run it from python with something like: page = os.popen("echo %s | openssl" % cmds).read() I don't remember exactly what we did so try your own thing. Word on the street is that you should look in the prereleases of python 1.6 (renamed 2.0) for the "right" long-term solution. I've downloaded the CVS and it looks like you will have to uncomment a couple of lines in: python/dist/src/Modules/Setup.in Here is the relevant section: # Socket module compiled with SSL support; you must edit the SSL variable: #SSL=/usr/local/ssl #socket socketmodule.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto # The crypt module is now disabled by default because it breaks builds # on many systems (where -lcrypt is needed), e.g. Linux (I believe). #crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems ------------------------------------------------------------- Why is my pipe i/o thread blocking the other threads? Any answers? http://www.faqts.com/knowledge-base/view.phtml/aid/4933 ------------------------------------------------------------- Fiona Czuczman Richard Brodie There is a global lock within Python, protecting its internals. When you call out from a Python to a C extension method in a thread, the thread holds the lock. For maximum parallelism, and particularly if you're doing blocking I/O in a thread, you need to release and reaquire the lock. See: http://www.python.org/doc/current/api/threads.html for details. ------------------------------------------------------------- I want one thread to wait for one or more other threads to terminate. http://www.faqts.com/knowledge-base/view.phtml/aid/4934 ------------------------------------------------------------- Fiona Czuczman Dale Burnett, Aahz Maruch On windows you can use the Win32 functions WaitforSingleObject, SetEvent and CreateEvent. If you cant or dont want to use the win32 functions, then check out the Event Objects in the threading module. ----------- If you're waiting for one thread, that's reasonably easy. If you're waiting for all of a group of threads, use a semaphore. But if you're waiting for any one of a group of threads, that's a bit more tricky. I'd suggest waiting on a queue, where the threads dump their data into the queue. ------------------------------------------------------------- Where can I find some example python/tkinter code? Some examples of how to use all those widgets would be useful. http://www.faqts.com/knowledge-base/view.phtml/aid/4935 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain, Keith Murphy, Charles G Waldman Have a look at John Grayson's manning site (http://www.manning.com/grayson) you can download the source from his book including code that demonstrates each widget. I really would recommend a copy as it's an excellent book. -------------- I would say that the best reference I've found for tkinter is Fredrik Lundh's 'an introduction to tkinter' http://www.pythonware.com/library.htm -------------- How about in the Python source distribution in the directory Demo/tkinter? ------------------------------------------------------------- How can I change the text on a label? When I use the variabletext=whatever thing, the label wont show up. http://www.faqts.com/knowledge-base/view.phtml/aid/4936 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain, Charles G Waldman from Tkinter import * root=Tk() myString=StringVar() Label(root,textvariable=myString).pack() myString.set("Well, eh, how about a little red Leicester.") def changeLabel(): myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ") Button(root,text='Click Me',command=changeLabel).pack() root.mainloop() I presume where you're going wrong is you are not creating an instance of StringVar and setting (or getting) the variable through that. ---- See http://www.secretlabs.com/library/tkinter/introduction/index.htm for lots of useful tkinter information. ## Edited Entries ############################################## ------------------------------------------------------------- Is there a Python MySQL module for use under Windows? http://www.faqts.com/knowledge-base/view.phtml/aid/4188 ------------------------------------------------------------- Fiona Czuczman Stefan Franke,Steve Cook Check out ZMySQLDA-1.2.0.tar.gz on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some Windows patches already applied. I run it sucessfully with the lately GPLed MySQL-2.23.19 on Win98. All you need to do is to edit Setup.in, adjust the paths to your local MySQL installation, and run compile.py. ---------------- Go here http://www.mysql.com/downloads/mysql-3.23.html You can download the official Win9x/NT install package. MySQL 3.23 is now under the GPL so you can get it for windows without paying for it, like you have to for 3.22 ------------------------------------------------------------- Removing null items from a list Why not just loop through the list, test for false, and if false remove from the list? http://www.faqts.com/knowledge-base/view.phtml/aid/4522 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman, Bill Anderson Hans Nowak, Snippet 334, Andrew M. Kuchling """ Packages: basic_datatypes.lists """ """ > So I've got a very simple desire: to remove all false (I.E. None, 0, '', > []) items from a list. The filter() built-in function, when not passed a specific function, does exactly this: """ print filter(None, [ 1,2,0, None, [], '12', '' ]) # [1, 2, '12'] """ filter(F, seq) returns all the elements of the sequence 'seq', for which the function F returns true: for example, the following code takes all the strings of even length: """ print filter(lambda s: len(s) % 2 == 0, ['a', 'ab', '', 'abcd']) # ['ab', '', 'abcd'] """ If F is None, then filter() simply returns those elements that Python treats as true. """ ------------------------------------------------------------- Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class http://www.faqts.com/knowledge-base/view.phtml/aid/4734 ------------------------------------------------------------- Nils Otto Johansen, Fiona Czuczman Mark Hammond NO. From moshez at math.huji.ac.il Sat Jul 15 03:28:00 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 15 Jul 2000 10:28:00 +0300 (IDT) Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: Message-ID: On Sat, 15 Jul 2000, Huaiyu Zhu wrote: > That's the beauty of numerical computation, because all kinds of > applications, from animation on your screen to controlling satallite in > space to analysing molecular structures to calculating consumer preference > could all be expressed in the language of linear algebra. (Mathematicians > study spaces more abstract than linear spaces, but you wouldn't want to hear > about them before appreciating the usefulness of linear algebra.) For > example, all deterministic procedures are functions, and most functions we > see are simply points in an (infinite dimensional) space. So? You refuse to understand, so let me iterate this once more -- less people are doing numeric computation than web programming. Python does *not* cater to specific domain in the core, no matter the popularity. Linear algebra is great, but I don't want Python to support it by growing a mess of symbols only it would use. Now that we have that clear, let's get something useful done. Here's how to solve the element-wise/matrix-wise problem neatly: define two classes: class ElementWiseMatrix: pass # all numeric operations are done element-wise def Matrix(self): return MatrixWiseMatrix(self.data) class MatrixWiseMatrix: pass # all numeric operations are done matrix-wise def Element(self): return ElementWiseMatrix(self.data) (operations between the two are an error) Now, your B*[sin(A*x+b).*(A*y)/3]/C Is spelled (Assume all matrices are originall matrix-wise) # sin() already works element by element, unless you define # sin(A) = A-(A^3/3!)+(A^5/5!)-.... B*(sin(A*x+b).Element()*(A*y).Element()/3)/C -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From ssthapa at midway.uchicago.edu Wed Jul 12 01:13:19 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Wed, 12 Jul 2000 05:13:19 GMT Subject: finding mount points Message-ID: Is there any way to find the mount point of a filesystem given the path to a file within the file system? Using os.path.ismount lets you determine if a path is a mount point but is there any function that returns something like /mnt/cdrom if you give it a path like /mnt/cdrom/foo/bar.txt? -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From alex at magenta.com Fri Jul 28 08:03:36 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 14:03:36 +0200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> Message-ID: <8lrt2h013fp@news2.newsguy.com> "Paul Boddie" wrote in message news:39814767.FFEFE5D0 at infercor.no... [snip] > > 1 + "foo" = string ("1foo") > > Doesn't Perl do this last one as well? I refer you to the example I give above - Nope; in Perl, 1 + "foo" is 1. > to have such behaviour permeating one's code is "nasty" to say the least. I do consider it impractical, but what's "nasty" about it? > > 1 + 1j = complex > > > > So please don't tell me you don't want "automagic" type changing when it > > is already there and, I'd wager, you use it extensively. > > Actually, this kind of thing does irritate some people, but at least one can > claim that such behaviour for numbers is more or less accepted in wider circles, Specifically: in mathematics, there is a natural injection from naturals to integers, from integers to rationals, from rationals to reals, from reals to complex. Unfortunately, things are *NOT* all roses and wine in the real world, because we don't really have rationals in Pythons (much less reals, of course:-), but rather an approximation -- so, precision-loss, which is a form of information-loss, threatens...: >>> long(12345678901234567890123L*1.0) 12345678901234567741440L While it takes the explicit 'long' converter to see it clearly, the information loss has really happened in the implicit and silent conversion of long-integer (unlimited-precision) to floating-point (limited-precision). Now *THAT* is nasty!-) I guess not enough people use a lot of long-integers, so they're rarely bitten by this -- but I do a lot of combinatorics, where long-integers are a real blessing, thus, the IMPLICIT information-loss in long->float conversion forces me to be *EXTREMELY* careful. Now if we had unlimited-precision *rational* numbers, with both long-integers and floats getting implicitly and silently promoted to suitable such *rationals*, the world would be a very nice place again...:-). > whereas 1 + "foo" is meaningless to almost everyone except Perl coders. No way -- it's perfectly valid in C, too, except that there it means the constant-string "oo". Really, truly, X my heart, I kid you not, check it out if you don't believe me (I wouldn't blame you for disbelieving this!). Alex From cut_me_out at hotmail.com Wed Jul 12 20:05:59 2000 From: cut_me_out at hotmail.com (Alex) Date: 12 Jul 2000 20:05:59 -0400 Subject: What is UnboundLocalError for? References: Message-ID: Tee hee. I'll get control over that pesky mouse one of these days. This is what I meant to paste in: >>> def f(): l = l + 1 ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 1, in f UnboundLocalError: l >>> Thanks for the replies. Good guess, Tim. Alex. From moshez at math.huji.ac.il Wed Jul 19 07:12:28 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 19 Jul 2000 14:12:28 +0300 (IDT) Subject: Toplevel "test()" functions in standard library In-Reply-To: <14709.32736.512813.306302@temoleh.chem.uu.nl> Message-ID: On Wed, 19 Jul 2000, Rob W. W. Hooft wrote: > I agree that there can be internal routines in a module. But: > > - python has a nice way of hiding those routines from the casual user > of the library, namely adding an '_' before the name. Which is a useful convention, but not a bug if not followed. > - you already argued that base64.test() provided useful functionality. > Why not document it? Because it is useful only to someone who's reading the module's source, not to the casual user. It would only add documentation cruft (IOW, do to the documentation what you tried to prevent it to do to the code -- but documentation is read by humans) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From pehr at pehr.net Thu Jul 6 22:14:44 2000 From: pehr at pehr.net (pehr anderson) Date: Fri, 07 Jul 2000 02:14:44 GMT Subject: os.system References: <8k23tg$38me$1@www.univie.ac.at> Message-ID: <39653D15.E4DE6131@pehr.net> Dear Matthias, In general, calling os.system causes the system to start a shell which then processes the command string. On linux this takes no time at all. On windows I can see that they may not have optmized the shell, especially since the shell under window has so many glaring deficiencies. All I can offer is an explanation, not a speedup. Perhaps you could find a way to talk to a browser that may already be started? I'd recommend browsing "Python for Win32" if you are serious about surviving under windows. -pehr Matthias Huening wrote: > > Some days ago somebody mentioned the possibility to start the standard > browser through os.system on a Windows machine: > > import os > os.system('start http://www.python.org/') > > That works just fine, when I start it from the command line in a DOS box. > But from IDLE it takes a few seconds for the system to respond. Could > somebody explain why an whether there is a speed up for this? > > Thanks, > Matthias From fae at sis.it Fri Jul 7 14:39:42 2000 From: fae at sis.it (fae) Date: Fri, 07 Jul 2000 20:39:42 +0200 Subject: EOF Message-ID: <396623EE.211B14E9@sis.it> Sorry, how can I test if I reached the end of file ? thanks , Leonardo. From tim.hochberg at ieee.org Wed Jul 19 00:33:18 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 19 Jul 2000 04:33:18 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: <39751EFA.6293FDFE@prescod.net> Message-ID: Paul Prescod writes: > Tim Hochberg wrote: > > > > Similarly: > > > > dot((A,B), C) -> A(B)(C) > > dot(A, dot(B,C) -> A(B(C)) > > > > which looks pretty good to me. And it's arguably closer to paper > > linear algebra notation than A*B is. > > Another good idea! You can even make it look like the new-syntax > proposal: > > A()*B()*C > A()+B()+C > A()-B()-C I suppose you could, although what I had in mind was specific to Matrix multiplication. I went ahead and added it to JNumeric, just for grins, and I still think it looks pretty good. Maybe I'll keep it and see if the CNumeric people will follow. An example: >>> from Numeric import * >>> a = arange(5) >>> a(a) 30 >>> a array([0, 1, 2, 3, 4]) >>> b = identity(5) >>> b array([[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) >>> b(a) array([0, 1, 2, 3, 4]) >>> b*a array([[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 3, 0], [0, 0, 0, 0, 4]]) >>> (b*a)(a) array([ 0, 1, 4, 9, 16]) >>> # For those of you who like the more symmetrical look. >>> (a)(a) 30 >>> (b)(a) array([0, 1, 2, 3, 4]) >>> It's easier to do than to explainily yours, -tim From ssthapa at midway.uchicago.edu Sat Jul 29 15:52:54 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 29 Jul 2000 19:52:54 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: Alex Martelli wrote: >It matters if you care about how easy/hard it is to turn those >"non-programmers" into "programmers in the language you >are designing". E.g., the CP4E project, which used to be >aimed at turning _everybody_ into programmers, had better Actually I think it would be easier for non-programmers to learn a language if it has strict typing. That way beginners just need to learn that operators only on objects of the same type and that parameters to a function need to match the type signature of the function. That way they wouldn't need to learn what types a given type can be automagically coerced to. That along with the introduction of type coercion would make understanding a code fragment a lot easier. Plus, if you add a few other features like polymorphic types you could make your program type safe so that any program that compiled would be guaranteed not to have any type errors. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From guido at python.org Thu Jul 27 11:29:15 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 27 Jul 2000 15:29:15 GMT Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: Greg Ewing writes: > By the way, does BeOpen have anything to do with > the BeOS people? If not, it would seem to be a > rather confusing choice of name. No, we're not related. BeOpen is to be read as "be open" (as in "open to open source"). If anything, "Be" made a rather confusing choice of name. For example, Google tells me, when I type "Be" in their search box: "Be" is a very common word and was not included in your search. (To search for Be in Google, you have to type +Be; then www.be.com is the first hit.) --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From billtut at microsoft.com Fri Jul 14 08:35:08 2000 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 14 Jul 2000 05:35:08 -0700 Subject: TypeLib for Python COM Server? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD2D6@RED-MSG-50> No, no, no... no need for a brand new policy... >From the MappedWrapPolicy doc string: _dispid_to_func_/_dispid_to_get_/_dispid_to_put_ -- These are dictionaries (keyed by integer dispid, values are string attribute names) which the COM implementation uses when it is processing COM requests. Note that the implementation uses this dictionary for its own purposes - not a copy - which means the contents of these dictionaries will change as the object is used. Bill -----Original Message----- From: Stefan Migowsky [mailto:smigowsky at dspace.de] Sent: Thursday, July 13, 2000 11:58 PM To: 'John Lull'; python-list at python.org Subject: RE: TypeLib for Python COM Server? Hi, use a special policy as shown in the example ...\python\win32com\servers\dictionary.py There are the invoke and getidsofnames of the dispatch interface overwritten to provide the special DISPIDs Stefan >-----Original Message----- >From: John Lull [mailto:lull at acm.org] >Sent: Friday, July 14, 2000 3:57 AM >To: python-list at python.org >Subject: Re: TypeLib for Python COM Server? > > >Bill Tutt wrote: > >> Don't rely on the 1000 thing. You should specifically >declare the dispid's >> in the Python class. > >How? > >Thanks, >John >-- >http://www.python.org/mailman/listinfo/python-list > -- http://www.python.org/mailman/listinfo/python-list From kuncej at mail.conservation.state.mo.us Fri Jul 21 10:35:00 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Fri, 21 Jul 2000 09:35:00 -0500 Subject: PIL and McMillan Installer References: Message-ID: > Has anyone used Gordon McMillan's Installer to > package a python app using PIL? OK, I figured it out myself (RTFM...) > It looks like _imaging.dll is making calls to .py > files, and I'm not sure how to configure that in > the installer. In my top level script, I added: import ImageFile, JpegImagePlugin These are the files that _imaging.dll needs, and importing them explicitly gets them bundled correctly into the installer. If I needed other image types, I would need to import their respective plugin modules as well. --Jeff From eviltofu at rocketmail.com Wed Jul 26 15:49:47 2000 From: eviltofu at rocketmail.com (Jerome Chan) Date: Wed, 26 Jul 2000 19:49:47 GMT Subject: Reading PCI Configuration Space... Message-ID: Does anyone know how to read the PCI configuration space with Python under Win 98 or Linux? From peter at wl.vg Sat Jul 15 22:50:35 2000 From: peter at wl.vg (Peter Halliday) Date: Sat, 15 Jul 2000 22:50:35 -0400 Subject: Python equivalent of CPAN in Perl Message-ID: <397122FB.71E32674@wl.vg> Is there a module or program like CPAN in Python that collects all the existing modules available in some organized way, and even compiles it for you? If not, that would really provide python with a reliability and usefulness that Perl has. We already beat them in the syntax hands down, let's start catching up in the modules dept. -- Peter Halliday Online Application Developer Whetstone Logic, Inc. http://www.whetstonelogic.com icq#75769411 AIM screen name: hoaggelos From MarkH at ActiveState.com Mon Jul 31 22:11:01 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 01 Aug 2000 02:11:01 GMT Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> <8lrvae015nm@news2.newsguy.com> <3981D157.D7A1A347@intel.com> <8lspqe02drs@news2.newsguy.com> <8m4ovo$g1s$1@nnrp1.deja.com> Message-ID: wrote in message news:8m4ovo$g1s$1 at nnrp1.deja.com... > It would be nice to be able to do permanent connections. The reference > for WNetAddConnection2 says the last parameter is a flag to indicate > whether or not the connection is to be permanent. The win32wnet source > looks like it's hard coded to temporary. good point - I've added a new optional param to handle this. [Note that a patch would also have been acceptable ;-] Mark. From paul at prescod.net Sun Jul 23 02:35:10 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:35:10 -0500 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <3977C029.2C1DC8AC@my.signature> Message-ID: <397A921E.4FCF8214@prescod.net> Greg Ewing wrote: > > ... > > About that particular syntax, yes. But not about > the idea of some sort of zipping syntax. Note that this feature started as a syntax and was "demoted" to a name when it was realized that there was no syntax that would "call out" parallel not cross-product. Plus, why add syntax when a function will do? > If there were a special syntax for zipping, the > compiler could easily recognise this case and > optimise it. We should get to the point where compilers can recognize and optimize built-in functions soon. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From hzhu at localhost.localdomain Tue Jul 18 22:25:43 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Wed, 19 Jul 2000 02:25:43 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: On Wed, 19 Jul 2000 01:21:10 GMT, Tim Hochberg wrote: > >There is a problem with adding new operators to mean elementwise: the >current operators are already elementwise in NumPy. Either all current >NumPy code would have to be broken to fit in with this rule, or the >rule would have to become "elementwise, except when it's not", which >is somewhat less satisfying. I would suggest that it would be more >productive to add operators that are not elementwise, except that >conflicts with the rest of Python. TNSTAAFL. I would have prefered compatibility with NumPy, except for two reasons: 1. MatPy was started because there is a real need for using infix operator for matrix multiplication and the only way available was to define a new class. So for MatPy users, at least, * already means matrixwise. 2. The current list add is not componentwise. I don't know of a way that satisfies every compatibility demand. Because the supply of binary operators has been very limited, each package assigns them to their most deserving ones instead of according to a better overall plan. Had there been more this could have been better coordinated. >Personally I think that this an overlarge crop of operators to be >adding. Since I prefer something like: > >A.inv * B > >to > >A \ B They are equal in math, but not in practice. The former takes O(n^3) computation while the latter is O(n^2). The former is also less accurate for near singular A because of rounding error. >anyway, the only operator I feel is missing is the matrix >multiplication. And, conveniently, there is an appropriate opperator The other operators are also useful. For example, the + and .+ do different things. If you add a row and column vector with + it will complain about shape mismatch, as defined in linear algebra. With .+ it will give a matrix properly extended to both rows and columns. This has been asked for in this thread. I've seen it been called prolongation, continuation or cross extension, among others. In fact, in MatPy, the .+ .- .* ./ do exactly what + - * / do in NumPy. >> names .+ "is" .+ types >> map(lambda x,y: x+"is"+y, names, types) > >There's a bit of a problem here since "is" is a sequence. I'm not sure >how you propose to have sequences of unequal length work with .X, but >I'd think this would have to be: > >names .+ ["is"]*len(names) .+ types Oops! It should be names .+ ["is"] .+ types Note the extension mechanism is used. Sequences with different length raise exceptions, except when one of them has length one, which is extended to the other length. Huaiyu From richard_chamberlain at ntlworld.com Wed Jul 26 12:29:32 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 26 Jul 2000 17:29:32 +0100 Subject: Deleting files with wildcards References: <397f046d.193858654@news.atnet.at> Message-ID: Hi Manfred, import glob,os filelist=glob.glob('c:/*.txt') for file in filelist: os.remove(file) Richard Manfred Pisecky wrote in message news:397f046d.193858654 at news.atnet.at... > Hello everyone! > > I have to delete a bundle of files, e.g. *.txt in a portable way (it > must work for Linux and NT). > > I use Python 1.5.2. and have not found a way to either delete files > with wildcards or to read the directory content (and do it file by > file). > > Is there a portable way in 1.5.2 ? > > Thanks, > Manfred Pisecky From cjc26 at nospam.cornell.edu Mon Jul 17 16:12:24 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Mon, 17 Jul 2000 20:12:24 GMT Subject: mxTextTools Question, Number 2 :) References: Message-ID: * Stephen Hansen menulis: | | ...works, I suspose... but, here's the harder part. I want to ignore that | whitespace as delimiter if the next character is a special | | So, "This &that" would end up capturing "This that". | | For the life of me I can't even fathom how to do the above! Well, I have a | vague conception of what needs to be done but can't get it down on | paper(Y'know what I mean. :)) Would it be possible to have the special character come >before< the space, rather than after? For example, "This& that". That might be a bit easier to do. If you can't do it that way, well..I don't know mxTextTools, but I do know a little about writing parsers in general. The way I would do it is to have the parser jump to a special state whenever it encounters a space; in that state, if the next character is "&" then add a space to the text buffer and jump back to the "Text" state. Hopefully you can translate the above into mxTextTools code. :) -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From kulbrich at yahoo.com Sun Jul 30 02:33:57 2000 From: kulbrich at yahoo.com (Karl Ulbrich) Date: Sun, 30 Jul 2000 02:33:57 -0400 Subject: Perl is worse! In-Reply-To: ; from grey@despair.rpglink.com on Sun, Jul 30, 2000 at 02:35:06AM +0000 References: <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8lvslc0mn8@news2.newsguy.com> Message-ID: <20000730023357.A3193@exeter.exeter.org> Quoting Steve Lamb (grey at despair.rpglink.com): > On Sun, 30 Jul 2000 02:22:31 +0200, Alex Martelli wrote: > >And of course None can also be converted, it's just not converted > >by a plain int(x). But it just takes an int(x or 7) to fix that, > >for example (if one wants None to be converted to 7...:-). > > It is my understand that in an int(None or 0) what is happening is that > the None fails, the or kicks in and we're really int()ing an integer in the > first place, not actually converting the None. Perhaps Alex should have said "a variable containing None can also be converted [to an integer]", but the intent (solving your problem) was clear. You are correct that the actual None object is not converted -- the 'or' is selecting the other value (7, in the example) if None occurs. > >Losing accumulated logs, and/or logging false data, would be utter > >disasters. > > You're speaking in absolute terms on something which is best determined by > the end user, not the language. To me, for a lot of the logs I process, no, > it isn't a disaster. It isn't even a minor annoyance. It is just a speck of > dust on a rather large desk that I couldn't care less about. Having the logs > processing puke on me, or any other of dozens of applications I can think of, > because of a inconsiquential burp in the data is the real annoyance. In that case, would "inconsistent is better than consistent" be an accurate reflection of your criteria for a log processing language? Actually that's not a fair generalization. For your logs, clearly minor errors in the data don't matter to you. You've been shown examples where minor errors mean a LOT, and you've also been shown Python ways to ignore the kinds of errors your data generates. It's *very* unreasonable to expect that *everyone* would want inconsistent data to slip through unnoticed, even if it is reasonable for a particular problem domain. > >bug is clearly the priority; if subtly-false data were being logged > >instead, > > Uhm, logs processing process logs for one of a variety of uses. IE, the > data has already been logged, how can it be falsely logged again? Easy. As an example, suppose your program processes 400 MB worth of http logs each day (not an uncommon task), but extracts and logs only a fraction of that for long-term storage (daily logs are not deemed worthy of permanent backups). If weeks go by and you've silently missed a value because Someone Else changed a title somewhere, who will wish he'd seen the error the day it occured instead of a month later when there's no July data? > >Why would you need to keep track of all things in the former > >paragraph? Just be explicit about what is to be done for each > >of the cases it can be, and you're all set. > > Except now you need to do tons of conversion at different levels depending > on what you do with the data. You either type it up front and have it fail > later, or type it later dozens of times. Neither is appealing to me. I think you're exagerrating the burden; Alex gave you examples (in another msg) that show how to make a function that returns matches as integers. > >Furthermore, I keep pointing out that, if you call the groups method > >of the match object, what Python returns for non-matching groups IS > >UP TO YOU: it will return the argument you pass to groups, None if > >you choose to pass no argument. So, *what* is supposed to be 'sad'?! > > I don't see where I can tell it to pass something other than None on a > match. The docs I read, (not here) state that it /will/ return None on a > no-match, not that it /can/ and that you can override it. I don't see it either (Alex?) in the library reference. Personally I thought both the 'int(x or 0)' approach and the function Alex suggested were good ways to establish problem-specific default values, especially since '0' isn't always an apprpriate default. Karl Ulbrich From ingo.adler at synacon.ch Thu Jul 13 20:41:01 2000 From: ingo.adler at synacon.ch (Ingo Adler) Date: Fri, 14 Jul 2000 01:41:01 +0100 Subject: Built-in exception class not found Message-ID: <396E619D.5BD09DF2@synacon.ch> I compiled Python 1.5.2 statically with CBuilder 5.0. When I start my python program I get the error message: Built-in exception class not found: EnvironmentError. Library mismatch? Warning! Falling back to string-based exceptions Why? I've only installed 1.5.2. I've configured the PYTHONPATH to the Pythonlibs. When the program starts, it finds the exceptions.pyc. Any suggestions? Ingo Adler -------------- next part -------------- A non-text attachment was scrubbed... Name: ingo.adler.vcf Type: text/x-vcard Size: 338 bytes Desc: Card for Ingo Adler URL: From db3l at fitlinxx.com Fri Jul 21 14:14:04 2000 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jul 2000 14:14:04 -0400 Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> <8l9ul4$9fa6$1@nntp6.u.washington.edu> Message-ID: Donn Cave writes: > Quoth David Bolen : (...) > | And only fully process files less than 8K in size. The call to > | file.readlines(8192) returns the list of lines contained within the > | first 8K of the file (approximately), and that's all the 'for' is > | going to iterate over. You have to repeatedly call file.readlines() > | again to keep reading the file, which puts you pretty much back in the > | original readline() mode, just with bigger chunks. > > Sure, but it's a useful idiom where the expected file is under > ca. 500 bytes in any sane case. The upper limit keeps the potential > insane case from wiping out the program. (Numbers arbitrary.) > Not an approach we would always want to take, but there could be > a place for it. Oh sure - it's good as a safety valve - I was just pointing out that it didn't address the underlying question in the thread which was to iterate over all the lines of a file, regardless of size. Under the conditions you note (small file, don't want to risk a large one causing problems and don't mind ignoring the overflow) it's a perfectly good idiom and safer than just a blind readlines(). -- -- 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 prescod.net.bbs Mon Jul 17 01:20:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 05:20:02 GMT Subject: Type checking in python? Message-ID: <3bR0e2$j9i@openbazaar.net> Matthew Cline wrote: > > def my_func(foo, bar, quux): > if not isinstance(quux, Quux): > raise RuntimeError("param 'quux' must be of class 'Quux'") Let me also point out that in many cases, this style of programming would be frowned upon by serious Python programmers. For instance, if you check that something is a string, your code will complain when it is handed a Unicode string, even though it would probably work fine. If you check that it is an open file, then your code probably will complain about stringIO file-like objects, even though it would probably work fine. If you check that it is an integer, your code will complain about integers, even though ti would probably work fine. In general, the Python philosophy is to "just try it" and see if it works. Sometimes type checks are appropriate but if you do it on the entry to every function, you are probably doing too much work and making your own life (or someone else's) harder later on. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From gherman at darwin.in-berlin.de.bbs Fri Jul 14 05:20:03 2000 From: gherman at darwin.in-berlin.de.bbs (gherman at darwin.in-berlin.de.bbs) Date: 14 Jul 2000 09:20:03 GMT Subject: Test writing volunteers needed Message-ID: <3bOcS3$mTr@openbazaar.net> "A.M. Kuchling" wrote: > > Skip Montanaro wrote: > >I'm look for a few people to write some regression tests for the posix (and > >windows or mac equivalents), os and sys modules. Some of that functionality > > To start the ball rolling, here's a little test case for the set{re,e}{u,g}id > functions that I added to the CVS version last night. What about using the excellent Python unittest module (pyunit.sourceforge.net) to accomplish this, like in the code below? Note that I've not tested it on a Unix box and suppose the calls to some get* functions look in lines with trailing '# ??' do really look like shown... Apart from these details, what unittest gives you is a very simple and useful test framework for *automated* test- ing where you specify your test cases *with expected out- put* such that you can build entire test suites to be run whenever you feel like you need a new short "confidence kick" before you continue with new functionality. Ideally, i.e. as an XP purist, you should write these tests *before* writing the *real code*! Dinu -- Dinu C. Gherman ................................................................ "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") import unittest class SetXIDTestCase(unittest.TestCase): "Test if a single PDF Number is read and written correctly." def testSetreuidSetregid(self): "Simple test case for os.setreuid(), os.setregid()" import os, pwd uid = os.getuid() msg = "This test must be run as root; skipping" assert uid == 0, msg nobody_uid, nobody_gid = pwd.getpwnam('nobody')[2:4] # Set real uid and gid to root, effective uid and gid to nobody os.setreuid( 0, nobody_uid ) os.setregid( 0, nobody_gid ) # Change effective ID to nobody os.seteuid( nobody_uid ) # Expect these to fail try: os.setuid( 1 ) except os.error: pass else: msg = 'Should have been unable to change UID to 1' assert 1 == 0, msg try: os.setgid( 1 ) except os.error: pass else: msg = 'Should have been unable to change GID to 1' assert 1 == 0, msg # These should succeed, since we're just swapping the IDs os.setreuid( nobody_uid, 0 ) msg = 'Unable to swap IDs.' assert os.getreuid( nobody_uid ) == 0, msg # ?? os.setregid( nobody_gid, 0 ) msg = 'Unable to swap group IDs.' assert os.getregid( nobody_uid ) == 0, msg # ?? # These should now succeed, since we're now back to root privilege os.setgid( 1 ) msg = 'Unable to reset group ID.' assert os.getgid() == 1, msg os.setuid( 1 ) msg = 'Unable to reset user ID.' assert os.getuid() == 1, msg def makeSuite(): suite = unittest.TestSuite() suite.addTest(SetXIDTestCase('testSetreuidSetregid')) return suite if __name__ == "__main__": unittest.TextTestRunner().run(makeSuite()) From p.knight at ktgroup.co.uk Thu Jul 6 04:54:17 2000 From: p.knight at ktgroup.co.uk (Pat Knight) Date: Thu, 06 Jul 2000 08:54:17 GMT Subject: PROCESS QUESTION - t.py [01/01] References: <3961D1D2.9C66B425@sicon.net> Message-ID: <8k1hfq$1v8$1@icarus.knowledgegroup.co.uk> In article <3961D1D2.9C66B425 at sicon.net>, sergio wrote: > Hi all, I'm working in NT SERVER 4.0 > >How can i search the id of a process running, searching it by the name? > You need to get Mark Hammond's Pythonwin package (version 129 if you're running Python 1.52). Use the win32pdh package to enumerate the processes on a system and then process the returned list. Attached is a function that doesn't quite do what you want. It tests to see if a process with a given id (and optionally name) is running. It should be easy to modify to get an id for a name. Cheers, Pat begin 644 t.py M:6UP;W)T('=I;C,R<&1H#0II;7!O3H-"B`@("`C(%9E M&ET*#$I#0H-"F1E9B!C:&5C:U]F;W)?<')O8V5S M&5C=71A8FQE(#T@)R&5C=71A8FQE(BX@(F5X96-U=&%B;&4B M(&-A;B!B92!A('-T7,@=')A;G-F;W)M(&%L;`T*("`@(&5X96-U=&%B;&4@;F%M97,@=&\@ M=7!P97)C87-E('=I=&@@82`N15A%(&]N('1H92!E;F0 at 8F5F;W)E#0H@("`@ M8V]M<&%R:6YG+ at T*("`@("&5C=71A8FQE M+'1Y<&5S+E-T&5C=71A8FQE(#T@*&5X M96-U=&%B;&4L*0T*#0H@("`@(R!)9B!T:&5R92!A3H-"B`@ M("`@("`@9F]R('`@:6X@:6YS=&%N8V5S. at T*("`@("`@("`@("`@8V]U;G1E M2D-"B`@("`@("`@9F]R('`L8R!I;B!C;&ES M=#H-"B`@("`@("`@("`@('1R>3H-"B`@("`@("`@("`@("`@("!O=&AE&-E<'0Z("`@("`@("`@("`@("`@("`@("`@(R!I9B!A('!R;V-E M'1R86-T M('1H92!Psynonym for cross-product). We're looking just to pair up elements. > no you need the pairwise concatenate product of the sets considered as vectors mumble handwave handwave -- Robin Becker From m.faassen at vet.uu.nl Mon Jul 31 06:00:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 10:00:50 GMT Subject: experts disagree on "call-by-reference" References: <8m29o0$p9g$2@news.dtc.hp.com> Message-ID: <8m3ioi$du4$2@newshost.accu.uu.nl> Jeremy Hylton wrote: > Here are two other examples that may illuminate Python's parameter > passing mechanism. > The C++ Programming Language (Stroustrup), 3rd ed: > The section of references (5.5, p. 97-100) has a simple example of > parameter passing with references. > void increment(int& aa) { aa++; } > void f() > { > int x = 1; > increment(x); // x = 2 > } > There is clearly no feature in Python to accomplish the same thing. > The call-by-reference allows the variable aa in increment to serve as > an alternate name for x in f. A change to aa results in a change to > x. I think this example is misleading, as you used an integer, which is immutable in Python. For mutable variables you can accomplish much the same thing; the difference with this C++ example is that the underlying value can be changed directly (integers are mutable in C++!). Another difference is that in Python, *all* variables behave as if they were C++ 'references' (or C pointers with implicit dereferencing). In the C++ example there is a reference-taking going on as soon as the increment() function is called; in Python no reference needs to be taken as it's already a reference, always. > "A History of Clu" (Liskov) in History of Programming Languages > (Bergin & Gibson, eds.), p. 483-4: [snip] > Given this extend description of CLU parameter passing, I believe it > would be fair to say that Python is also a call-by-object language. Yes, the description seems near-identical to the way Python works. I think the confusion arises in the 'call/pass by' part of the expression 'call/pass by reference'. 'call by reference' at least for many seems to imply that a reference is taken as soon as the call happens (as in the C++ example, for instance, and I believe also in Perl from what I've seen). In Python, this never happens; everything is a reference (to an object) already, so the references are simply passed along. So you could say that Python has reference semantics, and that references are the things that always are used and passed. But 'call by reference' definitely seems to carry unwanted connotations (the taking of a reference), and 'pass by reference' seems to have this trouble as well (though I'd say less so). Even so, references are the things that are passed. If the 'call-by-object' terminology is standard, then I'd agree Python is call by object. But that doesn't mean talking about references isn't useful; it would be in CLU too I presume from this description. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From braun32 at ibm.net Sun Jul 23 06:18:51 2000 From: braun32 at ibm.net (Stefan Braun) Date: Sun, 23 Jul 2000 12:18:51 +0200 Subject: Graphs - I need more graphs ( Simulation development ) References: <397a5658.88821067@news.online.no> Message-ID: <397AC68B.A07CAB3@ibm.net> Thomas, maybe this package is useful for you: http://www.zpr.uni-koeln.de/~gato Stefan Thomas Weholt wrote: > > like that. I know I`m probably the problem here, but if anybody has > any input on this it would be great, if just a simple code example on > graphs and how the work. :-> From jkraska1 at san.rr.com Sun Jul 30 14:03:56 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 30 Jul 2000 18:03:56 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> Message-ID: <39846ECC.DF5FE175@san.rr.com> > >This is a conceptualization issue, and I suspect to a degree, > >false. If "x" is merely a label, one can imagine x labeling > >3 or x labelling red quite easily. Your analogy works because > >you carefully framed it, but there's nothing at all to say that > >your framing of it was right. > > > >To the contrary; while I can't prove it, I do believe it's wrong. > > Nobody expects a proof, but a just-as-carefully-framed > counter-analogy would be a good start... I don't know why I'd need a carefully framed analogy at all. The labelling concept speaks for itself, and in fact is the way that some people teach python. It seems to be quite intuitive. C/ From grey at despair.rpglink.com Sat Jul 29 18:53:04 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:53:04 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 11:13:48 +0200, Alex Martelli wrote: >Let's take your case, that of parsing and interpreting >input strings of the form 'iDj[+k]' as found in role >playing games ('roll i j-sided dice and add k'). Say >that you now also need to support GURPS, which only ever >uses six-sided dice, so the j is often omitted *and needs >to default to SIX*, NOT to zero, when it is. GURPS, as well as other games, would be in different classes with the class defining defaults for the dice. >As the 'behaving oddly' will typically produce irreversible alterations >of a precious persistent database Only if you're typically working with persistent databases. >while the crash can at least be assumed to leave the database intact, the >choice is anything but easy. Would you rather die suddenly and painlessly, >but with no chance of making a last will and testament, or slowly in >excruciating pain, but with a last chance to put your worldly affairs in >order? What a heck of a choice to have to make! Personally, if my email client died because of some uncaught exception versus me being able to close out my message beacuse of some bug in a display routine, I'd rather be able to close out and save my 20k message than have to retype it. There is more to programs than databases. >Fortunately, it doesn't have to be made: wrapping the top-level entries >in a try/except is so TRIVIALLY easy, that there is really NO excuse >for any program not doing so. Great, and then we're out of some other common practices. CNTL-C, for example. :P >but that does not stop ME from having a last will registered, nor >from wrapping my programs in try/except...:-). Just out of curiousity, how do you get back down into the loop if it is, say, 12 deep? Does Python hit the handler, do its thing, drop back down? >Hey, you just *SAID* there could be a None, so you had NOT made >sure at all that they did contain numbers! None is NOT a number. >The empty sequence is not a number. You're contradicting yourself! No, I made sure there was a number in there, Python is the one that decided to drop a None in. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From kpmurphy at my-deja.com Fri Jul 21 10:45:13 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Fri, 21 Jul 2000 14:45:13 GMT Subject: closing a socket References: <8l72lp$mah$1@nnrp1.deja.com> Message-ID: <8l9nll$e2f$1@nnrp1.deja.com> william and co, so what does that line do? does it force a socket connection closed or are you able to do that? here's the problem. the server goes down, and it closes all of its connections, but a client is still running. when the server tries to restart, it can't because the socket is in use. does that magic line below fix this? thanks! -->keith In article , William Annis wrote: > > Keith Murphy writes: > > > is closing sockets tricky? or am i doing something wrong... shouldn't > > this work? > > There is one small thing you need, something every sockets > beginner misses at first. I know I did... > > > s = socket(AF_INET, SOCK_STREAM) > > You need the set the 'reuse address' option: > > s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) > > > however, i get the following error if i try and run it a second time: > > > > socket.error: (125, 'Address already in use') > > -- > 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 > Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at knowledgetrack.com Wed Jul 12 16:55:17 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Wed, 12 Jul 2000 20:55:17 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <396CB0D3.8F7BC8E5@prescod.net> Message-ID: On Wed, 12 Jul 2000 12:54:27 -0500, Paul Prescod wrote: >Richard Tobin wrote: >> >> Is it legal (it seems to work) to change the class of an object by >> assigning to its __class__ attribute? In particular for the case where >> the new class is a subclass of the old. > >It language reference doesn't say. I think you're on your own but I >wouldn't expect it to break soon. I also wouldn't expect it to work in >JPython or maybe even Zope. > I guess the interesting question is: If __class__ is changed, is there any trace of the older class left? If it works in the module it is used, will it break when it's imported by other modules? I also find I need to do this a lot of time. For example, when you read something from a file, you want to return an object of a specific class based on the content. The easiest way to do it appears to be class General: __init__(self, data): self.data = data if data is something: self.__class__ = Special1 else: self.__class__ = Special2 class Special1(General): pass class Special2(General): pass Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From see at message.body Thu Jul 27 01:08:01 2000 From: see at message.body (Sam Penrose) Date: Wed, 26 Jul 2000 22:08:01 -0700 Subject: Variables in strings.. References: <8lh75e+tjtl@eGroups.com> <119330503709.20000724135021@buz.ch> Message-ID: In article <119330503709.20000724135021 at buz.ch>, Gabriel Ambuehl wrote: > Hello Steve, > Monday, July 24, 2000, 12:52:30 PM, you wrote: > > > print "Hello %s" % names[1] > > to the eyes of anyone but a Perl afficionado. > > Perhaps. But in real world (tm) CGI scripts, one needs more than just > one variable in there. I've got Perl scripts who insert aroun 40 > variables (including array slices) during one print <<"EOF" > instruction. I could live with the "%(myvar)" % vars() syntax if there > would be a possibility to reference to lists and dictionary entries as > well. Without it, it's a real pain to quickly write CGI scripts. > Hell, > content=' ' + pair[0]+ ' > ' + pair[1] + ' <8l32vu$l7$1@news.jump.net> Message-ID: <39751236.240D6EAF@gs.verio.net> I've been playing UO for years and it is good to hear that they are going to a stable enviornment to run thier servers... Jason Ely wrote: > > Origin is currently using Python as the scripting language of choice for > Ultima Online II > > They love it from what I understand. What drove them to it? > > -Jason > > "Mallor" wrote in message > news:v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... > > Are any of you game developers out there using Python as your game > engine's > > embedded scripting language? I am wondering what drove your decision to > use > > Python instead of other embeddable scripting languages? I'd like to hear > what > > your overriding concerns were, and also what they are now, having put > Python to > > the test. > > > > -- > > Cheers, Infernal Troublemaker Troll > > Mallor "By simple mistake, mortals themselves amuse." > > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list From eq3pvl at eq.uc.pt Mon Jul 17 07:05:20 2000 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Mon, 17 Jul 2000 12:05:20 +0100 Subject: I'm confused with win32pipe Message-ID: <3972E870.C0A75F4B@eq.uc.pt> I need to run some commands on a win98 computer and I'm having some problems to understand win32pipe behavior If I write (pin, pout) = win32pipe.popen4(r'copy c:\tmp\*.* c:\tmp2\','t') the script copies some of the files (not all!). I have some questions. The first is where can I find more documentation for win32pipe (the pythonwin reference is very short) ?. Is the process run in a subprocess? What's the meaning of the 't' and 'b' flags? Thanks for the attention, pedro lima From jim at interet.com Mon Jul 10 13:24:06 2000 From: jim at interet.com (James C. Ahlstrom) Date: Mon, 10 Jul 2000 13:24:06 -0400 Subject: Embeded in GUI,Python output ? References: <8jihfg$et5$1@nnrp1.deja.com> Message-ID: <396A06B6.9A56CB0B@interet.com> heath7952 at my-deja.com wrote: > > I'm attempting to embed Python inside a GUI. Python will serve as a > command interpreter. I can type commands in the GUI command window and > they are being executed correctly, I'm using PyRun_String. The only > thing I need now is the output from the commands , so I can post them in > the GUI command window. > > i.e. a = 10 > print a > > I'd like to be able to get at the output string "10" which should be > returned, and display it. This is printed to the "write" method of sys.stdout, so you need to replace sys.stdout with your own method. Jim Ahlstrom From dgoodger at bigfoot.com.bbs Tue Jul 18 00:10:02 2000 From: dgoodger at bigfoot.com.bbs (dgoodger at bigfoot.com.bbs) Date: 18 Jul 2000 04:10:02 GMT Subject: pty.py: any example code out there? Message-ID: <3bRaOQ$kmI@openbazaar.net> I'm looking for some concrete examples of the use of pty.py or any equivalent. I've written a wrapper for the passwd program on QNX (a POSIX-compliant realtime OS), and passwd is reluctant to be wrapped, writing directly to the console/tty/pty, bypassing stdin/out. My wrapper currently uses telnetlib.py to do its dirty work, but it's a kludgey solution. Any samples, examples, pointers, hints or tips out there? Thanks in advance! -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From alex at magenta.com Sat Jul 29 06:06:08 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 12:06:08 +0200 Subject: Newbie DATA STRUCTURES Question. References: <398248BC.32DE3CC@nycap.rr.com> Message-ID: <8luhsk11ce8@news2.newsguy.com> "gbp" wrote in message news:398248BC.32DE3CC at nycap.rr.com... > > Hi all, > > I have experience with Perl but non with Python. > > I need to write a script to read a large text file into a structured > format. Which is a list of 'records', one per line? You can get the list of the lines by calling the readlines() method on the file object. (If your file is too large to fit in memory at once, you will have to loop line by line, but that's another issue). If you have a lineToRecord function that takes a line and outputs the record you desire for it, you can build your list of records very easily (if it can all fit in memory at once, transiently): theresult = map(lineToRecord, thefile.readlines()) while if you have to loop because it can't all fit in memory it becomes something like: theresult = [] while 1: line = thefile.readline() if !line: break theresult.append(lineToRecord(line)) or equivalent forms (often discussed because many don't like the while 1: ... break idiom, but that's quite another issue). > In Perl one can create a list of records using something like pointers. > So really you have a list of pointers-- each one pointing to an > anonymous record. Each record is some data from a line in the file. The pointers are, if you will, totally implicit in Python. Just think of the list-of-records. So, the lineToRecord function is really all you truly care about. > Since I learned data structures in languages with pointers (C, pascal) > I'm stuck. How does one go about constructing a list of records in > python? My python is still pretty weak. I understand how the lists > work (a lot like Perl). I understand that you can use objects as > records. I don't really get the full OOP though. I guess that you > can't make record anonymous in python? Is that right? Can you have > pointers? You cannot FAIL to have pointers, but the language handles them for you, so you never really have to think about them. If your records are just a collection of fields, and it's OK for the fields to be identified by sequence, you will probably want to use a tuple for each record (a list would also do, but a tuple is clearer and more efficient if you don't need it to be mutable). E.g., say that for each line you need to extract its length, the 1st character, and the 4th character (and you know all lines are at least 4 characters long). Then: def lineToRecord(line): return len(line), line[0], line[3] If some lines are shorter you may want more discrimination: def lineToRecord(line): l = len(line) if l>3: return l, line[0], line[3] else: return l, line[0] or if you prefer (a matter of style): def lineToRecord(line): try: return len(line), line[0], line[3] except IndexError: return len(line), line[0] and that is also OK -- there is no need for all entries in the list to have the same length (not even for them to be in any way homogeneous, e.g. all tuples -- it only depends on what proves most convenient to YOU, in terms of first preparing the list, and later using it in some ways). If you need more structure to your record, than just a sequence of fields (where each field can be a scalar, None, another nested sequence, ...), you will often choose to return a dictionary from your lineToRecord function. Tuples and dictionaries are anonymous. Rarely, and only if your structuring needs are heavy, will you NEED to return 'full-blown objects', i.e. instances of some class of yours (which cannot be anonymous), although you may _choose_ to do it for convenience even when a tuple or dict would suffice (a class-instance might just be a handier way to pack and access a dictionary, in some cases). > When I was learning Perl I found a manual page on this. Couldn't find a > example for Python. Hope that doesn't mean it can't be done. I haven't yet found a task that can't be done in Python -- and what's more, most can be done very elegantly & conveniently. Alex From amused at webamused.com Sat Jul 29 18:18:31 2000 From: amused at webamused.com (Joshua Macy) Date: Sat, 29 Jul 2000 22:18:31 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <3982F04D.74FCF41C@webamused.com> Message-ID: <39834B9F.C6877761@webamused.com> Steve Lamb wrote: > > On Sat, 29 Jul 2000 15:49:00 GMT, Joshua Macy wrote: > > I could be wrong, but I'm under the strong impression that the term > >"automagic" is thrown around repeatedly as a description of Perl's > >behavior in Programming Perl. Does that make Larry Wall a disgrace to > >the language he invented? > > No because he doesn't throw it around as a negative of the language like > some people here did. > So it's not the term itself you find offensive, but the way it's used? It sounds to me like what you're objecting to is the mere fact that some people dislike the behavior that Larry Wall calls "automagic", not that they use the same term that he does to describe that behavior. Joshua From mallor at 3DProgrammer.com Wed Jul 19 04:59:08 2000 From: mallor at 3DProgrammer.com (Mallor) Date: Wed, 19 Jul 2000 08:59:08 GMT Subject: Python in game development? References: <963990339.783645@marvin> Message-ID: "Jorrit Tyberghein" wrote in message > > In the Open Source Crystal Space 3D engine we are working on a framework for python > scripting. It is already working reasonably well but you cannot yet do everything > that you'd want to do from a python script. Why did you choose Python as opposed to any other scripting language? In particular, what are your experiences so far with efficiency issues? This seems to be a knock against Python from the articles that I read, but of course the efficiency of a language implementation can be a moving target, if the developers have their priorities set in that direction. -- Cheers, Infernal Troublemaker Troll Mallor "By simple mistake, mortals themselves amuse." From fiona at sitegnome.com Sun Jul 16 21:24:38 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Mon, 17 Jul 2000 11:24:38 +1000 Subject: Importing modules... References: Message-ID: <39726056.871BEB5@sitegnome.com> Hi Aaron, Perhaps this will help -> How do I import a file that isn't in the pythonpath? http://www.faqts.com/knowledge-base/view.phtml/aid/4719/fid/245/lang/ regards, Fiona Czuczman From mkrisch at netscape.net Mon Jul 17 23:11:08 2000 From: mkrisch at netscape.net (mkrisch at netscape.net) Date: Tue, 18 Jul 2000 03:11:08 GMT Subject: hexidecimal output as default? Message-ID: <8l0hs1$s3q$1@nnrp1.deja.com> how can i make it so the interpreter defaults to hexidecimal output? what i mean is the following: >>> i = 0xa >>> print i 10 >>> i 10 what i really want is to get the following: >>> i = 0xa >>> i 0xa --mk Sent via Deja.com http://www.deja.com/ Before you buy. From jacobs at darwin.epbi.cwru.edu.bbs Mon Jul 17 22:00:02 2000 From: jacobs at darwin.epbi.cwru.edu.bbs (jacobs at darwin.epbi.cwru.edu.bbs) Date: 18 Jul 2000 02:00:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRX63$je4@openbazaar.net> > In a program where there are a lot of computations, you'll get either > something like a ritual on every line, > PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) > PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) > PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) What if it could be as simple as: e(r'(A .* B)\C') # --> PyAlgebra.evaluate(r'(A .* B)\C', globals(), locals()) e(r'(A .* B)\C') e(r'(A .* B)\C') where A, B and C are bound to variables in the current namespace automatically? Does this not go 95% of the way toward the ideal solution? > Everybody would rush for the latter. In the end what's inside the quote > would be a minilanguage with all the bells and wistles of python. This > would be just similar to patching the parser, with lesser results. I disagree with your conclusion. Having worked with many algebra and statistical languages, I know the road you are undertaking. It doesn't and can't stop with one extra dot in the grammar. To do it right, you need the ability to break more rules that are intrinsic to Python's core. e.g., consider changing the rules for '\' as above. Another advantage to compromising and implementing a domain specific mini-language is that it simplifies some very tough design issues that only come up when working with the full Python grammar. Some of these syntactic and semantic issues are very likely irreconcilable. In the end we could end up with a any number of splinter languages with inferior support and narrow audiences. Lets not forget we are a community of users with very diverse goals, all trying make our lives easier by building better tools. -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 778-8211 <-------- S.A.G.E. Project Technical Coordinator | Department of Epidemiology & System Administrator | & Biostatistics Internet E-mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From mlp at amrose.dk Wed Jul 12 08:36:37 2000 From: mlp at amrose.dk (mlp at amrose.dk) Date: Wed, 12 Jul 2000 12:36:37 GMT Subject: TypeLib for Python COM Server? Message-ID: <8khooj$dus$1@nnrp1.deja.com> hi all. i'm in a situation where i'd like to have a typelib for a python com server, for use in a c++ client. i tried to just use midl on an idl i made to reflect the interface of the python server. this didn't work out, since when compiling the client code the tlb file is not recognized. my question: is there an automatic, easy, or standard, way to produce a typelibrary for a com server implemented in python? if not, is it possible at all? if so, could anybody help me with the details? a complete example would be splendid! python rules! 'gards, morten lind petersen, denmark Sent via Deja.com http://www.deja.com/ Before you buy. From dpetrov at www.yu Mon Jul 3 12:50:49 2000 From: dpetrov at www.yu (Dean Petrov) Date: Mon, 3 Jul 2000 18:50:49 +0200 Subject: Selling software Message-ID: <8jqge7$irv$1@cer.yubc.net> !!! Software WareHouse !!! We're selling software! Best prices! Under $ 100 free shipping!!! Order today: dpetrov at www.yu From dworkin at ccs.neu.edu Mon Jul 17 20:10:15 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 17 Jul 2000 20:10:15 -0400 Subject: Routing sys.stdout.write (print) In-Reply-To: Joseph Betz's message of "Mon, 17 Jul 2000 16:06:15 -0700" References: <39739167.39ED5F38@bmi.net> Message-ID: Joseph Betz writes: > I'm getting unexpected results from the following code: > > import sys > from sys import stdout > x = stdout > > class Writer > def write(self, string): > x.write(': ' + string) > sys.stdout = Writer() > print "Ni!" > x.write('Ni!\n') > > The output I'm getting is: > > : Ni!: > Ni! > > I am looking for a solution so that the second colon isn't in the > output. A good solution > may be very different then the code I have here. This is due to the implementation of the print statement, which effectively calls sys.stdout.write a separate time for the trailing newline. If you use sys.stdout.write() directly instead of the print statement, you won't have this problem. -Justin From hzhu at localhost.localdomain Thu Jul 20 21:10:54 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 01:10:54 GMT Subject: Discussion: new operators for numerical computation References: <8l85ae$487@stochastic.eng.umd.edu> Message-ID: On 20 Jul 2000 20:25:50 -0400, Warren B. Focke wrote: > >But I think also that we should consider not just user base, but code >base - how much code is already out there that will break under the >various suggestions. Ah, I see where the problem is! No. Not a single line of code. (well, see below.) For ordinary numbers, all the operators are exactly the same. For classes, they define their own __mul__ that is hooked to *. This will not change, unless you choose to redefine __mul__. For the new operators, be it .* or @ or @*, they are not defined for anything other than numbers. Each class is free to define them in any fashion. If your module uses, either from Numeric import array a, b, c = array ... matrixmultiply(a,b)*c or from MatPy import Matrix a, b, c = Matrix ... a*b.e_mul(c) nothing would cease to work, whatever the meaning of the new operators. (This is not strictly true, because MatPy actually uses __dotmul__ but s/__dotmul__/e_mul/ would do the trick.) Only when you decide to actually use the new operators which were not available today, then you need consider their meaning. In fact, even if NumPy and MatPy uses opposite meaning for * and @*, not a single line of existing code would break. These two packages already work perfectly with each other, and I do use both in production code. I see the eventual unification of MatPy and NumPy somewhat along the line of migration from the regex to re module. That is, it would be possible in the future to define a new package with a different name, with an interface that has advantage of both, or better than both. People could just use the new package for new code, which could coexist with old modules as well. They can migrate their code at leisure time. After writing this, I have the feeling that maybe after all it is not so important to consider what's the semantics of these operators. We do agree on the syntax of these operators. Is this enough for the PEP? I don't know. If it is called __dotmul__ this might already be enough? We are already allowed to define two interfaces. I don't see why introducing new operators would make one of them disallowed (break). That's why I'd be more interested in new code than existing code, as the purpose of these operators is to make writing future codes easier. Just my 2c. Huaiyu From mfletch at tpresence.com Sun Jul 23 01:20:14 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 23 Jul 2000 01:20:14 -0400 Subject: bit manipulation frustration Message-ID: Convoluted, yes, but this might give you some ideas for manipulations (or it might give you convulsions ;0) )... import struct def toRGB( line ): line = struct.unpack( 'H'*len(line), line) result = [] R = 64512 G = 2016 B = 63 for integer in line: result.append( ( R&integer >> 10, G&integer >> 5, B&integer, ) ) return result def toString( line ): result = [] for r,g,b in line: result.append( r << 10 + g << 5 + b ) return apply( struct.pack, ( 'H'*len(result),)+tuple(result) ) Oh, in case you're wondering, this will be _ridiculously_ slow, Python's not good at bit-fiddling :) . That's one reason PIL's C extensions exist :) . You'll probably find something that can read 16-bit integers into RGB values somewhere in the codebase. HTH, Mike -----Original Message----- From: Courageous [mailto:jkraska1 at san.rr.com] Sent: Sunday, July 23, 2000 12:56 AM To: python-list at python.org Subject: Re: bit manipulation frustration > > vice versa. Eeek. Help? Will someone please remind me and > > hit me with a rubber mallet??? :) > ... is one way. There are probably others. Consider youself whalloped. Yeah, amongst all the various documentation, I finally found my way to FAQTS. It was: >>> l=list("fred") >>> l ['f', 'r', 'e', 'd'] >>> string.join(l,"") 'fred' >>> > > Second, this whole paradigm seems so skrewball. > ... > > get it?) Um, well suppose I do something like... myfile.seek ( 2000, 0 ) str = myfile.read (20) This will result in a sequence of 20 bytes ('char'), But these are 16 bit RGB values (1 pad, 5/5/5 R/G/B). In C, I would quite possibly load these into ints, as 16 bit values straight up, and manipulate them that way. Now while I understand that I can unpack into 16 bit integers, manipulate, and then pack back to char all via the struct module, this is seeming like a great deal of transmogrification. Say for example I want to increase or decrease R, G, or B values. Or, say, I want to convert to 32 bit color bitmaps? C/ -- http://www.python.org/mailman/listinfo/python-list From jvickroy at sec.noaa.gov Mon Jul 17 16:37:06 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 17 Jul 2000 14:37:06 -0600 Subject: Multiline strings and indentation References: <39736250$0$14722@wodc7nh6.news.uu.net> Message-ID: <39736E71.AE8B128B@sec.noaa.gov> How about: >>> print "this" + \ " is" + \ " a" + \ " long" + \ " string" this is a long string >>> "donotspam-jen at personic.com" wrote: > I'm just getting started with Python. The indentation feature really does > make things readable ... except when using multi-line strings. This just > doesn't look right: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Is there a way to make the above more readable? It would be nice if it could > be written this way and have Python just figure out what whitespace to > ignore: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Thanks for any suggestions! > > Jen From rgparker at west.net Mon Jul 17 21:15:17 2000 From: rgparker at west.net (Randall Parker) Date: Tue, 18 Jul 2000 01:15:17 GMT Subject: Could someone clone MS's IL for another OS? Message-ID: Could someone write a clone of MS's new intermediate compiler language to native code compiler in order to write Perl, Python, or Eiffel on Windows, compile it to IL, and then eventually native code compile it on some other OS platform? Does anyone think such a capability is a good idea? Does anyone think that someone will do this? From gpepice1 at nycap.rr.com Fri Jul 28 22:33:10 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 29 Jul 2000 02:33:10 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> Message-ID: <39824324.480835B6@nycap.rr.com> > > Hmm. You seem to expect that strings and other > things will be automatically coerced to integers whenever a function > expects an integer. I think that's pretty scary; when I pass in the wrong > thing to a function I *want* it to complain, as it's very likely I did it > by accident. I don't want things to work by accident. Perhaps you're > missing that this 'problem' is also a 'feature'; you get less 'weird' > bugs due to the fact that your program keeps running long after your > data got coerce-mangled to death. Python would tend to throw exceptions > as soon as it went wrong. I think it depends what you are doing with your program. I use Perl (and now Python) to parse text files before putting the info in or sending it out of a databse. This is by no means bug free software (deadlines just don't permit enough testing). If someone sticks a letter in my input file where a number should go I would rather my script deal with it than crash. After all its not _my_ fault theres a letter there. However, managment will blame me for a 'bug' if the program throws an exception when someone else runs it. From olivierS.dagenaisP at canadaA.comM Tue Jul 11 23:03:43 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 12 Jul 2000 03:03:43 GMT Subject: Why does tkinter app crash on quit? References: <3969EF5C.EB7B14A4@acm.org> Message-ID: I think the PythonWin documentation claims there's a crash on Win95 when it is exit, but it is usually in an obscure 16-bit (user) module. This doesn't sound like it. Could you find out what SYNTPFCS.DLL is? (ie: hunt it down, then check out its properties) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "John Powers" wrote in message news:3969EF5C.EB7B14A4 at acm.org... > I have a python program which crashes every once in a while when I press > the "Quit" button. I'm running tkinter 1.127 and tcl/tk 8.0.5 under > Windows 95 and Python 1.5.2. Most of the time, it quits just fine. > > But sometimes, it crashes: "Python - This program has performed an > illegal operation and will be shut down. PYTHON caused an invalid page > fault in module SYNTPFCS.DLL at 0157:630067db. > > from Tkinter import * > > class App(Tk): > > def __init__(self): > Tk.__init__(self) > filename = "filename" > Label(self, text=filename).pack() > Button(self, text="Quit", command=self.quit).pack() > > App().mainloop() > > Anybody had experience with this? > > Thanks, jpp > From hei at adtranzsig.de Tue Jul 11 11:08:47 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Tue, 11 Jul 2000 17:08:47 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> Message-ID: <8kfd7o$2tf$1@desig-bs01-s04.adtranzsig.de> Sounds nice. But imagine this problem: You write an app for a customer, say, a paint program that lets the user compose a picture of elements like boxes, circles etc. Saving is done by storing the state of the objects using ZODB. Later, you want to give the customer a new version of the program. The object structure will have changed. Especially, some already existing classes might have more attributes now. Isn't this a very real problem? I mean, i could get around it using some export/import feature that saves to a certain file format i define. So i'd be writing save/load stuff myself again. So what do i gain using ZODB or pickle or whatever? That's my principal problem with all this persistency stuff - interoperability between versions of a program. Or is ZODB the first thing to overcome this, and i missed something? -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Tony J Ibbs (Tibs)" schrieb im Newsbeitrag news:002e01bfeb19$619a11a0$f0c809c0 at lslp7o.lsl.co.uk... > OK - I spent some of my "spare" time last night reading > > http://starship.python.net/crew/amk/python/writing/zodb-zeo.html > ... From fiona at sitegnome.com Mon Jul 10 02:45:58 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 10 Jul 2000 06:45:58 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 10th, 2000 Message-ID: <20000710064558.28914.qmail@synop.com> Hi Guys, Below are the latest entries to be entered into http://python.faqts.com cheers, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How can I do this Perl paragraph mode in Python? $/ = ''; # paragraph mode http://www.faqts.com/knowledge-base/view.phtml/aid/4629 ------------------------------------------------------------- Fiona Czuczman Harry George If you use pyperl: p=pyperl.Pyperl() p.INPUT_RECORD_SEPARATOR='' myfile=p.open("< $filename") lines=myfile.readlines() ------------------------------------------------------------- Is there anywhere I can get a list of the commands for python? http://www.faqts.com/knowledge-base/view.phtml/aid/4630 ------------------------------------------------------------- Fiona Czuczman Peter Schneider-Kamp Try the library and the language reference at http://www.python.org/doc ------------------------------------------------------------- How can I ring the PC's bell (ie internal speaker) to alert the operator that an operation has finished running? http://www.faqts.com/knowledge-base/view.phtml/aid/4632 ------------------------------------------------------------- Fiona Czuczman David Porter print "\a" ## Edited Entries ############################################## ------------------------------------------------------------- Is there a command/function in python to put a delay or wait step into a program? Does python have a sleep function? e.g. sleep(60) to wait 60 seconds? http://www.faqts.com/knowledge-base/view.phtml/aid/2609 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Andreas Jung,Greg Fortune, pehr anderson Try the sleep function in the time module. import time time.sleep(60) And put this in a while loop and a statement will only execute on the minute... That allows you to run a statement at predefined intervals regardless of how long the command takes (as long as it takes less than a minute or 5 or 60 or whatever you set it to) For example, I wanted to run a ping once a minute. If I just time.sleep(60) or time.sleep(45) even, the ping will not always take the same amount of time. Here's the code :) time.sleep(time.localtime(time.time())[5]) The [5] just pulls the seconds out of the time.localtime()'s return value. The great thing about time.sleep is that it supports floating point numbers! import time time.sleep(0.1) http://python.org/doc/current/lib/module-time.html ------------------------------------------------------------- Why are there no operators equivalent to C's , --, =, etc.? http://www.faqts.com/knowledge-base/view.phtml/aid/3378 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh, Peter Schneider-Kamp, Michael Hudson if you write things like "var = var + 1" a lot, you might be missing some important python idioms... here are a few, in no specific order: for item in sequence: ... sequence = map(operation, sequence) sequence.append(item) for index in range(size): ... for item1, item2 in map(None, sequence1, sequence): ... for index in range(start, stop, step): ... n = sequence.count(item) for index in range(len(sequence)): ... sequence.remove(item) for index in range(len(sequence)-1, -1, -1): ... (also note that most basic types are *immutable*, so it's not entirely clear how things like ++ and += should work. Michael Hudson wrote a patch for the +=, -=, *=, /= and some other of these operators. A patch can be found at: http://starship.python.net/crew/mwh/aug-patch.html http://www-jcsu.jesus.cam.ac.uk/~mwh21/aug-patch.html ------------------------------------------------------------- What is the best way of setting default options of widgets? http://www.faqts.com/knowledge-base/view.phtml/aid/4151 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain,Cameron Laird You can use an option database. If you create a file called optionDB with for example the following kind of entries: *font: Times New Roman *Button*foreground blue *foreground black You can then apply these via root.option_readfile('optionDB') For more on this, see http://www.regularexpressions.com/#options ------------------------------------------------------------- Is there a utility to convert module docstrings to HTML for nice documentation? http://www.faqts.com/knowledge-base/view.phtml/aid/4610 ------------------------------------------------------------- Stu D, Fiona Czuczman Richard Jones >From http://starship.python.net/crew/danilo/download.html: Gendoc generates documentation from Python source code in different formats. Currently it can generate HTML, MIF, MML and plain old ascii (MIF and MML are FrameMaker formats). If you want to generate HTML files, I strongly suggest you grab a copy of Robin Friedrich's HTMLgen package, with which gendoc generates quite nice pages, optionally with frames. From richard_chamberlain at ntlworld.com Fri Jul 21 02:38:28 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 21 Jul 2000 07:38:28 +0100 Subject: example Tkinter code? References: <8l7cvb$c61$1@mcnet.marietta.edu> Message-ID: Hi, Have a look at John Grayson's manning site (www.manning.com/grayson) you can download the source from his book including code that demonstrates each widget. I really would recommend a copy as it's an excellent book. from Tkinter import * root=Tk() myString=StringVar() Label(root,textvariable=myString).pack() myString.set("Well, eh, how about a little red Leicester.") def changeLabel(): myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ") Button(root,text='Click Me',command=changeLabel).pack() root.mainloop() I presume where you're going wrong is you are not creating an instance of StringVar and setting (or getting) the variable through that. Richard Locke wrote in message news:8l7cvb$c61$1 at mcnet.marietta.edu... > does anyone know where i can find some example python/tkinter code? i am > trying to learn, but i think some examples of how to use all those widgets > would be useful. > > also, how can i change the text on a label? when i use the > variabletext=whatever thing, the label wont show up. > > Thanks! > > From ingoogni at CUT.THIS.OUT.home.nl Sun Jul 30 04:03:57 2000 From: ingoogni at CUT.THIS.OUT.home.nl (ingo) Date: Sun, 30 Jul 2000 08:03:57 GMT Subject: cStringIO & write error? References: <8F80A1458seed7@212.120.66.218> <8F80E5BE4seed7@212.120.66.218> Message-ID: <8F816FC56seed7@212.120.66.218> Alex wrote: >Sorry, should have been more specific. What happens if you try this? > ..... It works. Thanks, Ingo -- Photography: http://members.home.nl/ingoogni/ Pov-Ray : http://members.home.nl/seed7/ From grey at despair.rpglink.com Sat Jul 29 18:01:18 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:01:18 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> <1vl4os8357de0humn8db0v30ejatjgcn48@4ax.com> Message-ID: On Sat, 29 Jul 2000 04:02:31 GMT, Ben Wolfson wrote: >Hmmm... An example of why I think I would prefer format strings over >in-place variables is that format strings seem more powerful to me. Why is there a difference? "Some string with a $formatstring in it",$foo "Some string with a $foo:$formatstring in it." "Some string with a $$foo:$formatstring in it." Last example both the variable and the format string are changable. Toss it outside the block... "Some string with a ",$$foo:len($$foo)-2:0," in it." The effect is exactly the same, you just do have the programming langauge trying to emulate German in the process. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From swun at eSec.com.au Wed Jul 19 00:57:22 2000 From: swun at eSec.com.au (the turtle) Date: Wed, 19 Jul 2000 14:57:22 +1000 Subject: How to use smtp and checksum in python? Message-ID: <39753531.983BC8F5@eSec.com.au> Thanks Sam From alex at magenta.com Mon Jul 31 08:27:11 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 31 Jul 2000 14:27:11 +0200 Subject: formatting (was Re: Perl is worse!) References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> <8luhso41ce8@news2.newsguy.com> <8m1f0462n4o@news2.newsguy.com> Message-ID: <8m3ri602ej2@news1.newsguy.com> "Steve Lamb" wrote in message news:slrn8o9jn9.i9b.grey at teleute.rpglink.com... > On Sun, 30 Jul 2000 16:29:42 +0200, Alex Martelli wrote: > >When the format string is expressed as an inline constant you can see it in > >place, but you don't have the other advantages (such as > > Non-issue. You were expressing your format string as a variable and the > same can happen with variables in line. Issue. Either the format-string and the variables are inline (you can see them inplace) or they're fetched otherwise and kept (far from clear how, if you have more than one thing, such as some pieces of formats, some of variables, some more of formats, etc; lucidly obvious, with format-string and [sequence|mapping] of values!), which gives you other advantages. Things being immediately-obvious-inline tends to help with smaller projects, beginning programmers, etc. The other advantages accrue increasingly to larger/functionally richer programs. There may be therefore a switch-over point, where one form or the other becomes preferable. A language may want to cover the whole spectrum. Smaller/poorer programs, ones being worked on by beginners, etc, tend not to require very accurate, nitpicky formatting. For those purposes, Python's print statement can be quite adequate -- and, not unsurprisingly, it works exactly by the sequence-of-variables- and-pieces-of-strings that beginners may find simpler, may be more obvious in-the-small, etc. When formatting needs get more sophisticated, both sequence-oriented and namingtag-oriented forms can come in handy -- and Python provides both. > >When you end with % vars(), there is no substantial difference. > >When you use the more substantial flexibility allowed by using > >other mapping-objects, if that flexibility is needed, then the > >advantages are many -- see above for a *beginning* to them. > > No, there is no difference. What you have is a format string with named > placeholders in-line. You have to define the variables ahead of time. There is absolutely no need to "define the variables ahead of time" with either form of Python format-string. The key issue is that _any mapping object_ is just as acceptable as vars(), so no variables need be defined unless you WANT to define them, either 'ahead of time' or not. All you need is to set up the associations tag->value in the mapping-object, and you can do that any which way -- ahead of time, just-in-time, a mixture of both. FAR *more substantial flexibility* than any language (fake, as in your examples, or true) that ties you hand and foot to the one-and-only-mapping provided by variablename->variablevalue. > I have the same. No you don't, not even in the blue-sky, invented-and-modified-on- demand fake-language you've been dreaming up as we go. You lack flexibility, because you're tied to a single mapping-object. > Difference is you still have to tack on the variables to the end, > regardless of what form they take. I have to specify what mapping-object I'm using each time (and I have many ways to do that) in order to be able to use different mapping objects in different cases. When I'm using "the variables", which appears to you to be the only mapping that exists or can ever exist, I'm basically writing: formatstring %vars() while you're writing formatstring someotheroperator or you can make the otheroperator prefix instead of postfix, etc, but you'd better have SOME way to say that formatstring is to be subject to formatting -- having different kinds of strings for formatting-operation and every-other-operation would be very unwieldy, as well as flying right in the face of your "data is data" stance, right? Oops wait I forgot, that's exactly what your beloved Perl does, isn't it? 'Ba$a at u%e' is a plain string without formatting, while "Ba$a at u%e" (still 'data is data is data', innit?-) is a string to which formatting ('interpolation', if I recall the terminology that Perl uses) is implicitly applied. So _in addition_ to this break in your 'data is data, the operator commands anyway' stance, you get the extra joy of figuring out different ways and means to have formatting applied anyway after a normal string is built up/fetched from somewhere/etc. Can you spell "ad hoc"?-) Python isn't beyond criticism here, by the way. As an alternative to the % _operator_, a named-function (to be provided as a built-in) could perfectly well have been chosen by our BDFL: format(formatstring, a, b, c) or format(formatstring, vars()) isn't (IMHO) any less readable than the current formatstring % (a,b,c) or formatstring % vars() just _slightly_ more verbose, but, again IMHO, that slight extra verbosity would be in a good cause. I do not know why the % operator happened to be chosen in preference to an explicitly-named 'format' built-in function (and I confess to some curiosity in this regard; understanding the design-rationale behind a language/framework/library is often extremely helpful in using it to best effect, and of course "I'm still an egg" in Python terms -- anybody _knows_...?). > >That's what I would have liked to do, but often couldn't because > >Perl might not be installed on some target-machines, sigh. At > >least, Bourne-shell could be counted on at the time. > > Aside from Solaris pre-8, what is left that doesn't? Just a zillion machines installed at about zillion/10 client sites, I guess. Remember we do commercial off-the-shelf software, that is supposed to install and run, without needing our direct involvement, on a huge variety of customer machines. I can't make Perl a pre-req (nor Python either, sigh) before scripts that determine configuration, and set up other scripts that do the actual installation, can run. OK, these days installations are done with dedicated packages (typically with proprietary scripting-languages so utterly weak as to make one blank -- but I'm not the one having to write those scripts nowadays, so, selfishly, I look the other way!-). _After_ the installation, of course, whatever I know my app has installed, I can use. Whether installing a scripting-engine is worthwhile depends on the amount of scripts in the application that could take advantage of it, of course. Alex From claird at starbase.neosoft.com Fri Jul 28 09:01:27 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jul 2000 08:01:27 -0500 Subject: Content of the Perl6 talk Message-ID: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> is the most pro- vocative summary I've yet seen of Larry Wall's talk at the O'Reilly Open Source Convention. Mark-Jason Dominus's typically masterful provides technical details. I think at least the first of these will reward a quick read by everyone involved in planning the futures of, for example, Python and Tcl. I applaud Conrad Schneiker for his care in prepar- ing this. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From m.faassen at vet.uu.nl Thu Jul 27 07:03:01 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Jul 2000 11:03:01 GMT Subject: Python 3000 References: <8li7ah$ign$1@serv1.albacom.net> <8lk1ee$71q$1@slb6.atl.mindspring.net> <8lk2kg$kbv$1@nntp9.atl.mindspring.net> <8lk4cp$i9c$1@nnrp1.deja.com> Message-ID: <8lp4t5$6bu$1@newshost.accu.uu.nl> effbot at pythonware.com wrote: > Aahz Maruch wrote: >> Yes, I know about the soap opera. The fact remains that 1.6 >> will almost certainly never be a released chunk of code -- it >> never had a beta! > looks like you've missed the last episode. > according to plans, 1.6 beta 1 will be released in > about a week. for more info, see PEP-160: > http://python.sourceforge.net/peps/ What a mess. So that was why I didn't watch soap operas. :) It'd be useful for the community if there were some document out there that described what the heck is going on, and why. Once all of this becomes a bit more clear for the parties involved, that is. It keeps changing and it makes people worried. At least it makes me worried. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rumjuggler at cryptarchy.org Fri Jul 28 05:21:28 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 09:21:28 GMT Subject: Perl is worse! References: Message-ID: <75k2osst2eh5nbel73ju033l8s97bs2v0s@4ax.com> On Fri, 28 Jul 2000 08:11:18 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 01:24:08 -0400, Tim Peters wrote: >>Steve, in case it isn't clear yet, Python programmers *want* to be blown out >>of the water when doing something as senseless as > >> 1 + "foo" > > It isn't senseless. That is the whole point. It is only senseless >because of typing. Clearly you cannot add a word to a number, granted. But >what of 1 + "1"? That isn't senseless, those are two numbers. I can see they >are two numbers, it is only because of typing that it fails. > > So I ask you this /VERY/ simple question. Why can't Python do both? Hm? >What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it >together? If it is a string that cannot be converted to an integer, throw an >exception, otherwise, do it. Then that preserves the 1 + "foo" exception and >also does the sane thing of getting rid of types when it makes sense to do so. Well, what if you wanted 1 + "1" to result in "11", not 2? > Hell, why do an exception at all? Why not do what is already done with >integers, reals and floats? > >1 + 1 = math > >1 + "1" = math > >1 + "foo" = string ("1foo") That could lead to some interesting results if you expect numerical input. >"foo" + "foo" = string ("foofoo") > > You already accept: > >1 + 1 = integer > >1 + 1.2 = float > >1 + 1j = complex > > So please don't tell me you don't want "automagic" type changing when it >is already there and, I'd wager, you use it extensively. Those are all numeric types. I don't see why you don't also start arguing for the validity of list(1 + ['4', someclassinstance] + "lalala") -- Barnabas T. Rumjuggler 93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. -- Alan Perlis From wjdandreta at worldnet.att.net Thu Jul 13 23:23:11 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Fri, 14 Jul 2000 03:23:11 GMT Subject: atof problem. References: Message-ID: Hi Jeff, I guess my question was poorly worded. I was looking for the way to set the internal thousands separator to a comma so atof('1,142.00') results in 1142.00. It's clear from the doc's that it is posssible to do but it doesn't give enough info for me to figure out how. I would consider that a better way than to do it by hand with the replace function. For some reason, the Python I am using (1.5.2 dx for dos) does not have the thousands separator set to a comma. Bill Jeff Blaine wrote in message ... > >I'm pretty sure you did it the Right Way. > >Numbers containing commas are there for readability purposes by humans. > >It's just a call to string.replace() to get rid of the comma... (or several >other ways to do the same thing). From lull at acm.org Thu Jul 20 22:15:02 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 21:15:02 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> Message-ID: Gregory Lielens wrote (with possible deletions): > I like the parethese a lot! except for ? which is probably out of > question, > this is the prettier way to do it, but (alwas a but :-( ) > > - the solve operator indeed...The only thing i can come with is the ugly > (%) > or the pretty but out-of-question (\) > - patching the parser to deal with that looks a lot more difficult than > @ or even > . variants (this is doable - in fact, this is already done...) because > I think > (){}[] are treated in a more specific way by the Grammar...I think to > implement that > we need a real Grammar guru! I'm no expert on the Python lexical analyzer, but I'd be surprised if the parens are a real problem. The '\' yes -- but not the parens. A typical 'maximal munch' rule says that if the same character could be the start of several different tokens, the longest matching token wins. That's why Python has no trouble distinguishing between the delimiter '=' and the operator '=='. The \ is likely handled as a completely separate step, prior to lexical analysis, so the lexical analyzer only sees it when the source code has it doubled: source code: '\\' lexical analyzer sees: '\' Regards, John From jcm at bigskytel.com Thu Jul 6 15:23:03 2000 From: jcm at bigskytel.com (David Porter) Date: Thu, 6 Jul 2000 13:23:03 -0600 Subject: Wait/Delay In-Reply-To: <8k2lhd$5i6$1@gossamer.itmel.bhp.com.au>; from wilson.austin.aj@bhp.com.au on Fri, Jul 07, 2000 at 05:11:36AM +1000 References: <8k2lhd$5i6$1@gossamer.itmel.bhp.com.au> Message-ID: <20000706132303.B19982@novara.avenue> * A J Wilson : > Is there a command/function in python to put a delay or wait step into a > program? import time time.sleep(1) From shouldbe at message.com Fri Jul 7 09:56:52 2000 From: shouldbe at message.com (Arinté) Date: Fri, 07 Jul 2000 13:56:52 GMT Subject: Doc question Message-ID: The docs say this about PyArg_ParseTuple objects "O" (object) [PyObject *] Store a Python object (without any conversion) in a C object pointer. The C program thus receives the actual object that was passed. The object's reference count is not increased. The pointer stored is not NULL. So, I don't need to do a Py_XDECREF on this unless I need to keep it, and in that case I need to do a Incref first. Correct. I am having a lot of bad experiences on embedding, and I just want to confirm stuff. I wish I was working on this stuff exclusively. From tim_one at email.msn.com Wed Jul 26 22:22:15 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 26 Jul 2000 22:22:15 -0400 Subject: The State of Python In-Reply-To: Message-ID: [Steve Lamb] > Stupid question: Why is it everyone and their mother is > coming out with a new open source license for their project > instead of sticking with the established ones? I wish I knew. Haggling over the license for Python has delayed the BeOpen Python release plans repeatedly, so all I see now are the costs; when the new license is posted, you can judge for yourself whether it was worth the delays. I've heard indirectly that CNRI (Python's former home, and author of the new license) believes the new license provides new protections for the community, but AFAIK they've made no public stmt about that. Maybe my employer will shoot me for saying so, but in *general* I find it sadly ironic that everyone plays along with carrying out negotiations about new "Open Source" licenses behind closed doors; while the result may be "open", the process sure isn't. > I mean, it causes headaches trying to keep all of the licenses > legally compatible with one another which can cause problems for > open source down the road when these licenses are actually put to > the legal test. Std pitch: If you're sure that you want *not* to control what people do with your project (which was the clear intent of the old Python license), consider putting it in the public domain from the start. As soon as it's got a license, you're going to have to hassle with it forever after, and every legal entity that touches your project is going to want to add their own unique twists (which is why licenses proliferate, I think -- asking a lawyer to refrain from changing an inherited license is like asking a hacker to leave inherited code alone <0.3 wink>). The decision to put something in the public domain is irrevocable, so stops that game before it starts. In the area of programming languages, the decision to develop Icon (http://www.cs.arizona.edu/icon/) in the public domain has granted Ralph Griswold a long, happy and lawyer-free life. not-speaking-for-anyone-ly y'rs - tim From anthony at interlink.com.au Thu Jul 27 21:19:15 2000 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 28 Jul 2000 11:19:15 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from "Alex Martelli" of "Thu, 27 Jul 2000 14:39:10 +0200." <8lpand0gbg@news1.newsguy.com> Message-ID: <200007280119.LAA23655@mbuna.arbhome.com.au> >>> "Alex Martelli" wrote > I will piously hope that the *internals* of Zope remain in bright, clean > Python (or C where needed, e.g. for speed purposes), but if that is > so, then no "pollution" ensues if, over that Python-base, one is allowed > to build superstructure in Perl, Visual Basic, Tcl, JScript, or whatever > your least-favourite language happen to be. Certainly that's the message coming out of DC... Anthony -- Anthony Baxter It's never too late to have a happy childhood. From grey at despair.rpglink.com Fri Jul 28 04:04:45 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 08:04:45 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On 28 Jul 2000 19:46:29 +1200, Paul Foley wrote: >The distinction you're trying to make (between "types" and "just >data") is rather foolish. Data are the things that have types. Rather foolish? For whom? Humans don't think in "integer" and "long integers" or "strings". We think in terms of data whose exact value, "type", is determined by context alone. As a human, type 1. Character? String? Integer? Floating number? No, it is 1 and it can be all of those all on context. Types are a construct created to help computers deal with human concepts. Why, then, when a language comes along that does a darn fine job of doing the right thing by defining data as a scalar (it isn't a string, it isn't an integer, it isn't floating point, it isn't a character, is can be all of them depending on context) do you call it "foolish" to think in those terms? >character "a" (Python, sadly, lacks a proper character type); I'd consider that a blessing. Once less artifical construct to get in the way. >No; "a" is a string and strings are sequences; 1 is an integer, and >integers are not sequences. This particular quirk is in your head. No, the particular quirk is in the language by forcing types. Remember, all this came about because I pointed out that Python has just as much automagical "typing" going on as Perl does, it just limits that typing from what I can see. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From guido at beopen.com Mon Jul 31 11:10:05 2000 From: guido at beopen.com (Guido van Rossum) Date: Mon, 31 Jul 2000 15:10:05 GMT Subject: Python in politics (sssssssssnake!) References: <398524B5.A608BFF1@philips.com> Message-ID: Gerrit Muller writes: > Here in Holland we have a series of books by Addo Stuur, Programming for > children, Windows for children etcetera, which all follow the formula of > telling in detail how to do something followed by an exercise. My > children sometimes get bored by the completeness of detail Addo brings > in. Nevertheless his method gets children productive in a short amount > of time. Maybe we should send Addo Stuur a few Python books :-) Not a bad idea! I'd be happy to do this, if Addo could be interested. Do you think that Addo can program in any language? Or is he just a computer *user*? Can you get me in touch with him? (Nederlands is OK!) --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From see at my.signature Thu Jul 20 22:25:54 2000 From: see at my.signature (Greg Ewing) Date: Fri, 21 Jul 2000 14:25:54 +1200 Subject: namespace sharing (longish) References: <3bP6MX$m9o@openbazaar.net> Message-ID: <3977B4B2.CC5420C3@my.signature> "robin"@illusionsexeculink.com.bbs at openbazaar.net wrote: > > All I want to do is execute user-supplied (eg: arbitrary) functions > and have them share a namespace. Your example doesn't work because your one() and two() functions live in a separate module. The global namespace of a function defined in a module is always the namespace of that module, regardless of how the function gets called. One way to do what you want is to compile() the function definition itself: namespace = {'var_main': 'hello', '__builtins__': {}} source = """ def one(): global var_main print var_main var_main = 'spam' """ code = compile(source, "", "exec") exec code in namespace # defines the function within namespace print namespace namespace["one"]() # call the function print namespace -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From rapto at arrakis.es Sat Jul 22 06:57:47 2000 From: rapto at arrakis.es (Marcos =?iso-8859-1?Q?S=E1nchez?= Provencio) Date: Sat, 22 Jul 2000 10:57:47 GMT Subject: PIL and HPGL References: <4682ls4ukdce8uipv7hcgfjkihv6teoppj@4ax.com> Message-ID: <39799B07.C71305BB@arrakis.es> You may get smaller file sizes if none of the steps converts your image to bitmap, staying vectorial. This might not be the case for very complex drawings, lots of hidden stuff, and/or low resolution. From rob at hooft.net Wed Jul 19 06:08:51 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Wed, 19 Jul 2000 12:08:51 +0200 (CEST) Subject: Toplevel "test()" functions in standard library In-Reply-To: <3975985F.FF8D1591@schneider-kamp.de> References: <3975985F.FF8D1591@schneider-kamp.de> Message-ID: <14709.32307.958757.855324@temoleh.chem.uu.nl> >>>>> "PS" == Peter Schneider-Kamp writes: PS> I cannot comment on the reason for this idiom, but for your name PS> space pollution using "from ... import *": Don't use it. I don't. But some still do. PS> Even in the short time I have been on the list I have seen PS> examples of nearly untrackable bugs because of name space PS> collisions when using "from ... import *". I am all in favor of solving this kind of problems 2 ways: - Discourage use of from ... import * even more than now - Make use that there is as little pollution as possible PS> I don't even use "from Tkinter import *" in GUI apps. Same here. I don't even rename it. The repeated Tkinter.TOP and Tkinter.YES are a bit annoying, but it makes the code quite clear. Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From neelk at brick.cswv.com Sun Jul 23 10:20:01 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 23 Jul 2000 14:20:01 GMT Subject: Discussion: new operators for numerical computation References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <8lcnf4$vmr$1@slb0.atl.mindspring.net> <8ite5.9395$4p3.69392@news-server.bigpond.net.au> Message-ID: Neil Hodgson wrote: > > I first ran into this when I tried to implement a sparse matrix > > class. At that time, the Numpy distribution had a Matrix class that > > implemented regular matrix multiplication with '*', and I wanted to > > write another class SparseMatrix that would do the right thing > > whenever it was multiplied with a Matrix. > > I had a look at Dylan a few years ago and multimethods look good for some > areas but you also lose the encapsulating aspect of normal OO. The > functionality for a class isn't nicely tied up in one bundle but is > federated over a wide and extensible area. I would expect Python with > multimethods to look very different from current Python. Like Aahz, I'd like > to see what your idea of Python with multimethods would look like? Honestly, I don't have a good idea yet. I'll spend a couple of days trying out some variations and then get back to you. In the meantime, there's a simple-minded implementation you can use to play around with multimethods on my webpage http://www.sff.net/people/neelk/open-source/Multimethod.py It's a one-day hack, so be warned -- it's more for experimentation than anything else. And there's a technical report by some of the Tuple and Cecil people that implements a module-friendly multimethod system for Java at ftp://ftp.cs.iastate.edu/pub/techreports/TR00-06/TR.ps.gz Neel From leo at iems.nwu.edu Mon Jul 24 16:55:41 2000 From: leo at iems.nwu.edu (Leonardo B. Lopes) Date: Mon, 24 Jul 2000 15:55:41 -0500 Subject: Embedding Example References: <397C6D55.6F7C@iems.nwu.edu> Message-ID: <397CAD4D.17D8@iems.nwu.edu> Dear Ted, Thanks! BTW, you mentioned the existence of a FAQ. Is it an embedding FAQ, or just the regular FAQ under embedding? I can't find any embedding FAQ on google: > > This really needs to be in the FAQ on embedding. > ^^^^^^^^^^^^^^^^ Thanks! Leo. -- ======================================================================== Leonardo B. Lopes leo at iems.nwu.edu Ph.D. Student (847)491-8470 IEMS - Northwestern University http://www.iems.nwu.edu/~leo From gabriel_ambuehl at buz.ch Sun Jul 30 12:58:55 2000 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Sun, 30 Jul 2000 18:58:55 +0200 Subject: CGI downloading In-Reply-To: <8m1lc5$89p$1@nnrp1.deja.com> References: <8m1lc5$89p$1@nnrp1.deja.com> Message-ID: <10673694897.20000730185855@buz.ch> Hello lkcho, Sunday, July 30, 2000, 6:33:09 PM, you wrote: > Is there any possible way to download the whole cgi script, instead of > letting it response with html pages? If the webserver's configured properly, this should not be possible without FTP or shell access to it. Best regards, Gabriel From newsgroup at neutron.globalnet.co.uk Wed Jul 19 09:48:02 2000 From: newsgroup at neutron.globalnet.co.uk (Newsgroup) Date: Wed, 19 Jul 2000 14:48:02 +0100 Subject: Python in game development? References: <963990339.783645@marvin> Message-ID: <8l4h60$jnk$2@gxsn.com> > In the Open Source Crystal Space 3D engine we are working on a framework for python > scripting. It is already working reasonably well but you cannot yet do everything > that you'd want to do from a python script. Can anybody explain what you actually do to attach the python, or any other general purpose scripting language, to your game? I'm making a game with a scripted engine and I have to write my own compiler to convert scripts into a length of integers and a virtual machine to convert it into game logic. Does python produce it's own compiled code and you then have to write a virtual machine based on this output? Regards, Sean Wilson http://www.users.globalnet.co.uk/~neutron/programming From skip at mojam.com Thu Jul 27 11:57:01 2000 From: skip at mojam.com (Skip Montanaro) Date: Thu, 27 Jul 2000 10:57:01 -0500 (CDT) Subject: Is the "Be" significant? (Re: The State of Python) In-Reply-To: <397FD6B9.5017B952@see.my.signature> References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: <14720.23501.580330.14923@beluga.mojam.com> Greg> By the way, does BeOpen have anything to do with the BeOS people? Nope, no connection. Greg> If not, it would seem to be a rather confusing choice of name. Agreed... -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From collins at seal.aero.org Wed Jul 19 11:48:34 2000 From: collins at seal.aero.org (Jeff Collins) Date: Wed, 19 Jul 2000 08:48:34 -0700 Subject: Stripping down Python In-Reply-To: References: Message-ID: <14709.52316.238323.441546@malibu.aero.org> Take a look a Python for the Palm (http://www.isr.uci.edu/projects/sensos/python/release_a1.tgz). The Parser, etc. has been stripped along with some builtin objects. I also created the new exception MissingFeatureError, which all removed standard builtin functions raise when called. The code is a work in progress - there are still opportunities for further reduction. Jeff Morten W. Petersen writes: > Are there any papers/stories ideas of how to most effectively strip down > Python? Ie. how to trim down the size of Python as much as possible, > removing the parser etc. Just having the basic Python interpreter, with > basic libraries, capable of running .pyc and .pyo files. > > -Morten > > ------------------------------------------------------------- > How to reply to email: > http://home.sol.no/~vidaandr/news/OBSquoting.html (norsk) > http://home.sol.no/~vidaandr/news/FAQquoting.html (english) > > Who is the bigger fool? The fool or the fool who follows him? > > -- > http://www.python.org/mailman/listinfo/python-list > From see at my.signature Thu Jul 20 01:04:15 2000 From: see at my.signature (Greg Ewing) Date: Thu, 20 Jul 2000 17:04:15 +1200 Subject: Arbitrary operator symbols (Re: Operators for matrix: current choices) References: Message-ID: <3976884F.51FD33D9@my.signature> The main problem I see with any kind of scheme requiring new operators to be defined before use is how you control their scope. Presumably they should be limited in scope to the module where they are defined or imported, so that different modules can define their own sets of operators without conflicting with each other. That means there has to be some way of importing operators. And whatever definition and importing scheme is used has to operate at compile-time, not run-time, so the proposals made so far which involve executing Python code to define operators aren't going to work. Some sort of special syntax is needed. Further, how do you manage a conflict between two modules that you want to use at the same time, but they define conflicting sets of operators? With names, you always have the option of using qualified names, but that doesn't work with operators. I think the only way to make something like this work is if there is no need to declare operators at all -- you just use them. This means there have to be fixed ways of (1) deciding the precedence of an arbitrary operator and (2) mapping it to a method name. (1) can be done by, e.g. requiring all operators to begin or end with one of the standard operators, from which it takes its precedence. (2) can be done by extending the function definition syntax to allow the name actual operator string to be used as the name of the method, so no mapping is required. e.g. class Matrix: def ".*"(self, other): # do an elementwise mul here -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From olmy at thistledown.org Sun Jul 9 11:47:03 2000 From: olmy at thistledown.org (Olmy) Date: Sun, 9 Jul 2000 10:47:03 -0500 (CDT) Subject: Feature Request: IPv6 support built into 1.6/2.0 In-Reply-To: <8ka50r$82n$1@nntp9.atl.mindspring.net> Message-ID: Good morning, Has there been any consideration of rolling the KAME IPv6 patches to Python into the official release? It would be quite interesting to start using python to code some small ipv6 utilities here and there. Any thoughts? Are there more appropriate methods to submit feature requests? jeff -- -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.0i for non-commercial use MessageID: RN7/dw97SSxgWUT2asyiONlPRzbOe0JQ iQCVAwUANofqRKxB/KiL2JNNAQEwxwP/VJQamtcDOlt9h3fQ9KqyuiBzBKcXQQMo Fahl3o4HjqI1qh5mv5Mac1G0YKJp+rkhp64GOKG6jDu46aPIgZ9xTc204wQ+wLyO mqw8/EEc3PKtGM57vPkkVJraxHZMdZV45wMnno21Gx03k+d7MWbpd85tjYhrXMFJ TwUCFSAG8/4= =TRCD -----END PGP SIGNATURE----- From Norbert.Klamann at pobox.com Mon Jul 17 04:56:18 2000 From: Norbert.Klamann at pobox.com (Norbert.Klamann at pobox.com) Date: Mon, 17 Jul 2000 08:56:18 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <8kuhnd$bh3$1@nnrp1.deja.com> Hello all, working with the new Build 132 of Pythonwin we have a minor problem. German Umlauts are not handled properly in the editor windows. They are shown as boxes, some of them seem to be dead keys. The problem did not exist in previous builds. Does anyone have a hint ? Thanks for your time ! Norbert -- Norbert Klamann Klamann Software & Beratung GmbH Erftstadt Germany Klamann.Software at pobox.com Sent via Deja.com http://www.deja.com/ Before you buy. From rmack at eznet.net Fri Jul 21 11:24:08 2000 From: rmack at eznet.net (Randolph MacKenzie) Date: Fri, 21 Jul 2000 11:24:08 -0400 Subject: Where to install Python 1.5.2 ? and pmw ? Message-ID: Where is the best place to install Python 1.5.2 in the Windows platform ? Is C:\Program Files\Python really the best location? I also want to install pmw so that I can import pmw without generating an error message. How do I do that ? -TIA, Randy From peter at schneider-kamp.de Sun Jul 23 03:38:54 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Sun, 23 Jul 2000 07:38:54 +0000 Subject: bit manipulation frustration References: <397A6980.CF15DB96@san.rr.com> Message-ID: <397AA10E.4FDF9422@schneider-kamp.de> Courageous wrote: > > First, in one fell swoop of antigenious, I seem to have > forgotten how to convert strings to sequences of char and > vice versa. Eeek. Help? Will someone please remind me and > hit me with a rubber mallet??? :) >>> map(None, "hello courageous") ['h', 'e', 'l', 'l', 'o', ' ', 'c', 'o', 'u', 'r', 'a', 'g', 'e', 'o', 'u', 's'] >>> But what do you need this for? You can work on a string like on that list except that the list is mutable. I am not sure if I have understood your other problem though. Maybe the following class can help you? from operator import add class isotile: def __init__(self, name, size, inc = 2): self.up = 1 self.pos = 0 self.num = inc self.size = size self.inc = inc self.data = open(name, "rb").read() def readline(self): if not self.num: return '' newpos = self.pos + self.num pad = (self.size - self.num) / 2 line = self.data[self.pos:newpos] self.pos = newpos if self.up: if self.num == self.size: self.up = 0 self.num = self.num - self.inc else: self.num = self.num + self.inc else: self.num = self.num - self.inc return pad * '\000' + line + pad * '\000' def readlines(self): result = [self.readline()] while result[-1]: result.append(self.readline()) return result[:-1] def read(self): return reduce(add, self.readlines()) if __name__ == "__main__": open("isotile_test.dat","wb").write('112222333333444455') a = isotile("isotile_test.dat", 6) print a.readlines() -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From zeitlin at seth.lpthe.jussieu.fr Mon Jul 17 10:41:52 2000 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 17 Jul 2000 14:41:52 GMT Subject: Looking for a tree widget with control of text color References: <_b%a5.155712$7o1.3884807@news2.rdc1.on.home.com> Message-ID: On Wed, 12 Jul 2000 14:23:54 GMT, Tom wrote: >This surprises me. >It is my understanding that wxPython is a 'native' gui, so, on Windows, its >tree control would be implemented using the windows tree view common >control, This is correct. > which is dynamic but doesn't support differing text colors for > different nodes. This is not entirely correct: newer (comctl32.dll 4.70+) versions of the treeview common control implement the so called "custom draw" functionality which wxTreeCtrl uses. Regards, VZ From gmcm at hypernet.com Tue Jul 18 23:17:25 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 19 Jul 2000 03:17:25 GMT Subject: Windows NT select.select( ) References: <8l2862$4n1$1@nnrp1.deja.com> Message-ID: <8F75EBAF3gmcmhypernetcom@199.171.54.155> David Cattarin wrote: >.... There was an oddity >under Windows NT that when no sockets were registered to >the socket_map select failed. ... > >Has anyone else noticed this? Yup. >... I was curious if anyone knew more. >Or even a better way to fix this. Nope. -Gordon From aek at aek.dk Sun Jul 16 12:49:23 2000 From: aek at aek.dk (Anders Eggers-Krag) Date: Sun, 16 Jul 2000 18:49:23 +0200 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> Message-ID: > VB's IDE is more than just a text editor. Every line is checked for syntax > errors and I think compiled in the background. Of course no other editor > could be as good, unless they also had access to the VB compiler/debugger. It is a typical god side of an MS product, total integration with total benfit, a pitty thought that the interface is less good than Borland's... > Using VC's autocompletion/intellisense, you can get similar results to VB, > so something like this can be done for any language, that is correct, but > not to the extent where the editor is also a compiler. It may not be all > that hard to implement self-correction and syntax checking in Python, since > we have "exec", but you are right: without variable declarations this can > prove to be difficult. Maybe whoever implements a self-correcting/syntax > checking IDE for Python should enfore a convention for "declaring" the > variables, without affecting the language itself. Something like this, for > example: (I'm new to Python, so please excuse the big fat mistakes I might > have made) Another solution is to be really smart and figure the flow of the program and determine when a variable is first used and color that color1 and the next time it is used it is colored color2... > Where the variables are declared in the form of a comment that starts with > the letters "var" which, I think, is how JavaScript declares variables, > isn't it? it is said the man who knew the language inside out :-) > So, by having a line at the beginning of a function (right after > the description line, which I hope I didn't screw up) indicating the names > of the variables we intend to use, any name that isn't in that list and > isn't in anything we imported would be highlighted as a mistake, and if only > the case differs, the editor would make the case match the declaration... The only problem is that it turns Python ugly... > Naming conventions are great, but also impossible to get everybody on earth > to accept (and use) them, unless your language enforces it, primarily > because we tend to think different, the latter being a wonderful thing! So > your naming convention is probably wonderful, but maybe also different than > that of a third party, whose module you want to use.... I know it is a problem, I will however try to enforce it in our concern, and one might design a devoloping tool that enforced a naming convention, that could be dfined by the user. > Come to think of it, I don't think I have a problem with the language being > case-sensitive. I have a problem with the editor making me think about a > detail that I have come to not have to worry about by using VB. VB may or > may not be case sensitive, I wouldn't really know, but what's great is that > I don't have to worry about it. Once you get used to it it really isn't much of a worry there is only one thing in this world that makes me wonder: why are all the beautiful languages run time parsed? (i here think primarily on Python and Java) -- Anders Eggers - Krag From moshez at math.huji.ac.il Thu Jul 27 08:09:19 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 27 Jul 2000 15:09:19 +0300 (IDT) Subject: Dot-comma, anyone? (Re: zip or marry etc) In-Reply-To: Message-ID: On Thu, 27 Jul 2000, jepler epler wrote: > >We should get to the point where compilers can recognize and optimize > >built-in functions soon. > > You mean so that > from mystuff import * > print len("actually, this is an argument to mystuff.len()") Nope. Here's a stategy to optmize and keep Python's semantics. Compile each code twice: once with those optimizations, and once without optimizations. Use the opimized version, until you see a "dangerous" opcode, such as "import *", "exec", or "eval" -- and then use the non-optimized version. You can even have the "global"s dictionary maintain weak references to all of the things it is their globals, and update them if it is tainted by such an opcode, or a direct manipulation of its __dict__. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From speed at ?.com Fri Jul 21 12:02:01 2000 From: speed at ?.com (Jake Speed) Date: Fri, 21 Jul 2000 16:02:01 GMT Subject: dynamic bases References: <20000721171635.B1431@balabit.hu> Message-ID: bazsi at balabit.hu (Balazs Scheidler) wrote in <20000721171635.B1431 at balabit.hu>: > >So what I basically want is to add a set of methods/attributes to an >instance dynamically, so that the methods added can access the >attributes of the original instance. My original idea was the following: This looks like a job for the 'new' module! import new class Object: a = 5 def __init__(self): self.bonus_method = {} def __getattr__(self, name): if self.bonus_method.has_key(name): return new.instancemethod(self.bonus_method[name], self, self.__class__) else: raise AttributeError, name def think(self, x): print 'self.a =', self.a, ': x =', x a = Object() think(a, 1) a.bonus_method['think'] = think a.think(2) ...so why not just say a.think = new.instancemethod(think, a, a.__class__) ? ...because this sets up a cicrular reference between the object and the new method, and they will never get garbage collected. If you generate the method in __getattr__, the object never holds on to the method reference. -Speed! From hinsen at cnrs-orleans.fr Mon Jul 24 06:36:38 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 24 Jul 2000 12:36:38 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: > This looks like a good idea. The question is whether we need to put this > into the infix operators or as class methods. First of all into the existing function equivalents of the operators we are talking about. Maybe later into the operators. Of course assuming that we follow the J approach, one could in principle make data and value ranks properties of the arrays. I don't know if this approach has ever been tried out in practice. > Another example concerns the inner and outer products. Suppose we define a > class of tensor-with-indices, we could do innerproduct like > > a = b.index((2,3)) * c.index((2,4)) # a_ilmnp = b_ijkl c_mjnkp What exactly does your index method return? > Is this similar to what you proposed? It looks to me this is can be handled > by the existing Python mechanism of method overloading. No, because in the J approach ranks are a feature of functions and operators, not of data. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From andrew.henshaw at gtri.gatech.edu Sat Jul 15 03:06:36 2000 From: andrew.henshaw at gtri.gatech.edu (Andrew Henshaw) Date: Sat, 15 Jul 2000 03:06:36 -0400 Subject: Discussion: Introducing new operators for matrix computation - general approach? References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> Message-ID: <8koktn$dik$1@news-int.gatech.edu> Gregory Lielens wrote: >John Lull wrote: ...snip... >> I'm don't think this is quite fair. You could just as easily write: >> b = rDiv(X, y) >> if you simply had an appropriate rDiv() function. ..snip.. >Indeed, but it is the old choice between functional/operator notation... >For example, the second expression, b = (X'*X)\(X'*y), would be in >functional notation >something like b=rDiv(Mul(X.T(),X),Mul(X.T(),y)) >This is ok, but imho far more error prone than operator notation, >because >- all linear algebra textbooks present expressions with operator >notation >- the operator notation is more natural to almost everybody when dealing >with arithmetic > I wonder if some of these problems could be approached in a more general manner. What if Python could support the definition of operators in the same manner as functions? If that were the case then something like: opr rDiv(X, y): would define a new operator function that would work like: b = X rDiv y The big advantage would be that special purpose grammars could be easily imported. The core language could be kept as simple as possible, but still be extensible in a way that matters to a lot of people. I suspect that whitespace would be required around these new 'operators', although many people already do that with regular operators. Also, I'm not sure how you'd specify an operator that wasn't valid as a function name, but I can think of possibilities. -- Andy Henshaw From m.faassen at vet.uu.nl Tue Jul 11 07:34:37 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Jul 2000 11:34:37 GMT Subject: POOP / Python (Object Oriented Persistence) ? References: <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> Message-ID: <8kf0od$708$1@newshost.accu.uu.nl> "Tony J Ibbs (Tibs)" wrote: [snip] > The persistent Java effort requires quite a lot of work in the innards of > Java (i.e., C++ programming). This is presumably because Java doesn't expose > its insides to introspection in the same way Python does (Zope does use > vanilla Python, doesn't it? Yes, though it uses ExtensionClasses which hook into some arcane part of Python. But it runs with vanilla Python, yes. > Can it work with JPython? (I assume not)). It'd be a major project to make it work with JPython, I think. I don't know if anyone actually seriously looked into this yet, though -- it may be quite doable. > This is obviously a disadvantage for the PJama people, not least because > of the licensing terms around Java (i.e., why they can't call their > variant pJava, even though they have had funding from Sun). Right -- open source is cool. :) [snip] > How easy is it to write a storage manager? I haven't tried myself, but given that there are various storage managers already there and some in the making, it is definitely doable. Someone's working on a storage manager on top of ReiserFS, for instance. > It sounds to me as if this would > be a useful thing to layer on top of a COM or CORBA interface to (for > instance) an existing GIS, taking advantage of whatever versioning, locking, > etc., that that existing software provides. Hm, I'm not quite sure what you mean here. What's a GIS? Note that the ZODB *does* depend on the Python-specific pickle protocol, so building it on top of say, a relational database, only gives you minimal advantages. SQL queries and such aren't very useful, as it's just pickled data in the fields. For the same reason I think taking advantage of versioning and locking of some underlying system is hard -- ZODB itself is perhaps too low level for that. I may be wrong, though. > Snags. > Well, it's obviously a bit of a pain if __getattr__ and __setattr__ are > unavailable for easy use - although I can't say I've used them for anything > significant myself, they're useful tools for the back pocket. I actually heard a while back that in the 2.2 release of Zope __getattr__ and __setattr__ are available again. I haven't checked into that yet. > Also, the "lists and dictionaries aren't classes so we have to prod the > persistence when they're altered" thing is a slight pain. Agreed. Easiest thing to do is something like this though: mylist = self.mylist # put in local variable (speed benefit in some cases!) mylist.append("change the list") self.mylist = mylist # prod persistence [snip] > So, why isn't this better known? I think because the Python and Zope worlds are quite a bit apart in some ways. Of course there's lots of overlap, but your average Zope user isn't necessarily well aware of the Python community and vice versa. Of course AMK's article is probably specifically an attempt to make the ZODB more well known. It'd also help if the ZODB could be easily downloaded as a package by itself. There's a packaging wiki (discussion hypertext thing) on www.zope.org to deal with such issues. I'm not sure how active it is, though. > Is it just that Python is too good at too > many things? Maybe we need a page of "clever things Python does that other > people think are hard", or "important buzzword compliances by application", > on the PythonLabs site... > [It would help if this was all more evident from the Zope site, as well, > though. Talk about hard to navigate round.] You should get in touch with the Zope folks if you want the Zope site improved -- tell them about your problems. They're actively looking at ways to improve that site. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From akuchlin at mems-exchange.org Fri Jul 28 08:56:22 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jul 2000 08:56:22 -0400 Subject: The State of Python References: <14721.10664.984701.353597@anthem.concentric.net> Message-ID: <3daef2v2fd.fsf@kronos.cnri.reston.va.us> bwarsaw at beopen.com (Barry A. Warsaw) writes: > Without GPL compatibility, Mailman could never rely on any feature or > patch after the Python 1.6alpha2 release. Why would this matter? Mailman is an application, so its licence is orthogonal to the licence of the substrate it runs on. You can compile GNU diff using a Sun compiler, and you could write a GPLed app in Delphi and release it, after all. (Or does Mailman copy bits out of the latest Python in order to guarantee that it has features it needs?) --amk From bdupire at seatech.fau.edu Fri Jul 14 15:04:41 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Fri, 14 Jul 2000 15:04:41 -0400 Subject: Setting a C-structure from Python References: <39649D5C.F1652171@seatech.fau.edu> Message-ID: <396F6449.F2E63F85@seatech.fau.edu> Armin wrote: -------------------------------------------------------------- I have changed your code in the following way: static PyObject * test_setstruct(PyObject * self, PyObject * args) { //PyObject * string_from_python; char * string_from_python; int len; // if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; if (!PyArg_ParseTuple(args,"s#",&string_from_python, &len)) return NULL; // example= (examplestruct *) PyString_AsString(string_from_python); example= (examplestruct *) string_from_python; // Py_DECREF(string_from_python); print_struct(); Py_INCREF(Py_None); return Py_None; } ---------------------------------------------------- Ok it works too! You convert the PythonString in a C string representation right away with PyArgs_ParseTuple. Now, I changed the test_getstruct function in the same way.. static PyObject * test_getstruct(PyObject * self, PyObject * args) { if (!PyArg_ParseTuple(args,"")) return NULL; return Py_BuildValue("s",(char *)exampleptr); } Yes.. it was too easy : it doesn't work : Traceback (innermost last): File "", line 1, in ? File "//1/old_home/bdupire/Alpha/morpheus/Python-1.5.2/Lib/my_prog/structure.py", line 24, in ? a =struct.unpack(fmt,rec) struct.error: unpack str size does not match format So my question is the following: how to tell Py_BuildValue about the size of the structure and the number of bytes to grab ? From spierre at rational.com Fri Jul 21 18:24:58 2000 From: spierre at rational.com (Sebastien Pierre) Date: Fri, 21 Jul 2000 22:24:58 +0000 Subject: Dynamic package exploration Message-ID: <3978CDBA.5859E594@rational.com> Hi ! I'm having a strange problem with Python : I cannot reference any Python object using an absolute name... Example : >>print os.name fails.... But if I do >>import os >>print os.name It works - so I guess you have to "import" first before being able to reference anything. But if I do : >>eval ( "import os" ) It doesn't work...so it prevents me from doing something dynamic...Ouch! The point is that I want to dynamically load a set of extensions that belong to a specific package. Let's say I have a package A that contains 10 python files. What I want to do is dynamically inspect the content of A (the 10 python files), and check if those python files have the attribute called '__my_attribute__'. Then I want to register these attributes in a list. Is it possible ? Thanks, Seb. -- Sebastien Pierre.- spierre at rational.com \ R a t i o n a l software | XML \ If you like classical music, . Rational Unified Process | technology \ feel free to visit . Vancouver, B.C, -Canada | intern \ From sglanger at u.washington.edu Wed Jul 19 11:22:08 2000 From: sglanger at u.washington.edu (Steve Langer) Date: Wed, 19 Jul 2000 08:22:08 -0700 Subject: Internet Programming in Python References: <397221B2.173C3947@u.washington.edu> <39736DEB.D2285ADD@gs.verio.net> Message-ID: <3975C7A0.8D9F2517@u.washington.edu> Nope, they don't. Tony Johnson wrote: > http://www.ora.com shuld carry this one... > > steve langer wrote: > > > > Does anyone know a used book store that would carry this out of print > > book? > > > > Email great. > > > > thanks, > > SL sglanger at oakland.edu > > > > -- > > http://www.python.org/mailman/listinfo/python-list From gee308 at mediaone.net Sun Jul 23 01:01:13 2000 From: gee308 at mediaone.net (Toy) Date: Sun, 23 Jul 2000 05:01:13 GMT Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> <210720002132510070%matt@mondoinfo.com> <39794752.D54A50CD@mediaone.net> <220720001345342915%matt@mondoinfo.com> <397A44A8.E3697BF1@mediaone.net> Message-ID: <397A8130.FC7CBF8A@mediaone.net> > Sorry, I didnt see the bottom line. From paul at prescod.net Wed Jul 19 12:14:37 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:14:37 -0500 Subject: CVS missing xmlparse.h References: <3975BA62.91AE3D0@prescod.net> <5YhvBcAHucd5Ewz$@jessikat.fsnet.co.uk> Message-ID: <3975D3ED.2CD5AEAA@prescod.net> Robin Becker wrote: > > ... > > so the core will include the module source, but not a needed .h file; Guido has a policy against distributing other people's modules. > the python-xml kit used to include all; I guess Andrew Kuchling isn't such a hard-ass. :) > do I need pyexpat.pyd? Probably > not. No, if you're compiling yourself you don't need it. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From fugate at lucent.com Mon Jul 31 09:35:30 2000 From: fugate at lucent.com (Cris A. Fugate) Date: Mon, 31 Jul 2000 08:35:30 -0500 Subject: variable scope Message-ID: <398580A2.9EBD6072@lucent.com> Hi, Im new to Python and I have a question about variable scope. It seems that any variable declared in a function is local. Is there any way to define a global variable within a function? For example, Tcl can use eval and uplevel to evaluate code on any scope level. In Scheme a local variable uses let, otherwise it is global. -- ********************************************************************** Cris A. Fugate Lucent Technologies, Robust Process Automation fugate at lucent.com http://ihgpweb.ih.lucent.com/~fugate 630 713-8255 Creator of framesets, a frames implementation -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.faassen at vet.uu.nl Fri Jul 28 23:40:01 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 03:40:01 GMT Subject: [Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> Message-ID: <8ltjmh$31a$3@newshost.accu.uu.nl> Konrad Hinsen wrote: [snip] > Looks like a good idea, count me in. Perhaps it would also help to > add Python-based projects that are administrated by the people who > sign the letter, to show that serious users are concerned and not > just people who love signing open letters. > And you can add me to the list, of course. >> P.S.: >> I find it rather startling that you see a need to change the license of >> a software whose development already has moved away from your institution. > I would rather not mention this issue. If the move to BeOpen is the > reason for CNRI's prolonged legal fight, then it's better not to > point it out again. And if it isn't, it's better not to suggest a > new argument to them. Agreed -- I'd remove the P.S. too. Without it add me to the list. Perhaps add a bit more diplomatic stuffing, such as "Perhaps it was unclear that this raises some concern in the community" and "Perhaps we missed the official statement from CNRI", giving a bit more benefit of the doubt is never bad. But this are just minor suggestions; excellent work! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From osuchw at ecn.ab.ca.nospam Sat Jul 22 19:05:26 2000 From: osuchw at ecn.ab.ca.nospam (waldekO) Date: Sat, 22 Jul 2000 17:05:26 -0600 Subject: Cannot create objects in Zope 2.2.0 References: <8ld6sb$qg5$1@nnrp1.deja.com> Message-ID: <%Mpe5.163$K85.8343@jekyl.ab.tac.net> wrote in message news:8ld6sb$qg5$1 at nnrp1.deja.com... > I've just downloaded Zope 2.2.0 for win32 and installed it. > > Ir runs with administrator privileges, but when I try to create any > objects I get the following message: > > ----------------- > Zope Error > > Zope has encountered an error while publishing this resource. > > Error Type: SuperCannotOwn > Error Value: Objects cannot be owned by the superuser Read the error. You have to create another user beside the administrator then logon as the new user and you can create objects. waldemar > > Any Ideas? > > Thanx! > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From bragib at my-deja.com Mon Jul 17 16:28:34 2000 From: bragib at my-deja.com (bragib at my-deja.com) Date: Mon, 17 Jul 2000 20:28:34 GMT Subject: Multiline strings and indentation References: <39736250$0$14722@wodc7nh6.news.uu.net> Message-ID: <8kvq8s$ali$1@nnrp1.deja.com> Can't you do someting like this. def multiline(x): if x: print "this is a"\ " multi-line string that spans"\ " three lines" print "another string" Sent via Deja.com http://www.deja.com/ Before you buy. From j.doty at gte.net Thu Jul 27 02:05:37 2000 From: j.doty at gte.net (John Doty) Date: Thu, 27 Jul 2000 06:05:37 GMT Subject: Python and COM: Aggregation? References: Message-ID: Groovy. I'll get right on it then. :) I've just been digging though the source, does look pretty easy... will it be a problem if people have to rebuild all the extentions? I don't think I can do it in a binary-compatible way. Also, while I'm on the subject-- has anybody written extentions for COM+ 1.0? john "Mark Hammond" wrote in message news:SNPf5.13158$4p3.102513 at news-server.bigpond.net.au... > "John Doty" wrote in message > news:AiPf5.138$6Z.107941 at paloalto-snr1.gtei.net... > > I love Python. I want to use it for all my programming needs. > > > > But I can't. > > > > Is there a reason that COM objects implemented in Python are not > > aggregatable? > > Simply no one has been bothered to add it. AFAIK, no one plans to, > either. Patches would be accepted tho! Should be not too difficult as we > already support delegation of IUnknown back to another object to support > COM identity rules. > > Mark. > > > From python-list at teleo.net Tue Jul 11 11:59:49 2000 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 11 Jul 2000 08:59:49 -0700 Subject: checking the existence of a fiel In-Reply-To: References: Message-ID: <00071109133610.03526@quadra.teleo.net> [Fernando Rodr?guez, on Tue, 11 Jul 2000] :: How can I check if a file exists? O:-) I see that your email address is "mindless.com" ... ... perhaps that's the reason -- or maybe you're just new here. At any rate, you don't appear to have gotten the news yet about the Python Library Reference. That's the document we all research *before* we ask trivial questions on this newsgroup. ;-) http://www.python.org/doc From nobody at nowhere.nohow Fri Jul 28 21:06:16 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:06:16 GMT Subject: Perl is worse! References: <7Khg5.2679$6E.683965@ptah.visi.com> Message-ID: In article , Steve Lamb wrote: >On Fri, 28 Jul 2000 15:34:27 GMT, Grant Edwards wrote: >>I'm not ignoring that case. I'm stating that I want to do the conversions >>explicitly rather than implicitly. Why do you find it so difficult to >>believe that "I want X" when I tell you "I want X"? I'm _not_ trying to tell >>you that "you want X" or "you should use X". I am trying to tell you that "I >>use X" because "I want X". > > Fair enough. So why can't we have both? Why can't we have variables >which are mutable and those that aren't? We could have both. But now the language is more complex, and it's harder to tell what a chunk of code does unless you have more context information available. One of the goals of Python appears (to me) to be to make the language simple enough that you don't need much context to figure out what a piece of code does. One of the problems with complex languages such as C++ is that it's so hard for th reader to determine what a piece of code is going to do without either just tring it or having a whole bunch of context information. >Just because something can be changed doesn't mean it can't be forced into a >certain context. -- Grant Edwards grante Yow! I love FRUIT at PICKERS!! visi.com From paul at prescod.net.bbs Mon Jul 17 12:20:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 16:20:02 GMT Subject: Python VM on a Chip? Message-ID: <3bRI13$kvw@openbazaar.net> Jim Brennan wrote: > > ... > > Has anyone ever considered doing the same kind of thing with the Python > VM? Is it even possible since the data types of Python are late > binding? Does anyone know of a commercial or university project that is > implementing a Python VM using ASICs or FPGAs? The data types aren't a problem. It isn't clear (to me) what the benefit of the project would be. Python code can already run in a lot of embedded systems through x86 compatibility and JVM compatibility. A dedicated chip might give better performance, but compiling Python to x86 would probably give even better performance. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From nelson_chenkin at seagate.com Thu Jul 20 13:14:22 2000 From: nelson_chenkin at seagate.com (nelson_chenkin at seagate.com) Date: Thu, 20 Jul 2000 17:14:22 GMT Subject: Embedded System - Trapping Errors Message-ID: <8l7c11$u0b$1@nnrp1.deja.com> I am embedding Python on a machine that does not have an output device. A Python script file is sent down to this machine from a host via an Ethernet connection and is then executed remotely. This is all working like a charm. Now I want to start intercepting script errors, converting the errors to an format of my own design, then send them back up to the host machine where they can be reported to the user. Can this be done? I have stepped through the code in PyArg_ParseTuple() to see what happpens when I intentionally provide the wrong number of arguments. It seems like all this error handling is hard coded. There is not any indirection that allows me to install an error handling hook. I am running the script using PyRun_AnyFile(). By the time that returns to me the error has been cleared - the hardcoded call to PyErr_Print() which then calls PyErr_Fetch() clears it. Obviously I can change the source code, but this presents a problem when new Pythons versions are released. Any help would be appreciated. Thanks, NC Sent via Deja.com http://www.deja.com/ Before you buy. From shapr at uab.edu Wed Jul 26 16:45:44 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 26 Jul 2000 20:45:44 GMT Subject: python compiler? References: <8lkvic$d621@magpie.cat.net.th> Message-ID: <397F4D4D.AEB129B3@uab.edu> Jamie Allison wrote: > > Does anybody know of a compiler for pyhton? Jeremy Hylton has a source to bytecode compiler written in Python. it's in the python/nondist/Compiler/ part of the CVS tree. Greg Stein and Bill Tutt wrote a Python2C translator, which cuts at least 10percent off of running time from what I've read. The C file that's written is a Python module, and so won't let you make a pure executable though. It's at http://lima.mudlib.org/~rassilon/py2c/ (or was last I checked) A python compiler is definitely possible, especially once you've checked out the two projects mentioned above. I don't know how much it's needed though. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From gfortune at micron.net Sat Jul 8 00:18:15 2000 From: gfortune at micron.net (Greg Fortune) Date: Fri, 7 Jul 2000 21:18:15 -0700 Subject: Wait/Delay References: <8k2lhd$5i6$1@gossamer.itmel.bhp.com.au> Message-ID: And put this in a while loop and a statement will only execute on the minute... That allows you to run a statement at predefined intervals regardless of how long the command takes (as long as it takes less than a minute or 5 or 60 or whatever you set it to) For example, I wanted to run a ping once a minute. If I just time.sleep(60) or time.sleep(45) even, the ping will not always take the same amount of time. Here's the code :) time.sleep(60 - string.atoi(time.strftime('%S', time.localtime(time.time())))) and btw, this can probably done cleaner. I did this the second day I used Python Greg Stephen Hansen wrote in message news:F1595.115780$WS3.1008506 at typhoon.we.rr.com... > >>> import time > >>> time.sleep(1) > > There :) > > --Stephen :) > > A J Wilson wrote in message > news:8k2lhd$5i6$1 at gossamer.itmel.bhp.com.au... > > Hi > > > > Is there a command/function in python to put a delay or wait step into a > > program? > > > > Thanks > > Austin > > > > > > From guido at beopen.com Fri Jul 28 09:12:43 2000 From: guido at beopen.com (Guido van Rossum) Date: Fri, 28 Jul 2000 13:12:43 GMT Subject: New operators needed? (was Re: Discussion: new operators for numerical computation) References: <397C9207.EC0528AA@eecis.udel.edu> <8lqbqu$uhm$1@slb2.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > In article , > Konrad Hinsen wrote: > > > >You raise an important point: adding operators may not be the best > >solution at all. > > > >With the ongoing rework of NumPy that turns arrays into Python classes > >with an underlying C implementation, it would be possible to have an > >"array" and a "matrix" class with different semantics, but sharing > >most of the code and having equal performance. Conversion between the > >two would also be possible at basically no cost, and C modules could > >be written to accept both. > > Huzzah! "And there was much rejoicing in the land...." By the way, Konrad (hi!) -- what's the status of that reworking? I've totally lost track of NumPy. The SourceForge project doesn't seem very active. So how is this going? Is it going anywhere? --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From iain at wombatzone.freeserve.co.uk Sun Jul 2 17:29:16 2000 From: iain at wombatzone.freeserve.co.uk (Iain Calder) Date: Sun, 02 Jul 2000 21:29:16 +0000 Subject: PyGTK and draw_array References: <395F0CA6.A20736F@pp.htv.fi> Message-ID: <395FB42C.89F435B0@wombatzone.freeserve.co.uk> Esko Lehtonen wrote: > > I am trying to manipulate an image and then draw it to GtkDrawingArea > using PyGtk and Numerical Python. > So I made following code: > > WIDTH = 30 > HEIGHT = 20 > D = 3 > # create rgb image as array, every value 100 > img = ones((WIDTH, HEIGHT, D), 'b') > img = img * 100 > ---- > darea = GtkDrawingArea() > ---- > draw_array(darea.get_window(), > widget.get_style().black_gc, x, y, > GDK.RGB_DITHER_NORMAL, img) > > I still have a problem, because then a got: "TypeError: array data must > be unsigned bytes" when I'm trying to use the draw_array function. After multiplying by 100, img is not longer of type 'b'. img.typecode() returns 'i'. Use img=img.astype('b') before the call to draw_array to cast back to bytes. HTH, Iain Calder From stephen at cerebralmaelstrom.com Fri Jul 7 22:33:47 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sat, 08 Jul 2000 02:33:47 GMT Subject: Newbie: Development plaform References: <20000707190803.4740.qmail@web210.mail.yahoo.com> Message-ID: My favorite GUI is wxPython (http://www.wxpython.org) and my favorite database is MetaKit (http://www.equi4.com/metakit). wxPython, to me, seems more `natural` on the Windows platform which is rather important to me, and it also doesn't require the installation of different scripting language just to run it, like Tkinter does.. that irritates me :) MetaKit is just awesome. Its fast, incredibly flexible and dynamic, and just about seems to suit me perfectly. :) The only drawbacks you may have for it is that it's not a SQL database, but there is a (beta? alpha?) SQL parser for it. --Stephen Demos Economacos wrote in message news:20000707190803.4740.qmail at web210.mail.yahoo.com... > Hello, > > I am comtemplating development of a system that will > have to run on Linux, Win and Mac. > > My questions are: > What GUI tool and Database (< 100,000 recs) would you > recommend? > How to distribute programs to users (< 100) > > Thanks > > Demos > > > > > __________________________________________________ > Do You Yahoo!? > Send instant messages & get email alerts with Yahoo! Messenger. > http://im.yahoo.com/ > From cjensen at bioeng.ucsd.edu Tue Jul 11 18:39:35 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 11 Jul 2000 15:39:35 -0700 Subject: Python and SSH References: <8kf4gl$fqm$1@saltmine.radix.net> Message-ID: <396BA227.7EE196E1@bioeng.ucsd.edu> Cary O'Brien wrote: > > I'd like to have a running python process ACCEPT an incoming SSH > connection. Any ideas on how I could do this? > > -- cary If I'm not mistake SSH just sends data accross a socket, same as most network protocals (I'm not sure which port SSH sends on). You can use the socketServer module to catch socket data from the SSH port. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From dalke at acm.org Wed Jul 5 12:29:28 2000 From: dalke at acm.org (Andrew Dalke) Date: Wed, 5 Jul 2000 10:29:28 -0600 Subject: Nth digit of PI References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca><394889C3.1ED5@esatclear.ie> <20000705071827.A1015156@vislab.epa.gov> Message-ID: <8jvni0$amr$1@slb3.atl.mindspring.net> Randall Hopper >But one of the interesting things that you can show with a Fourier >integral (possibly other ways too) is that: > > Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2) > >You can see that the sum is 1/1 + 1/9 + 1/125 + .... The terms get smaller >and smaller, which means making the decimal representation longer and >longer. In the limit, the decimal representation is infinitely long >because the denominator is infinitely large. I've seen the proof that e is irrational, but don't recall the details. The sketch you outlined isn't sufficient. Consider sum(n=1..inf, 1/n^2) = 1 + 1/2 + 1/4 + 1/8 + ... = 2 For any finite N in the sum 1..N, the denominator is infinitely large, but the infinite sum is an integer. Andrew dalke at acm.org From richard_chamberlain at ntlworld.com Tue Jul 18 02:42:37 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Tue, 18 Jul 2000 07:42:37 +0100 Subject: grid References: <8kvkvt$68h$1@nnrp1.deja.com> <8kvome$9ah$1@nnrp1.deja.com> Message-ID: Yes that looks fine. You might want to either increase the ipad of the right frame or add a blank label: Label(right,text='',bg='orange').grid(row=1,column=0,columnspan=2) so that your two frames are identically sized. Try and get the hang of pack though, it's probably the most popular and powerful of Tk's layout managers. I find that I use pack for 90% of my layouts. But that maybe just me. Oh and I think you spelt sweet wrong. Richard Keith Murphy wrote in message news:8kvome$9ah$1 at nnrp1.deja.com... > does this look alright? > > # embed.py > from Tkinter import * > > root = Tk() > > left = Frame(root, bg='red') > right = Frame(root, bg='orange') > > button1 = Button(left, text='hi') > button2 = Button(right, text='yo') > > entry1 = Entry(left) > entry2 = Entry(right) > > label1 = Label(left, text='this is schweet') > > left.grid(row=0, column=0, ipadx=10, ipady=10) > right.grid(row=0, column=1, ipadx=10, ipady=10) > button1.grid(row=0, column=0) > button2.grid(row=0, column=0) > entry1.grid(row=0, column=1) > entry2.grid(row=0, column=1) > label1.grid(row=1, column=0, columnspan=2) > > > mainloop() > # end embed.py > > > thanks, > -->keith > > In article <8kvkvt$68h$1 at nnrp1.deja.com>, > Keith Murphy wrote: > > can you embed grids? ...what i'd like to do is grid within several > > frames, and then grid the frames together. sort of like html > tables... > > i hate pack. > > > > -->keith > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From warren at sunesis-pharma.com Thu Jul 6 23:49:37 2000 From: warren at sunesis-pharma.com (Warren L. DeLano) Date: Thu, 06 Jul 2000 20:49:37 -0700 Subject: Namespace Mystery (HELP!) Message-ID: <39655351.9EE499F2@sunesis-pharma.com> In the following code (with Python 1.5.2)... ************** a = 1 def fn(): b = 1 globals()['a']=2 locals()['b']=2 print a,b fn() ************* Why is the output "2 1" and not "2 2"? What is it about the locals() function that makes it behave unexpectedly? Note that the same unexpected result also occurs with exec. def fn(): b=1 exec "b=2" in globals(),locals() print b # output is "1" does not produce the same result as def fn(): b=1 exec "b=2" print b # output is "2" The former example does not modify the function's local name space, where the latter does...my expectation would be that both examples should modify the local namespace. Has this behavior changed in 1.6? Insight from a Python Guru would be much appreciated! Thanks, - Warren -- mailto:warren at sunesis-pharma.com Warren L. DeLano, Ph.D. Informatics Scientist Sunesis Pharmaceuticals, Inc. 3696 Haven Ave., Suite C Redwood City, CA 94063 (650)-556-8800 fax: (650)-556-8824 From mhammond at my-deja.com Sun Jul 16 22:21:42 2000 From: mhammond at my-deja.com (Mark Hammond) Date: Mon, 17 Jul 2000 02:21:42 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> <396f9d89.25704394@news.btx.dtag.de> Message-ID: <8ktqjc$rjl$1@nnrp1.deja.com> In article <396f9d89.25704394 at news.btx.dtag.de>, spamfranke at bigfoot.de (Stefan Franke) wrote, regarding Python .NET [FWIW, the ActiveState page for this stuff is at http://www.activestate.com/.NET ] > How will that all impact the future of the CPython / Win32 > integration? It is just yet another demand on my time. It certainly does not sound the death knell for Pythonwin, win32com, or the win32 extensions. But-sometimes-I-wish-it-did-ly, Mark. Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Thu Jul 20 11:28:56 2000 From: aahz at netcom.com (Aahz Maruch) Date: 20 Jul 2000 15:28:56 GMT Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l6vc5$c07$1@slb6.atl.mindspring.net> <+MLEAgA0Lxd5EwDd@jessikat.fsnet.co.uk> Message-ID: <8l75ro$gai$1@slb6.atl.mindspring.net> In article <+MLEAgA0Lxd5EwDd at jessikat.fsnet.co.uk>, Robin Becker wrote: >In article <8l6vc5$c07$1 at slb6.atl.mindspring.net>, Aahz Maruch > writes >>Attribution for Remco Gerlich restored: >>> >>>The function zip as proposed (combine two lists into a list of pairs) >>>is straight from Haskell (and other functional languages) just like map >>>and filter. I think zip is the obvious name. >> >>Ah. Hmmmm.... Well, then, I guess I withdraw my objections to zip. >>I'd still prefer something else, but.... > >so are we saying that the almost unknown language Haskell has the >correct semantics for this; zip has at least three common usages other >than of zip fastener meaning (interlace). I'm not saying that. I'm saying that given that zip() is to be used for the purpose of giving Python some of the attributes of functional languages, it's reasonable to use the same notation they do (particularly if it's more than just Haskell). I still don't *like* it, but I'll put up with it, even though I'm worried about namespace collisions when someone creates a file zipping routine. "Standards are wonderful: there are so many of them to choose from." -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From paul at prescod.net Mon Jul 24 22:38:36 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 21:38:36 -0500 Subject: Operators for everything (was Re: Operators for matrix) References: <397CB3EA.15F5514F@prescod.net> <200007250053.RAA03842@rocket.knowledgetrack.com> Message-ID: <397CFDAC.38A22DAF@prescod.net> Huaiyu Zhu wrote: > > ... > > Is this meta operator allowed to be combined with existing operators, or is > it for identifiers only? Various people have proposed various different versions but my preference would be that it is for identifiers only. I think we should use alphanumerics for new operators for the same reason we use alphanumerics for variable and function names. So that when you come into a piece of code that you are not familiar with, you have a chance of understanding it. For instance, you could write this: from matpy import elementwiseadd ea=elementwiseadd j = a @ea b Now you can figure out what ea means merely by walking backwards through the code. Even if all you got from matpy was "ea" you might have a half a chance of guessing. OTOH, there is no way to guess whether @+ is elementwise or matrixwise in a particular piece of code. > If the former, then @+ @- @* @/ etc are also available. I don't think so. > A related question: > > If @add does not need to be hard coded in C, why @+ need so? Neither needs to be hard-coded into the grammar. The parser could always recognize them from the leading @-symbol. This is different from your earlier proposals where *any sequence of symbols* could be an operator. That's quite different. Nevertheless, I would be extremely reluctant to add a feature that would encourage people to do @++, @-- @+* and so forth. @increment is not so bad. @decrement is not so bad. @positive_mul (whatever that might mean in some particular domain) is not so bad. I think name-based binary operators are actually pretty neat and can be used very Pythonically. IMO, they are the right compromise between terseness and legibility. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From apardon at trout.vub.ac.be Mon Jul 31 09:29:09 2000 From: apardon at trout.vub.ac.be (apardon at trout.vub.ac.be) Date: 31 Jul 2000 13:29:09 GMT Subject: newbee, needs PIL-support Message-ID: <8m3uv5$fe5$1@snic.vub.ac.be> I cant find out how to access the palette? How do I figure out which colour a particular index represents? How do I change a palette-entry? I found out that converting an RGB image to a P-image doesn't always give an optimal palette. I have converted a five of six colorimage and I get pixel-values 45 and 225. Is there a way to optimalize the palette? -- Antoon Pardon From sabren at manifestation.com Thu Jul 27 11:46:47 2000 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 27 Jul 2000 11:46:47 -0400 (EDT) Subject: cgi dectection In-Reply-To: <39804dc7_1@news.chariot.net.au> Message-ID: On Fri, 28 Jul 2000, Michael Lunnay wrote: > is there a standard way to detect if script is being run as a cgi script or > from the command line. I am creating a script that can be run from both and > obviously want the cgi to output HTML but the cammnd line to print text. A couple ways to get what you want come to mind: 1. check for CGI-specific variables in os.environ, eg CONTENT_TYPE 2. make the core logic into a module, and then have two front ends. :) 3. check for a command line flag if you want text.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From donn at oz.net Thu Jul 20 03:06:49 2000 From: donn at oz.net (Donn Cave) Date: 20 Jul 2000 07:06:49 GMT Subject: Obscure Threading Bug References: Message-ID: <8l68e9$nrl$0@216.39.151.169> Quoth Glyph Lefkowitz : | I apologize for the length and obscurity of the attachment. However, the | previous example where I encountered this bug was easily twenty times as | long, and it took some effort to make it this short :-). | | Simply put, the interpreter usually segfaults when I run this file. I | don't know exactly why. My copy of python doesn't have debugging | symbols,so my backtraces aren't terribly meaningful, but the first few | lines are usually something like: | | #0 __flockfile (stream=0x0) at lockfile.c:32 | #1 0x4009ac07 in _IO_ferror (fp=0x0) at ferror.c:35 | #2 0x8069178 in PyFile_SetBufSize () | | the common theme being PyFile_SetBufSize (). | | "lots of threads, lots of sockets" is a common theme for a lot of apps | that I would like to build, so I would be glad to help if there's any more | information I can supply. | | This bug has been known to occurr on: RedHat/Debian Linux default Python | install, Digital Unix python 1.5.2 (Digital UNIX V4.0F (Rev. 1229); Thu | Jul 15 17:56:36 EET DST 1999) and on debian using CVS python. I tried it on a couple of others - FreeBSD 4.0, BeOS 4.5.2 - and actually didn't get any crashes, but did get some tracebacks. With luck perhaps someone who is more familiar with SocketServer and threads will have an easy fix. I can only say, this looks like a recipe for trouble to me. The cure, in my opinion, is to quit using file objects, and carefully segregate every single direct access to (one end of) a socket into its socket-specific thread. Even recv() vs. send(), these should happen in the same thread. That's how I do it. Maybe you can get away with some things that I stay away from, it's up to you. Now when another thread wants to do something with our socket, it has to go through the socket thread, which is naturally blocking on input from the socket. The mechanism is another socket, or a pipe, and the select() function. Could sound like a hack, but that extra I/O is essentially your message based dispatching system, and in my opinion it's the most elegant way to work with threads. It's also possible to add a thread-interlocked function call parameter passing database, to reduce the potential size of I/O if that's an issue. I have code that does that kind of thing, and I'm thinking about cleaning it up and making it more generic (currently very BeOS specific) for other people to use. Is there any other message dispatch thread framework out there we should be looking at? Donn Cave, donn at oz.net From bjorn at roguewave.com Tue Jul 18 19:07:45 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 18 Jul 2000 17:07:45 -0600 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <3974E341.58FC8939@roguewave.com> Robin Becker wrote: > > I suppose there must be something desperately wrong with using the > __mul__ for sequences to indicate the set pairwise product. I would > certainly be for > > x,y in A*B rather than x,y in zip(A,B) or marry(A,B), but since * is the > obvious operator it must be that someone else has reserved it. if A is of a class defining __mul__ (or B is of a class defining __rmul__) you'll have problems. How about A @ B... running-and-hiding'ly y'rs -- bjorn From bwarsaw at beopen.com Thu Jul 27 15:24:38 2000 From: bwarsaw at beopen.com (Barry A. Warsaw) Date: Thu, 27 Jul 2000 15:24:38 -0400 (EDT) Subject: PEP 201, zip() builtin Message-ID: <14720.35958.632383.574511@anthem.concentric.net> Folks, Here is the latest PEP 201, updated based on conversations with Guido yesterday. Notice that there are no more Open Issues. See instead the BDFL Pronouncements section. Plan on seeing a C-based implementation checked into the CVS devel tree soon. If you want to comment on this PEP, you must include "PEP 201" in the Subject: header. Enjoy, -Barry -------------------- snip snip -------------------- PEP: 201 Title: Parallel Iteration Version: $Revision: 1.10 $ Author: bwarsaw at beopen.com (Barry A. Warsaw) Python-Version: 2.0 Status: Draft Created: 13-Jul-2000 Post-History: 27-Jul-2000 Introduction This PEP describes the `parallel iteration' proposal for Python 2.0, previously known as `parallel for loops'. This PEP tracks the status and ownership of this feature, slated for introduction in Python 2.0. It contains a description of the feature and outlines changes necessary to support the feature. This PEP summarizes discussions held in mailing list forums, and provides URLs for further information, where appropriate. The CVS revision history of this file contains the definitive historical record. Motivation Standard for-loops in Python iterate over every element in a sequence until the sequence is exhausted[1]. However, for-loops iterate over only a single sequence, and it is often desirable to loop over more than one sequence, in a lock-step, "Chinese Menu" type of way. The common idioms used to accomplish this are unintuitive and inflexible. This PEP proposes a standard way of performing such iterations by introducing a new builtin function called `zip'. Parallel For-Loops Parallel for-loops are non-nested iterations over two or more sequences, such that at each pass through the loop, one element from each sequence is taken to compose the target. This behavior can already be accomplished in Python through the use of the map() built-in function: >>> a = (1, 2, 3) >>> b = (4, 5, 6) >>> for i in map(None, a, b): print i ... (1, 4) (2, 5) (3, 6) >>> map(None, a, b) [(1, 4), (2, 5), (3, 6)] The for-loop simply iterates over this list as normal. While the map() idiom is a common one in Python, it has several disadvantages: - It is non-obvious to programmers without a functional programming background. - The use of the magic `None' first argument is non-obvious. - It has arbitrary, often unintended, and inflexible semantics when the lists are not of the same length: the shorter sequences are padded with `None'. >>> c = (4, 5, 6, 7) >>> map(None, a, c) [(1, 4), (2, 5), (3, 6), (None, 7)] For these reasons, several proposals were floated in the Python 2.0 beta time frame for providing a better spelling of parallel for-loops. The initial proposals centered around syntactic changes to the for statement, but conflicts and problems with the syntax were unresolvable, especially when parallel for-loops were combined with another proposed feature called `list comprehensions' (see pep-0202.txt). The Proposed Solution The proposed solution is to introduce a new built-in sequence generator function, available in the __builtin__ module. This function is to be called `zip' and has the following signature: zip(seqa, [seqb, [...]]) zip() takes one or more sequences and weaves their elements together, just as map(None, ...) does with sequences of equal length. The weaving stops when the shortest sequence is exhausted. Return Value zip() returns a real Python list, the same way map() does. Examples Here are some examples, based on the reference implementation below. >>> a = (1, 2, 3, 4) >>> b = (5, 6, 7, 8) >>> c = (9, 10, 11) >>> d = (12, 13) >>> zip(a, b) [(1, 5), (2, 6), (3, 7), (4, 8)] >>> zip(a, d) [(1, 12), (2, 13)] >>> zip(a, b, c, d) [(1, 5, 9, 12), (2, 6, 10, 13)] Note that when the sequences are of the same length, zip() is reversible: >>> a = (1, 2, 3) >>> b = (4, 5, 6) >>> x = zip(a, b) >>> y = zip(*x) # alternatively, apply(zip, x) >>> z = zip(*y) # alternatively, apply(zip, y) >>> x [(1, 4), (2, 5), (3, 6)] >>> y [(1, 2, 3), (4, 5, 6)] >>> z [(1, 4), (2, 5), (3, 6)] >>> x == z 1 It is not possible to reverse zip this way when the sequences are not all the same length. Reference Implementation Here is a reference implementation, in Python of the zip() built-in function. These would ultimately be replaced by equivalent C code. def zip(*args): if not args: raise TypeError('zip() expects one or more sequence arguments') ret = [] # find the length of the shortest sequence shortest = min(*map(len, args)) for i in range(shortest): item = [] for s in args: item.append(s[i]) ret.append(tuple(item)) return ret BDFL Pronouncements Note: the BDFL refers to Guido van Rossum, Python's Benevolent Dictator For Life. - The function's name. An earlier version of this PEP included an open issue listing 20+ proposed alternative names to zip(). In the face of no overwhelmingly better choice, the BDFL strongly prefers zip() due to it's Haskell[2] heritage. See version 1.7 of this PEP for the list of alteratives. - zip() shall be a built-in function. - Optional padding. An earlier version of this PEP proposed an optional `pad' keyword argument, which would be used when the argument sequences were not the same length. This is similar behavior to the map(None, ...) semantics except that the user would be able to specify pad object. This has been rejected by the BDFL in favor of always truncating to the shortest sequence. - Lazy evaluation. An earlier version of this PEP proposed that zip() return a built-in object that performed lazy evaluation using __getitem__() protocol. This has been strongly rejected by the BDFL in favor of returning a real Python list. If lazy evaluation is desired in the future, the BDFL suggests an xzip() function be added. - zip() with no arguments. the BDFL strongly prefers this raise a TypeError exception. - zip() with one argument. the BDFL strongly prefers that this return a list of 1-tuples. - Inner and outer container control. An earlier version of this PEP contains a rather lengthy discussion on a feature that some people wanted, namely the ability to control what the inner and outer container types were (they are tuples and list respectively in this version of the PEP). Given the simplified API and implementation, this elaboration is rejected. For a more detailed analysis, see version 1.7 of this PEP. References [1] http://www.python.org/doc/current/ref/for.html [2] http://www.haskell.org/onlinereport/standard-prelude.html#$vzip TBD: URL to python-dev archives Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From jlecomte at ifrance.com.bbs Mon Jul 17 10:40:02 2000 From: jlecomte at ifrance.com.bbs (jlecomte at ifrance.com.bbs) Date: 17 Jul 2000 14:40:02 GMT Subject: CXX and Swig, pros and cons Message-ID: <3bRFK2$ivo@openbazaar.net> I am fairly new to Python and I'd like to interface part of a medium size C++ lib (around 70 classes) to Python. I looked on the www and I found CXX and Swig. They seem to have fairly different approach of the problem. I wonder which suits best C++. If I miss any other tool, please let me know. J?r?me. From jeremy at beopen.com Mon Jul 31 13:58:13 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 31 Jul 2000 13:58:13 EDT Subject: 64k Instruction Limit ?? References: <326536345498D311B3BC00105A39802A0747D3@newsintern.dspace.de> Message-ID: Stefan Migowsky writes: > if got a script which defines a big tuple > 64k entries. > After the tuple I define a for loop. > > The compile of this script causes a SystemError : com_addbyte out of > range. > Is there any way around this now or in future versions, other than > to try to change the script layout until it compiles ? I expect this will be fixed in Python 2.0. Charles Waldman has a patch to fix it. I believe there is still some discussion about how exactly to fix it, but not about whether to fix it. Jeremy -- Jeremy Hylton From hzhu at knowledgetrack.com Fri Jul 21 22:48:01 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Sat, 22 Jul 2000 02:48:01 GMT Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: On Sat, 22 Jul 2000 02:11:54 GMT, Neil Hodgson wrote: >> ... Surprisingly (maybe not, >> considering the math-oriented constituency), the third option draws the >most >> praise and almost not criticism. It has more variations and have more >> potential for the future. Despite that, imo, it is unlikely to be >accepted >> eventually, because it would not play well with by non-math audience. > > As one of the more reactionary Pythoneers with regard to syntax changes >and as someone who is unlikely to ever need to use the new operators, I say >the braced operators are the best. I just posted a summary that dismissed this idea before seeing recent two posts favoring brace based operators. It's becoming increasingly obvious that most discussants here favor this. Yes, I agree with all the advantages of this. Now the questions are: 1. How do we test reactions from people who do not read this thread? Anyone volunteer to give a try? 2. How important does the possible future extension play in this? What considerations should be put in this? 3. If there could be future calculus of operators, would we now favor (*)= or (*=) for augmented assignment? These questions come up because this is clear a new type of language structure, even though it only contains one or two characters at the moment. We might be opening a whole can of worms here. I have no idea of the future perspective of the acceptance. Are we asking too much, or are we trying to be as consistant as possible, or both? Perhaps someone else need to step up to take the lead in this discussion. > The .* style operators merge with the surrounding expression in a way >that leads to me confusing whether they are interpreted with their normal >meaning. The braced operator sequences like (*) merge together into one >visual entity. When encountered by someone for the first time, its fairly >obvious that they mean something new and not just a weird way of spelling a >current operation. > > The braced operators give a reasonable basis for future expansion >although it looks like you have used up all the best ones already. If this >is going to be used for future expansion, I'd like to see precedence looked >at closely now with all braced operators at lowest precedence. > > It may help to write a short demonstration script that intensively uses >matrix operations to show what code based on these proposals will look like. This would be extremely helpful. Huaiyu From glt at equod.com Wed Jul 19 15:02:36 2000 From: glt at equod.com (Gilles Lenfant) Date: Wed, 19 Jul 2000 21:02:36 +0200 Subject: a more comprehensive distribution? References: <8l4act$loo$1@news.kth.se> <3975D40E.E478EF44@schneider-kamp.de> Message-ID: <3975FB4C.8145B017@equod.com> A stuff for python like "rpm/rpmfind" is for Linux would be perfect to me. A quick reminder for the Windows users with rpm/rpmfind: * records a database about what's installed in your machine (package, version, dependances with other packages) * can browse in a dedicated public server for available packages (and of course download/install from this server) * warns obsolete versions of your packages. * warns dependancies issues with other packages. * build HTML report of your local packages library. And lots of other useful features. A Tkinter based interface above this would be a little more than perfect. Guido, do you hear me ? From jar at mminternet.com Sun Jul 30 00:33:29 2000 From: jar at mminternet.com (jim roush) Date: Sat, 29 Jul 2000 21:33:29 -0700 Subject: Newbie question regarding .readline() Message-ID: I have the following snippet of code causing me problems def process_free_category(cat_title, filename, start_anchor_tag): PK_INFILE = open(filename, 'r') PKFRESHOUT.write('
' + cat_title + '

\n') # Find beginning of section for line in PK_INFILE.readline(): print line if string.find(line, start_anchor_tag) > -1: break print line the problem is, line is only one character instead of an entire line. I used those print statements to verify this. It's as if I used .read() instead. If I use .readlines() instead, it reads multiple lines like it should. What gives? jar at mminternet.com James A Roush From bjorn at roguewave.com.bbs Sun Jul 16 13:20:01 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 16 Jul 2000 17:20:01 GMT Subject: Discussion: Introducing new operators for matrix computation -gen Message-ID: <3bQU41$kOG@openbazaar.net> Andrew Henshaw wrote: > Gregory Lielens wrote: > >John Lull wrote: > ...snip... > > >> I'm don't think this is quite fair. You could just as easily write: > >> b = rDiv(X, y) >> if you simply had an appropriate rDiv() function. > ..snip.. > >Indeed, but it is the old choice between functional/operator notation... > >For example, the second expression, b = (X'*X)\(X'*y), would be in > >functional notation > >something like b=rDiv(Mul(X.T(),X),Mul(X.T(),y)) > >This is ok, but imho far more error prone than operator notation, > >because > >- all linear algebra textbooks present expressions with operator > >notation > >- the operator notation is more natural to almost everybody when dealing > >with arithmetic > > > I wonder if some of these problems could be approached in a more general > manner. What if Python could support the definition of operators in the > same manner as functions? If that were the case then something like: > > opr rDiv(X, y): > > would define a new operator function that would work like: > > b = X rDiv y > > The big advantage would be that special purpose grammars could be easily > imported. The core language could be kept as simple as possible, but still > be extensible in a way that matters to a lot of people. > > I suspect that whitespace would be required around these new 'operators', > although many people already do that with regular operators. Also, I'm not > sure how you'd specify an operator that wasn't valid as a function name, but > I can think of possibilities. Prolog does this (you'll of course have to specify the precedence of the operator also, and to solve the current perceived problem probably their associativity too...) It's something that works relatively well in Prolog, but then Prolog doesn't have namespaces etc... If you think you can solve those problems, I would encourage you to try to implement it and try your solution in a couple of different domains (matrix-, db-, xml-, string- processing?) It could be useful, and if it is, then we can discuss whether it should be added to the core. Thankfully, Python doesn't add new ideas to the core before they have been tried out sufficiently first. C++ did, and has ended up working around design problems (how many people really know how Koenig lookup works...?) python-the-lean-mean-fighting-machine-with-batteries-included'ly y'rs -- bjorn From jessw at loop.com Mon Jul 10 13:24:45 2000 From: jessw at loop.com (Jesse W) Date: Mon, 10 Jul 2000 17:24:45 +0000 Subject: Can anyone hear me? (was Solution to IDLE and Tkinter problems) Message-ID: <200007110027.RAA16246@stevie.loop.com> Did anyone get my last message? Is the problem I posted about already dealt with or somehow taboo? Does anyone know why I got no response? If I am doing something _really_ stupid, would someone please tell me at least? I apolgize if this is considered a useless and pointless message, but I don't know what else to do! Thank you for your time, Jesse Weinstein From jbrennan at linuxfreak.com.bbs Mon Jul 17 01:40:00 2000 From: jbrennan at linuxfreak.com.bbs (jbrennan at linuxfreak.com.bbs) Date: 17 Jul 2000 05:40:00 GMT Subject: Python VM on a Chip? Message-ID: <3bR1H0$iTv@openbazaar.net> In the past I have read about companies implementing the Java VM on a chip. Vendors such as Rockwell have been working with Sun to make it possible to implement embedded Java applications that run a hundred times faster then the software VM. Has anyone ever considered doing the same kind of thing with the Python VM? Is it even possible since the data types of Python are late binding? Does anyone know of a commercial or university project that is implementing a Python VM using ASICs or FPGAs? Thanks, Jim Brennan jbrennan at linuxfreak.com From jesse at multimediacollective.com Mon Jul 31 17:41:43 2000 From: jesse at multimediacollective.com (jesse at multimediacollective.com) Date: Mon, 31 Jul 2000 21:41:43 -0000 Subject: removing characters from a string? Message-ID: <8m4rqn+jpg0@eGroups.com> say I had a string. this_string = "jesse at multimediacollective.com" """and I wanted to get rid of the @, how would I do that? This process has to be efficent for removing large quantities of special characters, such as <,>,#,%,* etc, from the same string. Any advice would be very helpful. Thanks in advance, Jesse. From shikida at my-deja.com Mon Jul 10 19:14:35 2000 From: shikida at my-deja.com (shikida at my-deja.com) Date: Mon, 10 Jul 2000 23:14:35 GMT Subject: zope and UNIX permissions Message-ID: <8kdlcc$epr$1@nnrp1.deja.com> We tried to install zope using its tar.gz file and it created a lot of files with non-default users and with very permissive permissions on a linux box (like 777 permissions for many files). This is a HUGE security hole. We couldn't install the RPMs files on our webserver. Is there any decent zope source code distribution? thanks in advance K. Sent via Deja.com http://www.deja.com/ Before you buy. From kirill at xyz.donetsk.ua Thu Jul 20 05:43:05 2000 From: kirill at xyz.donetsk.ua (Kirill Simonov) Date: Thu, 20 Jul 2000 12:43:05 +0300 Subject: iterating over lines in a file In-Reply-To: ; from no@bo.dy on Wed, Jul 19, 2000 at 07:14:15PM -0500 References: Message-ID: <20000720124305.A1220@xyz.donetsk.ua> On Wed, Jul 19, 2000 at 07:14:15PM -0500, nobody wrote: > while (line = ) { block; } The easiest way: for line in file.readlines(): block -- Kirill From hgg9140 at seanet.com Wed Jul 19 19:13:57 2000 From: hgg9140 at seanet.com (Harry George) Date: 19 Jul 2000 16:13:57 -0700 Subject: Python-ese for indexing a list within a class References: <8l4v6k$rd4$1@news.rchland.ibm.com> Message-ID: How are you choosing to use a vs b ...? I generally need to do this with named objects so I use a map: class C: def __init__(self): counters={} def someFunction(self): # some code #---discover we need a counter for x--- #---where x is "a", or "b", or whatever--- cnt=self.counters if not cnt.get(x,0): cnt[x]=0 cnt[x]=cnt[x]+1 "Larry Whitley" writes: > Is the following the appropriate Python-ese for indexing a list within a > class? > > # the following is defined outside of either class or function > nCounters = 4 > a,b,c,d = range(nCounters) > > # now define the class > class C: > def __init__(self): > cnt = [0] * nCounters > def someFunction(self): > # some code > self.cnt[a] = self.cnt[a] + 1 # <<< here's the statement in question > # some more code > > I'm trying to avoid the considerably ugly: > > self.cnt[self.a] = self.cnt[self.a] + 1 > > The code seems to work ok but is this the right/best/prettiest/(etc) way to > go about it? > > Larry > > -- Harry George hgg9140 at seanet.com From andymac at bullseye.apana.org.au Tue Jul 18 07:17:53 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 18 Jul 2000 21:17:53 +1000 (EST) Subject: nis module error In-Reply-To: <39736BCB.626BD669@hpbs1711.boi.hp.com> Message-ID: [sent to both originator & python-list] On Mon, 17 Jul 2000, Jacob Hunt wrote: > Traceback (innermost last): > File "", line 1, in ? > ImportError: /usr/lib/python1.5/lib-dynload/nismodule.so: undefined > symbol: yperr_string > > what does this mean? How can I correct the problem or is there a way > around it. nismodule.so wasn't linked with the library containing the "yperr_string" symbol, or the dynamic linker can't find the library containing it. you'll need to find out which library on your system contains this symbol and make sure that ld.conf or LD_LIBRARY_PATH contain the directory containing this library. if this still doesn't fix the problem, you'll need to rebuild the nis module (from source) with the correct library specifications - the setup file in the modules directory of the Python source will need to be doctored to add the necessary library reference (see the Tkinter section of that file for ideas on how to do this). -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From aahz at netcom.com Sat Jul 22 00:06:03 2000 From: aahz at netcom.com (Aahz Maruch) Date: 22 Jul 2000 04:06:03 GMT Subject: Discussion: new operators for numerical computation References: <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: <8lb6jb$vj9$1@slb6.atl.mindspring.net> In article , Ben Caradoc-Davies wrote: > >The fact that APL has been mentioned in this thread is a bad, *bad* sign. Yeah, that's my feeling, too. It's not entirely clear to me why we can't use some kind of string-based expression mechanism instead of adding all this at the language level. Python's brilliance is its *clean* syntax. Why are we mucking with the core language for this? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From athos84 at my-deja.com Mon Jul 31 11:39:39 2000 From: athos84 at my-deja.com (Mike Olson) Date: Mon, 31 Jul 2000 15:39:39 GMT Subject: Automatic naming Message-ID: <8m46jq$rj$1@nnrp1.deja.com> I am trying to create a window using Tkinter that has a variable number of Entry fields, 1 for each item in a list. My script looks something like this: cnt = 0 for x in list: label = Label(window, text=x) entry = Entry(window) label.grid(row=cnt) entry.grid(row=cnt, column=1) cnt = cnt + 1 The window looks fine, but my problem is that I have no way of using .get() commands on any of the entry widgets except for the last one. Is there a way of automatically naming widgets so that I can use them all, or of adding tags or something? If not, does anyone have a suggestion for a more efficient (or functional) way of doing what I'm doing? Any help will be greatly appreciated. -- Mike Olson Provis Corporation Columbia Heights, MN Sent via Deja.com http://www.deja.com/ Before you buy. From richard at cogsci.ed.ac.uk Fri Jul 14 14:09:08 2000 From: richard at cogsci.ed.ac.uk (Richard Tobin) Date: 14 Jul 2000 18:09:08 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> Message-ID: <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> In article <8knhql$lpi$1 at nnrp1.deja.com>, wrote: > It's explicitly provided in Python as well. No, that's just the point - it's not explicitly provided; instead the implementation is exposed. You can assign to the __class__ slot, you can initialise any new slots, and delete any that the new class doesn't have. But does anything say "yes, this is all you need to do, and it will work in all implementations"? Apparently not. > Changing the methods of the instance also counts as >a sneaky don't-do-that. I thought you'd say that :-) > Whatever it is you're trying to >do there's a way to do it in legitimate Python without >this sort of thing. Ok, I trying to directly model a rather abstract specification - the XML Infoset - as Python objects. I then want to to perform the action of XML Schema validation on this modelled infoset, which is defined to add various properties to the infoset. Various methods need to be changed to take account of the new properties. It is thus natural for the class of the objects after validation to be a subclass of what they were before. Now obviously it can be done in many ways as a programming task, and others might be better in engineering terms. One might produce a new infoset containing objects from the subclasses. But to directly model the specification of the validation process, changing the classes, or adding slots and changing methods, seems the natural way. -- Richard -- Spam filter: to mail me from a .com/.net site, put my surname in the headers. "The Internet is really just a series of bottlenecks joined by high speed networks." - Sam Wilson From krussell4 at home.com Wed Jul 12 19:04:59 2000 From: krussell4 at home.com (Kevin Russell) Date: Wed, 12 Jul 2000 23:04:59 GMT Subject: Sound module question References: <396BBA07.E844152@bresnanlink.net> <396BC08E.A3C036A4@pehr.net> <396C18D8.EC4CC59@bresnanlink.net> Message-ID: <396CF9BD.B8088DAF@home.com> In addition to the suggestions already given, you might think about Snack: http://www.speech.kth.se/snack/ It's really a Tcl extension, but it should be possible to pass commands and info back and forth between Tcl and Python using the same tricks that Tkinter does. -- Kevin From paul at prescod.net.bbs Mon Jul 17 17:40:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 21:40:02 GMT Subject: Parser project Message-ID: <3bRQH2$l4T@openbazaar.net> Huaiyu Zhu wrote: > > ... > > This is a good idea, although MatPy could not wait for it to happen, and I > do not foresee much additional syntax being requested. For the current > matrix issue, a limited parser might be easier and more useful. Not as much easier as you think. And anyhow, my proposal was to make a module useful to Python programmers from a variety of domains. That seems more likely than the infix operators which are not going to be as widely popular. For instance, someone wanting to experiment with list comprehensions or embedded SQL could do so. > I'm not sure if it can be made as easy as > > import NewOperator > NewOperator.define(".+", "__dotadd__") > class A: def __dotadd__(self, other) ... > a=A(); b=A() > a.+b > NewOperator.define("compares", "__cmp__") > ------> Exception: "compares" contains characters not allowed in operator. No, it can't be made that easy using traditional parser/compiler techniques. Using non-standard techniques, yes it could be but I'm not sure if someone out there is interested enough to do it. If you want to get started quickly, I would suggest you download all of the Python parser toolkits and look for those that have Python lexers/parsers built in. Choose one and use it. You may already be 80% of the way there. You might want to ask around for help in the compiler sig mailing list: http://www.python.org/sigs/compiler-sig/ Here is a list of parsing tools I collected once: PyLR For efficient
parsers in python Includes lexer and parser Supports LR(1) and LALR(1) By Scott Cotton PyLR example

expression: expression
		PLUS term (addfunc)
		| term;
term: term
	TIMES factor (timesfunc)
	| factor;
factor: LPAREN expression RPAREN (parenfunc)
	| INT;
kwParsing by Aaron Watters
GRAMMARSTRING ="""
Value ::
 @R SetqRule :: Value >> ( setq var Value )
 @R ListRule :: Value >> ( ListTail
 @R TailFull :: ListTail >> Value ListTail
 @R TailEmpty :: ListTail >> )
 @R Varrule :: Value >> var
 @R Intrule :: Value >> int
 @R Strrule :: Value >> str
 @R PrintRule :: Value >> ( print Value )
"""
Simpleparse Built on top of mxTextTools Generates tables that drive mxTextTools Reputed to be very fast by Michael Fletcher Gentle introduction to more complex mxTextTools package Simpleparse example
file := [ \t\n]*, section+
section := '[',identifier,']', ts,'\n', body
body := statement*
statement := (ts,';',comment,'\n')/equality/nullline
nullline := ts,'\n'
ts := [ \t]*

...
YAPPS Yet Another Python Parser system. Simple, easy to use Generates human-readable parsers Recursive descent Not as fast, powerful or flexible as others Supports LL(1) Spark Scanning, Parsing, and Rewriting Kit John Aycock Very powerful, easy, slow
def p_ifelse_stmt(self, args):
'''
stmt ::=
  IF expr
  THEN stmt
  ELSE stmt
'''
    somePythonCode()
-- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From boncelet at eecis.udel.edu.bbs Mon Jul 17 13:20:01 2000 From: boncelet at eecis.udel.edu.bbs (boncelet at eecis.udel.edu.bbs) Date: 17 Jul 2000 17:20:01 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators forma Message-ID: <3bRJS1$iD_@openbazaar.net> --------------8E279F1082DE31814A452DAA Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit (Huaiyu Zhu wrote a proposal for adding special linear algebra operator to Python) This proposal has been dismissed by many on this list (my paraphrasing) "because we don't want to pollute Python with new symbols/syntax for just one problem domain." Some have dismissed linear algebra as a small domain at that. Let's get some facts (yes, I know we are not supposed to let facts interfere with our arguments on usenet): 1. Amazon.com lists 117 book matches for "python", but most of these are for the snake or Monte. A quick perusal indicates there are 13 books currently available and another 7 on order for language. Amazon lists 179 matches for "matlab", of which 81 are currently available and 61 on order. Verdict: there are approximately 7 times as many Matlab books as Python books. 2. Alta Vista finds 4492 pages for "python language", and 489540 for "matlab". Even the one word "python" search only finds 412030 pages (which of course includes many references to the comedy troupe and the snake). Alltheweb finds 53378 for "python language" and 53368 for "python program"; it finds 156525 for "matlab". Verdict: There are 3-100 times as many web pages mentioning "matlab" as "python language" or "python program". 3. At my university (which I assume is pretty typical), all the engineering students use Matlab at some point in their studies. Most (perhaps all) of the math, physics, and chemistry students use Matlab at some point. Many of our ECE graduate students use Matlab extensively in doing their dissertation research. AFAIK, I am the only person using python for anything. (I am sure there are others, but I don't know of anyone and there are no courses using python.) Vendict: at my university, Matlab is tens to hundreds of times more popular than python. Conclusion: please don't dismiss linear algebra as "just another problem domain". If python incorporated numpy into its core and added some support for linear algebra syntax, it could easily double, triple, or more in popularity. Remember, these people spend real money on Matlab. Even the student edition is about $100. Now to the specifics of the proposal: I'd like to see "@" for matrix mulitplication and "*" for element-wise multiplication. This preserves compatibility with numpy, although breaks it with the MatPy package. It is more important, IMHO, to preserve compatibility with the existing python numerical facilities than with Matlab. Any user switching over will have to learn a lot of new things anyway. Distinguishing @ and * should be easy enough. Charlie Boncelet -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ --------------8E279F1082DE31814A452DAA Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit (Huaiyu Zhu wrote a proposal for adding special linear algebra operator to Python)

This proposal has been dismissed by many on this list (my paraphrasing)
"because we don't want to pollute Python with new symbols/syntax
for just one problem domain."  Some have dismissed linear algebra
as a small domain at that.

Let's get some facts (yes, I know we are not supposed to let facts
interfere with our arguments on usenet):

1. Amazon.com lists 117 book matches for "python", but most of these
are for the snake or Monte.  A quick perusal indicates there are 13 books
currently available and another 7 on order for language.  Amazon lists
179 matches for "matlab", of which 81 are currently available and 61 on order.

Verdict:  there are approximately 7 times as many Matlab books as
Python books.

2. Alta Vista finds 4492 pages for "python language",  and 489540 for
"matlab".  Even the one word "python" search only finds 412030 pages
(which of course includes many references to the comedy troupe
and the snake).

Alltheweb finds 53378 for "python language" and 53368 for "python
program"; it finds 156525 for "matlab".

Verdict: There are 3-100 times as many web pages mentioning "matlab"
as "python language"  or "python program".

3. At my university (which I assume is pretty typical), all the engineering
students use Matlab at some point in their studies.  Most (perhaps all)
of the math, physics, and chemistry students use Matlab at some point.
Many of our ECE graduate students use Matlab extensively in doing
their dissertation research.

AFAIK, I am the only person using python for anything.  (I am sure
there are others, but I don't know of anyone and there are no courses using python.)

Vendict: at my university, Matlab is tens to hundreds of times more
popular than python.

Conclusion: please don't dismiss linear algebra as "just another
problem domain".  If python incorporated numpy into its core
and added some support for linear algebra syntax, it could easily
double, triple, or more in popularity.

Remember, these people spend real money on Matlab.  Even the
student edition is about $100.

Now to the specifics of the proposal: I'd like to see "@" for matrix
mulitplication and "*" for element-wise multiplication.  This preserves
compatibility with numpy, although breaks it with the MatPy package.
It is more important, IMHO, to preserve compatibility with the existing
python numerical facilities than with Matlab.  Any user switching over
will have to learn a lot of new things anyway.  Distinguishing @ and *
should be easy enough.

    Charlie Boncelet

-- 
Charles Boncelet                              302-831-8008
Dept of Electrical and Computer Engineering   302-831-4316 (fax)
University of Delaware                        boncelet at eecis.udel.edu
http://www.eecis.udel.edu/~boncelet/
  --------------8E279F1082DE31814A452DAA-- From bwarsaw at beopen.com Wed Jul 19 08:50:56 2000 From: bwarsaw at beopen.com (Barry A. Warsaw) Date: Wed, 19 Jul 2000 08:50:56 -0400 (EDT) Subject: [Python-Dev] RE: Discussion: Introducing new operators for matrix computation References: Message-ID: <14709.42032.689117.684055@anthem.concentric.net> >>>>> "TP" == Tim Peters writes: TP> + There *must* be a PEP for this. There already is: PEP 211, Adding New Operators to Python. And it's been assigned to Greg Wilson, although he may want to re-assign it. It's currently just boilerplate. -Barry From pinard at iro.umontreal.ca Fri Jul 7 08:20:52 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 07 Jul 2000 08:20:52 -0400 Subject: Python bug reporting [was: Re: readline.c & more] In-Reply-To: Jeremy Hylton's message of "06 Jul 2000 22:40:19 EDT" References: Message-ID: [Jeremy Hylton] > I agree that the system [of necessarily using the Web to report Python > bugs, instead of the usual Python bug reporting email address] isn't > great, but at least it provides us with a mechanism to track patches and > assign responsibility for them. The old email approach didn't have either > feature, which made it much harder for the people catching the patches. There are plenty of users, and a much smaller bunch of maintainers. It seems more fit to me to adapt to the plenty of users, than force all of them into the methods of a few. This is not far from haughty maintenance. Besides, if the new mechanics and bug tracking systems did not even care to provide some interface or tools, so maintainers can receive and sort email into it, then that system is also haughty and aggressive at imposing itself. Do not misread me, I'm a maintainer myself. But I do care for my users, I do not make things hard for them to communicate with me, and never will. My little own anal methods with reports, I do not _impose_ them around. > You might suggestion an email interface in the SourceForge feature > request forum: https://sourceforge.net/forum/?group_id=1 Are you serious? You would force me to use a Web forum to discuss that Web is inappropriate? This isn't real, I am dreaming. :-( Please consider Web as a possible service, not as an inescapable religion. email is still ubiquitous, and very usable. If your bug tracking system cannot help you handling email, this should be the problem of those having written or selected it, not mine, and surely not mine to correct. P.S. - I nearly missed your message, it had no quote, and the subject was improper. Web abuse destroys one's elementary communication skills :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From peter at schneider-kamp.de Wed Jul 19 15:20:50 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 19:20:50 +0000 Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3975E070.308511F4@roguewave.com> Message-ID: <3975FF92.1B031588@schneider-kamp.de> Okay, assume you call it "merge". What will somebody who doesn't know what it's for think it does? merge([1, 2, 3], [4, 5, 6]) == [1, 4, 2, 5, 3, 6] or merge([1, 2, 3], [4, 5, 6]) == [(1, 4), (2 ,5), (3, 6)]? Where's your problem with zip? Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From obijohn at my-deja.com Thu Jul 27 16:10:21 2000 From: obijohn at my-deja.com (ObiJohn) Date: Thu, 27 Jul 2000 20:10:21 GMT Subject: The State of Python References: Message-ID: <8lq4v9$3fs$1@nnrp1.deja.com> In article , "Tim Peters" wrote: >[snip] > I'm not a lawyer either (as you well know ), but at least in America > you hold copyright on your works whether or not you state it explicitly. > Curiously, the CNRI disclaimer form didn't say anything about copyright. > I *am* a lawyer and I think a distinction needs to be made (maybe obviously) between a "license" and a "copyright". A copyright, as the name implies, gives the author the _right_ to control the _copy_ of his work. If this control is extended to others, it is done so in the form of a license. Contrary to what some may think, placing a work in the public domain is not issuing a "free-for-all" license; it completely removes the copyright. Thereafter, not even the original author can claim to hold the copyright or any form of license. However, a license on a copyrighted work may allow unrestricted use of the work and still retain the copyright. This is important because the holder of the copyright may later change the license. There is no "magic" in making a license. Indeed the Python 1.5.2 is a valid form of license. What the CNRI lawyers mean is that there are too many holes in it for a lawyer's taste. Lawyers *hate* short, consise contracts and licenses simply because it is so easy to make them appear to contain loopholes, even if the author did not intend it. Efforts to close those loopholes results in licenses like the GPL. Unfortunately, lawyers many times introduce more holes than they plug, and other lawyers step in to plug those... just look at the GPL/QT wrangling. Is there a simple answer? Not when the lawyers are involed! I would be greatly surprised if they were satisfied in 2 days. -- John Stoneham, Beaumont, Texas Life is too short: Program with Python! Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sun Jul 23 02:34:54 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 23 Jul 2000 01:34:54 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> Message-ID: <397A920E.A16E7B8A@prescod.net> Rainer Deyke wrote: > > This would allow constructs such as: > > A(.init)B > > In other words, it would turn all existing __magic__ functions into > operators. Not a good idea IMO. Easily fixed if we map ".foo" to "__operator_foo__" and "__roperator_foo__". I strongly prefer name-based proposals to cryptic symbols. I would support A(.mm)B for matrix multiply and A(.em)B for element multiply, A(.slv)B for solving and so forth. I can even imagine where this would be useful in other domains. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From hopper at omnifarious.mn.org Tue Jul 18 19:51:55 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Tue, 18 Jul 2000 17:51:55 -0600 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <3974C185.E39E082E@prescod.net> Message-ID: In article <3974C185.E39E082E at prescod.net>, Paul Prescod wrote: > Eric Hopper wrote: >> >> ... >> >> Oh, yes. Inheritance by mysteriously coiniciding method names. How >> fun. > > It has nothing to do with inheritance. We are discussing genericity, not > inheritance. Some languages can only do genericity through inheritance > but this is rare in modern languages. OK, genericity. I call generic programming 'inheritance for the lazy'. It's the thing I most dislike about STL. No requirement at all the you specify your interface anywhere, or make a statement about your class conforming to it. It just mysteriously calls these methods that have these special names and hopes for the best. Of the modern languages, the one I can think of right offhand is Java. And that's something I actually like about it. > It is not a big deal. You aren't the first person to write a large > project in Python. You are of course free to do what you want but I'll > caution you that paranoid type checking is typically a phase that Python > programmers go through. > > You'll notice that the standard library does not use type checking > functions in most places. In a lot of ways the error messages are *less > confusing*. When I get an error message: "read method not defined" then > I know I need to define a "read" method. So, what class do you need to define a read method for? Where did that object get passed in? What if the read method is only called in some odd circumstance that manages to excape anyone's notice for years? > This is better than having a hideously complex type inheritance > hierarchy in order to enforce nothing more than that the object needs a > read method. That way lies madness: > > http://java.sun.com/products/jdk/1.1/docs/api/Package-java.io.html This doesn't look too bad, though I think it's a little ill-designed. > Type checking is the most major difference between Java and Python. If I > liked everything about Java except its dynamic typing (which is, IMO, > its best feature) I would just use Java like everyone else. > Nevertheless, if you prefer Python with roll-your-own type checking to > Java, more power to you. It's a big tent. I prefer almost anything to Java because you can't get a standard Java implementation anywhere. Sun's got the standard all locked up. I also dislike the incredibly heavy runtime environment that Java comes with, and the fact that it's missing any I/O multiplexing mechanism, and so you're forced to have threads. Have you ever tried to write something that dealt with 500 clients using a reader and writer thread for each? I thought not. Anyway, this isn't a Java bashing forum. :-) -- Eric Hopper (hopper at omnifarious.mn.org) (http://www.omnifarious.org/~hopper) From olivierS.dagenaisP at canadaA.comM.bbs Sat Jul 15 00:40:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 15 Jul 2000 04:40:02 GMT Subject: Why make a language case sensitive? Message-ID: <3bPKc2$mjh@openbazaar.net> As a VB freak (or ex-thereof), I need to point out that the VB IDE will attempt to make all variables and keywords use the same case. So, for example, "if" is always 'converted' as "If" and if you declare a variable as such: Dim m_Spam As Long (which, BTW, the IDE would have 'fixed' the words 'Dim', 'As' and 'Long') and then you need to refer to m_Spam, you can type it without any capitals, and when you move the cursor to another line, the IDE will look up the declaration and match the case of the new instance of the variable with that of the declaration... For example, I type: m_spam = M_SPAM + 42 and it becomes: m_Spam = m_Spam + 42 ...which keeps the readability. (doesn't it?) Also, now that I have this line of code, if I go back to the declaration and change 'm_Spam' to 'm_SpAm', all the references 'm_Spam' will now read 'm_SpAm'... So, I can't say that I agree with you when you say that forcing the user to type the name correctly will improve readability, especially in the case of Pyton when a mis-typed variable name results in a new binding being created, and not a compile-time error, like in C. I once read an "article" (more like a joke) on how to write really bad (obfuscated) C code, and one of the "tips" was to mix the cases of the letters making up variable names.... If you have a pre-processor or a powerful IDE (more like a compiler built into an IDE), you can achieve readability that is customized to the person reading and making a change in the "readability" of a name does not require doing a [case-sensitive] find/replace. Let the user have only to remember the sequence of characters and let the computer find out (in a previous declaration or usage) how they should be capitalized. I love Python. I hope case sensitivity doesn't stay around for too long. All it *really* allows you to have is something like a previous post, where a file requires a close method with a small C and for a DB connection, a close method with a capital C: aFile.close() aConnection.Close() ...which just seems pretty silly to me, especially if you're someone trying to use code from two different sources, and they have adopt similar conventions, except the case is different. People just don't think like computers: 'a' and 'A' are the same letter, and you bring up a good example in your last paragaph... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Anders Eggers-Krag" wrote in message news:jbPb5.1245$bb.28195 at news101.telia.com... > I would say that it improves syntax consequense, leading to more readable > code > for others, you are never in doubt about what to look for when looking for a > keyword, > > in VB you might look for IF, If or if, and they look very different, and it > becomes a lot harder > to read somebody elses code. > > the case insensitivity is nice when I am the only one to read my code as I > could then choose my > own obscure notation such as mYmetOd() and keep it consequent writing dEf, > claSs, If eTc. > wheras case sensitivity makes it more natural to keep a more sensitive > manner such as myMethod() > MyMethod() or my_method() throughout that everyone can agree on, I believe > that case sensitivity > leads to more uniform code, that again makes it easier to read your > collegues code. And i think it should > seem natural to everyone, after all books are written in case sensitive... > you can't write: "i Am the wisEst > One of aLl." and be taken seriously > > But it depends on which kind of access is needed to the system ie it would > be dreadfull if DNS > or SMTP servers were case sensitive and user enters MicroSoft.com and gets > nowhere because > he should have written microsoft.com. > > > -- > Anders Eggers - Krag > > > "Peter Timaratz" wrote in message > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > I can't think of any advantages to a case sensitive language. Python is a > > very well-designed language though, so I imagine there is a good reason > that > > it is case sensitive. So what are the advantages of a case sensitive > > language? > > > > > > From grey at despair.rpglink.com Fri Jul 28 11:42:01 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:42:01 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <8ls1bb017he@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 15:16:29 +0200, Alex Martelli wrote: >Right, make it a list. I.e., instead of > a=None >start out with > a=[] >and you're done. What's hard about this? And if a can also be a string? >Clumsy! Just set a=[] once, outside of the loop -- how much easier can it >get? Uhm, if you need to ask that, then you haven't read this thread. ;) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From wware at world.std.com Mon Jul 31 14:44:39 2000 From: wware at world.std.com (Will Ware) Date: Mon, 31 Jul 2000 18:44:39 GMT Subject: [4th Draft] Open Letter to CNRI: Request for clarification References: <3985969C.48222D21@nowonder.de> Message-ID: You can add my name to the signature list whether or not you take my suggestions. The later drafts are big improvements, primarily in toning down the emotional language of the first draft. Here are some thoughts on this matter. For reference, CNRI's home page is http://www.cnri.reston.va.us/ 1. CNRI legally owns Python, up to version 1.6. You and I don't have any legal rights of any kind in this matter. The user community does not collectively have any legal rights in this matter. We are extremely dependent upon CNRI's good will. 2. CNRI does not need the existing Python user community. But it sounds like they may have future plans for Python. We don't know what those plans are, but CNRI would probably benefit from a cooperative friendly rapport with the user community, given the amount of expertise floating around out here. CNRI may not yet be aware of the size and quality of the user community, so they may be inclined to dismiss the benefits of cooperation. 3. No matter what, we should not alienate or bash CNRI. It's easy to imagine that every large organization with lawyers is another Microsoft, but we only hurt ourselves by establishing an atmosphere of mistrust or suspicion. 4. CNRI may wish to keep secrets, for business reasons or any other reason, and they are under no obligation to disclose those reasons to the user community. This is standard business practice throughout the world. There is nothing to be gained by complaining to them about it. > We are especially interested in the underlying intention of this > change. So we request a plain-English, non-legalese statement > regarding the purpose of that change and the ways in which it > affects Python's use. I see what you're looking for here, and agree that if CNRI discloses (at least partially) their thoughts and plans for Python, it would be a huge step to establishing a cooperative rapport with the community. I'm concerned about the phrase "underlying intention", which hints that you think CNRI is currently being sneaky and hiding something from the user community. You might want to use a phrase like "overall intent", or simply "intent". If CNRI is not yet aware of the benefits of cooperating with the user community, then the best thing to accomplish with this sort of letter is to initiate that cooperation yourself. Remember, you are asking CNRI to do things that they have no legal obligation or business reason to do. You want to be as polite about all this as possible. They don't owe you or me or the user community anything. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From cjensen at bioeng.ucsd.edu Sat Jul 8 19:32:08 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Sat, 08 Jul 2000 16:32:08 -0700 Subject: Getting ip address and browser info Message-ID: <3967B9F8.1694E2F3@bioeng.ucsd.edu> Using python CGI how can I get the ip address and browser info of the requestion party? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From db3l at fitlinxx.com Wed Jul 5 22:36:40 2000 From: db3l at fitlinxx.com (David Bolen) Date: 05 Jul 2000 22:36:40 -0400 Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> <3QR85.42743$W35.928737@news20.bellglobal.com> Message-ID: "Olivier Dagenais" writes: > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > Are you sure you can concatenate a string to a time? The ctime() function in the time module returns a string, so it should be fine. The mixture of arguments to print (resulting in an intervening space) and concatenation (which won't) is something I'd probably replace with a single method of handling the values - e.g.: print "

This is San Diego.
Localtime is %s.

" % ctime(time()) might be a touch more readable - but I suppose that's subjective. -- -- 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 Fri Jul 21 22:53:52 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Sat, 22 Jul 2000 02:53:52 GMT Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: "Neil Hodgson" writes: > As one of the more reactionary Pythoneers with regard to syntax changes > and as someone who is unlikely to ever need to use the new operators, I say > the braced operators are the best. > > The .* style operators merge with the surrounding expression in a way > that leads to me confusing whether they are interpreted with their normal > meaning. The braced operator sequences like (*) merge together into one > visual entity. When encountered by someone for the first time, its fairly > obvious that they mean something new and not just a weird way of spelling a > current operation. > > The braced operators give a reasonable basis for future expansion > although it looks like you have used up all the best ones already. If this > is going to be used for future expansion, I'd like to see precedence looked > at closely now with all braced operators at lowest precedence. > > It may help to write a short demonstration script that intensively uses > matrix operations to show what code based on these proposals will look like. I agree. When I try to channel to the general Python user base on this issue (a dubious undertaking at best), I see @* operators coming in last, hands down (line noise, P***like), .* and (*) are much closer, but I see (*) coming out ahead due to the reasons that Neil mentions above. However, the fact that this result matches my preferences, while Huaiyu believes the reaction would be the opposite, in line with what seems to be his preferences is probably no accident. It's be easy to check though: as Neil suggests, we should write up the example scripts and then we could solicit opinions from the general python users as well as the numeric crowd. -tim From stephen at cerebralmaelstrom.com Sun Jul 16 02:30:48 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sun, 16 Jul 2000 06:30:48 GMT Subject: mxTextTools Question, Number 2 :) Message-ID: Okay. I've hit a snag. :) My prior question was on a 'better way', but with this one, i'm not sure if its even possible, exactly... Given a string: "This that" I want to capture everything up until the whitespace, so: ('Text',AllNotIn,whitespace) ...works, I suspose... but, here's the harder part. I want to ignore that whitespace as delimiter if the next character is a special So, "This &that" would end up capturing "This that". For the life of me I can't even fathom how to do the above! Well, I have a vague conception of what needs to be done but can't get it down on paper(Y'know what I mean. :)) Note that "This &that &are &very &nice &things" would end up with "This and that are very nice things" Thanks for any help anyone has. :) --Stephen From thomas at xs4all.net Thu Jul 6 09:53:20 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 15:53:20 +0200 Subject: getattr and setattr In-Reply-To: <8k1vqo$3e9$1@supernews.com>; from dale@out-think.NOSPAMco.uk on Thu, Jul 06, 2000 at 01:58:45PM +0100 References: <8k1vqo$3e9$1@supernews.com> Message-ID: <20000706155320.A25064@xs4all.nl> On Thu, Jul 06, 2000 at 01:58:45PM +0100, Dale Strickland-Clark wrote: > I'm still trying to get to grips with object programming in Python and > finding decent documentation unbelievably hard to track down. Hm, I've never needed much more than the documentation on www.python.org: the tutorial at first, then the language ref and the library ref ;) The only parts lacking in there are Tkinter, and some modules which aren't documented yet. > I eagerly set about the tutorial but found it was lacking in - well - just > about every department. The tutorial is more of an intro than a comprehensive educational track. Try the Language Reference or the Library Reference. If you don't care for the dull reference-style writing, try something like Learning Python, by O'Reilly, or one of the other online tutorials available (sorry, no URLs ;P) > I can't find any meat on __getattr__ and __setattr__. > These two special object functions don't seem to be very well documented > anywhere. (Please prove me wrong!) The language reference, section 3.3, 'Special Method Names': http://www.python.org/doc/ref/specialnames.html. To be more specific, section 3.3.2, 'Customizing attribute access'. > I can see how to handle a special case in __getattr__ with something like: > class wibble > def __getattr__(name): > if name == 'fred': > return 1 > else: > # what? > But what if it's not the special case(s). How do I return an arbitrary > attribute? Do I do something like: __getattr__ is only called if the attribute does *not* exist on the object. The reason is fairly simple: if it was called for every lookup, __getattr__ itself could never be looked up ! If you decide, in your __getatr__, that an attribute shouldn't exist, you should raise AttributeError. Don't do something like 'return 0' or you'll confuse all kinds of internal mechanisms, like those that lookup special method names ;) __setattr__, however, is called for every attempt at storing a value in an attribute, wether it exists or not. If you use __setattr__ and want to alter an attribute, you shouldn't do the obvious ! If you assign from inside __setattr__, __setattr__ is called again. Instead, you should modify self.__dict__. Section 3.3.2 explains all this, but in a bit less (and different ;) words. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jtoy at tcgfinancial.com Wed Jul 26 14:14:17 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Wed, 26 Jul 2000 14:14:17 -0400 Subject: problems with telnetlib Message-ID: <397F2A79.8B066DD3@tcgfinancial.com> I have tried several sample scripts including the oses at python.org, but I can't get any of the scripts to work properly. I have Python 1.5.2 on Linux 2.2.15. All I want to do is write a script that telnets into a machine and executes '/etc/email'. I can safely get up to the password prompt with: from telnetlib import Telnet tn = Telnet('192.168.0.254') tn.read_until('login: ') tn.write('someuser\n') tn.read_until('password: ') tn.write('password\n') tn.read_until('$ ') then I get error in line 224 read_very_lazy and in 300 read_very_lazy My exact login prompt after a normail telnetsession is: [user at localnet user]$ So reading until '$' should be write. Also, after I type tn.read_until('password: '), thr python prompt freezes for 30 seconds but continues normally after, why is this? -- Jason Toy toyboy at toy.eyep.net jtoy at tcgfinancial.com http://toy.eyep.net From dgoodger at bigfoot.com Sun Jul 30 01:16:20 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sun, 30 Jul 2000 01:16:20 -0400 Subject: Newbie question regarding .readline() In-Reply-To: References: Message-ID: on 2000-07-30 00:33, jim roush (jar at mminternet.com) wrote: > the problem is, line is only one character instead of an entire line. > I used those print statements to verify this. It's as if I used > .read() instead. If I use .readlines() instead, it reads multiple > lines like it should. > > What gives? When you use .readline(), it returns a single string, which can be interpreted as a sequence of 1-character strings. So "for line in PK_INFILE.readline()" gives you one character at a time from a single line (the first line only). Use "for line in PK_INFILE.readlines()" instead. Doing "for line in PK_INFILE.read()" would loop one character at a time, as in .readline(), except that it wouldn't stop at the end of the first line. Try putting your print statements outside the loop, with each of .read(), .readline(), and .readlines(), to see how they differ. ie: lines = PK_INFILE.readline() print lines for line in lines: etc. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From paul.robinson at quantisci.co.uk Wed Jul 5 10:52:47 2000 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Wed, 05 Jul 2000 15:52:47 +0100 Subject: "Write to a file" question please? References: Message-ID: <39634BBF.5EFFC493@quantisci.co.uk> Paul Jensen wrote: > I wanted to include a reference to the "%" operator in the online > docs, but interestingly couldn't find one. Anyone know offhand where > "%" is covered in the docs? http://www.python.org/doc/current/lib/typesseq-strings.html#SECTION004151000000000000000 [Thats library reference - 2.1.5.1 More String Operations] ...although if you didn't know what an "sprintf() format string" was then the probability of understanding this particular section is low. Paul ----------------------------------- Business Collaborator Team Enviros Software Solutions http://www.businesscollaborator.com ----------------------------------- From hinsen at cnrs-orleans.fr Mon Jul 24 11:07:52 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 24 Jul 2000 17:07:52 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: Robin Becker writes: > outer products (of vectors at least) are inner products with the second > vector being transposed. There is of course a general tensor notation, I think I understand what you mean, but then this statement is only true if you make a number of assumptions about vector representations and array matching rules, some of which are not true in NumPy. There are two schools of vector/matrix representations: 1) Vectors are rank-1 arrays, matrices are rank-2 arrays. Consequence: the transpose of a vector is the same vector. This is the approach used in NumPy as well as in APL and some other array languages. 2) Vectors exist in two varieties, "row" and "column" vectors. Row vectors are matrices with one row, and column vectors are matrices with one column. The transpose of a row vector is a column vector and vice versa. This is the approach used in MatLab, but not in NumPy. Of course any NumPy user is free to use Nx1 and 1xN-matrices to represent vectors, but this requires a lot of effort, because all vector-generating functions return rank-1 arrays. Your statement only makes sense in the second framework. > One thing I personally find very strange is that very few in this thread > seem to want to make the default multiplication operation * into the > default matrix multiply. I suppose early language designers have decided > this for all time so all choose the unusual element wise operation. The point is simply that NumPy uses this definition. Changing this would mean facing the opposition of all those who have significant amounts of NumPy code, and then there is probably no one left in favor of the operator proposition. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From cozald at hotmail.com Wed Jul 26 14:07:29 2000 From: cozald at hotmail.com (OC) Date: Wed, 26 Jul 2000 11:07:29 -0700 Subject: HELP!! system calls? Message-ID: <8lna31$hv8$1@nntp.itservices.ubc.ca> Hello People, I have a question about sys calls. I am trying to call a tcl script with the following command: os.system('tclsh80 file.tcl') and it gives me a permission denied error... I checked my files permission (I am using winNT) and they are fine. Anyone know why, or is there a better way to do it? I will greatly appreciate your help. Thanks in advance, Os From stuart at forddata.com Mon Jul 31 16:07:18 2000 From: stuart at forddata.com (Stuart Ford) Date: Mon, 31 Jul 2000 15:07:18 -0500 Subject: [5th Draft] Open Letter to CNRI: Request for clarification References: <3985D797.E5D2FC08@nowonder.de> <8m4kmu$1eq$1@kopp.stud.ntnu.no> Message-ID: <004601bffb2a$ef9179f0$788b18ac@boeckh.com> Sorry about the ME2 type message..... Could you please include me in the list to CNRI? I have spent the last 15 months trying to convince my company that Python is not only a viable solution for prototyping, but also a good language for general development. Any change in the license that changes our ability to release products using Python will set all my hard work back to stage one, plus make me look the fool for recomending the language in the first place. Stuart Ford Programmer/Analyst E.H. Boeckh Corporation From Cedric.Lefeuvre at tcomhp43.epfl.ch Wed Jul 26 04:39:39 2000 From: Cedric.Lefeuvre at tcomhp43.epfl.ch (Cedric Lefeuvre) Date: Wed, 26 Jul 2000 10:39:39 +0200 Subject: Radio Button group Message-ID: <397EA3CB.80316D6C@tcomhp43.epfl.ch> Is there someone who is able to create a radio button group with gtk -- C?dric Lefeuvre SUPAERO 2A-Stagiaire EPFL 0041 (0)21 693 26 16 http://eleves.supaero.fr/page-perso/promo_01/lefeuvre/ Fax: 0041 (0)21 693 26 83 _ _ _/_ _ ( (-(// /( From david_ullrich at my-deja.com Fri Jul 21 11:33:12 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Fri, 21 Jul 2000 15:33:12 GMT Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> Message-ID: <8l9qfp$gc6$1@nnrp1.deja.com> In article , ge at nowhere.none (Grant Edwards) wrote: > In article <8l76hm$pm9$1 at nnrp1.deja.com>, david_ullrich at my-deja.com wrote: > > > You can use the notation [2,3] to accomplish the same > >thing: it appears that if you use multiple indices they > >get passed as a tuple to __getitem__: > > You're not using multiple indices. > > You're using a single index whose value is the expression 2,3. > The expression 2,3 evaluates to a tuple, which is passed to > _getitem__, just as would the value of any other expression > used as an index. Ok, then I should revise what I said: You can use the notation [2,3] to accomplish the same thing. No doubt you're exactly right. But evidently there's a difference between [] indices and function parameters here: def hmm(x): return x print hmm(2,3) gives an error (hence my suspicion that someone might expect whatever[2,3] to give an error without trying it...) Why is "2,3" a single expression in whatever[2,3] but not in hmm(2,3)? > -- > Grant Edwards grante Yow! My Aunt MAUREEN was > at a military advisor to IKE & > visi.com TINA TURNER!! > Sent via Deja.com http://www.deja.com/ Before you buy. From nobody at nowhere.nohow Sun Jul 30 22:04:52 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Mon, 31 Jul 2000 02:04:52 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> <39846ECC.DF5FE175@san.rr.com> <39848FFE.948BF635@san.rr.com> Message-ID: In article <39848FFE.948BF635 at san.rr.com>, Courageous wrote: >> I'm sorry, but I have no idea if you're agreeing or disagreeing with me. >> Are you claiming that in real life the operations you can perform on/with a >> physical object are not determined by the type of the object? > >Not at all. I'm claiming that using real life operations was itself a >framing of the problem which isn't at all correct. Why not? >I'd argue that referring to a python variable as an arbitrary label to any >object is something which is quite intuitive to the novice programmer. OK. >These same novices will also intuitively understand that, in the situation >where the label is currently labelling an object of a particular type, >certain operations are inappropriate for that object. Which is exactly how >python behaves. I was pointing out that that is also how real-life physical objects behave, and you said (I thought) that "while I can't prove it, I do believe it's wrong." What is it you believe is wrong? -- Grant Edwards grante Yow! ... I don't like at FRANK SINATRA or his visi.com CHILDREN. From rumjuggler at cryptarchy.org Sun Jul 23 15:24:37 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 23 Jul 2000 19:24:37 GMT Subject: Looping on more than one list References: <3979C6F4.B1FF1800@atlsci.com> <8ldkf7$7km$1@nntp9.atl.mindspring.net> <397A616E.A9549B93@san.rr.com> <397B00F8.112E7A8D@prescod.net> Message-ID: On Sun, 23 Jul 2000 09:28:08 -0500, Paul Prescod wrote: >Courageous wrote: >> >> ... >> Perhaps this should be folded into the map function? >> Ala, lisp: >> >> (map nil #'(lambda (i j) ...) list-one list-two) > >It's part of the map function now. But nobody without a Lisp background >would think to look there. Or at least no one without a Lisp background who also didn't read the tutorial. -- Barnabas T. Rumjuggler Go, malign?d spread, Seek thy glory upon bread: Marmite, thus to fame! -- John Larkin, in apihna From MarkH at ActiveState.com Wed Jul 26 20:10:18 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 27 Jul 2000 00:10:18 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <397EDA34.9CFF2BF2@hursley.ibm.com> Message-ID: "Paul Duffin" wrote in message news:397EDA34.9CFF2BF2 at hursley.ibm.com... > How likely do you consider the possibility that Microsoft will change > the IL to allow the non-MS languages to be fully supported ? > > Unless the probability is VERY high Better than "VERY high" - they have already done it. MS have been _excellent_ at listening to 3rd party language feedback. For example, the functional language guys are very impressed that MS managed to get tail recursion instructions in the VM, in time for the PDC. No current or future MS languages have this requirement, and not even any of the (expected to be successful) commercial languages - it was done exclusively for the "little languages". To be quite honest, I have been constantly amazed at the effort MS are putting into 3rd party languages. It is more than mere hand-waving. > what is the point of doing this > at all as you would end up with a versions of the language which were > not compatible with the other versions. What is the point in making assumptions and statements like this? Try finding some facts before you attempt to invent more "evil empire evidence" to support your conspiracy theories. But to address your point: JPython is _not_ a perfect emulation of CPython, but it does allow you entry to the Java playground. Python .NET is similar - I don't expect anyone will use it when they want to work in an exclusively Python environment, just like almost no one uses JPython in that way now... Mark. From paul.magwene at yale.edu Fri Jul 28 05:07:53 2000 From: paul.magwene at yale.edu (Paul Magwene) Date: Fri, 28 Jul 2000 05:07:53 -0400 Subject: The State of Python References: Message-ID: <39814D69.ADD4FF0@yale.edu> Stian Husemoen wrote: > > Tim Peters wrote: > >The old Python license served it very well for a decade. > > It served CNRI very well.. as it made it possible for them to grab a hold of > everyones contribution and make it their own property. > > The hole driving force of a open source project is that people feel they own > a part of the code. If that's taken away, people will stop working on the > project. > > -- > > Stian Husemoen Did you bother to read the license before posting that? Sounds pretty BSDish too me. God forbid I have to include a copyright notice! --Paul Copyright notice ================ The Python source is copyrighted, but you can freely use and copy it as long as you don't change or remove the copyright notice: ---------------------------------------------------------------------- Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathematisch Centrum or CWI or Corporation for National Research Initiatives or CNRI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. While CWI is the initial source for this software, a modified version is made available by the Corporation for National Research Initiatives (CNRI) at the Internet address ftp://ftp.python.org. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ---------------------------------------------------------------------- -- Paul Magwene paul.magwene at yale.edu From aek at aek.dk.bbs Sun Jul 16 12:50:02 2000 From: aek at aek.dk.bbs (aek at aek.dk.bbs) Date: 16 Jul 2000 16:50:02 GMT Subject: Why make a language case sensitive? Message-ID: <3bQTEP$mfg@openbazaar.net> > VB's IDE is more than just a text editor. Every line is checked for = syntax > errors and I think compiled in the background. Of course no other = editor > could be as good, unless they also had access to the VB = compiler/debugger. It is a typical god side of an MS product, total integration with total = benfit, a pitty thought that the interface is less good than Borland's... > Using VC's autocompletion/intellisense, you can get similar results to = VB, > so something like this can be done for any language, that is correct, = but > not to the extent where the editor is also a compiler. It may not be = all > that hard to implement self-correction and syntax checking in Python, = since > we have "exec", but you are right: without variable declarations this = can > prove to be difficult. Maybe whoever implements a = self-correcting/syntax > checking IDE for Python should enfore a convention for "declaring" the > variables, without affecting the language itself. Something like = this, for > example: (I'm new to Python, so please excuse the big fat mistakes I = might > have made) Another solution is to be really smart and figure the flow of the = program and determine when a variable is first used and color that color1 and the = next time it is used it is colored color2... > Where the variables are declared in the form of a comment that starts = with > the letters "var" which, I think, is how JavaScript declares = variables, > isn't it? it is said the man who knew the language inside out :-) > So, by having a line at the beginning of a function (right after > the description line, which I hope I didn't screw up) indicating the = names > of the variables we intend to use, any name that isn't in that list = and > isn't in anything we imported would be highlighted as a mistake, and = if only > the case differs, the editor would make the case match the = declaration... The only problem is that it turns Python ugly... > Naming conventions are great, but also impossible to get everybody on = earth > to accept (and use) them, unless your language enforces it, primarily > because we tend to think different, the latter being a wonderful = thing! So > your naming convention is probably wonderful, but maybe also different = than > that of a third party, whose module you want to use.... I know it is a problem, I will however try to enforce it in our concern, = and one might design a devoloping tool that enforced a naming convention, that = could be dfined by the user. > Come to think of it, I don't think I have a problem with the language = being > case-sensitive. I have a problem with the editor making me think = about a > detail that I have come to not have to worry about by using VB. VB = may or > may not be case sensitive, I wouldn't really know, but what's great is = that > I don't have to worry about it. Once you get used to it it really isn't much of a worry there is only one thing in this world that makes me wonder: why are all = the beautiful languages run time parsed? (i here think primarily on Python and Java) --=20 Anders Eggers - Krag From andre at UltraShell.Net Mon Jul 31 19:46:38 2000 From: andre at UltraShell.Net (Andre van Straaten) Date: Mon, 31 Jul 2000 23:46:38 GMT Subject: Retrieving a query string from a

command References: <_Ghh5.853$7F2.53864@news3.cableinet.net> Message-ID: What I don't understand is how the Web form (or the browser) did send spaces to the server. URI encoding translates spaces into +'s, I think, because an RFC determines that. This applies to both methods. I'm pretty sure that some C/C++ functions would stop reading from stdin, using the POST method, if spaces were in the datastream sent to the server. Did you (or others) change the browser or its configuration? If yes, it would be interesting to know what it was because this is something that shouldn't happen. -- avs Paul Goodyear wrote: > Yep i'm a newbie here. > Been doing this stuff for about a month and it rocks. The thing is I wrote a > guestbook and for the last weeks it's been working fine. But all of a sudden > the text that is sent to my server from the web page in the comments text > input or textarea boxes are sent with +'s instead of spaces. > I have tried both action="get" and action="post" in the HTML code. > I have put the code below that does the grabbing: > HTML CODE: > --------------- > > PYTHON CODE: > ------------------- > import time, string, os > print "Content-type: text/html\n\n" > qs = os.environ['QUERY_STRING'] > t = string.split(qs, "?") > tt = string.split(t[0], '&') > NameString = string.split(tt[0], '=') > EmailString = string.split(tt[1], '=') > CommentString = string.split(tt[2], '='); > TimeString = time.ctime(time.time()) > GuestList = open('cgi-bin/guestbook.txt') > CurrentGuest = GuestList.readlines() > GuestList.close() > GuestList = open('cgi-bin/guestbook.txt', 'w') > line = NameString[1] + ',' + EmailString[1] + ',' + CommentString[1] + > ',' + TimeString + '\n' > GuestList.write(line) > GuestList.writelines(CurrentGuest) > GuestList.close() > I'm taking the query string and placing all the fields into variables, > reading in the current entries and then writing them all out again. > But as I said and why I need help is that all the spaces are now been > replaced with + sysbols, which can I stress didn't do at first. I have > changed the code and put it back and it did just the same. > Please help. > email or post. -- Andre van Straaten http://www.vanstraatensoft.com ______________________________________________ flames please to /dev/null at vanstraatensoft.com From paul at prescod.net Wed Jul 19 13:23:20 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 12:23:20 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <3bRSXS$je4@openbazaar.net> Message-ID: <3975E408.987EF970@prescod.net> Gareth McCaughan wrote: > > ... > > Well, I was making a broken assumption about the meaning of > multiple comprehension indices: namely, that > [(i,j) for i in [1,2], j in [1,2]] > would evaluate to [(1,1), (2,2)] rather than [(1,1), (1,2), (2,1), (2,2)]. > If it's supposed to go the other way, then some of my other > assumptions stop working. :-) For exactly this reason I have proposed the following syntax: [for i in [1,2]: for j in [1,2]: i, j ] Which I think is more clear that it is not parallel. > So [f(x) for x in collection] would turn into something like > > indices = collection.valid_indices() > result = collection.clone() > for index in indices: > result[index] = f(collection[index]) ...easier to just require the "collection" type to have an append operator... > ... > With more than one collection being iterated over, as in > [blah blah blah for x in xs, y in ys], the simplest thing > would be to use the first collection mentioned as template > and source of valid indices. It's somewhat arbitrary but maybe it would work. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From gee308 at mediaone.net Mon Jul 24 02:08:13 2000 From: gee308 at mediaone.net (Toy) Date: Mon, 24 Jul 2000 06:08:13 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> Message-ID: <397BE26A.4093A037@mediaone.net> I've got an idea, Why don't you try doing some of the improvements yourself. If you write code in Python, I'm sure you could help write a few modules. Python is "Open sourced" and while I'm not in the developing community, I am sure many people have contributed with modules, code, etc. One "problem" that frequently happens from being open source is that people want to improve the code, so they(with a group of others) start developing their own enhancements. The groups eventually split and you end up with stuff like different versions of Apache Python modules, MySQL modules, etc. Just look at Linux, the mess is a thousand times larger. You have packages coming in RPMs, ELF, tar.gz, Hell, I can't even name half of them. There are even RPMs that don't work on RPM machines.(A lot of the new RPMs from Redhat don't work on the new Mandrake distributions). BTW, I hope that Python becomes more mainstream too. Jason Toy toyboy at toy.eyep.net http://toy.eyep.net Dan Grassi wrote: > Hi Guido, > > Well, I am rather ambivalent about 1.6. See, I really like python and > want to use it at work, a dot-com --- in fact I would like it to be the > standard. But I doubt that it will come to pass, there are to many > stumbling blocks. > > First and foremost is database support as a part of the languare > _package_! In particulay I need Oracle on ix86, a not uncommon database. > But that is no trivial task. Thus python fails because it can not be > used in a production environment that involves Oracle. > > Then there is the mod-python/mod_pyapache mess, two competing versions > both with major problems ranging from re not working in the module > version of mod_python to memory leaks in both versions. Memory leaks are > a major problem in a shop that is serving over 1 million pages a day. > > Also in the area of divergence is the MySQL database interface modules, > there are at least two and I believe four current versions. > > OK, but this is not python! Well, technically that is true but these are > problems when one tries to use python in production! > > I suggest that you, Guido van Rossum, father and inventor of Python, > "bless" some versions and thus get development behind single versions > instead of diverging from each other. Thjis in much the same manner that > Linus blesses a release of Linux. > > Oh well, this is just wishing upon a star. :-) At least I do get to use > python on occasion, thanks. > > Dan Grassi From gmcm at hypernet.com Sat Jul 22 12:22:19 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 22 Jul 2000 12:22:19 -0400 Subject: New PEP: Attribute Access Handlers In-Reply-To: <3979C616.CA01C09C@roguewave.com> Message-ID: <1247839555-20324326@hypernet.com> Bjorn Pettersen wrote: > Gordon McMillan wrote: > > Of course you don't! Because Paul forgot to tell you that the > > first proposal said that defining one or more of > > __set/get/del_XXX__ automatically defines all 3, with default > > behavior of "you can't do that". So a base class defining > > __get_X__ and a derived class defining __set_X__ will have the > > wrong semantics 50% of the time whichever way you choose to > > handle it. > > Hey, I think I understand it now ! So the reason you need > to install _one_ attribute handler with either scheme is that XXX > has no relation to an actual attribute ("it is disallowed to have > an attribute named XXX in the same instance dictionary as a > method named __attr_XXX__.") It's therefore impossible to have a > default set/get/del handler with the common semantics of > setting/getting/deleting the attribute. Solving that problem by > associating XXX with a 'real' attribute can't be done since it > would probably require new syntax, and wouldn't always be > desired... Am I close? Hmmm. Well, the implementation actually puts the access handler into class.__dict__ as 'XXX'. So the statement that "it is disallowed to have an attribute named XXX in the same instance dictionary as a method named __attr_XXX__" is a bit disingeneous (I mean besides the fact that methods only get into an instance dict when indulging in memory-leaking hackery). There *is* an attribute named XXX, and this is the basis for "get" access being sped up (getattr sees that the thing is an access handler, and reacts accordingly). However, the statement self.__dict__['XXX'] = 3 will work (there actually nothing there to "disallow" it), and further, it will undo the hack (it will never get called - for set or del either). So, if you understood the "semantics" section, you probably didn't understand the "proposed implementation" and vice versa. Therefor I can unequivocally answer both "Yes" and "No" to your final query . - Gordon From alex at magenta.com Thu Jul 27 03:46:56 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 27 Jul 2000 09:46:56 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: Message-ID: <8lopjh03s4@news1.newsguy.com> "Mark Hammond" wrote in message news:SWPf5.13166$4p3.102561 at news-server.bigpond.net.au... > "Moshe Zadka" wrote in message > news:Pine.GSO.4.10.10007270810400.2823-100000 at sundial... > > On Thu, 27 Jul 2000, Mark Hammond wrote: > > > > Hmmm...this sounds positively interesting. Do you know if there is > similar > > support for continuations? IOW, can Scheme be supported on IL? > > AFAIK, continuations are currently being fudged, but MS have promised to > add more stuff like this after release. Unfortunately, "after release" is > still some time off. For all of my MS praise in the last mail, it should > be obvious thay are still a commercial company with a tight deadline. I suspect their numerous stockholders would be pretty unhappy if either of these attributes were lacking:-). > They have said a number of times "if you can work around it, do" - Commendably pragmatic, or blamefully unprincipled, depending on how one chooses to look at it (I'll admit to a pragmatism bias, only moderated by a realization of how often such workarounds end up as short-sighted kludges leading to worse problems in the future...). > tail-recursion turned out to be an issue that was extremely difficult to > fudge, so support was added pre-beta. Continuations are simpler to fudge, > so explicit support was pushed back. Interesting! If I had to guess, I'd have guessed the other way 'round, which, I suppose, just shows you how much I know about IL and code generation for advanced/dynamic language features (==not much). Doesn't tail-recursion just basically map down to 'rebind args&locals suitably, then jump to the entry point', rather independent of the cross module communication issues that IL addresses? Or are we talking about mutual-tail-recursion or something even more refined? Just for my own edification and curiosity-sating (if the Scheme compiler you mention later is open-source, I guess I should get down to studying how it does things, but I don't yet know of any open-source IL generating compiler -- nor of publically available detailed preliminary specs for NWGS/IL/whatever runtimes, etc, etc [hint, hint:-)]). > I know of at least one (fairly) complete and fast scheme implementation. > > > That's sad -- JPython, CPython and Python .NET should feel the *same*. > > That's why we have a standard (the Python Language Reference Manual). > > I truly hope JPython and Python .NET (is that the official name) > > No idea what the official name is! Python .NET seems to make sense at > this stage. On the ActiveState site, Python .NET _is_ used as just such an official name (in fact, it sort of seems to be just about the only well-established aspect of the project, judging from the dearth of info at the site:-). > > will be similar enough to CPython that Python code will work across them > > seamlessly. > > I agree. Although there is a dilemma here - sometime you _must_ make a > choice between the language semantics versus the platform semantics. ie, > it would be just as much of a shame if JPython and/or Python .NET didnt > support enough platform semantics to make it a viable language on that > platform, thereby keeping it stuck in an "interesting, but not useful" flux. A dilemma I don't envy you. Striking a balance between "faithful compatibility with the old" and "exploiting new platform possibilities" is, of all excruciating design decisions, the least enjoyable kind, in my experience:-(. > I dont believe this needs to be a real problem. When implementing a new > version of Python, you will be amazed at how much _isnt_ spelt out. > Fortunately, the implementation is clean and available, meaning the > existing C code is usually a better reference than the docs! Im fairly No Extreme Programmer will be surprised in the least at this state of things:-). "The code IS the docs", etc. Actually, Brooks' observations about architectural documents in "The Mythical Man-Month" are worth periodically re-reading (as is the rest of the book:-). Maybe a huge test suite proclaiming 'you're Python iff you pass this test suite' would be the only way to keep consistence now that we're heading towards _many_ implementations in widespread use (CPython, JPython, Python .NET -- dunno what happened to Skaller's project [Viper, was it called?] -- and no doubt other hopefuls in the wings...). > confident I can support all documented semantics, and plenty of > undocumented ones. We're all here, with fingers crossed, rooting for you on this...!!! Alex From shouldbe at message.com Fri Jul 28 10:19:16 2000 From: shouldbe at message.com (Arinté) Date: Fri, 28 Jul 2000 14:19:16 GMT Subject: Is this the efficent way? Message-ID: I need to split a double (8) byte character into two bytes to send as a string so I have this code def hexSplit(arg): ans = 0 lobyte =arg-256 if arg<=255: ans = "\x00" + chr(arg) else: hibyte = lobyte/256 if (lobyte%256)>0: hibyte = hibyte+1 ans = chr(hibyte)+chr(lobyte) return ans Is this good enough? thanx From jepler.lnk at lnk.ispi.net.bbs Sun Jul 16 22:00:01 2000 From: jepler.lnk at lnk.ispi.net.bbs (jepler.lnk at lnk.ispi.net.bbs) Date: 17 Jul 2000 02:00:01 GMT Subject: string issue or questions about intern Message-ID: <3bQhU1$ivi@openbazaar.net> On 14 Jul 2000 16:56:47 -0400, Andrew Kuchling wrote: >Brian Kelley writes: >> eval('"AAAAA"') >> eval('"AAAAB"') >> eval ('"AAAAC"') > >This seems a reasonable outcome of the rule that Python always interns >string constants. Every string gets interned, and interned strings >are never freed, so memory is constantly being consumed. > >If you need full Python expressions, there seems no way around using >eval(). But if you simply need string escapes, it's probably worth >writing a parser. (Does such a parser already exist somewhere in the >standard library? Anyone know?) Well, the problem is pickle.Unpickler.load_string(): def load_string(self): self.append(eval(self.readline()[:-1], {'__builtins__': {}})) # Let's be careful dispatch[STRING] = load_string You can see that unpickling lots of unique strings causes Python to use progressively more memory. Jeff From ssthapa at midway.uchicago.edu Sat Jul 29 15:52:56 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 29 Jul 2000 19:52:56 GMT Subject: Perl is worse! References: <398178EA.7576E13A@hursley.ibm.com> <8ls9oe01f82@news2.newsguy.com> Message-ID: Grant Edwards wrote: >As long as the conversion can guarantee no information loss, I wouldn't have >a problem with it. I've yet to use a language that can make that guarantee. >I guess I never looked into the details in Python (haven't done much >numerical stuff yet). I had sort of assumed that floating point values were >32 bit, but if they're 64, then as you say, the problem is postponed until >long ints are involved. I believe scheme can guarantee no information loss for the conversion listed above since it has an explicit rational type. I suspect lisp may have similar features. Some of the functional languages like haskell and ML may do the same. If not, it should be relatively easy to add such a by introducing a rational type and coercion routines for ints to rationals. Incidently, ML is a completely type safe language and people who use it like the fact that if your program compiles then there are guaranteed to be no type errors in it at all. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From db3l at fitlinxx.com Mon Jul 24 23:55:36 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2000 23:55:36 -0400 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> Message-ID: "ye, wei" writes: > I have been using 'emacs', it's a nice editor, however I still concern if > add or remove a new block within a complex logic it may mess up > the old application. However if {} is applied, I'm pretty sure it doesn't > happen. There isn't really that much difference with Python code (and Emacs has a nice Python mode). Typically, if you're inserting a new block, it's going to be scoped beneath some existing block, and indentation is still easy to handle (just as you'd likely indent your braced block anyway). If you need to reallocate a block, certainly within Emacs it is easy to shift any portion of your current block in or out a level as necessary. I'm sure like many people here I felt sort of "naked" without my braces when I first started with Python - but when it comes down to it, I was already indenting my code logically (or letting Emacs do it for me) within the braced blocks, so as it turns out, removing the braces didn't really change the way I wrote or indented code and it's just as readable and easy to work with. I still occasionally miss the trailing braces at the bottom of heavily indented blocks, if only as a place to "hang" my comments about what block they are closing - of course that very construct was because even in C/C++ it was far from clear in some cases from just looking at the brace :-) > I can bear the {} issue, however I couldn't bear with variable > without declaration. I wrote many applications, I couldn't live > without declaration. For big project, there are so many scripts, > everyone may be misspell variable name. It's very timeconsume and > hard to find out such problem, which should be easy checked out by > compiler. Ah, but it's not at all easy to check in a fixed way with a dynamic language like Python, as I think you'll see as you work with it a little more, and run into items like __getattr__ or exec(). And if you do get it wrong, an exception is thrown for you and the traceback makes it easy to find. I think this is sort of one of these "Trust the Force, Luke" things. One of the very first things I worried about and tried to find a resolution to with Python was the issue of typos leading to NameErrors that I couldn't find because I didn't have compile time checking. I was surprised that there weren't a ton of syntax checkers out there (but there are definitely a few). I religiously tracked them down and downloaded them. You know what - I still haven't used them to any large extent, because surprisingly (to me at least) it hasn't been a big problem of mine at all in the code I'm working on. I think it's a mixture of a number of things. For example, Python's module system is terrific and really encourages small modular design with individual namespaces. The standard idiom of embedding tests into scripts themselves when run standalone means you think more about matching tests with your work as you go. And the exception handling is clean, ubiquitous and consistent. Heck, wrap your entire application in a top level try/except worst case if you want as a master safety net - you just re-initialize and keep running :-) So if this is the only thing really causing you heartache, the best I can suggest is to just get in there and try. You may surprise yourself in the same way as I have. > Yes, it is if you define a function expect a base class, its derived > class object should have no problem to be passed in. Both Java/C++ > have this feature. And if you give Python a chance I think you'll start to wonder why Java/C++ is so limited :-) How many times has a well designed class system gotten "re-designed" or just crufty because of molding things into the hierarchy to fit the requirements of libraries or other routines expecting a particular type of class. I've had enough experience with growing poorly designed class systems to think that there just has to be a better way. I felt that Java's interface approach felt more natural but its still quite strongly typed. The whole notion that you must have a formal class inheritance hierarchy in order to be able to use one object in place of another (e.g., a derived class), while valid, is hardly the only way to go. In Python, what matters is not the formal class hierarchy - in Python it's more common to inherit to obtain functionality than to impose an "is one of" classification. For Python, it's the actual dynamic run-time interface provided by an object that is of utmost importance. This is more similar to 'interfaces' in Java, but even there Java is more strict than Python. If a function requires that the supplied object support a "write" method, then all Python requires is that be the case. And it only cares when the function actually tries to make the call, not at compile time or function declaration. It doesn't where the object fits in a class hierarchy, nor if the object provides all sorts of unrelated methods. It only wants that "write" method to be present. Until you've worked this way you can't imagine how clean, natural and "fun" this is - at least IMO. It makes design much cleaner and simpler, and means that you can evolve things more simply. No, it's not perfect and has its own warts, but I'm sold on it. > If don't specify the variable type: > 1. When you read code, it's not easy for you to understand how to invoke that > function. > For example, compare > def f(x, y, z): ... with def f(int x, complex b, Employ c): ... > which declaration give you more information without read further code? > You know how to invoke the latter one without read its code and comments in > most cases. Why is reading the declaration for a function (which Python supports via docstrings) to understand that any better or worse than reading documentation? Or to phrase it another way, why bother with the syntactic sugar (and limitations) of the static typing when you can just as easily place the interface requirements in the developer documentation and have a function that can literally work on any object without ever needing changing or massaging of the class hierarchy, as long as it conforms to the interface? > 2. it leads the function is mis-called by passing not correct type. Ah, but now we get to the rub of what makes a type "not correct" - in Python, that would mean that it's got the wrong interface, and if that's the case it's easy for the function in question to just raise an exception, either by explicitly checking for the interface, or just attempting to use it and letting Python itself raise the proper exception when it isn't present. The amount of control over the process and its error recovery is completely in the application's control. But if the object in question does have the right interface, Python doesn't care what class it is part of or really anything about the class hierarchy - it just cares that it conforms to the required interface that the function desires for its argument. Don't get me wrong - if your background is more biased towards heavily typed languages (mine was, although I did have some decent experience in others) it's sort of a paradigm shift and takes some thinking to get over. The best I can suggest is to jump in there and write some code. You may be pleasantly surprised and start reconsidering some of these points - not so much their usefuless as points - but more how important they really are (or aren't) in the Python world. Then again, maybe not, in which case there are lots of other languages out there - and as another poster said, some improvements in these areas (but not, I expect, quite as far as you're advocating here) are likely to show up in future Python releases as well. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From m.faassen at vet.uu.nl Mon Jul 31 04:27:21 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 08:27:21 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8lvr4n0iue@news2.newsguy.com> <8m26up$ila$5@newshost.accu.uu.nl> Message-ID: <8m3d99$hn2$4@newshost.accu.uu.nl> Steve Lamb wrote: > On 30 Jul 2000 21:33:13 GMT, Martijn Faassen wrote: >>condition. It cannot magically repair bugs. So what is you want? > A little tolerance to those bugs, not a panic to break out of a 12 deep > nested loop to a point of no recovery while in the /customers/ hands. Then catch exceptions. Or make your code more tolerant of the data in the first place; let it skip the records that are corrupt. What is the problem? Really, your advocacy for more tolerance of bugs so that: * the program keeps running (even though it may be doing all the wrong things) * there is a possible (but impossible to predict!) chance of recovery of some data in interactive software. is really bizarre to me. What kind of software engineering attitude is that? If you want such tolerance, put it in your code. That's fine if it is in your requirements. But often it is *not* in requirements, in which case you seem to say it should be anyway. That is bizarre in the face of the examples you've been given. >>And what is your experience regarding databases and exceptions in Python? > As Alex pointed out there are more databases than just that. Yes, sure, but you were claiming exceptions and Python somehow made the picture worse. I just gave you examples where in the case of relational databases, it didn't, and in the case of the object database, it made it *better*. In the case of fragile databases, your bug-tolerant software has a higher chance to corrupt things and/or create data-loss than software that craps out on the first sign of something amiss, I'd say (especially since the crap-out handler can be made to do something sane with the data). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From spam at spam.com Thu Jul 27 03:28:06 2000 From: spam at spam.com (Penfold) Date: Thu, 27 Jul 2000 08:28:06 +0100 Subject: How to create COM Servers with IID_IDTExtensibility2 interface References: Message-ID: Mark Hammond wrote in message news:lWLf5.13002$4p3.101011 at news-server.bigpond.net.au... > > According to a very small demo I have downloaded from Microsofts > website, > > for a COM object to be used by excel as a COM Addin > > it must implement the interface IID_IDTExtensibility2. I know the GUID > for > > this interface and its "defined methods". > > Sorry - you are SOL. > > To support arbitary interfaces, you need C++ support, in the form of an > extension module. There is a new "Univgw" that may help you out, but I > dont know much about this (Bill Tutt has been working on that, but not > much has been done recently - I dont even know its completeness.) > > Mark. Aaargh!! :-) Thanks Mark, Des. From plusk at radford.edu Sat Jul 1 10:19:27 2000 From: plusk at radford.edu (Paul D. Lusk) Date: 1 Jul 2000 14:19:27 GMT Subject: ? WinNT sys.stdout and re-direction Message-ID: <8F6466ABEpluskrunetedu@137.45.128.146> I'm new to Python and I'm trying to run some scripts. System is WinNT, output via sys.stdout.write(). Redirecting output to file results in any empty file, for example: At the NT command prompt: script.py in.txt writes output to the screen, but script.py in.txt>out.txt gives me a empty out.txt Could somebody point me in the right direction to fix this? From alex at magenta.com Sat Jul 29 20:35:27 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 02:35:27 +0200 Subject: XML: good, but no magic bullet (was Re: Perl is worse!) References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> <3981BE50.23DB16C5@infercor.no> <8lsu2a02ho4@news2.newsguy.com> <8luhsl21ce8@news2.newsguy.com> Message-ID: <8lvth00ntg@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o6m3f.f91.grey at teleute.rpglink.com... > On Sat, 29 Jul 2000 12:13:16 +0200, Alex Martelli wrote: > >(XML helps. But don't anybody think it's anywhere close to > >the panacea it's apparently considered to be in some circles; > >that is just Yet Another recurrence of the never-ending dream > >for the Magic Bullet:-). > > Someone tell that to the people who wrote O'Reilly's Java & XML and, hmm, > there was another one out there. If you want a good chuckle pick it up and > read the first two paragraphs of the preface and introduction. In a nutshell Yeah, there's lot of hype about it, as is typically the case with so many new technologies in our field. In this case, it's a good and very useful technology, and I, for one, find the hype particularly irritating in cases like this -- because it raises expectations to unreasonable levels, thus ensuring eventual backlash. The point is: just as exceptions help you handle errors well, just as locales (and facets) help you do internationalization right, so does XML help you achieve interoperability (particularly exchange of data) between heterogeneous programs. But HELP is all each of these good technologies can do: you must still understand what it is you're doing, you must still do it properly. It IS no doubt easier to kill a bear with a gun than with a pocket knife, but if your aim is totally off then even the gun can't help you enough... > Me, I filed the book away until I actually have a need for it in spite of > the author's view of its use in the world. So far I have seen two /examples/ > of its use at one conference and to me it looks like a markup language with > definable tags. Yes, and a rather well-designed standard, with useful standardized API's (DOM, SAX) and lots of promising extensions and applications (although some of them bid fair to become too complicated for really practical use, sigh -- and also, there's so MANY of them one risks losing track:-). The point is, it will not *by itself* solve your interoperability problems, not even, by itself, all of your data interchange problems; you must still apply it correctly, and with clear understanding of its strengths, weaknesses, uses, limits. Basically, like any other technology -- some more, others less. Getting acquainted with the XML scene is not a bad idea, but IMHO the best way to do that right now would be to study the annotated standard (VERY good annotations!) then start playing around a bit with Python's XML support (due to grow a lot in the near future). I've got a dozen books on it, but none has given me much added value wrt the annotated standard plus some practical experiments!-) Alex From hzhu at localhost.localdomain Thu Jul 20 20:19:49 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 00:19:49 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: On Thu, 20 Jul 2000 18:18:10 -0500, Travis Oliphant wrote: > >These are my sentiments too. Huaiyu, it's obvious you've spent a lot of >time in Matlab but not so obvious that you've considered the design of >NumPy very much. There was A LOT of discussion that wen't in to NumPy to >make it more generic than 2-D Matlab (I wouldn't be using it if it >weren't). That's why you meet resistance when you seem to want to change >syntax to make just 2-D Matrix notation easier. That is a very good point. Would you like to summarise some of the design issues here? I would be especially interested in seeing some tensor operations that's candidate for infix notation, like kron, and how they are currently done. Some example codes that uses the expressions would be most helpful, imho. >I think that 6+5 operators will never fly. I think we'll be lucky if we >get four into Python itself. I suppose if you want to maintain a >separate patched-interpreter than you can do whatever you feel best about, >though.. ;-) Well, as I said, that's not really a proposal. It's just one way to list the options so as to be as compatible with everyone as possible. If we agree that's the case we can start to suggest what's the best migration path. I would be glad to see MatPy and NumPy merge in the future, as long as both interfaces remain available, as both make sense to a lot of people. Huaiyu From shindich at my-deja.com Mon Jul 10 20:57:57 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Tue, 11 Jul 2000 00:57:57 GMT Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> Message-ID: <8kdref$j4t$1@nnrp1.deja.com> In article <396A1EC6.6738CFCC at alcyone.com>, Erik Max Francis wrote: > I'm fairly new to Python, although it's simple enough that I've already > been able to write some fairly involved programs in it (I already know > C, C++, Perl, etc.). This question isn't so much about what's going > wrong, but rather what's the best, most natural way to get around it. > > I've come across a problem due to circular references, and I'm not sure > what's the best way to tackle it. In essence, the problem is that I > need a particular class to keep an associative array of its methods for > a lookup table (it's essentially a dispatcher). But with references to > its own bound methods, Python's garbage collector concludes it has > circular references and thus its destructor never gets called. > > Here is a simplified standalone program that demonstrates what I'm > talking about: > > class C: > def __init__(self): > print "in constructor" > self.map = { 'f': self.f, 'g': self.g } > > def __del__(self): > print "in destructor" > > def f(self): > print "in C.f" > > def g(self): > print "in C.g" > > def dispatch(self, name): > self.map[name]() > > c = C() > c.dispatch('f') > > When run, this program prints > > max at charmaine:~/tmp% ./circ.py > in constructor > in C.f > > and that's it; because of the circular reference, the destructor never > gets called. > > For the application I need, it's imperative that the destructor get > called. What is the best way to solve this? I can think of a few: > > - Move the map to a local variable in the dispatching function > - Make map a lookup table of _unbound_ methods > - Build a string of the function call and then exec it > > What would be the most effective way of getting around this? I'm > thinking that using unbound methods would probably be the best way. > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ We'll have to make our own luck from now on. > \__/ Louis Wu > Computer science / http://www.alcyone.com/max/reference/compsci/ > A computer science reference. > Hmm... It seems to me that there is no need to have this map at all. Python is an introspective language, so you can easily discover object's properties at run time by name. Here is my version of your program: #!/usr/bin/python class C: def __init__(self): print "in constructor" def __del__(self): print "in destructor" def f(self): print "in C.f" def g(self): print "in C.g" def dispatch(self, name): func = getattr (self, name) apply (func, []) c = C() c.dispatch('f') This is the output: >>>in constructor >>>in C.f >>>in destructor I hope this helps! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From weeks at golden.dtc.hp.com Sat Jul 29 20:41:38 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 30 Jul 2000 00:41:38 GMT Subject: "always passes by reference" References: <8lqd0p$snj$1@news.dtc.hp.com> <8lqiq3$7iha$1@nntp6.u.washington.edu> <8ls8bm$cde$1@news.dtc.hp.com> <39829E5D.45357D37@innuendo.de> Message-ID: <8lvtk2$8pa$1@news.dtc.hp.com> Ulrich Schreiner (ulrich.schreiner at innuendo.de) wrote: : it is all so easy, so why this big discussion? : you have ONE and exactly ONE object identity, but you can have multiple : references to this identity. in your program you always work with : references. So you phase it. I would never talk that way myself, and if someone asked me to describe what was going on, I would use quite different words, eg: Each object is the address of a region of memory -- an address that can be written to multiple locations. You prefer to think of the object as a region of memory [I think], and you define a writing of that memory's address to be a "reference". I prefer to think of the object as an address, and I don't give any special name to a writing of that address. There is no right or wrong here, but there is also no single correct description of what is going on. Some say Python is call-by-reference, some say Python is call-by-value. Everyone is correct. Greg PS: My motivation for my particular phasing is that I like to view all data in the computer as patterns of 0s and 1s. (I find this tidy and easy to remember.) An address is a pattern of 0s and 1s. A block of memory is not. So, for me, a datum can be an address, but not a block of memory. From paul at prescod.net Sat Jul 22 01:02:27 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 22 Jul 2000 00:02:27 -0500 Subject: Discussion: new math operators References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39792429.BB6163E8@roguewave.com> Message-ID: <39792AE3.84237196@prescod.net> Bjorn Pettersen wrote: > > ... > > I have seen no agreement on this, and I can only assume that if they're > made available new and "useful" meanings would be found for all of > lists, tuples, and dictionaries. This has certainly been the case in > other languages. I don't think that will happen in Python. The goal is not to extend "typical Python" but to make it Matrix-friendly. If you start doing .+ and .* in Python code, Python would become very hard to read and not only when you were using matrices, but always. > ps: did you read the APL/J pages? I don't know if it is really useful to skim another languages' design. Language issues are often deep and a surface examination may not turn up the reasons that choices were made. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From donn at u.washington.edu Tue Jul 11 12:43:35 2000 From: donn at u.washington.edu (Donn Cave) Date: 11 Jul 2000 16:43:35 GMT Subject: zope and UNIX permissions References: <8kdlcc$epr$1@nnrp1.deja.com> Message-ID: <8kfirn$41r4$1@nntp6.u.washington.edu> Quoth shikida at my-deja.com: | We tried to install zope using its tar.gz file and it created a lot of | files with non-default users and with very permissive permissions on a | linux box (like 777 permissions for many files). | | This is a HUGE security hole. We couldn't install the RPMs files on our | webserver. Is there any decent zope source code distribution? I don't know about Zope, but if you unpack tar.gz files from the net - as root and - don't monitor which files are installed that way and - don't change the ownerships and protections afterwards, then you are the huge security hole. One way to handle this is chown bin .; gzip -d -c bla-0.0.tar.gz | su bin -c 'tar xvf -' then monitor the files as the tar proceeds. All files will be owned by "bin" (per your UID scheme, not the author's), no file owned by root can be overwritten, and permissions will be limited by umask value. (You'd have to check that last one - I'm assuming tar on your platform is implemented correctly, and then there's the question of what umask value you get with su bin -c '...'.) Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From billtut at microsoft.com Thu Jul 13 12:28:22 2000 From: billtut at microsoft.com (Bill Tutt) Date: Thu, 13 Jul 2000 09:28:22 -0700 Subject: TypeLib for Python COM Server? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD2CD@RED-MSG-50> Don't rely on the 1000 thing. You should specifically declare the dispid's in the Python class. Bill -----Original Message----- From: Stefan Migowsky [mailto:smigowsky at dspace.de] Sent: Thursday, July 13, 2000 1:16 AM To: python-list at python.org Subject: RE: TypeLib for Python COM Server? Hi, there is no general support for typelib generation. But as I know all propertiues and methods of a Python COM Server start with the dispid 1000. So writing the IDL File by hand is no problem. Just take the same GUIDs, Names and the right DispID. So here is a little example : Python File : _reg_clsid_ = "{5B24BFC0-EF45-11d3-9B5F-0090274354BC}" _reg_libname_ = "PythonComInterpreter Typelib" class PythonComInterpreter: """Interface PythonComInterpreter""" _public_methods_ = ['Exec','Eval'] _reg_progid_ = "PythonComInterpreter" _reg_verprogid_ = "PythonComInterpreter.1" _reg_clsid_ = '{281AC1E3-E3D2-11D3-9B37-00902722BDE1}' _reg_desc_ = "PythonComInterpreterClass" _reg_class_spec_ = "PythonComInterpreter.PythonComInterpreter" def __init__(self): self.Dict = {} self.Dict["__name__"] = "__main__" self.Dict["__builtins__"] = __builtins__ self.Dict["__doc__"] = "" def Exec(self, Cmd): exec str(Cmd) in self.Dict def Eval(self, Cmd): return eval(str(Cmd),self.Dict) if __name__ == '__main__': print 'Registering Python COM Server ...' import win32com.Server.register win32com.Server.register.UseCommandLine(PythonComInterpreter) print 'Registering finished' ###################################################################### Corresponding IDL File: ###################################################################### [ uuid(5B24BFC0-EF45-11D3-9B5F-0090274354BC), // _reg_clsid_ Typelib version(1.0), helpstring("PythonComInterpreter 1.0 Type Library") ] library Interpreter { importlib("STDOLE2.TLB"); // Forward declare all types defined in this typelib dispinterface IPythonComInterpreter; [ uuid(281AC1E3-E3D2-11D3-9B37-00902722BDE1), // _reg_clsid_ PythonComInterpreter Class helpstring("PythonComInterpreter Class") ] coclass PythonComInterpreter { // _reg_progid_ PythonComInterpreter Class [default] dispinterface IPythonComInterpreter; }; [ uuid(F8887DE1-EF58-11D3-9B5F-0090274354BC), helpstring("IPythonComInterpreter Interface") ] dispinterface IPythonComInterpreter { properties: methods: [id(1000), helpstring("Executes a Pythonstatement")] VARIANT Exec([in] BSTR cmd); [id(1001), helpstring("Evals a Pythonstatement")] VARIANT Eval([in] BSTR cmd); }; }; Stefan >-----Original Message----- >From: mlp at amrose.dk [mailto:mlp at amrose.dk] >Sent: Wednesday, July 12, 2000 1:37 PM >To: python-list at python.org >Subject: TypeLib for Python COM Server? > > >hi all. > >i'm in a situation where i'd like to have a typelib for a python com >server, for use in a c++ client. > >i tried to just use midl on an idl i made to reflect the interface of >the python server. this didn't work out, since when compiling the >client code the tlb file is not recognized. > >my question: is there an automatic, easy, or standard, way to produce a >typelibrary for a com server implemented in python? if not, is it >possible at all? if so, could anybody help me with the details? a >complete example would be splendid! > >python rules! >'gards, >morten lind petersen, denmark > > >Sent via Deja.com http://www.deja.com/ >Before you buy. >-- >http://www.python.org/mailman/listinfo/python-list > -- http://www.python.org/mailman/listinfo/python-list From cut_me_out at hotmail.com Sat Jul 8 21:13:02 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 Jul 2000 21:13:02 -0400 Subject: Removing unstylish spaces Message-ID: Reading Code Complete and The Pragmatic Programmer at the same time can make you do some silly things. I learned recently that it's not stylish to have a space between a function name and the opening parethesis of its argument list, so I kludged something together to remove most of them from my code. I thought I would make it available here, in case anyone else is so frivolously minded. :) Alex. #!/usr/bin/env python '''Finds all *.py files beneath the cwd, looks in them for opening parentheses preceded by a space, and removes the space if it thinks it\'s part of a function call. If you use it without backing your files up, you\'re an idiot. That said, it\'s pretty paranoid about trying not to stuff files up, and will save a copy of file.py in file.py.bak, if it decides to modify it. You can do as you wish with this code, even attribute it to yourself, if you\'re in a plagiaristic mood.''' import os, string, re, shutil, sys class File_getter: def __init__ (self, paths): self.filenames = [] for path in paths: os.path.walk (os.path.expanduser (path), self.callback, None) def callback (self, dummy, directory, filenames): filenames = filter (re.compile ('\.py$').search, filenames) filenames = map (os.path.join, len (filenames) * [directory], filenames) self.filenames.extend (filenames) want_to_keep_the_space_p = re.compile ( '(([^%s](' % (string.letters + '_') + \ string.join (['if', 'and', 'or', 'else', 'assert', 'while', 'return', 'exec', 'del', 'for', 'not', 'raise', 'in', 'is', '[-^<>=+*%~:]'], '|') + \ '))|[-^<>=+*%~:]|\d)$').search assert want_to_keep_the_space_p (')and') assert want_to_keep_the_space_p ('5 %') assert not want_to_keep_the_space_p ('"%s" % str(4)') def clean_brackets(filename): '''Find brackets proceeded by spaces in the python file filename, and remove the spaces unless they are proceeded by a keyword or symbol. ''' file = open(filename).read() file_copied_p = None # ...first, get rid of confusing carriage returns file = string.replace (file, '\r\n', '\n') # Check that we don't get any false positives from an existing # syntax error. try: compile(file, 'test', 'exec') except SyntaxError: # Ignore file if we do. return None start = 0 while 1: candidate = string.find(file, ' (', start) if candidate == -1: # No more found break # This could skip ahead two, if a space is removed. start = candidate + 1 # Check that the bracket is in a coding region of the file # by seeing if removing it induces a syntax error. assert file[candidate: candidate + 2] == ' (' mutated_file = file[:candidate] + file[candidate + 2:] try: compile(mutated_file, 'test', 'exec') except SyntaxError: # This is part of a coding region of the file, amend it. # in the rest of the loop. pass else: # Removal had no effect on syntactical correctness of the # file, it must be irrelevant. continue # If this is the first amendment to the file, take a copy of # it, in case this screws up. if not file_copied_p: shutil.copyfile(filename, filename + '.bak') file_copied_p = 1 # Get the word/symbol prior to the bracket. # ...get the start of the current line line_start = string.rfind (file, '\n', 0, candidate) if line_start == -1: # No prior newline, must be on first line. line_start = 0 else: # Jump past the newline. line_start = line_start + 1 # ...get the word words = string.split (file[line_start: candidate]) if len (words) == 0: # Just whitespace prior to the bracket, ignore. continue prior_word = words[-1] if not want_to_keep_the_space_p (prior_word): assert file[candidate] == ' ' file = file[:candidate] + file[candidate + 1:] if file_copied_p: # Must have been modified, too. Save it. try: compile(file, 'test', 'exec') except SyntaxError: raise 'Stuffed up the syntax of ' + filename else: open(filename, 'w').write(file) if __name__ == '__main__': agreement = 'Yes_I_want_to_run_this_poorly_understood_code_' \ 'over_all_python_files_below_my_cwd.' if (len(sys.argv) != 2) or (sys.argv[1] != agreement): print 'Usage:' print sys.argv[0], agreement sys.exit (1) for filename in File_getter([os.getcwd ()]).filenames: print filename clean_brackets(filename) From alan.gauld at gssec.bt.co.uk Fri Jul 28 12:22:43 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Fri, 28 Jul 2000 17:22:43 +0100 Subject: Color, "DOS" programs, locate... References: Message-ID: <3981B353.404D516D@gssec.bt.co.uk> Jim Hribar wrote: > Where can I get information on using Python for text based programs, > specifically formatting the screen, changing colors, etc. In DOS mode you need to write ANSI control codes to the screen > I'm using Python for Windows. If you want to do it in real windows you need the winall package and use the MFC GDI capability in the Windows API. - Thats hard! Alternatively use Tkinter which has seveal ways to display text. See my online tutor for some examples. Look at the end of the event driven chapter and also the end of the case study. Then check the Tkinter documentation on the Python web site for details of setting color. http://www.crosswinds.net/~agauld/ > I saw something called the "curses" module, but doesn't seem to > be for Windows. There is a DOS version but you don't want it, Tkinter is your best bet. IMHO... Alan G -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From cjc26 at nospam.cornell.edu Mon Jul 17 19:31:09 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Mon, 17 Jul 2000 23:31:09 GMT Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> Message-ID: * Paul Prescod menulis: | Matthew Cline wrote: | > | > def my_func(foo, bar, quux): | > if not isinstance(quux, Quux): | > raise RuntimeError("param 'quux' must be of class 'Quux'") | | Let me also point out that in many cases, this style of programming | would be frowned upon by serious Python programmers. For instance, if | you check that something is a string, your code will complain when it is | handed a Unicode string, even though it would probably work fine. If you | check that it is an open file, then your code probably will complain | about stringIO file-like objects, even though it would probably work | fine. If you check that it is an integer, your code will complain about | integers, even though ti would probably work fine. In that case, it'd be more useful to check if a particular object implements certain methods, rather than to check if it inherits from a particular class. For example, if you need a file-like object and you know you will be calling its readlines() method, then you can just call getattr(obj, "readlines") beforehand; if it doesn't raise an AttributeError then you're all set. I don't ever actually >do< that in my own code, though. ;) | In general, the Python philosophy is to "just try it" and see if it | works. Sometimes type checks are appropriate but if you do it on the | entry to every function, you are probably doing too much work and making | your own life (or someone else's) harder later on. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From dgrisby at uk.research.att.com Fri Jul 14 11:38:52 2000 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 14 Jul 2000 15:38:52 GMT Subject: ANNOUNCE: omniORBpy 1.0 is now available Message-ID: <8knc6c$mp1$1@pegasus.csx.cam.ac.uk> AT&T Laboratories Cambridge is pleased to announce the release of omniORBpy version 1.0. omniORBpy is a robust, high-performance CORBA 2.3 ORB for Python. It is available for free, under the terms of the GNU General Public License; the libraries are under the GNU Lesser General Public License. Technical features: - Fully adheres to the OMG standard Python mapping. - Support for the Portable Object Adapter (POA). - Support for the Interoperable Naming Service (INS). - Strict 2.3 compliant IDL compiler. With the new compiler, it is easy to write your own customised code generators, using Python. - The omniORBpy runtime is fully multithreaded. - A persistent COS Naming Service, omniNames, is provided. omniORBpy 1.0 is available for many Unix platforms, Windows, and a number of other operating systems. Pre-compiled binaries are available for Windows (NT, 2000, and 9x), Solaris 2.5, Linux glibc2.1, HPUX 11, and Irix 6.5. For more details, and to download omniORBpy 1.0, see http://www.uk.research.att.com/omniORB/omniORBpy/ -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From kare at speech.kth.se Tue Jul 25 10:09:33 2000 From: kare at speech.kth.se (Kare Sjolander) Date: Tue, 25 Jul 2000 16:09:33 +0200 Subject: joakim_g References: <397C7363.3BAF0381@speech.kth.se> Message-ID: <397D9F9D.1D925CAE@speech.kth.se> Sorry, all readers of comp.lang.python, for posting that list. Stupid mistake. To readers proficient in Scandinavian languages I just want to say that the message was intended as a complaint about the sort of words occurring in the list. Regards Kare From rupole at compaq.net Thu Jul 20 18:51:10 2000 From: rupole at compaq.net (Roger Upole) Date: Thu, 20 Jul 2000 22:51:10 GMT Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: I must take exception to your insistence that "Everything should be done ONCE, and only ONCE. In ONE place in the code." Besides sounding didactic, it is also completely false. In many cases, an initial read is necessary to determine how (or even if) the rest of a file will be processed. Also, different code may need to be called if the file is empty. Additionally, this overly simplistic programming style would be completely inadequate for most involved programming tasks. Roger Upole "Alex Martelli" wrote in message news:8l73an01lgb at news2.newsguy.com... > "Roger Upole" wrote in message > news:hMrd5.49275$e6.2860918 at pouncer.easynews.com... > > Using an initial read is a common enough idiom in any language. > > It is extremely rare in languages which allow assignment in > expressions, and would normally denote lack of familiarity > with the language's idioms. > > > f=open('filename','r') > > fline = f.readline() > > while fline: > > .... > > fline = f.readline() > > Everything should be done ONCE, and only ONCE. In ONE > place in the code. This expands the abstract operation > "get next thingy if any" in two places, just because of a > language quirk. > > > > def readline(self): > > > line = self.source.readline() > > > self.line = line > > > return line # may be empty, thus false > > I don't see why not just: > > def readline(self): > self.line = self.source.readline() > return self.line > > Seems to have exactly the same semantics; the local-variable > line does not appear to be playing any role. > > > > > could somebody enlighten me, please? and is there any easier way to > > > iterate over lines in a file without resorting to ugly break statements? > > The fileinput module does just that in a very elegant way, IMHO: > > import fileinput > > for line in fileinput.input("myfile.txt"): > # do whatever you wish with line > > > Alex > > > From hzhu at users.sourceforge.net Wed Jul 26 18:33:28 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 26 Jul 2000 22:33:28 GMT Subject: MatPy-0.3.0 released Message-ID: MatPy-0.3.0 is released. This is a major release, with several interface changes, bug fixes and many enhancements. MatPy (Matrix package for Python) provides an alternative interface to NumPy that is more familiar to Matlab users. The home page contains many links. Home Page: http://MatPy.sourceforge.net Download: http://download.sourceforge.net/MatPy/ Release Notes: http://MatPy.sourceforge.net/RELEASE_NOTES Many changes are made in this release. Please read the Release Notes. Here's a summary of the main points: - The methods .T .H .I .C etc no longer need () - Major bug fix for mfunc - Finding functions by lookfor(keyword). - Histogram plotting. - Elementwise comparisons. - Docstrings for all functions. - Named elementwise and matrixwise functions. - Augmented assignment. - some others This is an open source project under the GNU Public Licence. Any contribution (including questions) is welcome. The homepage has all the links. Please also see the TODO file for some ideas. It is known to work on Linux, Solaris and Windows, possibly others. On Unix-like systems (including Windows with CygWin), installation can be as simple as typing 'make insatll'. See the file INSTALL for details. Enjoy, Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From peter at schneider-kamp.de Thu Jul 20 21:00:03 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Fri, 21 Jul 2000 01:00:03 +0000 Subject: zip() : how about braid() References: <397681C6.FEAEE2E@my.signature> <397746AE.3CCDD423@schneider-kamp.de> <700fnsknn7k7fp22au924m2cprk04ghfic@4ax.com> Message-ID: <3977A093.5F98A59C@schneider-kamp.de> Ben Wolfson wrote: > > >>> marry([1,3,5],[2,4,6]) > ([1, 2], [3, 4], [5, 6]) > >>> divorce([1,2,3,4,5,6]) > ([1, 3, 5], [2, 4, 6]) I absolutely truly *LOVE* this. That's great. Man, you made my day! zip() / unzip() sounds just so technical. Peter P.S.: But what about the costs of divorce? -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From robert.kiendl at delphi2.de Tue Jul 18 06:21:42 2000 From: robert.kiendl at delphi2.de (Robert Kiendl) Date: Tue, 18 Jul 2000 12:21:42 +0200 Subject: swig: modifying wrap function generation Message-ID: <39742FB6.BB16783A@delphi2.de> I have to modify a lot of my exported functions in the following way: // myapp.i class CMyClass { ... void NormalFunction(int par1, char* par2); //BOOL CriticalFunction(int par1); %addmethods { BOOL CriticalFunction(int par1) { CAllowThreads _t; return self->CriticalFunction(par1); } } ... } is there a way to just mark CriticalFunction with something in order to get extra code lines into the wrap function? robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at nightrealms.com Mon Jul 17 00:13:12 2000 From: matt at nightrealms.com (Matthew Cline) Date: Sun, 16 Jul 2000 20:13:12 -0800 Subject: Wishlist sumbission form? Message-ID: Is there any way of submitting feature requests for Python, other than by filing a bug report? Thanks in advance. From peter at schneider-kamp.de.bbs Mon Jul 17 18:20:03 2000 From: peter at schneider-kamp.de.bbs (peter at schneider-kamp.de.bbs) Date: 17 Jul 2000 22:20:03 GMT Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <3bRRJ7$kGE@openbazaar.net> Moshe Zadka wrote: > > In the face of ambiguity, refuse the temptation to guess!!!!! > > "GvR".ljust(6, "12") > Traceback (innermost last): > File "", line 1, in ? > ValueError: second argument to ljust must be of length 1 So what exactly did you want to express with that? I knew that it only takes strings of length 1 right now. My questions were directed to Thomas' question "Why not allow multiple characters as padding ?". better-read-the-quoted-text-too--ly y'rs peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From loewis at informatik.hu-berlin.de Mon Jul 3 07:05:25 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jul 2000 13:05:25 +0200 Subject: PYRO, XML-RPC, and their friends. References: <8jpm3d$6ss$1@nnrp1.deja.com> Message-ID: Stephen Hansen writes: > I've discovered recently that I have a need for some Client/Server db > fucntionality in the python project that i'm working on. What I don't > want is to have to deal with installing some Big Bunch Of Crap that > will be needed to support my program, and even though I know nothing > about ODBC, it seems like that would include more baggage then its > worth in this instance.. I don't know what database you are going to use, but I believe that odbc would indeed be the soluation that involves the least amount of extra stuff. For example, Python-Win comes with an odbc module, and there is also at least one other odbc module that would work in a plain python installation, as well. > have my little windows program run on Linux It is possible to use odbc on Linux, as well. Depending on the database, it may even be easy to do so. > Anyways. It might be a bit overly complicated in and of itself, but the > way i've thought of doing it is just setting up PYRO, XML-RPC, etc, to > communicate between my Server and its Clients, to then access a MetaKit > controlled on the server. For completeness, I'd like to add CORBA in this candidate list; the implementation with least installation overhead is probably Fnorb (only one C module, which comes precompiled for Windows). > #1) How fast are these? Some of these are only protocols, which you can't compare for performance - you'd have to compare concrete implementations. I don't think anybody has done significant benchmarking on them, so far, but I guess they are "fast enough". > I don't know how long it'd take one of these systems to send across > a multi-megabyte binary file. I hope most of them would achieve approximately the raw wire speed for bulk transfer, or be at least comparable to any other bulk data protocol. Most of these will require to copy the bulk data in memory a number of times, which would be the primary source of overhead. > The rest of the data i'd be sending would be irrelevant in > comparison. That is only true if you have only "few" calls. If you have "many" calls, it is actually the number of calls that matters, not the amount of data transferred. Regards, Martin From theebh at yahoo.com.bbs Mon Jul 17 22:00:02 2000 From: theebh at yahoo.com.bbs (theebh at yahoo.com.bbs) Date: 18 Jul 2000 02:00:02 GMT Subject: Zope newbie Message-ID: <3bRX61$jW6@openbazaar.net> In article <3973347E.B73015F4 at eq.uc.pt>, Pedro Vale Lima wrote: > coughlan at gothaminteractive.com wrote: > > > I've just installed Zope on Linux, and the documentation that comes > > with it refers almost exclusively to NT!? There is very little on Zope > > with Apace. > > > > Does anyone know of a URL or forum to get a decent tour of Zope on > > Linux? zope.com is also *very* dissappointing. > > The website is www.zope.org > > > It's unclear to me how to even create a hello world program to make > > sure it's installed and running. Any advice, would be appreciated. > > check in the /doc directory for install information. You don't need to use > > apache to check if Zope works, use Zope internal server instead. > > There are serveral ways to use Zope with Apache. For fastcgi, my > favourite, > in zope.org check for the fastcgi howto (under documentation-howtos). > > regards > > pedro > > Zope mailing list is also a good place to start(and ask questions). It can be found at Zope.org. You can even start posting your question to the community at zope at zope.org. Sent via Deja.com http://www.deja.com/ Before you buy. From johannes at zellner.org Wed Jul 5 17:28:10 2000 From: johannes at zellner.org (Johannes Zellner) Date: Wed, 5 Jul 2000 23:28:10 +0200 (CEST) Subject: cleanup order Message-ID: Hi, suppose I've # fred provides `fun' import fred class Lola: def __init__(self, x): self.x = x def __del__(self): fred.fun(self.x) x = Lola('hello') # end of script this doesn't work, because fred is not present any more when x is destroyed. I don't know anything about python's internals, but I guess the dynamical loaded shared object's function table is destroyed (somehow) before x is destroyed. Any comments ? (or even workarounds ?) -- Johannes From akuchlin at mems-exchange.org Tue Jul 11 15:41:26 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Jul 2000 15:41:26 -0400 Subject: off-topic, "Compiler" technology References: <396ABBD7.8715465D@t-online.de> Message-ID: <3dog44zc7t.fsf@kronos.cnri.reston.va.us> hzhu at localhost.localdomain (Huaiyu Zhu) writes: > OTOH, judging from some prior discussions here, not many developers would > put in serious effort until a working prototype is here, as many don't > believe it's feasible to achieve much. Read some of the compiler-related threads in c.l.tcl first, though; the compiler seems to be mostly a simple repackaging, and the author shows signs of Usenet kook-dom, as in http://www.deja.com/getdoc.xp?AN=642980911, where he says that the compiler technology used also applies to natural languages. Time is probably better spent working on python2c, which is much less spectacular and much more plausible. --amk From petersc at stud.ntnu.no Wed Jul 5 19:44:29 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Wed, 05 Jul 2000 23:44:29 +0000 Subject: readline.c & more References: Message-ID: <3963C85D.3924126C@stud.ntnu.no> Johannes Zellner wrote: > > ?) I had to modify Objects/fileobject.c because there was a > name clash between `getline' there and in /usr/include/stdio.h > (as it comes with the latest debian potato). I replaced > `getline' with `file_getline' in Objects/fileobject.c. as far as I can see this has been fixed today. look for revision 2.78 in the CVS repository (or better yet, update). > ?) I modified Modules/readline.c so that it allows reading and > writing of a history file. I also plan to implement readline > functions as `stifle history'. Eventually I'd also add the > possiblity to register a script completer which would be > called before the builtin completers. My question about > this: where would I post patches ? -- I've an account on > SF for other projects, but as this is my first mail to the > list I'd understand if you won't trust me ;-) mailto:patches at python.org for more details check out http://www.python.org/patches > ?) Is there a forum for developers? This list seems more for > users isn't it ? there is. but it's hard to get in (still trying). the mailing list python-dev is probably what you are looking for. better-history-means-less-typing-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From rlytleNOrlSPAM at tqs.com.invalid.bbs Mon Jul 17 17:30:03 2000 From: rlytleNOrlSPAM at tqs.com.invalid.bbs (rlytleNOrlSPAM at tqs.com.invalid.bbs) Date: 17 Jul 2000 21:30:03 GMT Subject: problems trying wxPython in Win 95 Message-ID: <3bRQ4T$mzt@openbazaar.net> I got wxPython to work, mostly. I installed the update for WinSock for win95. I was able to try the demo, but did get the "blue screen of death" upon exiting. rob * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful From ldw at us.ibm.com Wed Jul 19 15:23:00 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Wed, 19 Jul 2000 14:23:00 -0500 Subject: Python-ese for indexing a list within a class Message-ID: <8l4v6k$rd4$1@news.rchland.ibm.com> Is the following the appropriate Python-ese for indexing a list within a class? # the following is defined outside of either class or function nCounters = 4 a,b,c,d = range(nCounters) # now define the class class C: def __init__(self): cnt = [0] * nCounters def someFunction(self): # some code self.cnt[a] = self.cnt[a] + 1 # <<< here's the statement in question # some more code I'm trying to avoid the considerably ugly: self.cnt[self.a] = self.cnt[self.a] + 1 The code seems to work ok but is this the right/best/prettiest/(etc) way to go about it? Larry From glt at equod.com Tue Jul 18 19:46:43 2000 From: glt at equod.com (Gilles Lenfant) Date: Wed, 19 Jul 2000 01:46:43 +0200 Subject: Newbie: searching an ODBC package Message-ID: <3974EC63.897EF1C2@equod.com> Hi, I'm looking for an ODBC client package to Informix and SQL*Server which API is identical in Windows and Linux. I'm looking for a BINARY package because I've no C compiler for Windows Thanks in advance for your help. URLs, HowTo and sample code are welcome. Gilles Lenfant glt at equod.com From cut_me_out at hotmail.com Mon Jul 10 09:23:07 2000 From: cut_me_out at hotmail.com (Alex) Date: 10 Jul 2000 09:23:07 -0400 Subject: reference counter and __del__ References: <3969CB5C.A860D124@muc.das-werk.de> Message-ID: > 1. I have the problem that not all of my objects are destroyed and I > don't know where and why, so I wonder if there a way to check out from > where and how many references to a special object exists? You can find out how many using sys.getrefcount. There's a module by Tim Peters, plumbo.py, that can help you find cyclic references. I found it a little tricky to use, though. > 2. When __del__ is called the object will be detroyed, correct? I think that's right. > 3. Why is __init__ not called when I unpickle an object? I guess it's assumed that it was initialized prior to the pickling. If you want to re-initialize it, check out the __getinitargs__ method, at http://www.python.org/doc/current/lib/module-pickle.html: > When a pickled class instance is unpickled, its __init__() method is > normally not invoked. Note: This is a deviation from previous versions > of this module; the change was introduced in Python 1.5b2. The reason > for the change is that in many cases it is desirable to have a > constructor that requires arguments; it is a (minor) ;nuisance to have > to provide a __getinitargs__() method. > > If it is desirable that the __init__() method be called on unpickling, > a class can define a method __getinitargs__(), which should return a > tuple containing the arguments to be passed to the class constructor > (__init__()). This method is called at pickle time; the tuple it > returns is incorporated in the pickle for the instance. Alex. From brianbird at my-deja.com Thu Jul 6 05:49:27 2000 From: brianbird at my-deja.com (brianbird at my-deja.com) Date: Thu, 06 Jul 2000 09:49:27 GMT Subject: How to print to stdout in binary Message-ID: <8k1kn5$mkt$1@nnrp1.deja.com> I've seen similar questions to this posted in other language forums, but I've not seen anything for Python: Does anyone know how to tell python to print the sys.stdout in binary rather than plain text. It's mode is set as 'w' and I can't seem to change it. I'm experimenting with a cgi script which I want to output an image to the browser so that the HTML file can have: and the resulting output of the script is an image. I've currently got: f = open("test.jpg","rb") bytes = f.read() f.close() sys.stdout.print(bytes) but I want the output to print in binary mode so that the image can be displayed correctly. If I was printing to another file I could open it with: f2 = open("test2.jpg","wb") f2.write(bytes) f2.close() so is there any way to do this with stdout? Thanks Sent via Deja.com http://www.deja.com/ Before you buy. From tony at lsl.co.uk Tue Jul 11 05:21:23 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 11 Jul 2000 10:21:23 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8kcqug$p32$1@newshost.accu.uu.nl> Message-ID: <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> OK - I spent some of my "spare" time last night reading http://starship.python.net/crew/amk/python/writing/zodb-zeo.html and also Jim Fulton's Introduction to the Zope Object Database (referenced therefrom, although I found it by other means first), and also with a quick look at the ZODB How-To. Gosh. Damn time machines have been at it again. Ask for something and it will have been there. The PJama (persistent Java) people regard a mainstream persistent language as a killer-app, allowing a major revolution in how people program. It's the sort of thing that I find quite exciting, because it's a different programming paradigm - no more worrying about database startup/shutdown, crafting little save files, etc. And yet here is Python with ZODB which looks like it does a good part of what the PJama people are aiming at (as Martijn said a couple of messages ago), and I hadn't really heard of it. Well, I knew about Zope, and about pickling, but that's not the same thing at all. I need to go back and look at the PJama stuff a bit next (although a quick look makes me wonder if any work is progressing on it - all the dates look a bit old), because I only had vague understanding of it, but here are some uninformed musings: The persistent Java effort requires quite a lot of work in the innards of Java (i.e., C++ programming). This is presumably because Java doesn't expose its insides to introspection in the same way Python does (Zope does use vanilla Python, doesn't it? Can it work with JPython? (I assume not)). This is obviously a disadvantage for the PJama people, not least because of the licensing terms around Java (i.e., why they can't call their variant pJava, even though they have had funding from Sun). Glasgow has a lot of interest in distributed objects, etc., so they've also put a lot of thought into how that works in the persistent arena. Obviously, ZEO is a step in that direction, providing the first mechanisms needed (makes sense!). Given the Python world, I would believe that it will expand to cope with any problems that crop up in a practical manner. Versioning and cache management is a Good Thing, and it's there - from a superficial reading it sounds like the hooks are similar. How easy is it to write a storage manager? It sounds to me as if this would be a useful thing to layer on top of a COM or CORBA interface to (for instance) an existing GIS, taking advantage of whatever versioning, locking, etc., that that existing software provides. Snags. Well, it's obviously a bit of a pain if __getattr__ and __setattr__ are unavailable for easy use - although I can't say I've used them for anything significant myself, they're useful tools for the back pocket. Also, the "lists and dictionaries aren't classes so we have to prod the persistence when they're altered" thing is a slight pain. And I know I've had problems getting to grips with pickling - although that was my fault 'cos I *was* trying to do something odd. But I can't think of any SIGNIFICANT problems from what I've read. And I know I'm itching to try it (maybe I'll finally get round to cataloguing our book collection again...) So, why isn't this better known? Is it just that Python is too good at too many things? Maybe we need a page of "clever things Python does that other people think are hard", or "important buzzword compliances by application", on the PythonLabs site... [It would help if this was all more evident from the Zope site, as well, though. Talk about hard to navigate round.] Tibs, all excited again [Hmm - should CP4E be considering what happens to programming if people *start* with a persistent language? """*My* variables last longer than *yours*."""] -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ "Bounce with the bunny. Strut with the duck. Spin with the chickens now - CLUCK CLUCK CLUCK!" BARNYARD DANCE! by Sandra Boynton My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From cut_me_out at hotmail.com Wed Jul 5 17:38:53 2000 From: cut_me_out at hotmail.com (Alex) Date: 5 Jul 2000 22:38:53 +0100 Subject: Python Module for sequence alignments. Message-ID: Hi. I made a python module that does simple sequence alignments. If there is enough interest, I may make it a little more elaborate. You can get it from http://puffin.lcs.mit.edu:8080/align.tgz To use it on linux tar zxf align.tgz cd align make and make the align directory accessible to python, with a command like setenv PYTHONPATH `pwd`:${PYTHONPATH} It needs the Numeric extension. Here's an example of how it works from the command line: >>> import align >>> align.align ('aneotuhaneot', 'asneouhoteuh')[0][0][:3] ('neotuhane', 'sneouhote', '----uh--e') The second element of the tuple it returns is the matrices used to calculate the optimal alignments. I don't really care how you use or change this, nor will I assume any legal culpability for problems arising from its use. For instance, if a bug in this code tricks you into genetically engineering Giant Super-Intelligent Man-Eating Lizards, I may cackle evilly, but I won't explicitly own up. I may take on the care and feeding of one or two of them if you can prove they will co-exist peacefully with my cat, but that's definitely as far as it goes. But please do let me know of any problems with it, or any suggestions you have about how I could improve it. If you make any use or improvements to it yourself, I would love to hear about them. Alex. From fiona at sitegnome.com Sun Jul 30 22:55:48 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Mon, 31 Jul 2000 12:55:48 +1000 Subject: Python in politics (sssssssssnake!) References: <398296A1.1A97571A@sitegnome.com> Message-ID: <3984EAB4.C8264270@sitegnome.com> In our ongoing saga who will win .... Is Python weird? Is Perl worse? Let's hope our super heroes can triumph over evil .... Stay tuned! super-boys-mother-ly y'rs - Fiona Neil Hodgson wrote: > > > body actions of a super hero (muscle flex left and right arms :) .... > > hopefully I'll be able to maintain that level of enthusiasm. Do all you > > guys do that?? > > We no longer try to emulate super-heroes. We've got Tim Peters. > > no-time-for-murder-mayhem-or-mice-gonna-shine-them-sigs-so-nice-ly y'rs - > neil -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From mwh21 at cam.ac.uk Fri Jul 21 14:18:44 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Jul 2000 19:18:44 +0100 Subject: Operators for everything (was Re: Operators for matrix) References: <3977AF5E.552F4F42@my.signature> Message-ID: W.Whiten at mailbox.uq.edu.au (Bill Whiten) writes: > In article <3977AF5E.552F4F42 at my.signature>, Greg Ewing > wrote: > > Python with its overloadable operators can be thought of > > as a meta-language for creating domain-specific languages. > > But the number of operators is too restricted for it to > > be really good in this role. Operator overloading feels like > > something tacked on as an afterthought rather than a > > serious feature. I don't think it's unreasonable > > to consider whether this situation could be improved. > > I would prefer the normal oprerators plus an escape character followed by > additional characters to define new operators eg @+ @div etc. I quite like this idea (unlike most of the others that have been mentioned...); it reminds me of Haskell. The semantics would be: a @ b === (a,b) for any valid identifier . There are still precedence issues, but I think they can be ignored (make everything of this from the same (low) precedence & left asssociative). Cheers, M. -- 3. Syntactic sugar causes cancer of the semicolon. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From db3l at fitlinxx.com Thu Jul 27 21:46:58 2000 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jul 2000 21:46:58 -0400 Subject: Python 2.0 - win32pipe routines inclusion for Windows References: <39802DB6.73CEC178@endea.demon.nl> <3980ABA5.4190FC4F@endea.demon.nl> Message-ID: Niels Diepeveen writes: > I would propose waiting for the child to terminate and returning the > exit code only when closing the last remaining pipe, and returning None > on all the earlier closes. Is there any problem with that? Just a far harder implementation in terms of maintaining state - internally, the close() function has no automatic access to anything outside of the file handle - the patch I proposed linked the selected (stdin) handle to the original process handle, so a wait and retrieve result could be done, but cross-linking all of the files that relate to the same process handle, although not impossible, is much more effort to ensure correctness. It would also mean subtlety in terms of knowing for sure if you are getting the exit code or not. If somehow you didn't actually close all the file handles you thought you did, you might mistake the close() return of 0 on what you thought was the final handle for a successful child process exit when you just hadn't happened to close all handles yet. Hmm - maybe implementing pclose() semantics in a popen#() environment (e.g., not the normal plain popen()) isn't practical - I agree that we don't want to leave the potential for a deadlocked wait for a child process that an application can't protect against. Does anyone know if the higher order popen# calls part of Posix? Does it have defined behavior for retrieving exit codes in such a case? -- -- 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 webmaster at in852.com Thu Jul 6 12:45:57 2000 From: webmaster at in852.com (webmaster) Date: Fri, 07 Jul 2000 00:45:57 +0800 Subject: in852.com - 2 Message-ID: <3964B7C5.EDB2E793@in852.com> [ ???? ] ?T???????? http://www.in852.com ?????T???? http://www.ec852.com in852?S?I?G (1) ???????P???~?e???|?? (Printers?BScanner?B?q???C??????)?C (2) ???W???I?j???? ?]?A???????????~?B???s?q?????~?B?y?????~?????C (3) ?????? Free Mail ?u?n?|???? POP ?? SMTP ???? mail.in852.com?A?K?i?????q Mail Box (4) ???I???e ?T???????y???T?B???g?@???B?C?????a?B???????T?B?q?????? ?n???U?????@?????????????????T?s?????C From slinkp23 at yahoo.com Tue Jul 4 13:47:28 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 04 Jul 2000 13:47:28 -0400 Subject: Postscript font metrics? Message-ID: <39622330.3732B225@yahoo.com> I need to generate some nice Postscript output from a python script, and I'm finding that I need to get at the font metrics info from the .afm files so I can place things correctly. (Either that or write *everything* in postscript -- no way!!) I can't find anything like this on Parnassus. Anyone ever seen any python code that gets the useful info from .afm files? If not, I might have a go at hacking the relevant parts of the Perl PostScript-Font-1.02 module into Python... but then I'll have to (yuck) read someone else's Perl code, which I haven't done in a looong time and I was never that good at it. -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From parkw at better.net Mon Jul 24 12:53:07 2000 From: parkw at better.net (William Park) Date: Mon, 24 Jul 2000 12:53:07 -0400 Subject: Python questions from C/Perl/Java programmer In-Reply-To: <397C6F49.7BEBB207@alabanza.net>; from yw@alabanza.net on Mon, Jul 24, 2000 at 12:31:05PM -0400 References: <397C6F49.7BEBB207@alabanza.net> Message-ID: <20000724125307.A16134@better.net> On Mon, Jul 24, 2000 at 12:31:05PM -0400, ye, wei wrote: > 1. Why not use {}?! > def f: > ... > why not use {} like this: > def f { > ... > } Usual answer is '{}' uses up extra line. But, Guido decided on this long time ago and is unlikely to change his mind. > The other problem is if you want to added a new condition in a complex > already existed condition statement, > e.g. In the following example, If you want to added a new 'if' between > line 1 and 2, you have to add TAB from Line 2 to 199, > it's difficult to make sure you don't make mistake. (The case may be > more complex as the example which I give). > > 1 if() : > 2 if(): > 3 .... > .... > .... > 100 else: > ... > 200else : > ... If you have to manually type 200 if-then-else, then perhaps you re-examine your logic. However, indentation should be taken care of by your editor. I use 'vim' with au BufRead *.py set smartindent au BufRead *.py set cinwords=if,elif,else,for,while,try,except,finally,def,class to get automatic indenting for the first line. More recent 'vim' may have other features that I'm not aware of. > 2. Why variable doesn't have to be declared before use? The usual answer is "because it's Python". From m.faassen at vet.uu.nl Fri Jul 28 22:50:37 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 02:50:37 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> Message-ID: <8ltgpt$31a$1@newshost.accu.uu.nl> Steve Lamb wrote: > On 28 Jul 2000 20:11:42 GMT, Martijn Faassen wrote: [snip] > Don't do much re work? ;) Nope; though I understand the basic concepts. >>I'd probably solve that in a more verbose way myself. > My perl background shines through, eh? Perl code definitely seems to be regular expression happy. In many cases they're pretty handy, though in lots of cases where Perl uses regular expressions Python does it with the string module. [snip] >>As your program proceeds and for instance throws the dice, it'll try to use >>those variables as numbers, but since they're other strings, you'll >>eventually get strange answers (such as 0). And then presumably you'd have to >>search what part of your program is wrong. In Python you'd know pretty >>quickly that you got strings instead of numbers, and so you know what to fix. > I know even faster in Perl. When testing RE I take a sample, toss it in > an isolated script and build the regex until the expected results come forth. Oh, sure, testing is always useful, of course. I was presuming we had tested but some little error slipped in at some point anyway. > When that is done I test it against a much larger data set for any cases I may > have missed. If errant data gets in after that time in Perl you have a script > which runs but has some problems. In Python it pukes. Yes, in Python you'd need to extend it with a few int()s if you want integers, or build lists or objects or whatever more complicated thing you'd like. > In either case it > happens outside your hands. When it comes to regex a properly defined regex > will not let through abberant data. Esp. not when it comes to something as > simple as digits \d versus words \w. Right -- that's why I didn't understand why you complained about the extensive exception checking or other checks you need in Python; if you *know* a string can be safely converted to an integer, int() does the job just fine by itself. >>That wasn't the assumption. I said the exact opposite, you need to >>remember what type your data is *anyway*. In order to do that you need >>to check the data if it is input. > On input. But for data generated internally this is not the case since > you defined it from start to end. Right, though often your internally generated data is dependent on some input, and if you slipped in a string instead of a number suddenly your big formulate will return a mysterious 0 or something. :) But apart from that, if you are dealing with data internally generally your data is already of the right type, so no excessive conversions are necessary. (you mentioned one for your hash key which is using a number; I don't think a little str() somewhere, or perhaps a ("%s" % n) takes up so much space. >>This is a common misconception. *everything* in Python is always, always, >>references. It is just that certain data types (integers, string, tuples) are >>immutable; you cannot change them. So the semantics are the same as >>copy semantics. [snip example] > Forget, for a moment, what is happening internally. What looks like here > is that in the first case there is an assignment going on and in the latter a > reference. Yes, as I said; in the case of immutable objects reference semantics are the same as copying semantics. But once your object is mutable (such as a list), you'll see the reference semantics. > Nevermind that what is happening in the first case is a references > objint[1] and b references objint[1] and when we change a it points to a new > reference objint[2]. It is the difference in behavior of an identical > operator that is ambigious. I'm sure even though I am aware that it happens I > am going to be nailed by it a few times before I get used to it. It's usually surprisingly easy to handle; I don't recall getting nailed by it often. And the behavior *is* consistent; there's no ambiguity about it. In your first example, you use an immutable object. You could also have used a mutable object and not changed it, and get the same 'copy semantics' effect. In the second case, you used a mutable object and then changed it, and so you'll see the reference semantics in the clear. But it's always there; no ambiguity about it. >>Isn't that worse than the program giving up? > No. The program giving up in the customer's hands because of an unchecked > except is a far cry worse than a nigglet but having it continue on. As a > customer which would you rather have, given the choice of these two: > a: A program that crashes, stopping everything that you're doing with no > chance of recovery > b: A program that behaves oddly but allows for chance of recovery. Ahum, the first! Especially if it deals with critical data, or *money*. Imagine I get a string by accident (there's a bug in the program) instead of a number, and the string evaluates to 0, and suddenly what I'm selling in my e-commerce store is *free*, I'd be rather upset. I'd rather have the software not working in case of such input! Also, if you *know* you want to continue in the face of weird behavior and recover, in Python there's an excellent exception handling system for you to use. So Python offers the error recovery, if you explicitly enable it. [snip] >>But you haven't; you haven't told the system it's a number yet. :) That's >>the _only_ extra step you need to take. The system is too stupid to figure >>it out very well on its own anyway, so why not tell the system explicitly? > No, in my case I needed to check to make sure it was a type that can be > converted to int and then do the actual conversion. That is two steps more > than I deem needed considering the strictly checked input in the first place. This depends. If you know, like in Perl, that your data *has* to be a number, you just need a single int() and no further checks. If you turned out to be wrong, you'll find this out as well. >>Interactive mode (I think it explains in the tutorial) gives you the output >>of expressions as a result always. > Right, which is worthless in a script. Which is why it isn't happening in a script. In a script, the result of expression statements are discarded. This is useful in the case of function calls. > I'd personally have the Python > check what mode it is in and toss an exception when it is in interactive mode > and gets a meaningless statement. It's not a meaningless statement. Sometimes it's very handy to get the representation of some Python object. For instance: >>> def foo(): pass >>> [many complicated steps later] ...ah, but what is bar now? >>> bar > It does so on every other possible > ambiguity, why not this one when it is even less grey than a lot of the ones I > am tossing out? Is there a purpose for having such informative statements in > non-interactive mode? In non-interactive mode it isn't useful, I think (I'd love to hear some cases outside the function call example) so we could propose a patch to Python that trips over this (in the case of non-calls). >>No, my entire point was that you need to know what your data is *anyway*. > Right, I know what the data is, I don't need the language to ask me at > every operation, "Are you sure? I mean, really, really, REALLY sure!?" No, but this is hardly the case in Python either. :) >>You need to know that something is an integer anyway, so why not simply >>tell the computer what's going on? I'm *not* saying the language should >>do the checking. It can't; even though Perl tries. > Because what if I want to do something that the computer thinks is > non-sensical? Then don't depend on the computer trying to figure out your nonsensical thing anyway. Because you'll likely get something nonsensical, or something you can't predict, unless you learned what would happen already. Tell the computer explicitly what you want in a clear way. This way other humans reading your code can understand what's going on too. Or you yourself the next day, month, year. >>checking. If you want the system to shut up about your mistakes, >>you can always do this in Python: >>try: >> a = a + 1 >>except: >> pass > Great, now I get to litter my code on a per operation basis with tries > instead of being able to set it on certain variables. That would make more > sense. Hm, it's hardly a recommended way to handle things in general. I certainly don't use this type of thing in my code; I don't see the necessity and I don't feel your pain. I understand that you do, though. Just pointing out that this behavior is designed and does have a reason. >>This works. I didn't need to tell the system that 'a' is a cow or a chicken >>or an animal that can make sounds. > Of course not, they are types. The variable gets it type at declaration, > IE, assignment. Huh? What do you mean, they are types? I was treating two objects that have nothing to do with each other in the code as the same thing, and it worked. Wasn't that exactly what you wanted? >>You can do that in Python too. I tend to prefer that as well. > I also prefer the computer to trust me than mistrust me. That statement sounds good in rethorics, but in practice I'd rather have the computer give up on things if I'm trying to do things that don't seem to make any sense immediately. That way I need to remember less. >>> Funny, we have implicit typing in OO code that causes problems later in >>> the code. So yes in OO code. >>What implicit typing? I don't understand what you mean at all. > A variable gets its type upon assignment. That is implicit typing. You mean dynamic typing? The objects get the instance type in Python. But they may be instances of any class, if you call .foo() on an instance and their class can handle foo() in some way, it'll work. >>Yes, but if I'm not doing it properly at least the language will complain >>so I get a broad hint I do need to do it properly. :) > As well as if you're doing it properly the language will still complain > long and loud. I don't consider trying to add two things that cannot be added as 'proper'. But we already had that debate. :) >>Huh? Where in Python did you find your declarations? I'm confused. > a = None > int(a) > a is declared as None at assignment. No, the name 'a' doesn't have any type. The object a is referring to has NoneType. I'm not sure what you're trying to accomplish with 'int(a)'. (and since Python isn't sure either, it complains :). >>Well, because it doesn't really make a lot of sense if you want to convert >>something to an integer when Python can't figure it out. If you're so >>sure of yourself, you can always do: >> >>try: >> a = int(b) >>except ValueError: >> a = 0 > Right, which is basically what I had to do except I left None as None. > Just seems like a pain in the butt to do after I have allready made sure, > beyond all doubt, that those variables contain numbers in the first place. If you already made sure beyond doubt, you only need to do this: a = int(b) Unless you made it possible that b contained something that couldn't be turned into a number, such as None. If you made that possible you aren't sure beyond all doubt that the variable contains a number, right? >>All right; this just doesn't happen very often in my code. Generally because >>I can expect a certain regularity in my input. If my input is less regular >>than I expected, I get exceptions. That gives me a nice indicator that my >>expectations were off. > Which is why for the base parsing routine I use re. If it doesn't pass re > it doesn't get executed, period. People can try all they want to get around > the regular expressions but it is really hard to do so. I don't see a reason > to write my own test parsing routines when re does it for me. Sure, but it is the same in Python, right? Except that in the end you have to cast your integers to ints or whatever other thing you were expecting from your input. >>In that case you don't need to do any checking, obviously. You have a >>regularity in your data so you just do something like: >>a = int(a) >>Though I may be missing something about regular expressions here and >>I'm goofing up? > > A regex could return a string or None, only one of which is convertable to > int. You must litter your code with such checks. Ah, okay. I can see that this could be a minor pain, but it also makes sense to me that you need to check whether something matched *anyway*, just saying None is 0 isn't the right thing, for instance. In throwaway scripts it could be a pain, though. >>Hm, why would you do that? Depends on the structure of your keys. You can >>use numeric keys in your Python dictionary just fine. > Text for information, numericals to prevent duplication. In Python you'd use a tuple. That's what tuples are designed for; an immutable combination of things that can be used as a key, for instance. So you'd say something like: key = mystring, myvalue instead of making it all a string. >>But an integer can be seen as an object with methods as well. A string >>too (Python 2.0 will actually allow you to use string methods). In fact, >>I can make a new type of object in Python that behaves much like your >>Perl scalars: > Touche'. ;) Thanks! I'm glad my effort wasn't wasted. ;) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From "rod" at REMOVETHISinf.bme.hu Mon Jul 3 10:09:25 2000 From: "rod" at REMOVETHISinf.bme.hu (Gabor Papp) Date: Mon, 03 Jul 2000 16:09:25 +0200 Subject: lambda requirements References: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Message-ID: <39609ea1@news.caere.com> there's a section about this in the FAQ http://www.python.org/doc/FAQ.html#6.10 Gabor From boncelet at eecis.udel.edu.bbs Mon Jul 17 16:00:11 2000 From: boncelet at eecis.udel.edu.bbs (boncelet at eecis.udel.edu.bbs) Date: 17 Jul 2000 20:00:11 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRNaD$l9g@openbazaar.net> Bjorn Pettersen wrote: > On the contrary. The argument is something like the following: > > - Python is a general purpose language, and as such it can't > support special case syntax for Matrix/cgi/xml/db programming. > (special syntax has previously been requested for both cgi and > db programming). Not trying to be argumentative, but why not? Why not allow an additional, overloadable, operator? > - The proposal is to add a handful of operators that would only > have meaning in this one domain. > - the criteria for addition to the core is something that is > generally useful for a large segment of the community. > (and it's your job to convince us of it, not ours to > convince you that it isn't -- many more people would like > to see Stackless in the core, but that's not going to happen > anytime soon either...) I'd love to see stackless and += added. > - that many problems can be reduced to matrix operations is > a non-argument, since the same is true of functional/ > procedural/oo/predicate programming. I agree, but there is a big userbase waiting for an alternative to the $$ Matlab. > - There are allready ways of performing the required tasks in > Python, so there is no absolute need to add this to the core. The same can be said of any simplification. There is no need for it, but adding it may make life a lot easier. > - Other straight forward solutions has been proposed including > list comprehensions and Moshe Zadka's elementwise class > approach. This I must object to. Linear algebra often involves big objects. These operations want to call a carefully written C function. Any time you use Python to loop over matrix objects, you are dead in a big problem. As far as I understand (and I could be wrong) neither list comprehensions nor the elementwise approach would be able to call the underlying C functions without python loops. > > > On the other hand, alternative arguments based on analysis of functionality, > > overall design, history of evolution and possible future extension, etc, > > would carry some real persuasive weight. > > If you really want to convince people, I would like to see examples of > how adding these operators would make working in other domains easier > (directly, not through translation through linear algebra). This may be Hauiyu's argument, but it is not mine. I'll let the people working in other domains to give the examples for their domains. My argument is that there is a very large potential user group Python could address if it were improved slightly (for that domain.) -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From m.faassen at vet.uu.nl Fri Jul 28 16:32:45 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Jul 2000 20:32:45 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8lsqld$hrq$1@newshost.accu.uu.nl> Steve Lamb wrote: [snip] > Just playing around try this some time: > a = None > list(a) > a = 1 > list(a) > a = 123 > list(a) > a = "abc" > list(a) > To me all of those could be converted into lists yet only the last one is. The last one is a sequence, the rest of them aren't sequences so Python gives up in the face of ambiguity. What result should list(None) give? What about list(123)? If you want to put something in a list, that can be done unambigiously: [None] or [123] [snip what you expected] You are expecting different things than I am. That's the problem; Python just gives up when it sees things like that. > as expected in conversion. > a = "abc" > a > a = list(a) > a = str(a) > a > a is now "['a', 'b', 'c']". Which means we split a string up when > converting to list but don't concatinate on the way back. There's string.join() for that: string.join(a) Again, str() tries to give you a readable version of whatever you put into it. Its goal isn't to concatenate anything. [snip lots of assumptions that just don't work in Python. Your assumptions are not the same I make, or Python makes] > a = None > a = "" > Amazing, that. Automagical conversion from None to an emptry string on > the assignment operator. Actually, we both know, and correct me as I may be > wrong, that it is really reassigning the data space a is pointing to. Yes, in Python, assignment is *always* a rebinding of the reference. There's never anything being copied. > However, if we want to create the namespace with nothing we cannot because > we cannot convert it for later use. That's because you want to convert everything to everything else. In Python, you don't have this kind of anything to anything else conversion. If you want to get rid of None, then assign something else to your variable. You can't do anything with None (except display it and check for it), as there's no commonly accepted thing to do with None. Just like there's no real sense in adding "foo" to 155. [snips] > Like I said, every language has its quirks. Every language. Yes, though you're really finding some quirks where they're none; you just coming with the wrong set of assumptions (Perl's). A few years ago I tried to learn Perl but happily gave up as soon as I found Python -- Python's assumptions just make more sense than Perl's to me. [snip] > And just for fun, here's a good quirk for you. > None = 1 > a = None >>>> if a: > ... print "foo\n" > ... > foo >>>> a > 1 > I think that is kinda neat, don't you? Yeah, that's a pretty awful quirk, I discovered that one a few months ago and was aghast. Luckily this type of thing rarely happens in Python (only when you explictly say None = , which is easy enough to avoid). But it should be forbidden, I think. Trouble is that this would introduce a special case in the clean name rebinding that is assignment in Python currently. There's no way to say 'don't rebind this name' in Python, I think. [snip] > I just don't understand how people can advocate for types and the > restrictions they impose while, on the other hand, embracing a language that > is free enough to shoot yourself in the foot by reassigning None. The difference is of course that reassigning None is extraordinarily rare, as it can *only* happen when you really write an assignment with None (not a variable referencing None, no, just 'None') on the left hand side. Python is by the way *not* a language with 'types and restrictions' according to most people that come to Python. :) > Shoot yourself with "conversion" or with assignments like this, either way > your foot is shot. I say learn proper gun safty and aim it elsewhere. ;) > Seriously, that isn't to say that None should be restricted from being > changed, just, uh, anyone know how to change it back aside from restarting > python? :) Cute question. Hm.. Yes: None = __builtins__.None Now for the real problem: __builtins__.None = 1 Uh oh. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From david_ullrich at my-deja.com Sat Jul 15 13:56:35 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sat, 15 Jul 2000 17:56:35 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> Message-ID: <8kq8kc$guk$1@nnrp1.deja.com> In article <8knl04$1c9b$1 at pc-news.cogsci.ed.ac.uk>, richard at cogsci.ed.ac.uk (Richard Tobin) wrote: > In article <8knhql$lpi$1 at nnrp1.deja.com>, wrote: > > It's explicitly provided in Python as well. > > No, that's just the point - it's not explicitly provided; instead the > implementation is exposed. You can assign to the __class__ slot, you > can initialise any new slots, and delete any that the new class > doesn't have. But does anything say "yes, this is all you need to do, > and it will work in all implementations"? Apparently not. > > > Changing the methods of the instance also counts as > >a sneaky don't-do-that. > > I thought you'd say that :-) Well it's exactly what I was doing once because I was a lot more clever than the guys who said I shouldn't. And then I decided quite suddenly that they were right. (At the end of a _long_ stretch trying to figure out why the heck something wasn't working - of course the answer is the object in question was very different from the object it appeared it should be...) > > Whatever it is you're trying to > >do there's a way to do it in legitimate Python without > >this sort of thing. > > Ok, I trying to directly model a rather abstract specification - the > XML Infoset - as Python objects. I then want to to perform the action > of XML Schema validation on this modelled infoset, which is defined to > add various properties to the infoset. Various methods need to be > changed to take account of the new properties. It is thus natural for > the class of the objects after validation to be a subclass of what > they were before. > > Now obviously it can be done in many ways as a programming task, and > others might be better in engineering terms. One might produce a new > infoset containing objects from the subclasses. But to directly model > the specification of the validation process, changing the classes, or > adding slots and changing methods, seems the natural way. So it's something like the value of infoset.__class__ changes when you call infoset.validate(schema)? Seems a little spooky to me (and evidently not only to me). If the new class is always a subclass of the original that's maybe a little more natural, but I really don't see the point to changing the class of the object instead of just constructing a new object. Like you pass a WellFormedInfoset to something or call some method of one and get back an instance of a subclass of ValidInfoset. I don't see why changing the class of a single instance is more natural than constructing an instance of a new class. You could have a subclass of ValidInfoset for each schema (not sure whether that makes sense - you know what I mean if it doesn't). Like maybe class ValidatedInfoset: def __init__(self, AWellFormedInfoset): self.info = AWellFormedInfoset self.Validate(self.info) and the Validate method does various things in various subclasses, raising an exception on failure. There's a lot I don't know about programming in general and about what you're doing in particular, but I don't see what the advantage of what you're doing has over some scheme like this. > -- Richard > -- > Spam filter: to mail me from a .com/.net site, put my surname in the headers. > > "The Internet is really just a series of bottlenecks joined by high > speed networks." - Sam Wilson > Sent via Deja.com http://www.deja.com/ Before you buy. From swun at eSec.com.au Tue Jul 25 22:51:58 2000 From: swun at eSec.com.au (Sam Wun) Date: Wed, 26 Jul 2000 12:51:58 +1000 Subject: how to know number of threads are running. Message-ID: <397E524E.412FE123@eSec.com.au> thanks Sam. From loewis at informatik.hu-berlin.de Wed Jul 19 12:40:23 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Jul 2000 18:40:23 +0200 Subject: CORBA refrence References: Message-ID: Miki Tebeka writes: > Any pointers on using Python with CORBA? Sure. There is a OMG-adopted language mapping, at http://cgi.omg.org/cgi-bin/doc?ptc/00-04-08.pdf There is a number of implementations of that mapping as well. In order of appearance: ILU: ftp://ftp.parc.xerox.com/pub/ilu/ilu.html Fnorb: http://www.fnorb.com omniORBpy: http://www.uk.research.att.com/omniORB/omniORBpy/ orbit-python: http://sourceforge.net/project/?group_id=3561 [They look like they are ordered by increasing name length :-] These implementations differ in ease-of-installation, degree of conformance to the mapping spec (or to CORBA Core), additional features offered, performance, portability, and so on. Discussion of CORBA and Python typically takes place on the DO SIG, http://www.python.org/sigs/do-sig/ Regards, Martin From see at my.signature Mon Jul 24 02:05:59 2000 From: see at my.signature (Greg Ewing) Date: Mon, 24 Jul 2000 18:05:59 +1200 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> Message-ID: <397BDCC6.9C498F01@my.signature> Gordon McMillan wrote: > > Paul forgot to tell you that the first > proposal said that defining one or more of __set/get/del_XXX__ > automatically defines all 3, with default behavior of "you can't do that". I really like the idea of accessor functions, but I think the current proposal is marred by some less-than- desirable features that seem to be artifacts of the proposed implementation. I assume that the main reason for funnelling all three accessors through a single function stems from the desire to be able to look up the function using an interned string, and if it were necessary to turn "foo" into "__get_foo__" etc. on the fly, that wouldn't be possible. However, this could be easily dealt with by keeping a cache of translations from attribute names to interned accessor names. So, I'd like to suggest a much simpler (to my way of thinking) version of the proposal, in which there are three completely independent accessor functions for each attribute, which behave in the normal way with respect to inheritance, etc. The advantages I see are: 1. Simpler to explain and understand. 2. More efficient - no need to dynamically switch on an operation code inside the accessor. 3. Doesn't magically put any names in the class dict that weren't explicitly put there by the programmer. 4. As a consequence of 3, doesn't preclude having a real attribute with the same name in either the class or instance dict. -- 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 aahz at netcom.com Wed Jul 19 20:26:46 2000 From: aahz at netcom.com (Aahz Maruch) Date: 20 Jul 2000 00:26:46 GMT Subject: zip() : how about braid() References: Message-ID: <8l5h06$7q$1@slb7.atl.mindspring.net> In article , Michal Wallace wrote: > >I accidentally deleted the list of proposed names for "zip()", so I'm >not sure if this was alrady mentioned.. I think merge makes sense, >(and I don't really have a problem with zip()), but the metaphor that >most closely resembles what it does is braid(), as in hair.. I could go for this, too. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From peter at schneider-kamp.de Sun Jul 23 02:41:15 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Sun, 23 Jul 2000 06:41:15 +0000 Subject: Looping on more than one list References: <3979C6F4.B1FF1800@atlsci.com> Message-ID: <397A938B.B7F1EC97@schneider-kamp.de> ahmed Bouferguene wrote: > > a = [1,2,34] > b=["a", "b", "d"] > > for x in a, y in b : > print x, y > > and the loop exits when the shortest list is exhausted minlen = min(len(a), len(b)) for x,y in map(None, a[:minlen], b[:minlen]): print x, y In Python 2.0 you will probably be able to do: for x,y in zip(a,b): print x, y Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From neilh at scintilla.org Fri Jul 7 23:52:44 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 08 Jul 2000 03:52:44 GMT Subject: Splitting c.l.py... References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> <20000707140442.B4771@kronos.cnri.reston.va.us> Message-ID: > Beats me. Hmm... here's a possibility: ... Essentially the newsgroup would > be a read-only view of the python-dev mailing list. But would it be of interest to anyone? python-dev has a much worse signal-to-noise ratio than comp.lang.python IMHO. One morning this week I opened up my mailer in the morning to see over 100 messages in python-dev and less than 80 in c.l.py. The traffic in python-dev alternates between checkin chat (there's a CVS lock here, that patch breaks on X, when will you finish Y?) and language/library design issues. I can see a reason for some of the detailed design issues to be decided on the same forum as the checkin chat with a limited group of people, but some of the larger issues should be debated in a wider forum. Was there any reason for "urllib.browse() issues" to be on python-dev? Possibly comp.lang.python is also a bad forum for discussing future changes to Python and should concentrate on solving peoples current problems and avoiding long winded discussions on new functionality. So a comp.lang.python.future (or similar mailing list) could provide a way for /all/ Pythoneers to be involved in the evolution of the language. Neil From jae at ilk.de Wed Jul 26 15:11:46 2000 From: jae at ilk.de (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Wed, 26 Jul 2000 21:11:46 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: <8ln84n$380$1@gaia.cdg.acriter.nl> (cg@gaia.cdg.acriter.nl) References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: <26072000.1@sanctum.local.jae.ddns.org> >>>>> "Cees" == Cees de Groot writes: Cees> David Arnold said: >> it's impressive how much hype can be generated for a product that is >> still years away from general release ;-) >> Cees> ...and is soooo innovative that it does exactly the same thing as Java Cees> and the JVM, only five years later and at the vaporware stage. There's Cees> only one company that can pull this off, and I sincerely hope they'll Cees> choke in it this time. Well, not to mention that Java is *sooo* innovative... compared to the UCSD p-System. ;-) Bye, J -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard Bill Gates brought you Windows. Linus brought you the whole DAMN HOUSE! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From aa8vb at yahoo.com Fri Jul 14 12:39:51 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 14 Jul 2000 12:39:51 -0400 Subject: OpenDX Python Wrapper -- any interest? In-Reply-To: ; from luthi@vaw.baug.ethz.antispam.ch on Fri, Jul 14, 2000 at 01:11:22PM +0200 References: <20000515112219.C1304991@vislab.epa.gov> <8i323b$c4s$1@nnrp2.deja.com> Message-ID: <20000714123951.A2023787@vislab.epa.gov> luthi at vaw.baug.ethz.antispam.ch: |I am highly interested in this project! I packaged it up and made it available a few weeks ago. Here's what I posted to -announce: ------------------------------------------------------------------------------ For those that work with IBM Data Explorer, I've put some OpenDX wrappers up at: http://www.freebsd.org/~rhh/py-opendx/ Currently just the DXLink library is wrapped. I found this useful for developing a prototype Python/Tk GUI interface on top of dxexec. Python folks already know what a big win this is over C/X/Motif. This version uses the new [a recent anyway] Python Distutils, so installation should be a snap. Let me know if you have any questions or problems with it. ------------------------------------------------------------------------------ -- Randall Hopper aa8vb at yahoo.com From scarblac-spamtrap at pino.selwerd.nl.bbs Mon Jul 17 12:10:02 2000 From: scarblac-spamtrap at pino.selwerd.nl.bbs (scarblac-spamtrap at pino.selwerd.nl.bbs) Date: 17 Jul 2000 16:10:02 GMT Subject: converting tcl database file to python Message-ID: <3bRHaQ$m5z@openbazaar.net> Bob van der Poel wrote in comp.lang.python: > Bob Schmertz wrote: > > Did you consider a CdItem class? > > No. I've looked at them but the one thing that bothered me is that > after defining a class (aka structure) one is free to add variables a > will. But the same is true for dictionaries and lists anyway... Why do you think it will be a problem? Are you going to add harmful things (like what?) in your sleep? ;-) Imo, if you have a problem defining a structure and it's more complex than a simple list or dictionary, it's time to write a class. > Yes. started a bit this PM. I think that what I'll do is write a > conversion in tcl and end up with a very-verbose datafile format. With > PentiumIIs who cares about a few extra cycles of overhead parsing a > file. I've just gotta get into the 21th century. Or let the program write its output as Python style expressions, so you can eval them again like the Tcl did :-) -- Remco Gerlich, scarblac at pino.selwerd.nl 5:57pm up 133 days, 6:07, 6 users, load average: 0.53, 0.33, 0.13 From robin at jessikat.fsnet.co.uk Mon Jul 24 07:28:11 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 24 Jul 2000 12:28:11 +0100 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: In article , Konrad Hinsen writes .... >What are "Greg's indexing rules"? Inner and outer product are entirely >different operations in my mind, although in principle the inner >product can be thought of as an outer product followed by a summation. >I think that implementation issues also call for separate operators; >using indexing tricks might be difficult for sparse matrices, for >example. > .... outer products (of vectors at least) are inner products with the second vector being transposed. There is of course a general tensor notation, but as Python lacks the distinction between sub/super scripts that's a bit difficult. One thing I personally find very strange is that very few in this thread seem to want to make the default multiplication operation * into the default matrix multiply. I suppose early language designers have decided this for all time so all choose the unusual element wise operation. -- Robin Becker From dittoC at ix.netcom.com Tue Jul 18 14:37:57 2000 From: dittoC at ix.netcom.com (David Cattarin) Date: Tue, 18 Jul 2000 18:37:57 GMT Subject: Windows NT select.select( ) Message-ID: <8l2862$4n1$1@nnrp1.deja.com> I recently had to write an EventLoop class to replace the asyncore.poll( ) function since I need to support timers as well as sockets in my application. There was an oddity under Windows NT that when no sockets were registered to the socket_map select failed. This code worked fine under UNIX. For example, select( [ ], [ ], [ ], 5 ) will raise a "file does not exist" error under Windows NT. Has anyone else noticed this? I've worked around it by creating an unconnected socket and placing it in the exception list; ie. select( [ ], [ ], [ s ], 5 ). This allows the code to work under Windows and UNIX. I am using Python 1.5.2, the precompiled version. I am pretty sure it is just a Windows NT oddity and not a Python problem, but I was curious if anyone knew more. Or even a better way to fix this. Thanks for your help. -- Ditto In the English language two positives never form a negative. "Yeah, right." Sent via Deja.com http://www.deja.com/ Before you buy. From kuchler at ajubasolutions.com Fri Jul 28 16:31:29 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Fri, 28 Jul 2000 13:31:29 -0700 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> Message-ID: <3981EDA1.1CB1CE07@ajubasolutions.com> Andreas Kupries wrote: > > > > Syntax separation - multiple syntaxes ? > > Perl6 offers the possibility to ... write Perl programs in multiple > > syntaxes such as Python, JavaScript, and Perl5 ... > > This reminds me of Guile, which tried to do the same thing, no ? > Universal lisp engine below, multiple formats for programming it > above. Here just with the perl engine below. A try to unify > interpreters ? See also Jean-Claude's Minotaur, using a forth engine > below and beside interpreters for several scripting languages to allow > them to use each other (and their extensions) hither and fro. With the > long-term goal to make each interpreter a set of routines above the > universal forth engine below. Hm. > I understood this to mean that for perl 6 they might try to architect it into a front-end/back-end style where the front-end has a parsing engine (and translator to byte codes or some intermediary language?) and then the backend provides the code for actually implementing the various commands. If done correctly, only the perl front end would have to be implemented, but it would give others the opportunity for trying to write some new syntax (which could be like tcl, python, etc.) that would work with the existing perl backend. That was how I envisioned that bullet might be implemented.. --Dan From gmcm at hypernet.com.bbs Mon Jul 17 19:30:02 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 17 Jul 2000 23:30:02 GMT Subject: Event set/clear/wait Message-ID: <3bRTAQ$kuG@openbazaar.net> j vickroy wrote: >How can software be written to determine when it is "safe" to *clear* a >threading.Event that has previously been *set*? >"safe" is intended to convey the notion that all threads issuing a >*wait* on the event are no-longer blocking because of it. You don't need to worry about it. All waiting threads are notified while the setter holds the lock. Once notified, they don't look to see if the Event is set or clear - they're unblocked. - Gordon From lull at acm.org Thu Jul 20 10:08:02 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 09:08:02 -0500 Subject: Discussion: new operators for numerical computation References: Message-ID: Konrad Hinsen wrote: > But there are other alternatives. How about operators in parentheses? > a (*) b looks fine to me, and it is currently illegal so it can't cause > compatibility problems. I'd even claim that it somewhat *looks* like > a matrix operation. Yes, it does. Another alternative might be a [*] b. Regards, John From amitp at Xenon.Stanford.EDU Thu Jul 27 18:34:22 2000 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 27 Jul 2000 22:34:22 GMT Subject: Python in game development? References: <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l52hs$i05$1@kopp.stud.ntnu.no> Message-ID: <8lqdde$s24$1@nntp.Stanford.EDU> Magnus Lie Hetland wrote: | > | > Be sure to check out stackless Python, which has some advantages for | > game scripting: | > | > http://www.stackless.com/ | | What exactly *are* these advantages? (Very curious...) One thing that may be possible is if the "stack" frames are pickle-able, persistence in your game could include not only what your objects are, but what they are *doing*, e.g., the Town Crier could be in the middle of running line 34 of cry_wolf(), and you could save that stack frame, as well as the stack frames of the callers. That way you could restore the game, and all the threads would pick up right where they were! Persistence is the main reason I got interested in stackless in general (nor specifically Python stackless). - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From eq3pvl at eq.uc.pt.bbs Mon Jul 17 06:50:03 2000 From: eq3pvl at eq.uc.pt.bbs (eq3pvl at eq.uc.pt.bbs) Date: 17 Jul 2000 10:50:03 GMT Subject: I'm confused with win32pipe Message-ID: <3bR9KS$l4D@openbazaar.net> I need to run some commands on a win98 computer and I'm having some problems to understand win32pipe behavior If I write (pin, pout) = win32pipe.popen4(r'copy c:\tmp\*.* c:\tmp2\','t') the script copies some of the files (not all!). I have some questions. The first is where can I find more documentation for win32pipe (the pythonwin reference is very short) ?. Is the process run in a subprocess? What's the meaning of the 't' and 'b' flags? Thanks for the attention, pedro lima From bragib at my-deja.com Mon Jul 31 16:50:08 2000 From: bragib at my-deja.com (bragib at my-deja.com) Date: Mon, 31 Jul 2000 20:50:08 GMT Subject: telnetlib References: <20000729152800.B1899@reepicheep.avalongroup.net> <20000731091354.A1319@reepicheep.avalongroup.net> <8m4g7c$8pr$1@nnrp1.deja.com> Message-ID: <8m4opv$fpi$1@nnrp1.deja.com> Maybe you can offer some suggestions on this: This is a repost as I am still clueless! Bragi I am trying to telnet from a UNIX box to an NT to get the doskeys. The NT that I login to runs a couple of .bat scripts which clear the screen set up some stuff etc. When I try to do a read_all() it fails the first time with the exception: Traceback (innermost last): File "telnet.py", line 17, in ? tn.read_all() File "/usr/abaqus60/5-0_copy/source/Python/Lib/telnetlib.py", line 229, in read_all self.fill_rawq() File "/usr/abaqus60/5-0_copy/source/Python/Lib/telnetlib.py", line 367, in fill_rawq buf = self.sock.recv(50) socket.error: (131, 'Connection reset by peer') That is why I put the first try in a try: except: clause. The second time I try to do a read_all() it works fine but I don't get all the keys I am missing some of the first keys. I assume that the first read_all() actually did read some stuff and then the second read got the rest. Can anyone see anything obviously wrong with this. Thanks, Bragi import sys import telnetlib HOST = 'shadow' USER = 'bragi' tn = telnetlib.Telnet() tn.open(HOST) tn.read_until("login: ") tn.write(USER+'\r\n') tn.read_until("password: ") tn.write('my_password\r\n') tn.write('doskey /macros\r\n') tn.write('exit\r\n') print 'done' try: all1 = tn.read_all() except: pass all = tn.read_all() print all Sent via Deja.com http://www.deja.com/ Before you buy. From dcalvelo at pharion.univ-lille2.fr Tue Jul 18 13:47:07 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 18 Jul 2000 17:47:07 GMT Subject: Using filter() References: <8l1o9h$pto$1@news.rchland.ibm.com> Message-ID: <8l256r$d7n$1@netserv.univ-lille1.fr> Larry Whitley wrote: : I have a simple problem and from the description, filter() seems like a : match. But I can't figure out how to make it work. Here's the code without : using filter() : include string, os : def filter1( fileList, name ): : #-------------------------------------------------------- : # matches name to the first characters of a file in the file list : temp = [] : for i in range(len(fileList)): : if string.find( fileList[i], name ) == 0: : temp.append( fileList[i] ) : return temp This: filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) gives you back the same result. In this and filter2(), the point of using the built-in filter is to move out of the loop and design the test function element-wise. filter then does the job. : def filter2( filelist, aString ): : #------------------------------------------------- : # finds aString somewhere in the file list : temp = [] : for i in range(len(filelist)): : if string.find( filelist[i], aString ) != -1: # is in the string : somewhere : temp.append( filelist[i] ) : return temp Likewise: filter( lambda x,sf=string.find: sf(x, name ) !=-1, fileList ) [snip main] : I suspect using filter() would simplify this. Can someone help? : Larry HTH docstrings-are-your-friend-if-not-then-they-are-enemies-to-be-feared-ly y'rs Daniel. -- Daniel Calvelo Aros calvelo at lifl.fr From garry at sage.att.com Mon Jul 10 14:21:42 2000 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 10 Jul 2000 18:21:42 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> Message-ID: <396A1436.3B6BD73B@sage.att.com> "Thaddeus L. Olczyk" wrote: > Java is not a variant of C++. of course it is. it's c++ with training wheels. > Java is a very different variant of C . for exceptionally large values of "very", perhaps. > Otherwise it > would not be so popular. After all, if it were a C++ variant why would > people go to all the trouble to switch from C++. well, many people are not switching, but learning java instead. those who switch often do so because they like the simplifications java offers vs. c++, or have been burned by its complexity, or they like the standardised environment and toolset, or whatever. perhaps they just got sucked in by the hype machine. who knows. but much of java's initial popularity was because it was so similar to c++ that the learning curve was relatively low. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From gmcm at hypernet.com Sun Jul 2 09:07:44 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 02 Jul 2000 13:07:44 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> Message-ID: <8F655BA3Egmcmhypernetcom@199.171.54.154> [posted and mailed] Sean Mc Grath wrote: >Sheesh! I really need a holiday! Probably ! >I have a reproduceable GPF on NT when pickling objects of a class >that has a __getattr__ implementation. Take out the __getattr__ and >the pickle works fine. > >Are there ways to implement __getattr__ and yet preserve the ability >to pickle? C'mon Sean! You've been around a while. You know when __getattr__ hacks go bad it's because they go recursive. (And the stack size on Windows is off by some tiny amount, so it GPFs instead of traps.) So what do we need: >>> class A: ... def __getattr__(self, nm): ... print "get", nm ... raise AttributeError, nm ... >>> a = A() >>> import pickle >>> s = pickle.dumps(a) get __getinitargs__ get __getstate__ >>> x = pickle.loads(s) get __setstate__ >>> import cPickle >>> s = cPickle.dumps(a) get __getinitargs__ get __getstate__ >>> x = cPickle.loads(s) get __setstate__ >>> Do you have a __getinitargs__ or __getstate__ or __setstate__ that might be triggering a call to __getattr__? Does an Irishman like to talk? - Gordon From stephen_purcell at yahoo.com Fri Jul 28 06:26:15 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 28 Jul 2000 20:26:15 +1000 Subject: Win32 drive mapping... aka "net use" In-Reply-To: <8lr9nc$tdf$1@nnrp1.deja.com>; from lshuler@my-deja.com on Fri, Jul 28, 2000 at 06:37:32AM +0000 References: <8lr9nc$tdf$1@nnrp1.deja.com> Message-ID: <20000728202615.B15002@inkontact.com.au> lshuler at my-deja.com wrote: > Is there an API using Win32 extensions to map a > drive share? I have not found one yet and have > tried searching "Win32 map drive". I am looking > for the equivalent of: > > net use Yes, look at the 'win32wnet' module provided with Mark Hammond's Win32 extensions: http://starship.python.net/crew/mhammond/win32/Downloads.html If I recall correctly, there is an example therein. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From gfortune at micron.net Sun Jul 23 21:26:02 2000 From: gfortune at micron.net (Greg Fortune) Date: Sun, 23 Jul 2000 18:26:02 -0700 Subject: newbie: Mysql References: <397AA44A.DE16654C@mediaone.net> Message-ID: Hmmm, good question. To get a MySQL module, go to http://dustman.net/andy/python/MySQLdb/ and download the 0.2.1 release. The readme included with the module will give you a brief description of its functions. I haven't ever tried it on a windows box, but it works great for linux. If you havn't been to http://www.vex.net/parnassus/, take a look. They have a nifty tutorial section about lots of python related stuff. Greg Fortune Ricky Chaudhary wrote in message news:397AA44A.DE16654C at mediaone.net... > > Hi, > > I am new to python, and would like to access a MySQL database using > python. Does anybody know of a simple tutorial on the internet that I > could use. > > Thanks, > RC From fig at oreilly.com Wed Jul 12 16:55:51 2000 From: fig at oreilly.com (Stephen R. Figgins) Date: Wed, 12 Jul 2000 20:55:51 GMT Subject: python/win9x and contour plots References: Message-ID: <396CDB9E.6F6AA3@oreilly.com> Eric Haageman has given some examples of using DISLIN with Python on the O'Reilly Network. It works okay on my Win98 system. You can find articles in his column at: http://www.oreillynet.com/pub/q/numerically_python I don't know how well DISLIN can handle an irregular grid, if it can at all. But it does seem pretty easy to use with Python. Stephen From tim.hochberg at ieee.org Thu Jul 20 18:18:18 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 20 Jul 2000 22:18:18 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <8l7qol$91u$1@la-mail4.digilink.net> Message-ID: "Pete Shinners" writes: > > (*) outer product > > (.) inner product > > (|) matrix solve > > (**) matrix power > > > heh, in an effort to keep this discussion from being "half-assed" (HA) > i'd like to voice that i also think this syntax is very useful > and very clean. i'd be glad to see it come around for the next > big release > > but while we're at it, i would hope that we don't overlook the > potential of elementwise assignment operators. sometimes those > matrices can get rather large, and rather than create a new > temporary matrix for every operation, it would be nice to have > it done "in place" > > MatrixA (*)= MatrixB > MatrixA (.)= MatrixB Whatever the final syntax [(*), @*, .*, ?], we should keep in mind that in place operations will be possible only a fraction of the time. In order for the operation to done in place, the resulting matrix must be the same size as MatrixA. This never happens for outer product (modulo some edge cases), For inner product and solve, this happens if A and B are the same size. Power always works. This isn't to say that the X= operations wouldn't work; they'd work fine, the just wouldn't always save any space. This makes their addition somewhat less compelling from my point of view, especially since they start to look awfully long. On the other hand,orthoganality is nice too. -tim From paul at prescod.net Mon Jul 24 17:23:54 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 16:23:54 -0500 Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: <397CB3EA.15F5514F@prescod.net> Tim Rowe wrote: > > In article , mwh21 at cam.ac.uk > (Michael Hudson) wrote: > > > Sorry, but eh? I fail to understand you, I think. > > > > Example usage of what I'm talking about: > > > > def add(x,y): > > return x + y > > > > 1 @add 1 > > ==> 2 > > My problem is that identifiers that refer to overloaded infix operators > must begin with a @ (and presumably any identifier beginning with @ must > be an overloaded infix operator). That's simply not true. The name of the function is "add". At the syntactic level, "@" is an operator that takes three arguments, a left operand, a right operand and an operation to apply. It is a meta-operator. @add is not an identifier. *add* is the identifier. Personally, I think that this proposal is far more palatable then the others which add five or more inscrutable multi-character symbols to the Python lexicon. This one adds one character -- the meta-operator. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From moshez at math.huji.ac.il Fri Jul 28 03:11:05 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 10:11:05 +0300 (IDT) Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message-ID: On Fri, 28 Jul 2000, Grant Edwards wrote: > In article , Ben Wolfson wrote: > > >list() (and tuple()) only work on objects that actually have a sequence > >mapping makes a lot of sense and, to me, resolves the ambiguity in > >precisely the way I would expect. > > Is 'sequence mapping' for list() an tuple() defined the same as for the > 'for' statement: it has a get_item(i) method that returns either a value or > raises an exception? Actually, I think these two want an __len__ method too. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From tarnold at datacomm.ch Sun Jul 9 07:20:03 2000 From: tarnold at datacomm.ch (tarnold at datacomm.ch) Date: Sun, 09 Jul 2000 11:20:03 GMT Subject: win32pipe question References: Message-ID: <1103_963141603@name> On WinNT 4.0 the following code (with SWI-prolog) works; it writes a query to SWI-Prolog, reads the answer, writes the next query, reads the answer and then halts the SWI-process. The problem is that python seems to hang if it is waiting for input (= output from the prolog process) and there is none. After exiting python the SWI-prolog process has to be killed by hand. I am interested whether win32pipe only works on WinNT or on win95/98, too. --- Toni Arnold --- python code for pop2en 2 --- from win32pipe import popen2 (plwrite,plread) = popen2('C:/Programme/pl/bin/plcon') plwrite.write('write(abc),nl.\n') out = plread.readline() print out plwrite.write('write(cde),nl.\n') out = plread.readline() print out plwrite.write('halt.\nl') From zo at angband.org Fri Jul 28 12:49:57 2000 From: zo at angband.org (Eric Lorenzo) Date: 28 Jul 2000 12:49:57 -0400 Subject: Perl is worse! References: Message-ID: <3h8zumi4i2.fsf@angband.org> grey at despair.rpglink.com (Steve Lamb) writes: > And I meant what I typed and do and I don't need the language > telling me that I'm the stupid one. I've got news for you, Steve: You may not be the stupid one, but you *are* the ignorant one. And so am I, and so is any other programmer who is dealing with a piece of code that he hasn't looked at in months (if ever). Programmers in that position are typically unaware of many of the details that were in the mind of the code's original author (even if it is their own code - people, including you, forget things). When a programmer has explicitly laid out what a program is to do, it will be far easier for that code to be understood, later. Typing isn't intrinsically required for communicating with the computer. As you point out, we could simply treat each value is an untyped glob of bytes, and let the operations that the omniscient programmer specifies determine how it is treated. But communication with the *computer* isn't actually the primary purpose of typing. Rather, typing is a means for programmers to communicate with themselves and with other programmers. It provides them with a mental framework on which to hang some of their meta-knowledge about a particular glob of data, and more importantly, a way to explicitly and unambiguously make note of that meta-knowledge in the code. When I read a piece of Python code that passes an string to 'int()' immediately after reading it from the user, I know that the original programmer was expecting the user to input an integer. It's considerably harder to figure out the programmer's expectations when reading a piece of Perl code that reads an input string and doesn't bother doing any explicit conversions, instead depending on the language to implicitly coerce to integer where it's appropriate. Eric From horst at proceryon.at Thu Jul 20 03:51:44 2000 From: horst at proceryon.at (Horst Gassner) Date: Thu, 20 Jul 2000 09:51:44 +0200 Subject: Canvas text - clipping instead of wrapping References: <397583B4.52066F4E@proceryon.at> <8l42f6$f28$1@nnrp1.deja.com> Message-ID: <3976AF90.DF43D40@proceryon.at> Hello Richard, > text.config(wrap=NONE) > > The options are NONE,WORD or CHAR. Thank you for your fast reply. I tried this but I got the following error: s._parent.itemconfigure(textID, wrap=NONE) File "", line 1, in itemconfigure None File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1541, in itemconfigure cnf = {} TclError: unknown option "-wrap" This is my code: textID=s._parent.create_text(x, y, width=tableCellWidth, text='%s' % (str(col)), anchor=NW) s._parent.itemconfigure(textID, wrap=NONE) Horst From yw at alabanza.net Mon Jul 24 18:49:48 2000 From: yw at alabanza.net (ye, wei) Date: Mon, 24 Jul 2000 18:49:48 -0400 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> Message-ID: <397CC80C.43F5D8@alabanza.net> Remco Gerlich wrote: > ye, wei wrote in comp.lang.python: > > I'm a programmer and have C/C++, Perl, Java, PHP experience, now I'm > > interested > > in Python now. I spent a day to learn the Python, it's a cool language, > > however I have the following > > questions: > > > > 1. Why not use {}?! > > def f: > > ... > > why not use {} like this: > > def f { > > ... > > } > > > > I'm almost couldn't bear with it?! {} is not difficult to be added, > > however it can make sure the > > logic is correct. > > Unless the braces are misplaced. Just like indentation makes sure the logic > is correct, unless it's misplaced. At least with indentation it always does > what it seems to do, braces can be visually misleading if the indentation > looks different. > > Other short answers: it saves typing, is more readable, braces aren't > necessary, they're ugly. > Perlsonally, I don't agree with you, but I can bear with the rule. > > It's just Python. > > > The other problem is if you want to added a new condition in a complex > > already existed condition statement, > > e.g. In the following example, If you want to added a new 'if' between > > line 1 and 2, you have to add TAB from Line 2 to 199, > > it's difficult to make sure you don't make mistake. (The case may be > > more complex as the example which I give). > > > > 1 if() : > > 2 if(): > > 3 .... > > .... > > .... > > 100 else: > > ... > > 200else : > > ... > > Use a good editor. It's not so hard to check if the current line lines up > with the previous one. It's not hard to indent a long C function either, > is it? I have been using 'emacs', it's a nice editor, however I still concern if add or remove a new block within a complex logic it may mess up the old application. However if {} is applied, I'm pretty sure it doesn't happen. > > > > 2. Why variable doesn't have to be declared before use? > > Because it's not necessary! I can bear the {} issue, however I couldn't bear with variable without declaration. I wrote many applications, I couldn't live without declaration. For big project, there are so many scripts, everyone may be misspell variable name. It's very timeconsume and hard to find out such problem, which should be easy checked out by compiler. > > > > Is this hard to be implemented in script language? > > No, the other way around - this is a scripting language, meant for rapid > development, least hassle for the programmer - so no need for declaration. I agree with you script language is very good at rapid development, this is why I like Perl. Java is very good language, however it takes much longer time to develop projects because it's not a script language. However I don't think "not need for decalaration" is the favor for rapid development. We used "use strict" package in every Perl script to force "variable declaration", it doesn't waste any time for development, however project is still rapid to be developed. > > Although there is work in progress on this issue - it may become optional > in the future. If you make everything strict and using { } and so on you've > just got some dialect of Objective C or Java or something... I will be very *HAPPY* if it's true!!!!! I believe Python will be much stronger and grow faster if such features are enabled. Python's goal is a simple language, which everyone can use it to write program. However it should be a good language, which can as more as possible to correct the mistake people may make. This help programmers to shorten development and testing time. > > > Also, by forcing a variable to be a certain type (like arguments to a > function) you use flexibility. For instance, many functions except to get an > open file, but if you give them some class instance that works just like an > open file the functions don't complain and just work. That's very cool, but > it wouldn't work with strict types. Yes, it is if you define a function expect a base class, its derived class object should have no problem to be passed in. Both Java/C++ have this feature. If don't specify the variable type: 1. When you read code, it's not easy for you to understand how to invoke that function. For example, compare def f(x, y, z): ... with def f(int x, complex b, Employ c): ... which declaration give you more information without read further code? You know how to invoke the latter one without read its code and comments in most cases. 2. it leads the function is mis-called by passing not correct type. Again, do you know how Perl function is defined? Just like this: sub f { ... } Without parameters as well as types. The authors tried to add some prototype checking later, but too late, that will cause imcompatible problem with existed scripts. Perl's function declaration should be more flexible, however without parameter and type checking, it's causing many problems, and couldn't be tolerated. > > > But well, why am I replying to this. You've just met some Python features > that make Python Python; we're used to them and think they're good. See for > yourself :-). Thanks! > > > I've set followup-to poster since we could continue over email, but this has > been done to death in the group already. I still would like to post it on mailinglist, hope developer team can think about it. > > > -- > Remco Gerlich, scarblac at pino.selwerd.nl > "Early to rise, early to bed, makes a man healthy, wealthy and dead." -- TP > -- > http://www.python.org/mailman/listinfo/python-list -- Sincerely, Wei Ye From ram_garapaty at spk.agilent.com Wed Jul 5 17:57:40 2000 From: ram_garapaty at spk.agilent.com (Ram Garapaty) Date: Wed, 05 Jul 2000 14:57:40 -0700 Subject: serial communication in python..?? Message-ID: <3963AF53.F16F9CAA@spk.agilent.com> Hi! i am new to python and would like to know whether python would be any assistance to my situation as described below: i got a testing box which send s out the data through a serial port, i would like to capture that data through GUI window in PYTHON . Is this possible in python if soo please suggest me the right topics in python and right material to go through python asap. thanks in advance ram From bjorn at roguewave.com Fri Jul 21 14:27:35 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 21 Jul 2000 12:27:35 -0600 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> <39779175.3F2D163B@roguewave.com> Message-ID: <39789617.793C8F9B@roguewave.com> Huaiyu Zhu wrote: > On Thu, 20 Jul 2000 17:55:33 -0600, Bjorn Pettersen > wrote: > > > >> OTOH, would you care to give a brief summary of how these other languages > >> deal with these issues? It may indeed provide valuable insight. > > > >I agree with Paul, if you want to use Matlab syntax, use Matlab. Here's > >links to APL/J info http://www.acm.org/sigapl/links.htm > > It would be great if you could summarize some of the issues concerning > treatment of multiarray in APL/J. The purpose of this discussion is for all > sides to spell out their favorite. Imho, issues that are so involved that > could not be explained here are unlikely to be suitable to go into the PEP. Personally, I can't see any advantages to APL/J, but then I'm not heavily into math. I do think that anyone who is interested in a specific domain (especially when wanting to morph Python to fit this domain) should know what the current state of the art is. It took me less than half an hour to get a good grasp of what APL/J was about, and judging from some of the suggestions in this thread we're headed in a very interesting direction. (I'm assuming it's possible to maintain APL/J programs, but I can't quite see how?) -- bjorn From hzhu at localhost.localdomain Thu Jul 20 17:57:03 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 20 Jul 2000 21:57:03 GMT Subject: Discussion: new operators for numerical computation References: Message-ID: On Thu, 20 Jul 2000 00:58:06 GMT, Tim Hochberg wrote: > >> (2) Which is matrixwise or elementwise > >I can't see a good answer here. NumPy has been around for a long time >and I believe it has a fairly large user base which is a strong >argument in favor of the ".x" operators being matrixwise. However, We may need also to consider future userbase. I would predict (but predictions are unreliable!) that a large portion of future userbase from current matlab/octave users. (See below) My own experience and bias: NumPy does not orient toward people using arrays as objects in linear space, but rather like a holder of a large amount of homogeneous data. I'd already tried to use it for a month but almost gave up. I was looking for a python-octave pathway when Konrad Hinsen suggested that a simple wrapper would achieve the goal. I would imagine the majority of people who would prefer this never actually crossed the line from matlab. One indicator of this is that when I asked about matrixwise interfaces most answers came from people who are perfectly comfortable with multiarray. But when dealing with multidiemnsional arrays the infix notation is not quite necessary nor convenient. So my point is that the portion of NumPy users who do linear algebra instead of multilinear algebra may not be that great. (You can see my bias throughout this post. Be warned.) >other operators within python (*,+) operate "objectwise" on sequences >(concatenation and replication). I think it would be suprising if >these operators were elementwise for matrices and objectwise for >other, similar, objects (sequences). This tends to favor ".x" being >elementwise. This is by far the most important point, imho. It is good for an OO language to set the default behavior as objectwise. Even if the additional operators are not be implemented on other objects, the conceptual inconsistency is still worth considering. >> (3) Compatibility: NumPy uses * for elementwise, MatPy uses * for >> matrixwise. > >Do you have an idea of what the relative sizes of the userbases of >these two packages are? Honest question -- I have no idea, but I've >been operating under the assumption that userbase of MatPy was >relatively small. I don't know how to gauge NumPy. Any ideas? For MatPy the statitics of downloading is quite small. Just over 50 for the latest version in ten days and several hundred total for all version in the one month it has been in existence. The number is largely restricted to those who read c.l.p at the time I annouce a new release, but it has got to Vault of Parnassus recently. It did not work on Windows until over a week ago. I would say that those who use MatPy even at this alpha stage are those who really need this interface, and represent a tip of iceberg of the potential users. >> (4) Similarity with Matlab (but not really compatibility). > >I think it's a mistake to look just at Matlab here. If were going to >look to matrix languages for inspriation we should look to >several. Unfortunately, I'm no help here. Well, I just did a little experiment and found that it is surprisingly easy to translate Matlab to python. The other way is of course almost impossible. After all, Matlab is such a simple language compared with Python. (I wonder why people wwould compare it to Perl. <0.8wink>) So I would consider the similarity quite important. If a matlab program consists mostly of formulas the transition is almost effortness. Once we have these operators I do not see any great hurdle for mass immigration. Any examples of how other numerical languages treat this issue? There is anothe issue. If we decide on * for elementwise operations it is best to use @* for matrix usage. Having both * and .* and let them mean exactly the oposite of matlab is really too confusing for the targeted users, several have pointed out already. > >> 3. Their behavior on other objects: >> >Note that if ".x" ends up being matrixwise, things will become >horribly inconsistent if it is later decided to extend these operators >to other sequences. This IMO is probably the strongest argument for >making ".x" elementwise. Agreed. I think these operators will not have any default meaning on objects other than numbers. However, is it allowed for non-numerical classes to use them through __atmul__? After all, there is no syntactic distinction between these classes. So what if a subclass of UserList want to have both objectwise and elementwise add? >> 5. Other bits and pieces: >> >> - How to deal with left division? >> >> (1) Use sol(a,b) >> (2) use /@ or /. >> (3) use % > >'%' is already a valid elementwise operator and to have "%" and ".%" >mean completely different things is not good, so (3) is out. > >I think (2) only makes sense if the ".x" operators are matrixwise. It >seems just too weird to have "/" be right division "/." be left >division and "./" be elementwise. It's much more sensible to have "/" >be elementwise, "/." be left division, and "./" be right division for >instance. > >If possible I would like to avoid (1). 'sol' would almost certainly be >in the a seperate module and this is potentially painful. This seems to be the best reason to use @/ and /@. But sol does not live in a different module in MatPy. Using % or | involves changing the meaning of currntly used operators. Even though the actual usage might be very small, that's still a change. If we are not going to grab ^ for pow, we probably shouldn't consider grabing % and | for sol. >> - Do we want a copy operator := which is different from =? It allows >> efficient code. The following code does not change A >> B := A >> B += C >> This definitely will be usable for other classes. Call it __copy__? > >This seems to be a general request and not particularly numeric >specific. And I don't think it adds much in the way of >functionality. I would drop this. Agreed. As someone mentioned, it's no difference from B=A.copy() > >> - Since augmented assignment almost certainly will get in the core, we >> need to consider combining them. A few possible opinions >> >> (1) Just use prefix . or @ to mean e or m, use suffix = to mean in >> place assignment, and all are well defined. >> >> (2) a .**= 3 looks too long. Don't combine them. >> >> (3) allow .+=, etc but ban .**=. > >Here I'd go with (1), consistency over beauty. Agreed. I was only worrying that someone might charge its ugly. But the fault was really in using ** for pow in the first place. >I'm not yet convinced as yet that all of these operators are needed; >the +, - and .+, .- operators are very similar in behaviour. The main >reason they are present seems to be orthogonality. I'm sure this has >been brought up before, but does MatLab have both broadcasting and non >broadcasting versions of its operators? Is it worth considering adding >only the matrix operators .*, ./, /., and(?) .** and letting NumPy/ >MatPy choose whether they wish to broadcast or not? It seems that the >difference between .* and * is different in character than the >proposed difference between .+ and +; in one it's between elementwise >and matrixwise operations, and in the second it's between broadcasting >and nonbroadcasting operations. Yes, you can think of the second in >terms of the first, but it still feels a bit forced to me. I have a different opinion. The main reason they are needed is because they are conceptually consistant. The definition of + - * / adhere strictly in accordance with linear algebra, so they will balk at the wrong dimensions. But .+ .- .* ./ are elementwise, for which the current NumPy rules make perfect sense to me: make elementwise operations, extending missing dimensions whenever necessary. Unless we change the current NumPy defaults it is consistent to have them all. And why would we change? I find a .+ b so much more reasable (and probably faster) than a*ones(size(b)) + ones(size(a))*b Just for some ideas, I have a set of operators that would satisfy most of the above need: NumPy matrix NumPy element MatPy matrix Matpy element @+ + + .+ @- - - .- @* * * .* @/ / / ./ /@ none what none @** ** ** .** This provides the smoothest migration path for all the users. Note that the cause of NumPy/MatPy inconsistency was the lack of binary operators. As this already happened, it is difficult to integrate them until both got two versions of operators. Problems: - This introduces 6+5 new operators. Ironically the previous lack of operators actually results in more operators. - Having standard + - * / mean different things in NumPy and MatPy. I personally find this no problem. In certain portions of my programs I need elementwise operations exclusively, and I found it convenient to cast everything into NumPy without trouble. - There's still no left division for MatPy. Huaiyu From bjorn at roguewave.com.bbs Mon Jul 17 19:50:01 2000 From: bjorn at roguewave.com.bbs (bjorn at roguewave.com.bbs) Date: 17 Jul 2000 23:50:01 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operatorsfo Message-ID: <3bRTZP$jrX@openbazaar.net> Huaiyu Zhu wrote: [snip] > The morale of the arguement is: requiring every syntax to be useful in every > domain is too extreme and not quite useful. But considering exactly what > the domain is and exactly how it might be used may help. I think you hit the crux of the problem. You want to add syntax that is only useful in one domain, and that is too extreme. Why don't you create a preprocessor that converts a .* b into elementWiseMultiply(a,b) and create an appropriate suffix for your matlab/python files (mpy?) It's a pretty easy thing to do, and sounds much more appropriate in this situation. -- bjorn From dworkin at ccs.neu.edu Sat Jul 8 19:40:05 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 08 Jul 2000 19:40:05 -0400 Subject: Making tabs illegal In-Reply-To: Matthew Schinckel's message of "Sat, 8 Jul 2000 14:21:06 +0930" References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: Matthew Schinckel writes: > I hate having to hit space four times, I'd much rather just use tab. You should get a decent editor. -Justin From andres at corrada.com Thu Jul 13 15:07:29 2000 From: andres at corrada.com (andres at corrada.com) Date: Thu, 13 Jul 2000 15:07:29 -0400 Subject: INPUT TYPE=file in HTML In-Reply-To: ; from Jocelyn Paine on Tue, Jul 11, 2000 at 06:41:42PM +0100 References: Message-ID: <20000713150729.B13439@corrada.com> On Tue, Jul 11, 2000 at 06:41:42PM +0100, Jocelyn Paine wrote: > > The field is inside a form whose HTML arguments are just ACTION and > METHOD, nothing else. The field has a TYPE argument whose value is "file", > and a NAME attribute. And this combination of field and form works OK if I > use it to pload a file to a Perl CGI. > I would guess that you do not have ENCTYPE="multipart/form-data" set in your FORM tag. If this is missing, a tag is treated as just a normal tag and the only thing you get is the name of the file sans its contents. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From paul at prescod.net Mon Jul 3 14:57:14 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 03 Jul 2000 13:57:14 -0500 Subject: OO References: <8jb1ec$9mh2@news.qualitynet.net> <8jpvhi$jfs$1@newshost.accu.uu.nl> <20000703171722.A7614@bork> Message-ID: <3960E20A.4BA7AF49@prescod.net> Egbert Bouwman wrote: > > ... > > Actually a great eye opener was the remark in this list a few days ago, > when someone said that you use classes when you have to combine > program and data, and functions when you have only program code. Let me be more explicit about this. Classes are important when you want behavior to travel *with* the data. Procedural and functional styles are used where you want to impose behavior on "dumb" data. Real programs tend to use both styles. Often a procedural model is used to get data into the program where you combine the data with behavior in objects. When the behavior travels with the data (as methods), you can fiddle with the data without thinking much about its underlying implementation (through the methods). Therefore that underlying implementation can be really, really complex or really really simple and you don't care. It can also change between versions of the module and you still don't care. That's the encapsulation part of OO. You can actually do this pretty easily just with just functions (not methods), using a style of programming like this: obj=CreateNewObject() behavior1( obj, param1, param2, param3, ...) behavior2( obj, param1, param2, param3, ...) behavior2( obj, param1, param2, param3, ...) There are lots of APIs written in this style in non-OO languages. This is encapsulation (whether done in an OO language or not) The "polymorphism" part of OO comes from the fact that once you have an object, you can work on its methods without knowing exactly what kind of object you have. The Python library has lots of good examples of this but here's a beautiful example: class myOutputClass1: def write( self, data ): ...write it to a GUI window.... class myOutputClass2: def write( self, data ): ...write it to a log .... class myOutputClass3: def write( self, data ): ...send it via email to Bill Gates.... Now I can say sys.stdout=myOutputClass1() and hundreds of pieces of code that were supposed to work on the stdout "stream" will magically work on myOutputClass. When they say: sys.stdout.write( "foo" ), it calls the appropriate write method. The fact that it has the right methods is enough to make it "stand in" for a stream. This is much harder in a non-OO language because you have to "fake" the objects carrying around their behavior as methods. I think that polymorphism is really the heart of OO in Python. It's so important that some separate it out from the other OO stuff and just call it "genericity." The third part of OO is most emphasized in most non-Python languages: inheritance. Inheritance is a way of extending existing objects so that you do not have to write all of that code over again. In other languages, inheritance takes on some more mystical properties for the type system, but you could be a decent Python programmer and only use inheritance very, very rarely. According to the powers that be, these are the three main features of OO: encapsulation, polymorphism and inheritance. -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From aahz at netcom.com Mon Jul 31 16:16:18 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 20:16:18 GMT Subject: check file exists References: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: <8m4mqi$c2t$1@slb6.atl.mindspring.net> In article <3985DDA3.E811F70A at ncsa.uiuc.edu>, Randy Heiland wrote: > >How does one test for whether or not a (Unix) file exists? Check the os and os.path modules. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From cut_me_out at hotmail.com Tue Jul 4 11:41:33 2000 From: cut_me_out at hotmail.com (Alex) Date: 04 Jul 2000 11:41:33 -0400 Subject: Problem with dynamically linked extensions that use Numeric References: Message-ID: Just to follow up here, the problem was pointed out by Paul Dubois in another thread -- I need to do an import_array (); after the Py_InitModule. Alex. From rumjuggler at cryptarchy.org Thu Jul 20 18:51:20 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Thu, 20 Jul 2000 22:51:20 GMT Subject: zip() : how about braid() References: <397746c9.39446991@news.iol.ie> Message-ID: On Thu, 20 Jul 2000 21:22:02 +0100, Robin Becker wrote: >In article <397746c9.39446991 at news.iol.ie>, Sean Mc Grath > writes >>>I think merge makes sense, >>>(and I don't really have a problem with zip()), but the metaphor that >>>most closely resembles what it does is braid(), as in hair.. >>> >>Two suggestions: >> 1) raff >> 2) twingle >> >>"raff" is an invented verb form of "raffia", fibers of which are used >>to weave hats, baskets etc. (Spot the Monty Python >>connection?) >> >>"twingle" just sounds beautiful... >... >this thread is getting silly :) soon someone will mention Hitler :( That's precisely what it should be called! From neilh at scintilla.org Sun Jul 16 20:34:22 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 17 Jul 2000 00:34:22 GMT Subject: "Intellisense" drop-down... References: Message-ID: > Here it is, folks, the ability to use another key than TAB to select a word > in the AutoComplete list: I like it - good to see someone new improving PythonWin. A small problem with Ctrl+Enter is that it works in the editor but not the interactive window. Neil From olipt at mayo.edu Fri Jul 21 18:34:39 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Fri, 21 Jul 2000 17:34:39 -0500 Subject: [long and fussy] But what do these operators _mean_? In-Reply-To: References: <8l899g$6f5$1@agate.berkeley.edu> <8la3bo$b55$1@agate.berkeley.edu> Message-ID: > > - >Quick summary: Maybe there needs to be a numerics-sig before any > > - >of these changes are adopted... > >So how do we get one started? > > Good question. Any volunteers? The discussion list at SourceForge for Numeric Python is a perfect place for these discussions. > I would still think that's mainly caused by matlab's monolithic nature. > Python with its clean namespace separation would greatly minimize this risk. > > Here's my idea of "grand unification of numerical computation in python" :-) > > There are many packages that implement various numerical routines. They are > closely related to lapack, linpack, eispack, cephes or whatever names their > underlying fortran or C packages have. > > There are also several interface packages, which implements the interfaces > that emphasize multiarray or matrix algebra or other specific conveniences > like sparse matrices, etc. > > They are designed in such a way that users can easily assemble numerical > pacakges that has given guaranteed performance with desirable interface. > The advantage of separation of implementation from interface is that it > gives much more choices to the users without increasing the load on > developers. > > There can be also one or two assembled packages for dummies-only, with the > easiest interface and most foolproof implementation. > > How's that for a long term project? :-) > This is THE SAME long term project that PyLab represents (it is only a loose collection of packages at http://oliphant.netpedia.net at the moment due to my time constraints). In a broader context, NumPy was written with this express purpose in mind --- adding mathematical toolboxes to Python. Peauru Peterson and Paul Dubois both wrote automatic Fortran parsing tools to help in this work. If we are really going to attract developers, I'd argue we need toolboxes and easy help documentation, over specific syntax. People can get over at-first-awkward syntax easily, but it's a harder sale when you keep having to tell them that they will have to "roll-their-own" solution to implement this or that functionality. -Travis From ssthapa at midway.uchicago.edu Wed Jul 5 14:22:43 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Wed, 05 Jul 2000 18:22:43 GMT Subject: Random number generation, simple question. References: Message-ID: Kalle Svensson wrote: >Hello. > >I have a few questions about the (pseudo) random number generator supplied >in the standard library. I need 80 random bits (for a CipherSaber IV) but >I hear most RNG's only supply 32 bits or less. My questions are: > > * How many random bits does whrandom.random() generate? > > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? This may not be entirely wise. An psuedo-random number generator eventually cycles and starts repeating. The problem is that the seed supplied to the prng affects how quickly it loops and the distribution of the numbers the prng generates. If you feed random numbers into the prng youo could end up with weaker encryption than you think. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From bjorn at roguewave.com Thu Jul 27 14:00:02 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 27 Jul 2000 12:00:02 -0600 Subject: Python is wierd! References: <8lk1c5$fv4$1@nnrp1.deja.com> <8llqkl$rof$1@nnrp1.deja.com> <397FC213.88603B9E@see.my.signature> Message-ID: <398078A2.6B8196AD@roguewave.com> David Bolen wrote: > > Greg Ewing writes: > > > And to answer your question, yes, you can create an instance > > variable at any time simply by executing "instance.name = value". > > Which actually leads to an interesting question relating to a point > that I'm curious how others handle. > > If I'm going to package up some state (various bits of information) > into a class (aka using one as a structure - data only), one approach > could be to define an empty class: > > class MyInfo: > pass > > and then whenever I need to later: > > newstate = MyInfo() > newstate.variable = value > newstate.other_variable = value [snip] Whenever I feel the need to do something like this I use a dictionary instead... -- bjorn From heath7952 at my-deja.com Wed Jul 5 12:29:51 2000 From: heath7952 at my-deja.com (heath7952 at my-deja.com) Date: Wed, 05 Jul 2000 16:29:51 GMT Subject: Wanted: compile.py Message-ID: <8jvnp5$f4r$1@nnrp1.deja.com> Does anyone have a copy of compile.py referred to in the "Python Building C/C++ extensions documentation". I can't reach the website, or find it elsewhere. Thanks in advance. Heath. Sent via Deja.com http://www.deja.com/ Before you buy. From johnvert at my-deja.com Sun Jul 9 14:58:23 2000 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Sun, 09 Jul 2000 18:58:23 GMT Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> <87zonvso9c.fsf@cachemir.echo-net.net> <71vfmsc0sspvpg3mq8k3s1ri653908u9nk@4ax.com> <396863B7.875EA939@stroeder.com> Message-ID: <8kai0a$7g6$1@nnrp1.deja.com> In article <396863B7.875EA939 at stroeder.com>, Michael =?iso-8859-1?Q?Str=C3=B6der?= wrote: > Tim Roberts wrote: > > > > I'll say. Am I correct in understanding that the basic purpose of > > "mod_snake" is to allow me to write other Apache modules in Python, while > > PyApache is a module which lets me run Python CGI scripts without > > launching a separate interpreter, > > Yes. PyApache resets the Python interpreter everytime which leads to > reloading of the modules for every hit. > > With mod_python you can write Apache handlers but also wrap normal > CGI-BIN scripts without having to reload the modules for every hit. > > Ciao, Michael. Which one of these modules can you use to write embedded python code? I.e. foo.html.py: Looping through red, blue, green: colors = ['red', 'blue', 'green'] for color in colors: print color Thanks, -- John Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Sun Jul 2 08:31:15 2000 From: cut_me_out at hotmail.com (Alex) Date: 02 Jul 2000 08:31:15 -0400 Subject: Problem with dynamically linked extensions that use Numeric Message-ID: Hi. I have been writing an extension that uses the Numeric API. Up until now, I have just been building it straight into python, and it's working fine. However, I want to make it more widely available, so I need to make shared objects from it. The problem with that is that it segfaults. Here is a small piece of code that demonstrates the problem I am having: /////////////////////////////////////////////////////////////////////////////// #include "Python.h" #include "arrayobject.h" PyObject *test_array_test (PyObject *self, PyObject *args) { PyObject *t; int dimensions[2], i; if (!PyArg_ParseTuple (args, "")) { return NULL; } dimensions[0] = 10; dimensions[1] = 12; for (i=0; i < 20; i++) { printf ("testing\n"); t = PyArray_FromDims (2, dimensions, PyArray_INT); } if (!t) { return NULL; } return t; } static PyMethodDef Test_ArrayMethods[] = { {"test", test_array_test, METH_VARARGS}, {NULL, NULL} }; void inittest_array () { (void) Py_InitModule ("test_array", Test_ArrayMethods); } /////////////////////////////////////////////////////////////////////////////// I compiled this using the 'make -f Makefile.pre.in boot' method. Here were the commands make generated: [alex_c at puffin blast]$ make test_arraymodule.so gcc -I/scratch2/alex/include/python2.0/Numeric -g -O2 \ -I/scratch2/alex/include/python2.0 \ -I/scratch2/alex/include/python2.0 -DHAVE_CONFIG_H \ -c ./test_arraymodule.c gcc -shared test_arraymodule.o -o test_arraymodule.so This code segfaults when it hits the line 't = PyArray_FromDims (2, dimensions, PyArray_INT);' But when it's compiled directly in to python (i.e., I move the file into the Modules directory of the python source, and add a corresponding entry in the Setup file,) it works fine. I'd be grateful for any ideas as to how to get this to work. Alex. From nobody at nowhere.nohow Fri Jul 28 21:26:21 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:26:21 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> <3981BE50.23DB16C5@infercor.no> <8lsu2a02ho4@news2.newsguy.com> Message-ID: In article <8lsu2a02ho4 at news2.newsguy.com>, Alex Martelli wrote: >7 bits and up, anything goes. But everything else's size (except >for bit-fields, a peculiar oddity) is a multiple of char's size, >so the latter's size is often called a 'byte' (which need not be >the same thing as an 'octet', though it often is:-). And all hell generally breaks loose when it isn't -- especially when two programs are communicating and they have differing defintions of how many bits there are in a byte. But that's a whole different rant. -- Grant Edwards grante Yow! I wonder if I ought at to tell them about my visi.com PREVIOUS LIFE as a COMPLETE STRANGER? From jim at digicool.com Tue Jul 11 17:46:38 2000 From: jim at digicool.com (Jim Fulton) Date: Tue, 11 Jul 2000 17:46:38 -0400 Subject: POOP / Python (Object Oriented Persistence) ? References: <003001bfeb2f$99f60250$f0c809c0@lslp7o.lsl.co.uk> <3dzonozm72.fsf@kronos.cnri.reston.va.us> Message-ID: <396B95BE.25F9646D@digicool.com> Andrew Kuchling wrote: > > "Tony J Ibbs (Tibs)" writes: > > OK - I've lost one snag, so here's a new one (although much less > > important) - it's not clear (from the web pages) how to install the ZODB if > > one *doesn't* care about Zope in general - *presumably* one has to download > > the standard Zope distribution and just answer some questions? > > I've submitted setup.py scripts that use the Distutils to install just > ExtensionClass, or just the ZODB, and makes it pretty easy. Brian > Lloyd at Digicool, who's responsible for Zope releases, has said that > the scripts will get looked at after Zope 2.2final ships; I'd guess > that will happen in a week or so. I'm pushing hard to get the ZODB > packaged separately, because it'll be hard to use in Python > applications if you can only get it by downloading all of Zope. FWIW, we want to see ZODB packages separately too. Soo much to do, so little time. Waaaaaaaa. > > I still think someone should be pushing this more... > > Agreed; the ZODB is really quite cool! At work we're beginning to use > ZODB for storing business-related objects, and it's an interesting > learning experience. The major issues so far are: > > 1) lack of documentation, particularly for various advanced > properties of the ZODB. Sigh. > 2) the use of ExtensionClass means that the standard Python > isinstance() doesn't work any more, so you need to use a > modified version. FWIW I provided a patch to isinstance to make it work with ExtensionClass and AFAIK, the patch got checked in, so isinstance should work with ExtensionClass in the next release of Python and in the Python CVS. > We've also hit things like ExtensionClass > not supporting __radd__; the resulting symptoms are often > mysterious and it's time-consuming to pin down what the > problem is. Yes, unfortunately, the numeric protocol is a weakness because it's hard and because we (Zope) don't rely on it much. I'd love to see it improved. For that matter, I'd love to see some future release of Python render ExtensionClass unnecessary. > 3) lack of an easy installation method, which is why I wrote > the setup.py scripts. Thanks. :) Jim -- Jim Fulton mailto:jim at digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From anders.eriksson at morateknikutveckling.se Mon Jul 31 06:15:30 2000 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Mon, 31 Jul 2000 12:15:30 +0200 Subject: smtplib and cgi Message-ID: Hello! Is it possible to use smtplib to create and send mail from a CGI application? Or is there some better way? // Anders From bjorn at roguewave.com Tue Jul 25 11:52:38 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 25 Jul 2000 09:52:38 -0600 Subject: Searching a binary file References: <397C8195.E7DA03A3@roguewave.com> Message-ID: <397DB7C6.1BD84D5A@roguewave.com> luthi at vaw.baug.ethz.NOSPAM.ch wrote: > > Thank you for your reply. This is obvious, but it won't work on large files > (exceeding memory). This is why I read the file in chunks and searched these > chunks. How should I choose the size of these chunks? Well, that depends on your memory . I've got 256Mb on my desktop, so I tend not to worry about it ;-) > Is there a speed issue using string.find() or the regular expression search()? string.find() is faster (sometimes much faster). -- bjorn From hopper at omnifarious.mn.org Tue Jul 18 20:14:07 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Tue, 18 Jul 2000 18:14:07 -0600 Subject: Does Python support interfaces? References: <8l2i4101pon@news2.newsguy.com> Message-ID: <3x5d5.1596$6E.309563@ptah.visi.com> In article <8l2i4101pon at news2.newsguy.com>, "Alex Martelli" wrote: > > Yep, it is exactly what C++ does in its templates. Of course, they're > resolved at compile-time in C++, but then Python is not about > compile-time vs run-time distinctions, is it? I know. It's what I dislike about templates in C++. An occasional project of mine is wrapping all of the silly STL things in a properly defined interface hierarchy to both avoid all that extra code being generated for new types, and so STL is, IMHO, conceptually cleaner. > See Austern's excellent book on Generic Programming (and, also, on the > STL) about the GP metaconstruct he calls "concept", and how and why it's > not modeled by inheritance even in C++. The compiler cannot diagnose > many kind of concept-violations anyway (they're deeply semantic, e.g., > the concept that a certain function imposes a strict weak ordering) so > little is really gained by compile-time checks. Now, this is a worthwhile suggestion. Thanks! Maybe (s)he'll be able to change my mind. :-) I agree about the concept violation problem. I mostly think that interfaces make a nice form of enforced documentation, and reduce code bloat in languages with static type checking. -- Eric Hopper http://www.omnifarious.org/~hopper From Jelske.Kloppenburg at gmd.de Thu Jul 6 07:20:39 2000 From: Jelske.Kloppenburg at gmd.de (Jelske.Kloppenburg at gmd.de) Date: 6 Jul 2000 11:20:39 GMT Subject: Compiler switches for install In-Reply-To: <8jvi1j$412$1@hop.gmd.de> References: <8jvi1j$412$1@hop.gmd.de> Message-ID: <8k1q27$62l$1@hop.gmd.de> On 07/05/00, Jelske.Kloppenburg at gmd.de wrote: >... additional compiler >and/or >linker options are required." > >Where, how and when can I set the options? > I did it. You don't need to answer. j.k. -- Jelske Kloppenburg, +49 2241 14-2433, GMD - German National Research Center for Information Technology From mkrisch at netscape.net.bbs Mon Jul 17 23:20:07 2000 From: mkrisch at netscape.net.bbs (mkrisch at netscape.net.bbs) Date: 18 Jul 2000 03:20:07 GMT Subject: hexidecimal output as default? Message-ID: <3bRZA7$j9m@openbazaar.net> how can i make it so the interpreter defaults to hexidecimal output? what i mean is the following: >>> i = 0xa >>> print i 10 >>> i 10 what i really want is to get the following: >>> i = 0xa >>> i 0xa --mk Sent via Deja.com http://www.deja.com/ Before you buy. From johannes at zellner.org Sun Jul 9 15:07:00 2000 From: johannes at zellner.org (Johannes Zellner) Date: Sun, 9 Jul 2000 21:07:00 +0200 (CEST) Subject: Static member variables In-Reply-To: <8kahdq$5e2$1@zingo.tninet.se> Message-ID: On Sun, 9 Jul 2000, Thomas Svensson wrote: > Hello, > > Is there a way of declaring static (and constant) member variables in > classes? I have a member variable that should be unique for each class > type and thus should not waste memory for each instance of the class I > create. Something like the __doc__ string I guess. const is not possible, it's up to you not to modify your variables. static is possible see this example. The class variable (static in C++ jargon) is named with the class name: `Fred.count' class Fred: count = 0 def __init__(self): Fred.count = Fred.count + 1 def instances(self): return Fred.count x = Fred() print x.instances() y = Fred() print x.instances() z = Fred() print x.instances() -- Johannes From olivierS.dagenaisP at canadaA.comM Sun Jul 16 12:03:44 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 16:03:44 GMT Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> Message-ID: VB's IDE is more than just a text editor. Every line is checked for syntax errors and I think compiled in the background. Of course no other editor could be as good, unless they also had access to the VB compiler/debugger. Using VC's autocompletion/intellisense, you can get similar results to VB, so something like this can be done for any language, that is correct, but not to the extent where the editor is also a compiler. It may not be all that hard to implement self-correction and syntax checking in Python, since we have "exec", but you are right: without variable declarations this can prove to be difficult. Maybe whoever implements a self-correcting/syntax checking IDE for Python should enfore a convention for "declaring" the variables, without affecting the language itself. Something like this, for example: (I'm new to Python, so please excuse the big fat mistakes I might have made) def SpamWindow ( ): " Will draw the value of m_Spam to the DC associated with the current window handle " # var m_Spam, m_hWnd, m_hDC m_hWnd = GetCurrentWindowHandle ( ) m_hDC = GetDCFromhWnd ( m_hWnd ) m_Spam = m_Spam + 42 DrawToDC ( m_hDC, m_Spam ) DestroyWindow ( m_hWnd ) Where the variables are declared in the form of a comment that starts with the letters "var" which, I think, is how JavaScript declares variables, isn't it? So, by having a line at the beginning of a function (right after the description line, which I hope I didn't screw up) indicating the names of the variables we intend to use, any name that isn't in that list and isn't in anything we imported would be highlighted as a mistake, and if only the case differs, the editor would make the case match the declaration... Naming conventions are great, but also impossible to get everybody on earth to accept (and use) them, unless your language enforces it, primarily because we tend to think different, the latter being a wonderful thing! So your naming convention is probably wonderful, but maybe also different than that of a third party, whose module you want to use.... Come to think of it, I don't think I have a problem with the language being case-sensitive. I have a problem with the editor making me think about a detail that I have come to not have to worry about by using VB. VB may or may not be case sensitive, I wouldn't really know, but what's great is that I don't have to worry about it. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Anders Eggers-Krag" wrote in message news:o8kc5.203$rg.9815 at news101.telia.com... > I know that the VB IDE does this, but that is exactly because Microsoft > realised > that case sensitivity has advantages, and then they enforced case > sensitivity in a > way that is, agreed, in many ways smart. The real problem in Python does not > occur because of case sensitivity it occurs because you do not need to > declare > your variables. Case sensitivity is a good way way to keep the same case > across > different development platforms - the VB concept only works because if you > write > VB you use Microsofts VB IDE, not Ultra Edit, Emacs, notepad, Borland, you > name it. > Mircosofts system enforces IDE monopoly, which is anoying since I do not > like the Visual > studio IDE, I strongly prefer Borlands, or even better Ultra Edit. > > And the VB IDE concept could easily be implementet in a case sensitive > language as well. > > And one more thing, you do not need to remeber the case of any single > variable if you keep > a strict definition of how case should be used: in my case all new words > start with capital, > except the first word of a property, method or simple type - that way I am > never in doubt > as to 1: what type I am dealing with, 2: never in doubt as to what the case > is suposed to be used... > > -- > Anders Eggers - Krag > From greg at perceval.be Fri Jul 14 05:30:49 2000 From: greg at perceval.be (Gregoire Welraeds) Date: Fri, 14 Jul 2000 11:30:49 +0200 (CEST) Subject: calling .exe inside a .py? In-Reply-To: <8kl6jg$v13$1@nnrp1.deja.com> Message-ID: In reply to the message of shindich at my-deja.com sent on Jul 13 (see below) : > Try this: > > import os > os.execl ('foo.exe') execl is kind of alias for execv. So using this solution, be aware of the following: execv (path, args) Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows. This mean tha if you have the following code in a file: import os os.execv("/bin/ls",("ls","/")) print "Done!" Last line will never be executed because the python process is replaced by the /bin/ls command. To avoid this, Unix allows you to use the fork system call : import os i= os.fork() if i != 0: os.waitpid(i,0) # wait for the child to complete. print done! else: # child process os.execv("/bin/ls",("ls","/")) An other and easier solution which also works under Windows : import os os.system("foo.exe") print 'Done!' Sincerly yours -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Thu, 13 Jul 2000 shindich at my-deja.com wrote: > Date: Thu, 13 Jul 2000 19:51:21 GMT > From: shindich at my-deja.com > To: python-list at python.org > Newsgroups: comp.lang.python > Subject: Re: calling .exe inside a .py? > > In article <8kl527$tke$1 at nnrp1.deja.com>, > level2junkie at my-deja.com wrote: > > Does anyone know how to call an .exe file from inside a .py file? > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > Try this: > > import os > os.execl ('foo.exe') > > For more info read http://www.python.org/doc/current/lib/os-process.html > > Regards, > > Alex Shindich > http://www.shindich.com/ > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > > From collins at manhattan.aero.org Tue Jul 11 10:57:45 2000 From: collins at manhattan.aero.org (Jeff Collins) Date: Tue, 11 Jul 2000 07:57:45 -0700 Subject: [ANN] Python port to Palm Pilot In-Reply-To: <8kf8h9$ica$1@nnrp1.deja.com> References: <200007070140.SAA31035@wd264.aero.org> <200007101546.IAA09887@rushe.aero.org> <14698.38478.979087.248189@malibu.aero.org> <8kf8h9$ica$1@nnrp1.deja.com> Message-ID: <14699.12567.758815.250905@malibu.aero.org> Tom Smith writes: > So, forgive my ignorance, what exactly does palmPython (snigger) do? Currently the very little integration with the palm environment - stdout,stderr print to the screen and the input comes from pre-compiled modules. This will, of course, change. For the time being, when the development environment is installed, applications can be created from python modules in a manner analogous to python's freeze mechanism. The resulting application, in combination with the python vm (pylib.prc) can be run on the palm. > > I too installed before reading any docs, ran it...thought I'd crashed > it, then typed ... > print "testeroony" > ..and it went away and ran some tests... Soon, there will be a front-end for interactive use. Jeff From mskott at image.dk.bbs Sun Jul 16 11:10:03 2000 From: mskott at image.dk.bbs (mskott at image.dk.bbs) Date: 16 Jul 2000 15:10:03 GMT Subject: Imports in classes?? Message-ID: <3bQQXR$jK5@openbazaar.net> Hi Im currently writing a database applikation using Python and PostgreSQL. Because I need both a GUI and a web interface i have chosen to divide the program in three classes (and files): one containing my database queryes and one for each interface type. But where would be the right place to import my database connection module (pygresql)? In each interface file or in the query file? I guess both solutions would would work, but what would be the "right thing"? -- Martin Sk?tt mskott at image.dk Believe nothing no matter where you read it or who has said it, not even if I have said it, unless it agrees with your own reason and your own common sense. --Buddha From neilh at scintilla.org Wed Jul 12 07:59:08 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 12 Jul 2000 11:59:08 GMT Subject: Extending PythonWin References: <396c4f8a.787419228@news.online.no> Message-ID: > 2. Make some system so that users could make small scripts/modules > appear in the menues etc. I`d like to have a code revision system for > instance, and if there were a simple way of making modules available > from inside PythonWin, this could be done in a snap. ( For experienced > programmers that is. ;-> ) You can add items to the Tools menu. In regedit, find (substituting your version of Python for 1.6) HKEY_CURRENT_USER\Software\Python 1.6\Python for Win32\Tools Menu There is a list of numbered keys. Create a new key one larger than the last. Change the (Default) value of this key to the name you want as the command. Add a "Command" string value to the key. Edit the value of the Command value to be some arbitrary Python code. Remember ';' can be used to separate multiple statements. Start PythonWin and the new command will be present in the Tools menu. There is also a GUI for this in the Tools Menu pane of the Options Dialog but it doesn't always work. Neil From bjorn at roguewave.com Thu Jul 20 16:50:43 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 20 Jul 2000 14:50:43 -0600 Subject: Checking for end of a file References: Message-ID: <39776623.5B245EF5@roguewave.com> CB wrote: > > If I'm iterating through a text file, reading one line at a time within a > while statement, how do I check for the end of file. I tried while > filename.eof and filename.eof() but to no avail? > > Colin The two standard idioms are: f = open(...) for line in f.readlines(): and while 1: line = f.readline() if not line: break The second one works by the fact that f.readline() returns '\n' for empty lines and '' (the empty string, aka false) when reaching the end-of-file. I'm-not-even-going-to-try-to-defend-while-1'ly y'rs -- bjorn From jdub at nospam.net Tue Jul 11 15:35:31 2000 From: jdub at nospam.net (someguy) Date: Tue, 11 Jul 2000 15:35:31 -0400 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> Message-ID: <8kft65$rnc$1@news2.acs.oakland.edu> Drive letters could easily be enumerated using com & following the VB Script examples, only substituting python instead. Drive letters aren't a cross platform concept. I know of no native Python functions to perform this action. -Jay R. Wren "Lars Lundstedt" wrote in message news:8aKa5.485$652.11285 at newsc.telia.net... > The subject line says it all. How do I do it? > Anyone who knows? > > /LasseLu > > From ge at nowhere.none Fri Jul 14 11:50:47 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 14 Jul 2000 15:50:47 GMT Subject: raw socket exapmle? References: Message-ID: In article , Grant Edwards wrote: >Does anybody know where I can find an example of how to >send/receive raw Ethernet frames? The C examples I've found >use either AF_INET/SOCK_PACKET or PF_PACKET/SOCK_RAW. > >The socket module doesn't support SOCK_PACKET or PF_PACKET, so >I'm trying to use AF_INET/SOCK_RAW. I can't figure out the >format of the address string to pass to bind() to select the >ethernet interface to use. After looking at the source code for the socket module in 1.52 and 1.6a2, it doesn't look like either RAW or PACKET sockets are supported. Darn. Maybe I'll work on that. It should be pretty trivial to add for Linux. Does Win32 support any type of raw access to Ethernet devices? -- Grant Edwards grante Yow! I have the power at to HALT PRODUCTION on all visi.com TEENAGE SEX COMEDIES!! From hinsen at cnrs-orleans.fr Fri Jul 28 08:32:25 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 28 Jul 2000 14:32:25 +0200 Subject: [Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> Message-ID: Peter Schneider-Kamp writes: > I like the idea of an open letter to CNRI expressing the concern of the > Python Language Community. It cannot hurt to have them know what we feel > about the issues at hand. Unfortunately, as Martijn observed, the issues Looks like a good idea, count me in. Perhaps it would also help to add Python-based projects that are administrated by the people who sign the letter, to show that serious users are concerned and not just people who love signing open letters. And you can add me to the list, of course. > P.S.: > I find it rather startling that you see a need to change the license of > a software whose development already has moved away from your institution. I would rather not mention this issue. If the move to BeOpen is the reason for CNRI's prolonged legal fight, then it's better not to point it out again. And if it isn't, it's better not to suggest a new argument to them. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From richard_chamberlain at ntlworld.com Tue Jul 11 00:48:41 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Tue, 11 Jul 2000 05:48:41 +0100 Subject: Looking for a tree widget with control of text color References: Message-ID: Hi Tom, If you look in your python directory under tools you should see idle, in there is TreeWidget.py. It would be no problem getting Tkinter to do what you want but it would take a bit of effort on your part. Richard Tom wrote in message news:SMta5.147482$7o1.3697839 at news2.rdc1.on.home.com... > > Is there a tree widget for wxPython or TKinter that support setting the text > color (foreground or background) for each node? > > Ideally it could also be updated dynamically. > > I heard that there is a good tree widget in IDLE, called TreeWidget, but I > can't find it. Do I have the name right? I found the IDLE source code in > with the Python 1.5.2 source code but there was nothing called TreeWidget > there. > > Thanks, > > Tom. > > > From gmcm at hypernet.com Mon Jul 10 14:49:47 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 10 Jul 2000 18:49:47 GMT Subject: PythonService file creation References: <8kbel1$qrp$1@nnrp1.deja.com> Message-ID: <8F6D93D27gmcmhypernetcom@199.171.54.154> Dale Burnett wrote: >When running my app at the command prompt using the debug option I can >create a new file and write to it. When the app is started via Control >Panel/Services the file is not created and written too. I have used the >python native file functions and the NT api CreateFile() function. I >have tried running the service using the System Account with Interact >with Desktop checked and specifying an account. >Any suggestions? Besides the account it's running under, the only other problem I can think of is relying on some (mistaken) notion of what the current directory is. I've written files from services, so I know there's no showstopper. - Gordon From phil at geog.ubc.ca Fri Jul 21 15:45:26 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 21 Jul 2000 12:45:26 -0700 Subject: [long and fussy] But what do these operators _mean_? References: <8la3bo$b55$1@agate.berkeley.edu> <8la635$bff$1@agate.berkeley.edu> Message-ID: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) writes: > And Phil Austin writes: > - Any topic related to numerical methods and Python would be within > - the domain of that list. > > Hmm? Even if they have little to nothing to do with numpy? I > figured people would be as picky with list names as they are > with operators. ;) > Obviously I can't speak for the list, and it may turn out that Numerical Python != numpy, but since it's a descendent of matrix-sig, I'd say it inherits the domain of its parent (which a scan of the archive indicates was pretty far-ranging). Phil From steffen.ries at sympatico.ca Sun Jul 30 08:48:18 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Sun, 30 Jul 2000 12:48:18 GMT Subject: Find where you left off... References: <397F7BF5.F4A0138D@yahoo.com> <39831297.36F7C5C2@yahoo.com> Message-ID: Paul Winkler writes: > Toby, Alex, and Quotemaster: > > Thanks for the comments. > It seemed like a good idea at the time. :) > > I think I will use emacs bookmarks instead, sounds like a better > general solution. Thanks Toby! You may want to look at the 'desktop' package as well (C-h C-f desktop-save), which allows you to store state automatically and resumes *all* files where you left them... hth, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From olivierS.dagenaisP at canadaA.comM Sat Jul 22 11:25:05 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 22 Jul 2000 15:25:05 GMT Subject: Newbie question, Getting Started? References: <8lbtqg$2drj$1@earth.superlink.net> Message-ID: I also come from a VB background, and I have chosen to use wxPython for my GUI: http://www.wxpython.org Also, to see how wxPython compares to Tkinter: http://www.faqts.com/knowledge-base/view.phtml/aid/3565/fid/473 I've never used Access per say, but I have used some ADO with the Jet Engine. For my database, I think I will use Gadfly: http://www.chordate.com/kwParsing/ As for deployment, a solution that's recommended all the time is: http://starship.python.net/crew/gmcm/distribute.html ...but you don't need to worry about deploying until you're done, unless you have testers... (This "coming from VB" type of question should probably be in the FAQ or a tutorial. The only question that is sort of close to this is http://www.faqts.com/knowledge-base/view.phtml/aid/3243/fid/199 Maybe, one day, I'll write a tutorial on "switching to the light side") -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III wrote in message news:8lbtqg$2drj$1 at earth.superlink.net... > Hello all, > > I've done some programming with MS Access and Excell Visual Basic, but > am new to Python. I've been reading the tutorial for several days now and am > having difficulty figuring out where to start. For example, where do I write a > simple MessageBox program? > > Can I write Python 1.5.2 or Tcl executable programs that can be run on > a PC that does not have python installed? > > Thanks for your time, Al > > (The only stupid question is the one not asked.) From danny at thrud.anatomy.usyd.edu.au Fri Jul 7 10:58:33 2000 From: danny at thrud.anatomy.usyd.edu.au (Danny Yee) Date: 8 Jul 2000 00:58:33 +1000 Subject: ISO Latin -> HTML conversion Message-ID: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> I need to convert text with ISO Latin characters to HTML, e.g. I want to map ? to é and so forth. I can do this by reading in a wopping big file ('?', 'À'), ('?', 'Á'), ('?', 'Â'), ('?', 'Ã'), . . and then going for pair in fix_list: line = re.sub(pair[0], pair[1], line) as I read each line... but there has to be something quicker than that, surely. Is there a fast way to do this? Danny. From rloisel at helicon.net Sun Jul 23 10:13:39 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Sun, 23 Jul 2000 10:13:39 -0400 Subject: IDLE window disappears on startup References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> Message-ID: <397AFD92.7F17FFD1@helicon.net> All the python programs fail. Just a flash of a window. There is no idle.py in the idle directory , just a idle.pyw with a comment (no console) . Even my 'Hello' program won't run by clicking on the icon. All I can do with python is to use the start-> etc. >click on Python1.5 and get a generic window with no shell feature and do line by line scripting. Also I can do run python from the 'run' box and that indicates that the path is okay. import Tkinter works - so that is functional. Why would there be a missing file or library if I just dl's this program for the python web site. You also didn't say how to change the DOS 'close on exit' if that's the problem... thanks for the reply. Olivier Dagenais wrote: > Your DOS window is probably set to "Close on exit" (hence you don't see the > reason for the failure). Open a DOS prompt, navigate to the directory where > idle.py is, type "python idle.py" and if an exception is thrown, it should > appear right after that command. > > It might be that you're missing a module, like TCL or something... > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Rodney Loisel" wrote in message > news:397A3EEA.792BDDEB at helicon.net... > > New to Python but not script programming. W98 Python 1.5.2b > > First tried clicking on the idle.pw and idle.pwc icons and a window > > pops up and immediately disappears. Then tried: > > start->run-> python idle.py and idle.pyw and the same thing > > happened. Appreciate any suggestions. Also if there are any > > Amiga users of python out there. I also can't get IDLE going > > on that platform either but at least I have the shell. > > > > rloisel at helicon.net (Rod Loisel Enfield NH) > > From r2d2 at mao.acc.umu.se Mon Jul 31 03:07:36 2000 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: 31 Jul 2000 07:07:36 GMT Subject: Perl is worse! References: Message-ID: > It isn't senseless. That is the whole point. It is only senseless >because of typing. Clearly you cannot add a word to a number, granted. But >what of 1 + "1"? That isn't senseless, those are two numbers. I can see they >are two numbers, it is only because of typing that it fails. > > So I ask you this /VERY/ simple question. Why can't Python do both? Hm? >What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it >together? I hate to step into a thread that is already so bloated, but I feel much of the discussion is missing the point. There is nothing inherently wrong with having 1 + "1" == 2. It's a design choice, and for Perl, it is a design choice that makes sense. However, for Python, I do not believe it would be a good design choice, because it implies that operators are type specific. So you need separate operators for adding numbers (+) and concatenating strings (.). This is not that troublesome, because these are really different operations. More disturbing is that we need separate operators for comparing numbers (==) and comparing strings (eq). In Perl, this is not such a big problem, because Perl doesn't care that much about types. Often the types are implicit (the programer says to himself, well I'll represent cars by a list with the model in the first element and the year in the second - but doesn't actually define a Car type). (Of course, with objects and references this changes, but then automatic conversion breaks down as well \1 + 1 is not 2.) In Python, on the other hand, the programmer creates new types (classes) all the time, classes for rationals, matrixes, cars, etc --- things that we want to add, multiply and compare. With type specific operators, we would have to create new operators for each type, which I do not think is a very good idea. It would make the code harder to read and write and it would break the similarity with mathematic notation where + can indeed be used to add many things beside numbers. > Hell, why do an exception at all? Why not do what is already done with >integers, reals and floats? > >1 + 1 = math > >1 + "1" = math > >1 + "foo" = string ("1foo") > >"foo" + "foo" = string ("foofoo") Because it breaks down associativity? 1 + (1 + "foo") = "11foo" (1 + 1) + "foo" = "2foo" // Niklas From john.osullivan at chase.com Thu Jul 13 08:06:55 2000 From: john.osullivan at chase.com (john.osullivan at chase.com) Date: Thu, 13 Jul 2000 12:06:55 GMT Subject: Solaris/SparcWorks 1.5.2 build Message-ID: <8kkbcm$8nf$1@nnrp1.deja.com> I did a build and install of Python 1.5.2 on my Solaris box recently. I'm running Solaris 2.6 on an Ultra 5, with SparcWorks 4.2 C and C++ compilers. I ran across some gotchas which I thought I'd document. Others, who like me are working in a corporate environment where gcc and gmake aren't available, may find them handy. If you're trying to build with SparcWorks C/C++ and Solaris make you may well run into gotchas 1 to 3. Number 4 is a really bizarre one which is quite improbable - I wrote it down 'cos I enjoy winkling out a good bug... JOS 2000-07-13 (john.osullivan at chase.com) 1. Run configure to build without gcc and with support for threading... ./configure --without-gcc --with-thread 2. Make sure your path picks up the SparcWorks C and C++ compilers first, before /usr/ucb. My SparcWorks is in /dvl/sw/SUNWspro_4.2/bin. If you pick up /usr/ucb/cc first you will get something like... {dvcls105_le0:38} ./configure --without-gcc --with-thread loading cache ./config.cache checking MACHDEP... sunos5 checking CCC... checking for --without-gcc... yes checking for gcc... (cached) cc checking whether the C compiler (cc ) works... no configure: error: installation or configuration problem: C compiler cannot create executables. If you get this you can check whether the problem is caused by /usr/ucb/cc like so... {dvcls105_le0:34} cc /usr/ucb/cc: language optional software package not installed {dvcls105_le0:35} ls -l /usr/ucb/cc -r-xr-xr-x 1 bin bin 3084 Jul 16 1997 /usr/ucb/cc 3. Make sure that DEFS includes -D_REENTRANT -mt in the Makefiles... DEFS= -DHAVE_CONFIG_H -D_REENTRANT -mt You need this for multithreading - which you will need if you want to run, for instance, Zope. 4. Look out for Solaris make's implicit rules kicking in. The implicit rules live in /usr/share/lib/make/make.rules. They can cause the invocation of, among other things, sccs and yacc. I experienced a particularly bizarre interaction since I had a PROJECTDIR environment var set. sccs looks for an SCCS subdirectory below the dir pointed to by PROJECTDIR, and mine just happened to have an old history file called s.parser.y, which got recovered by an implicit rule in /usr/share/lib/make/make.rules and passed through yacc to overwrite parser.c. The output below was generated by 'make -d'. The "parser.y" prefixing the C compiler error reports was caused by a preprocessor directive in parser.y and the generated parser.c -O -I./../Include -I.. -DHAVE_CONFIG_H -D_REENTRANT -mt -c node.c Building pgen because it is out of date relative to node.o Sccs getting parser.y because s. file is younger than source file sccs get -s parser.y -Gparser.y Building parser.c using suffix rule for .y.c because it is out of date relative to parser.y yacc parser.y mv y.tab.c parser.c Building parser.o because it is out of date relative to parser.c Building parser.o using suffix rule for .c.o because it is out of date relative to parser.c cc -O -I./../Include -I.. -DHAVE_CONFIG_H -D_REENTRANT -mt -c parser.c "parser.y", line 12: cannot find include file: "parser.y", line 26: undefined or not a type: cmd_descriptor "parser.y", line 26: syntax error before or at: * "parser.y", line 26: warning: old-style declaration or incorrect type for: cursource "parser.y", line 27: undefined or not a type: cList "parser.y", line 27: syntax error before or at: * "parser.y", line 27: warning: old-style declaration or incorrect type for: curargs Sent via Deja.com http://www.deja.com/ Before you buy. From huaiyu_zhu at yahoo.com Sat Jul 22 17:56:57 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Sat, 22 Jul 2000 14:56:57 -0700 (PDT) Subject: Discussion: new math operators In-Reply-To: <39773679.69A8BF9D@fft.be> Message-ID: I've finally put the new operator patch by Greg Lielens, merged with Thomas Wouters' patch for augmented assignment, onto MatPy directory at http://MatPy.sourceforge.net/Misc/matop-000720.patch.gz It works against CVS on 2000-07-20. A brief instruction is put at the end of http://MatPy.sourceforge.net/INSTALL A test file is available (which also serves as a demo), http://MatPy.sourceforge.net/Misc/test_matop.py This works on my Linux box without needing any hand editing. If there is demand I'll put the separate matop patch there as well. Enjoy, Huaiyu PS. Greg, the test file was modified from yours in the patch. On Thu, 20 Jul 2000, Gregory Lielens wrote: ... > I attach it in the mail, a patch against the current CVS (CVS.patch) > that will add both augassign and @, and against the current CVS already > patched with the augassign (augassign.patch) that will add the @ > operators. Maybe you can put them in a MatPy directory at sourceforge > after trying it, and post the location in c.l.p ? > > The patch work well on my linux box, but on a hp we have here, it does > not compile...However, I am sure it is not the patch fault, as an > upatched current CVS have the same compilation troubles... I am not sure > if the current CVS is at fault (errors happen in the unicode section) or > if the compiler are not correctly installed on this box (this is > probably the explanation, we already have some problems with it). I > think that if you can compile it, it is better to let others check it on > a variety of platform... > > Greg. From yosefgold at hotmail.com Tue Jul 11 09:17:54 2000 From: yosefgold at hotmail.com (yosefgold at hotmail.com) Date: Tue, 11 Jul 2000 13:17:54 GMT Subject: capturing CTRL-BREAK on PC Message-ID: <8kf6ph$h0k$1@nnrp1.deja.com> How can I catch CTRL-BREAK (not CTRL-C, that I know how to do), so that I can do some cleanup work before exiting? I am using version 1.5.2 via a command prompt in NT. Thanks, Yosef Gold yosef at adsc.com -- please email answers here in addition to posting them. Sent via Deja.com http://www.deja.com/ Before you buy. From jbauer at rubic.com Thu Jul 27 12:01:11 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 27 Jul 2000 11:01:11 -0500 Subject: cgi dectection References: <39804dc7_1@news.chariot.net.au> Message-ID: <39805CC7.DE18566F@rubic.com> Michael Lunnay wrote: > is there a standard way to detect if script is being > run as a cgi script or from the command line. I usually build test cgi scripts by checking for the SERVER_PROTOCOL environment variable, e.g.: if os.environ.has_key('SERVER_PROTOCOL'): run() else: test() Hope that helps. Jeff Bauer Rubicon Research From mlp at my-deja.com.bbs Thu Jul 13 09:00:04 2000 From: mlp at my-deja.com.bbs (mlp at my-deja.com.bbs) Date: 13 Jul 2000 13:00:04 GMT Subject: TypeLib for Python COM Server? Message-ID: <3bO6d4$mOG@openbazaar.net> that's nice. and thanks for the reply. however, i already got a python module for generating a typelib from a python server. i got it from arpad kiss. tell me if you're interested ... morten In article <326536345498D311B3BC00105A39802A07478A at newsintern.dspace.de>, Stefan Migowsky wrote: > Hi, > > there is no general support for typelib generation. But as I know all > propertiues and methods of a Python COM Server start with the dispid 1000. > > So writing the IDL File by hand is no problem. Just take the same GUIDs, > Names and the right DispID. So here is a little example : > > Python File : > > _reg_clsid_ = "{5B24BFC0-EF45-11d3-9B5F-0090274354BC}" > _reg_libname_ = "PythonComInterpreter Typelib" > > class PythonComInterpreter: > """Interface PythonComInterpreter""" > > _public_methods_ = ['Exec','Eval'] > > _reg_progid_ = "PythonComInterpreter" > _reg_verprogid_ = "PythonComInterpreter.1" > _reg_clsid_ = '{281AC1E3-E3D2-11D3-9B37-00902722BDE1}' > _reg_desc_ = "PythonComInterpreterClass" > _reg_class_spec_ = "PythonComInterpreter.PythonComInterpreter" > > def __init__(self): > self.Dict = {} > self.Dict["__name__"] = "__main__" > self.Dict["__builtins__"] = __builtins__ > self.Dict["__doc__"] = "" > > def Exec(self, Cmd): > exec str(Cmd) in self.Dict > > def Eval(self, Cmd): > return eval(str(Cmd),self.Dict) > > if __name__ == '__main__': > print 'Registering Python COM Server ...' > import win32com.Server.register > win32com.Server.register.UseCommandLine(PythonComInterpreter) > print 'Registering finished' > > ###################################################################### > Corresponding IDL File: > ###################################################################### > > [ > uuid(5B24BFC0-EF45-11D3-9B5F-0090274354BC), // _reg_clsid_ Typelib > version(1.0), > helpstring("PythonComInterpreter 1.0 Type Library") > ] > library Interpreter > { > importlib("STDOLE2.TLB"); > > // Forward declare all types defined in this typelib > dispinterface IPythonComInterpreter; > > [ > uuid(281AC1E3-E3D2-11D3-9B37-00902722BDE1), // _reg_clsid_ > PythonComInterpreter Class > helpstring("PythonComInterpreter Class") > ] > coclass PythonComInterpreter { // _reg_progid_ > PythonComInterpreter Class > [default] dispinterface IPythonComInterpreter; > }; > > [ > uuid(F8887DE1-EF58-11D3-9B5F-0090274354BC), > helpstring("IPythonComInterpreter Interface") > ] > dispinterface IPythonComInterpreter { > properties: > methods: > [id(1000), helpstring("Executes a Pythonstatement")] > VARIANT Exec([in] BSTR cmd); > [id(1001), helpstring("Evals a Pythonstatement")] > VARIANT Eval([in] BSTR cmd); > }; > }; > > Stefan > > >-----Original Message----- > >From: mlp at amrose.dk [mailto:mlp at amrose.dk] > >Sent: Wednesday, July 12, 2000 1:37 PM > >To: python-list at python.org > >Subject: TypeLib for Python COM Server? > > > > > >hi all. > > > >i'm in a situation where i'd like to have a typelib for a python com > >server, for use in a c++ client. > > > >i tried to just use midl on an idl i made to reflect the interface of > >the python server. this didn't work out, since when compiling the > >client code the tlb file is not recognized. > > > >my question: is there an automatic, easy, or standard, way to produce a > >typelibrary for a com server implemented in python? if not, is it > >possible at all? if so, could anybody help me with the details? a > >complete example would be splendid! > > > >python rules! > >'gards, > >morten lind petersen, denmark > > > > > >Sent via Deja.com http://www.deja.com/ > >Before you buy. > >-- > >http://www.python.org/mailman/listinfo/python-list > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From mwh21 at cam.ac.uk Sat Jul 22 20:54:48 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 Jul 2000 01:54:48 +0100 Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: digitig at cix.co.uk (Tim Rowe) writes: > In article , mwh21 at cam.ac.uk > (Michael Hudson) wrote: > > > W.Whiten at mailbox.uq.edu.au (Bill Whiten) writes: > > > > > > > > I would prefer the normal oprerators plus an escape character > > > followed by > > > additional characters to define new operators eg @+ @div etc. > > > > I quite like this idea (unlike most of the others that have been > > mentioned...); it reminds me of Haskell. > > Ouch -- I don't. The type of an identifier determined by the characters in > the identifier, rather than being assigned? That's one of the things I > loathe about Perl. And what would a Python identifier be doing, > constrained to refer only to one type? Sorry, but eh? I fail to understand you, I think. Example usage of what I'm talking about: def add(x,y): return x + y 1 @add 1 ==> 2 Now, can you explain your problem again for the hard of thinking? (I'm not sure that this would make a good addition to Python either, but I do think it's a better idea than some that have been bandied around in the last week or so - and that's just the posts I've read) Cheers, M. -- 41. Some programming languages manage to absorb change, but withstand progress. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From jessw at loop.com Sat Jul 8 11:27:00 2000 From: jessw at loop.com (Jesse W) Date: Sat, 8 Jul 2000 15:27:00 +0000 Subject: Solution to IDLE and Tkinter troubles Message-ID: <200007082229.PAA66802@ritchie.loop.com> Dear Python Community, I have noticed, as have many others, that IDLE has trouble running Tkinter programs. I suspected, and read in newsgroup postings, the explanation that IDLE uses Tkinter and it causes problems when one Tkinter session is run within another. I have thought up, and implemented, a very simple solution to this problem(the code is below); however, it is pretty ugly and clumsy. My solution is just to use the os.system command to call python.exe and run the script. There are a few problems, however. os.system takes a _long_ time to get the interpreter running and blanks my screen while it does it. It would be nice if there was some more efficient command to start the interpreter. A second problem is the kludge randomly breaks, and I don't know why because I don't understand the IDLE code. Also, because of my lack of IDLE knowledge, I am probably using the wrong calls to get what I want and I am sure it could be made cleaner. I have had this for a while, and I did not post because I was sure that something this obvious would have already been done, or at least thought of as a TODO. I still suspect I am missing something, because this seems so simple, and it is definitely a problem... Thank you for your time, Jesse Weinstein My Solution: (insert in ScriptBinding.py) The lines with #JW after them are the lines I added menudefs = [ ('edit', [None, ('Import module', '<>'), ('Run script', '<>'), ('Alt Run script', '<>'), #JW ] ), ] def run_script2_event(self, event): #JW filename = self.getfilename() #JW if not filename: #JW return #JW print filename #JW os.system("c:\\python\\python.exe " + filename) #JW From cut_me_out at hotmail.com Fri Jul 21 15:47:06 2000 From: cut_me_out at hotmail.com (Alex) Date: 21 Jul 2000 15:47:06 -0400 Subject: Creating a setuid script References: <39789242.C93B0446@glo.be> Message-ID: > I am busy writing some scripts, which should be setuid root When I needed to do this, someone told me that scripts don't run setuid, as a security feature. The problem is, you can really mess a things up by passing it corrupted environment variables. So you have to have a C wrapper program, protects the script by passing it sanitized environment variables. There is one distributed with the python source. You can get it here: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/ src/Misc/setuid-prog.c?rev=1.5&content-type=text/ x-cvsweb-markup&cvsroot=python (Sorry, you'll have to join the three lines together.) Alex. From Jelske.Kloppenburg at gmd.de Wed Jul 5 10:51:31 2000 From: Jelske.Kloppenburg at gmd.de (Jelske.Kloppenburg at gmd.de) Date: 5 Jul 2000 14:51:31 GMT Subject: Compiler switches for install Message-ID: <8jvi1j$412$1@hop.gmd.de> In the Python-1.5.2/README under Configuring threads I read "Unfortunately, on some platforms, additional compiler and/or linker options are required." Where - configure, configure.in, Makefile, Makefile.in, Modules/Makefile.pre.in, ...? how - CFLAGS=, OPTS=, MY_CFLAGS= ...? and when - before configure, before make, ...? can I set the options? I repeat the question (until now nobody seems to understand me): Where, how and when can I set the options? -- Jelske Kloppenburg, +49 2241 14-2433, GMD - German National Research Center for Information Technology From spahievi at vega.bg Fri Jul 21 19:38:01 2000 From: spahievi at vega.bg (Spahievi) Date: Sat, 22 Jul 2000 02:38:01 +0300 Subject: Win95 python programs no longer start Message-ID: <200007212350.CAA12817@moria.vega.bg> ---------- > From: removeRishi Ed > To: python-list at python.org > Subject: Win95 python programs no longer start > Date: ??????, ??? 22, 2000 00:53 > > At some point, when I double click at .py program, nothing happens. It used to > start up. Windows knows about python and the .py extension, but it doesn't > start up the program. > > any ideas? When Win95 is upgraded with USB support all win32 console apps can't be started from GUI explorer. Niki Spahiev From dcalvelo at pharion.univ-lille2.fr Tue Jul 25 15:06:57 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 25 Jul 2000 19:06:57 GMT Subject: SIMPLE QUESTION References: <397D8299.27F82E6D@sicon.net> Message-ID: <8lkogh$1gg$2@netserv.univ-lille1.fr> sergio wrote: : Hi again , i try to explain it better this time. : From a dll of a pdf converter , i make a py file. And i want to use : the next function in order to initializate a new printer driver: : def DriverInit(self, PrinterName=defaultNamedNotOptArg): : return self._ApplyTypes_(0x1b, 1, (3, 0), ((8, 0),), 'DriverInit', : None, PrinterName), : included in the class: : class ICDIntf(DispatchBaseClass): : When i try to call it i get the error : File "", line 0, in ? : TypeError: unbound method must be called with class instance 1st : argument. : I suppose its refering to the argument 'self' so, how can i get the : class instance to pass it to the function. Without more info, one can only suppose that your call should have been along the lines of: sthg = ICDIntf() # Make a class instance sthg.DriverInit() # Call the method on the instance Or: sthg = ICDIntf() ICDIntf.DriverInit( sthg ) # Call the unbound method with class # instance first argument Or: ICDIntf().DriverInit() # Probably useless HTH -- Daniel Calvelo Aros calvelo at lifl.fr From skip at mojam.com Wed Jul 12 13:44:43 2000 From: skip at mojam.com (Skip Montanaro) Date: Wed, 12 Jul 2000 12:44:43 -0500 (CDT) Subject: Test writing volunteers needed Message-ID: <14700.44683.572283.391037@beluga.mojam.com> I'm look for a few people to write some regression tests for the posix (and windows or mac equivalents), os and sys modules. Some of that functionality is tested already (fork for example), but much of it isn't. If you can help out, please contact me in private email. I will help coordinate a small group of people. Here's what's required: * A few hours free over the next week or two. * You must be able to check out the CVS tree from SourceForge. You will probably be adding test cases for new or changed functionality. Testing against the 1.5.2 distribution will likely be insufficient. * I'd like to find some people who have access to something besides Linux or Windows. In particular, users of Macs and other Unix variants are encouraged to volunteer. * You should be able to write Python code (no C code writing is involved). If you have a little time to help with this project, please contact me. Thanks, -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From neilh at scintilla.org.bbs Sun Jul 16 19:20:02 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 16 Jul 2000 23:20:02 GMT Subject: Pythonwin 1.5.2 Message-ID: <3bQdM2$k0S@openbazaar.net> > Another PythonWin documentation quirk: Ctrl+T is listed twice as a keyboard > shortcut. Once as "Transpose (swap) the current line with the line above" > and later as "Toggle the use of tabs for the current file (after > confirmation)" Well it could be documented this way because the underlying Scintilla Transpose command would be exposed if you change your bindings file to move toggle-tabs to a different key. But I expect its just an oversight. Neil From cg at schlund.de Mon Jul 31 17:59:38 2000 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 31 Jul 2000 23:59:38 +0200 Subject: removing characters from a string? References: <8m4rqn+jpg0@eGroups.com> Message-ID: <3985F6CA.DCA6C56B@schlund.de> I'd give re.sub() a try. Carsten. jesse at multimediacollective.com wrote: > say I had a string. > > this_string = "jesse at multimediacollective.com" > > """and I wanted to get rid of the @, how would I do that? This > process has to be efficent for removing large quantities of special > characters, such as <,>,#,%,* etc, from the same string. > > Any advice would be very helpful. Thanks in advance, Jesse. From andymac at bullseye.apana.org.au Tue Jul 18 18:31:18 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 19 Jul 2000 08:31:18 +1000 (EST) Subject: Best way to switch between different view In-Reply-To: <3973EB14.1D3F17BF@proceryon.at> Message-ID: On Tue, 18 Jul 2000, Horst Gassner wrote: > In my application there are three different kind of views. Each of them > has to be displayed in the same main window. Two of them are scrolled > canvases and one is a scrolled frame (all of them with many widgets > inside). > > What is the best way to handle this different views? At the moment I > completely destroy one view and rebuild the new one but there must be a > better way. Some time ago I have read something about an unpack method > to hide a widget. Could this be the best way to do this? Could you get them into a tabbed notebook type setup - a number if GUI toolkits offer widget, and IIRC PMW has such a widget if you're using Tkinter. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From alex at magenta.com Fri Jul 28 17:17:52 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 23:17:52 +0200 Subject: Perl is worse! References: <8lsdir$aja$1@plutonium.compulink.co.uk> Message-ID: <8lstog02hch@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o3fei.49c.grey at teleute.rpglink.com... > On 28 Jul 2000 16:49:31 GMT, gbreed at cix.compulink.co.uk > wrote: > >? You said it was only declared to "get the name space in there". > > Yup. "I'm going to use a, for what I know not. Could be string, could be > integer, could be whatever I want." The point was defining the name and > assiciate it with nothing. But since the type is inferred on first use might > as well have the C declarations. No, there is no type-inferences about variables in Python, neither on first use nor on later ones. It serves no purpose that I can think of, in Python, to state to the compiler "I'm going to use a, for what I know not", in advance of when you know what you do want with it. Just bind it in the appropriate manner at the instant in which you do want to know, and feel free to rebind it later (or delete it, whatever) if and when you change your mind. Whatever a was bound to, or whether it was bound at all, will make no difference when you later bind or rebind it. If you need or want to make tests about a, call methods on it, etc, then of course it will matter what if anything it is bound to at that point; but not for the purpose of (re)binding it. Alex From garabik at center.fmph.uniba.sk.spam Thu Jul 20 11:26:54 2000 From: garabik at center.fmph.uniba.sk.spam (Radovan Garabik) Date: 20 Jul 2000 15:26:54 GMT Subject: Advice sought: text-mode (but not CLI) apps in Windows console ? References: <8F7682C13PaCmAnRDLM@195.25.12.37> Message-ID: <8l75nu$vq$1@sunnews.cern.ch> Fred Pacquier wrote: : Hi, : The other day I had an idea for something I wanted to do in Python. It is : to be run under Windows (9x), but for various reasons I did not want to do : a full Windows GUI (like with Tk or wxPython). I did not have a pure CLI : app in mind either, but wanted to provide some sort of simple character- : mode interface to the user, in a Windows console (DOS box). : Since then I have been through what I believe to be a reasonably thorough : Web search (from Parnassus outwards) to find something to get me started, : and have turned up precious little. Various Python bindings of curses or : ncurses exist, but can one run curses itself under Win 9x ? Or are there http://www.mikroplan.com.pl/~mak/python/files/pdcurses.zip : other, well-hidden libraries or modules that do more or less the same thing : on that platform ? (I'm not asking for something as high-level and : extensive as the Borland OWL of old :-) -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.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 rumjuggler at cryptarchy.org Fri Jul 28 02:52:19 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 06:52:19 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 05:00:16 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 04:15:24 GMT, Ben Wolfson wrote: >>I would never, personally, have expected list(123) to return a list >>containing only the element 123. After all, that isn't how it works with >>_any_ other data type. > > Well, considering it doesn't work with most other data types, that isn't >unexpected, isn't it? > >>_any_ sequence can be either a single value or a sequence. > > Right, any sequence. You said it, remember it, I'll get back to that. > >>The fact that list() (and tuple()) only work on objects that actually have a >>sequence mapping makes a lot of sense and, to me, resolves the ambiguity in >>precisely the way I would expect. > >>>>> a = (1,3,'5') > >>a is a single value. It's a tuple. If list() took single values and made >>them into single-element lists, and tuple() worked accordingly, I would >>expect > > No, a is a pointer to a tuple and the tuple contains three values. A >tuple is just an immutable list. I'm not sure why anyone would want that, but >hey, I'm sure there's a reason along there somewhere. I see three valies, 1, >3 & 5. > >>To have list() and tuple() behave one way when given non-sequence >>arguments, and another when given sequence arguments, rather odd for two >>reasons. > > I never said that. Not explicitly. But asking for list(1) to give [1], and list((1,3)) to give [1,3] is equivalent. Depending on how you look at it, in the first case it takes a single element and returns it into a single-element list, and in the second it takes a single element returns it with its type changed to list, or in the first case it takes a non-sequence and returns it a single-element sequence, and in the second it takes a sequence and returns the list-equivalent of that sequence. >>Firstly, it's unnecessary. If I have a single value in X, and I want to >>make it a single-element list, there's a way to do that: > > Really? > >>>>> some_variable = [X] > > Seems counter intuative, doesn't it, list() could take that single value >and make it a single item in a list. Yes, it does. List returns the list-equivalent of the sequence passed as its argument. 1 is not a sequence; it doesn't have a list equivalent. >I mean, c'mon, why have list when you >could just construct a for loop to use an append method? You could, but that would be less efficient. >>That is how you construct single-element lists. list(), as its docstring >>clearly states, creates a list from a sequence. > > You're right. It does. > >>Secondly, it's counterintuitive. You say "all of those can be converted >>into lists"; I look at 1 and think, "what is the list equivalent of an >>integer?" > > That is because you're thinking in terms of types and not just data. It >is a single element, nothing more. > > Ah, but getting back to that point I said to remember. > >foo = "a" >foo = list(foo) > > foo is not ['a']. It took a single element and made it a list. So we now >know that a single element has a sequence. Here is another sequence of a >single element. As has already been stated, "a" is a single-element sequence, as are [1] and (1,). >foo = 1 >foo = list(foo) > > Error. Single element sequence. Remember, any sequence can either be a >single value or a sequence. Yet here we have a single value denied. Quirks >abound. Any _sequence_ can be a single element or sequence. Any _single element_ can't be a single element or sequence. all A is B != all B is A. >>> a is now "['a', 'b', 'c']". Which means we split a string up when >>>converting to list but don't concatinate on the way back. > >>Why should str(['a','b','c']) == str(['abc']) == str(['ab','c']), etc? The >>str() function doesn't know that its argument was originally constructed >>from a string. > > I never said that, did I? No. Didn't I go on to state that I wouldn't >expect it to work because going down the scale from structures down to simple >data is hard. It would be like trying to stuff a directory into a list. >Going from more complex to something simpler is always going to have some >problems in implementation. I was just pointing out that, as with anything, >there are quirks in the language that one must learn. True, but to me, this isn't quirky at all, but precisely what I would expect and entirely logical. -- Barnabas T. Rumjuggler In Xanadu did Ozymandias a stately edict once decree: "look upon my Pleasure Dome, ye mighty, and despair!" -- David Zacuto From jmcbray at carcosa.net Sat Jul 22 13:15:38 2000 From: jmcbray at carcosa.net (Jason F. McBrayer) Date: 22 Jul 2000 13:15:38 -0400 Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: >>>>> "n" == nobody writes: n> cjc26 at nospam.cornell.edu (Cliff Crawford), in >>> i despise machines trying to second- guess my intentions, and silly >>> little print statements trying to be clever with their arguments are >>> nothing more than that. >> print doesn't really try to be clever with its arguments, except for >> printing a space between each one and a newline at the end. n> that's trying to be clever. then, if i'm reading raw lines from a file and n> want to print them verbatim, i have to strip a newline somewhere somehow? n> how do i copy a file to another one, is there a file.copy method in some n> module somewhere? There is, but that's not important here. What you really want is to not use print; use the write method of a file object (such as sys.stderr or sys.stdout). That doesn't try to be clever with its arguments like print does (python's print is not perl's print). -- +-----------------------------------------------------------+ | Jason F. McBrayer jmcbray at carcosa.net | | A flower falls, even though we love it; and a weed grows, | | even though we do not love it. -- Dogen | From brunnsNObrSPAM at beer.com.invalid Thu Jul 6 07:57:06 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Thu, 06 Jul 2000 04:57:06 -0700 Subject: Python for EPOC? References: <39644427.6036E82C@autosim.no> Message-ID: <08000838.2b2c7912@usw-ex0106-045.remarq.com> Alf Inge Iversen wrote: >Is there a Python interpreter and/or development environment available >for the EPOC operating system? Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From jhylton at my-deja.com Sat Jul 8 12:42:22 2000 From: jhylton at my-deja.com (Jeremy Hylton) Date: Sat, 08 Jul 2000 16:42:22 GMT Subject: Splitting c.l.py... References: Message-ID: <8k7lld$g53$1@nnrp1.deja.com> In article , Alex wrote: > > > trying to disentangle all the webs binding Python to CNRI so that we > > can be *effective* at BeOpen. > > Is there a synopsis of the legal woes that befell python somewhere? It > sounds sort of interesting. > It's not interesting <0.2 wink>. -- Jeremy Hylton Sent via Deja.com http://www.deja.com/ Before you buy. From root at rainerdeyke.com Thu Jul 20 16:49:20 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 20 Jul 2000 20:49:20 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> <8l7f69$bon$1@fermi.tro.net> Message-ID: "Moritz Voss" wrote in message news:8l7f69$bon$1 at fermi.tro.net... > Maybe I don't get the python concept. Do you link it statically? Or is the > interpreter *.exe invoked every time? > We came from dos, counting every clock we spent using 90% assembly in our > software. Until we were struck that our texturing algorithm sucked (and > anyway, 3d accelerators were coming up and I already had one...)... The Python interpreter is available as a DLL. You link your C/C++ with the Python library, then call python code with PyRun_String or something similar. Python is really easy to extend in C, although extending in C++ could be difficult, especially if you use C++ exceptions. > > >> From a game programming perspective, you can probably consider Python > to > > >> be dirt-slow, though. The trade-off is a lot of power for speed, but > > >> that power can help you gain back speed because you can be a lot > smarter. > > Yes and no. Just because I have encapsulation and overloaded operators, that > does not mean my program is going to be faster than a program that performs > the same task in assembly or C. Python is horribly slow and memory-consuming compared with C or C++. It is, however, extremely flexible and easy to program. However, this probably doesn't matter if you only use Python where appropriate. Don't write a path-finding function in Python; write it in C or C++ and access it from Python. > > > Thanks :) So designing my own scripting language is easier. > > > > That's of course not true; designing your own scripting language will > > most likely result in an ad-hoc broken design. Look at all the various > > Now, my own language would be an assembler-style thing. The concept is as > follows - every instruction corresponds to an index. Each of these indices, > after compilation, are then translated, during runtime, into direct function > addresses. So what I have is my program that consists of a huge bunch > pointers to C functions (which can have any level of complexity). These > would just be loaded, and called, loaded, and called. I'm not going into the > depths of this here but passing parameters and references is not a problem. Sounds messy and slow. An indirect function call per instruction? Could be slower than Python, especially since you'd need lots of instructions to do anything useful when programming assembly style. > > application specific scripting languages for examples. It's even possible > > your own design will be slower in many cases than the equivalent code > > in Python, as you don't have as much time to polish it. > > That is the problem - python is oblect-oriented. Most AI scripts are tiny, > though, just 15 lines or so with my assembler code. > Something for a missile would be > "CheckTarget--Steer-IfCloserThanX-Detonate". The script knows > how toget closer to what it wants - but does so not my reall playing god and > moving the missile, but just setting off a command "Steer" that tells the > physics engine "ThrustvectorAngleChange (angles)"... This is unlike the > scripts in the Quake engines that allow to do unrealistic things - in my > project, each script can only do what is physically possible - otherwise, > the missile will crash or the tank will tip over in a curve. This type of thing is possible in Python. To prevent the script from doing something naughty, override __builtins__. > A caveat here: The unit scripts will be lengthy, having units check engine > and gun temperature (and move into the shade or cease fire), check whether > they can go down that hill after it has started rainign, have them > communicate targetting info or even orders to other units, calculate the > lead for their next shots, return to a repair base via the safest way.... > > And it MUST all be user definable for the player, that point is muission > critical for the project. Otherwise, we'd hardcode it. All no problem in Python. If you use classes to represent unit types, you can override any attributes or behavior through subclasses. > I'll play around with python, but I found the way to embed it totally > confusing. (That is, of course, because I have never worked with embedded > languages yet). Also, I find no tutorial that clearly tells me how to change > my C variable "X" from within my Python program "Y" that is invoked by the C > Program. You would typically do things the other way around - change Python variables from C. If you must change a C variable from Python, you would have to write a function that changes the variable and write a built-in module that contains the function. Python programs can then access import the module and call the function. > > > Or: Isn't it feasibble to pull of a stunt like ID software did with > their VM > > > files? These contain compiled C code that is loaded dynamically - and of > > > If you want to script your game in C there isn't any problem. :) Actually there is. It's impossible to prevent a DLL from crashing the host computer and doing other bad things. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From Norman_Shelley-RRDN60 at email.sps.mot.com Fri Jul 14 12:28:22 2000 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Fri, 14 Jul 2000 09:28:22 -0700 Subject: ?Neil Schemenauer's GC patch in python1.6? Message-ID: <396F3FA6.6EBC62BA@email.sps.mot.com> Is Neil Schemenauer's GC patch scheduled to be in python1.6? I'm currently getting hit with huge memory leaks probably due to circular references. Even after going through and removing the most obvious ones it has helped only a little. Having to design programs and algorithms with reference counting in mind is just as bad as having to remember to remember to use free() when in C or C++. Python must be better than it currently is in order to sell it to others who have not yet seen the light. From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 19:50:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 23:50:02 GMT Subject: "Intellisense" drop-down... Message-ID: <3bQeBQ$kbv@openbazaar.net> I found it! In coloreditor.py, I found the two methods I had been wanting to use, namely SciAutoCActive and SCIAutoCComplete! Here it is, folks, the ability to use another key than TAB to select a word in the AutoComplete list: def AutoCompleteOrIgnore ( editor_window, event ): editor = editor_window.edit if editor.SCIAutoCActive ( ): editor.SCIAutoCComplete ( ) return 1 Just add it to your .cfg file and then, in the [Keys] section, add/change the following: Ctrl+Space = <> Ctrl+Enter = AutoCompleteOrIgnore Space = AutoCompleteOrIgnore and PythonWin should now [sort of] behave like VB! If you don't like "it" adding a space after an "auto-completed" word, change the function to: def AutoCompleteOrIgnore ( editor_window, event ): editor = editor_window.edit if editor.SCIAutoCActive ( ): editor.SCIAutoCComplete ( ) return 0 return 1 Wohoo!!! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:osrc5.3577$4p3.27127 at news-server.bigpond.net.au... > > I have found no way of defining new key combinations to select the > currently > > highlighted word in the "Intellisense" drop-down list. For example: > > ... > > I hightlight "Apply" and the only key I can use to make "Apply" appear and > > the list to disappear is "Tab". I want other keys to trigger this. The > > default.cfg file only lists this: > > When the previous post appeared about Ctrl+Enter in auto-completion, I > had a look at extending the keys that would choose an item and tried > changing this in Scintilla. This worked in other applications but not in > PythonWin as PythonWin intercepts keys before sending them on to Scintilla. > Then I went looking through PythonWin but the code was confusing so I gave > up. > > If you are interested in working on this, the Enter key calls > newline_and_indent_event in pywin\idle\AutoIndent.py. So you could intercept > it here or else bind Enter to your own event that calls the current > newline_and_indent_event only when no autocompletion is shown. > > Neil > > > From kalle at gnupung.net Mon Jul 3 10:28:38 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Mon, 3 Jul 2000 16:28:38 +0200 Subject: Random number generation, simple question. Message-ID: Hello. I have a few questions about the (pseudo) random number generator supplied in the standard library. I need 80 random bits (for a CipherSaber IV) but I hear most RNG's only supply 32 bits or less. My questions are: * How many random bits does whrandom.random() generate? * Suppose I do a loop where I get a byte at a time and then re-seed the generator either with random numbers from the generator or with values from time. Will that improve the randomness? * Are there better alternatives? I understand I could read from /dev/random on Linux, but this isn't portable, and even though I only use GNU/Linux myself, I have friends who don't. If anyone can tip me off about a similar feature in Win32, I could just detect platform and use the appropriate function, of course. I don't think I have to care about Macs or other *NIX dialects. Phew... :) Hope I'm making sense even though I hardly understand what I'm talking about... :) TIA, Kalle Svensson From ngps at madcap.dyndns.org Sat Jul 22 09:12:20 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 22 Jul 2000 13:12:20 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> Message-ID: <8lc6jk$1f1$1@coco.singnet.com.sg> According to : > im trying to using urllib and httplib that can access "https" url but i > got an error. Is it i must recompile again python 1.6a2 with ssl > module?? Try the binary distribution of M2Crypto 0.05-snapshot#3 here: http://www.post1.com/home/ngps/m2 Https should "just work". -- Ng Pheng Siong * http://www.post1.com/home/ngps From keitt at nceas.ucsb.edu Sun Jul 23 17:26:49 2000 From: keitt at nceas.ucsb.edu (Timothy H. Keitt) Date: Sun, 23 Jul 2000 14:26:49 -0700 Subject: Operators for everything (was Re: Operators for matrix) References: <3977AF5E.552F4F42@my.signature> Message-ID: <397B6319.27A6438A@nceas.ucsb.edu> R (www.r-project.org) uses '%' as in A %*% B. Might be nice to standardize. Tim Bill Whiten wrote: > > In article <3977AF5E.552F4F42 at my.signature>, Greg Ewing > wrote: > > Python with its overloadable operators can be thought of > > as a meta-language for creating domain-specific languages. > > But the number of operators is too restricted for it to > > be really good in this role. Operator overloading feels like > > something tacked on as an afterthought rather than a > > serious feature. I don't think it's unreasonable > > to consider whether this situation could be improved. > > I would prefer the normal oprerators plus an escape character followed by > additional characters to define new operators eg @+ @div etc. > > Regards, > ----------- > Bill Whiten, W.Whiten at mailbox.uq.oz.au > Julius Kruttschnitt Mineral Research Centre, > The University Of Queensland, Tel: int +61 7 3365 5888 > Isles Rd, Indooroopilly, Fax: int +61 7 3365 5999 > Brisbane Qld 4068, AUSTRALIA. -- Timothy H. Keitt National Center for Ecological Analysis and Synthesis 735 State Street, Suite 300, Santa Barbara, CA 93101 Phone: 805-892-2519, FAX: 805-892-2510 http://www.nceas.ucsb.edu/~keitt/ From cjensen at bioeng.ucsd.edu Thu Jul 13 12:41:30 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 13 Jul 2000 09:41:30 -0700 Subject: Simple File I/O Question Message-ID: <396DF13A.97CC3F5E@bioeng.ucsd.edu> I know this should be simple, but.... I have a variable that holds an int. I want to write it to a file. The following code: var = 5 f = open('foo','w') f.write(var) gives this error: TypeError: read-only buffer, int This works if: var = '5' So, How do I write an int variable to a file? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From mwh21 at cam.ac.uk Mon Jul 31 18:56:44 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 31 Jul 2000 23:56:44 +0100 Subject: check file exists References: Message-ID: Moshe Zadka writes: > On Mon, 31 Jul 2000, Randy Heiland wrote: > > > How does one test for whether or not a (Unix) file exists? > > os.path.exists() Hmm, seven answers in about ten minutes (from glancing at headers). Not bad... Cheers, M. -- 58. Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From bjorn at roguewave.com Sun Jul 16 13:24:41 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sun, 16 Jul 2000 11:24:41 -0600 Subject: Discussion: Introducing new operators for matrix computation - general approach? References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <8koktn$dik$1@news-int.gatech.edu> Message-ID: <3971EFD9.FE155FBE@roguewave.com> Andrew Henshaw wrote: > Gregory Lielens wrote: > >John Lull wrote: > ...snip... > > >> I'm don't think this is quite fair. You could just as easily write: > >> b = rDiv(X, y) >> if you simply had an appropriate rDiv() function. > ..snip.. > >Indeed, but it is the old choice between functional/operator notation... > >For example, the second expression, b = (X'*X)\(X'*y), would be in > >functional notation > >something like b=rDiv(Mul(X.T(),X),Mul(X.T(),y)) > >This is ok, but imho far more error prone than operator notation, > >because > >- all linear algebra textbooks present expressions with operator > >notation > >- the operator notation is more natural to almost everybody when dealing > >with arithmetic > > > I wonder if some of these problems could be approached in a more general > manner. What if Python could support the definition of operators in the > same manner as functions? If that were the case then something like: > > opr rDiv(X, y): > > would define a new operator function that would work like: > > b = X rDiv y > > The big advantage would be that special purpose grammars could be easily > imported. The core language could be kept as simple as possible, but still > be extensible in a way that matters to a lot of people. > > I suspect that whitespace would be required around these new 'operators', > although many people already do that with regular operators. Also, I'm not > sure how you'd specify an operator that wasn't valid as a function name, but > I can think of possibilities. Prolog does this (you'll of course have to specify the precedence of the operator also, and to solve the current perceived problem probably their associativity too...) It's something that works relatively well in Prolog, but then Prolog doesn't have namespaces etc... If you think you can solve those problems, I would encourage you to try to implement it and try your solution in a couple of different domains (matrix-, db-, xml-, string- processing?) It could be useful, and if it is, then we can discuss whether it should be added to the core. Thankfully, Python doesn't add new ideas to the core before they have been tried out sufficiently first. C++ did, and has ended up working around design problems (how many people really know how Koenig lookup works...?) python-the-lean-mean-fighting-machine-with-batteries-included'ly y'rs -- bjorn From jcm at bigskytel.com Mon Jul 10 18:06:49 2000 From: jcm at bigskytel.com (David Porter) Date: Mon, 10 Jul 2000 16:06:49 -0600 Subject: Making tabs illegal In-Reply-To: <8kcjqn$k7v$1@nnrp1.deja.com>; from fcahoon@my-deja.com on Mon, Jul 10, 2000 at 01:41:46PM +0000 References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> <20000708005527.L26534@xs4all.nl> <8kcjqn$k7v$1@nnrp1.deja.com> Message-ID: <20000710160649.A4184@novara.avenue> * Forrest Cahoon : > I have heard of the -tt flag, but I don't think that's exactly what I'm > looking for. I'd like to enforce spaces and disallow tabs altogether. > (What does "mixed in a dangerous way" mean, anyway?) Mixing tabs and spaces (a tab here, four spaces there...) is the real problem. Using tabs exclusively or spaces exclusively both work fine. So this is what the -tt flag does: ~ > python -tt Python 1.5.2 (#1, Jul 23 1999, 06:38:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> for x in range(10): ... print 'indented with four spaces' ... print 'indented with one tab' File "", line 3 print 'indented with one tab' ^ SyntaxError: inconsistent use of tabs and spaces in indentation >>> > The issue is being able to enforce a particular coding style in a > development environment. For that reason, it's better to have it > compiled in than to be a command-line switch. Just enforce a particular editor, which converts tabs to four spaces automagically. There are several which can do it. Then again, you have the sources, so if you know c you can add the switch yourself. From paul at prescod.net Tue Jul 25 01:12:15 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 25 Jul 2000 00:12:15 -0500 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> <397BDCC6.9C498F01@my.signature> <397BF66A.EF8BDEF4@prescod.net> <397D1ADA.A8074086@my.signature> Message-ID: <397D21AF.28498FBC@prescod.net> Greg Ewing wrote: > > To get attribute attr_name: > if attr_name is in the instance dict: > return it If I understand this correctly, then the very first time you add the attribute to the dict you effectively wipe out the accessor because the test above will evaluate true every time and the branch that uses accessors will never get called. If so, then your proposal does not allow the use of the XXX entry in the dict for arbitrary values. That would have been the primary benefit over my latest proposal. Subject: Attributes PEP Enhancement Date: Mon, 24 Jul 2000 01:00:02 -0500 -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From richard_chamberlain at ntlworld.com Sun Jul 9 09:41:24 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sun, 9 Jul 2000 14:41:24 +0100 Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> <8k9tot$5o$1@supernews.com> Message-ID: Dale I'm not sure what your original message was but: >>Anyone got any idea how to use makepy? Go into pythonwin and onto the tools menu and select COM Makepy Utility, and then the COM object you want to work with, and finally press OK. That will generate a python file in your py_gen folder, which depending on the object will be quite big. In that file will be a class for each automation object and a set of constants from the type library. On the oreilly site one of the sample chapters for Python Programming on Win32 is the advanced COM chapter which has a bit about makepy: http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html If you haven't got the book it's well worth the money. Richard Dale Strickland-Clark wrote in message news:8k9tot$5o$1 at supernews.com... > Well, all this seemed to do was break an existing working program. I've had > to delete the \gen_py folder to get things working again. > > I am confused now. > > Anyone got any idea how to use makepy? > > Thanks > > Dale Strickland-Clark > > "News.tele2.co.uk" wrote in message > news:8k9o91$7b1$1 at supernews.com... > > Well I've run it and it seemed to work but I'm not really sure what to do > > next. > > > > In fact, I'm not entirely sure what it's supposed to do for me but I'm > > hoping it will at least give me access to some COM object constants. > > > > Where is it documented? > > > > Thanks > > > > Dale Strickland-Clark > > > > > > > > > > From nobody at nowhere.nohow Sun Jul 16 12:18:30 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 16 Jul 2000 16:18:30 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <8kn71u02nn4@news2.newsguy.com> <8knng5$eue$1@slb3.atl.mindspring.net> <8kpavi04id@news1.newsguy.com> <8kpt05$uj6$1@slb3.atl.mindspring.net> Message-ID: On 15 Jul 2000 14:37:57 GMT, Aahz Maruch wrote: >Yeah, one of the reasons I hate AltaVista so much is because it does a >remarkably poor job of result ranking, even by the relatively poor >standards of search engines. I am reminded of something somebody once told me about network TV: "They don't care whether you like the programs or not. All they care about is whether their customers like their product." IOW: You are not the customer. You are the product. -- Grant Edwards grante Yow! An air of FRENCH at FRIES permeates my visi.com nostrils!! From pete at visionart.com.bbs Mon Jul 17 19:50:02 2000 From: pete at visionart.com.bbs (pete at visionart.com.bbs) Date: 17 Jul 2000 23:50:02 GMT Subject: event handler advice Message-ID: <3bRTZQ$kKP@openbazaar.net> i'm trying to write a simple event handler python class. so far i haven't come up with an 'elegant' solution i was expecting. i have a list of different messages, and they are all given different interger values. this list is defined in a C extension, for example msg.INIT, msg.EXIT, msg.STOP, msg.PLAY, ... i want to make a inheritable class that receives one of these messages and calls a member routine with the same name. my handler doesn't know the name of the variable, since python only sends it the INT value. so i need to find some nice way to map these message ids to a method name. i then need to get this name and have the class call it on itself. the end result being i can call "mymessagehandler_inst.handle(msg.PLAY)" and this will in turn call "mymessagehandler_inst.PLAY()" there's a good sized list of these messages, and in the future it will likely expand my guess is i need some dictionary that defines the messages and their routine name (no shortcut way to do this unless python had #define like macros :]) messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} then a routine like class basehandler: def handle(messageid): name = messages[messageid] self.name() #HAHA, no really, how do i do this? but i'm not exactly sure how to write this. need help, thx From peter at schneider-kamp.de Mon Jul 17 10:07:09 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Mon, 17 Jul 2000 14:07:09 +0000 Subject: [Patch] {l,r}just with optional pad character parameter References: <8kshd3$l1h$2@bw107zhb.bluewin.ch> Message-ID: <3973130D.F73CEA79@schneider-kamp.de> Beat Bolli wrote: > > Hi all > > this is my first crack at Python patching. I was simply appalled to find > '3'.zfill(5) not working anymore in 2.0b1, so I decided to do something > about it. Now since zfill can be expressed as rjust with an optional pad > characer argument, I implemented this. Looks fine to me. When you upload a version with updates to documentation and test cases please try to make a context diff (-c if you are using diff or cvs diff). As it should not break any existing code (if someone relies on {r,l}just only taking one parameter I'd say that's her/his problem), I think it will very likely be accepted. But then, only God knows > Live long and prosper! trying to seperate fingers at appropriate position, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From fiona at sitegnome.com Mon Jul 31 16:23:26 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Tue, 01 Aug 2000 06:23:26 +1000 Subject: check file exists References: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: <3985E03E.2DFB9E4A@sitegnome.com> Hi Randy, > How does one test for whether or not a (Unix) file exists? This entry might be useful -> How do I check to see if a file exists? http://www.faqts.com/knowledge-base/view.phtml/aid/2782/fid/552 cheers, Fiona From jtoy at tcgfinancial.com Thu Jul 20 15:38:34 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Thu, 20 Jul 2000 15:38:34 -0400 Subject: newwb Q:telnetlib Message-ID: <39775539.8B533FAE@tcgfinancial.com> Hi, Im trying to write a Python script that runs some simple telnet commands. I want to login, enter usrname/password, then enter a few command like: cd, pwd, mail, etc. I followed the example in telnetlib.py, but I cant get it to work. Can someone write a small example with the variables I wrote above? Thanks for your time. Jason Toy toyboy at toy.eyep.net http://toy.eyep.net From amk at mira.erols.com Thu Jul 13 20:48:01 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 14 Jul 2000 00:48:01 GMT Subject: Test writing volunteers needed References: <14700.44683.572283.391037@beluga.mojam.com> Message-ID: On Wed, 12 Jul 2000 12:44:43 -0500 (CDT), Skip Montanaro wrote: >I'm look for a few people to write some regression tests for the posix (and >windows or mac equivalents), os and sys modules. Some of that functionality To start the ball rolling, here's a little test case for the set{re,e}{u,g}id functions that I added to the CVS version last night. --amk # Simple test case for os.setreuid(), os.setregid() import os, pwd uid = os.getuid() if uid != 0: raise ImportError, "This test must be run as root; skipping" nobody_uid, nobody_gid = pwd.getpwnam('nobody')[2:4] # Set real uid and gid to root, effective uid and gid to nobody os.setreuid( 0, nobody_uid ) ; os.setregid( 0, nobody_gid ) # Change effective ID to nobody os.seteuid( nobody_uid ) # Expect these to fail try: os.setuid( 1 ) except os.error: pass else: print 'Should have been unable to change UID to 1' try: os.setgid( 1 ) except os.error: pass else: print 'Should have been unable to change GID to 1' # These should succeed, since we're just swapping the IDs os.setreuid( nobody_uid, 0 ) os.setregid( nobody_gid, 0 ) # These should now succeed, since we're now back to root privilege os.setgid( 1 ) ; os.setuid( 1 ) From ddb at crystal.uwa.edu.au Wed Jul 26 22:23:23 2000 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Thu, 27 Jul 2000 10:23:23 +0800 Subject: linear algebra in pure Python? References: <397E9CBC.2AD8FA89@crystal.uwa.edu.au> Message-ID: <397F9D1B.F6DA7037@crystal.uwa.edu.au> Tim Hochberg wrote: > > Douglas du Boulay writes: > > > I know that there is the Numeric python extension and/or the > > Matrix extension MatPy, but is there not anywhere a pure Python > > linear algebra package exploiting lists of lists for matrices and the > > like? > > (I would like to use eigen analysis etc. with JPython) > > Conrad has already pointed you to his fully Python array I am actually looking for the extra bits to solve systems of equations and the like. > package. Another option would be to use JNumeric which is a (more or > less) drop in replacement for Numeric for use with JPython. The > LinearAlgebra package has not, unfortunately, been ported(1), but if Thanks, Yes I have already looked at JNumeric. I actually spent a week or so modifying the PyMultiarray to accept Measurement (value,variance) pairs and propogate them through multiplication addition etc, only to find out that the matrix vector arithmetic I was doing (predominantly 3x3 or 4x4) took from 10 to 30 times longer than the original pure-python based matrix class (exploiting lists of lists) which I was using. Needless to say I was disapointed. I am sure it would be terrific as the matrices get larger, but I don't need that at the moment. I suspect the big killer was the very repetitious type coercions involved, which require construction of many temporary matrices (and which I don't have any control over). On the topic of JNumeric, are you interested in a wedge/cross product and Levi-Cevita antisymmetric tensor function add on for PyMultiarray, or would that blow the equivalence with Numeric? > you are only interested in operating on real matrices, there are > several Java packages out there that will perform various linear > algebra operations(2). Interfacing between JNumeric and these outside > package is relatively easy(3). That sounds like the way to go! I'll check it out. > (2) Colt (http://tilde-hoschek.home.cern.ch/~hoschek/colt/index.htm) > is the one I've looked at most recently. You might also want to look > at Nist's JavaNumerics page (http://math.nist.gov/javanumerics/). > > (3) Function to convert between JNumeric and Colt type matrics are as > simple as: > > from Numeric import * > from cern.colt.matrix import * > from cern.colt.matrix.impl import * > > def JNToColt(ja): > nAxes = len(ja.shape) > if nAxes not in (1,2,3): > raise ValueError, "Colt only supports 1, 2 and 3 dimensional arrays" > constructor = [DenseDoubleMatrix1D, DenseDoubleMatrix2D, > DenseDoubleMatrix3D][nAxes-1] > return constructor(ja) > > def ColtToJn(ca): > return array(ca.toArray()) That seems easy enough. Thanks for your help Doug From anders.eriksson at morateknikutveckling.se Mon Jul 31 09:06:35 2000 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Mon, 31 Jul 2000 15:06:35 +0200 Subject: Speed drops when focus moves away from script window References: Message-ID: On Mon, 31 Jul 2000 13:44:16 +0200, "christer fernstrom" wrote: >When running Zope, I have noticed a drastic drop in speed (order(s) of >magnitude!!) when focus is not on the window from which the python >interpreter is running. Response time for buttons change from a few seconds >to minutes. I run Python 1.6 on W2000. Any suggestions of what I should do? > In the Control Panel - System , You can set how much the active window shall 'accellerate' // Anders From cut_me_out at hotmail.com Sun Jul 2 21:19:51 2000 From: cut_me_out at hotmail.com (Alex) Date: 02 Jul 2000 21:19:51 -0400 Subject: multiple inheritance in Python? References: <395FE156.C0C13FBE@esec.com.au> Message-ID: > Does anyone have example of implement multiple inheritance in Python? What sort of example are you looking for? The basic syntax is pretty straightforward, as I understand it. >>> class A: t = 1 ... ... >>> >>> class B: s = 2 ... ... >>> class C(A, B): pass ... ... >>> C.t 1 >>> C.s 2 >>> C would also inherit methods from A and B, if they had any. Alex. From Wolfgang.Strobl at gmd.de.bbs Mon Jul 17 08:50:05 2000 From: Wolfgang.Strobl at gmd.de.bbs (Wolfgang.Strobl at gmd.de.bbs) Date: 17 Jul 2000 12:50:05 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bRCQT$jHe@openbazaar.net> "Neil Hodgson" wrote: > if key == 220: > return 1 > This avoids calling win32ui.TranslateVirtualKey for the "^" key. This helps. Many thanks! >More >tests may be needed for other accent characters or other locales. if key == 220 or key == 221: return 1 is sufficient for the German keyboard locale IMHO, it disables the other special key, on the other side of the keyboard, left to the backspace key, too. That key is labeled "?" and "`" on the German keyboard. -- o ( Wolfgang.Strobl at gmd.de (+49 2241) 14-2394 /\ * GMD Forschungszentrum Informationstechnik GmbH _`\ `_<=== Schloss Birlinghoven, | #include __(_)/_(_)___.-._ D-53754 Sankt Augustin, Germany | From paul at prescod.net Sun Jul 16 13:26:45 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 16 Jul 2000 12:26:45 -0500 Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME References: <963764534.1476580377@news.demon.co.uk> Message-ID: <3971F055.68CD6897@prescod.net> Phil Thompson wrote: > > ... > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. Be careful. When I worked at Watcom we tried to make "Visual REXX" to hear that some other company (not Microsoft, but obviously related to Microsoft) had a trademark on Visual X where X is a programming language. Microsoft licenses the name and other people are supposed to also. Of course this was years and years ago so I don't know what the current situation is. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From paul at prescod.net Sat Jul 15 15:22:19 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 15 Jul 2000 14:22:19 -0500 Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> <396F4473.35DCA488@prescod.net> <8F729880Egmcmhypernetcom@199.171.54.194> Message-ID: <3970B9EB.8FF00EF9@prescod.net> Gordon McMillan wrote: > > ... > > For Python, you want to look > >at > > > >http://starship.python.net/crew/gmcm/distribute.html > > > >For Java, at "jexegen.exe". > > Sorry, Paul, the latter does not bundle in the interpreter. It just > packages up byte code and uses a small exe to start your MS JVM. True, I forgot that because the MS JVM tends to be installed. I think I may have exaggerated the features of the former too. Is there any easy way to make a single executable for Python, the standard library, required .pyd's and your code? My vague impression is that you could if you had a compiler and the source for your pyd's, or else you could fall back on an installer (rather than a single big runnable app). -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From m.faassen at vet.uu.nl Wed Jul 26 08:51:33 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 26 Jul 2000 12:51:33 GMT Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> <8l5lne$lb$1@slb0.atl.mindspring.net> <87snt4iq6k.fsf@redcow.flibble.org> Message-ID: <8lmmsl$hp0$1@newshost.accu.uu.nl> Simon Oke wrote: [snip] >> For the function that creates [1,2,3,4,5,6] of [1,3,5] and [2,4,6], yes. > I believe in INTERCAL this operator is known as 'mingle'. That clinches the issue. We *have* to follow INTERCAL semantics here. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mnjeunn at sandia.gov Mon Jul 10 14:30:28 2000 From: mnjeunn at sandia.gov (mnjeunn) Date: Mon, 10 Jul 2000 11:30:28 -0700 Subject: COM registration Message-ID: <396A1644.6D6C5090@sandia.gov> I am trying to arrange communication between a piece of Visual C++ code and a python program on two different Win95 computers. In its simplest form, my task is to have the Visual C++ code call a function from the python code across the network, and then work with the string that the python function returns. I've managed to get Python to register a COM object on the server computer, but running the same code on the client machine gets no results. In both cases I have a script to run win32com.server.register.UseCommandLine(ClassName). After running the script, I open the dcomcnfg utility to verify that the object is registered...on the server computer (windows 95 version 4.00.950 B, dcom95) it comes up fine, but on the client machine (same windows version, but with IE 4.04.72.3110.8 and dcom98) the file I need doesn't show up under available applications in the dcomcnfg window. Is there another method for registering a python COM object on the client computer? Any ideas or suggestions would be greatly appreciated. Cheers, Mark From dima at xenon.spb.ru Wed Jul 5 11:19:52 2000 From: dima at xenon.spb.ru (Dmitry Rozmanov) Date: Wed, 05 Jul 2000 19:19:52 +0400 Subject: CGI POST on Win98 References: <395FB218.5CCD76C8@tiscalinet.it> Message-ID: <39635218.69678C49@xenon.spb.ru> I see such a behaviour under win95 and tinyweb. If I use post with the CGI_Test.py then python hangs up. Use get instead with test. But your code will work ok and with post and with get. ---Dmitry. Paolo Montrasi wrote: > > I have installed PWS and Python 1.5.2 on my win98 machine, created a > simple form which runs the test() function on the cgi module, when i use > method GET in the form all works perfectly but when I try to use the > POST method the page never appears on my browser and I see python.exe in > my machine process list. The same thing works perfectly under NT. I have > searched the archive but I was not able to find help so I am thinking I > am wrong with something but I do not know where, can you help me? > > ciao > Paolo From root at rainerdeyke.com Sat Jul 15 01:04:22 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 15 Jul 2000 05:04:22 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> <396FABF3.B82E0C2@roguewave.com> Message-ID: "Bjorn Pettersen" wrote in message news:396FABF3.B82E0C2 at roguewave.com... > mylist.foo() # are you calling the foo method on the list or the > elements? A valid point (though not very clearly stated). Suppose that for all X, .X is the elementwise operator such that: a = b .X c is equivalent to: a = [] for x in range(len(b)): a.append(b[x] X c[x]) What about situations where X is a function instead of an operator? Should we allow the following syntax? a = b..f() (Equivalent to the following:) a = [] for x in b: a.append(x.f()) Is b..f(c) equivalent to this: a = [] for x in range(len(b)) a.append(b[x].f(c[x])) or is it equivalent to this: a = [] for x in b: a.append(x.f(c)) For that matter, what if X is .+ (or ..+)? Should we allow this: a = b ..+ c as equivalent to this: a = [] for x in range(len(b)) a.append(b .+ c) There has to be a better way to do elementwise operations. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From erno at iki.fi Fri Jul 21 21:46:59 2000 From: erno at iki.fi (Erno Kuusela) Date: 22 Jul 2000 04:46:59 +0300 Subject: closing a socket References: <8l72lp$mah$1@nnrp1.deja.com> Message-ID: if you want to be able to bind to the same port immediately afterward, you can disable the so-called TIME_WAIT state by setting the socket option SO_REUSEADDR. (you can do this with the setsockopt method of socket objects.) it's not on by default because doing so leads to (small) risk of data corruption with TCP. for in-depth explanation of the whole thing, see and . -- erno From paul at prescod.net.bbs Mon Jul 17 19:10:03 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 23:10:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRSXT$ji3@openbazaar.net> Charles Boncelet wrote: > > .... > > Why is it ordained that objects should have only two operations, "*" and > "+", > defined with simple operators? "+" on strings means something entirely > > different than "+" on numbers. Why not add an "@" operator? Because 90% of Python programmers would not know what it means. Look, if you took a poll of all programmers in the world, only a small fraction use matrices very often. Therefore it is a niche. Most programmers use numbers and strings every day, however. Still, we all want you to succeed. We just disagree on the right approach. Here's my suggestion: > Python could become the primary open source alternative to Matlab in > time > if a few changes were made: Incorporate numpy into the core distribution > (or > release a distribution with it already embedded), The process of creating a numpy enabled distribution is underway. > improve the help facility at the interpreter. A module for that is under development. > simplify the syntax for matrix operations You (matrix people) can do that by parsing your own Python-like syntax and generating Python byte codes or Python source code. You don't need any official blessing from Guido or anyone else. Several people have written compilers for languages like Python IN Python and in other languages. It is possible. There are even techniques for making your language work on the interpreter line. We can help with that. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From oivvioREMOVETHIS at cajal.mbb.ki.se Mon Jul 24 10:57:36 2000 From: oivvioREMOVETHIS at cajal.mbb.ki.se (Oivvio Polite) Date: Mon, 24 Jul 2000 16:57:36 +0200 Subject: the right way of handling **args for __init__ and other methods Message-ID: <8lhlfg$sk5$1@news.kth.se> Hi all. I guess this is more of a design question than a howto question. It has to do with implementing arbitrary-argument set methods. I want the user to be able to use the same interface with __init__ and read. This is a stripped down version: class argeater: def __init__(self, somearg, **args): print "init ",args self.data = {} self.read(somearg, argdict=args) def read(self, somearg, argdict=None,**args): print "read ",args print "argdict ",argdict #putting everything from argdict into args #feels a bit awkward. if argdict: assert type(argdict) == types.DictionaryType for key in argdict.keys(): if not args.has_key(key): args[key] = argdict[key] #now do a lot of stuff to self.data #based on contents of args #but the user will have a nice and uniform interface to the class. spam = argeater(1, a = 1, b = 2,c = 3) spam.read(1, a = 4, b = 5,c = 6) is this have you would have done it? oivvio From bjorn at roguewave.com Mon Jul 24 13:52:24 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 24 Jul 2000 11:52:24 -0600 Subject: mapping the read() fonction References: <8lhsu5$huv$1@reda.worldonline.fr> Message-ID: <397C8258.D58E027A@roguewave.com> Benjamin wrote: > > I would like to map the read() function of a file object > > I have a list of file objects. I want to return the list of their content > using the map function > > I've used the map function to open my list of file > map(open,list,{"r","r","r"}) (to open a list of 3 files for example) > > but I can't do the same for the read() function, because it is a method > function of the file class > How can I map the read() fonction to my list of file? The problem is that I > don't know the class name of a file object. > > The only solution for the moment id to use a for loop on my list.... map( lambda f:f.read(), [list of open files]) or perhaps: def openAndRead(filename): return open(filename).read() map( openAndRead, listOfFilenames ) -- bjorn From oivvioREMOVETHIS at cajal.mbb.ki.se Wed Jul 19 12:11:58 2000 From: oivvioREMOVETHIS at cajal.mbb.ki.se (Oivvio Polite) Date: Wed, 19 Jul 2000 18:11:58 +0200 Subject: emacs keybindings in pythonwin Message-ID: <8l4jv0$t61$1@news.kth.se> PythonWin allows you to customize keyboard bindings. The example file show how to set Ctrl+Q to AppExit and some other things. But what if I wanted to set it to Ctrl-x Ctrl-c Has anyone worked that out yet? Maybe there's a whole emacs.cfg out there longing for the... eh spinning of my harddrive. oivvio From hzhu at knowledgetrack.com Wed Jul 19 18:26:24 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Wed, 19 Jul 2000 22:26:24 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: On Wed, 19 Jul 2000 21:01:22 +0100, Gareth McCaughan wrote: >You can do A\B in O(n^2) time? That's news to me. In fact, >I don't believe you. Oh-oh, (blush) The ratio between A.inv*B and A\B is more like (n+m)/(n/6+m), or something similar. The the factor is larger for smaller m, but it's bounded and not going up like n. Huaiyu From tim_one at email.msn.com Mon Jul 24 03:35:39 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 24 Jul 2000 03:35:39 -0400 Subject: IEEE 754 (was RE: [long and fussy] But what do these operators _mean_?) In-Reply-To: <20000721084848.C9897@xs4all.nl> Message-ID: [Edward Jason Riedy] > Python doesn't provide reasonable ways to test for Inf or NaN. > > These are needed in new eigenvalue routines (the only known > optimal ones). Yes, I know, there are some non-IEEE architectures > left, but they shouldn't be encouraged. (Keep in mind that I'm at > Berkeley; expect a strong IEEE-754 bias.) More accurately, Python provides no ways at all to test for Inf or NaN. If it provided unreasonable ways, half the battle would be over . [Thomas Wouters] > Well, now that the C standard (C99) says *something* about the > implementation of floating point numbers, we can expect some > change in this. > However, given that it took 10 years before Guido decided for an > all-out move from K&R C to ANSI C, it's not likely to happen > overnight ;) > > Tim can probably say more about this, though, as usual. For starters, I know of no implementation of C99, so it's a bit premature to switch to its features. There's no portable way to provide 754 support via current C (e.g., as Jason said in another msg, *many* compilers optimize "x != x" to 0 today when x is double or float; indeed, Python itself does too!). This means that just to start, we need to define an internal 754 C API, and implement it via mounds of platform-#ifdef'ed trickery. The practical problem with this is that it requires people expert in both their platforms (HW and compiler and libc) and 754 subtleties, and they're mighty rare. I can do it for the intersection of x86 chips and Microsoft's compiler, but that's it. The only platform-clever floating code in Python today is in fpectlmodule.c, and was written by someone whose main interest in life seemed to be to make 754 hardware act as if 754 had never happened (i.e., it aims to raise a fatal error (not a Python exception!) on overflow, invalid operation and "divide by 0"). So that's the technical battle. The political battle is that most number-crunchers in practice still don't understand why 754 is A Good Thing, and in my experience fight it tooth & nail (yes, Kahan likes to pin the blame on short-sighted vendors and their infernal benchmarks, but having been on all sides of this game, I can assure you that vendors will claw each other to death to provide what users *ask* for -- but, alas, they overwhelmingly don't ask for a better 754 story). In short, just business as usual in the wacky world of floating point . nevertheless-python-*could*-become-an-outstanding-754-platform-ly y'rs - tim From see at my.signature Mon Jul 24 01:28:07 2000 From: see at my.signature (Greg Ewing) Date: Mon, 24 Jul 2000 17:28:07 +1200 Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> <8l9qfp$gc6$1@nnrp1.deja.com> <6%_d5.1964$6E.417529@ptah.visi.com> <8lclbq$f6o$1@nnrp1.deja.com> Message-ID: <397BD3E7.38BF914F@my.signature> You may know already, but I just thought I'd mention that you can use this trick to make the implementation of your 2-index __getitem__ function look nice: class MyClass: def __getitem__(self, (x,y)): ... -- 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 denalione at my-deja.com Sun Jul 9 23:07:21 2000 From: denalione at my-deja.com (Dale Burnett) Date: Mon, 10 Jul 2000 03:07:21 GMT Subject: PythonService file creation Message-ID: <8kbel1$qrp$1@nnrp1.deja.com> When running my app at the command prompt using the debug option I can create a new file and write to it. When the app is started via Control Panel/Services the file is not created and written too. I have used the python native file functions and the NT api CreateFile() function. I have tried running the service using the System Account with Interact with Desktop checked and specifying an account. Any suggestions? Sent via Deja.com http://www.deja.com/ Before you buy. From edream at tds.net Mon Jul 17 18:59:41 2000 From: edream at tds.net (Edward K. Ream) Date: Mon, 17 Jul 2000 22:59:41 GMT Subject: Can't load .pyd files from embedded Python interp References: <39722B90.A41E02B5@tds.net> <8F73D685Egmcmhypernetcom@199.171.54.194> <3973384F.D6964D88@tds.net> <8F748426Egmcmhypernetcom@199.171.54.155> Message-ID: <39738FAD.A3BF1484@tds.net> Hey! Clean link, proper execution! Yippee. > >I'll write up my experiences when I've successfully embedded Python in > >my app. For now the conclusion seems to be that one only need link in > >C:\Windows\System\python15.dll to the app. There are some details > >specific to Borland, but presumably they won't be difficult. Getting a clean link was straightforward. I renamed c:\Windows\System\python15.lib to be python(orig)15.lib, then ran the Borland IMPLIB utility that creates import libs as follows: IMPLIB -a python15.lib python15.dll The -a option adds '_' alias for cdecl functions for compatibility with Microsoft libraries. After running IMPLIB one should _not_ declare functions with the __declspec attribute; just #include "python.h" and the linker is happy. Don't ask me why, maybe it's the -a options, maybe it's IMPLIB itself, maybe its magic. To link, I just added python15.dll and python15.lib to the project. That's all. I've just stepped through the following statements in my test app with no apparent problems: Py_Initialize(); PyRun_SimpleString("import sys"); PyRun_SimpleString("for i in sys.path: print i"); PyRun_SimpleString("import parser"); Well, err, stderr and stdout seem to have disappeared, but that's another issue. Presumably there is a way to send output to a window, a la Pythonwin. Heh, heh. Warning Redux: you must not call any of the misnamed "very high level" functions in the C API that have FILE * arguments when using the Borland compiler because Borland's idea of a struct FILE is not the same as Microsoft's. It's really too bad that there are _no_ "very high level" functions in the C API that will open a file for you. This should be fixed, and it would be trivial to do so. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From dougfort at downright.com Sat Jul 1 07:06:35 2000 From: dougfort at downright.com (Doug Fort) Date: Sat, 1 Jul 2000 07:06:35 -0400 Subject: Missing OmPyUnit module in OmPyUnit Message-ID: <0hk75.10271$HD6.284269@iad-read.news.verio.net> We've been using Steve Purcell's PyUnit from SourceForge. It's limited, but reliable. I'm attempting to investigate OmPyUnit as an alternative. It seems to offer more functionality, plus I have great respect for ObjectMentor ands Robert Martin. However, the package I downloaded seems to be missing a module: OmPyUnit. What's up with this? It doesn't fill me with confidence. -- Doug Fort Meat Manager Downright Software http://www.dougfort.com/~dougfort From anamax at earthlink.net Fri Jul 14 21:09:22 2000 From: anamax at earthlink.net (Andy Freeman) Date: Sat, 15 Jul 2000 01:09:22 GMT Subject: IDLE startup error on NT4 Message-ID: <8kodjp$aj2$1@nnrp1.deja.com> While starting IDLE on NT4, I get an error message about it not finding tcl80.dll (and the other tk and tcl dlls), an error that I don't get on Win95/98. No, it isn't the error message from FixTk - FixTk appears happy - the problem seems to occur during import _tkinter. My "fix" was to simply move the relevant files to the Python DLL directory on NT, but surely there's something else going on here. -andy Sent via Deja.com http://www.deja.com/ Before you buy. From gjm11 at g.local Sat Jul 15 18:38:30 2000 From: gjm11 at g.local (Gareth McCaughan) Date: Sat, 15 Jul 2000 23:38:30 +0100 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> <396FABF3.B82E0C2@roguewave.com> Message-ID: Huaiyu Zhu wrote: > How would you write this in list compresension (in less than 10 lines)? > > B*(sin(A*x+b).*(A*y)/3)/C > > Note that * is matrix multiplication and .* is elementwise. Note that C is > a matrix so the / is matrixwise. If you want to write everything as for > loops it takes at least 30 lines, without any decent error analysis. B*[p*q/3 for p in A*x+b, q in A*y]/C (I've forgotten the proposed syntax for comprehension, so that may be slightly wrong.) I'm not sure what precedences you want the .* and / operators to have, so it's possible that I really mean B*[p*q for p in A*x+b, q in (A*y)/3]/C ; of course they evaluate to the same thing anyway. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From sabren at manifestation.com Sat Jul 29 18:29:17 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 29 Jul 2000 18:29:17 -0400 (EDT) Subject: The 'widget' demo with python/Tkinter In-Reply-To: <3983D000.55110EEE@galactica.it> Message-ID: On Sat, 29 Jul 2000, Francesco Bochicchio wrote: > Matthew Dixon Cowles wrote: > > If you haven't seen it already, you might find Fredrik Lundh's > > introduction to Tkinter worth a look. It's at: > > > > http://www.pythonware.com/library.htm > > > > I certainly find it useful. As far as I'm aware, it's the current state > > of the art in Tkinter documentation. > > > I also found it very useful ( though it seems still a work in progress You both might want to check out _Python and Tkinter programming_ by John E. Grayson - http://www.manning.com/Grayson/index.html It's considerably more complete than anything else I've seen, and a well written book all around. It's written for people who already know python, and are ready for the next step. I'd never made a real GUI app before, and it helped a lot. It's also got a complete Tkinter and Pmw reference in the back.. I've also heard rumors that Fredrik's coming out with a Tkinter book, but I don't think I've ever heard _him_ say that.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From tony at lsl.co.uk Tue Jul 11 08:10:07 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 11 Jul 2000 13:10:07 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8kf0od$708$1@newshost.accu.uu.nl> Message-ID: <003101bfeb30$f3e5bb60$f0c809c0@lslp7o.lsl.co.uk> Martijn Faassen wrote: > > It sounds to me as if this would > > be a useful thing to layer on top of a COM or CORBA interface to > (for instance) an existing GIS, taking advantage of whatever versioning, > > locking, etc., that that existing software provides. > > Hm, I'm not quite sure what you mean here. What's a GIS? Sorry. Geographical Information System. The better ones (for example, the system produced by the company I work for) are already object oriented, with versioning, etc. "Free-standing" things like integers and lists aren't persistent, but the objects relating to geographic data are, and they can be quite interesting of themselves. But it sounds like this would require *serious* design commitment... > > So, why isn't this better known? > > I think because the Python and Zope worlds are quite a bit apart in some > ways. Of course there's lots of overlap, but your average Zope user isn't > necessarily well aware of the Python community and vice versa. Of course > AMK's article is probably specifically an attempt to make the ZODB more > well known. > > It'd also help if the ZODB could be easily downloaded as a > package by itself. That's my main gripe at the moment, I think. I'll have to make some comments on the "Feedback" slots at digicool, or somewhere - but not today! Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ Well we're safe now....thank God we're in a bowling alley. - Big Bob (J.T. Walsh) in "Pleasantville" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From rogerducky at my-deja.com Thu Jul 27 15:52:38 2000 From: rogerducky at my-deja.com (rogerducky at my-deja.com) Date: Thu, 27 Jul 2000 19:52:38 GMT Subject: rexec and traceback Message-ID: <8lq3u4$2ib$1@nnrp1.deja.com> Potentially a newbie question, but nobody else seem to have asked this before... Is it possible to use the traceback module along with rexec to produce a stack trace? Here's what I'm trying to do: In one.py: import traceback print traceback.extract_stack() ------ In two.py: import rexec import traceback import sys #Added exc_info, which traceback needs. class DHooks(rexec.RHooks): ok_sys_names = ('ps1','ps2', 'copyright', 'version', 'platform','exit', 'maxint', 'exc_info') if __name__ == '__main__': env = rexec.RExec(DHooks()) env.r_execfile('one.py') ----- Executing one.py in the normal environment produced the expected result. Running under rexec, however, exc_info simply will not return a stack trace. (Originally, I hoped it would return a stack trace for the restricted environment...) Reason for my wanting this? Capture/printing of error traces while within the restricted environment. Any help and/or suggestions would be appreciated. Thanks, Peter Yu Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Mon Jul 3 07:55:55 2000 From: cut_me_out at hotmail.com (Alex) Date: 03 Jul 2000 07:55:55 -0400 Subject: Getting double* from NumPy array? References: <72T75.24010$i5.229971@news1.frmt1.sfba.home.com> Message-ID: > There is quite a bit to know and just telling you to access x->data > would not be doing you any favors. Ah, well my apologies for the bad advice, then. > Please read the entire chapter before proceeding. Sounds like something I ought to do, too. Alex. From xiarcexml at yahoo.com.bbs Mon Jul 17 14:10:03 2000 From: xiarcexml at yahoo.com.bbs (xiarcexml at yahoo.com.bbs) Date: 17 Jul 2000 18:10:03 GMT Subject: Does Python code >.require<< a run-time environment?? (New to P Message-ID: <3bRKgT$mnm@openbazaar.net> I suppose... I have always had the kits and the java files installed on my computer... and when I started my major project (version 1.0) completed with Java, I was doing so because I had Macs and IBMS and Unix's, Linux's as potential clients. I was going for Java because of its touted 'platform independence'. I love Java... BUT.. it is not as independent as Sun would have wanted it... Ironically, now, I have only Windows users... but the language I chose to 'learn' was Java for it, and it is written in Java... Currently, they DL the files and install them into wherever their classes run, and type in the RUN box C:\WINDOWS\Jview CyberGameTable (yes, I, , have users using Jview, as it is installed, and convincing them do DL Sun's package did not work) I was hoping that Python (and it does seem to be really neat on the programming end) would provide me with the ability to create an executable that one would Download and run without having to (1) set classpath (2) run-line command it.. etc... ((I had been hoping for it in Java, too... chock it up to beginners' stupidity--one year later I am a little wiser)) I've read references to 'compiling it to C'... is this a laborious process requiring knowledge of C or C++? ~Dave __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From theebh at yahoo.com Tue Jul 25 01:13:01 2000 From: theebh at yahoo.com (Jonathan) Date: Tue, 25 Jul 2000 05:13:01 GMT Subject: Python is wierd! Message-ID: <8lj7kr$ttc$1@nnrp1.deja.com> Hi, just finished going through the 'Learning Python' book, and the feeling that i get is that Python is really wierd(compared to other conventional languages like C++, Java, etc). For e.g.(correct me if i'm wrong) 1. There are no keywords to declare static or instance variables; it all depends where they are placed(whether it's right after the statement, or inside a ). Isn't it harder for other programmers to know at one glance what type of attributes the class define? 2. No *formal* declaration of static class methods, e.g. no 'static' keyword (though i'm not sure how useful static methods are in OOP design). I read somewhere in this newsgroup that the workaround way is to define the method outside of the class - doesn't it break the 'encapsulation' a class suppose to have? 3. No keywords to differentiate between passing arguments by reference or value! An integer is passed by value(reference to a new copy), while a mutable object is by reference. To pass a list by 'value', i know you just need to insert one more line(list = [:]), but it seems so 'inconsistent' compared to Java or even PHP. (Not to mention the number of 'gotchas' listed in the book that are bound to trap beginners - *shudder*) The reason i'm picking up python is that i got sick of PERL:), and don't really like the inflexible typing of Java. Furthermore, some ppl claim that Python is easier to learn, enables you to write much cleaner codes... However, after reading the python book, my head is still spinning, trying to catch all the 'intricacies' of this language. No doubt it will be a powerful and useful 'tool' to me once i get used to it; but i don't think it's suitable to be a first programming language for non-programmers(i read somewhere about this project going on). Pascal(for procedural) and Java(for OOP) is still the better choice to start off, IMHO. regards, Jonathan Sent via Deja.com http://www.deja.com/ Before you buy. From stephen_purcell at yahoo.com Tue Jul 4 22:46:49 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 05 Jul 2000 02:46:49 -0000 Subject: Java line to JPython (help Obj.class) In-Reply-To: <8jt239$jb3$1@nnrp1.deja.com> Message-ID: <8ju7ip+ed4s@eGroups.com> tiddlerdeja at m... wrote: > Can anyone help me turn this java line into JPython? > > URL dtdURL = DOMConfigurator.class.getResource("l"); > > The problem I'm getting is that DOMConfigurator doesn't seem to have > attribute class. > > Is there a workaround? How about: dtdURL = DOMConfigurator.getResource('l') If DOMConfigurator is a Java class, then the JPython object 'DOMConfigurator' is equivalent to the 'DOMConfigurator.class' in Java. e.g., >>> import java.lang.Object >>> java.lang.Object -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From jbauer at rubic.com Mon Jul 31 10:58:00 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 31 Jul 2000 09:58:00 -0500 Subject: How about each() instead of zip()? References: <2b384e38.2adaccde@usw-ex0107-055.remarq.com> Message-ID: <398593F8.30D576FE@rubic.com> Hamish Lawson wrote: > A number of the proposals for a better name for the nascent > zip() function seem to employ the notion of taking items from > *each* of the constituent sequences. So I thought: how about > each() itself as the name of the function? The naming issue for Lockstep iteration is essentially over. See PEP 201: http://python.sourceforge.net/peps/pep-0201.html - The function's name. An earlier version of this PEP included an open issue listing 20+ proposed alternative names to zip(). In the face of no overwhelmingly better choice, the BDFL strongly prefers zip() due to its Haskell[2] heritage. See version 1.7 of this PEP for the list of alternatives. Jeff Bauer Rubicon Research From alex at magenta.com Tue Jul 25 07:29:50 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 25 Jul 2000 13:29:50 +0200 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> Message-ID: <8ljttr0b98@news1.newsguy.com> "David Bolen" wrote in message news:uya2q279j.fsf at ctwd0143.fitlinxx.com... [snip] > If a function requires that the supplied object support a "write" > method, then all Python requires is that be the case. And it only > cares when the function actually tries to make the call, not at > compile time or function declaration. It doesn't where the object > fits in a class hierarchy, nor if the object provides all sorts of > unrelated methods. It only wants that "write" method to be present. > > Until you've worked this way you can't imagine how clean, natural and > "fun" this is - at least IMO. It makes design much cleaner and > simpler, and means that you can evolve things more simply. No, it's > not perfect and has its own warts, but I'm sold on it. Incidentally, this is basically the way that C++'s templates work, except that they do their work at compile-time so that the constraints are slightly different -- if the call to method write is inside an if that never happens to be satisfied, you still need an object with such a method to instantiate the template, since the compiler is unable (in general) to ensure the "never happens"; but if it's inside a method of the template which, itself, is never invoked, then that's OK. The fact that templates are oblivious to class hierarchies and only care about a given subset of an object's signature is part of what gives them their awesome power. Think of Python as further extending this signature-subset-based paradigm of "typing" to every use of an object, not just uses happening inside a template, and (at least if, like me, you're a C++ guru moving to Python:-) some things may fall into place better... > Don't get me wrong - if your background is more biased towards heavily > typed languages (mine was, although I did have some decent experience > in others) it's sort of a paradigm shift and takes some thinking to Sort of, I guess. But I come from a lot of very-strong-typing myself, and I took to Python like a duck to water. Indeed, it's led me to reconsider much of what I took for granted about strong-typing and its usefulness. Alex From alex at magenta.com Fri Jul 28 09:16:29 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 15:16:29 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8ls1bb017he@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o25nr.e7.grey at teleute.rpglink.com... [snip] > Define a variable to get the name space in there but you don't know how it > is going to be used later on. a = None. Now make it a list in a concise > manner. > > for x in range(10): > a.append(x) > > Whoops, can't do it. It isn't a list. So make it a list. Right, make it a list. I.e., instead of a=None start out with a=[] and you're done. What's hard about this? > list(a) > for x in range(10): > a.append(x) > > Whoops, can't do it. None can't be transformed into a list. Whatever a refers to, the expression statement list(a) is not going to make a refer to anything different than before. > for x in range(10): > if a: > a.append(x) > else > a = [x] > > All that because of type checking? Jumping through 3 hoops just to get > done what should be a trivial matter. Clumsy! Just set a=[] once, outside of the loop -- how much easier can it get? Alex From samschul at pacbell.net Mon Jul 10 21:02:45 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Tue, 11 Jul 2000 01:02:45 GMT Subject: Can anyone hear me? (was Solution to IDLE and Tkinter problems) References: <200007110027.RAA16246@stevie.loop.com> Message-ID: <8kdrnd$j8b$1@nnrp1.deja.com> I am reposting your previous message so no one will have to search the news group for it. Hope this helps. Sam Schulenburg Dear Python Community, I have noticed, as have many others, that IDLE has trouble running Tkinter programs. I suspected, and read in newsgroup postings, the explanation that IDLE uses Tkinter and it causes problems when one Tkinter session is run within another. I have thought up, and implemented, a very simple solution to this problem(the code is below); however, it is pretty ugly and clumsy. My solution is just to use the os.system command to call python.exe and run the script. There are a few problems, however. os.system takes a _long_ time to get the interpreter running and blanks my screen while it does it. It would be nice if there was some more efficient command to start the interpreter. A second problem is the kludge randomly breaks, and I don't know why because I don't understand the IDLE code. Also, because of my lack of IDLE knowledge, I am probably using the wrong calls to get what I want and I am sure it could be made cleaner. I have had this for a while, and I did not post because I was sure that something this obvious would have already been done, or at least thought of as a TODO. I still suspect I am missing something, because this seems so simple, and it is definitely a problem... Thank you for your time, Jesse Weinstein My Solution: (insert in ScriptBinding.py) The lines with #JW after them are the lines I added menudefs = [ ('edit', [None, ('Import module', '<>'), ('Run script', '<>'), ('Alt Run script', '<>'), #JW ] ), ] def run_script2_event(self, event): #JW filename = self.getfilename() #JW if not filename: #JW return #JW print filename #JW os.system("c:\\python\\python.exe " + filename) #JW << previous ? next >> Unsubscribe from comp.lang.python Sent via Deja.com http://www.deja.com/ Before you buy. From serve at circe.dem.nl Thu Jul 20 14:36:49 2000 From: serve at circe.dem.nl (slauijssen) Date: Thu, 20 Jul 2000 20:36:49 +0200 Subject: Python in game development? References: Message-ID: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> Err, by the way On a linux cd I found a C++ interpreter. The funny thing is that the interpreter itself is written with c++ and interprets itself to interpret the really to interpret code. Got it? ;-) Mallor schreef in berichtnieuws v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... > Are any of you game developers out there using Python as your game engine's > embedded scripting language? I am wondering what drove your decision to use > Python instead of other embeddable scripting languages? I'd like to hear what > your overriding concerns were, and also what they are now, having put Python to > the test. > > -- > Cheers, Infernal Troublemaker Troll > Mallor "By simple mistake, mortals themselves amuse." > > > From michael at stroeder.com Mon Jul 3 07:33:54 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 03 Jul 2000 13:33:54 +0200 Subject: Python CGI security References: Message-ID: <39607A22.CA190D70@stroeder.com> Moshe Zadka wrote: > > On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > > > Ok, here are some examples from Python1.6a2 sources (see below). > > OK, here is an answer to the report I just snipped. Note that I only posted *excerpts* of the ITS4 output. Feel free to ask if you want the whole output by e-mail (approx. 1000 lines with a lot of repeated messages). > There are a few types of "potential security holes": > > -- exposing insecure parts of the API, such as os.system(). These should > stay, since the user should have those at his disposale Would it be possible to provide a secure version in the Python lib of e.g. os.system() with same function parameters but less unsecure behaviour instead of just wrapping it 1:1? > -- OS/2 message formatting. I haven't looked at it, but this only > concerns you if you're working on OS/2 Hmm, I do not know under which OS my demons will run. Would be worth to collect such insights somewhere. > -- checked "dangerous" functions, which are therefore fine as far as I > could see > > -- one sprintf() which will work fine as long as integers are <128 bits, > which is true in the forseeable feature. I'm planning to patch this, > just in case, but it should be fine anyway. (I'm talking about the > first sprintf() in posixmodule.c) Thanks for following up. Ciao, Michael. From phil at geog.ubc.ca Sun Jul 23 18:57:44 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 23 Jul 2000 15:57:44 -0700 Subject: Operators for everything (was Re: Operators for matrix) References: <3977AF5E.552F4F42@my.signature> <397B6319.27A6438A@nceas.ucsb.edu> Message-ID: "Timothy H. Keitt" writes: > R (www.r-project.org) uses '%' as in A %*% B. Might be nice to > standardize. > > Tim This is the first mention of R/Splus I've seen in this discussion -- for those who don't know, R is the free version of Splus, which is a very popular language in the academic statistics community. Here's a longer list of their operator choices from: http://stat.ethz.ch/R-alpha/doc/html/function.html %% Arithmetic Operators (base) %*% Matrix Multiplication (base) %/% Arithmetic Operators (base) %in% Value Matching (base) %o% Outer Product of Arrays (base) %x% Kronecker Product of Arrays (base) & Logical Operators (base) && Logical Operators (base) Phil From piet at cs.uu.nl Mon Jul 31 14:35:04 2000 From: piet at cs.uu.nl (Piet van Oostrum) Date: 31 Jul 2000 20:35:04 +0200 Subject: Dictionaries behaviour Linux vs. Windows References: <3985B4B4.8F7BD5F7@schlund.de> Message-ID: >>>>> Carsten Gaebler (CG) writes: CG> Hi! CG> I have the following problem with Python 1.5.2: CG> dict = {} CG> dict.get("test", []).append(1) CG> On Windows 95: dict == {"test": [1]} CG> On Linux: dict == {} CG> What's the difference? On Windows 95 I get {}, which is what it should be, as you don't change the dictionary. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From rumjuggler at cryptarchy.org Tue Jul 25 01:36:05 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Tue, 25 Jul 2000 05:36:05 GMT Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> <397BDCC6.9C498F01@my.signature> <397BF66A.EF8BDEF4@prescod.net> <397D1ADA.A8074086@my.signature> <397D21AF.28498FBC@prescod.net> Message-ID: <0s9qnsocfp80r09u4b4sm49ttuetdmmqb4@4ax.com> On Tue, 25 Jul 2000 00:12:15 -0500, Paul Prescod wrote: >Greg Ewing wrote: >> >> To get attribute attr_name: >> if attr_name is in the instance dict: >> return it > >If I understand this correctly, then the very first time you add the >attribute to the dict you effectively wipe out the accessor because the >test above will evaluate true every time and the branch that uses >accessors will never get called. > >If so, then your proposal does not allow the use of the XXX entry in the >dict for arbitrary values. That would have been the primary benefit over >my latest proposal. What about: To get attribute attr_name: if attr_name is in the instance dict: if the class's has_get_accessors flag is not set: return it else: translate attr_name to interned get_accessor_name using cache for each class along the inheritance path: if the class's has_get_accessors flag is set and it contains a method called get_accessor_name: call it and return the result else: if the class contains an attribute called attr_name: return it for each class along the inheritance path: if the class has a __getattr__ method: call it and return the result raise AttributeError That way, if I understand correctly, a class can still (actually, must) use the same XXX for __dict__['XXX'] and __get_XXX__. -- Barnabas T. Rumjuggler My words but a whisper, your deafness a SHOUT. -- Jethro Tull, "Thick as a Brick" From gregory.lielens at fft.be Wed Jul 19 05:03:39 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Wed, 19 Jul 2000 11:03:39 +0200 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: <39751EFA.6293FDFE@prescod.net> Message-ID: <39756EEB.7CC8F262@fft.be> Paul Prescod wrote: > > Tim Hochberg wrote: > > > > Similarly: > > > > dot((A,B), C) -> A(B)(C) > > dot(A, dot(B,C) -> A(B(C)) > > > > which looks pretty good to me. And it's arguably closer to paper > > linear algebra notation than A*B is. > > Another good idea! You can even make it look like the new-syntax > proposal: > > A()*B()*C > A()+B()+C > A()-B()-C Wow...Personally, I do not like it too mush...to say the least! I found it really confusing, because there is no way to visually tell if you are calling a function or performing matrix multiplication, which is not a good thing as these two operation are likely to appear at the same time on many lines of codes involving linear algebra...This is particularly confusing for A(B), and slightly better for A()*B()*C...but again, A could be a function with no arguments! On the other hand, the JNumeric "symmetric" notation looks already better, even "sexy": (A)(B), yeah! but I see 2 problems: -the parentheses around A are important because they are a visual hint to indicate that this is not a function call, but a matrix multiply (or more generally, an inner product for Nd numeric arrays). But internally, (A)(B) is the same as A(B) (I think it is the case, please correct me if I am wrong), so we have to count on the good will of people to avoid the A(B) thing, and to avoid to write (f)(A) when f is a function. The last case is not likely, but if f is an array of functions, (f[i])(A) could happen (and have a totally different meaning if f is an array of Numeric arrays). This problem comes only from "look", but it is important imho, I really fear to see A(B)! -it gives one more operator only, the multiplication...This is the more important, I agree, especially if (A.inv)(B) can be evaluated at the same cost as Matlab's A\B, but it rules out the distinction one could want to make regarding other operations. Greg. From stephen at cerebralmaelstrom.com Tue Jul 18 21:07:29 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Tue, 18 Jul 2000 18:07:29 -0700 Subject: Getting local IP address... References: <8l236h$8b8i$1@nntp6.u.washington.edu> Message-ID: <39750089$1_1@my.newsfeeds.com> > On the bright side, generally it's not necessary to know your own > IP address. I'm curious why we are seeing this question so often, > what are folks doing out there? Actually, my need has nothing to do with an application -- it is to answer a question i'm curious about. My cable internet provider, Road Runner, does not supply static IPs to its customers as a matter of policy... that way there's something for them to upgrade to, y'know... I'm wondering just how often the IP is shuffled -- my current one looks terribly familiar :) So I put up a log program to check periodically (daily) and see what my IP is, then record it. So far, after a week and a /major/ system outage due to an upgrade, i'm still using that terribly familiar one. :) I'm not going to mail and ask them because my experience with the bosses at RR is that they tend to be rather dumb, and I don't want them to think about it anymore then they have to if they happen to nto be expiring :) For instance, Road Runner Tampa Bay blocks, as a matter of policy, all incoming data on port 25 to stop spam.... :) --Stephen -----= 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 alex at magenta.com Mon Jul 10 09:12:14 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 10 Jul 2000 15:12:14 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <81da5.125084$WS3.1096675@typhoon.we.rr.com> <8kbuqn0uoa@news1.newsguy.com> Message-ID: <8kciag017h5@news2.newsguy.com> "Stephen Hansen" wrote in message news:Lgga5.125600$WS3.1101565 at typhoon.we.rr.com... > But you can't patent something like: "Something that carries large > objects from one place to another." You *shouldn't be able to*. But, given the way the Patent Office actually works, you can patent anything you can get away with, and you're likely to get away with a lot (e.g., patent something easy to prove impossible, such as "an algorithm to compress bitsequences which will always reduce the sequence length by at least one bit"; or, patent "some way that allows web users to order your product with a single click"...). Maybe the courts will later reverse it, but meanwhile you've got something to blackmail people and firms with. I don't think Sun has patented the general concept of programming language, but you should do a patent search just to make sure:-). And, sure, if they have it's probably invalid (previous art, obvious to one skilled in the art, etc, etc), but until a court invalidates it the can sue, or threaten to sue, they can ask for relief against your "infringement" until the case is decided, etc, etc. > You don't patent the concept of the end-effect, you patent the process, > model, device, etc... Yes, that's the theory. The practice of software and business-procedure patents is a much sadder and grubbier reality, it seems to me. But with BT claiming they hold a patent on (any way of implementing) hyperlinks, and Amazon claiming they hold a patent on (any way of implementing) one-click orders, etc, that should be abundantly clear these days. That much being said, if somebody's gotta be sued under these absurd current practices, then, better it be MS, than me; if nothing else, they can well afford the lawyers (they, and HP, did manage to win the "look and feel" suit, didn't they). Alex From aahz at netcom.com Sun Jul 16 00:56:41 2000 From: aahz at netcom.com (Aahz Maruch) Date: 16 Jul 2000 04:56:41 GMT Subject: Python equivalent of CPAN in Perl References: <397122FB.71E32674@wl.vg> Message-ID: <8krfa9$vf4$1@nntp9.atl.mindspring.net> In article <397122FB.71E32674 at wl.vg>, Peter Halliday wrote: > >Is there a module or program like CPAN in Python that collects all the >existing modules available in some organized way, and even compiles it >for you? If not, that would really provide python with a reliability and >usefulness that Perl has. We already beat them in the syntax hands >down, let's start catching up in the modules dept. We've got half of it with Vaults of Parnassus. Another third will come with the standardization of distutils in Python 2.0 (remember, 1.6 has been renamed to 2.0). -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From eq3pvl at eq.uc.pt Mon Jul 17 12:29:50 2000 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Mon, 17 Jul 2000 17:29:50 +0100 Subject: Zope newbie References: <8kv8ba$rq3$1@nnrp1.deja.com> Message-ID: <3973347E.B73015F4@eq.uc.pt> coughlan at gothaminteractive.com wrote: > I've just installed Zope on Linux, and the documentation that comes > with it refers almost exclusively to NT!? There is very little on Zope > with Apace. > > Does anyone know of a URL or forum to get a decent tour of Zope on > Linux? zope.com is also *very* dissappointing. The website is www.zope.org > It's unclear to me how to even create a hello world program to make > sure it's installed and running. Any advice, would be appreciated. check in the /doc directory for install information. You don't need to use apache to check if Zope works, use Zope internal server instead. There are serveral ways to use Zope with Apache. For fastcgi, my favourite, in zope.org check for the fastcgi howto (under documentation-howtos). regards pedro From thiele at muc.das-werk.de Wed Jul 5 08:29:32 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Wed, 05 Jul 2000 14:29:32 +0200 Subject: Segmentation fault(LINUX) and no idea why! Message-ID: <39632A2C.E6ABECEB@muc.das-werk.de> Hallo! In my program I create a new thread. In this new thread I fork and replace the child with an other program using excel. Normaly I have up to four threads with this procedure. So I have a number of threads and the same numbers of childs (the called program) The problem is sometimes (relativly seldom, so it's unreproducible ;-( ) I get a segmantation fault and the pytthon interpreter stops. But I if the segmentation fault happens, one of the childs is not running anymore. (I don't know is that the reason or a result) A little testprogram with the same construction shows that if a segmentaltion fault happens in one child, the parant keeps running. I get no traceback from the interpreter. My Question is, where can I look for the problem. Why does the interpreter (-> the whole program) die. What can be the reason? From alex at magenta.com Sun Jul 30 09:20:03 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 15:20:03 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> Message-ID: <8m1evu42n4o@news2.newsguy.com> "Courageous" wrote in message news:39838BAC.C855EDCB at san.rr.com... > > > > Actually I think it would be easier for non-programmers to > > >learn a language if it has strict typing. > > > > I concur. In non-programming, life is strictly typed. Allowed > > operations are determined by the type of the object. You can't > > make a phone call on a waffle-iron. > > This is a conceptualization issue, and I suspect to a degree, > false. If "x" is merely a label, one can imagine x labeling > 3 or x labelling red quite easily. Your analogy works because This only proves that types are not attached to LABELS, but rather to the OBJECTS they happen to be labeling. I.e., that Python's modeling of this situation is exactly right:-). Alex From greg at perceval.be.bbs Fri Jul 14 06:20:04 2000 From: greg at perceval.be.bbs (greg at perceval.be.bbs) Date: 14 Jul 2000 10:20:04 GMT Subject: calling .exe inside a .py? Message-ID: <3bOe75$nG6@openbazaar.net> In reply to the message of shindich at my-deja.com sent on Jul 13 (see below) : > Try this: > > import os > os.execl ('foo.exe') execl is kind of alias for execv. So using this solution, be aware of the following: execv (path, args) Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows. This mean tha if you have the following code in a file: import os os.execv("/bin/ls",("ls","/")) print "Done!" Last line will never be executed because the python process is replaced by the /bin/ls command. To avoid this, Unix allows you to use the fork system call : import os i= os.fork() if i != 0: os.waitpid(i,0) # wait for the child to complete. print done! else: # child process os.execv("/bin/ls",("ls","/")) An other and easier solution which also works under Windows : import os os.system("foo.exe") print 'Done!' Sincerly yours -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Thu, 13 Jul 2000 shindich at my-deja.com wrote: > Date: Thu, 13 Jul 2000 19:51:21 GMT > From: shindich at my-deja.com > To: python-list at python.org > Newsgroups: comp.lang.python > Subject: Re: calling .exe inside a .py? > > In article <8kl527$tke$1 at nnrp1.deja.com>, > level2junkie at my-deja.com wrote: > > Does anyone know how to call an .exe file from inside a .py file? > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > Try this: > > import os > os.execl ('foo.exe') > > For more info read http://www.python.org/doc/current/lib/os-process.html > > Regards, > > Alex Shindich > http://www.shindich.com/ > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > > From johngrayson at home.com Sat Jul 15 10:09:53 2000 From: johngrayson at home.com (John Grayson) Date: Sat, 15 Jul 2000 14:09:53 GMT Subject: Why make a language case sensitive? References: <000c01bfedcf$3e316160$6cb745c6@timaratz> Message-ID: <8kprb9$826$1@nnrp1.deja.com> In article <000c01bfedcf$3e316160$6cb745c6 at timaratz>, "Peter Timaratz" wrote: > I thought there might be a reason why it needs to be case sensitive. I guess > if you come from a Unix background (which I don't) and you create a > language, then it seems natural to make it case sensitive. > > I'm not trying to start a war, so I'll refrain from expressing my opinion. > :) > > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of richard_chamberlain > > Sent: Friday, July 14, 2000 9:52 AM > > To: python-list at python.org > > Subject: Re: Why make a language case sensitive? > > > > > > Hi Peter, > > > > That's a bit of a sore point at the moment :-) > > > > do a search on deja for case sensitive and you'll find a whole argument on > > the subject. > > > > Richard > > > > Peter Timaratz wrote in message > > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > > I can't think of any advantages to a case sensitive language. > > Python is a > > > very well-designed language though, so I imagine there is a good reason > > that > > > it is case sensitive. So what are the advantages of a case sensitive > > > language? > > > > > > > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > If you're used to C++ (or Python or Java), which don't have to be Unix-based, then you quickly discover that a simple naming convention in your code makes for easy (cheap) maintenance and reuse... e.g. MyClass ... Class definition myClass ... Instance of class (or other 'variable') MYCLASS ... Constant (maybe an enumeration) Then, within a class, instance or variable name, mixed case aids readability: A = ... ? Old Basic ;-) mainwindowframeborderwidth = ... Caseless language (or poor C++) mainWindowFrameBorderWidth = ... IMHO better Take a look at example code for any of the major languages and I'm sure that you'll spot a trend... Of course, if you're an assembler programmer, then you probably don't care -- but even assemblers can be case sensitive :-) John Sent via Deja.com http://www.deja.com/ Before you buy. From laurent8 at sxb.bsf.alcatel.fr.bbs Wed Jul 12 03:10:02 2000 From: laurent8 at sxb.bsf.alcatel.fr.bbs (laurent8 at sxb.bsf.alcatel.fr.bbs) Date: 12 Jul 2000 07:10:02 GMT Subject: simple (?) re question Message-ID: <3bN89Q$krp@openbazaar.net> Andrew Kuchling wrote: > You're using the wrong tool; regexes are very clumsy for this sort of > thing. Try looking at your regex using Demo/tkinter/guido/redemo.py > to see how it matches; the first .* matches '/foo/bar/SCCS/s.file', > the ?! expression matches nothing, and the second .* matches nothing. ok I will see this sample, but I've got a problem with the init of the Tkinter ----------------- Python 1.5.2 (#2, Jun 22 2000, 10:49:11) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import _tkinter >>> import Tkinter >>> Tkinter._test() Traceback (innermost last): File "", line 1, in ? File "/users/public_w3p/share/python/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py", line 1947, in _test root = Tk() File "/users/public_w3p/share/python/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: This probably means that Tcl wasn't installed properly. ----------------- I don't know where the python interpreter try to find the init.tcl file, in which directories it searches. I've put this file in a directory included in the $PYTHONLIB, but it doesn't work as you can see, if you have an idea... > Similar problem; the regex engine finds an alternative match. Why not > just write: > > path, filename = os.path.split( filename ) > if 'SCCS' in string.split(path, os.pathsep): > # SCCS in path I have make a sample as simple as possible in order to points out the problem, and of course for a such simple thing I'd rather use the string module, but my real code is more complex and I can't specialize it like this. > for the second? Much clearer than a complicated regex which has to be > analyzed to be understood, and it makes it more apparent that you're > making a decision based on the path. I want to use to regex module because I want to match thing like : it begins with something "/foo" then there is something I don't care, then I can find something like "F.?[0-9][\w*][.]/" and then something I don't care and it will finish by a "java|py" string. Of course, this is an example ! thanks for your answer. -- Fr?d?ric LAURENT mailto:frederic.laurent at sxb.bsf.alcatel.fr T?l : (33) 03 88 55 70 00 poste 57228 From neilh at scintilla.org Mon Jul 17 20:56:56 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 18 Jul 2000 00:56:56 GMT Subject: automatically filling web forms? References: <20000717071134.A2351410@vislab.epa.gov> Message-ID: > Still, have some questions though. Another cgi script that I'm trying to > write to doesn't work. > The python program hangs and just waits until I terminate it. Any idea. Its a good idea to read http://www.webtechniques.com/archives/1998/02/kuchling/ the techique given for ensuring you see tracebacks is very useful. Neil From scarblac-spamtrap at pino.selwerd.nl Tue Jul 25 13:33:25 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 25 Jul 2000 17:33:25 GMT Subject: Python is wierd! References: <8lk1c5$fv4$1@nnrp1.deja.com> Message-ID: Jonathan wrote in comp.lang.python: > I'm making this judgment from a perspective of a newbie to python, > comparing to my experience with these 2 languages(back when i first > started learning them). I'm thinking back which one has been easy to > pick up so far, and which one helps me to understand programming > principles. Things like strict typing, declaration of > functions/variables, difference btwn pass-by-value or pass-by- > reference, static or instance variables, (etc) seems easier to explain > to a newbie in Pascal or Java (of course i dun mean to use pascal for > serious programming purposes). Of course. And backtracking cuts are easier to explain in Prolog. Those things aren't basic programming principles - algorithms are, the whole concept of algorithms. Strict typing, declaration, pass-by-, static variables, they're all just elements of the particular languages you name. But they're not the basic principles. To me, Python has less irrelevant things to learn, so you can learn about algorithms faster. Almost immediately. How does java "Hello World" go again? Something like public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } Look at all the irrelevant language-specific stuff the newbie has to know about! Now show the newbie how a sorting algorithm for a list of numbers works; and compare to the Python version :). You think Python is weird - well, yes, it's different from C, Pascal and stuff. Those are very traditional procedural languages. But languages are supposed to be different, otherwise there would be no point :-). It would be good to look at some others, like Lisp, Haskell, Prolog... -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From hzhu at users.sourceforge.net Fri Jul 28 15:00:28 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Fri, 28 Jul 2000 19:00:28 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com><397FCE9C.F22BB6B4@see.my.signature> Message-ID: Let's see if this description make sense. In python there are objects and there are names. There are operations that act on existing objects and those that create new objects. These have nothing to do with mutability, except that for immutable objects, there are no operations acting on existing objects. Assignments change what a name refers to: a = b # these two names now refer to the same object. b = c # b refers to the one c refers to, instead of the one a refers to. Function calls pass reference of existing objects to local names in the function. Whether within the function you do things to the existing objects or newly created objects is another matter: b.method_call() # A reference to the object refered by b (and c) is # passed in (as self). # The object may be modified in function. # The names b and c still refer to the same object. do_something_to(b) # A reference to the object is passed in. # The object may be modified in function. # The names b and c still refer to the same object. b = some_operation(b) # A reference to the object is passed in. # The object may be modified in function. # The name c still refers to the same object. # The assignment causes b to refer to the returned # object, which may be the same, or different. The difficulty of new users from other languages is that they are not used to regarding a name and the object it refers to as separate things. In staticly typed languages, the association between names and objects are much tighter - it happens at declarations and often never changes. IMHO, the name/object dichotomy is much more descriptive for python than the reference/value dichotomy. Huaiyu On Thu, 27 Jul 2000 22:49:58 -0400, David Goodger wrote: >"Pass by Spanish Inquisition" is a highly Pythonic term, and one that I like >a lot. However... (and forgive me if this has already been mentioned) > >I've heard Python's parameter passing termed "pass by assignment". So a >function: > > def f(x): > pass > >which is called as: > > f(y) > >simply does the assignment: > > x = y > >with x in the function's namespace, and y in the caller's namespace. So what >happens in regards to values/references? Lists and dictionaries appear to be >passed by reference, because they're mutable. Strings, tuples and numbers >appear to be passed by value, because they're immutable. Not having delved >into the internals of the process, I can't authoratively say, but this seems >a perfectly reasonable explanation to me. All parameters are simply assigned >or bound to new names in new local namespaces. What is possible depends on >the type of object that's passed. > >Of course, this just passes the buck over to, "so how is assignment >performed in Python?". But that seems to be an easier question to answer. > From embed at NOSPAM.geocities.com Fri Jul 7 09:25:53 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Fri, 7 Jul 2000 09:25:53 -0400 Subject: wxPython or wxWindows + Python? References: <3964FE55.ECD800AB@tds.net> Message-ID: > Hi, > > I'm thinking of embedding the Python interpreter in my wxWindows app, or > else using wxPython to host my app. I can think of various pros & cons. > If I was doing that, I would start in Python, because it's certainly better to prototype in Python, and then I would consider writing C extensions for the Python app as an "accelerator" once a well known function exists that you could boil down to C code. The eventual third alternative is to do BOTH. Write your C++ app in wxWindows, and also use wxPython. I haven't tried this personally, but I suppose I'll end up doing something like it if I ever have an application grow large enough. Warren From ekw1 at my-deja.com Thu Jul 6 23:54:23 2000 From: ekw1 at my-deja.com (ekw1 at my-deja.com) Date: Fri, 07 Jul 2000 03:54:23 GMT Subject: mxODBC module References: <8k14us$c4c$1@nnrp1.deja.com> <20000706110421.B876@reepicheep.avalongroup.net> Message-ID: <8k3k9c$vrv$1@nnrp1.deja.com> In article <20000706110421.B876 at reepicheep.avalongroup.net>, Timothy Grant wrote: > On Thu, Jul 06, 2000 at 05:20:33AM +0000, ekw1 at my-deja.com wrote: > > I can't help you with the first problem, but I know the second one well. > Usually this happens when you have installed the win32 extensions. There is > an ODBC module that comes with them and you end up with a name conflict. The > solution is to delete the odbc.pyc file that is in one of the python/Win32 > directories. (Sorry, I don't have a Windows computer near me at the moment > to check the exact place). > Your solution sounded like it would work, but then I found out that I don't have the win32 extensions installed. Thanks for your help. ekw Sent via Deja.com http://www.deja.com/ Before you buy. From kern at caltech.edu Sat Jul 8 23:26:20 2000 From: kern at caltech.edu (Robert Kern) Date: Sat, 08 Jul 2000 23:26:20 -0400 Subject: Anyone used Python for GPIB instrument control? References: <3967A2E2.F6AFEE44@home.com> Message-ID: <3967F0DC.AAA67AE@caltech.edu> europax at home.com wrote: > > I think I am going to get a C compiler for work where we use NT. At > home here I use Linux and don't want to eat up my hard drive with > Windoze stuff (I have Windows 3.1, though since it is so small) > > I saw that Borland is selling a CD with Turbo C, Turbo C++,etc for about > $60. Thats a pretty good deal. I also found some free WIN32 > compilers. One based on the GNU gcc and it has an IDE called Rhine. To toot my own horn a little, you can use gcc (for the mingw target) to compile Python extensions that are binary-compatible with the released Python executable. See http://starship.python.net/crew/kernr If you can spare the disk space, I recommend installing Cygwin ( http://sourceware.cygnus.com/cygwin ) to give you a UNIX-ish environment, and then install the mingw compiler. If you're into IDEs, there is a listing available at http://www.mingw.org/mingwfaq.shtml Happy hunting. > Rob. [snip] -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From alex at magenta.com Sat Jul 29 05:13:48 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 11:13:48 +0200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> Message-ID: <8luhsi01ce8@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o40d1.49c.grey at teleute.rpglink.com... [snip] > >> (/^(\d{1,2})[Dd](\d{1,3})$/ || /^(\d{1,2})[Dd](\d{1,3})([\+\-])(\d{1,2})$/) > > >I don't know what you mean here. I never do anything like that, I'm > >happy to say. :) > > Extracting up to 6 match groups, 5 of which will be integers with the last > being a + or a -. This means all groups can be either strings or None. I've > already verified that groups 1-4&6 will be integers through the regular > expression so why check again? You have most definitely NOT verified that these groups will be integers: you have verified that they will be sequences of digits *which may be empty*. You keep talking about how the person on the street feels -- do you truly believe he or she perceives '' as being a NUMBER?! Of course, you can (and IMHO should) do better in this particular case because the start of the string is fixed; i.e., you could use a more compact and efficient expression: dicere = re.compile(r'(\d{1,2})[Dd](\d{1,3})([+-]\d{1,2})?$') The key issue here is striving to 'express any given thing ONLY ONCE' -- here, the 'given thing' is the start of the RE. I've also applied two minor simplifications -- no need for a ^ at the start, since we're going to re.match and not re.search; and no need to escape the + or - when within brackets. Strictly an issue of trying to minimize the syntax-complexity of the RE to make it as readable as possible (not much, but that's OK:-). Now, after mat=dicere.match(theline), you've left with only 3 match groups. Groups mat.group(1) and mat.group(2) are known to be non-empty sequences of digits; group mat.group(3) is either empty, or a + or - sign followed by a non-empty sequence of digits. You simply need to be explicit about what you want to do with each, as per Python's general mantra "explicit is better than implicit". If you have to do this any oftener than once, you should of course pack it in a little function of its own. What to put in it and what to leave outside is of course an issue of design, depending on what exactly you need/want to reuse. To get one single field out as a number (0 if the digit sequence is empty), you could do: def intgroup(match,index): digits = match.group(index) if digits: return int(digits) else: return 0 To get ALL of the matched-fields out as numbers (as before): def intgroups(match): results = [] for g in match.groups(): if g: results.append(int(g)) else: results.append(0) return results Or, of course, you could also move the re.match inside the function itself, etc. Also, I've been careful to only return a 0 for an empty sequence ("" or None), and not many other kinds of non-digit-sequences; you could soften that, if needed, with a try/except in lieu of the if construct I've chosen. On the other hand, you could only package the digit sequence to integer conversion, if you get such seqs from several different sources and not just from match.group constructs: def asInt(digits): if digits: return int(digits) else: return 0 and of course you could have BOTH layers, too: def intGroups(match): results = [] for g in match.groups(): results.append(asInt(g)) return results where the latter might perhaps more elegantly be expressed as: def intGroups(match): return map(asInt, match.groups()) [map and friends are easy to overuse, but, for a simple case like this, it seems made to order]. Don't get me wrong -- I fully realize how attractive it is, when you frequently need a certain functionality, to find it bundled right in the language, or in its standard libraries. Here, you seem to very often need 'treat this digit-sequence as a number, 0 if empty', and have chosen to think of any language not supplying it to you in a pre-cooked form as 'quirky' in this regard. But, really, the advantages of a language's built-in behaviour in a given situation being _close_ to what you want are easily overrated. As long as the issue is not as fundamental as, say, unlimited-precision integers:-), keeping it under your control has its own pluses: when the behaviour you want becomes slightly different (and it will!), it's an easy change to make rather than a potential nightmare. Let's take your case, that of parsing and interpreting input strings of the form 'iDj[+k]' as found in role playing games ('roll i j-sided dice and add k'). Say that you now also need to support GURPS, which only ever uses six-sided dice, so the j is often omitted *and needs to default to SIX*, NOT to zero, when it is. If you have closely relied on a language's implicitly and silently transforming empty digit-sequences into 0, you have to insert a lot of code, in various appropriate places, of the form "if x==0: x=6". If you have your own digits-to-number conversion function, on the other hand, the change is easier, sharper, and more explicit. For example: def asInt(digits, default=0): if digits: return int(digits) else: return default def intGroups(match, default6index=-1): groups = match.groups() defaults = [0] * len(groups) if default6index >= 0: defaults[default6index] = 6 return map(asInt, groups, defaults) Now, you only need to change some calls from: x=asInt(match.group(2)) to x=asInt(match.group(2), default=6) (you don't _need_ to give the argument name, but I find it very readable in this case!), or, when you're doing it in bulk to all groups, change: nums=intGroups(match) to nums=intGroups(match, default6index=2) > it behind and if or try every time. I don't feel that is an uncommon > occurance for anyone who might be taking numbers from plain text and wanting > to perform math operations on them. It's not all that rare, but very often 0 is not the desired result of an empty digit sequence. I get a lot of "strings that I know should be [non-empty sequences of digits; representations of dates; syntactically valid GUIDs; &c, &c]" from XML parsing, and rarely is 0 what I want the empty-string or missing-string to be equivalent to. An error is more often what I want to receive in that case; the rarer cases where the empty-string is OK (and the default is probably most often 1 in that case, NOT 0!) are best handled by either try/except, or an explicit test. Why would one think that 0 is most often desired, by the way? Take your RPG-dice example again. If you accepted a syntax such as 'D20+3', would anybody on Earth take that as meaning 'roll no 20-sided dice at all, and add 3 to the non-result'?-) Come on. If you ever WANT to accept such specs, they'd better be VERY explicit, say '0D20+3' -- you want to explicitly SEE that 0 there (if the string was generated by another program, it might make life simpler to accept it, but having the explicit 0 is not a burden and clarifies things). If you accept 'D20+3', which seems sensible to do, it must default to mean the same as '1d20+3' -- roll ONE 20-sided die, etc, etc. Same in the typical XML situations, by the way. is OK for "two ham and cheese sandwiches", but, if the number attribute can be omitted, then it had better default to ONE ham and cheese sandwich, not ZERO of them (although the explicit number='0' case should probably be accepted). Isn't that what the person on the street expects, when going to a counter and saying "ham and cheese sandwich, please", rather than an explicit "one sandwich" or "two sandwiches"?-) He or she expects one sandwich, not zero. What the counter attendant will do on an explicit order of "zero sandwiches" is here of course another issue:-). So, the language had BETTER not second-guess what IS meant when a digit-sequence happens to be empty! Defaulting it to the integer 0, as Perl does, seems to me a pretty bad design choice, predicated on a situation that is not really frequent. But I would oppose defaulting it to the integer 1, either, AS A LANGUAGE-BUILTIN CHOICE. The meta-design mistake lies in trying to have the language second-guess the programmer's intent: explicit is better than implicit. Just let the programmer STATE what he or she intends to happen when the digit-sequence is empty. If in a given application domain that is a frequent issue, the statement will happen once, as a function: def asInt(digits, ifEmpty=1): if digits: return int(digits) else: return ifEmpty the programmer may encode the default once (here assumed to be 1) and only have to make it explicit in the code body when it needs to differ; or the '=1' may be omitted if the programmer accepts 'explicit is better than implicit' and WANTS to code explicit statements such as: x = asInt(match.group(2), ifEmpty=6) each and every time (maximally readable, IMHO). In any case, the choice is UP TO THE PROGRAMMER, just as it should be: the language has not made it in advance for him/her, and has not second-guessed in the ambiguous case. Bliss!-) > >>> a = 1 > >>> b = a > >>> a = 2 > >>> b > 1 > >>> a = [1] > >>> b = a > >>> del(a[0]) > >>> b > [] > > Forget, for a moment, what is happening internally. What looks like here > is that in the first case there is an assignment going on and in the latter a > reference. Nevermind that what is happening in the first case is a references > objint[1] and b references objint[1] and when we change a it points to a new > reference objint[2]. It is the difference in behavior of an identical > operator that is ambigious. I'm sure even though I am aware that it happens I > am going to be nailed by it a few times before I get used to it. There is no difference in the behaviour *of an identical operator*. The difference is in the behaviour of two different constructs, a = 2 in the first case versus del a[0] in the second case. Use IDENTICAL operators, and you'll get the same behaviour: >>> a=[1] >>> b=a >>> a=[2] >>> b [1] See? EXACTLY as in the first case, b is not in the least affected by any rebinding whatsoever that you may perform on a. The difference is between _rebinding_ a, and _modifying_ whatever a is bound to (which can't happen when a is bound to something that cannot be modified, of course -- a number, string, tuple). Rebinding a never has any effect whatsoever on any other variables that may happen to have been bound to the same object as a before the latter variable was re-bound. Modifying happens to the OBJECT, *not* to the variable[s] bound to it; and so, after the object is modified, all variables, still bound, to it now reference the modified object, never the original, unmodified one, which isn't even around any longer. Never any "identical operator" in the two different cases, and never any ambiguity. You may have trouble thinking of variables as post-its that are just transiently bound to something (whether that something get modified during that transient, or not; indeed, whether that something is ever SUBJECT to modification, or not), but there is no ambiguity and no identical-operators. An everyday analogy is with identifying-roles (unique ones, that is) as opposed to names. 'The president of Smallton Soccer Club' and 'The president of Smallton Country Club' can happen to refer to the same person AT A CERTAIN POINT IN TIME, but there is nothing forcing the situation to remain the same. If that person undergoes some modification, e.g. she dies her hair blue, then that modification happens to 'both' presidents. If a new president of the Country Club is elected, the president of the Soccer Club can remain the same person. Other identifying-roles may refer to unmodifiable objects (hard to find examples in the real world, but a slight abstraction that is not alien to everyday thinking fixes that). 'My favourite novel' and 'Your favourite novel' can both happen to be "Moby Dick" at a given point in time (and nobody's going to modify the novel "Moby Dick" itself, which is an abstraction of what is common to all physical books that are copies of it:-). If I change my tastes so "My favourite novel" becomes "Heart Of Darkness", that does not automatically change _yours_, nor can it modify "Moby Dick" itself in any sense; it's just a rebinding of one variable, with no effect whatsoever on the bindings of other variables (here, other people's favourite novels) that just happened to be similarly bound at one point in time. > >Isn't that worse than the program giving up? > > No. The program giving up in the customer's hands because of an unchecked > except is a far cry worse than a nigglet but having it continue on. As a > customer which would you rather have, given the choice of these two: > > a: A program that crashes, stopping everything that you're doing with no > chance of recovery > > b: A program that behaves oddly but allows for chance of recovery. As the 'behaving oddly' will typically produce irreversible alterations of a precious persistent database, while the crash can at least be assumed to leave the database intact, the choice is anything but easy. Would you rather die suddenly and painlessly, but with no chance of making a last will and testament, or slowly in excruciating pain, but with a last chance to put your worldly affairs in order? What a heck of a choice to have to make! Fortunately, it doesn't have to be made: wrapping the top-level entries in a try/except is so TRIVIALLY easy, that there is really NO excuse for any program not doing so. Just as there is no excuse for not HAVING a last will and testament already made, if your estate (were you to die suddenly) has any worth whatever (yes, I know that most people die intestate, often leaving a mess in the executors' hands, and most programs do crash irretrievably on occasion -- two sad comments on the state of the world, that most people never think of their own demise AND most programmers never think of possible errors; but that does not stop ME from having a last will registered, nor from wrapping my programs in try/except...:-). (PS: to ensure the database is unpolluted, transactions exist: a crash will rollback the transaction, only an explicit commit will make the changes persist; the 'odd behaviour' that pollutes the database, however, is not helped at all by this, unless you've been able to express ALL the semantic constraints on your data as triggers in your db -- fat chance!-). > Right, which is worthless in a script. I'd personally have the Python > check what mode it is in and toss an exception when it is in interactive mode > and gets a meaningless statement. It does so on every other possible > ambiguity, why not this one when it is even less grey than a lot of the ones I > am tossing out? Is there a purpose for having such informative statements in > non-interactive mode? I'm not sure there is any practical way for Python to ensure that a certain statement IS meaningless, i.e., that it can have had no side-effects whatsoever. If such insurance could be had without pain, it would be worth having. But if there's a price to be paid, and I suspect there would be, I would not be willing to pay it. > >No, my entire point was that you need to know what your data is *anyway*. > > Right, I know what the data is, I don't need the language to ask me at > every operation, "Are you sure? I mean, really, really, REALLY sure!?" The language asks nothing: just TELL it what you know, explicitly. If you know s is a string which is a non-empty sequence of digits, and want to use the equivalent integer, use int(s). If s may be an empty sequence, or None, or "foo", you need to just-as-unambiguously state what is to be done in those cases. You appear to ASSUME that the only sensible thing in those cases is to have int(s) return 0, but I hope I've shown above how wrong that would be. Just write your explicit, tailored conversion-function ONCE, again as shown above, and you're all set. > >You need to know that something is an integer anyway, so why not simply > >tell the computer what's going on? I'm *not* saying the language should > >do the checking. It can't; even though Perl tries. > > Because what if I want to do something that the computer thinks is > non-sensical? Such as? Whatever it IS you want to do, if algorithmically feasible, it can be expressed. > >checking. If you want the system to shut up about your mistakes, > >you can always do this in Python: > > >try: > > a = a + 1 > >except: > > pass > > Great, now I get to litter my code on a per operation basis with tries > instead of being able to set it on certain variables. That would make more > sense. In Python, a variable refers to an object, PERIOD. It would make no sense at all, in this setting, to make a variable carry, besides the reference, extra flags specifying peculiar special-case behaviour, so that two variables referring to the same object would not be equivalent because of the flag-setting; a huge increase of complexity for no real gain, since the flags' meaning just has to depend on the object as well, so what happens when the variable with the peculiar flags is re-bound to some object of a completely different type? You want tailored behaviour, you put it in the OBJECT, *NOT* in the several variables that may or may not refer to it at different points in time. We're doing OBJECT-oriented programming, not VARIABLE- oriented programming, see? This is utterly fundamental to the language architecture, and even the underlying idea of O-O programming. Getting different behaviour from two variables referring to the same object, as can happen e.g. in C++ (because C++ variables also have type, as well as object having it, and not all methods need be virtual, so there CAN be a semantic mismatch between variable & object!) is a horrid wart, and in practice never what one MEANS to do. > Right, which is basically what I had to do except I left None as None. > Just seems like a pain in the butt to do after I have allready made sure, > beyond all doubt, that those variables contain numbers in the first place. Hey, you just *SAID* there could be a None, so you had NOT made sure at all that they did contain numbers! None is NOT a number. The empty sequence is not a number. You're contradicting yourself! > >Though I may be missing something about regular expressions here and > >I'm goofing up? > > A regex could return a string or None, only one of which is convertable to > int. You must litter your code with such checks. No, you must just code *ONCE* what specific integer you want None to be transformed to: you encode that in a make-this-an-integer function, and, if it's always the same integer, you're done -- you then just call that function, see above. Which gives you the needed flexibility of having a different number for None in some cases, etc, etc, again see above. Alex From wjdandreta at worldnet.att.net Wed Jul 5 01:15:39 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Wed, 05 Jul 2000 05:15:39 GMT Subject: Python and .lib files Message-ID: <%vz85.6488$oh5.499440@bgtnsc04-news.ops.worldnet.att.net> Is it possible to call functions in a .lib file with Python? If so, what is the easiest way to do so? Bill From gee308 at mediaone.net.bbs Tue Jul 18 01:10:03 2000 From: gee308 at mediaone.net.bbs (gee308 at mediaone.net.bbs) Date: 18 Jul 2000 05:10:03 GMT Subject: newb question Message-ID: <3bRc3R$lXa@openbazaar.net> what is a simple way I can save variables that people enter in from 'raw_input' ? That way, someone enters the variables they want, then when the script is booted up everytime the machine starts, it will grab the variables from somewhere. Thanks. Jason Toy toyboy at toy.eyep.net From petersc at stud.ntnu.no Mon Jul 10 18:14:47 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Mon, 10 Jul 2000 22:14:47 +0000 Subject: redirect output of functions to a string or file References: Message-ID: <396A4AD7.5A3966E6@stud.ntnu.no> "Fernando Rodr?guez" wrote: > > Is there a way to tell Python to "automagically" redirect the output > of _all_ functions to a string or file? O:-) You can redirect standard output: import sys sys.stdout = open("somefile.output","w") then you can just print the result of the functions. hope that helps - if not, send code or wait for better replies, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From zeitlin at seth.lpthe.jussieu.fr.bbs Mon Jul 17 10:40:02 2000 From: zeitlin at seth.lpthe.jussieu.fr.bbs (zeitlin at seth.lpthe.jussieu.fr.bbs) Date: 17 Jul 2000 14:40:02 GMT Subject: Looking for a tree widget with control of text color Message-ID: <3bRFK3$izp@openbazaar.net> On Wed, 12 Jul 2000 14:23:54 GMT, Tom wrote: >This surprises me. >It is my understanding that wxPython is a 'native' gui, so, on Windows, its >tree control would be implemented using the windows tree view common >control, This is correct. > which is dynamic but doesn't support differing text colors for > different nodes. This is not entirely correct: newer (comctl32.dll 4.70+) versions of the treeview common control implement the so called "custom draw" functionality which wxTreeCtrl uses. Regards, VZ From ge at nowhere.none Mon Jul 10 17:21:51 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 10 Jul 2000 21:21:51 GMT Subject: Enumerating drives References: Message-ID: In article , Lars Lundstedt wrote: >Anyone know how to enumerate drives (local and network) in Python? I can't believe that Windows users and applications are still expected to know what server and/or drive and partition contains their files. That is _so_ 1969. -- Grant Edwards grante Yow! I'm having an at emotional outburst!! visi.com From boncelet at eecis.udel.edu Mon Jul 17 13:24:45 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Mon, 17 Jul 2000 13:24:45 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: Message-ID: <3973415D.5262CD86@eecis.udel.edu> (Huaiyu Zhu wrote a proposal for adding special linear algebra operator to Python) This proposal has been dismissed by many on this list (my paraphrasing) "because we don't want to pollute Python with new symbols/syntax for just one problem domain." Some have dismissed linear algebra as a small domain at that. Let's get some facts (yes, I know we are not supposed to let facts interfere with our arguments on usenet): 1. Amazon.com lists 117 book matches for "python", but most of these are for the snake or Monte. A quick perusal indicates there are 13 books currently available and another 7 on order for language. Amazon lists 179 matches for "matlab", of which 81 are currently available and 61 on order. Verdict: there are approximately 7 times as many Matlab books as Python books. 2. Alta Vista finds 4492 pages for "python language", and 489540 for "matlab". Even the one word "python" search only finds 412030 pages (which of course includes many references to the comedy troupe and the snake). Alltheweb finds 53378 for "python language" and 53368 for "python program"; it finds 156525 for "matlab". Verdict: There are 3-100 times as many web pages mentioning "matlab" as "python language" or "python program". 3. At my university (which I assume is pretty typical), all the engineering students use Matlab at some point in their studies. Most (perhaps all) of the math, physics, and chemistry students use Matlab at some point. Many of our ECE graduate students use Matlab extensively in doing their dissertation research. AFAIK, I am the only person using python for anything. (I am sure there are others, but I don't know of anyone and there are no courses using python.) Vendict: at my university, Matlab is tens to hundreds of times more popular than python. Conclusion: please don't dismiss linear algebra as "just another problem domain". If python incorporated numpy into its core and added some support for linear algebra syntax, it could easily double, triple, or more in popularity. Remember, these people spend real money on Matlab. Even the student edition is about $100. Now to the specifics of the proposal: I'd like to see "@" for matrix mulitplication and "*" for element-wise multiplication. This preserves compatibility with numpy, although breaks it with the MatPy package. It is more important, IMHO, to preserve compatibility with the existing python numerical facilities than with Matlab. Any user switching over will have to learn a lot of new things anyway. Distinguishing @ and * should be easy enough. Charlie Boncelet -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From olczyk at interaccess.com Mon Jul 10 13:52:46 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Mon, 10 Jul 2000 17:52:46 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <81da5.125084$WS3.1096675@typhoon.we.rr.com> <8kbuqn0uoa@news1.newsguy.com> <8kciag017h5@news2.newsguy.com> Message-ID: <396d0cde.369352218@nntp.interaccess.com> On Mon, 10 Jul 2000 15:12:14 +0200, "Alex Martelli" wrote: > >That much being said, if somebody's gotta be sued under these absurd >current practices, then, better it be MS, than me; if nothing else, they can >well afford the lawyers (they, and HP, did manage to win the "look and >feel" suit, didn't they). > > Yeah, but if they had tried a Mac port which Mac stopped in court first, they would have lost. Lately they haven't had that much luck in court. Anyone using C# has to take that into account and wonder if it will be here in two years. Look at J++ ( yes it's still around, but does anyone use it?) From dale at out-think.NOSPAMco.uk Sat Jul 1 17:07:33 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 1 Jul 2000 22:07:33 +0100 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <8jlmj0$r1q$1@supernews.com> Start simple. Unless this is particularly time critical, I'd create a folder on the Build server and share it with suitably limited access. Give the Web server write access to the folder. The Web server writes a batch file or Python script to the shared directory. Every few minutes the Build server checks this folder for a file and executes it. If you need some feedback, it could change the name of the file or move it to a subdirectory while it's running so the Web server can see it's active. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants donotspam-jen at personic.com wrote in message news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > FYI, I'm doing all of this on Windows NT, in case that makes a difference > ... > > Is there a good way to get a script on one computer to talk to a script on > another computer? The process I'm thinking of is pretty simple ... I want a > script on a Web server to be able to send a command to a build server to > start a build process. I'd also like the Web server to be able to query the > build servers to find out their status (so that two builds do not run at > once on the same machine, for example). > > I've read a little about SOAP, but I think that my needs are probably a lot > simpler than that. The easiest way to accomplish this is to setup a Web > server on each of the build machines, too, I guess ... but I was hoping that > I could just have the scripts that run on the build servers run as NT > services. > > Thanks! > > Jen > > > > From dberlin at cygnus.com Sun Jul 2 23:09:14 2000 From: dberlin at cygnus.com (Daniel Berlin) Date: 02 Jul 2000 23:09:14 -0400 Subject: Referring to method of a class without instance? In-Reply-To: gmol@my-deja.com's message of "Mon, 03 Jul 2000 02:32:37 GMT" References: <8jou05$mei$1@nnrp1.deja.com> Message-ID: <86r99bewpx.fsf@dan2.cygnus.com> gmol at my-deja.com writes: > In my application I use the observer/observable pattern..question > I hate duplicating the information of what was changed by making up a > new message type (global message variables or strings) and using tonnes > of if-else clauses. I'd rather just tell my observer which method was > called and the arguments passed to it. (I.e. I have atoms in 3d space, > when setPosition(position) is called I would just like to tell whoever > is interested that setPosition was called with the argument position)) > > Problem, how do I refer to the method of a given class without making an > instance? Like suppose I notify my observers by giving the funciton > address and arguments, I would like the observer to have a dictionary > whose keys are methods > > class Atom: > .... > > > class myobserver: > ... > > updateTable={.... > Atom.setPosition:handle_A_setPositio > } > ... > > Hmm I have also just realized that given > class A: > def __init__(self...) > > a=A() > > a.init is not equal to A.__methods__['__init__'] > > Hmmm I thought that would be the worst way I could do it, but I guess I > couldn't if I wanted to... > > Any thoughts or better general solution would be appreciated... > This is a simple problem. Try A.__init__ >>> class B: ... def __init__(self): ... pass ... >>> B.__init__ >>> __ If you try to call it without a class instance as the first parameter, you'll get an error. >>> B.__init__(5) Traceback (innermost last): File "", line 1, in ? TypeError: unbound method must be called with class instance 1st argument Otherwise, it'll work fine. >>> B.__init__(B()) HTH, Dan From jhe at webde-ag.de Mon Jul 31 10:54:27 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Mon, 31 Jul 2000 16:54:27 +0200 Subject: Accessing NIC configuration via Python References: <8Rfh5.23380$07.914891@news1.rdc1.on.wave.home.com> Message-ID: <8m43rk$g0d$1@pollux.ip-plus.net> "Micheal Kelly" schrieb im Newsbeitrag news:8Rfh5.23380$07.914891 at news1.rdc1.on.wave.home.com... > I could do this by parsing the output of ifconfig, but for various reasons > don't want to do that. Is there any sort of low-level interface that I > can access via Python to get this information? I've looked through /proc > to see if there was something I could read, but nothing that seems to > contain the information I'm after. SIOCGIFADDR via ioctl() on a socket() (which does not have to be connected). Was mentioned in several news articles in the last two weeks. Bye, J?rgen From rob at hooft.net Wed Jul 19 06:16:00 2000 From: rob at hooft.net (Rob W. W. Hooft) Date: Wed, 19 Jul 2000 12:16:00 +0200 (CEST) Subject: Toplevel "test()" functions in standard library In-Reply-To: References: <14709.31813.259826.332843@temoleh.chem.uu.nl> Message-ID: <14709.32736.512813.306302@temoleh.chem.uu.nl> >>>>> "MZ" == Moshe Zadka writes: >> I will subtract my proposal, and submit a bug report that those >> test() routines are undocumented. MZ> Why? It's quite alright that there will be undocumented routines MZ> in modules. This is a module implementation issue. (If you want MZ> to test that the module is working, you can look inside) I agree that there can be internal routines in a module. But: - python has a nice way of hiding those routines from the casual user of the library, namely adding an '_' before the name. - you already argued that base64.test() provided useful functionality. Why not document it? Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From mallor at 3DProgrammer.com Thu Jul 20 08:06:24 2000 From: mallor at 3DProgrammer.com (Mallor) Date: Thu, 20 Jul 2000 12:06:24 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> Message-ID: <4XBd5.1595$U56.58279@newsread1.prod.itd.earthlink.net> "Martijn Faassen" wrote in message > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? Cyberwar? -- Cheers, Infernal Troublemaker Troll Mallor "By simple mistake, mortals themselves amuse." From darrell at dorb.com Tue Jul 11 00:00:04 2000 From: darrell at dorb.com (Darrell Gallion) Date: Mon, 10 Jul 2000 21:00:04 -0700 Subject: time zone Message-ID: <025501bfeaec$7ea865d0$6401a8c0@home> Noticed that running Win2k python 1.5.2 doesn't set the timezone correctly. Played around with the environment variable TZ and things work now. set TZ=GMT+8EST;1/1,1/1 I'm too lazy to figure out the day light savings stuff. How is this supposed to work? Haven't check 1.5.6 yet. --Darrell Gallion From cobrien at Radix.Net Tue Jul 11 08:38:45 2000 From: cobrien at Radix.Net (Cary O'Brien) Date: 11 Jul 2000 08:38:45 -0400 Subject: Python and SSH Message-ID: <8kf4gl$fqm$1@saltmine.radix.net> I'd like to have a running python process ACCEPT an incoming SSH connection. Any ideas on how I could do this? -- cary From mmiller3 at iupui.edu Thu Jul 6 18:34:24 2000 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 06 Jul 2000 17:34:24 -0500 Subject: splitting an avi image into a sequence of images with python? Message-ID: <87em567urz.fsf@lumen.med.iupui.edu> I'd like to split some avi files into image sequences. Is there already a module out there that will help me do that? Mike -- Michael A. Miller mmiller3 at iupui.edu Krannert Institute of Cardiology, IU School of Medicine Indiana Center for Vascular Biology and Medicine From neilh at scintilla.org Mon Jul 10 21:29:30 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 11 Jul 2000 01:29:30 GMT Subject: Can anyone hear me? (was Solution to IDLE and Tkinter problems) References: <200007110027.RAA16246@stevie.loop.com> <8kdrnd$j8b$1@nnrp1.deja.com> Message-ID: <_Lua5.13223$Tb7.89061@news-server.bigpond.net.au> > There are a few problems, however. os.system takes a _long_ time to > get the interpreter running and blanks my screen while it does it. It > would be nice if there was some more efficient command to start the > interpreter. This may just be the slow python.exe startup because of multimedia problem. If Python is also slow to start up from the command line search Deja at http://www.deja.com/=dnc/home_ps.shtml for the "Python startup seems slow" thread on comp.lang.python. Neil From see at my.signature Tue Jul 25 01:37:11 2000 From: see at my.signature (Greg Ewing) Date: Tue, 25 Jul 2000 17:37:11 +1200 Subject: New PEP: Attribute Access Handlers References: <397BE56C.6CEA865@prescod.net> Message-ID: <397D2787.A590170@my.signature> Paul Prescod wrote: > > __getattr__ will also take longer to get to until today. But using __getattr__ is so horribly inefficient anyway, I don't think anyone will notice. > Okay, so let's say I have a get function but no set function. Won't the > very first "set" put a variable in the dictionary so that future "gets" > will fail according to the algorithm you described? Doesn't that happen now if you have a __getattr__ but no __setattr__? If it's a problem in a given case, the solution would seem to be to provide a set method. ("Don't do that, then!") The opposite situation -- a set method but no get method -- is probably going to be more common, and will work correctly (provided the implementation doesn't purloin the dict slot for the attribute name itself). -- 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 kain at cableadmin.com Fri Jul 21 20:56:48 2000 From: kain at cableadmin.com (Scott) Date: Sat, 22 Jul 2000 00:56:48 GMT Subject: MySQL on Win9X References: Message-ID: I'm sorry, perhaps I was a little vague. What I meant was a precompiled (ie .pyd) version of one of the Python MySQL modules (ie MySQLdb). If someone happens to have built the package for a standard Win98 install of Python 1.5.2, I'd appreciate if you could make that available. Thanks, Scott On Sat, 22 Jul 2000 00:45:04 GMT, Steve wrote: >Go here http://www.mysql.com/downloads/mysql-3.23.html > >You can download the official Win9x/NT install package. MySQL 3.23 is now >under the GPL so you can get it for windows without paying for it, like you >have to for 3.22 > > >"Fernando Rodr?guez" wrote in message >news:IoYd5.199$kp4.2368 at m2newsread.uni2.es... -- ------------------------------------------------------------------------------- "That's a deer shooting hat." "Like hell it is. This is a people shooting hat. I shoot people in this hat." From kpmurphy at my-deja.com.bbs Mon Jul 17 15:10:05 2000 From: kpmurphy at my-deja.com.bbs (kpmurphy at my-deja.com.bbs) Date: 17 Jul 2000 19:10:05 GMT Subject: grid Message-ID: <3bRMLT$l5r@openbazaar.net> can you embed grids? ...what i'd like to do is grid within several frames, and then grid the frames together. sort of like html tables... i hate pack. -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From colinmeeks at home.com Fri Jul 28 08:07:38 2000 From: colinmeeks at home.com (Colin Meeks) Date: Fri, 28 Jul 2000 12:07:38 GMT Subject: PY to HTML References: Message-ID: Excellent. Thanks. Colin From rloisel at helicon.net Mon Jul 31 19:41:39 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Mon, 31 Jul 2000 19:41:39 -0400 Subject: Running a script in IDLE? Message-ID: <39860EB3.22EAFF7E@helicon.net> In CH6 of Laningham's "Teach Yourself Python ..." the text shows running an example script in a DOS window and IDLE. I loaded the file into IDLE which created a new window for the script but could find no way to run that script without typing it over again in the inter-active IDLE window. It would be so much easier to run scripts from IDLE if that's possible. btw - IDLE responds to my voice-rec. program and that sure saves a lot of typing ... rloisel at helicon.net Rodney Loisel Enfield NH. From bjorn at roguewave.com Sat Jul 22 00:48:21 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 21 Jul 2000 22:48:21 -0600 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> Message-ID: <39792795.B5B0D18C@roguewave.com> Justification, Scenario 4: An existing class has a string attribute, however the most common operation on it is appending to the end. Through the profiler you find that this operation is taking up 95% of the applications time. You want to change the implementation to cStringIO for efficiency (total execution time for your application goes from 90 seconds to 3 secs). True story :-) Perhaps you should add a few words about why you chose __attr_XXX__ instead of __set/get/del_XXX__? Would both of them work for introspection for e.g. a GUI builder? I seem to remember that JavaBeans looks for the presence of set/get methods to make attributes available, I'm not sure if Python could look at an objects __dict__ for that information under this proposal? -- bjorn Paul Prescod wrote: > > http://python.sourceforge.net/peps/pep-0213.html > > PEP: 213 > Title: Attribute Access Handlers > Version: $Revision: 1.3 $ > Owner: paul at prescod.net (Paul Prescod) > Python-Version: 2.0 > Status: Incomplete > > Introduction > > It is possible (and even relatively common) in Python code and > in extension modules to "trap" when an object's client code > attempts to set an attribute and execute code instead. In other > words it is possible to allow users to use attribute assignment/ > retrieval/deletion syntax even though the underlying implementation > is doing some computation rather than directly modifying or > reporting > a binding. > > This PEP describes a feature that makes it easier, more efficient > and safer to implement these handlers in Python class instances. > > Justification > > Scenario 1: > > You have a deployed class that works on an attribute named > "stdout". After a year, you think it would be better to > check that stdout is really an object with a "write" method > at the moment of assignment. Rather than change to a > setstdout method (which would be incompatible with deployed > code) you would rather trap the assignment and check the > object's type. > > Scenario 2: > > You want to be as compatible as possible with an object > model that has a concept of attribute assignment. It could > be the W3C Document Object Model or a particular COM > interface (e.g. the PowerPoint interface). In that case > you may well want attributes in the model to show up as > attributes in the Python interface, even though the > underlying implementation may not use attributes at all. > > Scenario 3: > > A user wants to make an attribute read-only. > > In short, this feature allows programmers to separate the > interface of their module from the underlying implementation > for whatever purpose. Again, this is not a new feature but > merely a new and more robust syntax for something that can > already be implemented. > > Current Solution > > To make some attributes read-only: > > class foo: > def __setattr__( self, name, val ): > if name=="readonlyattr": > raise TypeError > elif name=="readonlyattr2": > raise TypeError > ... > else: > self.__dict__["name"]=val > > This has the following problems: > > 1. The creator of the method must be intimately aware of whether > somewhere else in the class hiearchy __setattr__ has also been > trapped for any particular purpose. If so, she must specifically > call that method rather than assigning to the dictionary. There > are many different reasons to overload __setattr__ so there is a > decent potential for clashes. For instance object database > implementations often overload setattr for an entirely unrelated > purpose. > > 2. The string-based switch statement forces all attribute handlers > to be specified in one place in the code. They may then dispatch > to task-specific methods (for modularity) but this could cause > performance problems. > > 3. Logic for the setting, getting and deleting must live in > __getattr__, __setattr__ and __delattr__. Once again, this can > be mitigated through an extra level of method call but this is > inefficient. > > Proposed Syntax > > Special methods should declare themselves with definitions of the > following form: > > class x: > def __attr_XXX__(self, op, val ): > if op=="get": > return someComputedValue(self.internal) > elif op=="set": > self.internal=someComputedValue(val) > elif op=="del": > del self.internal > > Client code looks like this: > > inst=x() > fooval=inst.XXX > inst.XXX=fooval+5 > del x.XXX > > Semantics > > Attribute references of all three kinds should call the method. > The op parameter can be "get"/"set"/"del". Of course this string > will be interned so the actual checks for the string will be > very fast. > > It is disallowed to actually have an attribute named XXX in the > same instance dictionary as a method named __attr_XXX__. > If both are declared in a class then the last one declared > replaces the other one. > > An implementation of __attr_XXX__ takes precedence over an > implementation of __getattr__ based on the principle that > __getattr__ is supposed to be invoked only after as a > last resort after an appropriate attribute lookup has failed. > > An implementation of __attr_XXX__ takes precedence over an > implementation of __setattr__ in order to be consistent. The > opposite choice seems fairly feasible also, however. The same > goes for __del_y__. > > Proposed Implementation > > There is a new object type called an attribute access handler. > Objects of this type have the following attributes: > > name (e.g. XXX, not __attr__XXX__ > method (pointer to a method object > > Class construction > > In PyClass_New, methods of the appropriate form will be > detected and converted into objects (just like unbound method > objects). These are stored in the class __dict__ under the name > XXX. The original method is stored as an unbound method under > its original name. > > If there are any attribute access handlers in an class at all, > a flag is set. Let's call it "I_have_computed_attributes" for > now. Derived classes inherit the flag from base classes. > > Instance construction > > Instances inherit the "I_have_computed_attributes" flag from > classes. No other changes to PyInstance_New are anticipated. > > Property fetching > > At the layer, Python instance attribute lookup is always done > through PyInstance_getattr. > > A "get" proceeds as usual until just before the object is > returned. In addition to the current check whether the returned > object is a method it would also check whether a returned object > is an access handler. If so, it would invoke the getter method > and return the value. To remove an attribute access handler you > could directly fiddle with the dictionary. Gets should be more > efficient than they are today with __getattr__ and no different > for classes that do not use the feature at all. > > A set proceeds by checking the "I_have_computed_attributes" > flag. If it is not set, everything proceeds as it does today. If > it is set then we must do a dictionary get on the requested > attribute name. If it returns an attribute access handler then > we call the setter function with the value. If it returns any > other object then we discard the result and continue as we do > today. Note that having an attribute access handler will mildly > affect attribute "setting" performance for all sets on a > particular instance, but no more so than today, using > __setattr__. > > The I_have_computed_attributes flag is intended to eliminate the > performance degradation of an extra "get" per "set" for objects > not using this feature. Checking this flag should have miniscule > performance implications for all objects. > > The implementation of delete is basically identical to the > implementation of set. > > Caveats > > 1. You might note that I have not proposed any logic to keep > the I_have_computed_attributes flag up to date as attributes > are added and removed from the instance's dictionary. This is > consistent with current Python. If you add a __setattr__ method > to an object after it is in use, that method will not behave as > it would if it were available at "compile" time. The dynamism is > arguably not worth the extra implementation effort. This snippet > demonstrates the current behavior: > > >>> def prn(*args):print args > >>> class a: > ... __setattr__=prn > >>> a().foo=5 > (<__main__.a instance at 882890>, 'foo', 5) > > >>> class b: pass > >>> bi=b() > >>> bi.__setattr__=prn > >>> b.foo=5 > > 2. Assignment to __dict__["XXX"] can overwrite the attribute > access handler for __attr_XXX__. Typically the access handlers > will store information away in private __XXX variables > > 3. An attribute access handler that attempts to call setattr or > getattr on the object itself can cause an infinite loop (as with > __getattr__) Once again, the solution is to use a special > (typically private) variable such as __XXX. > > -- > Paul Prescod - Not encumbered by corporate consensus > New from Computer Associates: "Software that can 'think', sold by > marketers who choose not to." > > -- > http://www.python.org/mailman/listinfo/python-list From thomas_s at ebox.tninet.se Sun Jul 2 09:15:52 2000 From: thomas_s at ebox.tninet.se (thomas_s at ebox.tninet.se) Date: Sun, 02 Jul 2000 14:15:52 +0100 Subject: Tkinter and default options Message-ID: <8jnbhm$bb6$1@cubacola.tninet.se> Hello, I'm using Tkinter for the GUI parts of a little game I'm working on. What is the best way of setting default options of the widgets? For instance I want all widgets to have fg='green' and bg='black'. Is there a standard way of doing this? If not, I was thinking of maybe writing a widget factory that creates and configures them for me. Thank, Thomas From matt at mondoinfo.com Wed Jul 12 00:27:20 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 11 Jul 2000 23:27:20 -0500 Subject: [ANN] swallow.py: Unix GUI MUA Message-ID: <110720002327208153%matt@mondoinfo.com> swallow.py is an open-source GUI MUA (mail user agent) for Unix written in Python. It uses Tkinter for its GUI, retrieves mail via POP, sends it via SMTP, and stores it in Maildir format. It is hacker-ware. WARNING: It is in an alpha state of reliability. The current version is available at: http://www.visi.com/~mdc/swallow/ From hzhu at localhost.localdomain Tue Jul 18 16:07:39 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 20:07:39 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <39745372.EDCBF4FF@fft.be> Message-ID: On Tue, 18 Jul 2000 14:54:10 +0200, Gregory Lielens wrote: >I think that it is the more elegant solution if the introduction of new >operators is rejected... >This could turn to be even more elegant, if it allow something like >C = A.I*b to be equivalent to Matlab's C = A\b, i.e. without any >inversion of matrix A. Wait. Wouldn't this be in fact an operator .I* acting on a and b? I would think this is more than the additional operator .* etc. Module writers would have a feast on the abundance of supplies. :-) >This kind of "retarded" evaluation could even lead to further >optimizations, and I tink >that the trace-back problem is avoided if we can ensure that any new >matrix that is produced and returned >by an expression evaluation or a function is always in a "blank" state, >i.e. without any I, T, H,... flag >on... Maybe Travis can answer this: how is transpose implemented in NumPy today? Does it produce a new copy or just changes the indexing? Huaiyu From nobody at nowhere.nohow Wed Jul 5 22:01:55 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Thu, 06 Jul 2000 02:01:55 GMT Subject: Two Tkinter questions (long) References: Message-ID: On Wed, 05 Jul 2000 23:06:17 GMT, Tim Hochberg wrote: >> Functions bound to events need to take an event as a parameter >> (if you don't want the event, you can use lambda to discard it): >> >> self.filter_entry.bin('', labda event: self.do_filter()) > >You still needs to bind self to a default variable in order for it to be >accesible inside the lambda, e.g, > >self.filter_entry.bin('', lambda event, self=self : >self.do_filter()) Oops. The example I had in front of me at the time was binding a method bound to a global object. Any non-global values that are referenced inside the lamba expression have to be passed in as default valued parameters. This seems a bit obtuse at first, but it's an extremely handy thing to know. A common example of this is creating command functions on the fly for a bunch of buttons -- something like this snippet which fills with buttons a "matrix" that represents a chessboard. For each of the buttons, I want board.toggleSpace() called with the coordinates of the particular button [some details in the code have been elided]: for y in range(size): for x in range(size): b = Button(f,bitmap='@%s' % bitmapfile, [...]) b.bind("",lambda event,xx=x,yy=y: board.toggleSpace(xx,yy)) In this examle, "board" is a global object, so it can be referenced directly, but the values for x and y have to be passed in as default values for parameters, otherwise "x" and "y" will be evaluated when the button is pressed (and it will be an error since they won't be around). What I want is for "x" and "y" to be evaluated at the time the "bind" method is called, and their values "frozen" and passed to toggleSpace() later. Hence the old "default-valued-parameterized-labmda" trick. It will start to make sense after you've used it three or four times... -- Grant Edwards grante Yow! Are you selling NYLON at OIL WELLS?? If so, we can visi.com use TWO DOZEN!! From rgparker at west.net Mon Jul 10 16:09:41 2000 From: rgparker at west.net (Randall Parker) Date: Mon, 10 Jul 2000 20:09:41 GMT Subject: Run Python as separate process with Apache? References: <14697.3435.929500.668699@beluga.mojam.com> Message-ID: In news:<14697.3435.929500.668699 at beluga.mojam.com>, skip at mojam.com says... > Randall> 1) Have a persistent Python process that processes http > Randall> requests. > > Yup, Medusa, Zope, the ZServer part of Zope (which is a lightly touched up > Medusa), Is ZServer written in Python? Is all of Zope a Python-based app server? I went and looked at the http://www.zope.org site (I've seen Jon Udell rave about it in the past btw) and saw that it sounds like it is somehow more tightly tied to Python than to other scripting languages. Is that correct? >or something based on the HTTPServer class in the Python core > should do the trick. I use ZServer listening on 127.0.0.2 at port 9673 and > have Apache running on the same machine with proxy support. It then proxies > to the server only those things I want the ZServer to see. So there is a plug-in for Apache that can route requests to ZServer? I did something with Java Servlets and the Tomcat engine where one can basically set a pattern in some config file that tells Apache that any urls that start with: http://www.somedomain.com/webapps should be routed to Tomcat. So this is possible to do with Apache and ZEngine and Apache can still handle all URLs that don't have a leading /webapps pattern? > My ZServer then talks to a MySQL database using the MySQLdb module. If you > want SQL connection capability I suspect you'll find Zope is much closer to > a complete solution. Does ZServer support other RDBMSs? MySQL doesn't scale high enough for what I have in mind. I've used it on a smaller project but am reluctant to use it on something big. Besides, its lacking transactions, subselects (what a pain) and some other stuff I've become accustomed to using. See a MySQL/Postgres comparison here: http://www.phpbuilder.com/columns/tim20000705.php3 > Then I think you probably really want Zope. There are tons of contributed > Zope products available. There's bound to be one that will do session id > management. With the Servlet API the actual act of asking for a session id causes the Tomcat engine (or any servlet api compliant container) to create one if it already doesn't exist and then to go set a cookie on the client browser all seamlessly without your having to do anything. Then it will do timeouts on the session id based on how long since it was last asked for. I'm hoping I can find something as slick and automatic in the Zope/Python world. From sblakey at freei.com Wed Jul 19 19:15:58 2000 From: sblakey at freei.com (Sean Blakey) Date: Wed, 19 Jul 2000 16:15:58 -0700 Subject: HTTPS support? Message-ID: <20000719161558.A1809@freei.com> Are there any current SSL libraries for Python? A quick search of goole and Parnassus turned up some older links and some RPMS for a hack to 1.5.1 (I may have to figure out how to dissasemble an RPM - I develop on FreeBSD). Does anybody know of a commercially usable Python SSL library that works with current (1.5.2) Python? -Sean -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 Decaffeinated coffee? Just Say No. From paul at prescod.net Mon Jul 24 12:16:24 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 11:16:24 -0500 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <397C5DD3.437C4431@eecis.udel.edu> Message-ID: <397C6BD8.9BDBB174@prescod.net> Charles Boncelet wrote: > > ... > > What's wrong with "tuples"? That's the term used by M.A.L. in > his package, mxtools. It seems the most natural (and Pythonic) > to me. I also liked tuples but some complained that it was only one character away from "tuple". mktuples or maketuples would be better. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From grey at despair.rpglink.com Fri Jul 28 20:54:38 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 00:54:38 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> <39822505.73DA6F60@alcyone.com> Message-ID: On Fri, 28 Jul 2000 17:27:49 -0700, Erik Max Francis wrote: >and don't make any sense for language with strong typing. Python isn't >Perl, it's Python. Duh. Thank you for so pointing out what I have stated several times. You know, everyone else has been quite civil and I've learned a lot. You, you just piss me off. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From rumjuggler at cryptarchy.org Sun Jul 23 01:07:57 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sun, 23 Jul 2000 05:07:57 GMT Subject: Looping on more than one list References: <3979C6F4.B1FF1800@atlsci.com> <8ldkf7$7km$1@nntp9.atl.mindspring.net> <397A616E.A9549B93@san.rr.com> Message-ID: <0ovknsk976fjdd8hf25cki982ju3l67rkg@4ax.com> On Sun, 23 Jul 2000 03:04:13 GMT, Courageous wrote: > >> Not currently. Look at all the threads about zip(), marry(), braid(), >> etc. > >Perhaps this should be folded into the map function? >Ala, lisp: > >(map nil #'(lambda (i j) ...) list-one list-two) Right now, map(None, ...) will do what the proposed zip() function does, but zip() will be lazy, as is my understanding. -- Barnabas T. Rumjuggler Hey, does anyone remember when Matt McIrvin was talking about how he remembered the day when he read something about someone reminiscing about Frank Zappa talking about when nostalgia was better than it had become? That was really cool, far better than this degenerate age. -- jmbay, in ark From jim at digicool.com Tue Jul 11 17:53:31 2000 From: jim at digicool.com (Jim Fulton) Date: Tue, 11 Jul 2000 17:53:31 -0400 Subject: POOP / Python (Object Oriented Persistence) ? References: <002001bfea62$21eabdf0$f0c809c0@lslp7o.lsl.co.uk> <8kcqug$p32$1@newshost.accu.uu.nl> Message-ID: <396B975B.D821A4D3@digicool.com> Martijn Faassen wrote: > (snip) > > One of the interests of the people in Glasgow is how one copes with data > > that may be distributed over many computers. This includes issues such as > > how do you fallback to another copy of the data, how do you decide > > whether/when to cache locally, and if so when to update, etc. > > Zope's ZEO is going into this area. I haven't looked at it myself, but > basically you can cluster several copies of the ZODB together. In the > case of ZEO there's the case of a single point of failure (the central > front-end machine), however. But ZEO is definitely very cool. Not a lot > of code either from what I've seen. We've recently worked out (with help from Dr. Sushil Jajodia of George Mason U.) a protocol for replicating ZEO storage servers. This uses a quorum-based algorithm. Basically, you have multiple replicated storage servers and the system is available as long as more than half of them can communicate. It's pretty cool. See http://www.zope.org/Wikis/ZEO/QuorumBasedReplication for gory details. :) Jim -- Jim Fulton mailto:jim at digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From JohnH at PHM.GOV.AU Mon Jul 31 20:27:32 2000 From: JohnH at PHM.GOV.AU (Hirsch, John) Date: Tue, 1 Aug 2000 10:27:32 +1000 Subject: removing characters from a string? Message-ID: >say I had a string. >this_string = "jesse at multimediacollective.com" >"""and I wanted to get rid of the @, how would I do that? This >process has to be efficent for removing large quantities of special >characters, such as <,>,#,%,* etc, from the same string. >Any advice would be very helpful. Thanks in advance, Jesse. You could do this, not sure how fast or slow it is. >>> >>> import re >>> this_string = "jesse at multimediacollective.com" >>> pattern = re.compile('\W') >>> new_line = re.sub(pattern, '', this_string) >>> new_line 'jessemultimediacollectivecom' >>> It will remove all non alphanumeric characters from a string. For more info on re have a look at the Regular Expression HOWTO http://www.python.org/doc/howto/regex/regex.html john johnh at phm.gov.au From thomas at cintra.no Fri Jul 21 10:02:44 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 21 Jul 2000 14:02:44 GMT Subject: Graphs - I need more graphs ( Simulation development ) Message-ID: <397a5658.88821067@news.online.no> Ok, I need more info. I got an example in the Programming Python book by M. Lutz but I`d like to have more of the same. I`m pretty new to stuff like this so it needs to be *very* simple and basic. Gonna use it in a simulation-app, where objects interact with eachother and are affected by their environment. I need basic info on how to approach this, how to model robots in a virtual world etc. What data-types to use etc. Graphs are essential I believe so I need to understand how these work. For some reason the example in Programming Python doesn't make sense to me. At least, when I try to alter it, it does crazy stuff like returning the longest path to a given graph, when there's a lot shorter paths available. Stuff like that. I know I`m probably the problem here, but if anybody has any input on this it would be great, if just a simple code example on graphs and how the work. :-> Thomas From tismer at appliedbiometrics.com Thu Jul 6 12:14:28 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 06 Jul 2000 18:14:28 +0200 Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> <8jno3n$p6m$1@nnrp2.deja.com> <395F7A3A.FFB0B903@appliedbiometrics.com> Message-ID: <3964B064.AC484A7F@appliedbiometrics.com> Hmm, have to correct myself a little... Christian Tismer wrote: > > Hi Sean, ... > > The __getattr__ hook achieves a Delphi-like effect > > in which attributes of these sub-ordinate objects > > appear as attributes of the top level object. > > > > It seemed like a good idea at the time:-) > > Well, I see that your __getattr__ is a little insane. > > def __getattr__(self,n): > if hasattr(self.CurPos,n): > return getattr(self.CurPos,n) > else: > raise PyxieException ( > "No attribute '%s' on xTree or current xNode" % n) > > It redirects *every* reading attribute access to the CurPos > object, so Pickle can't even figure out what your xTree's > class is. Also, the CurPos object can's be saved with it, > nothing is accessible. I was not correct here. According to http://www.python.org/doc/ref/attribute-access.html section 3.3.2, the attribute lookup first walks the usual way, before __getattr__ is invoked. The problem with your solution is simply this: (p|cP)ickle does not recreate your curpos object which you create in __init__ . __init__ is not called at all. Now the following happens: When *ickle tries to reconstruct your object, it is looking for a __setstate__ property which is not there. So, __getattr__ is called which then tries to find self.curpos, which is also not there, causing __getattr__ to be called, which in turn...... *POFF*. The easy solution is this: Give it a __setstate__ method that just creates the curpos object, like __init__would do. cheers - chris file picklish.py: ------------------------- class magic: def __init__(self): self.uh = "oh" class ughh: def __getattr__(self, n): print "getattr called on", n if hasattr(self.curpos, n): return getattr(self.curpos, n) raise AttributeError, n def __init__(self): self.curpos = magic() def __setstate__(self, state): self.curpos = magic() import pickle, cPickle def test(use_cPickle = 0): pick= (pickle, cPickle) [use_cPickle] a = ughh() b = pick.dumps(a) c = pick.loads(b) return c -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From olivierS.dagenaisP at canadaA.comM Tue Jul 18 21:26:19 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 19 Jul 2000 01:26:19 GMT Subject: newbie urlopen() question References: <8l2lts$fln$1@nnrp1.deja.com> Message-ID: <%s7d5.1153$8Q3.56411@news20.bellglobal.com> Well, your URL is malformed. For local files, it usually has to be prefixed with "file://", so try url = "file://a:/1.htm" -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III wrote in message news:8l2lts$fln$1 at nnrp1.deja.com... > I have a simple file on my A drive (in the root) called 1.htm. > > Why doesn't the following code succeed in opening the file? (It works > fine if I assign a valid http address to url. But when I assign the > address below the IOError occurs): > > import urllib > url="a:1.htm" > > try: > f = urllib.urlopen(url) > print f.read() > except IOError: > print "Could not open " + url > > Any help much appreciated. > > Peter Dann > Melbourne, Australia > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From gmcm at hypernet.com Mon Jul 17 23:11:34 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 18 Jul 2000 03:11:34 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> <8F74C4E37gmcmhypernetcom@199.171.54.155> Message-ID: <8F74E7307gmcmhypernetcom@199.171.54.155> Huaiyu Zhu wrote: >On 17 Jul 2000 23:19:16 GMT, Gordon McMillan wrote: >> PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >Good point. So let me say why I do not like this. (Doesn't mean it has >to die.) :-) > >In a program where there are a lot of computations, you'll get either >something like a ritual on every line, > >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) >PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C) [snip] >or you get > >PyAlgebra.evaluate(r'(A .* B)\C > (A .* B)\C > (A .* B)\C', A=A, B=B, C=C) > >Everybody would rush for the latter. In the end what's inside the quote >would be a minilanguage with all the bells and wistles of python. This >would be just similar to patching the parser, with lesser results. It would be exactly what SQL and regular expression users deal with every day. I'm sure some ex-Perlers wish that regexes were "first class" objects, but there's little noise about it; and none whatsoever from SQL users. And you get the advantage that you can use the same syntax Matlab uses. -Gordon From aahz at netcom.com Thu Jul 27 10:30:00 2000 From: aahz at netcom.com (Aahz Maruch) Date: 27 Jul 2000 14:30:00 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> Message-ID: <8lph18$461$1@slb6.atl.mindspring.net> In article <397FCE9C.F22BB6B4 at see.my.signature>, Greg Ewing wrote: > >Maybe we need a new term to describe Pythonic parameter passing. Let's >call it "pass by spanish inquisition", because C/C++-heads are never >expecting it. Call it "pass by Spanish acquisition", and I'll play along. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From rumjuggler at cryptarchy.org Fri Jul 28 23:25:42 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 03:25:42 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 22:01:20 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 18:56:09 GMT, Ben Wolfson wrote: >>>>Any _sequence_ can be a single element or sequence. >>>>Any _single element_ can't be a single element or sequence. >>> >>> Let's pause and reflect on a single element not being able to be a single >>>element. > >>You are, I think, deliberately misinterpreting me. > >>Any single element can't be "a single element or a sequence". It can only >>be a single element. > > Nope, just grokking what is said. If it was a typo, please say so. From >what I see above in the 2nd line is the statement that any single element >can not be a single element. Say single element is a and we get a != a. Ah. What I meant, and perhaps didn't express very well, is that while a sequence can be interpreted as either a single element, or a set of elements, a single element cannot be interpreted that way (that is, as a single element or a set of elements). It can only be interpreted as a single element. I was thinking syllogistically; if all A is B, then any A can be either A or B, but any B can't necessarily be either B or A--it can only be B. -- Barnabas T. Rumjuggler More than half the people on the planet are female. OR WYMMYN AS WE LIKE TO CALL THEM IN THE TRADE!! -- Beable van Polasm From stephen_purcell at yahoo.com Wed Jul 26 18:29:33 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 27 Jul 2000 08:29:33 +1000 Subject: Problems installing PIL on linux In-Reply-To: <397F1232.27791F0C@yahoo.com>; from slinkp23@yahoo.com on Wed, Jul 26, 2000 at 12:30:42PM -0400 References: <397F1232.27791F0C@yahoo.com> Message-ID: <20000727082933.C9696@inkontact.com.au> Paul Winkler wrote: > > I'm trying to install PIL on a RedHat 6.1 system. > > I've downloaded the Imaging-1.1.tar.gz from the PIL website. > Following the instructions in the README, I get as far as step 8, > the actual build. It looks like step 7 (make -f Makefile.pre.in > boot) is finishing OK, but the created makefile does not work. I get > this: > > # make > make: *** No rule to make target > `/usr/lib/python at VERSION@/config/Makefile', needed by `sedscript'. > Stop. My advice is to get the RPM for 1.0b1 unless there's a particular need for fixes or features that can only be found in 1.1. Works fine for me. It's a shame that there seems to be no RPM available for 1.1. (I'm just one of those lazy people who more or less refuses to install anything that doesn't come in an RPM; I tire easily of tracking down make problems.) -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From shapr at uab.edu Tue Jul 18 17:52:22 2000 From: shapr at uab.edu (Shae Erisson) Date: Tue, 18 Jul 2000 21:52:22 GMT Subject: Duplicates again References: <397458FF.E5E88361@VerizonWireless.com> Message-ID: <3974D4A6.3CF1783@uab.edu> Bill Scherer wrote: > > It's happening again, duplicates by the dozen. > > sigh. > > I'm not the only one, am I? > > hoping-someone-is-listening-who-can-do-something-about-it-ly yrs, One repeated post sent from deja.com came up with these two path/ID values: news.maxwell.syr.edu!News.Math.NCTU.edu.tw!news.cs.nthu.edu.tw!news.nthu.edu.tw!newsfeed.nthu.edu.tw!news.mcu.edu.tw!news.ntu.edu.tw!OpenBazaar Message-ID: <3bRMLT$l5r at openbazaar.net> news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail Message-ID: <8kvkvt$68h$1 at nnrp1.deja.com> The repeated post also has these values in its header: NNTP-Posting-Host:linux3.cc.ntu.edu.tw X-Trace:gemini.ntu.edu.tw 963921703 6940 140.112.8.139 (18 Jul 2000 12:01:43 GMT) I think that's where the problem is. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely From guido at python.org Wed Jul 26 21:40:25 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 27 Jul 2000 01:40:25 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: Steve Lamb wrote: > Stupid question: Why is it everyone and their mother is coming out > with a new open source license for their project instead of sticking > with the established ones? I mean, it causes headaches trying to > keep all of the licenses legally compatible with one another which > can cause problems for open source down the road when these licenses > are actually put to the legal test. Excellent question. It's not my choice, that's for sure -- I've tried to convince CNRI [my old employer] to keep the old license, which is short and sweet and liked by all. But CNRI insists that the old license is "not a legally valid license". And since they have most of the power in this case, it's their lawyers' opinion that counts. Python is a "work for hire", owned by CNRI to the extent that it was produced under CNRI employment, and thus CNRI owns the all-important copyright. I'm working with BeOpen.com [my new employer] to ensure that something like this won't happen again -- I do not wish this upon any open source developers. Note that as far as I cal tell, my change of employers is not the reason for CNRI's desire to change the license; they have been talking about changing it for years, and since Python 1.5.2 came out their plan was to change the license on the occasion of the release of Python 1.6. If anything, the long hours that BeOpen's Bob Weiner has put into negotiating the license changes with CNRI probably make the new license more liberal than I would have been able to negotiate on my own if I were still a CNRI employee. (And no, I can't show the new license text yet. More news on Friday.) --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From aahz at netcom.com Sun Jul 9 10:50:21 2000 From: aahz at netcom.com (Aahz Maruch) Date: 9 Jul 2000 14:50:21 GMT Subject: CNRI vs. BeOpen (was Re: Splitting c.l.py...) References: Message-ID: <8ka3fd$87m$1@slb6.atl.mindspring.net> In article , Tim Peters wrote: > >[Alex ] >> Is there a synopsis of the legal woes that befell python somewhere? >> It sounds sort of interesting. > >[Jeremy Hylton] >> It's not interesting <0.2 wink>. > >And it's even less interesting for me, as (unlike Jeremy) I never >worked at CNRI so have no interest at all in their internal politics. >From my POV, it looks almost exactly like a divorce, except that >besides just arguing over custody of the children (Python's license >makes that pretty much a non-issue over the long haul), they're also >wrangling over who gets the kid's used clothes, the old security >blanket, and the first tooth that fell out. Separations are painful! >Sometimes messy too. This is apparently one of those. I do believe >both sides want Python to thrive, though. I think what would be interesting is to know what effect this is having on Python (e.g. is it delaying 1.6?). It would also be nice to know if there is an ETA for getting all this resolved. It would be useful to know what parts of the Python community are affected; I notice, for example, that starship.python.net still says to send checks for PSA to CNRI -- is that correct? (My interest in the last question comes mainly because I'm getting ready to upload my thread tutorial to a web site, and I'd prefer to use a Python site rather than my own.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From cg at gaia.cdg.acriter.nl Tue Jul 25 16:55:39 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 25 Jul 2000 22:55:39 +0200 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <397DE866.CA57D01D@alabanza.net> Message-ID: <8lkusb$ngt$1@gaia.cdg.acriter.nl> ye, wei said: >> 1. There are no keywords to declare static or instance variables; it >> all depends where they are placed(whether it's right after the >> statement, or inside a ). Isn't it harder for other programmers to >> know at one glance what type of attributes the class define? > >This is what I couldn't tolerate as well!! >I'm the same guy is looking for another new language, my path >is C/C++->Java->PHP->Perl. > Intolerable is a strong word. I've yet to have a problem with this, because it almost never goes wrong in real life (maybe during a code/test iteration, but it's not problematic at run-time). Typo's only slip through if you do a wrong assignment (e.g. "Foo = 1" and "foo = 2"). In an OO system, variables typically have a very limited scope, are qualified by classnames and therefore tend to be shorter, largely alleviating the problem procedural languages have with undeclared variables. >I'm the same frustrated as you about the Perl/Java and now Python, >Java is a good language, however it's not open language. Could you elaborate? It seems quite open to me. Even the GNU project accepts Java software, nowadays. >Perl has some >language deficients as well. Python is so loose for type checking. However >today I just read the Perl6 vision, it makes me very exciting - > Depends what you define as a) "a type", and b) "type checking" for Python. It also assumes that an absense of whatever you define under b) is a disadvantage, but there are more languages that employ the same kind of type checking (Smalltalk, to name one) and are quite succesful. It's different, but it works. > >It also will bring some python's features into Perl. :) > But it'll always stay a write-only language. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From matthias_w at my-deja.com Thu Jul 20 03:14:22 2000 From: matthias_w at my-deja.com (Matthias) Date: Thu, 20 Jul 2000 07:14:22 GMT Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> Message-ID: <8l68s5$3ht$1@nnrp1.deja.com> > > > > We're looking just to pair up elements. > > In that case, obviously the solution is to combine this > thread with the one on new operator symbols, and define > an elementwise tuple-creation operator > > ., > > as in > > [1,2,3] ., [4,5,6] == [(1,4), (2,5), (3,6)] ... > for x,y,z in a.,b.,c: > .... Hy I like that one, but since bitwise operations do not make sense on range operators (,do they?), why not use "&" since it is often used as alternative for "and" or "+" ??: for x,y,z in a&b&c: ... An other question: Who should list/tuples be handled things like this: for x,y in [1,2,3] & [1,2,3,4]: ... :-) Matthias Sent via Deja.com http://www.deja.com/ Before you buy. From embed at NOSPAM.geocities.com Wed Jul 5 14:58:43 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Wed, 5 Jul 2000 14:58:43 -0400 Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: "Gordon McMillan" wrote in message news:8F655BA3Egmcmhypernetcom at 199.171.54.154... > [posted and mailed] > C'mon Sean! You've been around a while. You know when __getattr__ hacks go > bad it's because they go recursive. (And the stack size on Windows is off > by some tiny amount, so it GPFs instead of traps.) That kinda says (a) Windows Sucketh, and (b) surely there must be a workaround for the Infinite-Recursion-Crash bug? Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. Hope that stackless makes it into the official python, by 1.7, or if not, there's always 3000. Here's hoping. Warren From alex at magenta.com Fri Jul 28 08:43:38 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 14:43:38 +0200 Subject: Perl is worse! References: <398178EA.7576E13A@hursley.ibm.com> Message-ID: <8lrvdh015qk@news2.newsguy.com> "Paul Duffin" wrote in message news:398178EA.7576E13A at hursley.ibm.com... > Moshe Zadka wrote: > > > > Because numbers are numbers and strings are not. Given, Python's numeric > > model is not very good. > > What is wrong with Python's numeric model ? What about the silent, implicit, automatic conversion from long integer to floating point? It can silently, implicitly, automatically lose an unlimited amount of information. I would not call that "very good"... Alex From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 23:50:03 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 17 Jul 2000 03:50:03 GMT Subject: problems trying wxPython in Win 95 Message-ID: <3bQkNS$jK1@openbazaar.net> I also had a problem with running a wxPython app on a Win95 machine. Mine was crashing in the wx(something).DLL. I think it might have been an MFC DLL issue, which I have seen a few posts discuss in this newsgroup before. Try a search on www.deja.com (go to USENET, and then find this newsgroup and search for something like "wxPython MFC") to see what turns up... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Rob" wrote in message news:iFtc5.19052$V34.236887 at news1.sttls1.wa.home.com... > I want to run the demo program included in wxPython 2.1. Upon starting it I > immediately get the message appended to this post. I have two versions of > Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and > get the same result. I tried running it from the console, from PythonWin, > and from IDLE, all with negative results. Does anyone have an idea of what > is going on? > > Thanks, Rob. > > PYTHONWIN caused an exception c06d007eH in module KERNEL32.DLL at > 0137:bff9a07c. > Registers: > EAX=0063d7bc CS=0137 EIP=bff9a07c EFLGS=00000246 > EBX=00000000 SS=013f ESP=0063d7b8 EBP=0063d80c > ECX=0063d7d4 DS=013f ESI=0063d864 FS=2287 > EDX=ffffffff ES=013f EDI=00000000 GS=0000 > Bytes at CS:EIP: > 5e 8b e5 5d c2 10 00 64 a1 00 00 00 00 55 8b ec > Stack dump: > 018a9c34 c06d007e 00000000 00000000 bff9a07c 00000001 0063d830 bff782c7 > 817f9000 81821708 00081822 00000000 0063d6e3 00000000 bff7c4f7 0188e4d0 > > From niels at endea.demon.nl Tue Jul 11 15:05:04 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Tue, 11 Jul 2000 21:05:04 +0200 Subject: references again References: <396A1233.17F2F302@muc.das-werk.de> <396B4CF3.90B13F9A@endea.demon.nl> <396B60D0.68BD2E62@muc.das-werk.de> Message-ID: <396B6FE0.E26D7C4A@endea.demon.nl> Thomas Thiele schreef: > > But I don't understand why they have used eval and write the string it in __buildins__. eval() is probably the easiest and the fastest way to get from repr(s) back to s. The { '__builtins__': {} } argument forces the evaluation to take place in an environment without access to any built-in functions. Otherwise someone might maliciously feed you a pickle like S`__import__('os').system('mail logins at psu.org <3963E6D6.F47FA4D8@roguewave.com> <3964BC64.761858FA@bioeng.ucsd.edu> <3964C635.E730EB97@roguewave.com> <3964C6FE.9BEC7ABB@bioeng.ucsd.edu> Message-ID: <3964D69C.AAA9EEA7@roguewave.com> Curtis Jensen wrote: > > Bjorn Pettersen wrote: > > > > Curtis Jensen wrote: > > > > > > Bjorn Pettersen wrote: > > > > > > > > What you're seeing are the symptoms of Python having thrown an exception > > > > and the weblog not capturing all the information. The solution is to make > > > > sure Python can only throw where you can grab the exception and do > > > > something useful with it, like printing it to the browser... Try the > > > > following (but make sure you can execute it from the command line first -- > > > > one possible error is a SyntaxError, which this scheme will not save you > > > > from...) > > > > > > > > -- bjorn > > > > > > > > #!/usr/bin/env python > > > > print """Content-type: text/html > > > > > > > > """ > > > > > > > > def main(): > > > > from time import * > > > > > > > > print "" > > > > print "" > > > > print "Hello World" > > > > print "" > > > > print "" > > > > print "

Hello World !

" > > > > print "
" > > > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > > > > > > > print "" > > > > print "" > > > > > > > > import traceback > > > > > > > > def execute(fn): > > > > # make sure any errors are legible, and directed to the user. > > > > try: > > > > sys.stderr = sys.stdout > > > > fn() > > > > except: > > > > print '

Something went wrong!!!

' > > > > print 'Please send the transcript below to webmaster at your.web

' > > > > print '\n\n

'
> > > >         traceback.print_exc()
> > > >
> > > > execute(main)
> > > >
> > >
> > > I tried this.  I got the same errors in the log and in the browser.  I
> > > took out the print line since it caused a discussion.  Any more
> > > suggestions?  Thanks.
> >
> > You do need the print line! The first thing your cgi must print out
> > (modulo cookies) is "Content-type: text/html" followed by exactly two
> > newlines (yes, I know there are situations where this isn't true, but in
> > this case it is.. )
> 
> Sorry, I didn't say witch line.  I took out the print line with the time
> in it.  So now it is a simple hello world script.  By the way, is,
> print 'Content-type: text/html\n\n'
> just as good as they way you have it?  I've tried both.
> 
> >
> > Check that:
> >
> >  - your script is executable (by everyone)
> 
> It is. permissions are 775
> 
> >  - some webservers require a .cgi extension (a symbolic link to your .py
> > will work)
> 
> I tried that and got the same errors
> 
> >  - python is where you think it is, and is executable (again by
> > everyone)
> 
> from the unix prompt, I can run helloworld.py and it prints fine.
> Permissions on python are 755
> 
> >  - your webserver is set up to execute cgi scripts.
> 
> In the same directory as helloword.py there are Pearl cgi scripts that
> run fine.
> 
> > If all that works, try the simplest possible cgi script, something like:
> >
> > #!/usr/local/bin/python
> > print  """Content-type: text/html
> >
> > """
> > print '

hello world

' > > We tried this and got the same problem. > Anything else? Thanks for the help so far. print 'Content-type: text/html\n\n' is fine... Hmmm... it seems clear that there is something going wrong when the webserver is trying to execute your script (the errormessage being "premature end of headers")... How about #!/bin/sh echo "Content-type: text/html" echo echo "

hello world

" if that works, create a text file called yyy.txt and make it world writable (777), then try: #!/bin/sh echo "Content-type: text/html" echo /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py >> yyy.txt 2>&1 Your browser should tell you that the document contained no data, but the yyy.txt file will hopefully contain the error... (you're getting very close to the limit of my cgi knowledge here ;-) -- bjorn From alex at magenta.com Tue Jul 18 17:26:06 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 18 Jul 2000 23:26:06 +0200 Subject: Does Python support interfaces? References: Message-ID: <8l2i4101pon@news2.newsguy.com> "Eric Hopper" wrote in message news:Rv_c5.1492$6E.294613 at ptah.visi.com... > In article , Justin Sheehy > wrote: > > > > Just define the class, and make sure that it provides the proper > > interface. Note that I'm not using "interface" with any special > > language-dependent meaning here. If it behaves properly, it behaves > > properly, and that is all that matters. > > Whee! Inheritance by mysteriously coinciding method names is so much fun! Yep, it is exactly what C++ does in its templates. Of course, they're resolved at compile-time in C++, but then Python is not about compile-time vs run-time distinctions, is it? See Austern's excellent book on Generic Programming (and, also, on the STL) about the GP metaconstruct he calls "concept", and how and why it's not modeled by inheritance even in C++. The compiler cannot diagnose many kind of concept-violations anyway (they're deeply semantic, e.g., the concept that a certain function imposes a strict weak ordering) so little is really gained by compile-time checks. Alex From ddb at crystal.uwa.edu.au Wed Jul 26 04:09:32 2000 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Wed, 26 Jul 2000 16:09:32 +0800 Subject: linear algebra in pure Python? Message-ID: <397E9CBC.2AD8FA89@crystal.uwa.edu.au> Hi, I know that there is the Numeric python extension and/or the Matrix extension MatPy, but is there not anywhere a pure Python linear algebra package exploiting lists of lists for matrices and the like? (I would like to use eigen analysis etc. with JPython) Thanks Doug From paulb at infercor.no Thu Jul 13 12:13:45 2000 From: paulb at infercor.no (Paul Boddie) Date: Thu, 13 Jul 2000 18:13:45 +0200 Subject: Solaris Binaries References: Message-ID: <396DEAB9.94FE44BC@infercor.no> "C. Porter Bassett" wrote: > [sunfreeware.com] > That is where I tried first. The python that they have does not even have > the thread module. You could always download gcc from there and then build Python from its sources. Then you'll have the features that you want. Apart from that, if you just need a Python binary for CGI purposes there's the CGIPython archive: http://starship.python.net/~lemburg/mxCGIPython.html Regards, Paul From cmyanko at bigfoot.com Tue Jul 25 08:07:08 2000 From: cmyanko at bigfoot.com (Hartford Hackers) Date: Tue, 25 Jul 2000 12:07:08 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: Message-ID: <8ljvta$epd$1@nnrp1.deja.com> Is it me or has it been totaly missed that C# sits on top of the Common Language Runtime Libray. It supports, Eifle, Perl, Python, VB, C++, C# and Java. Any language can call any object from any other language! So... if your looking for a way to *sell* Python to management, you now have the ammo to do so. Simply express why you chose Python as the implementation language! There's the list, you pick the one that works best for you. VB is, and will be, the best solution for UI's and C++ for system level stuff. Python will likely find its niche in the middle tier, business logic or whatever you want to call it. My question though, is, how does this effect future versions of Python, or Perl for that matter? Who controls the distribution of this library? -- -Curtis Yanko Sent via Deja.com http://www.deja.com/ Before you buy. From david_ullrich at my-deja.com Wed Jul 26 12:55:45 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Wed, 26 Jul 2000 16:55:45 GMT Subject: conatraints on "for" magic? References: <8llqso$q75$1@news.dtc.hp.com> Message-ID: <8ln56f$r78$1@nnrp1.deja.com> I don't recall seeing a precise statement about this in the docs (which no doubt just proves I haven't looked) but it's in various books for example Lutz (book at home, title is either "Learning Python" or not): When you say "for x in someInstance" the __getitem__ is called repeatedly, with an index starting at 0 and increasing by 1 each time, terminating when there is an IndexError: class Squares: def __init__(self, count): self.count = count def __getitem__(self, index): if not (index < self.count): raise IndexError return index*index for x in Squares(10): print x DU In article <8llqso$q75$1 at news.dtc.hp.com>, weeks at golden.dtc.hp.com ((Greg Weeks)) wrote: > Initially I learned that > > for x in seq: > > > required seq to be a sequence. But then I saw the code: > > import fileinput > for line in fileinput.input(): > > > How did the implementer of the "fileinput" module convince the "for" > construct that fileinput.input() was a sequence? > > (In "Python ESSENTIAL REFERENCE" I don't find any way of creating class > instances that are recognized by "for" as sequences.) > > Regards, > Greg > Sent via Deja.com http://www.deja.com/ Before you buy. From darrell at dorb.com.bbs Sun Jul 16 23:20:12 2000 From: darrell at dorb.com.bbs (darrell at dorb.com.bbs) Date: 17 Jul 2000 03:20:12 GMT Subject: problems trying wxPython in Win 95 Message-ID: <3bQjYC$m5z@openbazaar.net> My experience with this isn't recent. But last I checked wxPython didn't work with 1.6, don't know about 2.0. The demo will work with 1.5.2. I'd suggest uninstalling wxPython, rebooting and reinstalling it. I had a problem like this when upgrading from the last version of wxPython. Also check the wxPython mailing list where others of much greater wxPython experience hang out. And similar questions have been asked. --Darrell ----- Original Message ----- From: "Rob" > I want to run the demo program included in wxPython 2.1. Upon starting it I > immediately get the message appended to this post. I have two versions of > Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and > get the same result. I tried running it from the console, from PythonWin, > and from IDLE, all with negative results. Does anyone have an idea of what > is going on? > > Thanks, Rob. > From robin at jessikat.fsnet.co.uk Thu Jul 27 06:46:40 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 27 Jul 2000 11:46:40 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: The fact that there are dyed in the wool M$ hating academics is surely a reflection of M$'s past behaviour. The fact that M$ can apparently turn these guys around so easily says a lot about what M$ is really good at (selling and hype) and also about what the academics are poor at (real world judgement). If M$ is doing something for the competition there's a reason for it. No doubt in the environment addressed by IL Python.NET (or whatever it comes to be called) will have some critical advantage which M$ will use in whatever way it sees fit. This IL stuff is not a big deal intellectually so why doesn't M$ just release the language definition and sources and let the big & small guys play? Which part of a broken up M$ will control IL/.NET? when can we expect .NET2 or whatever? What parts of the IL/.NET API have not been made public? Etc. Etc. -Tee-shirt thinking really won't cut it-ly yrs Robin Becker From davidw at linuxcare.com Fri Jul 28 07:38:54 2000 From: davidw at linuxcare.com (David N. Welton) Date: 28 Jul 2000 13:38:54 +0200 Subject: The State of Python References: <8lqg6o$k2k$1@slb1.atl.mindspring.net> Message-ID: <87zon21o35.fsf@eugene.prosa.it> "Andrew Dalke" writes: > Stian Husemoen wrote: > I would still be using Tcl or start looking at Lua or Ruby or other > languages. A very interesting "other language" is elastiC, at www.elasticworld.org. The author is a Python fan (and smalltalk, scheme, objective C, etc..) -- David N. Welton, Responsabile Progetti Open Source, Linuxcare Italia spa tel +39.049.8043411 fax +39.049.8043412 cel +39.348.2879508 davidw at linuxcare.com, http://www.linuxcare.com/ Linuxcare. Support for the revolution. From thomas at xs4all.net Mon Jul 10 15:40:46 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 10 Jul 2000 21:40:46 +0200 Subject: Circular reference problem -- advice? In-Reply-To: <20000710123559.A2218@freei.com>; from sblakey@freei.net on Mon, Jul 10, 2000 at 12:35:59PM -0700 References: <396A1EC6.6738CFCC@alcyone.com> <20000710123559.A2218@freei.com> Message-ID: <20000710214046.P26534@xs4all.nl> On Mon, Jul 10, 2000 at 12:35:59PM -0700, Sean Blakey wrote: > Also, your self.map looks like it duplicates the information in the builtin > self.__dict__. Parhaps you could use that instead? > def dispatch(self, name): > self.__dict__[name]() Don't forget that an instnace's __dict__ doesn't list methods, just data members. (instance methods are created on the fly, from the unbound versions, and not stored in the instance's __dict__.) getattr() will work though, hadn't thought about that one ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rhicks at rma.edu Thu Jul 20 21:12:52 2000 From: rhicks at rma.edu (Robert) Date: Fri, 21 Jul 2000 01:12:52 GMT Subject: Source-Navigator and Python Message-ID: <3977A474.43AE035B@rma.edu> Wouldn't it be nice if Source-Navigator (just released as GPL by Redhat) had a Python plug-in... From roy at popmail.med.nyu.edu Wed Jul 5 07:53:47 2000 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Wed, 05 Jul 2000 07:53:47 -0400 Subject: Nth digit of PI References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca> <394889C3.1ED5@esatclear.ie> <20000705071827.A1015156@vislab.epa.gov> Message-ID: Randall Hopper wrote: > Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2) Interesting, I've never seen that one before. It's not a very efficient way to compute pi (I know, that's not what you were trying to do). A little experimentation shows that 1000 terms only gets you 4 significant digits correct, and 10,000 terms still only had 5! -- Roy Smith New York University School of Medicine From dwhite2 at seas.upenn.edu Thu Jul 27 17:31:27 2000 From: dwhite2 at seas.upenn.edu (David White) Date: Thu, 27 Jul 2000 17:31:27 -0400 Subject: javadoc equivalent for python? Message-ID: <3980AA2F.4E4E6E1F@seas.upenn.edu> Hi all, Is there an equivalent python application to javadoc? thanks, david From lull at acm.org Thu Jul 20 01:40:07 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 00:40:07 -0500 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: Huaiyu Zhu wrote (with possible deletions): > A variant: only use .E for elementwise. Always return matrixwise. This > is simply just using casting to help select among two methods denoted by > the same binary symbol. Does not look much better than 4 but worth > considering. Might I suggest .e instead of .E? .e* just looks a lot more like an operator to me than .E*. I think it makes the resulting expressions more readable. Regards, John From perer at cica.es Thu Jul 6 03:21:19 2000 From: perer at cica.es (Manuel Perera) Date: Thu, 06 Jul 2000 09:21:19 +0200 Subject: [URGENT]: Setting PYTHONHOME and PYTHONLIB Message-ID: <3964336F.E6ECA187@cica.es> Hello, I'm using Debian in a machine, where I'm not root. I need to set the variables PYTHONHOME and PYTHONLIB , I've uncompressed the packages python-base...deb and python-base..tk... in /tmp/python, so I have this kind of directory structure: /tmp/python/usr/bin/python /tmp/python/usr/lib/python ... Any help would be gratefully welcomed. -- MGA From aahz at netcom.com Mon Jul 31 14:35:51 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 18:35:51 GMT Subject: [5th Draft] Open Letter to CNRI: Request for clarification References: <3985D797.E5D2FC08@nowonder.de> Message-ID: <8m4gu7$dqt$1@slb7.atl.mindspring.net> In article <3985D797.E5D2FC08 at nowonder.de>, Peter Schneider-Kamp wrote: > >Should I add email addresses? Actually, that's probably a good idea, unless someone objects. >--- begin open letter ------------------------------------------------- >To: Dr. Robert E. Kahn , > (president of The Corporation for National Research Initiatives) > >Dear Dr. Kahn, > >many people in the Python community around the newsgroup >comp.lang.python are deeply concerned about the latest license >issues that have arisen around the new 1.6/2.0 releases. Capitalize "many people". I'd shorten this to "Many people in the Python community have concerns about the license issues that have popped up around the new 1.6/2.0 releases." >The following attached signatures represent people from the Python >community who would like some clarification regarding the future of the >Python language. As of now, there has been no official statement from >your institution regarding the new Python license. We are especially >interested in the underlying intention of this change. So we request >a plain-English, non-legalese statement regarding the purpose of that >change and the ways in which it affects Python's use. Looks mostly good to me. Go ahead and add my name: Aahz, aahz at pobox.com -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From max at alcyone.com Fri Jul 28 15:14:31 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 28 Jul 2000 12:14:31 -0700 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> Message-ID: <3981DB97.E367C81E@alcyone.com> Steve Lamb wrote: > Nope. 1 + "foo" = 1. Perl uses the a different syntax to put > strings > together. + is only a mathematical operator, not a math and string > operator. In Perl you need two operators for mathematical addition (+) and string concatination (.) because Perl is very weakly typed. Python is strongly typed, so this is unnecessary. + for integers (floats, longs, etc.) means addition, and + for strings means concatenation. What you're suggesting is mixing the two meanings, which is horribly ambiguous and a terribly bad idea for a strongly typed language. If 1 + 1 == 2 and '1' + '1' == '11' (note, not 11), then what should 1 + '1' or '1' + 1 do? Implicit type conversion between incompatible types (integer and string) is a bad idea in a strongly-typed language. That's not how it's done in Perl, but who cares? This isn't Perl, and in fact Python's strong typing means that looking to Perl for language advice is a very bad idea, because the way Perl works is predicated on its weak typing. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ You must surely know / If man made Heaven, then man made Hell \__/ Level 42 Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From johannes at zellner.org Fri Jul 7 20:47:06 2000 From: johannes at zellner.org (Johannes Zellner) Date: Sat, 8 Jul 2000 02:47:06 +0200 (CEST) Subject: Help! Indenting craziness! In-Reply-To: <8k5pev$182l$1@nntp1.ba.best.com> Message-ID: On 7 Jul 2000, Adam Clark wrote: > Hi all, > > Does anybody have a technique for avoiding syntax errors due to blank, > unindented lines? I'm getting these on a regular basis, and I haven't > figured out any reliable way to fix them. Sometimes if I take every line > in the vicinity, backspace it to the end of the previous line, and > reposition it, the errors go away. But often they don't, and I end up > just deleting chunks and rewriting them until Python stops complaining. > > This is with Emacs and python-mode. switch to vim and type `:set list' ;-) -- Johannes From richard_chamberlain at ntlworld.com Wed Jul 5 16:30:06 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 5 Jul 2000 21:30:06 +0100 Subject: Embedded apps and range??? References: <8k0331$n7d$1@nnrp1.deja.com> Message-ID: <6UM85.860$dL5.16129@news6-win.server.ntlworld.com> What is sz assigned to? >>> sz=3 >>> for i in range(sz): ... print i ... 0 1 2 >>> for i in range(1,sz): ... print i ... 1 2 An integer works fine. Richard Arint? wrote in message news:8k0331$n7d$1 at nnrp1.deja.com... > I am trying to use a range in a for loop > for i in range(-1,sz): > devlist[0] = PossDevice.PossArg(resource,i) > devlist[0].setValue(i) > ret = diz.set(devlist) > diz.ioctl("POS_SYS_GET_VALUES",devlist) > if i not in _range: > print "Checking for errors " + str(ret) > checkForErr(ret,error) > > I am getting the good old "TypeError: len() of unsized object" error, > problem is when I use range(sz) or range(1,sz) I don't get the error??? > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From pduffin at hursley.ibm.com Mon Jul 31 05:09:34 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Mon, 31 Jul 2000 10:09:34 +0100 Subject: The State of Python References: <39817536.FDBC508D@hursley.ibm.com> <87g0ota6fo.fsf@psyche.evansnet> Message-ID: <3985424E.90C4AC49@hursley.ibm.com> Carey Evans wrote: > > Paul Duffin writes: > > > What does GPL compatible mean ? > > It means you can distribute a program derived from both GPL-licensed > code and (in this case) CNRI-licensed code, given the conditions in > section 6 of the GPL: > > ... You may not impose any further restrictions on the recipients' > exercise of the rights granted herein. ... > So a GPL compatible license is simply one whose Terms and Conditions do not conflict with the GPL license. Does this mean that it is possible to create a GPL version of Python ? If so then this would result in a split as patches submitted under the original license could be merged into the GPL version but the reverse direction would not be allowed, otherwise they would both end up a GPL. > For example, the Apache license is not GPL-compatible because it > adds an additional restriction: > > 3. All advertising materials mentioning features or use of this > software must display the following acknowledgment: > "This product includes software developed by the Apache Group > for use in the Apache HTTP server project (http://www.apache.org/)." > > This means you can't distribute a program based on Apache-licensed and > GPL-licensed software. > The viral effect of GPL still applies of course so any derived code has to be licensed under the GPL. Is there a list of GPL compatible (and incompatible) licenses ? From pablo.prieto at dulcesol.es Tue Jul 4 07:41:23 2000 From: pablo.prieto at dulcesol.es (Pablo Prieto) Date: Tue, 04 Jul 2000 12:41:23 +0100 Subject: Equivalent to ppm for Python? References: <3961881d$0$20233@wodc7nh6.news.uu.net> Message-ID: <3961CD63.553F6D46@dulcesol.es> "donotspam-jen at personic.com" escribi?: > > Is there anything like PPM for Python? For those who don't know, PPM is the > Perl Package Manager > (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility > that will go out and download and install packages for you from the Internet > (at least on Win32 -- I assume it works elsewhere, too). > > Jen Sorry. This is not a reply. Just a request for this question be answered since I'm interested in it too. Have a nice day. Pablo. From dalke at acm.org Thu Jul 27 12:18:10 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 27 Jul 2000 10:18:10 -0600 Subject: Variables in strings.. References: <8lh75e+tjtl@eGroups.com> <119330503709.20000724135021@buz.ch> <8liokm$je0$1@slb6.atl.mindspring.net> Message-ID: <8lpn4p$j67$1@slb6.atl.mindspring.net> (horn tooting follows) I wrote: >You could write a wrapper, like: > >class LookupConverter: > def __init__(self, dict): > self.dict = dict > def __getitem__(self, name): > return eval(name, {"__builtins__": {}}, self.dict) > I should have shown the even more impressive >>> import math >>> lookup = LookupConverter(locals()) >>> "cos(45 degrees) == %(math.cos(math.pi/4))f" % lookup 'cos(45 degrees) == 0.707107' Try doing *that* in Perl :) But seriously, I am impressed that this can be done at all, since it understands balanced parens, although not quotes: >>> "%(f('))', 9)s" % {} Traceback (innermost last): File "", line 1, in ? KeyError: f(') Is this a bug? Andrew From gregory.lielens at fft.be Thu Jul 20 11:37:12 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Thu, 20 Jul 2000 17:37:12 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <39771CA8.A1BF8D6E@fft.be> Robin Becker wrote: > > In article <8l6vul$5ig$1 at slb3.atl.mindspring.net>, Aahz Maruch > writes > >In article , > >Huaiyu Zhu wrote: > >> > >> matrix element names (with prefix m or e) > >> + .+ add > >> - .- sub > > > >I am strongly opposed to operators of the form ".+". What happens if > >take an expression of the form "5.+matrix"? No, that goes against the > >Python rule of having zero ambiguity. > >-- > > --- Aahz (Copyright 2000 by aahz at netcom.com) > > > ... > people keep talking about matrix operations as though there is only one > way to do one kind of matrix multiply; I use at least two (inner, outer) > commonly, but others eg Kronecker or Lie are certainly in use. I don't > think any proposal which doesn't address this is likely to get my vote. > -- > Robin Becker Are you talking of matrices, or Nd arrays? I am only aware of one kind of matrix multiply, defined as a=b @ c <=> a(i,j) = b(i,k) * c(k,j) (using summation over repeated indices, @ stand for the yet-to-be-defined matrix mul operator) For Nd arrays, there is indeed more possibilities, and I fear adressing all of them could be too much to ask to "simple" infix operators.... I propose to extend the meaning of the matrix multiply to Nd arrays as a=b at c <=> a(i1,...,in,j1,...,jm) = b(i1,...,in,k) * c(k,j1,...,jm) For general inner/outer product, something in the line of Yorick notation is imho unavoidable a=b[,,Contract,Contract]@c[,Contract,,Contract] would stand for a(i,j,k,l)=b(i,j,c1,c2)*c(k,c1,l,c2) Replace Contract keyword with + sign, and you almost have Yorick notation... Kronecker/lie, I am not really aware of what they are...but I guess they would be writable in a general inner/outer framework, with the help of special arrays/tensors (correct me if am completely off on this!) imho Division (right and left) belongs to pure matrices, and can not really be generalized I feel that way because I am not aware of a well defined inverse for a Nd array ...(should someone be interrested in this I could post a discussion I had with Travis Oliphant, from NumPy group) Greg. From thomas at xs4all.net Sun Jul 16 10:55:39 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 16 Jul 2000 16:55:39 +0200 Subject: [Patch] {l,r}just with optional pad character parameter In-Reply-To: <8kshd3$l1h$2@bw107zhb.bluewin.ch>; from beat.bolli@earthling.net on Sun, Jul 16, 2000 at 04:38:05PM +0200 References: <8kshd3$l1h$2@bw107zhb.bluewin.ch> Message-ID: <20000716165538.V7340@xs4all.nl> On Sun, Jul 16, 2000 at 04:38:05PM +0200, Beat Bolli wrote: > this is my first crack at Python patching. I was simply appalled to find > '3'.zfill(5) not working anymore in 2.0b1, so I decided to do something > about it. Now since zfill can be expressed as rjust with an optional pad > characer argument, I implemented this. Excellent ! But as you might know, Python has moved to SourceForge, which includes a Patch Manager. It would definately be best to post your patch there, including some comments on why it is necessary. If you can't post it there for some reason, send it to python-dev at python.org. Oh, and read http://www.python.org/patches/', it contains some hints about submitting a patch and coding style and such. As for the patch itself, it looks okay, though I'd say the restriction on padchar being a single character is a bit strange. Why not allow multiple characters as padding ? string.join() allows strings instead of single characters, too. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rhicks at rma.edu Tue Jul 18 14:33:17 2000 From: rhicks at rma.edu (Robert) Date: Tue, 18 Jul 2000 18:33:17 GMT Subject: Wherefore art thou, 1.6? References: <3973D0A1.5E1289D9@concentric.net> Message-ID: 1.6a2 is actually at the PythonLabs site. It is being renamed to Python 2.0 and then next version will be out *soon* according to the website. Robert "Manus Hand" wrote in message news:3973D0A1.5E1289D9 at concentric.net... > As I assume we all know, there is nothing but an unlinked "Python 1.6" > at python.org. I was curious about this, but thought it a temporary > condition. That was a while ago, though.... > > So I did a quick deja.com search through c.l.p to see if I could get > an explanation. All I found was someone asking three weeks ago and > getting, well, no answer. > > Can someone please post a status on 1.6? > > Thanks, > Manus (who is using [and loves] 1.6a2 and lives in fear that the 1.6 > release was for some reason decided against in the alpha stage) From max at alcyone.com Mon Jul 10 15:06:46 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 10 Jul 2000 12:06:46 -0700 Subject: Circular reference problem -- advice? Message-ID: <396A1EC6.6738CFCC@alcyone.com> I'm fairly new to Python, although it's simple enough that I've already been able to write some fairly involved programs in it (I already know C, C++, Perl, etc.). This question isn't so much about what's going wrong, but rather what's the best, most natural way to get around it. I've come across a problem due to circular references, and I'm not sure what's the best way to tackle it. In essence, the problem is that I need a particular class to keep an associative array of its methods for a lookup table (it's essentially a dispatcher). But with references to its own bound methods, Python's garbage collector concludes it has circular references and thus its destructor never gets called. Here is a simplified standalone program that demonstrates what I'm talking about: class C: def __init__(self): print "in constructor" self.map = { 'f': self.f, 'g': self.g } def __del__(self): print "in destructor" def f(self): print "in C.f" def g(self): print "in C.g" def dispatch(self, name): self.map[name]() c = C() c.dispatch('f') When run, this program prints max at charmaine:~/tmp% ./circ.py in constructor in C.f and that's it; because of the circular reference, the destructor never gets called. For the application I need, it's imperative that the destructor get called. What is the best way to solve this? I can think of a few: - Move the map to a local variable in the dispatching function - Make map a lookup table of _unbound_ methods - Build a string of the function call and then exec it What would be the most effective way of getting around this? I'm thinking that using unbound methods would probably be the best way. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ We'll have to make our own luck from now on. \__/ Louis Wu Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From aahz at netcom.com Tue Jul 4 10:02:05 2000 From: aahz at netcom.com (Aahz Maruch) Date: 4 Jul 2000 14:02:05 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> <8js4jc09qf@news1.newsguy.com> Message-ID: <8jsqot$pj2$1@slb0.atl.mindspring.net> In article <8js4jc09qf at news1.newsguy.com>, Alex Martelli wrote: > >Good! Now if I only knew what:-). Oh well, guess I'll wing the >presentation based on "need to keep flexibility in such times of rapid >change and uncertainty" and Python's excellence at such flexibility. >Unfortunately our top mgmt is made up of smart guys _and_ they're wise >to my ways, so I doubt this will fly (maybe I'd better come clean and >confess I know there IS something but I don't know what and will they >allow me one more month of research...?-). Just tell them that a reliable source says that more info will be coming in two weeks and can you please have a three- or four-week extension on your presentation so you can present them with Microsoft's smoke'n'mirrors instead of your faked-up smoke'n'mirrors. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From bjorn at roguewave.com Sun Jul 16 13:41:05 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sun, 16 Jul 2000 11:41:05 -0600 Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> <396F4473.35DCA488@prescod.net> <8F729880Egmcmhypernetcom@199.171.54.194> <3970B9EB.8FF00EF9@prescod.net> Message-ID: <3971F3B1.B45CEBBE@roguewave.com> Paul Prescod wrote: > Gordon McMillan wrote: > > > > ... > > > For Python, you want to look > > >at > > > > > >http://starship.python.net/crew/gmcm/distribute.html > > > > > >For Java, at "jexegen.exe". > > > > Sorry, Paul, the latter does not bundle in the interpreter. It just > > packages up byte code and uses a small exe to start your MS JVM. > > True, I forgot that because the MS JVM tends to be installed. I think I > may have exaggerated the features of the former too. Is there any easy > way to make a single executable for Python, the standard library, > required .pyd's and your code? My vague impression is that you could if > you had a compiler and the source for your pyd's, or else you could fall > back on an installer (rather than a single big runnable app). Nah, I distribute my xml scripts as windows .exe files all the time (including the expat dll). It's actually quite trivial since the builder only wraps everything into a zip archive and appends it to the special Python executable. -- bjorn From hinsen at cnrs-orleans.fr Fri Jul 21 05:53:36 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 21 Jul 2000 11:53:36 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: Travis Oliphant writes: > The only question is can the (*) be implemented in the current grammar? I see no reason why not. It's no different from other multi-character operators (!=, <>, **). > I don't think we should start introducing [*] {*} variants. That would > likely weaken our case in the PEP. Exactly. In the heat of an active discussion we should not overlook that we (numerical/scientific users of Python) are a minority in the Python community. Moreover, our additional operators are not likely to be of much interest to others. We'll have a hard time arguing for *any* additional operators, so we should be careful to propose the smallest reasonable list and avoid anything that could affect other users in a negative way. Python esthetics is also an important point, although difficult to cast into rules. Many pythonists have strong objections against Perl-like "line noise syntax". What makes Python syntax particularly clear is the close resemblance to pseudo-code writing style; there are very few features that one would not use when writing illustrative pseud-code. I don't think any proposal introducing @ into matrix operators has a serious chance to get accepted. The same goes for .* or *. because of the conflict with floating-point notation. We might come up with a unique rule to disambiguate the syntax from the parser's point of view, but it will always remain confusing to users, and there is also a risk of breaking existing code. Another point to consider is implementation. In the current Python implementation, every operator must be implemented by a special method (or subroutine for C types). This can quickly become messy. There are other possible arrangements (e.g. all matrix operations could be mapped to a.__matrix_op__(b, op_code)), but it is in any case better to keep the number of new operators to a minimum. It is also worth reminding everyone that we are not discussing the addition of new features that were not available before. It's only new syntax for operations that already exist. Unless the operation is really a frequent one, there is no point in adding operators. Therefore I agree with Travis that we should probably not ask for more than the following ones: > (*) outer product > (.) inner product > (|) matrix solve > (**) matrix power > (^) is better but only if ^ is power (which is not likely!) For "matrix solve", I propose to follow APL and define it in the sense of a least-squares solution, implemented via singular value decomposition (SVD). There are two reasons for this: 1) SVD is stable even for near-singular (or downright singular!) matrices. This is one of the few fool-proof algorithms in linear algebra, and it spares unexperienced users a lot of trouble. 2) Linear least-squares fits are a sufficiently frequent operation in their own right, especially in data analysis tasks. The only disadvantage is that SVD is slower than a standard solve algorithm, which however could still be available as a function in some module. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From huaiyu_zhu at yahoo.com Thu Jul 20 15:13:52 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Thu, 20 Jul 2000 12:13:52 -0700 (PDT) Subject: Guidelines for new operators Message-ID: Since I still have not seen Tim's post on my news reader, while the discussions on the new operators is becoming somewhat more wide ranged than could possibly be accepted, I'm forwarding it here again. I don't mind discussing all sorts of possibilities, as long as we are aware of the limits for final acceptance. Imho, getting it into the core so that users do not need to fetch CVS, patch, configure, compile and install python is a much greater convenience than exactly how the operators look like. But I do not mean to put any limits on the discussion itself, as discussing different possibilities beyond practical limitation often leads to better insight to the issues at hand. So go ahead as you like. :-) Huaiyu ---------- Forwarded message ---------- Date: Wed, 19 Jul 2000 01:12:11 -0400 From: Tim Peters To: hzhu at users.sourceforge.net, python-list at python.org, PythonDev Cc: gvanrossum at beopen.com Subject: RE: Discussion: Introducing new operators for matrix computation Sleeping in the same room with Guido for a night did not make it easier to channel him, but it did make it easier to cloud his mind: Guido is not opposed to adding new operator symbols to core Python. As of breakfast Tuesday, anyway, and there are witnesses, so he'll have trouble changing his mind (well, it will be clumsy for him to *admit* it if he changes his mind ...). But but but (you knew it wouldn't be *that* easy!): + Everybody concerned that new operators are "not Pythonic" please swallow it -- it is Pythonic, cuz Guido said it is <0.9 wink -- but see following points too>. Contribute by helping to come up with a complete and Pythonically beautiful implementation instead. + Please keep this off of Python-Dev. Doesn't belong there (at least not yet). Interested parties can form a mailing list, or try to discuss it on comp.lang.python (my personal hope is that you try the latter, and stick to one Subject line). + There *must* be a PEP for this. Guido won't read any more of the debate -- it's too voluminous, repetitive and contentious. He'll eventually read a PEP, though, *after* some sort of consensus is reached. A PEP requires a champion. I hope Huaiyu Zhu volunteers for this, as he's argued his case eloquently and rationally. The champion doesn't need to know how to implement it, but does need to summarize sometimes-opposing positions dispassionately. + There are things Guido will & won't tolerate. Guessing which is an interesting & educational challenge . For example, adding a new operator like .+ is fine, as the maximal-munch rule for lexing can resolve formal ambiguities easily. OTOH, *any* new operator symbol containing a backslash is dead before arrival -- backslash has purely "meta" meanings in Python today. If the goal is to make Python look exactly like some other language, forget it. It's still Python, with some light syntactic sugar to make life in special domains sweeter. + This one is from me, but it's a safe bet you can view at as precognitive channeling if you oppose it: anyone suggesting to, e.g., make ".+" mean something new and exciting for ints or floats or strings or ... will be shot. There are probably no operations on the builtin types used frequently enough to merit new syntactic shorthands (excepting, perhaps, that if P3K changes the meaning of integer division, a new "//" operator for flooring division was looked upon kindly in the past). The new operators are for convenience in special domains (where the case for them is indeed very strong), not an excuse to turn current Python into a cryptic mess. + Also from me: forget about user-defined precedence and associativity. The PEP must define these once & for all, and that's that. + The set of new operator symbols cannot be open-ended (as it is in, e.g., Haskell). There are at least 4 variants of Python tranlators already in existence, and Guido wants the set of operator symbols fixed so that a variety of parsing techniques can be used in their natural forms without trickery. IOW, the full set of operator symbols must-- as it is today --be a fixed finite set known in advance. + If the numerical folk can't reach consensus on the set of operators and what they should mean, my bet is that Guido will let this die rather than get sucked into Pronouncing on each of the points in dispute. After all, he has little personal use for this stuff: if the people who *do* want it can't agree, it's not worth having. how's-that-for-a-mysterious-announcement?-ly y'rs - tim From dale at out-think.NOSPAMco.uk Mon Jul 10 01:57:33 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 10 Jul 2000 06:57:33 +0100 Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> <4p%95.10247$A06.1298430@pouncer.easynews.com> <8ka7cd$c3$1@supernews.com> Message-ID: <8kbokp$qi8$1@supernews.com> Is this with or without you running makepy first? -- Dale Strickland-Clark Dag Sunde wrote in message news:DG8a5.21687$R7.3894985 at juliett.dax.net... > It got 2 from the implicit "self" parameter > that all classes in python is called with... > > So what effectively is sendt in your call is: > print DBRec(self, 0).Value > > But what puzzles me is that your code is running for > me... (With ths AddrBook.mdb sample-database)... > > Dag. > > > "Dale Strickland-Clark" wrote in message > news:8ka7cd$c3$1 at supernews.com... > > Thanks for all replies. I've now read the chapter in Python > Programming on > > Win32 and am somewhat the wiser. > > > > However, I am confused as to why it seems to break this very simple > program > > after running Makepy on "Microsoft ActiveX Data Objects 2.5 Library". > > > > At the print statemtent, I get this: > > > > print DBRec(0).Value > > TypeError: too many arguments; expected 1, got 2 > > > > Where did it get 2 from? > > > > ------------------------ > > import win32com.client > > > > DBCon = win32com.client.Dispatch("ADODB.Connection") > > DBRec = win32com.client.Dispatch("ADODB.Recordset") > > DBRec.CursorLocation = 3 # adUseClient = 3 > > > > sDB = "s:\\ths\\merlin.mdb" > > > > DBCon.Open("Driver={Microsoft Access Driver (*.MDB)}; DBQ=" + sDB) > > #DBRec.open("House", DBCon, adOpenStatic, adLockOptimistic, > adCmdTable) > > DBRec.Open("House", DBCon, 3, 3, 2) > > > > DBRec.AddNew() > > DBRec.Fields("Price").Value = 234000 > > DBRec.Update() > > print DBRec(0).Value > > > > DBRec = None > > DBCon = None > > ---------------------------- > > > > Thanks for any help > > > > Dale Strickland-Clark > > > > > > "Roger Upole" wrote in message > > news:4p%95.10247$A06.1298430 at pouncer.easynews.com... > > > It should speed up your COM calls. Also, you can browse thru the > > > generated file and see all the properties and methods of the COM > > > object. > > > Once the object has been created, the constants will be available as > > > win32com.client.constants.someconstantname. > > > There is a Readme.html in the /win32com directory, and more > documentation > > in > > > /win32com/HTML/QuickStartClientCom.html. > > > HTH > > > Roger Upole > > > > > > "News.tele2.co.uk" wrote in message > > > news:8k9o91$7b1$1 at supernews.com... > > > > Well I've run it and it seemed to work but I'm not really sure > what to > > do > > > > next. > > > > > > > > In fact, I'm not entirely sure what it's supposed to do for me but > I'm > > > > hoping it will at least give me access to some COM object > constants. > > > > > > > > Where is it documented? > > > > > > > > Thanks > > > > > > > > Dale Strickland-Clark > > > > > > > > > > > > > > > > > > > > > > > > > > > > From niels at endea.demon.nl Thu Jul 27 17:37:41 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Thu, 27 Jul 2000 23:37:41 +0200 Subject: Python 2.0 - win32pipe routines inclusion for Windows References: <39802DB6.73CEC178@endea.demon.nl> Message-ID: <3980ABA5.4190FC4F@endea.demon.nl> David Bolen schreef: > > But closing that hole at the application level isn't very difficult. > The application needs to have processed all the child output (through > knowledge of the child), or just explicitly closed the other files > returned by the initial popen# call before doing the final close on > the child-stdin to receive the exit code. It is not only difficult but impossible to solve this at the application level. The sort program does not (and can not) produce any output before it reaches the end of its input. Many other programs behave less extremely, but otherwise similarly, i.e. they will produce the final part of their output only after the end of their input. There is no way to force the end of that input other than by closing it. (at least not on Unix, I expect it's similar on Windows) I would propose waiting for the child to terminate and returning the exit code only when closing the last remaining pipe, and returning None on all the earlier closes. Is there any problem with that? -- Niels Diepeveen Endea automatisering From matt at nightrealms.com Sat Jul 15 07:03:35 2000 From: matt at nightrealms.com (Matthew Cline) Date: Sat, 15 Jul 2000 03:03:35 -0800 Subject: Docs for __init__.py? Message-ID: The documentation for __init__.py at python.org seems a little sparse. Is there anything that goes into more depth? Other than reading the Python source code? Specifically, does the package name have to corespond to the name of the directory that __init__.py is in? Or is there some way for __init__.py to say "No, *this* is the name for the package?" Thanks in advance. From fannyy at idmail.com Thu Jul 20 00:39:19 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Wed, 19 Jul 2000 21:39:19 -0700 Subject: Can one have successfully install Python in SCO OS3 ? Message-ID: Hi everyone, I try to install python 1.5.2 in SCO OS3 system. My previous installation experience in Linux is painless. But this time when it try to link, it complains dlopen, dlerror, and any dl function undefined. I check the README file and reckon that will be something to do with dynamic link. But after I download and 2 libraries (dl and dld ) and find out one of the libraries does not support in SCO. Anyone has any idea to solve this ? By working at the code, it seems I can turn off the dynamic link. If I do that, does it means I can only load library in compile time ? Thanks From kpmurphy at my-deja.com Tue Jul 25 10:19:00 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Tue, 25 Jul 2000 14:19:00 GMT Subject: tkinter: grid: expand and fill References: <8lhrbd$t4v$1@nnrp1.deja.com> <8lhs6l$tpt$1@nnrp1.deja.com> <8lhurd$3d$1@nnrp1.deja.com> <397CCB2D.DFD84326@ajubasolutions.com> Message-ID: <8lk7ke$ko6$1@nnrp1.deja.com> thanks guys! -->keith In article , "richard_chamberlain" wrote: > row_configure(0,weight=1) > column_configure(0,weight=1) > > Richard > > Dan Kuchler wrote in message > news:397CCB2D.DFD84326 at ajubasolutions.com... > > Keith Murphy wrote: > > > > > > here's my example that still doesn't work: > > > > > > class scrolledtext: > > > def __init__(self, master, scrollflags=(NO,NO)): > > > stxt = self.stxt = Frame(master) > > > txt = Text(stxt, height=5) > > > txt.grid(row=0, column=0, sticky=NSEW) > > > > > > if scrollflags[0]: > > > hbar = Scrollbar(stxt, orient=HORIZONTAL, takefocus=NO, > > > width=10) > > > hbar.grid(row=1, column=0, sticky=W+E, columnspan=2) > > > txt.config(xscrollcommand=hbar.set) > > > > > > if scrollflags[1]: > > > vbar = Scrollbar(stxt, orient=VERTICAL, takefocus=NO, > > > width=10) > > > vbar.grid(row=0, column=1, sticky=N+S) > > > txt.config(yscrollcommand=vbar.set) > > > > > > ...called with the following line: > > > statustxt = scrolledtext(sbar, (YES, YES)) > > > where sbar is a frame. > > > > > > i want the text to fill the area except for the spots where the scroll > > > bars are. i also want the window to be able to be resized. help! > > > > > > thanks, > > > -->keith > > > > > > > > is there a way to make a frame, that's been formatted using grid, > > > > expand > > > > > to fill the space it is given? > > > > In tcl/tk this would be solved by making column 0 and > > row 0 have a weight of 1 and by making column 1 and row > > 1 have a weight of 0. > > > > This would be done using 'grid columnconfigure' and 'grid > > rowconfigure' in combination with the sticky code that you > > already added. > > > > If you can find the python equivalent of setting the weight > > of the columns and rows, I think your code should work. > > > > --Dan > > Sent via Deja.com http://www.deja.com/ Before you buy. From sdm7g at Virginia.EDU Tue Jul 25 13:00:15 2000 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 25 Jul 2000 13:00:15 -0400 (EDT) Subject: Python is wierd! In-Reply-To: <8lk1c5$fv4$1@nnrp1.deja.com> References: <8lk1c5$fv4$1@nnrp1.deja.com> Message-ID: On Tue, 25 Jul 2000, Jonathan wrote: > Hi, just finished going through the 'Learning Python' book, and the > feeling that i get is that Python is really wierd(compared to other > conventional languages like C++, Java, etc). For e.g.(correct me if > i'm wrong) [ ... and later ] > Yep, point taken. I think the book did a good job by listing out all > the potential gotchas that might trap a newbie. What i was thinking is > the nature of the 'gotchas' that arise in python. My knowledge in > programming is quite shallow(i must admit), and my progress was > from 'pascal'->'c'->'c++/java'->'perl'->'php'. Along the way, of course > there are a few 'gotchas' in each language, but most of them did not > throw much surprises(except perl - the 'blessing' part for e.g.) Jonathan: Tim and others have answered some of your specifics, but I'm still worried about you! I'm afraid that these 'feelings' about Python being 'weird' are just a sign of your overly sheltered upbringing (in programming languages, that is. c/c++/java just barely count as separate languages and Perl seems to have been your only walk on the wild side!) If you think Python is weird, then you haven't seen very much! I suggest you: [1] Get a copy of Jean Samet's old book on programming languages plus volumes I and II of HOPL - History of Programming Languages out of the library and read. ( And if you don't have time to read, then at least look at the "geneology" chart. ) [2] Below is a partial list of languages outside of the C/Pascal/Algol tradition that have significantly contributed to ideas about programming and programming languages. If you can afford to spend a couple of weeks each learning a few from that list, it will expand your horizons amazingly! Lisp|Scheme, FORTH, Smalltalk, Snobol, Icon, APL|J, Prolog, Haskell, ML, Intercal, ... [3] Read Peter Landin on "The Next 700 Programming Languages" ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "There's a new programming language called C+++. It's 50% better than C++, but every time you compile, your modem hangs up." From gregory.lielens at fft.be Tue Jul 18 08:54:10 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Tue, 18 Jul 2000 14:54:10 +0200 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> Message-ID: <39745372.EDCBF4FF@fft.be> > Yep. See code below. > > > BTW, you meant > > > > (a.E*b.E).M*(c.E*d.E).M > > > > for otherwise it is equivalent to (a.*b).*(c.*d). > > Actually, I was thinking that elementwise multiplication would return > an object that does matrixwise multiplication (the idea being that > elementwise is a special case, just as .* is used for it instead of * > in Matlab). > > > >But what if we assume that if one operand has .E, the other does also! > > >Then we can write > > > > > >(a.E*b)*(c.E*d) > > > > This won't work. It would introduce many hard-to-trace bugs. Looking at > > > > (a*b)*(c*d) > > > > and you have to trace the program all the way down to figure out the > > identities of a,b,c,d. Note that in concept the identities of the objects > > do not change. We are changing their identities only as labels to help > > picking different operators. I can foresee great confusion in practice with > > this approach. > > I realize this. Note that you have to trace the program to tell that > a,b,c,d are matrices anyway :-). A lot of this is removed by always > having an operation return a Matrixwise object. I think that it is the more elegant solution if the introduction of new operators is rejected... This could turn to be even more elegant, if it allow something like C = A.I*b to be equivalent to Matlab's C = A\b, i.e. without any inversion of matrix A. This kind of "retarded" evaluation could even lead to further optimizations, and I tink that the trace-back problem is avoided if we can ensure that any new matrix that is produced and returned by an expression evaluation or a function is always in a "blank" state, i.e. without any I, T, H,... flag on... A minor problem of this approach could be the time spend in checking the flags, but the main problem I see is that it will make the code for *,+,...more complex for optimized version. For any unoptimized function or operator, something like a FlagReset method shoul be called for all arguments, to have the updated matrices... If the flags treatment prove to take significative time, one solution should to move them in the C struct which implement NumPy arrays, which will makes thing even more complex, I am affraid... But appart from this complexity, this is quite appealing imho... Greg. From stadt at cs.utwente.nl Wed Jul 12 10:15:12 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Wed, 12 Jul 2000 16:15:12 +0200 Subject: CyberChair available Message-ID: <396C7D70.2786049A@cs.utwente.nl> It didn't work for comp.lang.python.announce: ===================== Hi. This is the qmail-send program at starship.beopen.com. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. : Sorry, no mailbox here by that name. (#5.1.1) ===================== So, here the announcement: CyberChair, an online paper submission and reviewing system (for conferences and workshops), which has been used for the European Conference on Object-Oriented Programming (ECOOP) since its 1997 edition, and by some other conferences as well, is now available under the GNU General Public License. CyberChair was written in Python (http://www.python.org). At least version 1.5.1 is needed. Until recently I had not read anything else than the Python tutorial and this newsgroup, so CyberChair may contain "silly" Python code which could be improved. My colleague Fred Gansevles (who pointed me at Python 4 years ago - thanks:-) helped me out with some problems. To get CyberChair, visit http://www.cyberchair.org/requestUse.html, fill in the details of your webserver and conference or workshop, and download the generated customized version. Before downloading, you may want to try the demo system, which has been installed at the CyberChair homepage (http://www.cyberchair.org). Cheers, Richard van de Stadt From shuz at bresnanlink.net Thu Jul 27 12:48:54 2000 From: shuz at bresnanlink.net (Aaron Berg) Date: Thu, 27 Jul 2000 11:48:54 -0500 Subject: Sound---Anyone play with it in python? References: <397FDBE9.B8E1A2E0@bresnanlink.net> Message-ID: <398067F6.6D0BB3FE@bresnanlink.net> An HTML attachment was scrubbed... URL: From hzhu at knowledgetrack.com Wed Jul 5 19:51:30 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Wed, 05 Jul 2000 23:51:30 GMT Subject: Overloaded Operators allowed??? References: <8k07ke$j0r@news.or.intel.com> <3963AADB.25A6776E@roguewave.com> <8k0f7m$rma@news.or.intel.com> Message-ID: On Wed, 5 Jul 2000 16:09:41 -0700, Jeff wrote: >Well yes, that is true, but say I wanted to overload "/" to operate on a >class such as "cookies". Can this be done? This is in the docs. Like, class cookies: def __div__(self, other): return self.data/other def __rdiv__(self, other): return other/self.data Huaiyu From ldw at us.ibm.com Fri Jul 7 16:24:48 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Fri, 7 Jul 2000 15:24:48 -0500 Subject: Is there no function to convert a hex number to decimal? References: <395DB41F.85E51307@iue.tuwien.ac.at> <3960677C.BED04E21@iue.tuwien.ac.at> Message-ID: <8k5eaj$soo$1@news.rchland.ibm.com> Here's another way: hex = "abcd" dec = eval( "0x"+hex) Don't know which is better, faster, etc... Larry "Markus Gritsch" wrote in message news:3960677C.BED04E21 at iue.tuwien.ac.at... > Markus Gritsch wrote: > > > Hi! > > > > Although there are several built in functions to convert numbers from > > decimal to hex or oct, it seems that there is no function which can do > > the same in the reverse direction. Of course I can write 0xff, but > > what should I do, if I have a string containing a hex value? > > Currently I use this brute code: > > > > hex_dec = {} > > for i in range(256): > > hex_dec[hex(i)[2:]] = i > > > > def dec(hex_string): > > return hex_dec[string.lower(hex_string)] > > > > But I am not entirely happy with it, because I have to generate this > > clumsy dict, and the function works only for two-digit-hex-numbers. > > > > Is there really no other way? > > I found the solution in the string module: > atoi (s[, base]) and atol (s[, base]) > > BTW, these functions will become obsolete in python 2.0, because there will be an > optional "base" argument to the built-in functions long() and int() > > -- > |\/\/\/| > /------------------------------------------------------------------\ | | > | Markus GRITSCH | phone: +43 / 1 / 58801-36015 | | | > | Institute for Microelectronics | cellular: +43 / 676 / 4973431 | | (o)(o) > | Technical University of Vienna | fax: +43 / 1 / 58801-36099 | C _) > | Gusshausstrasse 27-29 / E360 | email: gritsch at iue.tuwien.ac.at | | ,___| > | A-1040 Vienna / AUSTRIA | SMS: 436764973431 at max.mail.at | | / > \------------------------------------------------------------------/ /____\ > / \ > "Computers let you make more mistakes faster than any other invention in human > history, with the possible exception of handguns and tequila." > Mitch Radcliffe > > > From invalid.address at 127.0.0.1 Sun Jul 2 00:29:54 2000 From: invalid.address at 127.0.0.1 (David) Date: Sun, 02 Jul 2000 04:29:54 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> Message-ID: <395fc536.9838883@news.telus.net> On Sat, 01 Jul 2000 05:10:50 GMT, Courageous wrote: >Java is is a variant of the C++ language with the kitchen >think glued on Heh. Pun, or typo? From cgw at fnal.gov Fri Jul 21 19:02:41 2000 From: cgw at fnal.gov (Charles G Waldman) Date: 21 Jul 2000 18:02:41 -0500 Subject: process id from os.system References: <3977482B.478D2754@sec.noaa.gov> Message-ID: j vickroy writes: > How can I obtain the process id for a program launched via > > os.system (theProgram) ? > > I would like to do this portability (Unix, Windows). > > Presently on Unix, I'm getting the pid by parsing the output from: > > "ps -ef | grep theProgram" > > but that seems messy and unreliable since "theProgram" may be truncated > in the output from ps. Yes, you really don't want to do "ps" (and it's not really portable either, is it? ps takes different flags on just about every flavor of Unix). I'd rather do something like: ###UNTESTED def pid_system(cmdline): pid = os.fork() if pid: return pid else: os.execv("/bin/sh", ("sh", "-c", cmdline), os.environ) os._exit(0) This works like "system" but returns you the PID of the child process. The "/bin/sh" is there so you get shell command syntax in your command line (wildcard expansion, backgrounding, I/O redirection, etc) just like "os.system" does. However if you don't need this, you can skip the /bin/sh and just execv the program itself. And you can pass in a different dictionary for environment variables, if you like. As far as portability to Windows: "/bin/sh" won't be there but something like "command.com" or "cmd.exe" will, you can use that in place of /bin/sh, or as stated above if you don't need to execute a full-fledged command line but just a single program, you can skip the shell entirely. From Bill.Scherer at VerizonWireless.com Mon Jul 24 10:18:08 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Mon, 24 Jul 2000 10:18:08 -0400 Subject: binary distribution of Zope's DCOracle for Win32 References: <8lhhhf$l73$1@nnrp1.deja.com> Message-ID: <397C5020.7C660996@VerizonWireless.com> I've never seen one. Have you tried using odbc? It works well enough for me. honza_v at my-deja.com wrote: > Is there a binary version of DCOracle for Win32 systems? I have no > access to C compiler, also my knowledge of C is not sufficient. > > Thanks a lot > Jan > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From paul at prescod.net Wed Jul 19 12:11:12 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:11:12 -0500 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974CE13.3267A16B@roguewave.com> Message-ID: <3975D320.FD79A77C@prescod.net> Bjorn Pettersen wrote: > > ... > > Wasn't there an announcement about plex(?) a little while ago (a pure > python implementation of a lexer)? Yes, there are a few lexers. The issue is just deciding to put one in the library, and deciding which one and using what API. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on educatioX-Mozilla-Status: 0009.. It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From dale at out-think.NOSPAMco.uk Sun Jul 2 17:10:55 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sun, 2 Jul 2000 22:10:55 +0100 Subject: Threads? References: <8jlnkh$7h$1@supernews.com> <8jlvat$ohi$1@nntp9.atl.mindspring.net> Message-ID: <8job5d$6i$1@supernews.com> You mean I have a choice? It supports both? Either or both, is the answer. I want separate execution paths that run concurrently to (or appear to) the main one but share the same code. The ability for the processes/threads to share memory and signal each other would be a bonus. Thanks -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Aahz Maruch wrote in message news:8jlvat$ohi$1 at nntp9.atl.mindspring.net... > In article <8jlnkh$7h$1 at supernews.com>, > Dale Strickland-Clark wrote: > > > >Can Python execute a function from the same module in another process? > >I might do this, for example, to take advantage of multiple processors. > > I'm a bit confused here. The Subject says "Threads?" but your text says > "process". Which is it? > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz From paul at prescod.net Thu Jul 20 10:33:26 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 09:33:26 -0500 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> Message-ID: <39770DB6.372D4CFB@prescod.net> Martijn Faassen wrote: > > ... > > >From a game programming perspective, you can probably consider Python to > be dirt-slow, though. The trade-off is a lot of power for speed, but > that power can help you gain back speed because you can be a lot smarter. Python is dirt-slow if you are going to write a whole game in it. But is it really much slower than the embedded scripting languages these games sometimes have? -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From buzzard at urubu.freeserve.co.uk Thu Jul 20 20:27:33 2000 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Fri, 21 Jul 2000 01:27:33 +0100 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> <8l7vlm$r63$1@news6.svr.pol.co.uk> Message-ID: <8l85gq$tup$1@news6.svr.pol.co.uk> Yes. I should have stated that I do get the NameError. Thanks. I think the problem probably is that sys.stdout is still referencing the file. It's the first time I've tried to write anything to a file and I'm a bit confused. I didn't post the whole script because it's about 50K and my code probably isn't particularly well written. But I do have a second problem if anyone fancies wading through 50K of code? Thanks again. From hzhu at localhost.localdomain Thu Jul 13 15:47:23 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 13 Jul 2000 19:47:23 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396daf35.3870545@aplnews> Message-ID: On Thu, 13 Jul 2000 12:33:49 GMT, Matt Feinstein wrote: > >My own preference would be 'as consistent as possible with MATLAB, >with some caveats'-- this would mean option 1, with some thought about >changes in places where the current MATLAB syntax drops the ball >(IMO). I don't think MATLAB's inelegances should be preserved for the >sake of consistency. Any specific examples in mind? > On the other hand, I think it's very important to >make the translation from MATLAB language to Python as automatic as >possible. Agreed. OTOH, it is forgone conclusion that we can't have both a\b and a/b. So they have to be something similar to a/@b and a@/b. That's my main problem with option 1. Using a fine symbol like \ as an escape marker looks like a great waste to mathematicians but this has been with so many programming languages for such a long time. >The main thing I'd think about in addition to standard MATLAB syntax >is a natural 'prolongation' syntax. Are you thinking about this? a = [1 2] b = [3 4] [a,b] # [1 2 3 4] [a;b] # [1 2; 3 4] Currently in MatPy we have the following, which is more general because no special syntax is needed. But maybe we can find a better names? Matrix_r([a,b]) Matrix_c([a,b]) >One thing that MATLAB does correctly (again, IMO) is its relatively >relaxed attitude towards distinctions among scalars, 1x1 vectors & >matrices as well as among different kinds of nulls and NAN's. You can >test for these distinctions if you want to, but generally MATLAB will >just quietly do the right thing. There's a tendency to get wrapped up >in fine distinctions in cases where there's really no ambiguity about >what the programmer wants to do. Right now in MatPy the distinction between 1x1 matrix and scalar is maintained, intentionally. So if size(x)==(3,1) then a*x works if a is scalar but not if a is 1x1 matrix. I had had a fair bit of surprises in matlab where something would work properly until someday it is given a vector of length one, which is treated as a scalar. On the other hand, there is no need to distinct vectors from 1xn and nx1 matrices and that's where we depart from NumPy. Huaiyu From jkraska1 at san.rr.com Sat Jul 1 01:10:50 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 01 Jul 2000 05:10:50 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> Message-ID: <395D7E14.B18EC77D@san.rr.com> > Virtually all SUN has to do is pull some of the demo programs out of > Microsofts manual. Write the equivalent code in python, perl, C++, > pascal, and a few other languages. Compare them side by side. A fairly > sophisticated person can see that it's resemblance to Java. Look at > the law judges are sophisticated enough. Given that Microshit is being > sued by SUN for their abuse of Java, I don't think it will be hard at > all for SUN to convince a judge that all C# is, is a variant of Java > with tons of proprietary crap glued on and the label changed. And all Java is is a variant of the C++ language with the kitchen think glued on and the label changed. Hence the ridiculousness of the claim. Sun would be stupid to even try. C/ From Marc.Poinot at onera.fr Wed Jul 19 08:06:22 2000 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Wed, 19 Jul 2000 14:06:22 +0200 Subject: Python et Question sur Linux References: <8l43gh$j3u$1@broadway.news.is-europe.net> Message-ID: <397599BE.EF3C1101@onera.fr> J?r?me Lecomte wrote: > > Salut, > > J'ai commenc? ? regarder Python. Ca a l'air vraiment bien (plus facile > et plus clair que Perl et mieux int?gr? avec le reste du monde que > tout ce que j'ai vu jusqu'a pr?sent). Tu connais ? > > Mon fr?re envisage d'installer Linux sur son PC (266Mhz) pour > programmer. Il faut compter combien de DD pour ?tre confortable. 500Mo > peut faire l'affaire, ou il faut 1Go min. > Salut, Ton frere peut poser ses questions en Francais sur python at aful.org Mon frere aussi, il voulait mettre Python sur son PC. Et en plus il s'appelle Jerome, mon frere ! Marcvs [alias Dans la communaute Python, on est tous freres. Sauf Guido qui est le Pere, et Tim Peters qui est l'oncle ;)] From egbert at bork.demon.nl Mon Jul 3 11:17:23 2000 From: egbert at bork.demon.nl (Egbert Bouwman) Date: Mon, 3 Jul 2000 17:17:23 +0200 Subject: Books In-Reply-To: <8jpvhi$jfs$1@newshost.accu.uu.nl>; from Martijn Faassen on Mon, Jul 03, 2000 at 12:05:06PM +0000 References: <8jb1ec$9mh2@news.qualitynet.net> <8jpvhi$jfs$1@newshost.accu.uu.nl> Message-ID: <20000703171722.A7614@bork> On Mon, Jul 03, 2000 at 12:05:06PM +0000, Martijn Faassen wrote: > > I'm not sure how good Learning Python is at teaching OO concepts to people > who don't know about it yet. *Python* would be good though. Any opinions? > The PizzaRobot in Learning Python gave me a better idea what OO in Python is about, and what it can be used for, than anything else I have read so far. But it didn't teach me OO. Either I have to do a lot of thinking and experimenting myself, or I have to wait for a book with more ideas, concepts, design etc, and not in the first place tricks and techniques. Actually a great eye opener was the remark in this list a few days ago, when someone said that you use classes when you have to combine program and data, and functions when you have only program code. Or something like that. For what is a program without data. egbert -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== From andre at UltraShell.Net Fri Jul 28 05:28:29 2000 From: andre at UltraShell.Net (Andre van Straaten) Date: Fri, 28 Jul 2000 09:28:29 GMT Subject: problems with telnetlib References: <397F2A79.8B066DD3@tcgfinancial.com> Message-ID: <1ncg5.3375$%W6.127846@news-east.usenetserver.com> As no one has responded so far, my hint is to have a look for the specification of the terminal you send to the server. The following three lines are a simple script which sets up as default a very dumb terminal which cannot even filename completion, but you insert characters (after naturally having logged in). import telnetlib se = telnetlib.Telnet("209.150.158.130") se.interact() Try this to exclude other sources of errors, and then search for terminal set up (and maybe the prompt, too). -- avs jtoy wrote: > I have tried several sample scripts including the oses at python.org, > but I can't get any of the scripts to work properly. I have Python > 1.5.2 on Linux 2.2.15. All I want to do is write a script that telnets > into a machine and executes '/etc/email'. I can safely get up to the > password prompt with: > from telnetlib import Telnet > tn = Telnet('192.168.0.254') > tn.read_until('login: ') > tn.write('someuser\n') > tn.read_until('password: ') > tn.write('password\n') > tn.read_until('$ ') > then I get error in line 224 read_very_lazy and in 300 read_very_lazy > My exact login prompt after a normail telnetsession is: > [user at localnet user]$ > So reading until '$' should be write. Also, after I type > tn.read_until('password: '), thr python prompt freezes for 30 seconds > but continues normally after, why is this? > -- > Jason Toy > toyboy at toy.eyep.net > jtoy at tcgfinancial.com > http://toy.eyep.net -- Andre van Straaten http://www.vanstraatensoft.com ______________________________________________ flames please to /dev/null at vanstraatensoft.com From jonathan at meanwhile.freeserve.co.uk Wed Jul 12 04:53:19 2000 From: jonathan at meanwhile.freeserve.co.uk (Jonathan Coupe) Date: Wed, 12 Jul 2000 09:53:19 +0100 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: <8kfum1$1nk$1@news8.svr.pol.co.uk> bv wrote in message news:396A493A.DE1DF77B at sdynamix.com... > > Language Challenge 2000 -- Results > > Contest entries have been tabulated and you're invited to find out how > different languages fared. View the effortless solution of this > technical problem embodying a central theme of modern engineering and > scientific practice -- computer aided optimal design. > > To view the contest summary please click on the "Language Challenge > 2000" on http://sdynamix.com So they had seven entries. Six in Fortran and one in assembler. And which language do you think got the highest average score... Jonathan Coupe From hopper at omnifarious.mn.org Thu Jul 13 21:17:18 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Thu, 13 Jul 2000 19:17:18 -0600 Subject: DB-API and Sybase Message-ID: Posted this in the wrong place previously. Oops. *embarassed look* Does anybody know where I can find a DB-API connection to Sybase? I've been looking, but it's not at at all clear where a recent version actually is. Thanks, --Eric Hopper From sdf at sdf.com Wed Jul 26 18:04:23 2000 From: sdf at sdf.com (sdf at sdf.com) Date: Wednesday, 26 Jul 2000 16:04:23 -0600 Subject: * User-friendly software.. Message-ID: <26070016.0423@sdf.com> I found a fast and powerful FTP software, it is called FTP Now... I used it for a week already, I think it is quite good, just like Cuteftp and Ws_ftp. Also, it has a user-friendly interface and you can perform any FTP command easily. Anyway, i think it is a very good software and it is worth to try. Download here: http://english.myfolder.net/Categories/Internet_and_Network/Telnet_and_FTP/Review/?sn=9707 @`[)fx)#7TUz$4\ <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> <8l5lne$lb$1@slb0.atl.mindspring.net> Message-ID: <3976B36F.B244ABC1@schneider-kamp.de> Aahz Maruch wrote: > > Oh, *that's* a good one. All right, anyone else agree that "interleave" > is the best suggestion we've had so far? Not me. E.g.: a = [1,2,3] b = [4,5,6] c = [7,8,9] d = [10,11,12] To me there are many interpretations (thinking of TV screens etc.): interleave(a,b,c,d) == [1,2,3, 7,8,9, 4,5,6, 10,11,12] or interleave(a,b,c,d) == [1,2,3, 6,5,4, 7,8,9, 12,11,10] or interleave(a,b,c,d) == [1,7,4,10, 2,8,5,11, 3,9,6,12] or interleave(a,b,c,d) == [1,4,7,10, 2,5,8,11, 3,6,9,12] The last one is the nearest I get, but for me interleave is always producing one list. Following the zip-is-compression argument, there will also be people who think that open("my_interlaced.gif","wb").write(interleave(open("my.gif","rb").read())) will do the obvious thing ;-) Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From wtanksle at dolphin.openprojects.net Fri Jul 28 17:47:19 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 28 Jul 2000 21:47:19 GMT Subject: Perl is worse! References: <8lsdir$aja$1@plutonium.compulink.co.uk> Message-ID: On Fri, 28 Jul 2000 21:10:51 GMT, Steve Lamb wrote: >On 28 Jul 2000 15:37:05 -0400, David Bolen wrote: >>In the case here it seems as if you don't really want to define the >>name and associate it with nothing, you want to define the name and >>associate it with an object that will support being appended to. In > Will this work if the decision is to make it a string, not a list? No, because strings don't support being appended to. You can concatenate two strings to produce a new one, but you can't append to one. >>Or conversely, you could be asking to really have no definition for a, >>but have the language implicitly create a new object upon your first >>attempt to use an ".append" method - something which I don't think is >>really either intuitive or something that works in the general case >>for an object oriented model. > Hmmm, I see your point there. As I mentioned, you could also use a function -- the parameter of the function is by definition of no known contents, and therefore of no known type. > Steve C. Lamb -- -William "Billy" Tanksley From phil.harris at zzope.co.uk Sat Jul 15 13:30:43 2000 From: phil.harris at zzope.co.uk (Phil Harris) Date: Sat, 15 Jul 2000 18:30:43 +0100 Subject: NT4 shortcuts and import References: <8koe6q$avh$1@nnrp1.deja.com> Message-ID: <39709fdc@news.server.worldonline.co.uk> You can't do that in NT. Shortcuts are not the same as links in *nix. Shortcuts are really, next to useless. Even most microsoft products don't know what to do with them, try using a shortcut to a folder in any standard ms product and it will fail in the same way. Phil Andy Freeman wrote in message news:8koe6q$avh$1 at nnrp1.deja.com... > I'd like to use a shortcut named, say, "src", from the current > directory to a directory somewhere else and then use "import src.foo". > The problem is that NT4 thinks that the shortcut is named "src" > but Python thinks that the shortcut is named "src.lnk". Note that > I can't use "import src.lnk.foo" because the first "." is interpreted > as a directory name separator, not a part of the "src.lnk" module > name. > > (1) How do I get Python to use "src" as the module name? > (2) How do I escape "." in variable names? > > I'm using Python 1.5. > > thanks, > -andy > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From dsavitsk at e-coli.net Fri Jul 14 15:18:44 2000 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 14 Jul 2000 19:18:44 GMT Subject: Local CGI programming References: <396F0F28.7C8B8B83@ieee.org> <8kn7s0$dkb$1@nnrp1.deja.com> Message-ID: will you ever deploy this in the "real world"? if so i agree with Apache, especially if you will be on a Unix host. If, however, this is only local or you will deploy on an NT server, IIS using a PythonScript ASP should run a bit more efficiently and faster. my $.02 anyhow. "David Currie" wrote in message news:8kn7s0$dkb$1 at nnrp1.deja.com... > In article <396F0F28.7C8B8B83 at ieee.org>, > Didier WILLAME wrote: > > Is a http service needed to perform this test? > > If yes, what minimal product propose you? > > If no, what is the error? > > You have hit the nail on the head. Yes, an http server has to serve > the pages because the browser doesn't handle the CGI protocol. > > I don't know how suitable I am for recommending a product, but the > Apache for NT installation is quick and easy to do. However, this > discussion probably belongs in another newsgroup.. :) > > Dave > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From paul at prescod.net Tue Jul 18 23:22:34 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 22:22:34 -0500 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: <39751EFA.6293FDFE@prescod.net> Tim Hochberg wrote: > > Similarly: > > dot((A,B), C) -> A(B)(C) > dot(A, dot(B,C) -> A(B(C)) > > which looks pretty good to me. And it's arguably closer to paper > linear algebra notation than A*B is. Another good idea! You can even make it look like the new-syntax proposal: A()*B()*C A()+B()+C A()-B()-C -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From gee308 at mediaone.net Sat Jul 22 02:42:15 2000 From: gee308 at mediaone.net (Toy) Date: Sat, 22 Jul 2000 06:42:15 GMT Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> <210720002132510070%matt@mondoinfo.com> Message-ID: <39794752.D54A50CD@mediaone.net> Thanks for showing me how to do that. I tried to edit something, but it didn't work, I'll show you: def getMyAddr(): object = raw_input(Which device is connect to the internet(i.e. ppp0, eth0, ne3: ") p=os.popen("/sbin/ifconfig",object) Is it possible to do that? Will it work with os.system? What are the differences bewteen using os.popen and os.system? Thanks for your time. BTW, I only compared OpenBSD 2.7, Linux 2.2.15, and FreeBSD 4.0, but it seems if you do the string search on ifconfig with find text on 1 line beginning with inet and ending with mask, It looks like you can get the IP from those 3 machines.(of coure I still can't write some code to actually do it). Thanks again. Jason Toy Matthew Dixon Cowles wrote: > In article <3978FD9D.B08460CB at mediaone.net>, Toy > wrote: > > > How can I make python issue the command, "ifconfig -a eth0", and then > > parse the data to grab the IP? I would think that you could tell Python > > to look for the word, 'inet addr:"(is it different on different Unixes?) > > and then tell it to get a number right after 'inet addr' that looks like > > xx.x.xxx.xxx !! Simple Q, but I'm new, thanks. > > Something like this should work for you: > > import os > import string > import re > import sys > > def getMyAddr(): > p=os.popen("/sbin/ifconfig ep0") > l=p.readline() > while l<>"": > if string.strip(l)[:5]=="inet ": > matchObj=re.search("\d+.\d+.\d+.\d+",l) > p.close() > return matchObj.group(0) > l=p.readline() > p.close() > return "not found" > > def main(): > print getMyAddr() > > if __name__=="__main__": > main() > > You'll also notice that the answer to your second question is yes. The > format of the output of ifconfig is different from Unix to Unix. The > above example works on FreeBSD. You will need to fiddle it some to get > it to work under Linux. > > Another way to get the local IP is to use the functions in the socket > module: > > >>> import socket > >>> socket.gethostbyaddr(socket.gethostname())[2][0] > > But how to do that varies from machine to machine too. The code above > works correctly on my FreeBSD box but on my Linux laptop it returns > 127.0.0.1. In order to make it work right on that machine, I need to > ask for the address of the hostname only, not the FQDN: > > >>> socket.gethostbyaddr(socket.gethostname() > >>> [:string.find(socket.gethostname(),".")])[2][0] > > If there's a portable way of getting the local IP address, I don't know > what it is. > > Regards, > Matt From mwh21 at cam.ac.uk Mon Jul 24 07:26:48 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Jul 2000 12:26:48 +0100 Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: Ronald Steedman writes: > A full compile of a complex software package can often take 30 seconds or > more. That can be frustrating when you're trying to find and remove bugs. > You try one thing, wait 30 seconds, try another thing, wait 30 seconds... > > Imagine how an intepreter would help. Try one thing IMMEDIATELY SEE THE > RESULT... try another thing IMMEDIATELY SEE THE RESULT... then you only > compile the application when you're finished and want a faster program. > > I like how Visual Basic offers both compiled and interpreted programs. I > would like to see Visual C++ follow suit. :) Another major advantage of dynamic languages like Python (or lisp or ...) is that you can easily poke around at the data structures at runtime (which is rather less tedious than stopping your debugging session, adding some code to dump said data structures to a file, recompiling, getting your program back to the state you want to debug, then looking at the file, trying to remember why you created it). guess-what-I'm-doing-today-ly y'rs Michael -- I'm okay with intellegent buildings, I'm okay with non-sentient buildings. I have serious reservations about stupid buildings. -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year) From jkirwan at easystreet.com Mon Jul 24 21:49:33 2000 From: jkirwan at easystreet.com (Jon Kirwan) Date: Mon, 24 Jul 2000 18:49:33 -0700 Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: On 24 Jul 2000 14:08:25 -0400, David Bolen wrote: >gerryq at indigo.ie (Gerry Quinn) writes: > >> In article <8lh588$oti$3 at news.fsu.edu>, Ronald Steedman wrote: >> > A full compile of a complex software package can often take 30 seconds or >> > more. That can be frustrating when you're trying to find and remove bugs. >> > You try one thing, wait 30 seconds, try another thing, wait 30 seconds... >> > >> > Imagine how an intepreter would help. Try one thing IMMEDIATELY SEE THE >> > RESULT... try another thing IMMEDIATELY SEE THE RESULT... then you only >> > compile the application when you're finished and want a faster program. >> >> If I were your boss I would make sure you had no access to an >> interpreter! I would even slow down your compilation by giving you an >> older machine ;-) >> Changing things at random and hoping the problem goes away is not the >> way to fix bugs. > >Where in the above did he say "random" and "hope"? Being able to >iteratively and interactively make changes hardly has to impact the >methodology used in arriving at those changes to be made. > >Or are you saying that the use of a compiler would remove the need to >ever iterate more than once on a bug fix? I'm not sure I'd agree :-) I'm guessing at Gerry's meaning here, drawing from my own observations, but... Perhaps he meant to point out the lack of discipline that a prototyping language may often encourage. Folks start "hacking" their code into what appears to be the right behavior rather than designing it in, from careful thought. They may instead wait until the interpreter slaps up an error dialogue on some line and then just hack in an 'IF' to "cover (fix) it." Perhaps "random" and "hope" were too strong of words. But the gist may have been that he'd like to encourage the kind of mental skills developed, that better happen when you are coding "on a high-wire and without a net." I use a debugger rarely and sporadically -- perhaps twice a year, on average -- usually to clear up an ambiguity not entirely obvious from the instruction documentation. Debuggers and interpreters are often (but not always) used chronically as crutches to get around in everyday life, rather than the occasional solution to an acute problem. Mental growth languishes and withers with such poor exercise. Jon From aahz at netcom.com Thu Jul 20 09:51:40 2000 From: aahz at netcom.com (Aahz Maruch) Date: 20 Jul 2000 13:51:40 GMT Subject: Waiting for Threads to Stop References: Message-ID: <8l705c$uop$1@nntp9.atl.mindspring.net> In article , Doug Fort wrote: > >I have several cases where I want one thread to wait for one or more other >threads to terminate. I've had poor results attempting to spin on isAlive() >in join(). I'm contemplating using a semaphore. Has anyone got a more >elegant idiom? If you're waiting for one thread, that's reasonably easy. If you're waiting for all of a group of threads, use a semaphore. But if you're waiting for any one of a group of threads, that's a bit more tricky. I'd suggest waiting on a queue, where the threads dump their data into the queue. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From gerrit.muller at philips.com Mon Jul 31 03:03:17 2000 From: gerrit.muller at philips.com (Gerrit Muller) Date: Mon, 31 Jul 2000 07:03:17 GMT Subject: Python in politics (sssssssssnake!) References: Message-ID: <398524B5.A608BFF1@philips.com> Moshe Zadka wrote: [...snip...] > "Thinking like a computer scientist in Python", available at > http://yhslug.tux.org/obp/ > (follow the links) > might be a bit too heavy for 9yr old, but should be a good place to start. > > It's under the GPL, so you're welcome to fork a version suitable for > younger kids, and share the changes with everyone. > -- > Moshe Zadka > There is no IGLU cabal. > http://advogato.org/person/moshez Books for children should immediately contain action, preferably audio or images/video. My children (12 and 10 years) loose interest if there is more than a few paragraphs of explaining text, especially when it is dull theory. Here in Holland we have a series of books by Addo Stuur, Programming for children, Windows for children etcetera, which all follow the formula of telling in detail how to do something followed by an exercise. My children sometimes get bored by the completeness of detail Addo brings in. Nevertheless his method gets children productive in a short amount of time. Maybe we should send Addo Stuur a few Python books :-) -- ------------------------------------------------------------------------- Gerrit Muller Philips Research Laboratories Eindhoven Building: WLp 1 17 Prof. Holstlaan 4 Phone: +31 40 27 45242 5656 AA Eindhoven Fax: +31 40 2743741 The Netherlands mailto:gerrit.muller at philips.com http://www.extra.research.philips.com/natlab/sysarch/index.html From wware at world.std.com Thu Jul 20 00:12:11 2000 From: wware at world.std.com (Will Ware) Date: Thu, 20 Jul 2000 04:12:11 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l52hs$i05$1@kopp.stud.ntnu.no> Message-ID: > > Be sure to check out stackless Python, which has some advantages for > > game scripting: > > > > http://www.stackless.com/ Magnus Lie Hetland (mlh at idi.ntnu.no) wrote: > What exactly *are* these advantages? (Very curious...) Stacklessness allows you to implement extremely light-weight threads, because you can concisely maintain a number of execution contexts simultaneously, and rapidly switch between them. This could be useful in a game if you want to model simultaneous behavior of a large number of agents, such as soldiers in an army, ants in an anthill, airplanes in a Pearl Harbor simulation, etc. Chris Tismer, Just van Rossum, and I have done some work on this. See http://world.std.com/~wware/uthread.html -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From gansevle at cs.utwente.nl Tue Jul 4 06:14:08 2000 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Tue, 04 Jul 2000 10:14:08 GMT Subject: Performance References: <39619175.5F8B503D@proceryon.at> Message-ID: <8jsdd9$51r$1@nnrp1.deja.com> In article <39619175.5F8B503D at proceryon.at>, Horst Gassner wrote: > Hi all! > > I have implemented a tree view with special items (the base for this > work was the TreeWidget from IDLE). > > The performance is not the best and therefore I ran the profiler today. > The following function is one of the slower ones and I would be happy if > there are any possibilties to speed this thing up. > > subItems = {} > if s.__subList[level] : > for key in s.__subList[level].keys (): > # root level is special case! > # get all sublevels without recognizing id of sublevel > if level==0 or string.find(key, id) == 0 : > subItems[key] = s.__subList[level][key] > > The functions looks for all subitems for a given level and a given id. > For each level I have pre-built a list that I have just to go through > the items of the given level. > You can speed things up by putting the special case outside the loop Another speedup is: use slices instead of string.find since you only match the first part of the key subItems={} if s.__subList[level]: if level == 0: # root level is special case subItems = s.__subList[level].copy() else: id_len = len(id) for key in s.__subList[level].keys (): if key[:id_len] == id: subItems[key] = s.__subList[level][key] This might improve things abot 5-10% depending on how often string.find would fail on finding the id. > Thanx in advance > Horst > -- ----------------------------------------------------------------------- ---- Linux/Windows-NT/IntraNetware Administrator ---- -- Whenever it sounds simple, I've probably missed something! ... Me -- ----------------------------------------------------------------------- Sent via Deja.com http://www.deja.com/ Before you buy. From sglanger at u.washington.edu Sun Jul 16 16:57:22 2000 From: sglanger at u.washington.edu (steve langer) Date: Sun, 16 Jul 2000 13:57:22 -0700 Subject: Internet Programming in Python Message-ID: <397221B2.173C3947@u.washington.edu> Does anyone know a used book store that would carry this out of print book? Email great. thanks, SL sglanger at oakland.edu From cjc26 at nospam.cornell.edu Mon Jul 10 20:50:30 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 11 Jul 2000 00:50:30 GMT Subject: Nonblocking IO? References: Message-ID: * Nolan Darilek menulis: | | The most obvious solution is to use curses, but this makes my program | much more complex than it needs to be. Since cmd does almost exactly | what I want it to do, I'd much rather change the Cmd class than add | curses. I've seen code written in C which does what I'd like to do | (Micq, for example, has the interface which I'm aiming for, yet it | doesn't use curses/ncurses.) So, is it somehow possible to either a) | make raw_input nonblocking or b) use some other nonblocking IO method? You could use the select module to wait for input from multiple file descriptors (for example, sys.stdin and a socket). Also, the asyncore module is a higher-level interface to select, and may be useful to you too. | And, is it then possible to ensure that the output from the socket | isn't intermingled with the input? If I do nonblocking IO, I'm | assuming that it's simply a matter of printing a newline, my message, | and then reprinting the prompt while stuffing the existing input back | into the input buffer. Have you checked out the termios module? That would be pretty much the only other way to do it, besides curses (which is aptly named, don't you think? ;) curses-shmurses-ly y'rs, Cliff -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From paul.magwene at yale.edu Sat Jul 15 13:17:37 2000 From: paul.magwene at yale.edu (Paul Magwene) Date: Sat, 15 Jul 2000 13:17:37 -0400 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F76F0.1B451932@sage.att.com> <8kp4bo$jpt$1@slb7.atl.mindspring.net> Message-ID: <39709CB1.4F652EFA@yale.edu> Andrew Dalke wrote: > > Huaiyu Zhu wrote: > > > >That's the beauty of numerical computation, because all kinds of > >applications, from animation on your screen to controlling satallite in > >space to analysing molecular structures to calculating consumer preference > >could all be expressed in the language of linear algebra > > Speaking as someone who has been analysing molecular structures for the > last 7 years and animating them for about 5 of those years, I can say > the lack of dot-wise elements, both in C++ and in Python, has not been > a great concern. > > Andrew > dalke at acm.org I agree with Andrew. The bread and butter of my programming activities involve numerical computation, and in particular linear algebra. But I DO NOT want to see python polluted with all sorts of special syntax just for that purpose. -- Paul Magwene paul.magwene at yale.edu From xiarcexml at yahoo.com Mon Jul 17 14:17:43 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Mon, 17 Jul 2000 11:17:43 -0700 (PDT) Subject: Does Python code >.require<< a run-time environment?? (New to Python) Message-ID: <20000717181743.6728.qmail@web5302.mail.yahoo.com> I suppose... I have always had the kits and the java files installed on my computer... and when I started my major project (version 1.0) completed with Java, I was doing so because I had Macs and IBMS and Unix's, Linux's as potential clients. I was going for Java because of its touted 'platform independence'. I love Java... BUT.. it is not as independent as Sun would have wanted it... Ironically, now, I have only Windows users... but the language I chose to 'learn' was Java for it, and it is written in Java... Currently, they DL the files and install them into wherever their classes run, and type in the RUN box C:\WINDOWS\Jview CyberGameTable (yes, I, , have users using Jview, as it is installed, and convincing them do DL Sun's package did not work) I was hoping that Python (and it does seem to be really neat on the programming end) would provide me with the ability to create an executable that one would Download and run without having to (1) set classpath (2) run-line command it.. etc... ((I had been hoping for it in Java, too... chock it up to beginners' stupidity--one year later I am a little wiser)) I've read references to 'compiling it to C'... is this a laborious process requiring knowledge of C or C++? ~Dave __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From etiennel at geospace.co.za Fri Jul 14 05:26:18 2000 From: etiennel at geospace.co.za (Etienne Labuschagne) Date: Fri, 14 Jul 2000 11:26:18 +0200 Subject: Memory leak problems with python and COM References: <963474833.835936@proxy.lia.net> <8klbu9$38u$1@nnrp1.deja.com> Message-ID: <963566559.894793@proxy.lia.net> Thanks for the reply Mark, I will get the latest version and report back if that helped. Regards Etienne "Mark Hammond" wrote in message news:8klbu9$38u$1 at nnrp1.deja.com... > In article <963474833.835936 at proxy.lia.net>, > "Etienne Labuschagne" wrote: > > Deleted a and b on the python side and then destroying the COM > server - that > > doesn't clear up the memory. I am using SafeArrayAccessData and > > SafeArrayUnlock on the server side to make sure that it releases the > data on > > the server side. > > > > Is there something else that I must do? > > I suggest you get the latest CVS version (I realize this may be a > PITA :-( Since build 132, a number of leaks have been fixed. There is > a very good chance that this particular leak was plugged previously. > > If not, I will definately look into this and plug it! > > Mark. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From m.faassen at vet.uu.nl Fri Jul 28 16:11:42 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Jul 2000 20:11:42 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> Message-ID: <8lspdu$m7e$1@newshost.accu.uu.nl> Steve Lamb wrote: > On 27 Jul 2000 20:24:38 GMT, Martijn Faassen wrote: >>In the end if you want to add your data together, you need to know what >>the result will be. If you want to substract your data, you also need >>to know. > That all depends. In python, yes, you need to know. Why? Because 1 + > "foo" doesn't work. Sure, in perl you get 1, but you don't get blown out of > the water because of it. You mean your interpreter does not stop, it continues, even though it got data it couldn't really make sense of. I mean, there's no reason 'foo' would be 0, '1foo' is 1, and 'foo1' is 0 again. Right? I don't see how you dont 'get blown out of the water'; it seems worse -- you get input that is not a number, and Perl just happily continues with your calculations. So you have to make sure your input is a number *anyway* if you want to calculate things, so why not complain in the first place when you run into something that doesn't seem to make sense. Anyway, I'm sure we won't be able to budge each other from our position on this. :) > OTOH, in Perl, if you meant to do a string addition > there is a different.syntax.for.that. Because of this you know that "foo" > doesn't equal anything, IE, 0. 0 *is* a legitimate number, you know. I know there's a different syntax for concatenating strings in Perl. >>What if your data is "foo" and you add them together? What if >>the user gave some input and you don't *know* what the user entered? > Then that would be a user error, wouldn't it? You can check for those > things. If you're relying upon user input you don't need type checking to do > it. Yes, but in Python at least the program doesn't try to do things when you forgot to check the user input properly. And that increases the chances you'll find the bug in the first place. > python: > try: > b = b + 1 > except TypeError: > print "Numbers, stupid, not letters." > perl: > unless (int($a)){ > print("Numbers, stupid, not letters.\n") > } > $a++ This code doesn't seem to be equivalent, though. In Perl if 'a' is a string-that-when-striped-of-whitespace-does-not-start-with-a-number you'd get 1 (I think?), and in Python 'b' remains unchanged. And if I forgot the 'unless' in Perl (though it doesn't matter in this code fragment :), I'd get 1, and in Python it'd get a bug. So I know I need to change my code to do a check. > The difference comes when you do something like this: > (/^(\d{1,2})[Dd](\d{1,3})$/ || /^(\d{1,2})[Dd](\d{1,3})([\+\-])(\d{1,2})$/) I don't know what you mean here. I never do anything like that, I'm happy to say. :) > Perl or Python, doesn't matter, you should be able to read it. I'm not able to read it. > Simple regular expression to take die codes from RPGs (3D6+3, for example) > and break it down into the component parts regardless of their being a > modifier to the actual dice rolled. What does this sample show? Same > thing that the previous one did. I'd probably solve that in a more verbose way myself. [snip regex example] So you're saying, since I know those particular groups are numbers anyway by necessity, it makes no sense to require explicit conversion (with int() in Python) to numbers of those things. I just want to use them as numbers right away. Did I understand that correctly? The problems arise if you made either a mistake in your regular expression so what's being returned happens not to be a number (but you expected it to be), or when the regex is fine but you confused which variable contained what result. As your program proceeds and for instance throws the dice, it'll try to use those variables as numbers, but since they're other strings, you'll eventually get strange answers (such as 0). And then presumably you'd have to search what part of your program is wrong. In Python you'd know pretty quickly that you got strings instead of numbers, and so you know what to fix. >>I think in your case you usually need to remember what type your data >>is *anyway*, and what's worse you need to know what will happen to your >>data for various cases: > Assumption: that data checking cannot be performed by the programmer. That wasn't the assumption. I said the exact opposite, you need to remember what type your data is *anyway*. In order to do that you need to check the data if it is input. > False assumption, I've given two examples where the data will be what I > want because I have made the appropriate checks. That's the point; you need to do that anyway. It doesn't take you that much effort to do the right kind of conversion (to an integer) afterward; as you're checking anyway. And it catches the bugs more quickly, I'd think? > One comes right from the > program that I am porting to Python to learn Python. In fact, that program > relies on user input every step of the way yet I've not had any problems > performing the operations I want to perform on the data. >>This may become quite unobvious in various cases, and may happen by >>accident, right? > Doesn't mean the programming language should barf on it. But if the language barfs and tells me where it barfed and why, I can more easily fix the bug, right? > I am of the > opinion that a /lot/ more operations are performed where a lack of type > checking is a virtue than a bane. I really dislike having to explicitely > declare data as a certain type just for an operation, > especially after having programmed in a language where such is not > required and especially if I have > control of the dataflow throughout the entire course of its life. Not only > does this cause problems for simple operations like extracting numbers with > regex to be manipulated with mathematics, but also internal data structures > where the author is defining things on the fly and needs to perform both > string and numerical operations on, say, the keys of a hash/directory. >>Though I understand the case for genericity, I don't really see it here. > I see it the other way. Though I understand the case for typing, I rarely > see a case where it is actually useful and, in fact, many cases where it is a > bane. I'd much rather have to deal with the few cases when they arise than > the many cases when they arise. For example, mathematics which require > roll-over at a certain number (unsigned int, for example). This is more so in > a language which does have certain cases when types can change (int versus > float, for example) and the initial type is implicitly stated but requires an > explicit declaration to change that implicit type. > Either have all types be immutable regardless of context unless explicitly > stated or have all types mutable as best as possible based on context with the > option of explicit typing. The half-and-half is just as confusing as a lot of > what a lot of Python pundants dislike about Perl. Just like lists and > directories (does that include tuples? I forget) being referenced but the > "single" data types (integer, character, I believe string, not sure) being > copied. This is a common misconception. *everything* in Python is always, always, references. It is just that certain data types (integers, string, tuples) are immutable; you cannot change them. So the semantics are the same as copy semantics. > That is no less magical and confusing than, It may be confusing, but it's definitely not magical. The rule is one of the simplest I've seen, actually. :) > say, using an implicit $_ > in a foreach loop or constructing a data loop from @lines into %lines using > $line to do it. $lines{$line} = $line[$line] is always fun to bedazzle > newbies, isn't it? No different than implicit typing, IMHO, except here I do > have cues as to what is a scalar, a hash and an array. >>But what if that makes no sense? What if I entered 'foo' in the config >>file where I needed to enter a number? Won't you get a weird bug now? > OK, go ahead and do it in Python, what do you get? An exception. > Do it in Perl, what do you get? The /possibility/ of odd behavior. Isn't that worse than the program giving up? Especially when I'm trying to debug things. Obviously the right thing in both languages is to *check*, and if you're checking anyway I don't see what the disaster is of doing int() somewhere in your checking function. Especially because it points it out to you if you forget. [snip] > And that is the whole point. In both cases you have to do error checking. > The difference is that with the implicit types enforced it gets in the way. > I'd much rather the language assume I am smart enough do to my own checking > and assured that the data is valid than to assume I'm too stupid to do it and > crap the program out when something doesn't match what it /thinks/ is invalid > even though I have taken pains to ensure it is. But you haven't; you haven't told the system it's a number yet. :) That's the _only_ extra step you need to take. The system is too stupid to figure it out very well on its own anyway, so why not tell the system explicitly? Anyway, this whole debate is silly as philosophically Python and Perl are very close in depending on the intelligence of the programmer. Python assumes a bit less intelligence, I'm glad to say. I'm not intelligent enough to do regular expressions a lot, for instance. :) But compared to language that does static type checking the difference is so minimal. >>This script won't do anything. > Thank you for so stating the obvious, especially when I provided the > interactive mode right after it. Interactive mode (I think it explains in the tutorial) gives you the output of expressions as a result always. >>I imagine the reason Python doesn't complain here is that it can treat >>expressions as statements, and that sometimes this makes sense, such >>as when there's a function call: > The problem is, outside the context of interactive mode what good does it > do? I just gave you the example of the function call, right? That's what good it can do: foo() is an expression, just like 1 + 1 is. foo() definitely makes sense, right? > Nothing that I can think if. Have you made calls for Python to check for > such things just as it checks implicit types? If not, why not? In both cases > the assumption is that the programmer does dumb things and should be babysat. Okay, I rarely run into this type of thing, so I haven't made calls for it. I think it's fairly difficult to add this, as you never know whether the user didn't mean to place an expression there that does a function call, which does make sense. So you'd need to check whether your expression is a function call and supress the complaint if that happened. Perhaps that would be interesting if it doesn't break anything else. Anyway, perhaps you're right and you don't run into this type of problem very often as you take care to do checking and your checking code doesn't have too many bugs in it. I myself like this particular safety net, and also the absense of lots of ambiguity in the case of adding something together when the something involved is not a number. But I'm sure I could learn to live with it. >>I'm not claiming we want to be strict about things at all times. If >>I thought that I wouldn't be using Python. I was claiming that 'guessing' >>what a line of code is supposed to mean can be bad. I mean, really: >>"foo1" + 1 # 1 >>"1foo" + 1 # 2 >>"1" + 1 # 2 >>" 1" + 1 # 2 >>"\n1" + 1 # 2 >>"1*2" + 1 # 2 >>Are you sure this never gives you any odd output? > Positive. Because you have made the base assumption that the only way to > check data is for the language to do it instead of the programmer. No, my entire point was that you need to know what your data is *anyway*. You need to know that something is an integer anyway, so why not simply tell the computer what's going on? I'm *not* saying the language should do the checking. It can't; even though Perl tries. > I know what data I am passing, I don't need type checking in an implicit > system to provide annoyances all over the place for the off chance that > I /might/ goof up. Quite a Libertarian view, innit? In a sentence. > LET ME MAKE MISTAKES! And when you make them, let the system complain loudly! I just don't see the annoyances in this case. I do see the annoyances of static type checking. If you want the system to shut up about your mistakes, you can always do this in Python: try: a = a + 1 except: pass But at least you're saying explicitly here that the system is shutting up about your mistakes. >>No, giving up in the face of ambiguity versus guessing. Ambiguity tends >>to arise when I'm doing something wrong; if I did it right it wouldn't >>be ambiguous code. Besides, I wouldn't want to read such code even >>if it did the right thing; confusing. > What ambiguity? Data is data. "foo" is not 0 to most people. "1foo" is not 1 to most people. What's more, "one" *is* 1 to most people and "2*2" means 4 to most people. Lots of ambiguity here. Where does the computer stop in trying to make sense of it? The computer is stupid after all. > I don't find it confusing when you unlearn > the concept of types. I mean, how many people out there who program in other > languages consider Python confusing because whitespace is used for block > declaration instead of {} or BEGIN/END or whatever other block declaration is > out there. > If your mind can wrap itself around the concept of a lack of braces for > block declaration then there should be no problem unlearning the concept of > data "types". The problem is that there is no unambiguous way to do numerical addition of strings. You use the concept of numbers versus non numbers in Perl too; you *have* to check for this in the face of unpredictable input. Since you're using this concept, why not explicitly tell the machine about it? The answer is; you're not because of convenience. And that's fine; Python does that a lot in other places (all over its OO system, for instance). It's just that I'm not convinced that treating numbers and strings as the same thing *is* convenient. >>In Python there are tons of ways to do it too. :) > So long as you tell it explicitly what you want even though its ambuigity > on the implicit typing is what cause the problem in the first place? No, you probably don't realize how limited this kind of implicit typing in Python really is. It doesn't exist in it's OO system! class Cow: def make_sound(self): print "moo!" class Chicken: def make_sound(self): print "cluck!" mycow = Cow(); mychicken = Chicken() a = mycow # or: a = mychicken a.make_sound() This works. I didn't need to tell the system that 'a' is a cow or a chicken or an animal that can make sounds. The Cow and Chicken classes have nothing to do with each other; no inheritance, no explicit interface, nothing. The only thing they have in common is a make_sound() method. > I'm > sorry, but I do not consider data confusing unless it is typed. I see 1 and I > am confused why I can't add it to 2. I don't /care/ if it is a char, string, > integer or floating. It is 1 to me. Sure, but what about "one" and "foo"? I don't see "foo" and think I can add it. >>Because I wasn't arguing for 'strict checking'; I was arguing not checking >>until the *last moment*, and if that makes no sense, give up. >>(unless you catch the exception, of course) > Which makes no sense without declarations up front since you are allowing > ambiguity, to use your term, from the onset. > Python: You need to know what data type it spews out for each operation. > Perl: You need to know what the data contains. > Either way, you got ambiguity. Sure, but Python gives up in the face of ambiguity. It doesn't try to continue and infect the rest of the system with more ambiguity. (though again, this debate is very limited! Look at Python's OO system) > As for catching the exception I'd much rather check the data first, thank > you. You can do that in Python too. I tend to prefer that as well. >>Not in OO code: > Funny, we have implicit typing in OO code that causes problems later in > the code. So yes in OO code. What implicit typing? I don't understand what you mean at all. > >>That works, as the check at the last moment could figure it out; there was >>such a method, so it executes it. Now if 'doit()' was absent and the system >>started guessing, we'd be in trouble, right? > This is not, however, data. Methods are functions, if there is nothing to > call, there is nothing to call. 1 is data, be it integer, float, char, string > or any other name you want to give it. 1 is data with operations. Just like an object is data with operations. In Python, 1 is an object. See the end of my post. >>So I don't need to know about what happens when I do "1foo" + 1? >>Or "foo1" + 1? Or "foo1" - 1? Presumably I'd need to check my user >>input *anyway*, right? > Yup, that is exactly what you should be doing and if you were doing it > properly then you'd not have to rely upon the language to do it for you. Yes, but if I'm not doing it properly at least the language will complain so I get a broad hint I do need to do it properly. :) > As I said, you're trading knowing what a certaion operation does with > certain data versus having to know what type of data a certaion operation > spits out at you. Yes, but they're not equivalent. Imagine we have 5 binary operators and 5 types of data. In Perl you can use any type of data with those operators, and Perl will figure it out. That means I have 15 possible combinations that I need to know about (whether they make sense or not, such as adding together non-integer data). Now let's imagine a simple Python case, where you can use all 5 operators for each type, but you can't mix types. That means I need to know what Python does with only 5 combinations; the rest of the cases, Python will complain. >>> Not that hard to remember. Much easier, in fact, that having to >>> remember to declare everything from the onset or declare it each time you >>> need to use it in a particular context much less having to put in checks >>> in case you're trying to declare something into something which it cannot >>> be morphed into. >>But in Python you don't need to declare at all. You just need to explicitly >>say sometimes you want something changed into something else. If you >>want an integer, change your string into an integer. Do it early on if >>you don't want to do it everywhere and work with integers from then on. > Thank you for ignoring what I said. My apologies, what did I ignore? I didn't get the impression you read what I was saying all the time either. :) > First off, in Perl I don't have to > declare at all as a rule and only need to worry about the exceptions. In > Python it is the reverse, I need to declare as a rule except for the > exceptions. Huh? Where in Python did you find your declarations? I'm confused. > Furthermore if I need to change my string into an integer I need > first check to make sure it is a string /THEN/ I can convert it to an integer. [snip] Well, because it doesn't really make a lot of sense if you want to convert something to an integer when Python can't figure it out. If you're so sure of yourself, you can always do: try: a = int(b) except ValueError: a = 0 > This causes problems when using a regex that has an or that can match > different numbers of groups based on which or hits because any conversions on > any group that didn't hit now needs to be encapsulated in either a > try/except|finally block or an if. All right; this just doesn't happen very often in my code. Generally because I can expect a certain regularity in my input. If my input is less regular than I expected, I get exceptions. That gives me a nice indicator that my expectations were off. > You might like littering your code with > try/except and ifs which are only needed because the type checking isn't > allowing you to do things you should be able to do but personally I don't. I > find it foolish that I need to check a variable to make sure it exists so I > can type it to integer when I know an integer is going into it in the first > place! In short a regex which returns a number turns into... In that case you don't need to do any checking, obviously. You have a regularity in your data so you just do something like: a = int(a) [snip example] Though I may be missing something about regular expressions here and I'm goofing up? [snip] >>The funny thing is that in Python this happens, and I'd agree with you, >>but it tends to happen more often for class instances > Except I don't consider instances data. They are structure or commands, > not data. I consider both integers and strings and instances as *objects*. See the end of my post. >>We aren't so far apart in that sense; we just disagree about how many >>operations the basic datatypes should support. I personally never had >>trouble with having to call int() excessively, for instance. If you >>find you're doing that a lot in your code, something may be odd about the >>design of your code. > I seriously doubt that. All I'm doing is a basic regex match and > assignment of the matched data. I haven't gotten into making complex data > structures yet in Python but I have a feeling the typing will get in the way > since a lot of the times that I manipulate keys in a hash/directory I move in > and out of numerical and string processing to get the job done. Hm, why would you do that? Depends on the structure of your keys. You can use numeric keys in your Python dictionary just fine. >>Note also that in your case, the only thing you're complaining about is >>that Python treats numbers and strings differently; Python doesn't care much >>whether your number is an integer or a float or a long integer, for instance. >>It doesn't distinguish between characters and strings either. The only >>addition to your type pantheon would seem to be the string/number >>dichotomy and the list/tuple dichotomy, nothing else. :) > Hmmm, but you forget, lists, tuples and hashes are not data, they are > structure. They're all objects. :) > Hashes and arrays are not data, they are structure. Classes that > hold only data are not data, they are structure. Classes, in fact, to me, are > just structures that hold either functions (renamed to methods) or data. > You have different types of data. I have, conceptually, data, commands > and structure. What /form/ those take and what semantics assigned to them > vary from language to language but the concepts to me are quite clear. I have objects (and some functions). Not all objects support all operations. [snip] > Lists, arrays, hashed, directories, classes, structs, etc, etc, etc are > all organizational in nature. In Python, they're objects just like there rest of them. > OO has the distinction of having the ability to > apply those organizing constructs to commands and not just data. > Operations, functions, prodecures, methods. All manipulate the data. The > do something. In OO they can be organized. But an integer can be seen as an object with methods as well. A string too (Python 2.0 will actually allow you to use string methods). In fact, I can make a new type of object in Python that behaves much like your Perl scalars: import string import re class Scalar: def __init__(self, data): self.data = magic(data) def __add__(self, other): return Scalar(self.data + other) def __radd__(self, other): return Scalar(self.data + other) def __sub__(self, other): return Scalar(self.data - other) def __rsub__(self, other): return Scalar(other - self.data) def __mul__(self, other): return Scalar(self.data * other) def __rmul__(self, other): return Scalar(other * self.data) def __div__(self, other): return Scalar(self.data / other) def __rdiv__(self, other): return Scalar(other / self.data) # (not all possible operations implemented) def __coerce__(self, other): return self, magic(other) def __str__(self): return str(self.data) def magic(d): """Magically convert d to an integer, whatever it may be. """ if type(d) == type(1): return d d = string.strip(str(d)) matches = re.match("(\d+)", d) if matches: d = int(matches.group(1)) else: d = 0 return d # now let's use it: print Scalar("1") + "1" # 2 print Scalar("2") - "1" # 1 print Scalar(3) * "4" # 12 print Scalar("12") + 2 # 14 i.e. any expression with a scalar object involved will try to treat any operant as a number. Of course this particular implementation has various disadvantages: * it's incomplete * it's likely buggy * it's slow (could be solved by a C implementation though) * no operators for string concatenation exist by default in Python; we'll either have to coopt an existing operator or provide functions to do concatenation. I even used a regular expression. :) There's-more-than-one-way-to-do-it--ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From musingattheruins at my-deja.com.bbs Mon Jul 17 17:10:02 2000 From: musingattheruins at my-deja.com.bbs (musingattheruins at my-deja.com.bbs) Date: 17 Jul 2000 21:10:02 GMT Subject: Again: ODBC / Win98 -> crash Message-ID: <3bRPRQ$lPc@openbazaar.net> i have installed the most recent mdac 2.5 and now cannot connect to any DSNs with ADO!!! and cannot make DSN-less connections with ADO!!! tried rolling back to 2.1 (nope... component checker reports v 2.5) + re-install 2.5 + re-install python 1.5.2 + re-install python win32 all + try again -------------------------------- NFG no solution yet... _if_ i find one i will post it. bill :-( > >Now for a really strange thing: I just moved my script to a different > >computer (almost identical configuration), and... - everything works > >just fine! No crashes, no problems whatsoever. I hate computers. > > Maybe the machine it crashed on had Office 2K installede recently ??? and > the one that doesn't crash hasn't or something like that. The combination of > Win2k, Office2000/97 has caused me no end of grief. > > Try installing the newest version of mdac on your machine. (should not be > needed on win 2K). > > Also check your security settings and r/w acces. Combinations of these two > has helped me before. > > Regards Max M > > Sent via Deja.com http://www.deja.com/ Before you buy. From jhe at webde-ag.de Thu Jul 20 04:15:28 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Thu, 20 Jul 2000 10:15:28 +0200 Subject: zip() : how about braid() References: Message-ID: <8l6cbp$fgr$1@pollux.ip-plus.net> "Michal Wallace" schrieb im Newsbeitrag news:Pine.BSF.4.10.10007191838040.26945-100000 at chi.pair.com... > I accidentally deleted the list of proposed names for "zip()", so I'm > not sure if this was alrady mentioned.. I think merge makes sense, > (and I don't really have a problem with zip()), but the metaphor that > most closely resembles what it does is braid(), as in hair.. I do have a problem with zip, namely that I think of compression first (and I did when i first read about zip(), and wondered what the hell it had to do with sequences). merge() is the best yet, since it's a common (programming) term with a well-defined meaning. Don't forget EnglishAsA2nd speakers, which won't know what "braid" is all about, but are likely to know merge. OK, to add some confusion, paste() would be possible too (compare to the UNIX command). Bye, J?rgen From no at bo.dy Fri Jul 21 00:04:32 2000 From: no at bo.dy (nobody) Date: Thu, 20 Jul 2000 23:04:32 -0500 Subject: iterating over lines in a file References: Message-ID: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich), in : > import fileinput > for line in fileinput.input("somefile"): > process(line) ah, many thanks! i'm still spelunking my way around the standard library; gems like this seem to be lying around all over it. :-) From "rod" at REMOVETHISinf.bme.hu Mon Jul 3 10:24:26 2000 From: "rod" at REMOVETHISinf.bme.hu (Gabor Papp) Date: Mon, 03 Jul 2000 16:24:26 +0200 Subject: tracing a variable References: <395BEC23.9A3097F0@uniserve.com> Message-ID: <3960a227@news.caere.com> there's a trace method of tkinter variables. use like var.trace(ops, callback) 'callback' is called if 'var' is accessed in one of the ways given by ops. operations are the same as in tk ('w', 'r', 'u'). Gabor From olivierS.dagenaisP at canadaA.comM Sun Jul 23 16:03:35 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 23 Jul 2000 20:03:35 GMT Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> Message-ID: The Python binary might be in your path, but maybe the libraries aren't? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Rodney Loisel" wrote in message news:397B0D93.6A5EE7CB at helicon.net... > Changed the DOS properties not to close on exit > the following is the result of > import Tkinter > several levels of error > last: > DLL load failed: one of the library files > needed to run this application cannot be > found. > rloisel > From horst at proceryon.at.bbs Tue Jul 18 01:30:03 2000 From: horst at proceryon.at.bbs (horst at proceryon.at.bbs) Date: 18 Jul 2000 05:30:03 GMT Subject: Best way to switch between different view Message-ID: <3bRcSR$mve@openbazaar.net> Hi all! In my application there are three different kind of views. Each of them has to be displayed in the same main window. Two of them are scrolled canvases and one is a scrolled frame (all of them with many widgets inside). What is the best way to handle this different views? At the moment I completely destroy one view and rebuild the new one but there must be a better way. Some time ago I have read something about an unpack method to hide a widget. Could this be the best way to do this? Thanx in advance Horst From smigowsky at dspace.de Thu Jul 20 08:24:44 2000 From: smigowsky at dspace.de (Stefan Migowsky) Date: Thu, 20 Jul 2000 13:24:44 +0100 Subject: Pythonwin attribute expansion Message-ID: <326536345498D311B3BC00105A39802A0747A7@newsintern.dspace.de> e.g. try: items = items + dir(ob.__class__) for i in ob.__class__.__bases__: items = items + dir(i) except AttributeError: pass Stefan >-----Original Message----- >From: Mark Hammond [mailto:MarkH at ActiveState.com] >Sent: Thursday, July 20, 2000 12:15 PM >To: python-list at python.org >Subject: Re: Pythonwin attribute expansion > > >Let me try this again... > >It's a bug. > >If you would like to fix it, look in pywin\scintilla\view.py, >and locate >the _AutoComplete() method. The line: > > items = items + dir(ob.__class__) > >Is at fault - dir() doesnt search sub-classes. Simply make this line >smarter, by iterating over ob.__bases__ > >Mark. > > > >-- >http://www.python.org/mailman/listinfo/python-list > From tim_one at email.msn.com Wed Jul 12 19:04:49 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 12 Jul 2000 19:04:49 -0400 Subject: What is UnboundLocalError for? In-Reply-To: Message-ID: [Alex] > (Python 2.0 question.) > > I was wondering what situations the UnboundLocalError exception is > intended to be thrown in. When a local name is referenced but has not been bound to a value. In other words, it's an unbound local error . Note that UnboundLocalError is a subclass of NameError, because it's a more specific form of NameError, so old code expecting to catch NameError exceptions will still catch UnboundLocalError exceptions. In 1.5.2 and before, NameError was thrown regardless of whether the offending name was local or global. So UnboundLocalError gives more information. > I encountered it when I made a mistake like this: > > >>> f() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1, in f > UnboundLocalError: l > >>> So your function f (which you have not shown us) refers to a local name "l" which you didn't give a value before referencing it. It's impossible for us to guess what you put in the body of f; here's one possibility: >>> def f(): ... l = l + 1 # local "l" referenced on the right before definition ... return l ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in f UnboundLocalError: l >>> > This was much more confusing to me than a simple NameError, which is > what python 1.5 throws for the same mistake. Perhaps I'm biased, > though. Sounds more like it's simply not exactly what you were used to before . From kirill_simonov at mail.ru Fri Jul 14 02:16:49 2000 From: kirill_simonov at mail.ru (Kirill Simonov) Date: Fri, 14 Jul 2000 09:16:49 +0300 Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: ; from hzhu@localhost.localdomain on Thu, Jul 13, 2000 at 09:23:28PM +0000 References: <396E160D.272C0C34@roguewave.com> Message-ID: <20000714091649.A932@xyz.donetsk.ua> On Thu, Jul 13, 2000 at 09:23:28PM +0000, Huaiyu Zhu wrote: > Doesn't this look like the other p language or lisp? Well, my original post > missed two parentheses and two matrixmultiply's and nobody even noticed it. > If one cannot even write X\y in one line, think about how to write a typical > formula like > > B = inv(A) - A\U/(C+V/A*U)*V/A You can use '%' for right division. It has the same precedence as '/', and remainder operator doesn't occur too often in linear algebra. And don't forget about '~', '|', '^', and '&'. -- Kirill From aahz at netcom.com Fri Jul 7 11:56:09 2000 From: aahz at netcom.com (Aahz Maruch) Date: 7 Jul 2000 15:56:09 GMT Subject: Comparing 2 class types References: Message-ID: <8k4uip$v0i$1@slb6.atl.mindspring.net> In article , Arint? wrote: > >How can you know if a 2 variables are different instances of the same class? >x = someclass() >y= someclass() >I tried is, type, and type(x) is someclass, but none seem to work unless I >did it wrong. In addition to Jepler and Jeremy's responses, you need to also use "is" to find out whether it's a *different* instance of the same class: class foo: pass a = foo() b = foo() c = a print a is b print a is c -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From alex at magenta.com.bbs Mon Jul 17 18:20:03 2000 From: alex at magenta.com.bbs (alex at magenta.com.bbs) Date: 17 Jul 2000 22:20:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRRJ3$k0A@openbazaar.net> "Kevin Jacobs" wrote in message news:8kvocr$5mq$1 at eeyore.INS.CWRU.Edu... [snip] > Silly idea 1: > > Until add-on Python grammar modules are available, what about a PyAlgebra > evaluator module. For a precedent, see regular expressions. The > difference is that linear-algebra syntax can be made too Python-like for > some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() [snip] > Feel free to chime in! Seems to me we could do better (in terms of concision) along the general idea of KJSI1. As PyAlgebra is basically just parsing arbitrary syntax into (presumably) some suitable Python function-like object, what it returns from parsing a string could well have free variables just as well as bound ones. Free variables (to be bound at evaluation-time either by name or positionally) might be the syntactic default, with some special marker for parsing-time-bound variables. Or maybe the difference need not be know at parse-time. And I think this should be an expression-evaluator, only -- no assignment -- dunno, it seems smoother to me... sort of: from PyAlgebra import parse expr = parse(r'(Left .* Right)\Divisor') Result = expr(Left=X, Right=Y, Divisor=Z) being equivalent to something like: Result = X.dotProduct(Y).rightDiv(Z) Is there anything that stands in the way of implementing this sort of thing right now? Is it much of an improvement? Would smoother integrated syntax sugar such as Result = (X .* Y) \ Z be perceived as hugely better than Result = whatever(r'(X .* Y) \ Z') ??? I dunno -- I perceive no loss by having RE isolated in such a way, rather than merged into the language's syntax as in Perl; indeed, I personally perceive it as an advantage, for all that RE's are something I use SO frequently. But then, I'm not the target-audience for this sort of thing, I guess. So I can hardly judge how that target-audience would react. Alex From m.faassen at vet.uu.nl Sat Jul 29 13:25:32 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 17:25:32 GMT Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> <39808e81.145010138@news.telus.net> Message-ID: <8lv42c$ah0$1@newshost.accu.uu.nl> Bernhard Herzog wrote: [snip] > I think we can reconcile both viewpoints, namely "new operators violate > python philosophy" vs. "new operators are useful", by introducing just > one new operator. This new operator guesses what the progammer wanted > and is used like this: > A ;;>> B > This new operator is pronounced "wink-wink-nudge-nudge" or > "do-whaddaye-mean-do-whaddaye-mean" (although this might be a tad too > Perlish). I think the 'grok' statement (considered for Python 3000) is much more Pythonic: if cant_figure_it_out_anymore: grok: well fix it else: grok: also make it run faster and so on. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Wolfgang.Strobl at gmd.de Mon Jul 17 07:36:01 2000 From: Wolfgang.Strobl at gmd.de (Wolfgang Strobl) Date: Mon, 17 Jul 2000 13:36:01 +0200 Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: Norbert.Klamann at pobox.com wrote: >Hello all, >working with the new Build 132 of Pythonwin we have a minor problem. >German Umlauts are not handled properly in the editor windows. >They are shown as boxes, some of them seem to be dead keys. And a major problem, the ^-key kills build 132 immediately, when using the German keyboard layout. -- o ( Wolfgang.Strobl at gmd.de (+49 2241) 14-2394 /\ * GMD Forschungszentrum Informationstechnik GmbH _`\ `_<=== Schloss Birlinghoven, | #include __(_)/_(_)___.-._ D-53754 Sankt Augustin, Germany | From aa8vb at yahoo.com Thu Jul 6 08:38:44 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 06 Jul 2000 08:38:44 -0400 Subject: Nth digit of PI In-Reply-To: <8jvni0$amr$1@slb3.atl.mindspring.net>; from dalke@acm.org on Wed, Jul 05, 2000 at 10:29:28AM -0600 References: <8hogt2$57t$1@nnrp1.deja.com> <8houlu$j9s$1@nntp.itservices.ubc.ca> <394889C3.1ED5@esatclear.ie> <20000705071827.A1015156@vislab.epa.gov> <8jvni0$amr$1@slb3.atl.mindspring.net> Message-ID: <20000706083844.A1121226@vislab.epa.gov> Andrew Dalke: |I've seen the proof that e is irrational, but don't recall the details. |The sketch you outlined isn't sufficient. Consider | | sum(n=1..inf, 1/n^2) = 1 + 1/2 + 1/4 + 1/8 + ... = 2 | |For any finite N in the sum 1..N, the denominator is infinitely large, |but the infinite sum is an integer. Good point. Thanks for the correction. -- Randall Hopper aa8vb at yahoo.com From fannyy at idmail.com Mon Jul 10 12:13:17 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Mon, 10 Jul 2000 09:13:17 -0700 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: Thank Richard. Mak richard_chamberlain wrote in message news:izia5.9108$_O.150809 at news2-win.server.ntlworld.com... > Hi, > > There isn't one that I know of, however there are a few nice examples in tcl > which you could convert. Try looking at the links from > dev.ajubasolutions.com. > > Richard > > Fanny Yeung wrote in message > news:07ga5.11385$BS1.314666 at brie.direct.ca... > > Hi everybody, > > > > I am reading "Python and Tkinter Programming" and I am thinking of writing > a > > simple database application that need to show table of data ( something > > similar to grid control in VB or Jtable in Swing). I guess I can use > Canvas > > to implement that but I wonder anyone have implement this already ? If > yes, > > can I use it ? Or is there by any chance provided by Tkinter directly or > > indirectly ? > > > > Thanks > > > > Mak > > > > > > From olivierS.dagenaisP at canadaA.comM Wed Jul 26 14:34:14 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 26 Jul 2000 18:34:14 GMT Subject: newbie q: pythonwin editor References: <8ln2gf$ouq$1@nnrp1.deja.com> Message-ID: Make sure you have build 132, as it has the biggest set of features and works pretty nicely for me. Try this: View/Options/Tabs and Whitespace Set TabSize and IndentSize to the same thing (3 or 4), and preferably select "Keep tabs". You may also want to turn on "Tab-Timmy" -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Jonathan" wrote in message news:8ln2gf$ouq$1 at nnrp1.deja.com... > Hi, i have just installed pythonwin(as i plan to do most of my > programming on windows). I notice that on the interactive screen you > can change the tab size(e.g. from 8 to 4) and it will automatically add > tabs for you. However, when i try to create a new python script, the > text editor that pops out does not add tabs automatically. I couldn't > found any solution from its help system; does anyone knows how > to 'toggle' the feature on? > > Or do you recommend other text editor that is more suitable for coding > python? I know there's a webpage somewhere that lists out the various > text editors available, but i would like to know your opinion(based on > your experience). TIA. > > regards, > jonathan > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From johann at physics.berkeley.edu Fri Jul 14 11:32:10 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 14 Jul 2000 08:32:10 -0700 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: Peter Timaratz writes: > I can't think of any advantages to a case sensitive language. Python is a > very well-designed language though, so I imagine there is a good reason that > it is case sensitive. So what are the advantages of a case sensitive > language? The most obvious is that any identifiers that look different are different. "LIsT" and "list" look different, so my "principle of least surprise" says that they should be different tokens. But this has been a large debate recently, with opinions all over the board. -- Johann Hibschman johann at physics.berkeley.edu From sabren at manifestation.com Fri Jul 28 09:28:53 2000 From: sabren at manifestation.com (Michal Wallace) Date: Fri, 28 Jul 2000 09:28:53 -0400 (EDT) Subject: bug in M2Crypto.urllib2 .. Message-ID: Hey all, I've been using the excellent M2Crypto package for its HTTPS support, and I've discovered a small bug that I'm trying to track down. When I hit my own HTTPS pages, everything works just fine. But when I send a request to another particular server, I'm unable to read from the url, even though data IS being sent. Here's my code: ####################### import M2Crypto.urllib2 import urllib url = "https://secure.authorize.net/gateway/transact.dll" page = M2Crypto.urllib2.urlopen(url) print page.headers print "-" * 50 while 1: line = page.readline() if not line: break print line print "-" * 50 ###################### Which produces: Server: Microsoft-IIS/4.0 Date: Fri, 28 Jul 2000 13:17:48 GMT Content-Type: text/html Content-Length: 42 Content: -------------------------------------------------- -------------------------------------------------- If I try page.read(), that doesn't work either... However, if I step through with the debugger, I see: "Invalid Merchant Login or Account Inactive" .. 42 characters, which is what I want. To prove it, I added the following debug code to M2Crypto.httpslib: def getreply(self): rep = httplib.HTTP.getreply(self) while 1: line = self.file.readline() print "::", line if not line: break return rep and now I get: :: Invalid Merchant Login or Account Inactive :: Server: Microsoft-IIS/4.0 Date: Fri, 28 Jul 2000 13:26:20 GMT Content-Type: text/html Content-Length: 42 Content: -------------------------------------------------- -------------------------------------------------- I've been at this for a couple hours now, and my brain is fried, so maybe I'm missing something obvious here.. I'm going to try again in a little while to narrow it down some more, but first I thought I'd ask if anyone else had run into this problem and had a workaround or a patch...? Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From yemartin at garage.co.jp Mon Jul 31 02:42:07 2000 From: yemartin at garage.co.jp (Yves-Eric Martin) Date: Mon, 31 Jul 2000 15:42:07 +0900 Subject: Missing feature in urllib? (Getting HTTP reply code) Message-ID: <39851FBF3B.60DAYEMARTIN@smtp.garage.co.jp> Hello everyone, I am now using urllib to get some data from a HTTP server, say: import urllib f = urllib.urlopen('http://www.nowhere.com/stuff') readData = f.read() Now my problem is that wether "stuff" exists or not on the server, I still get a readData, which can be either the actual stuff, or an error message "404 Not found"... Because different servers can return different error messages (or also because the actual data may be a 404 error message, who knows...), I cannot rely on the data itself to decide wether to accept my readData or to discard it: I must use the HTTP reply code to discriminate between actual data and error messages. The problem is: I looked through the urllib documentation, checked the f.headers, browsed my archives of this mailing list... I still cannot figure out where to get this HTTP reply code... Is there indeed no way to get it with urllib? Maybe there is a good reason for that (explanations welcome), but it seems like a *big* limitation to me... I guess I'll have to do with httplib for now. Help/explanation-greatly-appreciated'ly yours. -- Yves-Eric Martin Digital Garage Inc. yemartin at garage.co.jp From grey at despair.rpglink.com Sat Jul 29 22:35:06 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sun, 30 Jul 2000 02:35:06 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8lvslc0mn8@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 02:22:31 +0200, Alex Martelli wrote: >And of course None can also be converted, it's just not converted >by a plain int(x). But it just takes an int(x or 7) to fix that, >for example (if one wants None to be converted to 7...:-). It is my understand that in an int(None or 0) what is happening is that the None fails, the or kicks in and we're really int()ing an integer in the first place, not actually converting the None. >Losing accumulated logs, and/or logging false data, would be utter >disasters. You're speaking in absolute terms on something which is best determined by the end user, not the language. To me, for a lot of the logs I process, no, it isn't a disaster. It isn't even a minor annoyance. It is just a speck of dust on a rather large desk that I couldn't care less about. Having the logs processing puke on me, or any other of dozens of applications I can think of, because of a inconsiquential burp in the data is the real annoyance. >bug is clearly the priority; if subtly-false data were being logged >instead, Uhm, logs processing process logs for one of a variety of uses. IE, the data has already been logged, how can it be falsely logged again? >Why would you need to keep track of all things in the former >paragraph? Just be explicit about what is to be done for each >of the cases it can be, and you're all set. Except now you need to do tons of conversion at different levels depending on what you do with the data. You either type it up front and have it fail later, or type it later dozens of times. Neither is appealing to me. >Furthermore, I keep pointing out that, if you call the groups method >of the match object, what Python returns for non-matching groups IS >UP TO YOU: it will return the argument you pass to groups, None if >you choose to pass no argument. So, *what* is supposed to be 'sad'?! I don't see where I can tell it to pass something other than None on a match. The docs I read, (not here) state that it /will/ return None on a no-match, not that it /can/ and that you can override it. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From alex at magenta.com Mon Jul 17 17:17:32 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 17 Jul 2000 23:17:32 +0200 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> Message-ID: <8kvti101p79@news1.newsguy.com> "Kevin Jacobs" wrote in message news:8kvocr$5mq$1 at eeyore.INS.CWRU.Edu... [snip] > Silly idea 1: > > Until add-on Python grammar modules are available, what about a PyAlgebra > evaluator module. For a precedent, see regular expressions. The > difference is that linear-algebra syntax can be made too Python-like for > some tastes. > > e.g.: > > import PyAlgebra > > PyAlgebra.run(r'A = (A .* B)\C') > e = PyAlgebra(r"D = A'*B") > e.run() # or e() [snip] > Feel free to chime in! Seems to me we could do better (in terms of concision) along the general idea of KJSI1. As PyAlgebra is basically just parsing arbitrary syntax into (presumably) some suitable Python function-like object, what it returns from parsing a string could well have free variables just as well as bound ones. Free variables (to be bound at evaluation-time either by name or positionally) might be the syntactic default, with some special marker for parsing-time-bound variables. Or maybe the difference need not be know at parse-time. And I think this should be an expression-evaluator, only -- no assignment -- dunno, it seems smoother to me... sort of: from PyAlgebra import parse expr = parse(r'(Left .* Right)\Divisor') Result = expr(Left=X, Right=Y, Divisor=Z) being equivalent to something like: Result = X.dotProduct(Y).rightDiv(Z) Is there anything that stands in the way of implementing this sort of thing right now? Is it much of an improvement? Would smoother integrated syntax sugar such as Result = (X .* Y) \ Z be perceived as hugely better than Result = whatever(r'(X .* Y) \ Z') ??? I dunno -- I perceive no loss by having RE isolated in such a way, rather than merged into the language's syntax as in Perl; indeed, I personally perceive it as an advantage, for all that RE's are something I use SO frequently. But then, I'm not the target-audience for this sort of thing, I guess. So I can hardly judge how that target-audience would react. Alex From nhv at cape.com Wed Jul 5 10:38:53 2000 From: nhv at cape.com (Norman Vine) Date: Wed, 5 Jul 2000 10:38:53 -0400 Subject: "Write to a file" question please? References: Message-ID: <8jvh9i$del$1@newsie2.cent.net> > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() > > The code above gives the error. > > Traceback (innermost last): > File "ttest.py", line 5, in ? > OUT.write("Number =", number) > TypeError: read-only buffer, tuple > > OUT.write("Hello World") > > Works but a number or variable of a number does not. > > I have been reading documents on Python to no avail this time. > I am using Win98 with the latest python for this OS. > Try OUT.write("Number=%d"%(number)) see Python\Doc\tut\formatting.html Norman From thomas at xs4all.net Tue Jul 18 02:32:47 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 18 Jul 2000 08:32:47 +0200 Subject: nis module error In-Reply-To: <39736BCB.626BD669@hpbs1711.boi.hp.com>; from jhunt@hpinst1.boi.hp.com on Mon, Jul 17, 2000 at 02:25:47PM -0600 References: <39736BCB.626BD669@hpbs1711.boi.hp.com> Message-ID: <20000718083247.V7340@xs4all.nl> On Mon, Jul 17, 2000 at 02:25:47PM -0600, Jacob Hunt wrote: > I am new to python and want to use the nis module. When I import the > module I get the error: > Traceback (innermost last): > File "", line 1, in ? > ImportError: /usr/lib/python1.5/lib-dynload/nismodule.so: undefined > symbol: yperr_string > what does this mean? How can I correct the problem or is there a way > around it. > I am using python 1.5.2 on x86 SuSE 6.4. The error means the nismodule tries to use a symbol 'yperr_string', which could be a function or a global variable, and it's listed as being 'external', but it can't find the module where that symbol should live. Try using 'ldd nismodule.so', it should give something like this: libnsl.so.1 => /lib/libnsl.so.1 (0x40008000) libc.so.6 => /lib/libc.so.6 (0x4001f000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2aaaa000) You need to include the 'nsl' library, libnsl.so.*, in order for NIS to work. This should be enabled by default, in the Modules/Setup file, but maybe I'm mistaken, or it got removed somehow. Or perhaps SuSE places the library in a strange spot, and you need to add that spot to /etc/ld.so.conf -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mskott at image.dk Sun Jul 16 11:11:03 2000 From: mskott at image.dk (Martin Skøtt) Date: Sun, 16 Jul 2000 15:11:03 GMT Subject: Imports in classes?? Message-ID: Hi Im currently writing a database applikation using Python and PostgreSQL. Because I need both a GUI and a web interface i have chosen to divide the program in three classes (and files): one containing my database queryes and one for each interface type. But where would be the right place to import my database connection module (pygresql)? In each interface file or in the query file? I guess both solutions would would work, but what would be the "right thing"? -- Martin Sk?tt mskott at image.dk Believe nothing no matter where you read it or who has said it, not even if I have said it, unless it agrees with your own reason and your own common sense. --Buddha From root at rainerdeyke.com Wed Jul 26 02:37:59 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 26 Jul 2000 06:37:59 GMT Subject: Python is wierd! References: Message-ID: "Christian Tanzer" wrote in message news:m13HJaf-000wcDC at swing.co.at... >"Rainer Deyke" wrote: >> Static variables and methods are a mess anyway. In Python, there is no >> need for them - just place the variables and functions outside the >> class. > >That's a strong statement. But it is not true. > >If you write code using classes as first-class objects, class >variables and methods can be very useful. If you need an object that acts like a class with added features, you can write a wrapper around the class. class class_with_extra: def __init__(self, it, **extras): self.__dict__.update(extras) self.it = it def __getattr__(self, name): return getattr(self.it, name) -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From drew.csillag at starmedia.net Mon Jul 24 20:15:36 2000 From: drew.csillag at starmedia.net (Drew Csillag) Date: Mon, 24 Jul 2000 20:15:36 -0400 Subject: f.write(chr(10)) ? In-Reply-To: <8F7BD871Fseed7@212.120.66.201>; from ingoogni@CUT.THIS.OUT.home.nl on Mon, Jul 24, 2000 at 06:32:05PM +0000 References: <8F7BD871Fseed7@212.120.66.201> Message-ID: <20000724201536.C4472@naxos.skunk.org> On Mon, Jul 24, 2000 at 06:32:05PM +0000, ingo wrote: > Hi all, > I'm just beginning with programming and Python. > Writing a file using this: > > >>> f=open("testpy",'wd') > > >>> f.write(chr(10)) > > >>> f.close() > > When I open the file with HexEdit I see: > 0000: 0D 0A > I expected > 0000: 0A > > What's wrong? Try instead: f=open("testpy", 'wb') # note wb not wd This opens the file in binary mode instead of the default ascii mode, which does line ending conversions (i.e. LF -> CRLF). Cheers, Drew -- print'e=%s'%(lambda x:'%s.%s'%(x[0],x[1:-1]))(str(reduce(lambda (a,b),y,z=10L**1835:(a+z/b,b*y),[[0L,1L]]+range(1,752))[0])) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From claird at starbase.neosoft.com Fri Jul 28 09:25:08 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jul 2000 08:25:08 -0500 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> Message-ID: <0181AB40BE860781.1F0198BC17D97283.0659315248148B76@lp.airnews.net> In article <8lrt2h013fp at news2.newsguy.com>, Alex Martelli wrote: . . . >> whereas 1 + "foo" is meaningless to almost everyone except Perl coders. > >No way -- it's perfectly valid in C, too, except that there it means the >constant-string "oo". Really, truly, X my heart, I kid you not, check it >out if you don't believe me (I wouldn't blame you for disbelieving this!). > > >Alex > > > Mutably so. Your reflections on Wittgenstein prompt me to speculate that soon we'll need to assure young- sters, "well, yes, 1 + "foo" evaluates to "oo", but of course a variable assigned with, for example, p = 1 + "foo"; might, depending on implementation details, eventually end up equal to something other than "oo" without itself having been reassigned." Will they believe it? Like a time before seat belts and standardized electrical power plugs ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rurban at sbox.tu-graz.ac.at Mon Jul 3 23:52:50 2000 From: rurban at sbox.tu-graz.ac.at (Reini Urban) Date: Tue, 04 Jul 2000 03:52:50 GMT Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: <39615d75.142572338@news> jhylton at my-deja.com wrote: >I recommend looking at the Yarrow design by Kelsey, Schneier, and >Ferguson: http://www.counterpane.com/yarrow.html If it comes to critical or important data I would NEVER rely on any PRNG ("pseudo is pseudo and never truly random") instead of some inpredictable hardware noise. There were some C libs around dealing with some special PC timer chips which can be abused for exactly that. such as the linux /dev/random pseudodevice or truerand.c "Physically random numbers (very nearly uniform)" by D. P. Mitchell, AT&T. This is portable. But I know only the perl Math::TrueRandom module. -- Reini Urban http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From fiona at sitegnome.com Tue Jul 18 04:25:18 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 18 Jul 2000 08:25:18 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 18th, 2000 Message-ID: <20000718082518.5435.qmail@synop.com> Hi Guys, Below are the latest entries into http://python.faqts.com cheers, Fiona Czuczman ## Unanswered Questions ######################################## ------------------------------------------------------------- Can a class have two __init__ functions with different argument lists? http://www.faqts.com/knowledge-base/view.phtml/aid/4799 ------------------------------------------------------------- Mark Tomko ## New Entries ################################################# ------------------------------------------------------------- Searching an example on how to use configparser in python? http://www.faqts.com/knowledge-base/view.phtml/aid/4827 ------------------------------------------------------------- Fiona Czuczman Olmy assuming you have a config file called test.conf and it contains the following: [DEFAULT] name = pythontest path = /tmp/test then you should be able to use the following quickie test script: from ConfigParser import * configdict = ConfigParser() configdict.read('test.conf') print configdict.defaults().keys() print configdict.defaults()['path'] path = configdict.defaults()['path'] print path that should give you a quick idea of how to load your config file in ConfigParser's dictionary format. See the following URL for the reference documentation on what else you can do with ConfigParser: http://www.python.org/doc/current/lib/module-ConfigParser.html Pay special attention on how to handle RFC822 sections and how to handle the "%" expansions. ------------------------------------------------------------- Where can I get the source for all of the built-in methods, types, etc.? http://www.faqts.com/knowledge-base/view.phtml/aid/4828 ------------------------------------------------------------- Fiona Czuczman Alex Check out this link: http://www.python.org/download/download_source.html ------------------------------------------------------------- Working with the new Build 132 of Pythonwin the German Umlauts are not handled properly in the editor windows. How can we fix this? http://www.faqts.com/knowledge-base/view.phtml/aid/4832 ------------------------------------------------------------- Fiona Czuczman Neil Hodgson 132 defaults to using Unicode for editing Python source code and the interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and comment out the two lines under "# Enable Unicode if we can". Save the file, shut down Pythonwin and restart it and see if this fixes the problem. ------------------------------------------------------------- Tthe ^-key kills build 132 immediately, when using the German keyboard layout. How can we stop that? http://www.faqts.com/knowledge-base/view.phtml/aid/4833 ------------------------------------------------------------- Fiona Czuczman Neil Hodgson This is a known problem. It occurs inside the line key = win32ui.TranslateVirtualKey(key) found in fire_key_event in Pythonwin\pywin\scintilla\bindings.py. Mark is aware of the problem in the win32ui code, but you might want to try this short workaround while waiting for a fixed PythonWin. Just before the "if event is None:" line inside fire_key_event insert this code. if key == 220: return 1 This avoids calling win32ui.TranslateVirtualKey for the "^" key. More tests may be needed for other accent characters or other locales. ------------------------------------------------------------- Is there a way to position child widgets on a TopLevel widget using absolute coordinates instead of using pack, place or grid? http://www.faqts.com/knowledge-base/view.phtml/aid/4834 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain You can do absolute positioning with place: from Tkinter import * root=Tk() Label(root,text="He's not the messiah,").place(x=5,y=5) Label(root,text="he's a very naughty boy.").place(x=35,y=70) root.mainloop() Not highly recommended though! ------------------------------------------------------------- Installing PyOpenGL on Linux http://www.faqts.com/knowledge-base/view.phtml/aid/4835 ------------------------------------------------------------- Fiona Czuczman Robin Humble, Stephen R. Figgins Installing PyOpenGL on Linux is not easy right now. I managed to do it, but had to alter some of the source. I was about to write up how I did it when I found Robin Humble had done the same thing, and posted it to the PyOpenGL egroup: http://wxwindows.org/pipermail/wxpython-users/2000-April/001922.html Here is the text of his post: ===================================================================== Hi, First post... These are the steps I went through to get pyOpenGL from CVS (May30) working with RedHat 6.2. I think it'd be similar for RH6.1. Some of these changes should probably go into CVS... * install python-numpy-15.3-1.i386.rpm from http://download.sourceforge.net/numpy/python-numpy-15.3-1.i386.rpm * grab pyOpenGL from CVS using the instructions on http://www.pythonpros.com/cvs.html * edit Setup.in to be all -lGL -lGLU (not MesaGL) and to be link paths of -L/usr/X11R6/bin - this'd be fine as a spec file patch... don't worry about CVS * edit src/Togl-1.5/togl.c at ~line 127 to add a 8.0.5 version choice which is the same as the 8.0.4 version - probably should be in CVS as it appears to work with tk/tcl 8.0.5 * run python BUILD.py * run python install.py -v * edit /usr/lib/tk8.0/Togl/pkgIndex.tcl to be .so not .dll - there should be an OS dependant 'pkgIndex.tcl' in the support/ directory that 'install.py' chooses depending upon whether you're running Unix or Windows. Obviously .dll makes no sense under Unix/Linux. * move /usr/lib/tk8.0/Togl/togl.so to be Togl.so - maybe if I knew what the syntax of the 'pkgIndex.tcl' file was then this wouldn't be necessary as 'togl.so' should be ok? Not sure... I also have most of the demos from www.python.de working if anyone is interested. The RawOpengl one being the exception. I couldn't find any sensible demos from the cvs version of pyOpenGL. Maybe I don't know the right place to look? Please let me know if you'd like patches for any of these things and I'll do my best to help. If the CVS gets updated then I'm happy to contribute a .spec file and create a source and binary i386 rpm (and a download site) if anyone is interested. Possibly also an Alpha/Linux binary rpm. I'm impressed by the speed and simplicity of pyOpenGL so far! About 100k+ points per frame animating smoothly and happily (software only Mesa with Athlon700/K7V/G400Max)... ===================================================================== Since reading this, I found another person who says they solved some of the MesaGL library problems by installing the Mesa 3.0 RPM from Robin Dunn's wxPython site: http://alldunn.com/wxPython/dist/others/ ## Edited Entries ############################################## ------------------------------------------------------------- How do I get IDLE to run a script on startup? http://www.faqts.com/knowledge-base/view.phtml/aid/3241 ------------------------------------------------------------- Fiona Czuczman Shae Erisson Problem: I've created a script called $IDLESTARTUP.py in the IDLE directory, and I'm running idle.pyw with the -s switch, but it doesn't appear to be working. (Running IDLE 0.5 on Win98.) Solution: $IDLESTARTUP actually means "read the value of the environment variable IDLESTARTUP" That means if you add a line in your autoexec.bat that says: SET IDLESTARTUP="C:\Program Files\Python\Tools\idle\autoidle.py" Then the -s switch will work (as long as you have a file name autoidle.py in the correct path that's a python file that is :) You can of course change the value of that variable to start with any file you prefer. For shell variables, you don't need to surround them with double quotes if there aren't any spaces in the path you're giving it. ex: SET IDLESTARTUP=C:\Python\Tools\idle\idlesetup.py that will work fine since there aren't any spaces (like "Program Files") in the directory specification. From rumjuggler at cryptarchy.org Fri Jul 21 17:55:31 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 21 Jul 2000 21:55:31 GMT Subject: zip() : how about braid() References: <8l6cbp$fgr$1@pollux.ip-plus.net> <3977C2A8.6D8F7586@my.signature> <8la8ib$8um$1@slb2.atl.mindspring.net> Message-ID: <01ihns4q4urkisti1mc02kadfohpo32mov@4ax.com> On 21 Jul 2000 19:33:31 GMT, aahz at netcom.com (Aahz Maruch) wrote: >In article <3977C2A8.6D8F7586 at my.signature>, >Greg Ewing wrote: >>"J?rgen Hermann" wrote: >>> >>> merge() is the best yet, since it's a common (programming) term with a >>> well-defined meaning. >> >>But it's a DIFFERENT meaning! >> >>merge([1,2,4,6,7,8],[3,5,9]) --> [1,2,3,4,5,6,7,8,9]) > >No, that's only when "merge" is a modifier for "sort". I would expect merge() called on n lists to return a list consisting of all its arguments concatenated. -- Barnabas T. Rumjuggler My despair has long since been ground up fine and is no more than the daily salt and pepper of my life. -- Russell Hoban, _Turtle Diary_ From cg at schlund.de Mon Jul 31 13:17:40 2000 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 31 Jul 2000 19:17:40 +0200 Subject: Dictionaries behaviour Linux vs. Windows Message-ID: <3985B4B4.8F7BD5F7@schlund.de> Hi! I have the following problem with Python 1.5.2: dict = {} dict.get("test", []).append(1) On Windows 95: dict == {"test": [1]} On Linux: dict == {} What's the difference? Regards Carsten. From francois.granger at free.fr Fri Jul 21 02:57:14 2000 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Fri, 21 Jul 2000 06:57:14 GMT Subject: Pythonwin attribute expansion References: <8l5a2g$egp$1@nnrp1.deja.com> <59Bd5.7287$4p3.52016@news-server.bigpond.net.au> <326536345498D311B3BC00105A39802A0747A7@newsintern.dspace.de> <8l79ou$shk$1@nnrp1.deja.com> Message-ID: <1ee3cps.2law471a5cb8lN@paris11-nas6-50-9.dial.proxad.net> Howard B. Golden wrote: > Note this timeline for problem resolution: > > - Problem found/message on c.l.p: 2000 July 20 0000 GMT (California) > - Solution suggested: 2000 July 20 0215 GMT (Australia) > - Solution coded: 2000 July 20 ???? GMT (Germany) > - Solution accepted: 2000 July 20 1600 GMT (California) > > (Stefan, I didn't have a message time for your reply. Could you supply > it?) >From my newsreader, it is 4 hours 12 minutes befor your last one or 13 hours 57 minutes after your original post. -- "Le plus difficile au monde est de dire en y pensant ce que tout le monde dit sans y penser." - Alain (?mile Chartier, dit), Histoire de mes pens?es - cit?e par Natacha From pinard at iro.umontreal.ca Sun Jul 9 10:38:21 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Jul 2000 10:38:21 -0400 Subject: Updated `tree' program Message-ID: Hi, gang! I updated my `tree' program (a `du' displayer) once again, and thought that some might like that I share it with you. I was not satisfied with all directory sizes being given in a single column, making difficult to visually sort them out. So I tried two things. The `-m' option is surely fun, but maybe not that useful for deep hierarchies, so I did not make it the default. The old behaviour is available with the `-p' option. -------------- next part -------------- #!/usr/bin/env python # Produce directory hierarchy with sizes, well sorted and indented. # Copyright ? 1996, 1999, 2000 Progiciels Bourbeau-Pinard inc. # Fran?ois Pinard , 1996. # Idea from Pierre Rioux , 1996-07-12. """\ Produce directory hierarchy with sizes, well sorted and indented. Usage: tree [OPTION]... PATH... -p display sizes vertically within a single prefix column -m if not -p, mirror the structure while displaying sizes -b within a directory, show biggest hierarchies first -l LEVEL disregard directories more than LEVEL levels deep -s SIZE disregard hierarchies smaller than SIZE Kb By default, sizes are printed before the name, and sort is lexicographical. Use `.' to list the current directory. """ import getopt, os, string, sys class run: biggest = 0 mirror = 0 prefix = 0 level = None size = None def main(*arguments): if not arguments: sys.stdout.write(__doc__) sys.exit(0) # Decode options. options, arguments = getopt.getopt(arguments, 'bl:mps:') for option, value in options: if option == '-b': run.biggest = 1 elif option == '-l': run.level = int(value) elif option == '-m': run.mirror = 1 elif option == '-p': run.prefix = 1 elif option == '-s': run.size = int(value) # Get the data, properly filtered. pairs = [] for line in os.popen('du %s' % string.join(arguments)).readlines(): text, path = string.split(line, '\t') size = int(text) if run.size is None or size >= run.size: split = string.split(path[:-1], '/') if run.level is None or len(split) <= run.level: pairs.append([split, size]) # Sort the information as wanted. if run.biggest: value = {} for split, size in pairs: value[tuple(split)] = -size items = [] for split, size in pairs: item = [] for counter in range(len(split)): item.append((value[tuple(split[:counter+1])], split[counter])) items.append(item) items.sort() pairs = [] for item in items: split = map(lambda((size, fragment)): fragment, item) size = -item[-1][0] pairs.append([split, size]) else: pairs.sort() # Erase unneeded fragments of vertical lines. clean(pairs) pairs.reverse() clean(pairs) pairs.reverse() # Erase leftmost white columns. skip = 0 split, size = pairs[0] while not split[skip]: skip = skip + 1 # Format size information. margin_size = 0 for pair in pairs: split, size = pair if run.prefix: pair[1] = '%d ' % size elif run.mirror: margin = '%d _/' % size items = split[skip:-1] items.reverse() for item in items: if item: margin = margin + ' |' else: margin = margin + ' ' pair[1] = margin else: split[-1] = '%d %s' % (size, split[-1]) pair[1] = '' margin_size = max(margin_size, len(pair[1])) # Produce resulting display. write = sys.stdout.write for split, margin in pairs: write(' ' * (margin_size - len(margin))) write(margin) for item in split[skip:-1]: if item: write('| ') else: write(' ') write('\\_ %s\n' % split[-1]) def clean(pairs): # The basename is always written. Intermediate directories normally # print as `|', yet None is used to inhibit the vertical line. draw = [] for split, size in pairs: while len(draw) > len(split) - 1: del draw[-1] while len(draw) < len(split) - 1: draw.append(0) draw.append(1) for counter in range(len(split) - 1): if not draw[counter]: split[counter] = None if __name__ == '__main__': apply(main, tuple(sys.argv[1:])) -------------- next part -------------- -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hamish_lawson at yahoo.co.uk Mon Jul 31 10:35:36 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Mon, 31 Jul 2000 07:35:36 -0700 Subject: How about each() instead of zip()? Message-ID: <2b384e38.2adaccde@usw-ex0107-055.remarq.com> A number of the proposals for a better name for the nascent zip() function seem to employ the notion of taking items from *each* of the constituent sequences. So I thought: how about each() itself as the name of the function? So: for x, y, z in each(a, b, c): print x, y, z Hamish Lawson ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From jeroen at valcke.com Sat Jul 15 17:29:13 2000 From: jeroen at valcke.com (Jeroen Valcke) Date: Sat, 15 Jul 2000 21:29:13 GMT Subject: automatically filling web forms? Message-ID: Hello, I was wondering since it is possible to read from webpages using the urllib in python, is it also possible to 'write' to a webpage. What I mean is, can I automatically fill webforms? -- Jeroen Valcke jeroen at valcke.com ICQ# 30116911 Home page: http://users.pandora.be/valcke/jeroen/ The best glimpse of heaven ... is on the way into hell. From ssurland at online.no Sun Jul 30 06:47:20 2000 From: ssurland at online.no (Stein Surland) Date: Sun, 30 Jul 2000 12:47:20 +0200 Subject: ftp and lowercase? References: <39832544.2E05FCFB@online.no> <9yQg5.21128$5N1.752914@newsread1.prod.itd.earthlink.net> Message-ID: <398407B8.381B029B@online.no> J P wrote: > > Have you tried sendcmd ("ls") ? I think that would work for you. > > "Stein Surland" wrote in message > news:39832544.2E05FCFB at online.no... > > I have made a small script using ftplib to retrieve a list from a ftp > > directory. It worked OK using ftp.retrlines('LIST', lines.append). > > However using it on another ftp host gives me this message: > > > > ftp.retrlines('ls', lines.append) > > File "/usr/lib/python1.5/ftplib.py", line 345, in retrlines > > conn = self.transfercmd(cmd) > > File "/usr/lib/python1.5/ftplib.py", line 285, in transfercmd > > return self.ntransfercmd(cmd)[0] > > File "/usr/lib/python1.5/ftplib.py", line 273, in ntransfercmd > > resp = self.sendcmd(cmd) > > File "/usr/lib/python1.5/ftplib.py", line 228, in sendcmd > > return self.getresp() > > File "/usr/lib/python1.5/ftplib.py", line 201, in getresp > > raise error_perm, resp > > ftplib.error_perm: 500 'LS': command not understood. > > > > The host did not take the LIST command so I changed it to LS and ls. It > > seems that the ftplib sends the list command in uppercase. How to change > > this to lowercase? I have ftp'ed to the host and it does not recognize > > LIST or LS only ls. > > Sorry, my mistake! My line in the ftp script: ftp.retrlines('LIST ', lines.append) has a space after the LIST command. It worked well on one host, but not on another. By closing it: ftp.retrlines('LIST', lines.append) it works OK. I was a bit flabbergasted by the 'command not understood' error... Stein -- Stein Surland Trying is the first step towards failure ssurland at online.no - Homer Simpson http://home.online.no/~ssurland/ From gerryq at indigo.ie Mon Jul 24 11:13:38 2000 From: gerryq at indigo.ie (Gerry Quinn) Date: Mon, 24 Jul 2000 15:13:38 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: In article <8lh588$oti$3 at news.fsu.edu>, Ronald Steedman wrote: > A full compile of a complex software package can often take 30 seconds or > more. That can be frustrating when you're trying to find and remove bugs. > You try one thing, wait 30 seconds, try another thing, wait 30 seconds... > > Imagine how an intepreter would help. Try one thing IMMEDIATELY SEE THE > RESULT... try another thing IMMEDIATELY SEE THE RESULT... then you only > compile the application when you're finished and want a faster program. If I were your boss I would make sure you had no access to an interpreter! I would even slow down your compilation by giving you an older machine ;-) Changing things at random and hoping the problem goes away is not the way to fix bugs. Gerry Quinn -- http://bindweed.com Puzzle / Strategy Games and Kaleidoscope for Windows Download evaluation versions free, no time limits New: Unique 2-player strategy game "Zen" From btang at pacific.jpl.nasa.gov Tue Jul 25 17:39:50 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Tue, 25 Jul 2000 14:39:50 -0700 Subject: python (I sent this by mistake.) References: <397E0813.640A3D21@pacific.jpl.nasa.gov> Message-ID: <397E0926.62EF0114@pacific.jpl.nasa.gov> Benyang Tang wrote: > > 1. > Learning Python (Help for Programmers) > by Mark Lutz, et al > > I learned python from this book. But it is can be hard for the very beginner. It is a good book though. > > 2. > The Quick Python Book > by Daryl D. Harms, Kenneth McDonald > I don't have this book, but I read it in bookstore. I think it is better the Lutz's book for beginners. > > The python distribution also includes a good tutorial. You can learn the very basic from there. > Sorry. I don't mean to send the above message to the newsgroup. From pj at sgi.com Thu Jul 27 22:17:55 2000 From: pj at sgi.com (Paul Jackson) Date: 28 Jul 2000 02:17:55 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <8losor$4bk$1@nnrp1.deja.com> <8lpand0gbg@news1.newsguy.com> Message-ID: <8lqqgj$a2tvs$1@fido.engr.sgi.com> Alex wrote: |> People using Perl for web-related tasks are really legions ... Just an anecdote to back this up: As I was leaving the Main Auditorium from a speech by Bill Joy last year, at O'Reilly's Open Source Conference in Monterey, California, to go to the Python break-out session, I noticed that perhaps 900 of the 1000 people (wild estimates) were staying in their seats. I got worried that I had read my schedule wrong, and that there was another general session next. Reading carefully, I found that: no - the Perl break-out session was in the Main Auditorium. -- -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From mwh21 at cam.ac.uk.bbs Tue Jul 18 02:20:04 2000 From: mwh21 at cam.ac.uk.bbs (mwh21 at cam.ac.uk.bbs) Date: 18 Jul 2000 06:20:04 GMT Subject: Python equivalent of CPAN in Perl Message-ID: <3bRdh4$mXg@openbazaar.net> Robin Becker writes: > Unfortunately not true. A large share of the Python market (on win32) > have no compilers and probably wouldn't/couldn't use one even if it were > present. I doubt the extension builders will always want to include > .pyds for Python15.dll Python20.dll etc etc. But distutils will make it much easier for someone else to provide the binaries... Cheers, M. -- After a heavy night, I travelled on, my face toward home - the comma being by no means guaranteed. -- paraphrased from cam.misc From tjg at exceptionalminds.com Mon Jul 31 12:13:54 2000 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 31 Jul 2000 09:13:54 -0700 Subject: telnetlib In-Reply-To: ; from guido@beopen.com on Mon, Jul 31, 2000 at 03:17:10PM +0000 References: <20000729152800.B1899@reepicheep.avalongroup.net> Message-ID: <20000731091354.A1319@reepicheep.avalongroup.net> On Mon, Jul 31, 2000 at 03:17:10PM +0000, Guido van Rossum wrote: > Timothy Grant writes: > > > Everything works great until I enter the Terminal type. It appears that the > > telnet session stops receiving at that point. As you can see from the > > Traceback I receive the echo of from my write, but then don't receive the > > next prompt. > > > > I'm guessing it has something to do with either changing the terminal type > > on telnetlib, or a timing issue, but I'm stumped at the moment. > > Could you post a transcript of what the session looks like when you do > it manually??? > > A random "poke-and-hope" suggestion: perhaps you could use \r instead > of \n in input??? OK, now I'm cautiously optimistic. Things look like they are working correctly, though I still have a ways to go before I am convinced of the fact. This causes me to have a question. As I have been working through this problem I used a debug level of 255 and interact() to see what was going on. Using interact, the Enter key on my computer sends a \012. Using \n sends the same thing. interact() would die in the same spot as my script did, so is there something weird going on with this particular terminal? -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com Red Hat Certified Engineer (503) 246-3630 Avalon Technology Group, Inc. fax (503) 246-3124 >>>>>>>>>>>>Linux...Because crashing isn't normal<<<<<<<<<<<<< From tim_one at email.msn.com Fri Jul 7 14:54:14 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 7 Jul 2000 14:54:14 -0400 Subject: Splitting c.l.py... In-Reply-To: <39661DE1.A409330C@roguewave.com> Message-ID: [Bjorn Pettersen] > ... > *) Is there a forum for developers? This list seems more for > users isn't it ? [Andrew Kuchling] > It is now, because most of the core developers lack the time to keep > up with python-list. Still, starting more core discussions may lure > some of them back. Since I work for PythonLabs now, I guess that makes me a "core developer" by definition . Can't speak for me mates at Luxurious PythonLabs World Headquarters, but I'd like to apologize for my own lack of participation on c.l.py over the past several months! The personal and professional demands of closing down one job, starting another, and moving to a new state have just been crushing. Still are, alas. And Guido got socked at least as hard by the combo of getting married and trying to disentangle all the webs binding Python to CNRI so that we can be *effective* at BeOpen. At least his marriage has worked out so far . When things settle down, at least I intend to resume harassing c.l.py. And there's already a great deal of development discussion on Python-Dev that *should* be on c.l.py. if-you-can't-find-what-you-want-on-one-newsgroup-it's-not-likely-you'll- be-twice-as-successful-with-two-ly y'rs - tim From greg at perceval.be.bbs Fri Jul 14 06:10:02 2000 From: greg at perceval.be.bbs (greg at perceval.be.bbs) Date: 14 Jul 2000 10:10:02 GMT Subject: getpid Usage Message-ID: <3bOdgR$oOM@openbazaar.net> In reply to the message of david at tumbleweed.com sent on Jul 13 (see below) : You should have a look at the os.fork() function which is python "translation" of the fork system call (availability Unix). It lets you create a new process (a child process) from the current one (called the parent process). The child process execute the same than the parent process. Thus, you have two processes, executing the same code. The fork() function return 0 in the child process and the id of the new created process for the parent process. See the following example: import os i= os.fork() # Create the new process if i != 0: # If i != 0, we are in the parent process print 'Forked process as the pid : ', i else: # We are in the child process os.system('ls -la') hope-I-have-been-clear-enoughly-yours, Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Thu, 13 Jul 2000 david at tumbleweed.com wrote: > Date: Thu, 13 Jul 2000 17:02:20 -0000 > From: david at tumbleweed.com > To: python-list at cwi.nl > Subject: getpid Usage > > Is there some convenient way of getting os.getpid to return the PID of > a given executable? What I want to do is start a process and know it's > PID. When I do the following I get the PID of the python executable. > > os.system("path") > os.getpid() > > Alternatively, as a hack, I am doing: > os.system(self.m_server_start_exe) > for line in os.popen("ps -ef | grep -i IMEController | awk '{ if (NR > > 1) { print $2 }}'").readlines(): > pid = line[:-1] > > I would rather just path in an executable name/pathname and have it > return this process' pid. Is there an updated version of os.getpid I > could use to do this. If not, is there a better solution that is not > shell dependent? > > Thanks, > David > > > > -- > http://www.python.org/mailman/listinfo/python-list > > From neilh at scintilla.org Wed Jul 26 09:03:31 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 26 Jul 2000 13:03:31 GMT Subject: PythonWin/Scintilla aggressive folding... References: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> <1csf5.40036$Gh.442627@news20.bellglobal.com> <7mwf5.12307$4p3.95451@news-server.bigpond.net.au> <397EAE32.8A76A18A@letterror.com> Message-ID: > still-hope-to-find-time-some-day-to-port-Scintilla-to-my-platform-ly y'rs -- just That is certainly on the agenda. The Mac hasn't really had a decent binary visual object standard since the demise of OpenDoc. Controls are too low level for something as complex as Scintilla. I'm not very current on MacOS development but I imagine that OS X will have something sensible for this. There is wxStyledTextControl, a Scintilla based class for wxWindows, which could be made to work on MacOS. Neil From robin at illusionsexeculink.com Fri Jul 21 09:11:11 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Fri, 21 Jul 2000 09:11:11 -0400 Subject: Waiting for Threads to Stop [silly version] References: <8l705c$uop$1@nntp9.atl.mindspring.net> Message-ID: Personally, I'm waiting for this "zip vs. braid" thread to stop. Any module to help me there? ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "I choked on my words but just couldn't spit. It will affect a lot of physics -- it should have fallen from a bridge, but..." an official said Wednesday. He was 74. From mbel44 at dial.pipex.net Tue Jul 25 09:13:48 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 25 Jul 2000 14:13:48 +0100 Subject: Python in game development? References: <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> <8li3gg$7vg$1@gaia.cdg.acriter.nl> Message-ID: cg at gaia.cdg.acriter.nl (Cees de Groot) wrote: >Michael Hudson said: >> >>Another major advantage of dynamic languages like Python (or lisp or >>...) is that you can easily poke around at the data structures at >>runtime (which is rather less tedious than stopping your debugging >>session, adding some code to dump said data structures to a file, >>recompiling, getting your program back to the state you want to debug, >>then looking at the file, trying to remember why you created it). >> >And this gets /really/ great if your code runs in a persistent VM, like >Smalltalk. ...... or like python, using ZODB http://starship.python.net/crew/amk/python/writing/zodb-zeo.html http://www.zope.org/Members/michel/HowTos/ZODB-How-To Toby Dickenson tdickenson at geminidataloggers.com From OneDay at ATime.net Sun Jul 23 07:07:44 2000 From: OneDay at ATime.net (OneDay at ATime.net) Date: Sun, 23 Jul 2000 07:07:44 EDT Subject: Newbie ?? Running hello1.py and compiling? Message-ID: <8lejm0$d3o$1@earth.superlink.net> Hello all, At Python's site I started with Example 2.1, Our First Program. I opened IDLE, Opened a new window and copied/wrote the commands and saved it as hello1.py. To run the program it says to "run the script as usual" $ python hello1.py Where do I type this, I don't know what "as usual" means. After I wrote hello1.py, I noticed a compiled version in my explorer. Which I can run from there. How did that happen? When I copied/wrote hello2.py, following the above steps, I did not get a compiled version. What did I do wrong? Thank you for your time and patience, Al From samschul at pacbell.net Wed Jul 5 12:47:29 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 16:47:29 GMT Subject: Corrected URL http://starship.python.net/crew/samschul References: <8jvg2d$8q5$1@nnrp1.deja.com> <8jvgdi$95f$1@nnrp1.deja.com> Message-ID: <8jvoqr$g18$1@nnrp1.deja.com> The corrected URL ( I'll get it right yet) http://starship.python.net/crew/samschul Sent via Deja.com http://www.deja.com/ Before you buy. From avv at quasar.ipa.nw.ru Tue Jul 25 19:51:49 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Tue, 25 Jul 2000 16:51:49 -0700 Subject: Python & AI References: Message-ID: <397E2815.A049BAF0@quasar.ipa.nw.ru> Hi, rhymes wrote: > > Do u know something on the net related to Artificial Intelligence and > Python Language?? A wrapper for the FuzzyCLIPS engine, which implements forward chaining (Rete algorithm) with fuzzy logic extensions: ftp://starship.python.net/pub/crew/avv/clips-wrapper.tgz A new version with a bit more enhanced interface is about to replace this one. Alexander From ngps at madcap.dyndns.org Mon Jul 24 10:45:55 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 24 Jul 2000 14:45:55 GMT Subject: crypto modules in python References: <397B8440.C1DD25C9@mindspringdot.com> Message-ID: <8lhkr3$com$1@violet.singnet.com.sg> According to anupam : > can someone please point me to link(s) to python modules dealing with > cryptography e.g ssleay or open ssl wrappers. i cannot find any sig > at python.org dealing specifically with cryptography, and searching > usenet at deja news wasn't very helpful either. Hi, M2Crypto at http://www.post1.com/home/ngps/m2 is a Python interface to OpenSSL's crypto, SSL and S/MIME functionality. python-crypto at egroups.com is a low-volume mailing list talking about Python and crypto. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From nolan_d at bigfoot.com Thu Jul 6 18:12:10 2000 From: nolan_d at bigfoot.com (Nolan Darilek) Date: Thu, 06 Jul 2000 17:12:10 -0500 Subject: Nonblocking input: the quest continues Message-ID: I'm continuing to try to figure out this non-blocking input thing. Yesterday I didn't want to use curses since cmd provided much of the interface that I wanted. But, after grep'ing through Python libraries, I don't feel any closer to a solution. So, I thought that it might be possible to use curses for nonblocking input only, and to ignore the additional functionality. I wrote up an ugly, but semi-functional, replacement for raw_input which may do what I want. But, I'm still encountering problems. Here is the ugly test code which I've written: #!/usr/bin/env python import curses import time input="" prompted=0 window=None def raw_input(prompt = ""): global input, prompted, window if prompted == 0: print prompt prompted = 1 ch = window.getch() if ch == -1: return None if chr(ch) == '\n': prompted = 0 r = input input = "" return r input = input+chr(ch) window = curses.initscr() window.nodelay(1) window.nooutrefresh() for x in range(0, 10000000): time.sleep(0.1) line = raw_input(">") if line is not None: print line While this does seem to except input nicely, and despite the fact that it stores all incoming input in a global variable so that my program can reconstruct the prompt when new data arrives, it still exhibits problems. First, it doesn't print the prompt string. I'm wondering if this is due to the fact that I'm mixing curses with print? Or is there some silly error which I've missed due to the fact that I've been staring at this for hours? :) And, even if this approach excepts input, how will it behave when the prompt is reconstructed and if someone wants to erase the text? Does the text need to be stuffed into an input buffer, or will the terminal nicely handle the program's request to erase text which was printed to the display? I suspect not, so I'm wondering if I'm taking the wrong approach with this? I had originally thought of trying to write to stdin, hoping to cram text back into the input buffer, but this seems to be impossible. From chrisw at nipltd.com Sat Jul 8 12:30:33 2000 From: chrisw at nipltd.com (Chris Withers) Date: Sat, 08 Jul 2000 17:30:33 +0100 Subject: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: <39675729.C9E01442@nipltd.com> Alan Daniels wrote: > >Does python support, or if not, would it be cool to have support for > >try/except/finally? > > No, but just use try/except/else instead. Why it's "else" instead of > "finally", I have no idea, but this works just fine. Example: Actually, yes it does ;-) ...but it does something different. I read the discription on page 50 of David Beazely's Python Essential Reference, but it didn't make much sense to me :S cheers, Chris From wizard at eznet.net Mon Jul 17 22:12:15 2000 From: wizard at eznet.net (David A. Frantz) Date: Mon, 17 Jul 2000 21:12:15 -0500 Subject: OT: RedHat 6.1 (was Re: newbie unimpressed...) References: <8kvp81$9q1$1@nnrp1.deja.com> <8kvqqb$8e5$1@nntp9.atl.mindspring.net> <8l047h$6ag$1@slb6.atl.mindspring.net> Message-ID: In article <8l047h$6ag$1 at slb6.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article , Grant Edwards > wrote: >>In article <8kvqqb$8e5$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >>>In article <8kvp81$9q1$1 at nnrp1.deja.com>, >>>wrote: >>>> >>>>(I'm using python 1.5.1 on Redhat 5.2) >>> >>>I strongly recommend upgrading to Python 1.5.2. The documentation is >>>much better, for starters. >> >>FWIW, RH 5.2 is getting a bit old also. I couldn't recommand >>6.[01], but 6.2 seems to be decent. > > What's wrong with 6.1? (We upgraded a few months back, mainly to get > 1.5.2, and I'd like to know if there's a serious reason we should move > to 6.2.) I don't know if you would consider this serious or not; but 6.2 as a whole is a vast improvement over 6.1. Well maybe not vast but it certainly is the best bug fix release that I've seen. The only unfortunate thing is that you have to be careful with the Kernel Updates. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> > http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 > > Q: In a lesbian relationship, who decides who gets to be the man? A: > It's two women. There is no man. That's the point. From neilh at scintilla.org Thu Jul 27 09:30:05 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 27 Jul 2000 13:30:05 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au><8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: > The fact that there are dyed in the wool M$ hating academics is surely a > reflection of M$'s past behaviour. The fact that M$ can apparently turn > these guys around so easily says a lot about what M$ is really good at > (selling and hype) and also about what the academics are poor at (real > world judgement). You are overlooking the appeal of a decent sized research grant to your average starving academic ;) Neil From cjensen at bioeng.ucsd.edu Wed Jul 5 20:13:13 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 05 Jul 2000 17:13:13 -0700 Subject: Py_Apache Vs. mod_python Message-ID: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> What is the difference between Py_Apache and mod_python? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From hzhu at localhost.localdomain.bbs Mon Jul 17 14:50:03 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 17 Jul 2000 18:50:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRLiS$lbb@openbazaar.net> On Mon, 17 Jul 2000 13:33:55 -0500, Paul Prescod wrote: > >Let me repeat a challenge I made to Huaiyu Zhu. If the only difference >between Matlab and Python is the syntax, then let's you and I make a >Matlab syntax for Python and sell it at half of Matlab's price. We could >make millions on a month's work! I thought I replied your email through email ... Ah, here it is: > > Now look at the total number of users of matlab/octave, and ask: Is python > > really so inferior that most of them wouldn't switch to python? > > I have no idea. If the primary difference between expensive matrix > packages and Python is syntax, perhaps you and I should incorporate and > exploit that market inefficiency. :) The market is efficient. Matlab does worth that much (or even more). It does take that much human labor to get to that stage, so sadly we can't get rich by following them. On the other hand, open source may beat them easily, as long as 1. we are using a better language which has more potential 2. users have incentive to contribute because it's already useful 3. there's no big hurdle beyond what's already in Numerical Recipe >My strong feeling is that people don't just use Matlab for the syntax. >And the popularity of Matlab books is probably not proportional to the >popularity of Matlab. University students are forced to buy those books. You feeling may be wrong, even if it is strong. Many students use Matlab despite their adviser's urge to use other more "conventional" software - at least in the earlier years. For all I know, the disproportionality is the other way round - most matlab users never own a matlab book. (A personal note which may not worth much: I've used matlab for ten years and don't own a matlab book. I've used python for half a year and proudly own three python books.) Huaiyu From digitig at cix.co.uk Wed Jul 5 16:29:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Wed, 5 Jul 2000 21:29 +0100 (BST) Subject: [FAQTS] Python Knowledge Base Update -- July 1st, 2000 References: <20000702031926.7937.qmail@synop.com> Message-ID: In article <20000702031926.7937.qmail at synop.com>, fiona at sitegnome.com (Fiona Czuczman) wrote: > On Windows 9x systems, you may also use the COM interface. We have > recently used PythonWin to (what else?) spam a number of recipients > over Novell GroupWise. It took very little time to work this out. Ah, that's useful -- I sometimes use Python to parse text into an Access 97 DB, and at the moment I do it via CSV's. Where do I find info on the COM interface? With that I should be able to poke it in directly. From bobby at devos.org Wed Jul 12 22:53:46 2000 From: bobby at devos.org (Bobby de Vos) Date: 12 Jul 2000 22:53:46 -0400 Subject: vCard module Message-ID: Greetings, Does anyone know of a Python module that would allow me to easily parse and format vCards? Thanks, Bobby -- Bobby "the fox" de Vos bobby at devos.org ECE - Georgia Tech http://www.devos.org/bobby From cut_me_out at hotmail.com Sat Jul 15 15:05:36 2000 From: cut_me_out at hotmail.com (Alex) Date: 15 Jul 2000 15:05:36 -0400 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> Message-ID: > Well it's exactly what I was doing once because I was a lot more > clever than the guys who said I shouldn't. And then I decided quite > suddenly that they were right. (At the end of a _long_ stretch trying > to figure out why the heck something wasn't working - of course the > answer is the object in question was very different from the object it > appeared it should be...) It can have really confusing consequences, but it's still too useful for me to abandon. If you have a class which takes a long time to instantiate (e.g., you have to load a lot of statistical data into memory,) then having a script like class C: pass if 't' not in dir(): t = C() t.__class__ = C t.experiment_with_instance() can really decrease your turn-around time when you're debugging -- you can change t's methods around behind its back without changing its data. Alex. From Jorrit.Tyberghein at uz.kuleuven.ac.be Wed Jul 19 03:05:37 2000 From: Jorrit.Tyberghein at uz.kuleuven.ac.be (Jorrit Tyberghein) Date: Wed, 19 Jul 2000 09:05:37 +0200 Subject: Python in game development? References: Message-ID: <963990339.783645@marvin> Mallor wrote in message ... >Are any of you game developers out there using Python as your game engine's >embedded scripting language? I am wondering what drove your decision to use >Python instead of other embeddable scripting languages? I'd like to hear what >your overriding concerns were, and also what they are now, having put Python to >the test. In the Open Source Crystal Space 3D engine we are working on a framework for python scripting. It is already working reasonably well but you cannot yet do everything that you'd want to do from a python script. Greetings, -- --------------------------------------------------------------------------- Jorrit Tyberghein (Jorrit.Tyberghein at uz.kuleuven.ac.be) Project Manager of Crystal Space, a free and portable 3D 6DOF portal engine. More info at: http://crystal.linuxgames.com --------------------------------------------------------------------------- From aahz at netcom.com Mon Jul 24 11:05:09 2000 From: aahz at netcom.com (Aahz Maruch) Date: 24 Jul 2000 15:05:09 GMT Subject: Class static methods References: <8lh6ri$dkl$1@nnrp1.deja.com> Message-ID: <8lhlv5$6kl$1@slb3.atl.mindspring.net> In article <8lh6ri$dkl$1 at nnrp1.deja.com>, Guillaume wrote: > >Well, now that I have class static vars, I need class static methods... >Is it possible in Python ? Not sure... Nope. You have two options: * generate an instance of the class and fake it through an instance method (deprecated) * segregate the class into its own module and use module-global functions as proxies for class static methods (preferred) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From jkraska1 at san.rr.com Sat Jul 22 23:04:13 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 23 Jul 2000 03:04:13 GMT Subject: Looping on more than one list References: <3979C6F4.B1FF1800@atlsci.com> <8ldkf7$7km$1@nntp9.atl.mindspring.net> Message-ID: <397A616E.A9549B93@san.rr.com> > Not currently. Look at all the threads about zip(), marry(), braid(), > etc. Perhaps this should be folded into the map function? Ala, lisp: (map nil #'(lambda (i j) ...) list-one list-two) C/ From alex at magenta.com Sun Jul 30 10:37:40 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 16:37:40 +0200 Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com><8lpt57$hsu$2@newshost.accu.uu.nl><8lq5q6$fn4$1@newshost.accu.uu.nl><8lspdu$m7e$1@newshost.accu.uu.nl><20000728192952.A32288@exeter.exeter.org> <3h7la4bz5j.fsf@angband.org> Message-ID: <8m1f0572n4o@news2.newsguy.com> "Eric Lorenzo" wrote in message news:3h7la4bz5j.fsf at angband.org... [snip] > def parse_die(s): > try: > g = parse_die_re.match(s).groups() > except AttributeError: > raise ValueError('Not a valid die expression') > return int(g[0]), int(g[1]), int(g[2] or 0) I think it may be slightly preferable to express this as: try: g = parse_die_re.match(s).groups(0) except AttributeError: raise ValueError('Not a valid die expression') return map(int, g) Alex From paul at prescod.net Sat Jul 15 00:00:14 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 23:00:14 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <396F1914.DBE530CA@prescod.net> Message-ID: <396FE1CE.FE9967A8@prescod.net> John Lull wrote: > > ... > > The problem is that Python provides no way for an add-on module to > define new operators. But that's not really an accident. There are languages that allow you to define new operators. REBOL is the most flexible example. Python emphasizes syntactic *simplicity*. > Unfortunately, the current lack of appropriate notation makes these > problems very difficult to code clearly. Every domain of computing would be enhanced with special notation. Text processing, XML, COM, databases, Web programming etc. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From hzhu at knowledgetrack.com Mon Jul 24 17:44:04 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Mon, 24 Jul 2000 21:44:04 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: On 24 Jul 2000 12:47:32 +0200, Konrad Hinsen wrote: >> >> 1. Is it necessary to distiguish inner and outer? With Greg's indexing >> rules these are essentially the same. Six would be enough. > >What are "Greg's indexing rules"? Inner and outer product are entirely >different operations in my mind, although in principle the inner >product can be thought of as an outer product followed by a summation. >I think that implementation issues also call for separate operators; >using indexing tricks might be difficult for sparse matrices, for >example. Quote from Gregory Lielens ---------------------- maybe something as (I adopt (*) for matrix product, may the parser do the same!) a = b.i(1,2,-1,-2) (*) c.i(4,-2,3,-1) for a_ijkl = b_ijmn c_lnkm ------------------------------------- End quote Is this enough for both outer product and inner product (which is outer and contract)? Outer product would be like a = b.i(1,2,3,4) (*) c.i(5,6,7,8) >They still look acceptable to me, but perhaps [*] etc. is better in >the end. Indexing expressions are never as long as expressions in >parentheses. Yes, [*] looks much better. Huaiyu From root at 127.0.0.1 Thu Jul 27 15:35:46 2000 From: root at 127.0.0.1 (David) Date: Thu, 27 Jul 2000 19:35:46 GMT Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> Message-ID: <39808e81.145010138@news.telus.net> On Thu, 27 Jul 2000 10:44:08 +1000, Steve Purcell wrote: >Shae Erisson wrote: >> And I'm opposed to it because it seems like sugar to me. I've always >> loved Python's simplicity, and I hope it stays that way. >> Adding new operators and new syntax will make Python harder to read, and >> harder to learn. I don't want that. > >Yay! Python luddites unite! Hear, hear. Hell, yeah, I'll use the new operators and syntax! I freely admit it: I'm lazy, I like shortcuts, I'll take the easy way out. That doesn't mean I think it's a good idea for Python to offer them. IMO, they're detrimental, and should not be offered. From hzhu at localhost.localdomain Thu Jul 13 23:40:19 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 14 Jul 2000 03:40:19 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396E7791.EE9D36FF@prescod.net> Message-ID: On Thu, 13 Jul 2000 21:14:41 -0500, Paul Prescod wrote: >> >> Point 1. We _can_ assign a universal meaning to dot operators, as >> "componentwise operators". For example > >There is another proposal for allowing these types of operatoins: > >> [1, 2] .+ [3, 4] # [4, 6] > >[x+y; for x in [1,2], y in [3,4]] How about [x+y: x in [1,2], y in [3,4]]? But this has nothing to do with matrices, because one of their main virtue is that you do not need to consider the indices. How would you possibly write A*B in this notation anyway? Just a random line from my code, like s = tanh(A0*x+b0); y = A1*s + b1; would take a dozen lines to do in the above way. >Note that this feature is more general than a fixed list of operators: That might be true, but mathematicians have spent hundreds of years to distill the concepts to a very small list of operators that are extremely useful. Would you say that add(a,b) and mul(a,b) are more general type of expressions than some special symbols like a+b and a*b? Writing in asembly may be even more general than any high level language. Learn some linear algebra and you'll find that you could do some incredible things with it. It is not difficult (if the syntax is simple). For starters, just download the current version of MatPy from http://MatPy.sourceforge.net/, untar, and type make install, and see the graphics flow across your screen. Huaiyu From adetalabi at clara.co.uk Tue Jul 4 07:26:23 2000 From: adetalabi at clara.co.uk (Ade Talabi) Date: Tue, 04 Jul 2000 12:26:23 +0100 Subject: Socket problem References: Message-ID: <3961C9DF.6AFF4D3D@clara.co.uk> Manuel Gutierrez Algaba wrote: > > I'm doing a game for my University. It's divided into 3 parts > ( AI (clips), core(python), GUI(python)) communicated by sockets. > I've been running it in Red Hat 4.2 happily. > Now, I'm switching to Red Hat 6.0 and the core when > trying to access to port 50008 it says: > > ocket.error: (99, 'Cannot assign requested address') > Exception exceptions.AttributeError: 'conn' in > > ignored > Exception exceptions.AttributeError: > 'delete non-existing instance attribute' in > ignored > > Where is the fault ? > > Thanks. > > -- > MGA check that /etc/services has got the port set -- We see, whatever we want to see, whether visible or not - AT. June 2000. From stianh at ifi.uio.no Fri Jul 28 08:06:06 2000 From: stianh at ifi.uio.no (Stian Husemoen) Date: 28 Jul 2000 12:06:06 GMT Subject: The State of Python References: Message-ID: Tim Peters wrote: >life-in-limboland-ly y'rs - tim I bow to the timbot for it's skills to dodge my puny troll-like flamebait postings But another question.. You say the new license will be GPL compatible. What does this mean exactly? the-AI-serves-you-well-ly y'rs -- Stian Husemoen From piet at cs.uu.nl Mon Jul 3 10:52:47 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 03 Jul 2000 16:52:47 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> Message-ID: >>>>> "Alex Martelli" (AM) writes: AM> Don Tuttle wrote in message AM> news:qJ165.8938$nZ5.153196 at typhoon.southeast.rr.com... >> Consider this a heads up NOT a promotion!! AM> Why would the Python community care about a Microsoft-proprietary AM> quasi-Java-clone...? It is not proprietary. They will put the language definition in the public domain. Maybe not the implementation. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From spam at spam.com Sun Jul 9 17:10:44 2000 From: spam at spam.com (Penfold) Date: Sun, 9 Jul 2000 22:10:44 +0100 Subject: Pythonwin 1.5.2 References: <8kaij5$c9s$1@supernews.com> <8kaolt$flc$1@supernews.com> Message-ID: <1S5a5.1617$6W.258543@nnrp4.clara.net> Dale Strickland-Clark wrote in message news:8kaolt$flc$1 at supernews.com... > TAB! Thanks > > Oh for standards in keyboard shortcuts. What's wrong with ctrl-enter like > Visual Studio? > > Dale Strickland-Clark (i) Visual Studio defined the standard as of when ? (ii) Microsofts VBA editors use Tab :-), and so you might find Visual Studio accepts it too ... Oh for standard signatures D From bvdpoel at uniserve.com Sat Jul 15 19:31:33 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 15 Jul 2000 16:31:33 -0700 Subject: converting tcl database file to python Message-ID: <3970F455.58A6CAD3@uniserve.com> I'd like to convert a program I have from tcl/tk to python/tkinter (I just can't read the tcl stuff anymore!). The biggest initial problem I have is converting the data from a tcl fromat to something python will be happy with. What I have is a database of my CD collection. The flat text file I'm using for storage is read into a tcl list. Each line looks something like: {#1 Million Sellers} {} Laurie Rock {} {Chapel of Love} {Dixie Cups} {} {} .... Tcl reads this and parses off the fields into the CDname, Comment, Label, Catagory and then takes the remainder as 4 field entries for the Title, Artist, Composer, and Timing. The 4 field groups continue to the EOL. So, 2 questions: 1. What would be a suitable python datatype to store the data? I'm thinking that I could have a dictionary with the CD name as the key and then have a bunch of lists associated with each dictionary entry. I'm also thinking that this is dumb. If I were using C I'd use a structure like this: typedef struct{ char *Title, *Artist, *Composer, *Timing; }CDITEM; typedef struct{ char *Name; char *Comment; char *Label; char *Catagory; char *CDItem[]; }CDENTRY; CDENTRY Mydata[maxtitles]; Or something like that. Any suggestions on how that would translate to a proper python idiom? Maybe I should can the idea of having in-memory data and convert this sucker to use a proper database idiom? Is there a reference/tutorial document for gdbm somewhere? 2. Any quick ideas on how to convert the tcl-style data file to something python can deal with? The initial problem is that some items in the file are {} delimited and others are simply space delimited (single words). I suppose the simpliest might be to write a tcl program to read the stuff and then rewrite it to something resembling whatever my new data format is going to be. Thanks. -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From garry at sage.att.com Mon Jul 10 14:22:12 2000 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 10 Jul 2000 18:22:12 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395E05CD.E38F642C@webamused.com> <396b3f42.316716812@nntp.interaccess.com> <8kcsu9$r9g$1@nnrp1.deja.com> Message-ID: <396A1454.1F775E0F@sage.att.com> Torgo Jr wrote: > > In article , > "Stephen Hansen" wrote: > > > If Microsoft took the > > CONCEPT of the Language, and made their /entire own language/ > > around the > > /idea/ of it, then they havn't /copied/ anything. > > They have copied the idea. No crime here, but by doing this > they ideally can't claim any kind of "innovation" (but they > will most likely do anyways). it never stopped them before. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From sholden at bellatlantic.net Wed Jul 5 08:57:52 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Wed, 05 Jul 2000 12:57:52 GMT Subject: Is there a searchable archive of c.l.py References: <8jq7l3$f1e$1@slb0.atl.mindspring.net> Message-ID: <396330BC.DB5DCD00@bellatlantic.net> Deja have "promised" to get the older archives back on line when their new face is up and running. Does anyone have any personal contacts in that organization to ask if we can have the data NOW to put a searchable archive up somewhere else? regards Steve Aahz Maruch wrote: > > In article , > Neil Hodgson wrote: > > > > Is there a sensibly searchable archive anywhere? In the future we will > >need this resource. Otherwise how will we know how we beat those nanoviruses > >back in '97? > > Well, we've got the archive: http://www.python.org/pipermail/python-list/ > > Unfortunately, it only seems to go back to March '99. Does anyone > maintain an older archive? Once we have the archive, making it > searchable is a relatively trivial task. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, > but to post the wrong information. --Aahz -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://home.cox.rr.com/sholden/ From donod at home.com Tue Jul 25 23:29:51 2000 From: donod at home.com (Donald O'Donnell) Date: Wed, 26 Jul 2000 03:29:51 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <8lldpn$n7a$1@news.dtc.hp.com> Message-ID: <397E5B61.3C0B2B9D@home.com> Don't know if it's good or bad as long as you understand how it behaves and program accordingly. The glitch is that Python treats built-in types and class instances differently, as far as argument passing. Python's class instances (objects) behave more like Perl's: class cc: pass def f(a): a.v = 42 c = cc() c.v = 1 f(c) print c.v # PRINTS 42 Don O'Donnell P.S. - I've been studying and using Python for a couple weeks now - rewriting a major main-frame app in Python. It's the greatest invention since chocolate chip cookies. It's been around for 10 years, so how come I haven't heard of it till now? Either I'm out of touch (probably), or Python needs more promoting and marketing. It happened by accident, just happened to notice David Beasley's book on a table in B&N one day, started leafing through it, and gradually realized it was the answer to my prayers. The perfect tool for porting an interactive main-frame data analysis package (needing GUI and scripting) to a wintel platform. Thank you Guido and everyone else who made my job possible and brought fun back to programming. (I love being able to get inside and play with the machinery. It's a lot like Forth in that respect.) "(Greg Weeks)" wrote: > > (Greg Weeks) (weeks at golden.dtc.hp.com) wrote: > : I prefer the old way of speaking. With the new way of speaking, both > : Python and Perl are "pass by reference", but Perl is somehow *more* so. > > If it isn't clear what I mean, here's some Perl: > > sub f > { > $_[0] = 42; > } > > $x = 1; > f($x); > print "$x\n"; # PRINTS 42 > > and the corresponding Python: > > def f(a): > a = 42 > > x = 1 > f(x) > print x # PRINTS 1 > > Good Python! Bad Perl! > > Greg From thomas at xs4all.net Sun Jul 16 15:33:27 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 16 Jul 2000 21:33:27 +0200 Subject: Top 10 Language Constructs (Phyton) In-Reply-To: ; from nobody@nowhere.nohow on Sun, Jul 16, 2000 at 06:03:14PM +0000 References: <8kmkam$m45$1@pollux.ip-plus.net> <8kpavi04id@news1.newsguy.com> <8kpt05$uj6$1@slb3.atl.mindspring.net> <8kss1j$s39$1@slb7.atl.mindspring.net> Message-ID: <20000716213327.Z7340@xs4all.nl> On Sun, Jul 16, 2000 at 06:03:14PM +0000, Grant Edwards wrote: > On 16 Jul 2000 17:40:03 GMT, Aahz Maruch wrote: > >I literally can't remember the last time I bothered visiting > >AltaVista for anything other than a quick test to see if > >they've improved their software, and I also warn other eyeballs > >away from them. > I gave up on altavista over a year ago and use google most of > the time. Back when altavista was just a demo of how big/fast > a DEC machine could be, it seemed to provide (to me) useful > info. Once it switched over to being an ad-driven > profit-center, it went into the dumpster pretty quickly. Hah! I can remember back when WWW search engines were a new and exciting thing! And more importantly, no matter what you searched for, you never got more than a few screenfulls of hits, and most of them were positive hits, too. And if it didn't, a rephrasing of the search criteria solved the problem. Compared to that, almost all searchengines nowadays are worthless. That was before Netscape arrived and made the WWW popular, though ;) Anyone remember Netscape's HTML 1.1 ? :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jasonives at hotmail.com Thu Jul 27 20:16:13 2000 From: jasonives at hotmail.com (Jason Ives) Date: Thu, 27 Jul 2000 17:16:13 -0700 Subject: Variables in strings.. References: <8lh75e+tjtl@eGroups.com> <119330503709.20000724135021@buz.ch> Message-ID: > 3) It's helpful to create two subclasses of UserDict: one I call > PartialStringSubstitution that leaves alone any extra %(variable)s tags > rather than raising a KeyError and another, NoKeyErrors, that replaces > them with empty strings rather than raising a KeyError. I can post these > if anyone wants to see them. I'd love to see these! Sounds like they would help out with some cgi development I'm doing. ~jason ives From tim.hochberg at ieee.org Wed Jul 5 19:06:17 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 05 Jul 2000 23:06:17 GMT Subject: Two Tkinter questions (long) References: Message-ID: "Grant Edwards" wrote in message news:QXO85.3118$iN5.767799 at ptah.visi.com... > In article , Aaron Ginn wrote: [SNIP] > Functions bound to events need to take an event as a parameter > (if you don't want the event, you can use lambda to discard it): > > self.filter_entry.bin('', labda event: self.do_filter()) You still needs to bind self to a default variable in order for it to be accesible inside the lambda, e.g, self.filter_entry.bin('', lambda event, self=self : self.do_filter()) (I suspect this is just a typo on Grant's part, but I figure I'd clarify it for Aaron...) -tim From gbreed at cix.compulink.co.uk Fri Jul 14 12:16:31 2000 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 14 Jul 2000 16:16:31 GMT Subject: Downside to using Python in ASP/MS IIS server side? References: <3973b7ce.945183441@news.online.no> Message-ID: <8knecv$btb$1@plutonium.compulink.co.uk> In article <3973b7ce.945183441 at news.online.no>, thomas at cintra.no (Thomas Weholt) wrote: > We`re trying to use Python as script-language instead of VBScript in a > MS IIS/MS Site Server solution. We have to access a MS SQL 7.0 > database too. Does anybody have any experience in something like this? > All we want is to get rid of VBScript. ( At least, for now ;->) > > Are there any obvios downsides to this? Will we get into trouble cuz > Python cannot access the same stuff as VBScript etc. ?? The only downside is that the documentation is all geared for VBScript. Now I've got session variables sorted out, there's nothing I can do in VBScript that I can't do in Python. There are lots of things I can do in Python that I can't do in VBScript, like connect to an SMTP server, import text from an HTTP request. All the clever stuff in ASP comes from COM, and it translates right across. Occasionally you get tuples returned when you don't expect them, but you'll get the hang of it. > > Any hints, advice or possible case-studies would be great. > > Thomas From jacobs at darwin.epbi.cwru.edu.bbs Mon Jul 17 15:50:04 2000 From: jacobs at darwin.epbi.cwru.edu.bbs (jacobs at darwin.epbi.cwru.edu.bbs) Date: 17 Jul 2000 19:50:04 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRNNU$lzZ@openbazaar.net> I've held back a few times from contributing my 0.02 cents, but here goes: 1) Python is a nifty language that allows its programmers to revel in the richness of its dynamic object model. 2) Such models are always subject to abuse and can result in horrible and unmaintainable hacks. These are frequently disguised as nifty syntactic 'features'. 3) Such attempts are bound to lead to terminal feeping-creaturism if not carefully kept out of the core language. Ok, we all know this. Most of us accept it. Lets move on. Thus far, I am in line with the main-stream non-linear algebra proponents. However, I'd love to see clean linear algebra implemented in Python. So the dilemma is how to make the marriage work. First, Huaiyu has done an outstanding job as not only an advocate, but implementor, of such a hybrid system. This is always the first step. People can complain about the lack of something from now until doomsday, but without someone at bat nothing will ever happen. So, we have a critical mass. Now what? Now he is asking for advice and guidance. And what do we tell him? I'm sure that both (all) camps know their party lines at this point, but it seems to me that little constructive has been done to work around the issues. So, here I go. Brainstorming... Silly idea 1: Until add-on Python grammar modules are available, what about a PyAlgebra evaluator module. For a precedent, see regular expressions. The difference is that linear-algebra syntax can be made too Python-like for some tastes. e.g.: import PyAlgebra PyAlgebra.run(r'A = (A .* B)\C') e = PyAlgebra(r"D = A'*B") e.run() # or e() Admittedly, its not perfect, nor optimally compact, but it is no longer encumbered by having to support the full Python grammar and is free to redefine as much as necessary. Silly idea 2: How about a "Linear-Algebra Python" to "Stock Python" translator. Parsing Python isn't rocket science, so a fairly simple source-to-source translator can hide all the new syntax and turn it into redistributable stock but ugly Python code. No fuss or muss, assuming that the original source is available when necessary. Silly idea 3: Lets continue arguing until everyone, both pro and con, gets irritated, starts calling each other Nazis and gives up. Feel free to chime in! -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 778-8211 <-------- S.A.G.E. Project Technical Coordinator | Department of Epidemiology & System Administrator | & Biostatistics Internet E-mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From dnotspam-jen at personic.com Sun Jul 2 18:19:38 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:19:38 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <395fbd8c$0$5622@wodc7nh0.news.uu.net> I checked out the link, but from what I read, it sounds like this is a client-side implementation only. Is there more info on this somewhere? Maybe some examples of how to use this? Thanks! Jen "David Bolen" wrote in message news:uem5e38if.fsf at ctwd0143.fitlinxx.com... > Well, there's probably no end to the number of protocols and methods > by which you could get the machines to talk, but given that it's > Python invoking Python, you might take a peek at Fredrik Lundh's > XML-RPC library. XML-RPC was sort of the precursor to SOAP. Similar > in concept, but it's dirt simple to get two Python processes > communicating (calling arbitrary methods with any Python objects and > returning any Python objects). > > See http://www.pythonware.com/products/xmlrpc/index.htm. From alex at magenta.com Fri Jul 28 06:57:31 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 12:57:31 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8lrp6k0utp@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o2fgr.1e2.grey at teleute.rpglink.com... > On 28 Jul 2000 19:46:29 +1200, Paul Foley wrote: > >The distinction you're trying to make (between "types" and "just > >data") is rather foolish. Data are the things that have types. > > Rather foolish? For whom? Humans don't think in "integer" and "long > integers" or "strings". We think in terms of data whose exact value, "type", > is determined by context alone. Human language, and human thought, are really all like this: fuzzy, imprecise, vague, ambiguous, highly context-dependent. Ludwig von Wittgenstein, in my opinion (and not mine only:-), is the thinker who most lucidly explored this issue -- in a manner all the more striking because, in his youth, he took such a drastically different tack, striving to define the conditions for "proper" speech, by which he meant speech (and thought) logical, precise, specific, effective. He concludes his first masterpiece, the "Tractatus Logico-Philosophicus", by the famous admonition "Whereof you cannot speak, thereof must you be silent". The main implication of which is that there ARE things, extremely significant ones as it happens, of which "speech" (in the logical, etc) sense is just unfeasible (e.g., earlier in the Tractatus, "The Mystical cannot be spoken of: it SHOWS itself"). Alas, a built-in contradiction lies at the root of this -- because, among the Unspeakable things, are most of those which the Tractatus speaks of!-) Young W, quite aware of this, makes heroic attempts to talks his way around the issue ("this is just a ladder, to be discarded once you've used it to climb" -- I'm quoting by memory, and no doubt unreliably). But the fact remains that humans WANT to speak, most of all, about "unspeakable" things (in the precise, young-Wittgensteinian sense of "speech"). And precision, sharpness, logical rigour, are just unfeasible in such domains. And so, after decades of development and reflection, does Wittgenstein come up with the framing best displayed in the postumously published "Philosophical Investigations" (alas, not a finished work: he never thought it ready for publication). "Whatever we're talking about, we are talking about the natural history of human beings". Language -- actual use of speech -- is a collection of language-games that are played out, for biological reasons connected to how evolution shaped us, in their various, separate contexts. Rigour, sharpness, precision, are ideals never to be attained (save by hypothetical inhuman-speakers), and their relentless pursuit can be a snare and a delusion. Now this framing leads to an interesting perspective regarding the unceasing stream of requests for computers to be able to handle "natural language". This really translates to a request that the machines be able to deal with deliberate and accidental ambiguity, mixed signals, vagueness, imprecision, fuzzy requests that had better be ignored, all the mix of issues that human being themselves often have trouble with (else, young geniuses would not spend years writing "Tractatus"-like pleads for precision, sharpness, logic...:-), and are, roughly speaking, able to disambiguate/resolve by relying on shared context, which is largely cultural but ultimately rests on biological foundations. Yes, I would call this quest "foolish", just as I would call Don Quichote's quest for unattainable chivalric ideals, young Wittgenstein's quest for unassailable, perfect sharpness in language, and many other ones of humanity's noblest pursuits. This is a strictly descriptive term and does not imply value-judgments in the general case; we'd all be less human, and poorer for it, if all of humanity's efforts were always bent towards practical, attainable, sensible ends (besides, pragmatically speaking, a tiny fraction of such 'foolish' projects ends up with often-unexpected side benefits of such magnitude as to repay humanity, collectively, for all of what a bean-counter could consider "wasted" effort; although it's not a strictly good example, since the collective benefits are highly debatable, an analogy might be Columbus' foolish quest for a way West towards Asia -- unattainable due to Earth's actual girth, which he should have known but had wilfully blinded himself to, but serendipitously ending up in the lucrative-for-his-backers landing in unforeseen America). Floating down from these dizzy heights, back to everyday programming: that humans being tend to think in certain fuzzy/imprecise/ambiguous ways is hardly a recommendation for a language intended for human use *to interact with computers* to shy away from precision, clarity, and sharpness, nor does it necessarily make it any less 'foolish' to do so. Very specific analysis of the various possible trade-offs will be needed: what levels of ambiguity are allowed, what their practical consequences are, and so forth. > As a human, type 1. Character? String? Integer? Floating number? No, > it is 1 and it can be all of those all on context. Types are a construct > created to help computers deal with human concepts. Why, then, when a Not really: they were molded to help humans deal with *PRECISION*, well before computers existed. The need for such precision came from maths, and often from its growing applications in science and technology as well. To a human being's typically-fuzzy thinking, the number '23' and the set containing the number '23' as its only member are basically one and the same thing, for example. But mathematicians found it necessary to draw a sharp distinction between an elementary object, and the singleton set containing that object, well before computers existed. "CATS": is this a 4-letter string? a set of animals? a popular musical? or an important diagnostic technique? Philosophers felt the needs for such precision of concepts well before mathematicians did -- and laid the foundations for what we can recognize today as a theory of types. Human beings are often able to disambiguate from context -- but not always. One of my cherished memories is a Uniforum session, many years ago, which was billed as being about "ATM Networks" -- keen, like many others, to learn the latest about Asynchronous Transfer Mode networks, I trooped into the small room and, like all others, found myself surprised to see it packed with twice as many people as it could hold; half of them, as it happened, the suit-and-tie kind of people, rather than the T-shift-and-sneakers guys you could expected to be interested in such tech exoterica, which made up the other half of the audience. It soon transpired that half the audience were in the room to learn the latest about technology being applied to networks of Automatic Teller Machines, of course. It so happened that the context of being at a computer and networking conference was NOT sufficient to disambiguate -- the guys from the banking and finance sectors had quite reasonably misread 'ATM', it being such a pervasively used acronym in _their_ world. It was bad enough (if excessively amusing) among human beings; it could be very serious, and potentially VERY costly, if such ambiguity was let loose among clearly-common-sense-free computers. > language comes along that does a darn fine job of doing the right thing by > defining data as a scalar (it isn't a string, it isn't an integer, it isn't > floating point, it isn't a character, is can be all of them depending on > context) do you call it "foolish" to think in those terms? In my practical experience of Perl use, this can and does indeed give rise to substantial problems. For example, if a floating number gets implicitly coerced to a string, and that string gets coerced back to a number, a loss of precision is a frequent occurrence. Of course, this specific issue is not going to hit you on the nose until and unless you attempt to use Perl for substantial computations. But the general issue, which tends to loom larger and larger as program size and complexity grows, is that coercions are being silently, implicitly perpetrated *that are NOT reversible*. Whenever a pair of conversions, A->B->A, happens implicitly and silently, and the A you end up with is NOT the same A you started out with, then you have a problem just waiting to show up. By general law, it will show up when you can least afford it do, i.e., when you have just deployed your application at your most valuable customer's site:-). ("Only the paranoids survive"...:-). The ancillary costs must also be considered. By choosing not to distinguish between two types of data, you miss being able to use those types to provide you with context to clarify the meaning of the operations you perform; rather, the _operations_ must supply the context and therefore the meaning themselves. I.e., having 'abc' + "def" return 0 is NOT very desirable: surely the "context" of the "+" being applied to strings should let it mean "concatenate these strings" rather than "sum these numbers"? They *aren't* numbers after all, are they? But you can't have it both ways: either the operations fix the context rigidly, and the data gets coerced (with information loss) to fit that context; or, the data has a specific type, that can supply the context in which the operation is performed. Perl picks the first alternative, and thus you must have different operations for "concatenate these strings" and "add these numbers", specify explicitly every time whether a scalar or a collection (and of which kind) is being used, etc, etc. I see colleagues with years of experience in Perl, and enthusiastic about the language, STILL write "@x[3] oops I mean $x[3]" and so on. I'm not being a Python apologist here; I think that using typed data is preferable in most cases _but not in all_, and that Python should let the operation determine the context, rather than the data, in a few more cases than it currently does. E.g., the print statement now coerces its arguments to strings, and I consider it a good thing. But the operator / does integer (truncating) division on integers, and that is a detail which I consider not optimal -- I believe it would be better (like, say, in Pascal) to have different operators for division-with- truncation and division-with-floating-result (the existing divmod builtin function, actually, could perfectly well carry the burden of division with truncation, IMHO, letting / always mean division-with-floating-result -- were it not for the need of backwards compatibility, of course, i.e. in an abstract and hypothetical language-design-ab-ovo context). > >character "a" (Python, sadly, lacks a proper character type); > > I'd consider that a blessing. Once less artifical construct to get in the > way. Here I happen to agree with you -- since bidirectional transformation between a character and a 1-character string yields no information loss, and no 'intuitively-desirable' "overloads" of operations to mean different things in the two context appear obvious, then little would be gained in drawing the distinction. A similar situation, IMHO, holds between integers and long-integers; I hear that the current sharp distinction between them is going to be somewhat relaxed in a near-future release, and that seems to be a good thing to me. So, you see, I'm being anything but a type-purist; I dislike Perl's silent implicit coercion between strings and numbers for highly pragmatical reasons, direct and consequential, borne out by many years of practice (and tens of thousands of lines of code) with Perl, and a few months (and thousands of lines of code) with Python. My pragmatical inference from this experience (and from reasoning about it) is that keeping the distinction just works better in most cases, although specific, constrained, motivated cases of relaxation thereof (such as in 'print', and IMHO also in some other cases where it is not currently applied) might be worthwhile. > >No; "a" is a string and strings are sequences; 1 is an integer, and > >integers are not sequences. This particular quirk is in your head. > > No, the particular quirk is in the language by forcing types. Remember, > all this came about because I pointed out that Python has just as much > automagical "typing" going on as Perl does, it just limits that typing from > what I can see. What "automagical typing"? Are you referring to, e.g., "print" always trying to turn every argument into a string in order to print it? Yes, it does happen, in some very specific cases. But it's definitely not "just as much" as in Perl, so I suspect you must be intending something else. Just in case you're thinking of the fact that a variable can refer to different types in different cases, why, of course -- in fact Python is much more general in this than Perl, since the same variable can refer to a string, number, list, tuple, dictionary, object, &c, without any syntax quirks needed to distinguish between the various cases. The type is carried by the *data* being referred-to, and never by the variable doing the referring; which is a completely different issue, with nothing "automagical" about it (no transformation whatsoever takes place, i.e., no coercion -- no risk of information loss whatsoever -- etc, etc). Alex From stephen_purcell at yahoo.com Thu Jul 27 19:32:52 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 28 Jul 2000 09:32:52 +1000 Subject: javadoc equivalent for python? In-Reply-To: <3980AA2F.4E4E6E1F@seas.upenn.edu>; from dwhite2@seas.upenn.edu on Thu, Jul 27, 2000 at 05:31:27PM -0400 References: <3980AA2F.4E4E6E1F@seas.upenn.edu> Message-ID: <20000728093252.A12152@inkontact.com.au> David White wrote: > > Is there an equivalent python application to javadoc? Try Laurence Tratt's Crystal package:- http://www.btinternet.com/~tratt/comp/python/crystal/ The output even looks like Javadoc (not that that's necessarily a good thing). My personal favourite is Ka Ping Yee's htmldoc package: http://www.lfw.org/python/ -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From shouldbe at message.com Fri Jul 7 08:29:31 2000 From: shouldbe at message.com (Arinté) Date: Fri, 07 Jul 2000 12:29:31 GMT Subject: Comparing 2 class types Message-ID: How can you know if a 2 variables are different instances of the same class? x = someclass() y= someclass() I tried is, type, and type(x) is someclass, but none seem to work unless I did it wrong. From collins at rush.aero.org Thu Jul 6 21:45:20 2000 From: collins at rush.aero.org (collins at rush.aero.org) Date: Thu, 6 Jul 2000 18:45:20 -0700 Subject: [ANN] Python port to Palm Pilot Message-ID: <200007070140.SAA31035@wd264.aero.org> Announcing the alpha port of Python-1.5.2+ to the Palm Pilot, available for download after 8AM PDT July7, 2000 at http://www.isr.uci.edu/projects/sensos/python/. This release includes the modified Python source and tools for creating Palm applications from Python modules. As a convenience, we include the gnu toolchain required to support the Python distribution on the Palm Pilot. We emphasize that this is an alpha release and is deficient in many respects. We are releasing it now to stimulate interest in Python on small computing platforms. Enjoy! From olivierS.dagenaisP at canadaA.comM Wed Jul 5 14:56:47 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 18:56:47 GMT Subject: [ANN]pre-release DBAPI2.0 for ADO References: Message-ID: Hey, this announcement made me think of a question concerning databases: is the DBAPI designed for exchanging recordsets between databases opened by two different implementations? For example, could I take your ADO cursor and assign it to a database opened with, say, Gadfly? (supposing they had the same table definitions) Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Michel Orengo" wrote in message news:B5L85.2924$EV6.75523 at typhoon1.ba-dsg.net... > Hi all, > I enclosed a very preliminary version of the DBAPI 2.0 for ADO (Microsoft > Active X Data Object) - ADODBpy. It is built on top of another module called > ADOpy which give a more "pythonic" interface to ADO (I've posted this module > few days ago) > > ADODBpy is still largely incomplete (does not deal with exceptions for > instance). It is released to get a feedback from the python community. > > Some examples to get you started: > > import ADODBpy > > db = ADODBpy.connect('MyDB', 'MyUser', 'MyPassword') > cur = db.cursor() > cur.execute('select * from mytable') > tup = cur.fetchone() > > #now because it is build on top of ADOpy, we can access also the > properties/methods of the > #underlying ADOobject > print db.provider > print cur.fields.Item('col').Value > # or better: > print cur['col'] > > Hope this help. > Cheers, > Michel > > > From nobody at nowhere.nohow Fri Jul 28 21:34:58 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:34:58 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: In article , Steve Lamb wrote: > Neither cruel or jest. I consider "Automagic" coversion on the same vein >as "Winblows". I've never thought "automagical" was derogitory. Rather it describes something that is done using contextual information and heuristic rules to "guess" at what should be done when there less information that might be needed to do something determinstically. -- Grant Edwards grante Yow! I don't know WHY I at said that... I think it visi.com came from the FILLINGS inmy read molars... From ingo.adler at synacon.ch Sun Jul 2 13:15:43 2000 From: ingo.adler at synacon.ch (Ingo Adler) Date: Sun, 02 Jul 2000 18:15:43 +0100 Subject: Memory leaks Message-ID: <395F78BF.CBEAA090@synacon.ch> Hi, I have some simple Python-Code which generated memory leaks (ca. 4MB): (The real code is more complicated, but I could strip it down to this simple example = the smallest example with the memory leak.) //--------------------------- x = X() for i in range(100000): y = x.getY() y.getNumber() //--------------------------- It doesn't generate memory leaks when: //--------------------------- x = X() y = x.getY() for i in range(100000): y.getNumber() //--------------------------- or //--------------------------- x = X() for i in range(100000): y = x.getY() //--------------------------- So getY and getNumber don't generate memory leaks on their own. Details: X and Y are implemented in C++ and connected to python via Swig-Shadow classes. The Implementation of X: class X { Y* pY; public: X() { pY = new Y; } ~X() { delete pY; } Y* getY() { return pY; } }; The Implementation of Y: class Y { float getNumber() { return 3.4; } }; The wrapper code it generated straight forward - nothing special, nothing hidden. I use Python 1.5.2, Borland C++ Builder 5.0 with statically linked Python. My code is much bigger and works pretty well - except the memory leaks. So the basic integration works. I hope someone has a solution! Ingo -------------- next part -------------- A non-text attachment was scrubbed... Name: ingo.adler.vcf Type: text/x-vcard Size: 338 bytes Desc: Card for Ingo Adler URL: From yw at alabanza.net Mon Jul 24 12:31:05 2000 From: yw at alabanza.net (ye, wei) Date: Mon, 24 Jul 2000 12:31:05 -0400 Subject: Python questions from C/Perl/Java programmer Message-ID: <397C6F49.7BEBB207@alabanza.net> I'm a programmer and have C/C++, Perl, Java, PHP experience, now I'm interested in Python now. I spent a day to learn the Python, it's a cool language, however I have the following questions: 1. Why not use {}?! def f: ... why not use {} like this: def f { ... } I'm almost couldn't bear with it?! {} is not difficult to be added, however it can make sure the logic is correct. It's easy and simple. SPACE and TAB mixed may cause problem in Python script, consider use 'vi', it's hard to write Python script. The other problem is if you want to added a new condition in a complex already existed condition statement, e.g. In the following example, If you want to added a new 'if' between line 1 and 2, you have to add TAB from Line 2 to 199, it's difficult to make sure you don't make mistake. (The case may be more complex as the example which I give). 1 if() : 2 if(): 3 .... .... .... 100 else: ... 200else : ... 2. Why variable doesn't have to be declared before use? Perl and PHP variables don't have to be declared before use, it's easy, however if a variable happens to be spelled wrong, it takes time to found it. In the other word - it causes to more time on testing and debug. This is why perl 'use strict' come out and obviously we benefit from it a lot. In perl, if you use 'strict' package, you need declare variable before use it, or your script couldn't run. for example: #!/usr/bin/perl use strict; my $i; $i=... I like variable need to be declared before use, alos perfer the declare with type, e.g. int i; object x; def f ( object x, int i): Is this hard to be implemented in script language? Thanks for advance! -- Sincerely, Wei Ye From bellamy at freesurf.fr Sun Jul 16 11:15:32 2000 From: bellamy at freesurf.fr (Bellamy Bruno) Date: Sun, 16 Jul 2000 17:15:32 +0200 Subject: Newbie question: PyOpenGL installation Message-ID: <3971D194.1A951464@freesurf.fr> I'd like to use OpenGL for Python with Linux, but I'm really confused with the installation. I'm used to RPMs, or installing software from sources in .tar.gz format with the regular './configure', 'make', and 'make install', but I just can't understand the explanations on PyOpenGL web site. If anyone who did it OK could give me a little help, that would be just great (or if there's a RPM installation package for PyOpenGL somewhere on the planet...). Thanks a lot. From rumjuggler at cryptarchy.org Thu Jul 20 18:49:33 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Thu, 20 Jul 2000 22:49:33 GMT Subject: zip() : how about braid() References: <397681C6.FEAEE2E@my.signature> <397746AE.3CCDD423@schneider-kamp.de> Message-ID: <700fnsknn7k7fp22au924m2cprk04ghfic@4ax.com> On Thu, 20 Jul 2000 18:36:31 +0000, Peter Schneider-Kamp wrote: >Dennis Lee Bieber wrote: >> >> It's silly, but has anyone considered >> >> marry() >> >> or >> >> partner() >> >> as names for the function? > >It's not that silly. An older proposal favored marry(). > >But imho marry() and partner() implicate the zipping >of two lists (even stronger than the zipper zip()). > >OTOH somebody mentioned that it would be a great >political statement. Marriage of an arbitrary number >of arbitrary types (read: genders). On the other hand, if it were marry(), then you could do all sorts of fun stuff: >>> def marry(*sequences): length = len(sequences[0]) results = [] for i in range(length): results.append([]) for sequence in sequences: for i in range(length): results[i].append(sequence[i]) return tuple(results) >>> def divorce(sequence, num_results=2): results = [] length = len(sequence) if length % num_results <> 0: raise Exception for i in range(num_results): results.append([]) for i in range(length): results[i % num_results].append(sequence[i]) return tuple(results) >>> marry([1,3,5],[2,4,6]) ([1, 2], [3, 4], [5, 6]) >>> divorce([1,2,3,4,5,6]) ([1, 3, 5], [2, 4, 6]) From blinocac1 at home.com Mon Jul 10 17:29:09 2000 From: blinocac1 at home.com (David L. Heald Jr.) Date: Mon, 10 Jul 2000 21:29:09 GMT Subject: Compiling Python Message-ID: Does anyone know if there is a compiler available anywhere for python for win32? From see at below Mon Jul 31 23:06:21 2000 From: see at below (Paul Foley) Date: 01 Aug 2000 15:06:21 +1200 Subject: experts disagree on "call-by-reference" References: <8m29o0$p9g$2@news.dtc.hp.com> <8m5a74$gp1$1@news.dtc.hp.com> Message-ID: On 1 Aug 2000 01:47:16 GMT, (Greg Weeks) wrote: > : Yes, exactly. "Pass by whatever" has never really applied to > : Lisp-like call semantics, Greg Weeks' protestations about "the old way > : of speaking" notwithstanding. > Again, these are words that you like to use. Winston and Sussman like > different words (eg, that Lisp is call by value). Are you saying that they > are flat-out wrong to use those words? OK: Yes, they're flat out wrong to call it "call by value"! But let me qualify that by adding: given that some people will read that to mean what it means in Pascal. However, several people have suggested "call by object" as a good name for what's actually happening, and I see no good reason to distinguish between "objects" and "values", so "call by value" is actually a perfectly good description -- it just doesn't mean quite what you want it to mean. -- And ?lc ?ara ?e gehier? ?as min word, and ?a ne wyrc?, se bi? gelic ??m dysigan menn... (setq reply-to (concatenate 'string "Paul Foley " "")) From victor at prodigy.net Fri Jul 14 23:05:02 2000 From: victor at prodigy.net (Victor Muslin) Date: Sat, 15 Jul 2000 03:05:02 GMT Subject: using threading module Message-ID: <396fd2ff.3598724@news.prodigy.net> I tried using the threading module with the following simple program: #!/usr/bin/python from threading import * reps = 10 def f1(msg='xxx'): for i in range(0, reps): print 'f1', msg, i t1 = Thread(target=f1,args=('bar')) t1.start() For some reason it barfs with the following trace that, being rather new to Python looks pretty nasty to me: Exception in thread Thread-1: Traceback (innermost last): File "E:\Apps\Python_1.5.2\Lib\threading.py", line 376, in __bootstrap self.run() File "E:\Apps\Python_1.5.2\Lib\threading.py", line 364, in run apply(self.__target, self.__args, self.__kwargs) TypeError: too many arguments; expected 1, got 3 However, when I do not pass the "args" parameter to the Thread constructor, as in: t1 = Thread(target=f1) Yet I've seen example where parameter(s) had been passed like that. What is going wrong? I am using Python 1.5.2 on Windows NT machine. TIA From robin at jessikat.fsnet.co.uk Wed Jul 19 06:53:56 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 19 Jul 2000 11:53:56 +0100 Subject: generator.py References: Message-ID: In article , Robin Becker writes >has anyone go the generator.py from starship; the link there seems >broken. duh! it's in demos/threads duh :Q -- Robin Becker From hei at adtranzsig.de Mon Jul 17 05:17:22 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Mon, 17 Jul 2000 11:17:22 +0200 Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME References: <963764534.1476580377@news.demon.co.uk> <3971F055.68CD6897@prescod.net> Message-ID: <8kuj13$20i$1@desig-bs01-s04.adtranzsig.de> There's also some thing called Visual or Visual Python by David Scherer. See the edu-sig archives for details. Call it "optisches Python", that's german and surely not trademarked. (When we germans seek a product name, we always come up with an english one because that's modern so we wouldn't ever trademark anything that contains a word in our native language. So you're secured.) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Paul Prescod" schrieb im Newsbeitrag news:3971F055.68CD6897 at prescod.net... > Phil Thompson wrote: > > > > ... > > > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. > > Be careful. When I worked at Watcom we tried to make "Visual REXX" to > hear that some other company (not Microsoft, but obviously related to > Microsoft) had a trademark on Visual X where X is a programming > language. Microsoft licenses the name and other people are supposed to > also. From morganea at bellatlantic.net Wed Jul 5 14:26:41 2000 From: morganea at bellatlantic.net (Michel Orengo) Date: Wed, 05 Jul 2000 18:26:41 GMT Subject: [ANN]pre-release DBAPI2.0 for ADO Message-ID: Hi all, I enclosed a very preliminary version of the DBAPI 2.0 for ADO (Microsoft Active X Data Object) - ADODBpy. It is built on top of another module called ADOpy which give a more "pythonic" interface to ADO (I've posted this module few days ago) ADODBpy is still largely incomplete (does not deal with exceptions for instance). It is released to get a feedback from the python community. Some examples to get you started: import ADODBpy db = ADODBpy.connect('MyDB', 'MyUser', 'MyPassword') cur = db.cursor() cur.execute('select * from mytable') tup = cur.fetchone() #now because it is build on top of ADOpy, we can access also the properties/methods of the #underlying ADOobject print db.provider print cur.fields.Item('col').Value # or better: print cur['col'] Hope this help. Cheers, Michel begin 666 ADODBpy.zip M4$L#!!0``@`(`%QOW"@DOGOS3 0``(P-```(````041/<'DN<'G-5LUNXS80 MO@?(.TR=@^3&$;+;4X.F11JG0 Y)C'3;+1H8`DV-8VYE4B#I.%KTF?H0^V0[ M)!69EI5NVAQ:(0ADSO_WS0QU`$=?>O;W#N!L?%/5)W#!3 V7TJ*>,XXP5]I) MG,)+O#B]]UI8BQ)F-5P)OL 2;C3*>Y7!9#4K!8>Q6C(A,Z=[K>!<5;46]PL+ M(Y *;MVK at 5LTJ!^P& &3A3M_S[1FT at HTL%XP:Q0^H,Z:D/1JA))PG+W=WZ.# M`WBW$ :6JEB5"(*JD84!JZ#2ZD$4"(QD&F%0U7:AI. #KQ1*)K50L<<$3ET5 M6ADUMY_^@C-NQ0/^1F]C9AG2TNA(LK$P%;-\D2:4YOC'[%Q) M2O M-*'NI$UJVU9!NF/E+:_5>@1V at 6"H;N+"+IJ)BV&JFTD8&&LQ-PI MU+!&&EAC:8IBK88;2^SUN2"3`@F0PDT at +0@7:C )2T /LF9NR;O39)R2-6+F M!K?VJE1U&9@#Y2<]:G2W:/;W&N*-)5#N1Z"Q/6H'O3W9&>W]O=R1:!S(F)&D M$B5QDOXP^6Y=?']W=O3[U/\[_#.\LZ./QT??3@^'KB_W]WA)70`YP>W?J!.! MG at +GD.?W2$A9G>6%UDIW M at G72_:"$3 -VV5S(@I5E&@*.$D at Z47=3C]/?3CM>9,%A6!2[]OVU1/6T_#MB M<^PIRKMAPF"G]C2"+K!I>M@"&[S_,[YGFY[]?QP1E=&8*9-*N9EVTO2ZB33L)[#K\[X"HO+EO _L(X= M-LUWWJZG2U+N4$9WF+.*-D5T#[5+8[BU-804MHW9?"OITR1Y<3'/?J,,NM\H M at XAH6O%/P> KNM&2G9[LTAUT3UNSN,CEDNZ7%U78NCR]5G)KDBBC5NB^Z9R\ M+ZE_CX//, at 8!2],?PG?7IJ\VI6ZN]/]WL6V>KRNWT^VOJ_F96-'*;==MS^"9 MG049-LXP+B=8;9?X&5!+`P04``(`" !K8N4H!G'^:A\'``!O% ``"@```$%$ M3T1"<'DN<'FU5VU/X\86_ at P2_^&4B.+T>JV$95^*RI5@`[V1N@$!V]6JJJ*) M/4GFKNWQSHQATU_?_#B>S][NSTX&UV-SJ\_ MG<"(&39CFL/9]1B.D@',I2(N at 9XCB7 ?E3"&ES!;P7N1+GD.5XJ7"YG =3W+ M10HC63!1)H2=2'@GJY42BZ6!&$H)-_2HX89KKNYY%@,K,Z)_9$JQT at BNX6') MC);\GJND48F/6L at 2!LEP;W=O5Q255(;LKE;0$Z7A:LY2#@_"+)TW#<*L*JYC M\IK?B8)#C]R=B3(3Y<(J3F5I5)T:J30)WMLU2\59IMF%-HRG)Q' M<1U&H.^;X"[7A3'C8=O->38_*9I9PWFHQ:A3#D(H/. M?TUY94+61);C[GRE'3G&D-MP83A:GL0BFIH at LK!7/1ZJH0 MX'&8P"6F5=3!;Z&;Y//[IGN4UURX]B9(X`N:'>VA/I47E#TFSY$XG);M]`U%"<-SR M?/(-.L!?OHD;TDN;^Y[ZPO;!V[N;\>17JL>N5Y&%X@\,CWZ.H<>R=TNF6N+1 M8&B)O\ER\3M3'=[;&(!XYRB[);XYBBWQUP_CT5KTP!%MK /9+T/9'SO"AR\' M]DB7BL5Y/IZ"BSLF']^<7-T_J/'8> MCG at J"I:W]%=-C$82YQUOR2\;LBT/'G@]=&+.IM\PUT`)NZ,?"CL[N+N_'[BZ="_\:'V$["-BXNMT;G&^3CANPF M9$M^%9!OW71L>/#ZV(J_Q(G=.01DX,W5Q_'H*>M0]NNFJBKL;K at Y@=T2I%L4 MV$S6QJT+.&&2)/$'^V$GPA6 at 1*G8=2.[R"1K0M^WI=217(.!3).O)()?-\QM+/FUA/[Z+36FELO<[$ MDA7\]! '.] I9&$8WSD`L?H--6'HYSU?>XPPJP(C(6VP at S&-^"!J3IB/6%'@ M((W=VPU/T5W-3?_QKKXVCH1W)"0=9!_OENZ/PXPO! UU$.90`[,Q1'C3NDD> M_' *AX>N-UL/+/'4\MK T6J[TN(O8 at Q;:L9UJD35N.^6D3;2#ZFL2X-TZO0N MSEAIN&VFC3/T2$IB^,FNF1P3,9Q8_"M/:\.C-6X-B^'8WYZ'.:'2+P(A^O2/ M/V/O.57#Z7 C?XC.OY*Q[?DM/IY#?O#F+MC>&#+\-+3;VMH=^"\,7&S71$07 MK(K<=AG:V7<#4B.Q$\38QG8KPY*+QO7&BBU1P=#=DOE=:?W&(3R:7 J>9QIS MC0YBO at R:;QYCN1=7ET'Z3%.F381T3,*)?,#$PR3$L'%*/^4SW.+]HKN=,^[= M at JU2BPKVWYUF+=K9SD2\;$NG[QM!^PO6^L*E1S(/_. at W@BS-JVP`8\.+2+CK MV&GJP;*2"?.]EK[,IJG,^"-]UF&)T,C(A*YRMIHV)>3X(SX7-(&0YE"BV32[ ML+/4U"Q?HRJ,B]"NYASBVE.:8&*A!1:[&7Q+Q,:A.L^G\O-:`7[3B!E>O88? M8?#U:& '2YZ-]021K-T0-B.=L H[=A9%KCK;@&"?#]R-H>-6[$>)G4.M+YB= M9""V.&=A6VR6N^9>IG$_#OO"OE+E%H*VHB&>^!6[4/N5;4.-V<=ZP M+JB29Q>Q_0[E)EUB!PC&65LZ6*%6(!4A=#X+NP6SPS[!<-LYZ_6;NLIY1)(ZS at 772TER.F@_0UPI8(Q/ MFD?H#J0M9X2_$&PG;5G[`%I3'I:X-$%$?%QPJ(M15/JVIT6"OF10[B,^XP%7 MSJ1"P']<&GQ;C_]^1Q&AKS@%@XOLV/X=DS2ZS]KPR41=S_< M;F+:_NB_W__\QI.6U/*"K;/OB$EP_K'=T6]A)5;[WU!+`0(4`!0``@`(`%QO MW"@DOGOS3 0``(P-```(``````````$```"V at 0````!!1$]P>2YP>5!+`0(4 M`!0``@`(`&MBY2@& I tried to send this earlier, but after consulting the archives, it didn't appear as if it made it. So now I'm subscribed and I'll try again. :) I'm trying to do nonblocking input with Python, but without using curses. I'm writing a text-based, line-oriented client, and the cmd module does almost exactly what I want, except for the fact that it doesn't do nonblocking input. I've worked on this all day, and I'm closer to a solution,though I'm still running into some problems. The client currently uses a thread to read from the socket, and the output is printed to the screen. The problem with this method is that output gets intermingled with input. The obvious solution is to store all input, reprint the last line of the display, then print the prompt and stuff the old data back into the input buffer, but don't I need nonblocking I/O for this? Or, is there some other module/method which I am completely missing? I'd like to avoid using curses since 1) my application uses only a single window, and doesn't need all of the additional overhead which curses provides and 2) cmd provides an interface which is perfect for what I am trying to write. From see at my.signature Thu Jul 20 23:25:28 2000 From: see at my.signature (Greg Ewing) Date: Fri, 21 Jul 2000 15:25:28 +1200 Subject: zip() : how about braid() References: <8l6cbp$fgr$1@pollux.ip-plus.net> Message-ID: <3977C2A8.6D8F7586@my.signature> "J?rgen Hermann" wrote: > > merge() is the best yet, since it's a common (programming) term with a > well-defined meaning. But it's a DIFFERENT meaning! merge([1,2,4,6,7,8],[3,5,9]) --> [1,2,3,4,5,6,7,8,9]) -- 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 jhylton at my-deja.com Thu Jul 6 14:20:53 2000 From: jhylton at my-deja.com (jhylton at my-deja.com) Date: Thu, 06 Jul 2000 18:20:53 GMT Subject: job offer References: <8k2a7p$mi71@imsp212.netvigator.com> <8k2asd$gin$1@slb0.atl.mindspring.net> Message-ID: <8k2ilp$aao$1@nnrp1.deja.com> In article <8k2asd$gin$1 at slb0.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > This is actually related; having jobs available boosts acceptance of > Python! However, you might try getting your posting up at > http://www.python.org/Jobs.html > > Unfortunately, I've heard that the updater of the above URL hasn't been > responsive lately. I just wanted to confirm that you are correct. I am the updater of the jobs board, and I have been unresponsive of late. I am feeling guilty about it, if that's any consolation. I was busy getting the new PythonLabs site ready, http://www.pythonlabs.com/, but I hope to be able to get back to the jobs board soon. Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From bill at dehora.fsnet.co.uk Fri Jul 28 18:45:30 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Fri, 28 Jul 2000 23:45:30 +0100 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> <39808d84.23819726@news-server.austin.rr.com> Message-ID: <8lt3pl$bgg$1@newsg4.svr.pol.co.uk> Q: how do you stop programmers making bugs? A: take away their computers. From thomas at xs4all.net Wed Jul 19 04:14:17 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 19 Jul 2000 10:14:17 +0200 Subject: Type checking in python? In-Reply-To: ; from hopper@omnifarious.mn.org on Tue, Jul 18, 2000 at 05:59:42PM -0600 References: <397296BC.415C97E1@prescod.net> <20000718231047.D4283@xs4all.nl> Message-ID: <20000719101417.I4283@xs4all.nl> On Tue, Jul 18, 2000 at 05:59:42PM -0600, Eric Hopper wrote: > In article <20000718231047.D4283 at xs4all.nl>, Thomas Wouters > wrote: > > If you insist on type-checking, do it the interface-way: > > > > getattr(object, "required_method") getattr(object, "required_datatype") > > [etc] > *shudder* Well, that's why noone does it. Just using the object and assuming *some* clue in the programmer is what most people do, and you know ? It works pretty well, really. > > Scoping is incredibly simple in Python. There's the local scope, and the > > global scope ;) It might take some getting used to if you're used to > > magic or explicit scopes, but it's definately very simple ;) > > It is very simple. I would prefer more nesting of scopes though. In > particular, lambda expressions should have the local scope they're > declared in as their global scope. I understand why they don't. It's > because of how references to variables inside functions are optimized. Nah, that can be turned off or worked around. The problem is that Python has no nested scopes period. local/global *look* nested, but they really aren't, they're just two seperate namespace-pointers that might point to the same one. For Python to get nested scopes it would, for one, have to deal with cyclic garbage first, and then be rewritten do to nested scopes. Quite a large rewrite. I think the 'lambda x, y=y, z=z' trick works good enough. If you need more complicated lambda's, you don't need a lambda, you need a class. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From moshez at math.huji.ac.il Sat Jul 22 01:49:16 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 22 Jul 2000 08:49:16 +0300 (IDT) Subject: Operators for everything (was Re: Operators for matrix) In-Reply-To: Message-ID: On 21 Jul 2000, Michael Hudson wrote: > a @ b === (a,b) > > for any valid identifier . ... > 3. Syntactic sugar causes cancer of the semicolon. people-with-automatic-signatures-should-be-careful-of-what-they-post-ly y'rs, Z. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From arnold at dstc.monash.edu.au Tue Jul 25 23:57:38 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Wed, 26 Jul 2000 13:57:38 +1000 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: Your message of "Tue, 25 Jul 2000 14:50:02 +0200." <8lk2kc0esc@news1.newsguy.com> Message-ID: <200007260357.NAA28707@xevious.dstc.monash.edu.au> -->"Alex" == Alex Martelli writes: Alex> since IL does not support multiple inheritance of Alex> implementation, which full Eiffel wants; dunno what Python Alex> .NET will do about that). urk! is that true? mark? is this an issue for Python/IL ? Alex> CRL (or CLR or whatever the correct acronym happens to be) is Alex> a Microsoft-proprietary thing; I doubt it will be available Alex> for non-MS platforms, i've heard (from reasonable sources) that porting IL is pretty simple, and these sources have seen it running on unix, etc. Alex> Presumably things will be a little better when Visual Studio Alex> .NET's first beta appears (currently, only a pre-beta of it is Alex> yet around). it's impressive how much hype can be generated for a product that is still years away from general release ;-) d From moshez at math.huji.ac.il Sat Jul 15 14:12:53 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 15 Jul 2000 21:12:53 +0300 (IDT) Subject: How to read one raw character at a time? In-Reply-To: <963677152.546123668@news.libertysurf.fr> Message-ID: On Sat, 15 Jul 2000, Jerome Quelin wrote: > Hi all, > > When prompting a user for something, I would like to fetch and proceed > his answer character by character, and not line by line. How should I > do? > > sys.stdin.read(1) proceeds only when the user hits the return key, > that's not what I want. You haven't mentioned your OS, but if you're on UNIX, you better have a look at the "curses" module. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From buzzard at urubu.freeserve.co.uk Thu Jul 20 15:57:27 2000 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Thu, 20 Jul 2000 20:57:27 +0100 Subject: Closing a file Message-ID: <8l7lm7$kkb$1@news6.svr.pol.co.uk> I am attempting to write data to a file so I can export it to another application after running a simulated annealing algorithm. (self.cost == 0 on the first iteration only.) The relevant code is below. The file seems to be created and written to O.K., bit it's not closed and I can't access 'simresults.txt' without shutting down Python. I've checked the FAQ etc. but I'm no computer scientist and I can't figure out where I'm going wrong. Thanks in advance for any help. from Numeric import * from Set import * from RandomArray import * import sys def acceptsim(self, cost, n): t = 10000.0 / n if self.cost == 0: outputfile = open('simresults.txt', 'w') sys.stdout = outputfile self.cost = DJT.totalcost(self) self.low_cost = self.cost self.low_ordering = self.ordering[:] if n > 900000: outputfile.close() return 'stop' if cost > 0: p = exp ((-1 / t) * (float(cost) / self.cost)) if random() > p: print self.cost return 0 else: self.cost = self.cost + cost print self.cost return 1 else: self.cost = self.cost + cost if self.cost < self.low_cost: self.low_cost = self.cost self.low_ordering = self.ordering[:] print self.cost return 1 From paul at prescod.net Fri Jul 14 17:37:04 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 16:37:04 -0500 Subject: string issue or questions about intern References: <396EEAFF.3AD7B951@bioreason.com> <396F87C4.6B3C9FAE@schneider-kamp.de> <396F0DD3.B391503@bioreason.com> <3dk8eol9bk.fsf@kronos.cnri.reston.va.us> Message-ID: <396F8800.49F7D25D@prescod.net> Andrew Kuchling wrote: > > ... > > If you need full Python expressions, there seems no way around using > eval(). But if you simply need string escapes, it's probably worth > writing a parser. (Does such a parser already exist somewhere in the > standard library? Anyone know?) In general, wouldn't it be nice if there was a parser for all Python literal syntaxes? Sometimes its really convenient to keep your data in a format like this: {"a":"b"} but I cringe to load the file and then eval it for security reasons. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From rumjuggler at cryptarchy.org Fri Jul 28 05:08:31 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 09:08:31 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 07:57:12 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 05:56:07 GMT, Grant Edwards wrote: >>> foo is not ['a']. > >>It is when I try it... > > ... > >>> It took a single element and made it a list. > > Right, which is what I said here, who knows how the not got there. > >>No, it took a sequence containing a single element and turned it into a list >>containing a single element. list() only works on sequences. 'a' is a >>sequence of length 1. > > That is what I said. It took a single element and made it a list with a >single element. > >>>So we now know that a single element has a sequence. > >>Not in the general case. > > Not in this language. In general, yes. Both of these are a single >element sequence. 1. a. Because Python doesn't think so doesn't make it any >less so. You don't even know that a single element has a sequence. You just know that a sequence with only one element has a sequence, which is no great revelation, I think. >>No, 1 is not a sequence. 1 is an integer. [1] is a sequence. (1) is a >>sequence. > > 1 is a single element sequence, regardless of any arbitrary type assigned >to it. How is assigning what is rather clearly a number the type "number" arbitrary? If one is a single-element sequence, why does one plus one equal two? Sequence addition should be equivalent to concatenation. And if one is a sequence, what's one hundred and eleven? A three-element sequence, or a one-element? I mean, is 111[0] 111, or 1? >>str() and list() are not inverse operations. They are neither claimed nor >>intended to be. > > Nor did I claim they were. That's three people who didn't read the last >sentence of that paragraph. I read it, I just didn't see the point in the entire paragraph being there if you weren't making some implicit criticism of the current system. -- Barnabas T. Rumjuggler True, Father Time has long and cruelly sodomized me with the splintered haft of his great scythe, but I shall out-live the God-damned lot of you! -- T. Herman Zweibel From cut_me_out at hotmail.com Wed Jul 26 17:42:59 2000 From: cut_me_out at hotmail.com (Alex) Date: 26 Jul 2000 17:42:59 -0400 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> <397F56CC.55C036EF@bioeng.ucsd.edu> Message-ID: > What is the difference between "print" and "sys.stdout.write"? >>> import sys >>> sys.stdout.write(1) Traceback (innermost last): File "", line 1, in ? TypeError: read-only buffer, int >>> print 1 1 >>> Alex. From aahz at netcom.com Tue Jul 25 06:20:08 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Jul 2000 10:20:08 GMT Subject: Bug hunting (was Re: Python in game development?) References: <3L%e5.9930$r4.5151@news.indigo.ie> <397D1F01.214C4F52@my.signature> Message-ID: <8ljpko$90v$1@slb1.atl.mindspring.net> In article <397D1F01.214C4F52 at my.signature>, Greg Ewing wrote: > >The ability to watch your program execute is an extremely powerful way >to track down the causes of bugs. You know what the program is supposed >to do; the program is actually doing something different. If you can >watch the program execute step by step, it becomes instantly obvious >where they diverge. Usually it's also instantly obvious what has to be >done to fix it, since often it's just some simple oversight. That's assuming that it's not a race condition in a multi-process system, of course. :-( (We had a really narsty problem with MS SQL Server a few months back.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From moshez at math.huji.ac.il Wed Jul 5 01:08:02 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 5 Jul 2000 08:08:02 +0300 (IDT) Subject: Python to C++ in a pickle In-Reply-To: Message-ID: On Tue, 4 Jul 2000, Larry Whitley wrote: > I'd like to pickle an object in python and unpickle it in C++. The object > in question is a python dictionary so it will have to go into a C++ map. > Has someone done this and is willing to share? Or, is the cPickle source > available on the web somewhere? Why use pickle? XML-RPC seems much better for this purpose. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From davidw at linuxcare.com Mon Jul 31 08:09:08 2000 From: davidw at linuxcare.com (David N. Welton) Date: 31 Jul 2000 14:09:08 +0200 Subject: Speed drops when focus moves away from script window References: Message-ID: <87ittm4i3f.fsf@eugene.prosa.it> "christer fernstrom" writes: > When running Zope, I have noticed a drastic drop in speed (order(s) > of magnitude!!) when focus is not on the window from which the > python interpreter is running. Response time for buttons change from > a few seconds to minutes. I run Python 1.6 on W2000. Any suggestions > of what I should do? Run Linux?;-) Doesn't NT have some kind of setting where it ups the 'nice' level of the current window? I think that there is a way to disable that. Ciao, -- David N. Welton, Responsabile Progetti Open Source, Linuxcare Italia spa tel +39.049.8043411 fax +39.049.8043412 cel +39.348.2879508 davidw at linuxcare.com, http://www.linuxcare.com/ Linuxcare. Support for the revolution. From fiona at sitegnome.com Wed Jul 5 09:14:23 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 5 Jul 2000 13:14:23 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 5th, 2000 Message-ID: <20000705131423.10879.qmail@synop.com> Hi ! Another instalment of entries into http://python.faqts.com cheers, Fiona Australian - instalment American - installment :-) .. in case you were wondering that I couldn't spell? ## Unanswered Questions ######################################## ------------------------------------------------------------- How do I format my request to get an url/socket when there is a proxy in the middle and Proxy Authentication is required ? http://www.faqts.com/knowledge-base/view.phtml/aid/4182 ------------------------------------------------------------- Guest ## New Entries ################################################# ------------------------------------------------------------- How do I return a user's login name who is logged on at a PC? http://www.faqts.com/knowledge-base/view.phtml/aid/4189 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain, j vickroy, Ralf Claus You'll need the win32 extensions - http://starship.python.net/crew/mhammond/ import win32api login=win32api.GetUserName() --- or --- On Windows NT: import os os.environ['USERNAME'] ... provides the information. I do not believe that either Win 95 or 98 has the 'USERNAME' attribute set. --- or --- import getpass username = getpass.getuser() works on both systems (NT,UNIX), if you need. ------------------------------------------------------------- Can I use Python to run Internet Explorer and control it via COM? http://www.faqts.com/knowledge-base/view.phtml/aid/4191 ------------------------------------------------------------- Fiona Czuczman Roger Upole, Mark Hammond Here's a small sample of how to navigate to a URL. >>> import win32com.client >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') >>> x.Visible=1 >>> x.Navigate('http://www.python.org') If you run makepy on Microsoft Internet Controls, the file generated in Python\win32com\genpy will show all the properties and methods available for this object. This will work fine to control IE. However, look in "win32com\client\__init__.py", and look for the "DispatchWithEvents" docstring - this has an example that uses IE to both control it, and respond to events (such as URL load completed, etc) ------------------------------------------------------------- Is there a Python MySQL module for use under Windows? http://www.faqts.com/knowledge-base/view.phtml/aid/4188 ------------------------------------------------------------- Fiona Czuczman Stefan Franke Check out ZMySQLDA-1.2.0.tar.gz on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some Windows patches already applied. I run it sucessfully with the lately GPLed MySQL-2.23.19 on Win98. All you need to do is to edit Setup.in, adjust the paths to your local MySQL installation, and run compile.py. ## Edited Entries ############################################## ------------------------------------------------------------- What is the best way to make multiple replacements of text strings in a file? http://www.faqts.com/knowledge-base/view.phtml/aid/4049 ------------------------------------------------------------- Fiona Czuczman, Thi?baut Champenier, Steve Holden Steve Holden, Steve Nordby,David Goodger, Fredrik Lundh,Thi?baut Champenier You could clean the source up a bit with: foobar = ( ('foo1', 'bar1'), ('foo2', 'bar2'), ('fooN', 'barN') ) source = open(source_file,'r') contents = source.read() source.close() for foo, bar in foobar: contents = replace(contents, foo, bar) dest = open(dest_file, 'w') dest.write(contents10) dest.close() For speedup, you could write the whole loop as a single statement, but it will get horrible quickly: contents = replace( replace( replace(contents, 'fooN', 'barN'), 'foo2', 'bar2'), 'foo1', 'bar1) and, of course, ths code is much less easy to maintain. How about using a dictionary and a loop: replaceme = {'foo1': 'bar1', 'foo2': 'bar2', 'foo3': 'bar3'} for key in replaceme.keys(): srch = key rplc = replaceme[key] contents = string.replace(contents, srch, rplc) ------------------- Perhaps a bit complex for a newbie, but the most definitive answer I've seen so far has been Fredrik Lundh's 2000-04-12 reply to the "Python idiom: Multiple search-and-replace" thread: > Is there a Python feature or standard library API that will get me > less Python code spinning inside this loop? re.multisub or > equivalent? haven't benchmarked it, but I suspect that this approach is more efficient: ... # based on re-example-5.py import re import string symbol_map = { "foo": "FOO", "bar": "BAR" } def symbol_replace(match, get=symbol_map.get): return get(match.group(1), "") symbol_pattern = re.compile( "(" + string.join(map(re.escape, symbol_map.keys()), "|") + ")" ) print symbol_pattern.sub(symbol_replace, "foobarfiebarfoo") ------------------- Thi?baut Champenier has wriiten a string replacement utility, which is available for inspection at: http://tibi.free.fr/repl.py From steedman at quake.cs.fsu.edu Mon Jul 24 23:47:50 2000 From: steedman at quake.cs.fsu.edu (Ronald Steedman) Date: 25 Jul 2000 03:47:50 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: <8lj2l6$ibb$1@news.fsu.edu> In comp.games.development.programming.misc Gerry Quinn wrote: :> A full compile of a complex software package can often take 30 seconds or :> more. That can be frustrating when you're trying to find and remove bugs. :> You try one thing, wait 30 seconds, try another thing, wait 30 seconds... : If I were your boss I would make sure you had no access to an : interpreter! I would even slow down your compilation by giving you an : older machine ;-) : Changing things at random and hoping the problem goes away is not the : way to fix bugs. Hehe. I'm thinking about two cases in particular. First is finding a bug such as a memory leak within a project. Inserting debugging statements incrementally to locate it is my usual approach. True, this should be avoided by careful modularization and testing. I know. "Testing is NOT an optional phase in development..." Second is fixing a minor graphical problem, such as some text or border that is a little too big or small. Hmm... border=200? Nope. Border=400? -- Ron Steedman From jbrennan at linuxfreak.com Mon Jul 17 02:54:32 2000 From: jbrennan at linuxfreak.com (Jim Brennan) Date: Sun, 16 Jul 2000 23:54:32 -0700 Subject: Python VM on a Chip? Message-ID: <3972ADA8.BF327969@linuxfreak.com> In the past I have read about companies implementing the Java VM on a chip. Vendors such as Rockwell have been working with Sun to make it possible to implement embedded Java applications that run a hundred times faster then the software VM. Has anyone ever considered doing the same kind of thing with the Python VM? Is it even possible since the data types of Python are late binding? Does anyone know of a commercial or university project that is implementing a Python VM using ASICs or FPGAs? Thanks, Jim Brennan jbrennan at linuxfreak.com From wlfraed at ix.netcom.com Tue Jul 11 12:04:21 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 11 Jul 2000 09:04:21 -0700 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> <126lmsosi64hj8v5dse4ln3khnuvdtpbb8@4ax.com> Message-ID: On Mon, 10 Jul 2000 21:14:21 -0700, Dennis Lee Bieber declaimed the following in comp.lang.python: > > > "The server does not have a DNS entry" (as reported by netscape, > and for once it is not my ISP having problems -- I can hit other pages > fine). Maybe it was my ISP; I could hit it today, and noticed all the "loading..." messages had "home.netcom.com" in them, and I have an ix.netcom.com account (which was sucked up by mindspring, only to be sucked up by earthlink...). -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From giem_I_AM_SINGING_IN_THE_RAIN at free.fr Sun Jul 23 05:10:06 2000 From: giem_I_AM_SINGING_IN_THE_RAIN at free.fr (Jm) Date: Sun, 23 Jul 2000 09:10:06 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> Message-ID: <397ab732.1184204@news.proxad.net> Do you have a link to it, or at least the name of that interpreter ?? -- On Thu, 20 Jul 2000 20:36:49 +0200, "slauijssen" wrote: >Err, by the way >On a linux cd I found a C++ interpreter. The funny thing is that the >interpreter itself is written with c++ and interprets itself to interpret >the really to interpret code. Got it? ;-) > >Mallor schreef in berichtnieuws >v62d5.580$GQ1.26151 at newsread2.prod.itd.earthlink.net... >> Are any of you game developers out there using Python as your game >engine's >> embedded scripting language? I am wondering what drove your decision to >use >> Python instead of other embeddable scripting languages? I'd like to hear >what >> your overriding concerns were, and also what they are now, having put >Python to >> the test. >> >> -- >> Cheers, Infernal Troublemaker Troll >> Mallor "By simple mistake, mortals themselves amuse." >> >> >> > > From ajm at enteract.com Wed Jul 12 23:44:13 2000 From: ajm at enteract.com (Alan Miller) Date: Wed, 12 Jul 2000 22:44:13 -0500 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> Message-ID: Lars Lundstedt (lars.lundstedt at telia.com) wrote: >The subject line says it all. How do I do it? >Anyone who knows? import string, os drivelist = [] for driveletter in string.uppercase: if os.path.isdir(driveletter + ":\\"): drivelist.append(driveletter) print drivelist From dalke at acm.org Fri Jul 7 15:08:47 2000 From: dalke at acm.org (Andrew Dalke) Date: 7 Jul 2000 20:08:47 +0100 Subject: Python Module for sequence alignments. References: Message-ID: <8k0nte$l14$1@slb0.atl.mindspring.net> Alex wrote: >Hi. I made a python module that does simple sequence alignments. If >there is enough interest, I may make it a little more elaborate. You >can get it from > >http://puffin.lcs.mit.edu:8080/align.tgz By the way, you may be interested in biopython.org, which is developing a set of libraries and tools for bioinformatics and related fields. You may also be interested in the Bioinformatics Open-Source Conference which really should include your disclaimer concerning Giant Super-Intelligent Man-Eating Lizards. Andrew dalke at acm.org From pehr at pehr.net Thu Jul 20 01:20:51 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 20 Jul 2000 05:20:51 GMT Subject: Getting local IP address... References: <200007190105.LAA27331@xevious.dstc.monash.edu.au> Message-ID: <39768C32.EFB576B0@pehr.net> I would be *very* interested in a module that made it easy to access low-level interface information. There are a few goodies python excludes, for better or worse, in the name of cross-platform portability: 1. localhost IP addresses, 2. MAC addresses for ethernet interfaces, 3. listing available PPP addresses with an interface to connect / disconnect. 4. raw_sockets support. I haven't delved deeply enough to know why this is excludeded but for embedded development it is *really* handy. 5. Built-in library for cross-platform serial device interfaces. This is one we are starting to put together at work. We currently do a lot of development that looks as follows: python --Ethernet--> lantronix --RS232--> embddded device Imagine a serial port interface for python that could talk to linux serial ports, windows serial ports, and ports accross a network using a terminal server! -pehr David Arnold wrote: > > -->"Stephen" == Stephen Hansen writes: > > Stephen> Um, jeez. I'm rather surprised by these responses -- I > Stephen> assumed it was some simple little function somewhere I was > Stephen> missing. > > sadly not. in the simple case, gethostbyname(gethostname()) will do > what you want, but for machines with multiple interfaces it's not > guaranteed to get you a useful IP address. > > this is particularly the case for a machine with a dialup PPP link, > and a local ethernet card using (just to exhibit some more complexity) > a NATed private address range. in this case, it's likely that the > reverse lookup on the hostname would return the NATed address, which > is useless to external hosts. > > the third approach has load implications, but is at least portable and > reliable ... > > i've been looking at the available facilities (under Unix) for finding > interfaces and addresses, and it's reasonably arcane, and has a lot of > portability warning, but it's tempting to write a small module to > expose the functionality. > > one complication i found today is that h2py (needed to get the > constants for use with ioctl()) doesn't support multi-parameter > macros, and consequently IOCTL on Solaris doesn't work ... > > anyone have plans to extend h2py for 1.6/2.0 to support multi-arg > macro translations? > > anyone interested in a general interface info module? > > d From cg at gaia.cdg.acriter.nl Wed Jul 26 13:45:59 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 26 Jul 2000 19:45:59 +0200 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> Message-ID: <8ln84n$380$1@gaia.cdg.acriter.nl> David Arnold said: >it's impressive how much hype can be generated for a product that is >still years away from general release ;-) > ...and is soooo innovative that it does exactly the same thing as Java and the JVM, only five years later and at the vaporware stage. There's only one company that can pull this off, and I sincerely hope they'll choke in it this time. (http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html, support /that/ many stuff on your little VM, M$). ... happily going back to Java, Python, SmallTalk, Scheme, XML and whatnot on top of HotSpot..., Cees -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From aahz at netcom.com Sun Jul 16 13:40:03 2000 From: aahz at netcom.com (Aahz Maruch) Date: 16 Jul 2000 17:40:03 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <8kpavi04id@news1.newsguy.com> <8kpt05$uj6$1@slb3.atl.mindspring.net> Message-ID: <8kss1j$s39$1@slb7.atl.mindspring.net> In article , Grant Edwards wrote: >On 15 Jul 2000 14:37:57 GMT, Aahz Maruch wrote: >> >>Yeah, one of the reasons I hate AltaVista so much is because it does a >>remarkably poor job of result ranking, even by the relatively poor >>standards of search engines. > >I am reminded of something somebody once told me about network >TV: "They don't care whether you like the programs or not. All >they care about is whether their customers like their product." > >IOW: You are not the customer. You are the product. True enough -- but if I don't visit their site, I'm not product for them. I literally can't remember the last time I bothered visiting AltaVista for anything other than a quick test to see if they've improved their software, and I also warn other eyeballs away from them. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From luthi at vaw.baug.ethz.antispam.ch Fri Jul 14 07:11:22 2000 From: luthi at vaw.baug.ethz.antispam.ch (luthi at vaw.baug.ethz.antispam.ch) Date: 14 Jul 2000 13:11:22 +0200 Subject: OpenDX Python Wrapper -- any interest? References: <20000515112219.C1304991@vislab.epa.gov> <8i323b$c4s$1@nnrp2.deja.com> Message-ID: I am highly interested in this project! Martin Luethi From mfletch at tpresence.com Thu Jul 27 23:23:52 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 27 Jul 2000 23:23:52 -0400 Subject: Socket question: arbitrary port Message-ID: Oh, dang, turns out I'm a lazy person, mama'll be so disappointed :o) ! I'm wondering about the question though, and if it might be asking how to connect to a service that might be on multiple ports (port scanning)... there are cases where I've created port ranges (such as the MUVRML reserved port-range) in which services can exist. The thing is that Python alone _can't_ determine if the correct protocol is being used on the server (from the client (well, assuming we're talking something based on UDP/TCP)), so you have to do "application-level" testing to determine if you've got a usable connection (keeping in mind that in these cases you'll likely find _other_ services running on those "conflicted" ports). If it was a question related to binding (as you supposed), then the trying each port approach was the best I came up with (seems to work, I have a hundred clients on the same machine able to correctly negotiate port usage among themselves with no perceptible delay (note, these are UDP ports)). Enjoy, Mike -----Original Message----- From: Robert W. Bill [mailto:rbill at digisprings.com] Sent: Thursday, July 27, 2000 2:37 PM To: python-list at python.org Subject: Re: Socket question: arbitrary port On Thu, 27 Jul 2000, Jean Bergeron wrote: > Is it possible to connect a socket through an arbitrary port? > In other words, can Python find an available port without having the > programmer (or user) specify a particular port number? > > Any help would be appreaciated! > Thanks! > ... portNum = 1 while 1: try: s.bind('127.0.0.1', portNum) break except socket.error, why: # could analyze why here portNum = portNum + 1 ... From jesse at multimediacollective.com Thu Jul 27 13:38:49 2000 From: jesse at multimediacollective.com (jesse at multimediacollective.com) Date: Thu, 27 Jul 2000 17:38:49 -0000 Subject: retrieveing mail from a pop3 account Message-ID: <8lps39+ski@eGroups.com> Hey, I've been writing a program which connects to my Pop3 mail account, logs in, retrieves each mail in order and prints them out. (just printing to standard output for now). However, say I have two messages in my mailbox. It will print out the body of the first message TWICE. So it will use the first body message as the body of every message. Here is the code. def access_mail(host, user, password): open_mail = poplib.POP3(host) open_mail.user(user) open_mail.pass_(password) numMessages = len(open_mail.list()[1]) for index in range(numMessages): (server_msg, body, octets) = open_mail.retr(index) message_body = cStringIO.StringIO(string.join(body, '\n')) msg = mimetools.Message(message_body) print message_body.read() if __name__=='__main__': if len(sys.argv)<4: print "Usage:", sys.argv[0], "host username password" else: access_mail(sys.argv[1], sys.argv[2], sys.argv[3]) when I try to run this it comes up with this error. Traceback (innermost last): File "", line 1, in ? File "dial.py", line 36, in access_mail if __name__=='__main__': File "C:\Program Files\Python\Lib\poplib.py", line 218, in retr return self._longcmd('RETR %s' % which) File "C:\Program Files\Python\Lib\poplib.py", line 153, in _longcmd return self._getlongresp() File "C:\Program Files\Python\Lib\poplib.py", line 132, in _getlongresp resp = self._getresp() File "C:\Program Files\Python\Lib\poplib.py", line 125, in _getresp raise error_proto(resp) error_proto: -ERR no such msg Any thoughts? It is a very strange problem, and none of us seem to be able to figure it out. From fiona at sitegnome.com Wed Jul 12 04:05:50 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 12 Jul 2000 08:05:50 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 12th, 2000 Message-ID: <20000712080550.29655.qmail@synop.com> Greetings, Here are the latest entries to be entered into http://python.faqts.com regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- How do you read from / write to the system clipboard from Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/4668 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain I presume that you want to paste or copy into or out of an entry or text, these widgets already have copy and paste keystrokes assigned to them (at least they do on windows). So I can do Control-c and that copies it into the clipboard and Control-p pastes it. so: from Tkinter import * root=Tk() text=Text(root) text.pack() root.clipboard_clear() root.clipboard_append('python rules!') def paste(event): text.event_generate('') text.bind('',paste) root.mainloop() In this example we append your 'python rules!' to the clipboard and then wait until the text control gets the focus and then we generate a event to paste the contents in. ------------------------------------------------------------- What's the Python equivalent for C's #include "myfile.h"? http://www.faqts.com/knowledge-base/view.phtml/aid/4669 ------------------------------------------------------------- Fiona Czuczman Rainer Deyke, Matthew Schinckel The standard substitute is: >>> import myfile or >>> from myfile import * However, this is not quite equivalent to #include. If you really need behavior identical to #include, you could try the following: exec open("myfile.h").read() ------------------------------------------------------------- How can I enumerate drives (local and network) in Python? http://www.faqts.com/knowledge-base/view.phtml/aid/4670 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain On Win32 you can use: import win32api,string drives=win32api.GetLogicalDriveStrings() drives=string.splitfields(drives,'\000') print drives GetLogicalDriveStrings returns a string with each drive null terminated so you can use the string module to separate them into a list. There is also a win32api.GetLogicalDrives() which returns a bitmask where each bit represents a drive letter, so 1101 (or 13 in decimal) would represent (going from right to left) a:\,c:\ and d:\. ------------------------------------------------------------- What is the difference between the calls PyObject_GetAttr and PyObject_GetAttrString? http://www.faqts.com/knowledge-base/view.phtml/aid/4671 ------------------------------------------------------------- Fiona Czuczman Thomas Wouters PyObject_GetAttrString takes a PyObject pointer and a char pointer, whereas PyObject_GetAttr takes two PyObject pointers: the second argument should be a PyString, which is then turned into a char pointer (using PyString_AS_STRING) and passed to PyObject_GetAttrString. ## Edited Entries ############################################## ------------------------------------------------------------- How can I create a stand alone "win32" executable file from a python script? Is a compiler available anywhere for python for win32? http://www.faqts.com/knowledge-base/view.phtml/aid/3111 ------------------------------------------------------------- Fiona Czuczman Daley, MarkX http://starship.python.net/crew/gmcm/index.html This link will provide you with a pretty good wrapper that gives you a one-file installer executable. I'm pretty sure it's win32. From jeroen at valcke.com Mon Jul 17 11:01:06 2000 From: jeroen at valcke.com (Jeroen Valcke) Date: Mon, 17 Jul 2000 15:01:06 GMT Subject: automatically filling web forms? References: <20000717071134.A2351410@vislab.epa.gov> Message-ID: Whaaw, great, although I'm a newbie to python I managed to write to a cgi script in a matter of minutes. I had read about python, and it is true: this is powerful stuff! I'm hooked. I'm going to learn python. Thanks for this sample code, it helped me alot! Still, have some questions though. Another cgi script that I'm trying to write to doesn't work. The python program hangs and just waits until I terminate it. Any idea. Somebody mentioned that on that particular site you can't write to their cgi scripts. It is only possible to use that script from within there own pages. Is that possible? Also, a small question about the code what about the file you open in the code, is that to write results? because the file never gets created when i run the program, I don't need results too. -- Jeroen Valcke jeroen at valcke.com ICQ# 30116911 Home page: http://users.pandora.be/valcke/jeroen/ The best glimpse of heaven ... is on the way into hell. From rumjuggler at cryptarchy.org Fri Jul 28 23:19:30 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 03:19:30 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: On Sat, 29 Jul 2000 00:52:33 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 19:29:52 -0400, Karl Ulbrich wrote: >>If they already contained numbers (well, strings of digits), and you were >>certain, then simply: > >> a = int(b) > > As stated, that would work except Python returns a None on a no-match and >None can't be converted. def REint(i): if i is None: do whatever you want in this case. return int(i) -- Barnabas T. Rumjuggler Now, most of y'all be thinkin', "Tha H-Dog, he know his bidness." And thas right, man. Shit need addin'? I creep in, adds tha shit up, and slip out, quiet as a muthafuck. Variance need resolvin'? It be gone without a trace. Uh-huh. Only a wack-ass fool ask someone besides tha H-Dog to accountz-receeve they shit. -- Herbert Kornfeld, Accounts Receivable Supervisor From grey at despair.rpglink.com Fri Jul 28 11:27:37 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:27:37 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 09:08:31 GMT, Ben Wolfson wrote: >How is assigning what is rather clearly a number the type "number" >arbitrary? Uh, because a number can be a sequence? I thought that was rather obvious. You keep interchanging what Python defines as a sequence as what is a sequence. Python has defined that 1 is not a sequence even though if I put down 1 on a blackboard, ask a classroom of people to identify that sequence, they will say 1. Just because Python doesn't recognize a sequence there doesn't mean there isn't one there to be recognized. >I read it, I just didn't see the point in the entire paragraph being there >if you weren't making some implicit criticism of the current system. No, it was to point out that such "odd" behavior in moving from simple to complex back to simple is to be /expected/. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From david_ullrich at my-deja.com Mon Jul 3 13:37:45 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Mon, 03 Jul 2000 17:37:45 GMT Subject: Bug in math.frexp? References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> Message-ID: <8jqj17$rl0$1@nnrp1.deja.com> In article <14688.12945.528521.351944 at cj42289-a.reston1.va.home.com>, "Fred L. Drake, Jr." wrote: > > Tim Peters writes: > > The docs are wrong. I just checked in a repaired version of mathmodule.c. > > Fred, would you please get the truth into the Library Reference Manual's > > math module docs too? > > --sigh-- > So are the Solaris and Linux man pages wrong, or just confusing? I found some Linux docs on this that said "If the argument x is not zero, the normalized fraction is x times a power of two, and is always in the range 1/2 (inclusive) to 1 (exclusive)." This is not just wrong or confusing, this is _impossible_ if x < 0; a negative number simply is not a power of two times a number in the range [1/2, 1). DU > Ok, I'll have something like your docstring checked in shortly. > > -Fred > > -- > Fred L. Drake, Jr. > BeOpen PythonLabs Team Member > > Sent via Deja.com http://www.deja.com/ Before you buy. From pj at sgi.com Mon Jul 31 18:36:00 2000 From: pj at sgi.com (Paul Jackson) Date: 31 Jul 2000 22:36:00 GMT Subject: How does Python compare to ? References: <3FF3ED6EC164DBD2.77C81740D77CD9FA.D247DC7D74D3B365@lp.airnews.net> <8m4bo1$3le2$1@nntp6.u.washington.edu> Message-ID: <8m4v0g$bcbbu$1@fido.engr.sgi.com> Donn Cave, donn at u.washington.edu wrote: |> But it has to be partly the interpreter too. Good grief - does it ever. On my setup at least, Python startup is much worse than Perl. Summary: Python does a lot more work loading modules at startup, for even the most trivial program, than does Perl. 1) On SGI Irix 6.5.9m and 180 MHz R5000 MIPS: Perl startup: 13 msec Python startup: 196 msec 2) On SuSE 6.3 Linux and 400 MHz Pentium II: Perl startup: 9 msec Python startup: 60 msec where startup is measured from the time libc loads, until the time 'real work' begins (the interpreter reads the print command and writes "hi"). Below, I analyze the startup in more detail for the Irix case. The Linux case is similar, except that proportionately more time is spent waiting for file system calls, and less cpu-bound in the application (my Linux box has a faster processor). All numbers are from "hot" runs -- after first repeating the same command a few times to get all files accessed into the buffer cache. The "cold" buffer times for python also seem to be much worse than perl, which is not surprising, given the larger number of files python attempts to access at startup. Comparing Perl and Python startups on a system: SGI Irix 6.5.9m on 128MB 180MHz R5000/SC O2 using versions: Perl: perl5 (5.0 patchlevel 4 subversion 4) Python: Python 1.5.2 (#25, Jun 11 1999, 16:45:34) examining the startup of the two using 'par' to run the following: echo 'print "hi"' | perl echo 'print "hi"' | python I see that between the time libc is dynamically loaded (at about 6 msecs after the execve()) until the time that perl/python get down to business (read the echo'd program and write "hi\n"), there is a _big_ difference between perl and python. Perl: In this interval, perl does just the following 13 milliseconds worth of stuff: 6mS sysinfo(_MIPS_SI_PROCESSORS, 0x7fff2d20, 257) = 10 7mS open("/usr/lib32/libperl.so.4.4", O_RDONLY, 05) = 4 7mS read(4, <...>..., 512) = 512 7mS elfmap(4, 0x7fff0f50, 2) = 0x97f0000 8mS close(4) OK 8mS open("/usr/lib32/libm.so", O_RDONLY, 05) = 4 8mS read(4, <...>..., 512) = 512 8mS elfmap(4, 0x7fff0f50, 2) = 0x94e0000 9mS close(4) OK 10mS syssgi(SGI_TOSSTSAVE) OK 11mS getpagesize() = 4096 11mS brk(0x10015000) OK 11mS syssgi(SGI_USE_FP_BCOPY, 0, 0x181, -1, 0x180, 0) = 0 12mS brk(0x10025000) OK 13mS getuid() = 2324, euid=2324 13mS getuid() = 2324, euid=2324 13mS getgid() = 20 egid=20 13mS getgid() = 20 egid=20 14mS time() = 965078506 14mS getcontext(0x7fff29d0) = 0 18mS getpid() = 1147056, ppid=1142422 19mS ioctl(0, __OLD_TCGETA, 0x7fff0170) errno = 89 19mS read(0, "print "hi"\n", 4096) = 11 Python: In the same interval, python does some 196 milliseconds worth of stuff, including 52 open attempts, 34 stat attempts, 67 sigaction calls, 12 fstat's, 20 close's, 27 brk's, ... The opens are mostly to open some 10 modules, where each module open requires about 4 attempts, for spam.so, spammodule.so, spam.py and spam.pyc. The modules being loaded are: exceptions, site, os, posixpath, stat, UserDict, and about 4 variants of site-customize (under the main python1.5 directory, as well as under plat-irix6, lib-tk and lib-dynload). The stat's are for each of these potential modules, plus looking for the file 'python' in every directory on my $PATH, plus 4 stats in the subtree "/usr/lib/locale/C". Most of the elapsed time, however, does _not_ seem to be in waiting on the system for the above calls (the file calls were quick - several per msec - out of cache). Rather most of the time seems to be cpu bound, just after reading in one of the modules. Often, some 10-20 msecs go by, marked only by a close() call or two, such as when python is reading a couple of nested modules, such as stat and posixpath, and closes the child module while still plugging away on the parent. The stat() search for the python file along $PATH comes early (before loading modules) and the sigaction() calls come just after loading the exceptions module. -- -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From tim.hochberg at ieee.org Tue Jul 18 16:34:27 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Tue, 18 Jul 2000 20:34:27 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <39745372.EDCBF4FF@fft.be> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: > Maybe Travis can answer this: how is transpose implemented in NumPy today? > Does it produce a new copy or just changes the indexing? I'm not Travis, but I'll answer anyway: it just changes the indexing. -tim From MarkH at ActiveState.com Mon Jul 3 19:22:38 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 03 Jul 2000 23:22:38 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> Message-ID: <2f985.6708$Tb7.40527@news-server.bigpond.net.au> "Alex Martelli" wrote in message news:8jqbru017gf at news2.newsguy.com... > I believe the only relevant issue for the Python community > is: C#, like every other Microsoft offering in recent times, > will be *STRONGLY* oriented to COM. Every C# object will be > a COM object (just like every Java object was one when run > under Microsoft's Java VM), etc, etc. Its a little more complicated than that! > So, C#'s possible (unlikely...) emergence as a major language > is just the N-plus-1-th motivation for Windows versions of > Python to support COM *very, VERY* well. And that! > Yeah, I know, I should put my coding efforts where my mouth > is -- and, having expended substantial efforts doing just > this sort of thing for a proprietary scripting language Please do. Typelib work may be kicking off again (if I ever clear my inbox that is - sorry John - I havent forgotten you :-) A framework for calling arbitary vtable interfaces is also in place. So what you will find is that it needs less "framework" code, and more a motivated and skilled person to pull a few of these "late" pieces together. My motivation WRT win32com now is more towards keeping the status-quo - and helping _others_ change it :-) > Re .NET -- I dunno, and I wish I did! All will be revlealed after the PDC; less than 2 weeks. I can safely say (as this is a Python language newgroup and C# is apparently a "competing" language), the Python community will probably be more interested in .NET than in C#. _Quite_ a bit more :-) > I'll do y'all a favour and summarize them into basically > two stances: > "It's Microsoft and thus evil, vapourware, immoral, > and/or fattening" > "It's Microsoft and thus good, splendid, progressive, > and/or sexy" Well put :-) > I do wonder what other items that have technical reality > are in .NET besides C#, XML, and SOAP. If any, that is. There are - and a number of them. Mark. From digitig at cix.co.uk Sun Jul 16 14:56:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Sun, 16 Jul 2000 19:56 +0100 (BST) Subject: ODMG? Message-ID: Is there any ODMG-style Object-Oriented Database system for Python? From Armin at Steinhoff_de Sun Jul 9 07:55:52 2000 From: Armin at Steinhoff_de (Armin Steinhoff) Date: 9 Jul 2000 04:55:52 -0700 Subject: Setting a C-structure from Python References: <39649D5C.F1652171@seatech.fau.edu> <3967F70C.17A90288@seatech.fau.edu> Message-ID: <8k9p88$1s19@drn.newsguy.com> In article <3967F70C.17A90288 at seatech.fau.edu>, Benoit says... > >I think I find out where the bug was. >Thanks Armin ! > >Why this C extension didn't work ? > >> >> static PyObject * test_setstruct(PyObject * self, PyObject * args) { >> PyObject * string_from_python; >> >> if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; >> >> example= (examplestruct *) PyString_AsString(string_from_python); >> Py_DECREF(string_from_python); >> print_struct(); >> >> Py_INCREF(Py_None); >> return Py_None; >> } > >Simply because the "example" pointer points to memory owned by >string_from_python it point to internal data which is actually part of the >string object. >When I "decref " string_from_python, its reference counter becomes 0, and >the string object is deleted. >So "example" points to something wrong in memory. "example" is always initialized in the context of test_setstruct() ... so it can't be the reason for your trouble. As long as "example" points to memory owned by your process ... you will read probabbly garbage, but it will not produce a SIGSEV. If you use a different variable for the second call of struct.pack/test_API all seems to be working well ... but the interpreter is already corrupted. You can see it if you terminate the interpreter with Ctrl-D ... -> it leads to a SIGSEV. I believe the real point is that you can't apply the "S" format to a "string buffer" which contains binary zeros. IMHO it corrupts the interpreter. I have changed your code in the following way: static PyObject * test_setstruct(PyObject * self, PyObject * args) { //PyObject * string_from_python; char * string_from_python; int len; // if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; if (!PyArg_ParseTuple(args,"s#",&string_from_python, &len)) return NULL; // example= (examplestruct *) PyString_AsString(string_from_python); example= (examplestruct *) string_from_python; // Py_DECREF(string_from_python); print_struct(); Py_INCREF(Py_None); return Py_None; } Regards Armin From m.faassen at vet.uu.nl Fri Jul 28 14:18:26 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Jul 2000 18:18:26 GMT Subject: The State of Python References: Message-ID: <8lsipi$hoq$1@newshost.accu.uu.nl> Moshe Zadka wrote: > On Fri, 28 Jul 2000, Paul Duffin wrote: >> What does GPL compatible mean ? > It means that it can be relicenced as GPL. Are you sure? I thought it meant you could legally link it to GPL-ed software. That's what the whole Qt/KDE squabble is about, at least. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tim_one at email.msn.com Fri Jul 28 01:24:09 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 28 Jul 2000 01:24:09 -0400 Subject: "always passes by reference" In-Reply-To: <397E5D52.AA7AB610@san.rr.com> Message-ID: [Tim] > A semi-accepted term to describe what Python (and similar > languages) do is "call by object". [Courageous] > I like "putting stuff on the argument line" better. :)- Well, yes, but I try not to get that technical because people find it off-putting . you'll-never-see-"applicative-sublanguage"-from-these-supple- fingers-ly y'rs - tim From ftian at cs.wisc.edu Mon Jul 31 16:04:24 2000 From: ftian at cs.wisc.edu (ftian at cs.wisc.edu) Date: Mon, 31 Jul 2000 20:04:24 -0000 Subject: httplib hung on read Message-ID: <8m4m48+g8f4@eGroups.com> Hi, I am using the httplib to get some webpage, it hungs sometimes in the following senario, http = httplib.HTTP('myhost') http.putrequest('GET', myurl) http.putheader(...) http.endheaders() errcode, errmsg, header = http.getreply() myfile = http.getfile() # "Still OK here" page = myfile.read() # Sometimes Cannot Reach here the page can be opened with IE, and it only hungs sometimes. Anyone know the reason? Thanks. Feng From m.faassen at vet.uu.nl Wed Jul 12 04:19:19 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 Jul 2000 08:19:19 GMT Subject: POOP / Python (Object Oriented Persistence) ? References: <002001bfea62$21eabdf0$f0c809c0@lslp7o.lsl.co.uk> <8kcqug$p32$1@newshost.accu.uu.nl> <396B975B.D821A4D3@digicool.com> Message-ID: <8kh9m7$l5m$1@newshost.accu.uu.nl> Jim Fulton wrote: [snip] Hey, look, Jim Fulton himself! :) > We've recently worked out (with help from Dr. Sushil Jajodia of > George Mason U.) a protocol for replicating ZEO storage servers. > This uses a quorum-based algorithm. Basically, you have multiple > replicated storage servers and the system is available as long as > more than half of them can communicate. It's pretty cool. Sounds like it. > See http://www.zope.org/Wikis/ZEO/QuorumBasedReplication > for gory details. :) Thanks for the link. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From pete at visionart.com Wed Jul 12 21:29:42 2000 From: pete at visionart.com (Pete Shinners) Date: Wed, 12 Jul 2000 18:29:42 -0700 Subject: Combining PyMethodDef's to create one C module Message-ID: <396D1B86.553E00B6@visionart.com> i've got a python extension in the works. the extension is split into two main C source files. i figured it would be easiest if each file has its own "PyMethodDef". then combine both these lists when creating the module with "Py_InitModule" I have not been able to find an easy way to combine these lists to create the new module. i was hoping there would be something like "PyModule_Append(PyObject*, PyMethodDef*)" Is there some way i can add the functions from one PyMethodDef into the other by getting the first one's dictionary, then adding the functions from the other one one-by-one? i think i could do this easy enough, but if someone could show me the code to take a function pointer and __doc__ string and combine them into a callable PyObject it would give me a BIG head start. From moshez at math.huji.ac.il Fri Jul 21 00:26:17 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 21 Jul 2000 07:26:17 +0300 (IDT) Subject: [ANNOUNCE] Python Enhancement Proposals on the Web In-Reply-To: <39779F05.3181C5E5@schneider-kamp.de> Message-ID: On Fri, 21 Jul 2000, Peter Schneider-Kamp wrote: > http://python.sourceforge.net/peps > > Thanks to /F who hacked up a small pep2html converter you > can browse them as hypertext rather than as the plain text > they are. > > PEPs that already carry some content include: ... > 0206 2.0 Batteries Included moshez > > Peter First of all, I'd like to thank Peter and /F. Now, if anyone sees a module/library I forgot, and thinks it would make a useful addition, please let me know. If you can do the web-research to find out where it can be downloaded from, it would increase its chances remarkebly. You don't have to tell me what it does -- I'll operate on the rule-of-thumb that if I had no idea what it does, it probably isn't that popular. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From robin at jessikat.fsnet.co.uk Thu Jul 20 03:38:35 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 08:38:35 +0100 Subject: Discussion: new operators for numerical computation References: Message-ID: In article , Tim Hochberg writes >Huaiyu Zhu writes: >Based on my ramblings I'll toss out a proposed operator set for the >pack to feed upon: > > Operator Name > .* matmul > ./ matdiv > /. matsol > .** or(?) .^ matpow > * mul > / div > %,^,&,|,** mod, xor, and, or, pow > >With broadcasting / nonbroadcasting decided by the individual packages. > >My 3 cents. > >-tim The real trichotomy is between inner, outer and element type operations (I leave out Kronecker products which many use). Using . to start an operator seems in Python to lead to all sorts of confusion A=Matrix()....; B=A.*C A=F().........; B=A.*C No way for the parser to know if the latter should be A.f*C -- Robin Becker From petersc at stud.ntnu.no Fri Jul 7 11:58:54 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 07 Jul 2000 15:58:54 +0000 Subject: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: <3965FE3D.1A202F51@stud.ntnu.no> Thomas Weholt wrote: > > try: > # some code > except : > # catch exception > finally: > # clean up whatever You can always use try: try: # some code except: # catch exception finally: # clean up whatever Not quite as elegant, but do we really need an extra syntax for that? wanting-orthogonal-persistence-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From moshez at math.huji.ac.il Thu Jul 27 01:13:25 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 27 Jul 2000 08:13:25 +0300 (IDT) Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: Message-ID: On Thu, 27 Jul 2000, Mark Hammond wrote: > Better than "VERY high" - they have already done it. MS have been > _excellent_ at listening to 3rd party language feedback. For example, the > functional language guys are very impressed that MS managed to get tail > recursion instructions in the VM, in time for the PDC. No current or > future MS languages have this requirement, and not even any of the > (expected to be successful) commercial languages - it was done exclusively > for the "little languages". Hmmm...this sounds positively interesting. Do you know if there is similar support for continuations? IOW, can Scheme be supported on IL? > But to address your point: JPython is _not_ a perfect emulation of > CPython, but it does allow you entry to the Java playground. Python .NET > is similar - I don't expect anyone will use it when they want to work in > an exclusively Python environment, just like almost no one uses JPython in > that way now... That's sad -- JPython, CPython and Python .NET should feel the *same*. That's why we have a standard (the Python Language Reference Manual). I truly hope JPython and Python .NET (is that the official name) will be similar enough to CPython that Python code will work across them seamlessly. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From MarkH at ActiveState.com Thu Jul 20 07:00:18 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 20 Jul 2000 11:00:18 GMT Subject: Python 2.0 - win32pipe routines inclusion for Windows References: Message-ID: <6ZAd5.7258$4p3.51905@news-server.bigpond.net.au> "David Bolen" wrote in message news:u66q3ovcg.fsf at ctwd0143.fitlinxx.com... > I've noticed that the latest sources for Python 2.0 in CVS have > included the win32pipe code from the PythonWin extensions as a > replacement for the prior os.pipe() routine in Python 1.5.2. One > consequence of this is that you no longer receive process exit codes > on the pipe.close() operation. Since I need the result codes in my > work, and work under Windows NT primarily, I figured I'd try to do > something about it. Great! > wondering if this is something that should just be submitted to the > SourceForge patch manager Yep. > While munging around in the source it also appears that there seems to > be a mismatch between the ordering of file handles returned by the > higher order popen# routines in the internal posixmodule (the > win32pipe routines) versus the current popen2.py library module. I > think I saw a discussion about this in the python-dev archives, but it > wasn't clear if the two should be consistent at this point in the > repository. Although I recall the discussion, I can't recall the outcome. Add this comment to the patch (but not, at this stage, the code to correct it) Mark. From mbel44 at dial.pipex.net Tue Jul 11 06:33:52 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 11 Jul 2000 11:33:52 +0100 Subject: POOP / Python (Object Oriented Persistence) ? References: <8kcqug$p32$1@newshost.accu.uu.nl> <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> Message-ID: "Tony J Ibbs (Tibs)" wrote: >OK - I spent some of my "spare" time last night reading > >http://starship.python.net/crew/amk/python/writing/zodb-zeo.html > >and also Jim Fulton's Introduction to the Zope Object Database (referenced >therefrom, although I found it by other means first), and also with a quick >look at the ZODB How-To. > >Gosh. Damn time machines have been at it again. Ask for something and it >will have been there. >Given the Python world, I would believe that it will expand >to cope with any problems that crop up in a practical manner. Too true.... >Snags. >Well, it's obviously a bit of a pain if __getattr__ and __setattr__ are >unavailable for easy use - although I can't say I've used them for anything >significant myself, they're useful tools for the back pocket. As of very recently, __getattr__ and __setattr__ do mix with ZODB persitent objects :-) Toby Dickenson tdickenson at geminidataloggers.com From hzhu at localhost.localdomain Mon Jul 17 16:37:59 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 17 Jul 2000 20:37:59 GMT Subject: Parser project References: <397361C5.1D401DF2@prescod.net> Message-ID: On Mon, 17 Jul 2000 14:43:01 -0500, Paul Prescod wrote: >Here is a project for a parser hacker: This is a good idea, although MatPy could not wait for it to happen, and I do not foresee much additional syntax being requested. For the current matrix issue, a limited parser might be easier and more useful. The only bottleneck here is that the supply of binary infix operators is very limited, unlike function or method names. This forces people to write latter when the former is much cleaner. Why not write a parser that changes nothing else but allows additional binary operators? By definition, it would put all the special symbols stuck together as operators, like +=, -=, :=, @+, .*, @*=, etc. Someone had proposed allowing general forms a op b but I would think limiting op to consisting only the symbols that are not in other syntax constructs (like parenthesis, numbers, names, etc) is warranted. This would still give quite a few dozen operators, far more than needed, imo. I'm not sure if it can be made as easy as import NewOperator NewOperator.define(".+", "__dotadd__") class A: def __dotadd__(self, other) ... a=A(); b=A() a.+b NewOperator.define("compares", "__cmp__") ------> Exception: "compares" contains characters not allowed in operator. That would be useful in many domains. Huaiyu From no at bo.dy Wed Jul 19 20:14:15 2000 From: no at bo.dy (nobody) Date: Wed, 19 Jul 2000 19:14:15 -0500 Subject: iterating over lines in a file Message-ID: assume i want to iterate a block of code over every line in a text file, and that i don't want to snarf the whole thing into memory for fear of coredumps or whatever. in perl (and many others) there is a simple, common idiom: while (line = ) { block; } this doesn't seem to have a simple, direct analog in python. searching around on the web i found a solution at faqts.com (though this newbie might like to see it explained, but whatever works): class Reader: def __init__(self, source): self.source = source def readline(self): line = self.source.readline() self.line = line return line # may be empty, thus false file = Reader(open("filename")) # i might have got this worng...? while (file.readline()): line = file.line now, this seems to me like an awful lot of typing just to get around the fact that assignments in python do not seem to be expressions returning the value assigned. since that is thus in several other languages, and since it gives rise to several common idioms of this type, i can only assume that there must be some good reason for breaking this pattern in python; i just can't see what it could possibly be. could somebody enlighten me, please? and is there any easier way to iterate over lines in a file without resorting to ugly break statements? From ejr at lotus.CS.Berkeley.EDU Fri Jul 21 14:04:40 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 21 Jul 2000 18:04:40 GMT Subject: [long and fussy] But what do these operators _mean_? References: <8l899g$6f5$1@agate.berkeley.edu> Message-ID: <8la3bo$b55$1@agate.berkeley.edu> And Huaiyu Zhu writes: - >Quick summary: Maybe there needs to be a numerics-sig before any - >of these changes are adopted... - - Yes. So how do we get one started? Maybe I can finally have an excuse to dig into Python's code... And if there is one, I hope we have some folks who have to deal with platforms that have problematic IEEE support (Alphas) or none (Vaxen, but not the Cray vector boxes) on it for reality checks. - Concerning the semantics of these operators, I think we only need a - general agreement, leaving out algorithmic specifications to various - packages. I'm not so sure. My experience on the periphery of the BLAST group has shown that general agreement has to be backed up with some guaranteed, TESTABLE error bounds to be reliable. - The advantage of Python over Matlab really shows here: Only the - association between .* and __dotmul__ would be built into the - language. Moderately recent versions of Matlab have operator overloading. This has even been used to make a `parallel' Matlab, http://www.ai.mit.edu/projects/ppserver/ If anything, that's made the confusion on what things mean worse. If you don't associate some reasonable error bounds, some well-meaning soul will quietly provide a heavily optimized routine that works well for 99% of the cases, but is wrong on 1%. Like I said, tracking the resulting bugs down in real code is a terrible ordeal, if you even happen to find that 1% before it's deployed. - Whichever package you import you'll know its complete specification. Yes, but what if you didn't import it? What if you're providing a routine someone else is using, and they import one with numerically poor routines? They then file a bug report, and you blow a _lot_ of time determining who's problem it is. This does happen in real life. And too often the bug report is never resolved, leading to things like probes crashing into Mars rather than landing gently... - The advantage is that this allows natural migration towards better - algorithms without breaking any existing code. (Cf the migration - from regex to re.) Ok, I think my examples were misleading. I don't care about the exact implementation. I care about the error bounds. In the regex v. re case, well, they both had the same error properties: none. (Ideally.) - Imho, the only possible resolution on this is to only provide pure - math definition of these operators in the core language, leaving - numerical specification to the packages that implement them. You should not rely on the pure math definition because it assumes exactness. Besides what is the ``pure math definition'' of some of your operators? Is left division defined as A^(-1) * B, or as the solution of the linear equations in A against the right-hand sides in B? The former would lead me to believe it's very loose; I'd _never_ use it for numerical work. You'll notice that Matlab states how they are computed (elimination or least-squares). What I'd shoot for is a statement of exactly what problem is solved along with a guaranteed error bound. - No one could prove that any of the numerical algorithms used today - would be optimal forever, anyway. Yes, we can. The new eigenvalue routine from Dhillon and Parlet _is_ theoretically optimal; it's O(n) for n eigenvalues with error bounds as small as is possible. And there's not much to shave off in the implementation, either. It might well be the end of the story for the symmetric case; the damn algorithm just makes so much sense once it's explained. The only way to change its optimality would be to attack the arithmetic assumptions. Recent work is leading people to believe that there aren't many sensible arithmetics possible. IEEE754 is slightly over-specified, but only to help the user. On the flip side, matrix inversion is still open. Kinda neat that it's so much harder... The theoretical minimum is O(n^2) for the general case, as you have to fill n^2 entries. The best ones are related to the best matmuls, but I can't remember Winograd's best one right now. Unfortunately, the best ones aren't numerically reasonable. Even Strassen's recursive matmul isn't stable. And I'm not looking for the best possible error bounds, just currently feasible ones. Those are available, and any better algorithm must beat them to be considered better. Also, the error bounds given in the LAPACK and BLAST docs have been achieved with very fast implementations, so it's not that much of a burden. - Agreed. Although this is not the topic here, it is really a big - drag. How do Octave handle this on all platforms? Not well: > bool > xisnan (double x) > { > #if defined (HAVE_ISNAN) > return isnan (x) != 0; > #else > return false; > #endif > } A better test (guess I gotta send in a patch now that I've seen this) would be to return !(x==x) instead of false. That should work on any IEEE platform and fall through on any other platform unless the compiler does something silly. Unfortunately, many compilers do. They probably have a reason why they haven't done that; it's a fairly standard idiom. I won't have time to test and ask until next Wednesday. Probably is the over-zealous compiler issue. - I support the idea that Python should use IEEE whenever possible, - as I don't buy Java's philosophy of using the common minimum of - every platform. THANK YOU. ;) However, I can see the sense in providing a common minimum environment that's good for many, so long as you do not restrict access to better features. The goal is not to turn everyone into numerical analysts, but rather to make numerical analysts as unnecessary to daily life as possible. That takes guaranteed, testable error bounds. Even though most users won't know what they mean, test suites can keep implementors honest. And, imho, the default should always be accuracy before speed. You can always compute a wrong answer very quickly. - Would a NonIEEEError be possible? That might help users on those - platforms to invoke their own error handling routines by catching - this exception. That will take some thought, and these results aren't always errors. Sometimes they carry important information. There probably needs to be a full FP environment system, vaguely like C99's or Common Lisp's. - Unlike matlab that is not object oriented, [...] It has been for the past few years. The competition is not standing still. - For really precision or efficiency critical applications, I think - nothing beats special subclass where the user can fine tune the - definition of every methods. True, but I feel it's important to have a standard minimum level of expectation in terms of definitions and error bounds. People who do not meet that for various reasons need to say that loudly, preferably by using a slightly different interface. Keep in mind that I'm not against someone using faster, less accurate routines when they absolutely know they can. That can be terribly necessary and useful in some areas (signal processing comes to mind). I'm just for ensuring that the vast majority of people never need to think about it. Matlab's popular because people don't need to think about many of the lower-level details. Unfortunately, the lower-level details frequenty come up an bite people. (Ok, I don't have any numbers to back up `frequently', and I only hear of the cases where things fail, but still...) That and the huge number of supporting packages. Jason From none at none.com Sun Jul 30 03:11:01 2000 From: none at none.com (J P) Date: Sun, 30 Jul 2000 07:11:01 GMT Subject: ftp and lowercase? References: <39832544.2E05FCFB@online.no> Message-ID: <9yQg5.21128$5N1.752914@newsread1.prod.itd.earthlink.net> Have you tried sendcmd ("ls") ? I think that would work for you. "Stein Surland" wrote in message news:39832544.2E05FCFB at online.no... > I have made a small script using ftplib to retrieve a list from a ftp > directory. It worked OK using ftp.retrlines('LIST', lines.append). > However using it on another ftp host gives me this message: > > ftp.retrlines('ls', lines.append) > File "/usr/lib/python1.5/ftplib.py", line 345, in retrlines > conn = self.transfercmd(cmd) > File "/usr/lib/python1.5/ftplib.py", line 285, in transfercmd > return self.ntransfercmd(cmd)[0] > File "/usr/lib/python1.5/ftplib.py", line 273, in ntransfercmd > resp = self.sendcmd(cmd) > File "/usr/lib/python1.5/ftplib.py", line 228, in sendcmd > return self.getresp() > File "/usr/lib/python1.5/ftplib.py", line 201, in getresp > raise error_perm, resp > ftplib.error_perm: 500 'LS': command not understood. > > The host did not take the LIST command so I changed it to LS and ls. It > seems that the ftplib sends the list command in uppercase. How to change > this to lowercase? I have ftp'ed to the host and it does not recognize > LIST or LS only ls. > > Stein > > -- > > Stein Surland Trying is the first step towards failure > ssurland at online.no - Homer Simpson > http://home.online.no/~ssurland/ > From vartan at leland.stanford.edu Wed Jul 19 16:25:30 2000 From: vartan at leland.stanford.edu (Ryan Vartanian) Date: Wed, 19 Jul 2000 13:25:30 -0700 Subject: Tkinter Problem with Radiobuttons References: <3974E55A.FED978BD@leland.stanford.edu> <8l3lac$68q$1@nnrp1.deja.com> Message-ID: <39760EBA.E4FDEECC@leland.stanford.edu> Richard- Thx a lot, this has fixed my problem, and made IntVar and the Var types in Tkinter a lot clearer. Ryan richard_chamberlain at my-deja.com wrote: > > Hi Ryan, > > You are getting the value of self.selection as if it were a variable > rather than a class. To get the current value of self.selection use > self.selection.get(). An example: > > from Tkinter import * > root=Tk() > > selection=IntVar() > nativeButton=Radiobutton(root,text="Native: CFD Datasets produced on > this OS", > variable=selection,value=0) > bigEButton=Radiobutton(root,text="Big Endian: Solaris,SGI, Motorola", > variable=selection, value=1) > littleEButton=Radiobutton(root,text="Little Endian:Intel, DEC", > variable=selection,value=2) > def Ok(): > print 'This is selection.get():',selection.get() > print 'This is just selection:',selection > okButton=Button(root, text="Ok", command=Ok) > nativeButton.pack(anchor=NW,side=TOP) > bigEButton.pack(anchor=NW,side=TOP) > littleEButton.pack(anchor=NW,side=TOP) > okButton.pack(anchor=NE,side=TOP) > > root.mainloop() > > Notice the two print statements in Ok(), one returns the PY_VAR which > is how IntVar represents it self. > > Richard > > In article <3974E55A.FED978BD at leland.stanford.edu>, > Ryan Vartanian wrote: > > > > I am trying to use radiobuttons to select a value for a program, and I > > am haveing trouble with the IntVar() and StringVar() classes. > > > > My code looks like this: > > > > self.selection=IntVar() > > self.nativeButton=Radiobutton(self.byteWindow, text="Native: CFD > > Datasets produced on this OS", variable=self.selection, value=0) > > > > self.bigEButton=Radiobutton(self.byteWindow, text="Big Endian: > Solaris, > > SGI, Motorola", variable=self.selection, value=1) > > > > self.littleEButton=Radiobutton(self.byteWindow, text="Little Endian: > > Intel, DEC", variable=self.selection, value=2) > > > > self.okButton=Button(self.byteWindow, text="Ok", command=self.Ok) > > self.cancelButton=Button(self.byteWindow, text="Cancel", > > command=self.Cancel) > > > > All of this is packed in window, and things when I select a given > > radiobutton, the value of the variable is not 0, 1, or 2, but PY_VAR0, > > PY_VAR1, or PY_VAR2. The documentation for IntVar() is sparse at > best. > > Any suggestions on what is going on here? > > > > Ryan Vartanian > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From alex at magenta.com Thu Jul 6 03:52:44 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 6 Jul 2000 09:52:44 +0200 Subject: Accessing ASP-IIS objects in modules References: <8k0egu$ujn$1@nnrp1.deja.com> Message-ID: <8k1e340l3f@news2.newsguy.com> wrote in message news:8k0egu$ujn$1 at nnrp1.deja.com... > I am using Python in ASP under Microsoft IIS. I can use the IIS objects > like Server, Request and Response easily in my ASP script but cannot > access them from a module. > > For example I want to use Response.Write("blah") from within a module > (called from an ASP script) but Reponse is not a known object from > there. > > Any ideas? Passing these as arguments to the module's functions that you're calling seems cleanest to me. One alternative might be to add references to them to the __dict__ of the module you want to use them from, a la themodule.__dict__['Response']=Response from the ASP script, but that doesn't seem very clear/clean... or maybe something like: themodule.Response = Response is better. Similarly operating with the __builtin__ module might be worst from the POV of clarity and cleanliness, but, if you have LOTS of modules that MUST directly access such global objects... (warning: haven't tried any of these -- check if they work!-). Alex From MarkH at ActiveState.com Tue Jul 25 20:18:08 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 26 Jul 2000 00:18:08 GMT Subject: Memory management References: <8lkdh5$qpm$1@news.rchland.ibm.com> Message-ID: <47qf5.12035$4p3.93361@news-server.bigpond.net.au> "Michael Hudson" wrote in message news:m3zon6asl3.fsf at atrus.jesus.cam.ac.uk... > I'm guessing that you have reference cycles; these can be fun to find, > and even more fun to eliminate. However the code you posted didn't > create any cycles, so either post some more, or go and stare at your > code some (ask Gordon about the "hypnotising bricks" approach...). It is well worth tracking down Tim Peters' "Cyclops" module - has found many a reference leak for me. Cyclops.py doesnt appear to be in the Python CVS tree - I think it should! Mark. From falk.lehmann at gmx.net Fri Jul 21 17:25:20 2000 From: falk.lehmann at gmx.net (falk.lehmann at gmx.net) Date: Fri, 21 Jul 2000 21:25:20 GMT Subject: compiling Python 1.6a2 using VC++ 6.0 References: <8l0n61$vlj$1@nnrp1.deja.com> Message-ID: <8laf3d$15m$1@nnrp1.deja.com> > The problem seems to be HASHINFO, the rest is most likely errors > depending on this. > > do a search in file after HASHINFO and you will probably find it in > some include file. Then include this and it should work... I already did that. but didn't help. HASHINFO is defined in db_185.h. if I include this file too, than there are some types declared in a different way. If just include this file instead of db.h, some things like "@u_int8_decl@" are not defined and the preprocessor/compiler complains about the "@". Any idea what to try next? Falk Sent via Deja.com http://www.deja.com/ Before you buy. From spam at spam.com Sun Jul 30 19:55:02 2000 From: spam at spam.com (Penfold) Date: Mon, 31 Jul 2000 00:55:02 +0100 Subject: Windows DDE Server via Python References: Message-ID: This is fairly easy using the dde module that comes with Mark Hammonds ever invaluable win32all distribution. [http://starship.python.net/crew/mhammond/]. Once you've grabbed it look at files in the win32/demos/dde subdirectory of your Python directory. You'll see connecting as a DDE client is a piece of cake. I'm not sure how warm/hot DDE links can be implementing using it but static requests and Execs are no problem. Des. [cosi@*REMOVESPAM*operamail.com] d. savitsky wrote in message news:V5Qg5.89374$dF.3137888 at news1.rdc1.il.home.com... > has anybody ever connected to a Windows DDE Server via Python? is it > something i should do or not? > > i have a .dll that does it for me and i just use windll (god bless Sam > Rushing), but the dll is written badly (i.e. it crashes often from python, > vb, c++, anything really, and doesn't give much in the way of error > messages) so i thought i might skip the middle man - although it could be > the server itself that sucks ... > > thanks for any suggestions, > > doug > > From tim at pnorthover.freeserve.co.uk Fri Jul 21 13:35:05 2000 From: tim at pnorthover.freeserve.co.uk (Tim Northover) Date: 21 Jul 2000 18:35:05 +0100 Subject: Railroad generator Message-ID: I'm currently trying to understand the python source (I've cracked the parser generator I think), but in the Grammar file it mentions a railroad program. I've found the railroad.ps file on www.python.org, but it says it is for an old version and I think this would confuse me when I get things working. I couldn't find any mention of this program on the internet so does anyone know where I could find either it or an up to date .ps file? Thanks. Tim N. From johngrayson at home.com Sat Jul 15 09:54:28 2000 From: johngrayson at home.com (John Grayson) Date: Sat, 15 Jul 2000 13:54:28 GMT Subject: help with tkinter coding References: <396FDD54.E2DD84FF@structurex.net> Message-ID: <8kpqee$7jn$1@nnrp1.deja.com> In article <396FDD54.E2DD84FF at structurex.net>, walter hanagriff wrote: > i got this file from a person on the list not too long ago, thanks for > this, it is better then what i was thinking of before > just 2 questions: > first, how can i make the frame that is to the right of the first one > appear on the bottom of it instead > second, how do i write more then just a label into the second frame, > in the second frame is going to be a new set of options depending on > which option was picked in the first frame, so how do i do that? > this code works as a standalone > > -- File test.py > #!/usr/bin/python > from Tkinter import * > > class Main: > def __init__(self, root): > # The top label. > text = 'this program figures the area, perimeter, and power of > n' > text = text + '\n' + '_'*len(text) > Label(root, text=text).pack(side=TOP, fill=X) > > # The 'main' panel to command the option frame to show. > self.var = StringVar() > self.var.set('power') > main = Frame(root, bd=2, relief=SUNKEN) > Radiobutton(main, text="1 = Find the power of a number", > value='power', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Radiobutton(main, text="2 = Find the area of a shape", > value='area', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Radiobutton(main, text="3 = Find the perimeter of a shape", > value='perim', > command=self.update_frame, > variable=self.var).pack(anchor=W) > Button(main, text="Close", command=root.destroy).pack(padx=10, > pady=10) > main.pack(side=LEFT, padx=5, pady=5) > > # Create 3 frames, one for each option. > self.frames = { 'power': Frame(root), > 'area': Frame(root), > 'perim': Frame(root) } > > # Populate the option frames at your convenience. > prefix = 'this frame is where you put information to get ' > list = (('power', 'power of n'), > ('area', 'the area of a shape'), > ('perim', 'the perimeter of a shape')) > for (frame_name, text) in list: > frame = self.frames[frame_name] > text = prefix + text > text = text + '\n' + '_'*len(text) > Label(frame, text=text).pack(expand=YES, fill=BOTH) > > # We start with one frame. > self.update_frame() > > def update_frame(self): > # Unpack every option frame. > for n in self.frames.keys(): self.frames[n].pack_forget() > # Pack the current option frame. > self.frames[self.var.get()].pack(side=RIGHT) > > if __name__== '__main__': > root = Tk() > root.title('test') > start = Main(root) > root.mainloop() > -- End of file > > I throw up your class Func and swept a little your code. Hope this helps > ? > > Regards, > Jerome > > It just happens that one of the sample chapters for Python and Tkinter Programming is on geometry managers. It might help you understand how the Packer works... http://www.manning.com/Grayson/chapt05.pdf John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Wed Jul 19 18:23:38 2000 From: aahz at netcom.com (Aahz Maruch) Date: 19 Jul 2000 22:23:38 GMT Subject: merge (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3975EF36.1651C9CB@roguewave.com> <8l52re$tbe$1@nntp9.atl.mindspring.net> <39763FF4.2CA5BF75@schneider-kamp.de> Message-ID: <8l59pa$6ff$1@slb1.atl.mindspring.net> In article <39763FF4.2CA5BF75 at schneider-kamp.de>, Peter Schneider-Kamp wrote: >Aahz Maruch wrote: >> >> Precisely. "Zip" has come to mean compression, and I think *that's* a > >I hate to warm up the whole thread from python-dev, but I'll post >a quote from /F: Some of these make sense, others are absurd. And while I'm sure /F meant this as a joke, I feel a need to respond seriously: >/F: >> is this the end of Python development? >> >> just imagine what this crowd would have done if guido had asked >> you *before* he added things like: >> >> dir ("hey, dir should give you a list of filenames") Directories existed before DOS. Not relevant. >> del ("removes files, right?") Ditto. >> compile ("but people will think that it generates >> machine code") A point, but mostly >> global ("but it's not truly global. how about regional >> or domestic?") Amusing. >> hash ("that's a data type, right?") ("or perhaps something >> from the The Amsterdam Aloha Seed Bank?") Again, "hash" has long since had a relevant meaning for computers. >> hex ("now wait. it's not clear from the name if it con- >> verts a hex string to an integer, or the other way around. >> oh, it's the latter. sorry, but that will confuse perl pro- >> grammers") IIRC, at that point in time, Perl was not a standard other languages were being judged against. >Come on, other languages can live with zip(), too. I think I was insufficiently clear: in addition to "zip" having a known meaning, it does not have any connotation in computer terms of combining data that I've ever seen. Yeah, if you want to call it "zipper", I might almost see your point. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From tim_one at email.msn.com Fri Jul 28 01:24:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 28 Jul 2000 01:24:08 -0400 Subject: Perl is worse! In-Reply-To: Message-ID: [Steve Lamb] > ... > Because 1 + "foo" doesn't work. Sure, in perl you get 1, but you > don't get blown out of the water because of it. Steve, in case it isn't clear yet, Python programmers *want* to be blown out of the water when doing something as senseless as 1 + "foo" You don't. I'm sure you'll agree that's a fair summary of the rest of the 18Kb of debate too . [not,a,list]-ly y'rs - tim From robin at jessikat.demon.co.uk Sun Jul 2 10:25:21 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 2 Jul 2000 15:25:21 +0100 Subject: tkinter hanging Message-ID: I'm having problems with zombie processes under win32 with a tkinter linked against Tk 8.3. I seem to be exiting the mainloop ok and have destroyed all subwindows and then the gui object itself, but occasionally I still generate a zombie. I have checked that my after's are cancelled and debug prints seem to show me exiting the script. has anyone else had these kinds of problems? heeelllppp :( -- Robin Becker From kaevee at my-deja.com Tue Jul 18 08:35:27 2000 From: kaevee at my-deja.com (kaevee at my-deja.com) Date: Tue, 18 Jul 2000 12:35:27 GMT Subject: grouping in regular expressions. Message-ID: <8l1iue$j3e$1@nnrp1.deja.com> I am finding it difficult to match the ip address in the following line using re module. " inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0" here is the expression I used. re.compile('\s+inet addr:(\d+\.\d+\.\d+\.\d+)\s+.*') I am not able to make out where i am making a mistake. Tons of thanks in advance, Regards, kaevee Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Sat Jul 22 11:30:12 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 Jul 2000 15:30:12 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> Message-ID: <8F7974AF5gmcmhypernetcom@199.171.54.194> Cameron Laird wrote: >Michael Hudson wrote: >>5 gets you 7 that you have added a >> >>from os import * >> >>to your script. >> >>Don't do that. >I'd be willing to raise the odds on that bet. > >You're also right that > from os import * >is, of course, universally deprecated. > >What surprises me, though, is that no one ever >mentions the possibility of writing > inp = __builtin__.open("c:/autoexec.bat",'r') Because __builtin__ is a module and has to be imported. And someone who says from os import * would also say from __buitin__ import * And we'd be back where we started. -Gordon From jurberg at my-deja.com Thu Jul 20 13:10:36 2000 From: jurberg at my-deja.com (John Urberg) Date: Thu, 20 Jul 2000 17:10:36 GMT Subject: Newbies trying to do a build script References: <8l1o61$n45$1@nnrp1.deja.com> Message-ID: <8l7bq0$tuh$1@nnrp1.deja.com> In article , Matthew Cline wrote: > In article , Matthew > Cline wrote: > > > In article <8l1o61$n45$1 at nnrp1.deja.com>, John Urberg > > wrote: > > > >> Hi all, > >> > >> I am working on a project with a couple of other developers and we > >> are all new to scripting languages. We need to create a build > >> script to build an application that consist of C++ and Java code. > >> We have some Perl resources in another group, but I would prefer > >> doing it in Python. I was hoping someone here could point me to > >> some examples of build scripts in Python to get us going quickly. > > > > So you're doing something that autoconf, automake, configure and so > > forth can't handle? > > Urgh, that probably wasn't too useful. Sorry. > > What exactly do you need the script to do? If you want to compile > files in sub-directories, sub-sub-directories, and so forth, the > standard UNIX make already takes care of that. If you want to apply > scripts or programs to certain files, then you can have make call > those scripts. If you want to figure out the configuration of your > computer, like where the JVM is, what version it is, and so on, or to > automatically figure out what "-D" flags you should give to the > compiler, then autoconf and automake will take care of things. > > If, after the compile is done, you want to move files around to create > the file tree you'll use for distribution, make can probably do that > as well. > I was looking for an excuse to use Python on my project. Looks like I'll have to figure out nmake. Regards, John Urberg Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at localhost.localdomain Thu Jul 20 13:57:01 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 20 Jul 2000 17:57:01 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39771CA8.A1BF8D6E@fft.be> Message-ID: On Thu, 20 Jul 2000 17:06:03 +0100, Robin Becker wrote: > >the kronecker product is also called the matrix direct product > > >A ox B = [a11 B a12 B] > [a12 B a22 B] > >seems to me to be like a tensor outer product; but I ain't no >mathematician ;) In matlab/octave, this is called kron(A,B). I don't think it deserves an infix operators, because it is just a special case of matrix multiplication. You can define a sparse matrix Kron(A) so that kron(A,B) == Kron(A)*B For such specializations it is best to explicitly spell out the names of operators. This is also true of unitary functions. + - have symbols but sin, cos, ... do not. >the lie product (or bracket) has applications in sensitivity analysis >and other more exotic stuff in differential geometry > >[A,B] = AB - BA def lie(a,b): return a*b-b*a On the other hand, the difference between elementwise and matrix operators are much more fundamental. They result from the different views of vectors, either as a simple collection of numbers, or as a point in a linear space that happens to be represent by an array of numbers. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From peter at schneider-kamp.de Thu Jul 13 10:49:04 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Thu, 13 Jul 2000 14:49:04 +0000 Subject: Switching to Linux...... converting files and databases.... References: <20000712201149.7701.qmail@web5302.mail.yahoo.com> Message-ID: <396DD6E0.39E3548A@schneider-kamp.de> Bobby de Vos wrote: > > Star Office has some slight problems with Word files. The page breaks > are slightly different, and Star Office did not display some > geological time characters in my lab handout. Yes, but you can observe the same problems when switching from one Windows system to another (with another printer driver and different installed fonts). As far as I can see Word files are quite well supported by StarOffice 5.2. Password protected Excel files are something different though. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From alin at clicktomarket.com Mon Jul 10 16:49:45 2000 From: alin at clicktomarket.com (Angela Lin) Date: Mon, 10 Jul 2000 13:49:45 -0700 Subject: App testing Message-ID: <8kdcmo$g5r$1@bob.news.rcn.net> I need to carry out some testing of a cgi application from a Browser client. I have been informed that I can use Python (or some of it's extensions) to capture and replay the http traffic between the Browser and the Webserver to simulate a user session. Unfortunately I've not been able to find any information on this usage in the books I've looked at so far. I am also interested in any other applications free or otherwise which would allow me to do this. I would like to be able to capture the traffic and edit it to allow modified replays of sessions. Can anbody help with this? Should I be looking at other news groups for these features? Thanks. From j.doty at gte.net Thu Jul 27 00:57:04 2000 From: j.doty at gte.net (John Doty) Date: Thu, 27 Jul 2000 04:57:04 GMT Subject: Python and COM: Aggregation? Message-ID: I love Python. I want to use it for all my programming needs. But I can't. Is there a reason that COM objects implemented in Python are not aggregatable? thanks, john From jessw at loop.com Mon Jul 10 16:41:39 2000 From: jessw at loop.com (Jesse W) Date: Mon, 10 Jul 2000 20:41:39 +0000 Subject: Can anyone hear me? (was Solution to IDLE and Tkinter proble In-Reply-To: <9_va5.13290$Tb7.89359@news-server.bigpond.net.au> Message-ID: <200007110344.UAA23990@stevie.loop.com> Sourry for the stupid question, but: Which path? Is it the Pythonpath, the Windows path, the dos config.sys path, or some other path? Thank you for a reply anyway. Jesse W > If starting up a shell is slow check your path. Too long a path or a path > that includes networked volumes or floppy/zip drives can slow things down a > lot. From pduffin at hursley.ibm.com Fri Jul 28 07:57:42 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Fri, 28 Jul 2000 12:57:42 +0100 Subject: The State of Python References: Message-ID: <39817536.FDBC508D@hursley.ibm.com> Tim Peters wrote: > > [Chris Lawrence] > > ... > > I hope BeOpen and/or CNRI are keeping RMS in the loop on this > > one, as I think that was the problem that led to the > > neverending QPL squabble. > > While we can't say much yet, I can assure you that BeOpen is strongly > committed to GPL compatibility for the new Python license. From that you > can probably draw inferences that are at least fundamentally correct . > > Note that the current JPython license is not GPL compatible. We'd sure like > to see that change. But *retaining* CPython's GPL compatibility is the > first goal, and not one BeOpen is likely to compromise on. > What does GPL compatible mean ? Does it just mean that it is an Open Source license as certified by www.opensource.org or is it something more ? From grey at despair.rpglink.com Sat Jul 29 22:47:39 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sun, 30 Jul 2000 02:47:39 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 01:48:32 GMT, Grant Edwards wrote: >I concur. In non-programming, life is strictly typed. Allowed >operations are determined by the type of the object. You can't >make a phone call on a waffle-iron. Were I to _try_ to make a >phone call on a waffle-iron, it doesn't "automagically" convert >istelf into a telephone. Instead, I get a rather interesting >burn pattern on the side of my head. Whoops, exited too fast. When I started programming it was in Turbo Pascal 3. I had the absolutely WORST time with that language at that time because of typing because I couldn't just do what I thought was logical. Furthermore the casting also didn't work in any manner that I thought logical, either. I hit the same problem in C. I really, REALLY despised being told that what I wanted to wasn't possible when I knew darn well it /was/. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From gmcm at hypernet.com Tue Jul 18 23:02:36 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 19 Jul 2000 03:02:36 GMT Subject: What's happening here ???? References: Message-ID: <8F75E3744gmcmhypernetcom@199.171.54.155> Gregoire Welraeds wrote: > > > Not much, dude. - Gordon From rhymes at tiscalinet.it Wed Jul 26 04:17:35 2000 From: rhymes at tiscalinet.it (rhymes) Date: Wed, 26 Jul 2000 10:17:35 +0200 Subject: Python & AI References: Message-ID: Thanxx very much. C u next time on the NG. Bye bye Lawrence Oluyede rhymes at tiscalinet.it "Per cambiare, per diventare un' altra cosa dobbiamo prima sapere cosa siamo" Bruce Lee On Tue, 25 Jul 2000 17:10:39 GMT, "Chris Ryland" wrote: >See http://www.norvig.com/python-lisp.html for a start. From richard_chamberlain at ntlworld.com Sat Jul 22 02:41:14 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sat, 22 Jul 2000 07:41:14 +0100 Subject: textvariables in Labels don't work in Win98se References: <8lb8qr$3s1$1@mcnet.marietta.edu> Message-ID: Nick, I'm running win98se and it runs fine, obviously have a setup issue somewhere. Richard Nick Brown wrote in message news:8lb8qr$3s1$1 at mcnet.marietta.edu... > I am running Python 1.5.2 in Win98se. When I run this program: > > from Tkinter import * > root=Tk() > myString=StringVar() > Label(root, textvariable=myString).pack() > myString.set('hello there') > root.mainloop() > > I get a window with empty space. > But when I run the EXACT SAME CODE on a Linux box, I get a window with the > text 'hello there' in it. Why does the same simple program work differently > in Win98se than in Linux? > > From neilh at scintilla.org Sun Jul 16 08:58:54 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 16 Jul 2000 12:58:54 GMT Subject: Pythonwin: problem with syntax highlighting References: <32966860B9270DBB.82F799B3E78DDCD7.9E33DCD378F53BB0@lp.airnews.net> Message-ID: Telling us what version number will help. Using PythonWin 132 is best if you are running Python 1.5.x. > There's just one irritating thing, not with the language itself, but > with the pythonwin editor. I havn't managed to make autocompleting and > syntax highlighting to work. Autocompletion requires some symbols to be loaded. I don't know all the ways this can happen but in the interactive window try import win32api win32api. After you press the '.' you should see a list appear. Syntax highlighting should just happen - it even looks as though Mark has dropped the option to turn off syntax highlighting. > I've checked and unchecked the options in > the GUI, but it didn't change a thing. I've looked into the registry > to see if a component had'nt been registered properly during setup but > I didn't see anything wrong. > > What could prevent my machine from displaying online help ? Help is bad too? Your machine is posessed by the anti-Python! Try uninstalling and reinstalling. And use Python 1.5.2 and PythonWin 132. Neil From alexandre.ferrieux at rd.francetelecom.fr Tue Jul 4 08:30:48 2000 From: alexandre.ferrieux at rd.francetelecom.fr (Alexandre Ferrieux) Date: Tue, 04 Jul 2000 14:30:48 +0200 Subject: Test results of linuxaudiodev.c References: Message-ID: <3961D8F8.983@rd.francetelecom.fr> Michael Hudson wrote: > > > dsp = linuxaudiodev.open("w") > > dsp.setparameters(au.getframerate(), au.getsampwidth() * 8, > > au.getnchannels(), formats[spec]) > > dsp.write(data) > > dsp.close() > > This doesn't work. I don't really understand why. Can you characterize "doesn't work" ? If by this you mean 'no errors, no sound', then probably the problem is that the close doesn't (by default) linger until all the queued data have been played - in which case success is just one ioctl() away... -Alex From fiona at sitegnome.com Sat Jul 15 21:08:20 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 16 Jul 2000 01:08:20 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 15th, 2000 Message-ID: <20000716010820.11712.qmail@synop.com> Hi List, Here are the latest entries into http://python.faqts.com cheers, Fiona ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class http://www.faqts.com/knowledge-base/view.phtml/aid/4734 ------------------------------------------------------------- Nils Otto Johansen ## New Entries ################################################# ------------------------------------------------------------- Where can I find a DB-API connection to Sybase? http://www.faqts.com/knowledge-base/view.phtml/aid/4753 ------------------------------------------------------------- Fiona Czuczman Paul Boddie The 'ctsybasemodule' apparently resides at the following URL: http://starship.python.net/crew/pgodman/ Whilst 'ctsybasemodule' is rather nice, I found it insufficient for my purposes (no "bind variables" in SQL statements) and decided on mxODBC instead: http://starship.python.net/crew/lemburg/mxODBC.html If you decide to pursue that option, I would suggest looking at my ODBC resources page: http://www.crosswinds.net/~pboddie/Python/mxODBC.html I managed to get mxODBC working with Adaptive Server Anywhere and Adaptive Server Enterprise, but with the recent announcement of zxJDBC you could use JPython and Sybase's jConnect software instead: http://www.ziclix.com/zxjdbc/ http://www.jpython.org http://www.sybase.com/products/internet/jconnect/ ------------------------------------------------------------- How can I call an .exe file from inside a .py file? http://www.faqts.com/knowledge-base/view.phtml/aid/4757 ------------------------------------------------------------- Fiona Czuczman Alex Shindich, Gregoire Welraeds Try this: import os os.execl ('foo.exe') For more info read http://www.python.org/doc/current/lib/os-process.html execl is kind of an alias for execv. So using this solution, be aware of the following: execv (path, args) Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows. This mean that if you have the following code in a file: import os os.execv("/bin/ls",("ls","/")) print "Done!" The last line will never be executed because the python process is replaced by the /bin/ls command. To avoid this, Unix allows you to use the fork system call : import os i= os.fork() if i != 0: os.waitpid(i,0) # wait for the child to complete. print done! else: # child process os.execv("/bin/ls",("ls","/")) Another and easier solution, which also works under Windows : import os os.system("foo.exe") print 'Done!' ## Edited Entries ############################################## ------------------------------------------------------------- How can you check on the status of a file's "archive" bit, on DOS-type platforms http://www.faqts.com/knowledge-base/view.phtml/aid/4706 ------------------------------------------------------------- Barry Pederson, Fiona Czuczman http://www.python.org/windows/win32all/,Alex Martelli On Win32, with Hammond's extensions: PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au) >>> from win32file import GetFileAttributes >>> GetFileAttributes("C:/witha.txt") 32 >>> GetFileAttributes("C:/withouta.txt") 128 >>> where witha.txt does have the A attribute and withouta.txt lacks it. You can also use symbolic names for the constants: >>> import win32file >>> win32file.FILE_ATTRIBUTE_ARCHIVE 32 >>> win32file.FILE_ATTRIBUTE_NORMAL 128 >>> Note that the 'normal' bits seems to be set if and only if no other bits are set. Other attributes in the bitmask behave more normally, i.e., they are bitwise-or'ed to give all attributes of the file. For example, after making witha.txt read-only (still _with_ the A attribute as well), we have: >>> GetFileAttributes("C:/witha.txt") 33 >>> win32file.FILE_ATTRIBUTE_READONLY 1 >>> I.e., the attributes of the file are the bitwise-or of archive and readonly. So, if you only want to test for archive, and don't care about the others, you'll bitwise-and GetFileAttributes' result with FILE_ATTRIBUTE_ARCHIVE, rather than testing for equality! From cg at schlund.de Tue Jul 11 10:23:38 2000 From: cg at schlund.de (Carsten Gaebler) Date: Tue, 11 Jul 2000 16:23:38 +0200 Subject: Sybase module crashes (segfault) Message-ID: <396B2DEA.2FAEA72B@schlund.de> Hi! I have compiled and installed the Sybase module 0.6 on SuSE Linux 6.3 with Sybase Open Client 11.9.2. When I say import Sybase db = Sybase.connect(host, user, passwd) Python crashes with a segmentation fault. What went wrong? Regards Carsten. From owen at astroNOJNK.washington.edu.invalid Mon Jul 17 19:10:36 2000 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Mon, 17 Jul 2000 16:10:36 -0700 Subject: Does Python have "not a number" floating point values? Message-ID: <8l03pc$92co$1@nntp6.u.washington.edu> Does Python support any sort of floating point "not a number" (e.g. IEEE infinity)? I realize I can just use None, but it's convenient to be able to tell the difference between inifinity and undefined, and to be able to perform a computation that may fail without raising an exception. -- Russell From donn at u.washington.edu Wed Jul 12 12:32:09 2000 From: donn at u.washington.edu (Donn Cave) Date: 12 Jul 2000 16:32:09 GMT Subject: File IO with select? References: <396BBCE9.2C114ED3@tgflinux.com> Message-ID: <8ki6i9$3lbs$1@nntp6.u.washington.edu> Quoth Jared Lee Peterson : | I am trying to syncronize two clients that are accessing the same file. | One client spawns the other and then needs to wait until process two | writes to the file before it can then read from it. I am trying to use | select() for this but I am not having much luck. So I guess that my | question would be whether or not I can use select() for this or not. If | so could someone offer some guidance ... if not could someone offer | another suggestion. Thanks a lot Select() is not the answer. You need a filesystem lock. I'd look at fcntl.lockf(). Like select(), this function operates on an integer file descriptor -- fd = posix.open(file, posix.O_RDWR) # open file fcntl.lockf(fd, fcntl.LOCK_EX) # lock fcntl.lockf(fd, fcntl.LOCK_UN) # unlock, or posix.close(fd) # unlock The cooperating processes must both lock the file, lockf() is where they interlock. Don't use buffered I/O. If you must use a Python file object, turn off its buffering or use flush() at strategic points. Same as with select(), the system doesn't work if the processes don't really write their data out. To go on to excruciating detail, there are two different kinds of filesystem lock on some UNIX platforms. The lock supported by the fcntl() and lockf() functions is pretty much universal, and since BSD 4.2, Berkeley platforms have had an flock() that's a little different. Some misguided attempts to support Berkeley compatibility support flock() as a way to call lockf(), but the real flock() doesn't interoperate with lockf(), applies only to local files (not remote network mounted) and is somewhat more reliable. The flags I use up there with lockf() are really the flags for flock(), that's how it works in Python. With fcntl/lockf, if the same file is open on more than one unit, the first unit to close releases the lock. Donn Cave, donn at u.washington.edu From paul at prescod.net.bbs Mon Jul 17 17:30:03 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 21:30:03 GMT Subject: Type checking in python? Message-ID: <3bRQ4U$n1s@openbazaar.net> Matthew Cline wrote: > > .... > > That's another reason why I'd like the type checking to be done by the > Python compiler, because it could be intelligent about those things. > Like for "list" it could accept a tuple, a list, or anything derived > from UserList. Most list-like Python objects do not derive from UserList. We could argue whether they should or should not but the point is that your syntactic change would only provide maximum benefit if Python programmers change their programming style. That's why it is not something that can be implemented overnight. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From morten.soerensen at framfab.dk Wed Jul 19 11:05:32 2000 From: morten.soerensen at framfab.dk (Morten Sorensen) Date: Wed, 19 Jul 2000 17:05:32 +0200 Subject: Newbie : Python install MIME type problem (I think) Message-ID: <3975C3BC.3D346C5B@framfab.dk> I have installed Python on Win2k - but I just get the source code in a browser. Do need to include some MIME types in my web servers (Apache) configuration - and if so, which MIME types ? morten sorensen From claird at starbase.neosoft.com Thu Jul 27 19:46:52 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Jul 2000 18:46:52 -0500 Subject: Consorting with infidels (was: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <8lq20g$kt1$1@nntp9.atl.mindspring.net> <8lqel0$78o$1@nntp9.atl.mindspring.net> Message-ID: In article <8lqel0$78o$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >In article , >Ben Caradoc-Davies wrote: >>On 27 Jul 2000 19:19:44 GMT, Aahz Maruch wrote: >>>In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, >>>Guido van Rossum wrote: >>>> >>>>I've placed the slides of my talk at the O'Reilly Open Source >>>>Convention on-line at our BeOpen PythonLabs website: >>>> >>>> http://www.pythonlabs.com/talks.html >>> >>>It appears that the HTML version requires JavaScript. That's a Bad Idea. >> >> > >Guido sent me an e-mail response saying that unfortunately he only had >time to take Outlook's default output and stick it up on the Web. Given >what he's going through currently, I'm inclined to cut him some slack -- >but not Microsloth. . . . Slack--why, I cut him not merely slack, but also sympathy, for having to move in the social circles where work is transacted in the medium of PowerPoint(less) slides. Poor brave knight, so far from home. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim_one at email.msn.com Tue Jul 25 03:17:22 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 25 Jul 2000 03:17:22 -0400 Subject: Python is wierd! In-Reply-To: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: A few quickies: [Jonathan] > Hi, just finished going through the 'Learning Python' book, and the > feeling that i get is that Python is really wierd(compared to other > conventional languages like C++, Java, etc). For e.g.(correct me if i'm > wrong) > ... > 3. No keywords to differentiate between passing arguments by reference > or value! An integer is passed by value(reference to a new copy), while > a mutable object is by reference. To pass a list by 'value', i know you > just need to insert one more line(list = [:]), but it seems > so 'inconsistent' compared to Java or even PHP. I'm surprised you got that impression from the book. It isn't a true one. Everything in Python is passed by reference, always; Python never (ever!) makes a copy of anything unless you explicitly ask for one. What you describe is actually much closer to the way Java works. > (Not to mention the number of 'gotchas' listed in the book that are > bound to trap beginners - *shudder*) You'll find that (by far) most Python users believe the language has far fewer gotchas than other languages they've used. I'm certain the book did *not* say the gotchas they list at the end of each chapter "are bound to trap beginners". Different people have different blind spots, and the authors did a remarkable service by listing the *union* of "gotchas" they've seen beginners get got by . There are very few gotchas in Python that *most* beginners suffer (stark contrast with C, C++ or Perl is dead easy). See also Andrew Kuchling's "Python Warts" paper: http://starship.python.net/crew/amk/python/writing/warts.html That lists deep areas of ongoing (and going, and going ) debate. The "beginner gotchas" are much shallower, and the best predictor I know of for which feature will trip which beginner is the programming language they used most before coming to Python. It's insane to believe that language X "should" work exactly like language Y, and beginners who don't come in with an insane attitude very quickly adjust. As the years have gone by, I've gotten a sick, hypocritical thrill out of cruising other language newsgroups, and finally seeing people complain that language X, Y or Z doesn't work exactly like Python <0.9 wink>. > The reason i'm picking up python is that i got sick of PERL:), There are many here who came to Python for the same reason. Don't expect Python to act like Perl, and I predict you'll be happy. If you left Perl reluctantly, you may also want to give Ruby a try. One suggestion: stop reading so much and write some damn code already . > ... > Pascal(for procedural) and Java(for OOP) is still the better choice to > start off, IMHO. Try to reserve judgment until you've actually used the language. Are you old enough to remember the then-famous 1977 paper "Ambiguities and Insecurities in Pascal", by Welsh, Sneeringer and Hoare? A frank discussion of *any* language's lapses from perfection will scare the snot out of anybody who only reads about the language. The Python community is very open about what they think is lacking in the language; curiously, though, there's almost no consensus on what that is. don't-reply-start-coding-ly y'rs - tim From moshez at math.huji.ac.il Mon Jul 3 08:53:49 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 3 Jul 2000 15:53:49 +0300 (IDT) Subject: Python CGI security In-Reply-To: <39607A22.CA190D70@stroeder.com> Message-ID: On Mon, 3 Jul 2000, Michael [iso-8859-1] Str?der wrote: > Note that I only posted *excerpts* of the ITS4 output. Feel free to > ask if you want the whole output by e-mail (approx. 1000 lines with > a lot of repeated messages). > > > There are a few types of "potential security holes": > > > > -- exposing insecure parts of the API, such as os.system(). These should > > stay, since the user should have those at his disposale > > Would it be possible to provide a secure version in the Python lib > of e.g. os.system() with same function parameters but less unsecure > behaviour instead of just wrapping it 1:1? no: the insecurities are there for a reason: they give more power for local applications Please send to me (personally!) the whole output. I'll have a look at it and try to summarize it. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From Armin at Steinhoff_de Mon Jul 17 04:02:03 2000 From: Armin at Steinhoff_de (Armin Steinhoff) Date: 17 Jul 2000 01:02:03 -0700 Subject: Type checking in python? References: Message-ID: <8kuehr$22c5@drn.newsguy.com> In article , Matthew says... > >It would be nice if I could do something like: > > def my_func(int foo, list bar, Quux quux): > ... > >rather than > > def my_func(foo, bar, quux): > if not isinstance(quux, Quux): That's plain C ... if not quux.isinstance(Quux): is more flexible ... so you have just to implement that method in your class definition Regards Armin > raise RuntimeError("param 'quux' must be of class 'Quux'") > >Is there any plans on doing this for Python 3000? Or will something >like this never be a part of Python? > > From mjackson at wc.eso.mc.xerox.com Tue Jul 18 08:26:47 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 18 Jul 2000 12:26:47 GMT Subject: Why is openbazaar.net reposting duplicate articles to c.l.py? Message-ID: <8l1ie7$3o2$2@news.wrc.xerox.com> This doesn't have anything to do with the CNRI-BeOpen hassle, does it? :-( -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson A doctor can bury his mistakes, but an architect can only advise his client to plant vines. - Frank Lloyd Wright From ejr at lotus.CS.Berkeley.EDU Wed Jul 26 23:45:47 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 27 Jul 2000 03:45:47 GMT Subject: Discussion: new operators for numerical computation References: <8ite5.9395$4p3.69392@news-server.bigpond.net.au> <3hu2dfrndo.fsf@angband.org> <397FA0FF.5FFEB6AA@see.my.signature> Message-ID: <8lob9b$i7j$1@agate.berkeley.edu> And Greg Ewing writes: - - It's hard to see how to implement multiple dispatch in a way - that preserves this property, while still being flexible - enough to solve the kinds of problems that multiple dispatch - is supposed to solve. Assume the generic function route to multiple dispatch. One name is declared to be a generic function, then definitions are attached by declaring methods that implement the function for combinations of argument types. These definitions must be loaded from appropriate modules before they can be bound to the name, which is itself located within some module. How is this significantly more painful than the object factory pattern? You have one front-end package that provides a factory. The factory can return objects from any package the factory's package has loaded. The client of the factory need not have imported the back-end module, so this won't be obvious in the way you seem to prefer. Of course, both Python and most (all dynamic) languages supporting generic functions have run-time introspection facilities, so you can answer these questions then. Some programming environments can also help out, although I'm pretty much stuck in Emacs- and vi-land until someone plops a free software one with compatable key bindings in front of me. Jason From paul at prescod.net Mon Jul 17 19:11:13 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 18:11:13 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> Message-ID: <39739291.4155A128@prescod.net> Charles Boncelet wrote: > > .... > > Why is it ordained that objects should have only two operations, "*" and > "+", > defined with simple operators? "+" on strings means something entirely > > different than "+" on numbers. Why not add an "@" operator? Because 90% of Python programmers would not know what it means. Look, if you took a poll of all programmers in the world, only a small fraction use matrices very often. Therefore it is a niche. Most programmers use numbers and strings every day, however. Still, we all want you to succeed. We just disagree on the right approach. Here's my suggestion: > Python could become the primary open source alternative to Matlab in > time > if a few changes were made: Incorporate numpy into the core distribution > (or > release a distribution with it already embedded), The process of creating a numpy enabled distribution is underway. > improve the help facility at the interpreter. A module for that is under development. > simplify the syntax for matrix operations You (matrix people) can do that by parsing your own Python-like syntax and generating Python byte codes or Python source code. You don't need any official blessing from Guido or anyone else. Several people have written compilers for languages like Python IN Python and in other languages. It is possible. There are even techniques for making your language work on the interpreter line. We can help with that. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From aahz at netcom.com Mon Jul 31 11:54:04 2000 From: aahz at netcom.com (Aahz Maruch) Date: 31 Jul 2000 15:54:04 GMT Subject: The State of Python References: <398546C5.E9E59957@hursley.ibm.com> Message-ID: <8m47es$904$1@nntp9.atl.mindspring.net> [p&e] In article , Guido van Rossum wrote: > > [....] I just thanked Tim, but thank you, too, for keeping us informed. Knowing what's going on, no matter how nebulous, is infinitely better than a vast silence. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 NOTE: end of September, Earthlink kills Netcom. My new permanent address is aahz at pobox.com. I have not decided where to set my primary shell account. Please do not send me e-mail condolences; my mailbox is already too big. From m.faassen at vet.uu.nl Sun Jul 30 16:41:35 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jul 2000 20:41:35 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> <8lvu6d$8pa$2@news.dtc.hp.com> Message-ID: <8m23tv$pqc$1@newshost.accu.uu.nl> (Greg Weeks) wrote: > Martijn Faassen (m.faassen at vet.uu.nl) wrote: > : This seems to be where the confusion comes in. When people claim Python > : passes by value, because the *references* are being passed by value, > : that seems to be just stating that the only thing the computer can pass > : in the end is numbers. If you say that, everything is by value and references > : are impossible, which seems to be a useless set of semantics. > Why useless? If you say everything is 'by value' in end because references are values too, you're giving up the useful distinction between 'by value' and 'by reference'; everything is 'by value'. So you can say less. So it's a rather useless way to define the words, in my opinion. > It works well for me and others. Lisp uses the same object > model as Python, and old Lispers never bothered with this "references" > business. They managed fine. And there are advantages. For example, > these semantics allow me to say that Perl is call-by-reference while Python > is call-by-value, a very real distinction that IMO contributes to the > superiority of Python. What does 'call-by-reference' mean? I mean, as opposed to 'pass-by-reference'? If you want to ignore the word 'reference' and call it 'address', that's fine with me. But reference and address are in my book not too different; 'address' has a machine-connotation where reference does not (it may not actually be implemented by memory addresses, though usually it is). An address in the real world is after all just a reference to a particular house, not? If you mean *pass* (arguments) by reference, then I'd definitely say *Perl* is pass by value (by default), and Python is pass by reference. I don't understand the reversal? > I started -- or at least leapt into -- this thread because at the very > least I think it is misleading for people to assert flatly that Python is > call-by-reference when from another point of view that is not the case. On > the other hand, as much as I prefer my own viewpoint, I realize that it is > a matter of taste, and tastes are rarely changed as a result of newsgroup > discussions. All names in Python are references; so you're just passing the references to the functions when you do a function call. In that sense it's by value, but in C you wouldn't call passing around pointers and storing them in variables 'by value' either. You 'dereference' a pointer, for instance, when you want actual access to the value inside it. In Python you never have to deal with getting a pointer (reference) to some value and the other way around; you only deal with references and manipulate them in some way. Perhaps there is some other semantics for 'value' and 'reference' stemming from another programming tradition that I'm not aware about, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From julesk24 at my-deja.com.bbs Mon Jul 17 09:00:02 2000 From: julesk24 at my-deja.com.bbs (julesk24 at my-deja.com.bbs) Date: 17 Jul 2000 13:00:02 GMT Subject: Reading asynchronous data from a serial device Message-ID: <3bRCd3$kGG@openbazaar.net> I am attempting to write a program (to run on a linux box) in python which communicates to a device via a serial port. The problem is that the device is not reliable in responding when expected. Therefore, I have many reads timeout. I am relatively new to the world of multiple threads so I am probably making many mistakes. My current approach is to use a separate thread for the read and then to join() the thread back into the main thread if the read is not sucessful within the given amount of time. The end result is hundreds of hung processes and an eventual segmentation fault (the program needs to be designed to run for days). My questions are: 1) Is there any (easy) way for me to cause the thread to exit (not just join the processes) after a timeout on a read? 2) Is there a better way of reading for data (without starting my own thread for the read process and then trying to exit out of the thread after a period of time)? I have read through the newsgroups, but I haven't found anything which specifically answers my questions. Thanks to anyone who can answer my questions! Julie Kempton jmk11 at duke.edu Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Sat Jul 1 15:48:02 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 1 Jul 2000 15:48:02 -0400 Subject: Event Binding and Variable Passing Message-ID: <1249641616-55775887@hypernet.com> [posted & mailed] Cameron subtly baited: In article <39567A5A.5B692C5D at pacbell.net>, Bruce Wolk <{HYPERLINK "http://www.deja.com/[ST_rn=ps]/profile.xp?author=bawolk at ucdavis.edu&ST=PS"}bawolk at ucdavis.edu> wrote: >You need to use a lamda expression. > >def fun(x): > print x >b.bind('', lambda event, b=x: fun(b)) . . . Can one of the old(er?)-timers help me with this? There's a sect (claiming the Guido among its sym- pathizers) that deprecates lambdas for Python, no? But their reasons (very abstractly, that object- oriented metaprogramming gives more than enough goodies, making lambdas essentially redundant) do *not* apply for communication with the event- and binding-mechanisms adapted from Tcl, true? The conclusion would be, then, that Tkinter forces a fundamental need for lambdas. Well, my version of IDLE contains all of 9 lambdas, only 3 of which are used with Tkinter. So obviously Guido is no big fan of lambda, but neither does he abstain from its use. However, the fact that that much Tkinter code uses only 3 lambdas belies your assertion. Of course there are a multiplicity of sects within Python, sharing little more than a common shortage of virgins... - Gordon From cjensen at bioeng.ucsd.edu Thu Jul 6 15:35:01 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 06 Jul 2000 12:35:01 -0700 Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> <3963E6D6.F47FA4D8@roguewave.com> <3964BC64.761858FA@bioeng.ucsd.edu> <3964C635.E730EB97@roguewave.com> <3964C6FE.9BEC7ABB@bioeng.ucsd.edu> <3964D69C.AAA9EEA7@roguewave.com> Message-ID: <3964DF65.4D0EB00@bioeng.ucsd.edu> Bjorn Pettersen wrote: > > Curtis Jensen wrote: > > > > Bjorn Pettersen wrote: > > > > > > Curtis Jensen wrote: > > > > > > > > Bjorn Pettersen wrote: > > > > > > > > > > What you're seeing are the symptoms of Python having thrown an exception > > > > > and the weblog not capturing all the information. The solution is to make > > > > > sure Python can only throw where you can grab the exception and do > > > > > something useful with it, like printing it to the browser... Try the > > > > > following (but make sure you can execute it from the command line first -- > > > > > one possible error is a SyntaxError, which this scheme will not save you > > > > > from...) > > > > > > > > > > -- bjorn > > > > > > > > > > #!/usr/bin/env python > > > > > print """Content-type: text/html > > > > > > > > > > """ > > > > > > > > > > def main(): > > > > > from time import * > > > > > > > > > > print "" > > > > > print "" > > > > > print "Hello World" > > > > > print "" > > > > > print "" > > > > > print "

Hello World !

" > > > > > print "
" > > > > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > > > > > > > > > print "" > > > > > print "" > > > > > > > > > > import traceback > > > > > > > > > > def execute(fn): > > > > > # make sure any errors are legible, and directed to the user. > > > > > try: > > > > > sys.stderr = sys.stdout > > > > > fn() > > > > > except: > > > > > print '

Something went wrong!!!

' > > > > > print 'Please send the transcript below to webmaster at your.web

' > > > > > print '\n\n

'
> > > > >         traceback.print_exc()
> > > > >
> > > > > execute(main)
> > > > >
> > > >
> > > > I tried this.  I got the same errors in the log and in the browser.  I
> > > > took out the print line since it caused a discussion.  Any more
> > > > suggestions?  Thanks.
> > >
> > > You do need the print line! The first thing your cgi must print out
> > > (modulo cookies) is "Content-type: text/html" followed by exactly two
> > > newlines (yes, I know there are situations where this isn't true, but in
> > > this case it is.. )
> >
> > Sorry, I didn't say witch line.  I took out the print line with the time
> > in it.  So now it is a simple hello world script.  By the way, is,
> > print 'Content-type: text/html\n\n'
> > just as good as they way you have it?  I've tried both.
> >
> > >
> > > Check that:
> > >
> > >  - your script is executable (by everyone)
> >
> > It is. permissions are 775
> >
> > >  - some webservers require a .cgi extension (a symbolic link to your .py
> > > will work)
> >
> > I tried that and got the same errors
> >
> > >  - python is where you think it is, and is executable (again by
> > > everyone)
> >
> > from the unix prompt, I can run helloworld.py and it prints fine.
> > Permissions on python are 755
> >
> > >  - your webserver is set up to execute cgi scripts.
> >
> > In the same directory as helloword.py there are Pearl cgi scripts that
> > run fine.
> >
> > > If all that works, try the simplest possible cgi script, something like:
> > >
> > > #!/usr/local/bin/python
> > > print  """Content-type: text/html
> > >
> > > """
> > > print '

hello world

' > > > > We tried this and got the same problem. > > Anything else? Thanks for the help so far. > > print 'Content-type: text/html\n\n' is fine... > > Hmmm... it seems clear that there is something going wrong when the > webserver is trying to execute your script (the errormessage being > "premature end of headers")... > > How about > > #!/bin/sh > echo "Content-type: text/html" > echo > echo "

hello world

" > > if that works, create a text file called yyy.txt and make it world > writable (777), then try: > > #!/bin/sh > echo "Content-type: text/html" > echo > /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py >> yyy.txt > 2>&1 > > Your browser should tell you that the document contained no data, but > the yyy.txt file will hopefully contain the error... (you're getting > very close to the limit of my cgi knowledge here ;-) > > -- bjorn The shell-cgi worked fine. I redirected the output and the yyy.txt file remained empty. If I ran the shell-cgi script from the unix prompt, yyy.txt contained the correct html code. So, even though I didn't get any errors in the yyy.txt file, this helped me figure out what is going on. The webserver is not able to execute the python executable. Python was compiled for a newer OS than what the webserver is running at. I was running the scripts from my machine which is IRIX 6.5, but the OS on the webserver is older. I logged into the webserver, and tried running the python interpreter and it returned with a new unix prompt. So, that's our problem. We're going to have to make a work around for this. Thanks for the help. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From jhe at webde-ag.de Thu Jul 27 05:33:32 2000 From: jhe at webde-ag.de (Jurgen Hermann) Date: Thu, 27 Jul 2000 11:33:32 +0200 Subject: File Upload Problem References: <397FF05C.D0A7A724@yahoo.co.jp> Message-ID: <8lovi0$lf8$1@pollux.ip-plus.net> schrieb im Newsbeitrag news:397FF05C.D0A7A724 at yahoo.co.jp... > Uploaded image files are truncated. Set stdin to binary mode (see my msg in c.l.p 1-2 weeks ago). From bjorn at roguewave.com Fri Jul 14 20:23:09 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 18:23:09 -0600 Subject: string issue or questions about intern References: <396EEAFF.3AD7B951@bioreason.com> <396F87C4.6B3C9FAE@schneider-kamp.de> <396F0DD3.B391503@bioreason.com> <3dk8eol9bk.fsf@kronos.cnri.reston.va.us> <396F8800.49F7D25D@prescod.net> Message-ID: <396FAEED.32400187@roguewave.com> Paul Prescod wrote: > > Andrew Kuchling wrote: > > > > ... > > > > If you need full Python expressions, there seems no way around using > > eval(). But if you simply need string escapes, it's probably worth > > writing a parser. (Does such a parser already exist somewhere in the > > standard library? Anyone know?) > > In general, wouldn't it be nice if there was a parser for all Python > literal syntaxes? Sometimes its really convenient to keep your data in a > format like this: > > {"a":"b"} > > but I cringe to load the file and then eval it for security reasons. Do you want something like (from the python2c distribution)?: D:\bjorn\py2c>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import transformer >>> t = transformer.Transformer() >>> t.parseexpr("""{'a':'b'}""") ('dict', [(('const', 'a'), ('const', 'b'))]) -- bjorn From erno at iki.fi Wed Jul 12 13:45:28 2000 From: erno at iki.fi (Erno Kuusela) Date: 12 Jul 2000 20:45:28 +0300 Subject: Python and SSH References: <8kf4gl$fqm$1@saltmine.radix.net> <396BA227.7EE196E1@bioeng.ucsd.edu> Message-ID: >>>>> "Curtis" == Curtis Jensen writes: Curtis> If I'm not mistake SSH just sends data accross a socket, Curtis> same as most network protocals (I'm not sure which port Curtis> SSH sends on). You can use the socketServer module to Curtis> catch socket data from the SSH port. ... and implementing the crypto stuff and ssh protocol details and the equivalent scrutiny of 5 years of bugtraq pounding on it is left as an exercise to the reader :). -- erno From brown.2053 at osu.NOSPAM.edu Wed Jul 19 16:35:21 2000 From: brown.2053 at osu.NOSPAM.edu (Locke) Date: Wed, 19 Jul 2000 16:35:21 -0400 Subject: Python/Tkinter and Windows 2000 Message-ID: <8l53a9$e64$1@mcnet.marietta.edu> When I run any Tkinter programs on Win2k, I get an error that it can't find tcl80.dll or something like that. Does Python/Tkinter not support windows 2000? From moshez at math.huji.ac.il Fri Jul 28 07:21:28 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 14:21:28 +0300 (IDT) Subject: [Draft] Open Letter to CNRI: Request for clarification In-Reply-To: <39816303.C808D05A@nowonder.de> Message-ID: On Fri, 28 Jul 2000, Peter Schneider-Kamp wrote: > Or should it better by a letter from the community to CNRI? I don't think so. The "community" is amorphous -- Peter is a specific being you can speak for . That the community is behind this should be evident from the sheer number of signatures (BTW: please append my signature too). However, I don't think the letter should merely express concern: it should also ask for a clear statement. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From rumjuggler at cryptarchy.org Fri Jul 28 15:06:54 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 19:06:54 GMT Subject: Perl is worse! References: Message-ID: On Fri, 28 Jul 2000 15:08:12 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On 28 Jul 2000 14:09:30 +0200, Hrvoje Niksic wrote: >>I sort of hope you're trolling here. > > No, I am not. > >>For me, 1 and "1" are clearly not two numbers. The former is a >>number, the latter a string consisting of the character "1". Saying >>that they are numbers because we "see" they're numbers is like >>insisting one 1 + "one" to return 2 because "one" is so obviously a >>number. > > You see that only because you are a programmer and have gotten used to the >concept of types. I, too, am a programmer and I reject the concept of types >because to the human that concept is meaningless. Actually it's quite meaningful and useful when you want to talk about languages. "Tree has four letters" vs. "'tree' has four letters", and all that. -- Barnabas T. Rumjuggler The night of time far surpasseth the day, and who knows when was the equinox? -- Thomas Browne From mikl at club-internet.fr Tue Jul 11 06:11:39 2000 From: mikl at club-internet.fr (Mickael Remond) Date: 11 Jul 2000 12:11:39 +0200 Subject: Python book suggestions? References: <8kdpeq$hqe$1@nnrp1.deja.com> Message-ID: <87puolou1w.fsf@louxor.home> >>>>> "shindich" == shindich writes: I recommand XML processing with Python (Sean McGrath) published by Prentice Hall. It is both a very good way to learn XML processing and a very good introduction to Python. -- Micka?l From to_get_my_address at see.my.signature Thu Jul 27 02:24:05 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 19:24:05 +1300 Subject: polymorphism (was Re: Type checking in python?) References: <8lmo4i$s28$1@news.kth.se> Message-ID: <397FD57F.5F588026@see.my.signature> Oivvio Polite wrote: > > What are your experiences? Does the type(arg) checking really become > unmanageable as Paul's post implies? If so what are the alternative routes? It's not so much that it becomes unmanageable, but that it needlessly constrains what kind of objects your methods can operate on. Rather than checking for specific types, a more flexible way is to test whether they support the operations you need to do on them. For example, class myclass: def __init__(self, arg): if hasattr(arg, "read"): # It seems to be a file or a file-like object ... else: # Assume it's a string or something that can be converted to one filename = str(arg) ... -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From jvickroy at sec.noaa.gov.bbs Mon Jul 17 16:50:04 2000 From: jvickroy at sec.noaa.gov.bbs (jvickroy at sec.noaa.gov.bbs) Date: 17 Jul 2000 20:50:04 GMT Subject: Multiline strings and indentation Message-ID: <3bRP2S$m5v@openbazaar.net> How about: >>> print "this" + \ " is" + \ " a" + \ " long" + \ " string" this is a long string >>> "donotspam-jen at personic.com" wrote: > I'm just getting started with Python. The indentation feature really does > make things readable ... except when using multi-line strings. This just > doesn't look right: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Is there a way to make the above more readable? It would be nice if it could > be written this way and have Python just figure out what whitespace to > ignore: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Thanks for any suggestions! > > Jen From neilh at scintilla.org Tue Jul 25 21:49:50 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 26 Jul 2000 01:49:50 GMT Subject: PythonWin/Scintilla aggressive folding... References: Message-ID: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> [PythonWin / Scintilla folds away comments that belong to next definition] Mark's comments are correct but I'd like to explain a little more. Scintilla uses a simple fold discovery algorithm that relies mostly on indentation and only looks at a narrow window of lines. Often, comments are not indented with the executable code so are treated by the folder as having a 'neutral' indentation level which will bind to the indentation level of a nearby piece of executable code. Blank lines also have neutral indentation level as they are often sprinkled within a function. This allows a function like def z(y): x = 1 # x = sin(y) return x*2 to fold correctly. It has the downside of binding the top level comment in your example to the preceding definition. This could be fixed by doing a much better job of parsing the Python code or by doing some more tweaks such as detecting this particular common case. The argument against a really good parser is the need for performance as the folding structure is being continuously recalculated as editing occurs. Eventually I'll do some more work on the code folder but haven't yet found a good alternative. It'd be great if someone else was interested in working on this. Neil From spamfranke at bigfoot.de Mon Jul 3 20:15:01 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 04 Jul 2000 00:15:01 GMT Subject: mysql module for python under windows References: <8jqt8d$3do$1@nnrp1.deja.com> Message-ID: <39612aaa.15439725@news.btx.dtag.de> On Mon, 03 Jul 2000 20:32:13 GMT, ekw1 at my-deja.com wrote: >Is there a Python MySQL module for use under Windows? All the ones I >come across on python.org are for Unix/Linux. Thanks for any info. > >ekw > > >Sent via Deja.com http://www.deja.com/ >Before you buy. Hmm, dunno where to download it separately, but check out ZMySQLDA-1.2.0.tar.gz on the Zope site (www.zope.org). It contains MySQLdb-0.1.2 with some Windows patches already applied. I run it sucessfully with the lately GPLed MySQL-2.23.19 on Win98. All you need to do is to edit Setup.in, adjust the paths to your local MySQL installation, and run compile.py. If you don't have Visual Studio, mail me personally and I'll send you the files. No-warranties-of-course-ly y'rs Stefan From grey at despair.rpglink.com Thu Jul 27 11:46:41 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 15:46:41 GMT Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: On Thu, 27 Jul 2000 15:29:15 GMT, Guido van Rossum wrote: >If anything, "Be" made a rather confusing choice of name. Well, I think it fits if what I hear about what it stands for is true. BeOS - Bleeding edge Operating System. Considering they designed it from the ground up for the latest hardware at the time it fits. Otherwise, yeah. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From cjc26 at nospam.cornell.edu Wed Jul 19 14:22:14 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 19 Jul 2000 18:22:14 GMT Subject: Advice sought: text-mode (but not CLI) apps in Windows console ? References: <8F7682C13PaCmAnRDLM@195.25.12.37> Message-ID: * Fred Pacquier menulis: | | Since then I have been through what I believe to be a reasonably thorough | Web search (from Parnassus outwards) to find something to get me started, | and have turned up precious little. Various Python bindings of curses or | ncurses exist, but can one run curses itself under Win 9x ? Or are there | other, well-hidden libraries or modules that do more or less the same thing | on that platform ? (I'm not asking for something as high-level and | extensive as the Borland OWL of old :-) You may be able to compile curses using cygwin/djgpp. Also, there is another library called S-Lang which you could use, and I believe there is a port for it for Windows. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From cliff.penton at b_i_g_f_o_o_t.c_o_m Mon Jul 10 16:10:47 2000 From: cliff.penton at b_i_g_f_o_o_t.c_o_m (Cliff Penton) Date: Mon, 10 Jul 2000 21:10:47 +0100 Subject: Palm Python? References: <8h8jmc$t9i$1@gaia.cdg.acriter.nl> <14649.14534.184930.984180@malibu.aero.org> <3939FFB4.A7824367@mindspring.com> Message-ID: "Will Ware" wrote in message news:FxDxF7.E1D at world.std.com... > Blake Winton (bwinton at tor.dhs.org) wrote: > There's actually an interesting problem with "static", as it applies > to variables rather than functions. For variables, it also limits the > name scope to the current source file, but it has a second meaning > which is to ensure that the variable has a permanent address (rather > than being, say, just a local allocated on the stack). It would have > been good to use a second keyword for this second meaning. This hasn't > ever actually been a problem for me in writing C code, but it's an > interesting little design blunder. Don't think of the reuse of static as a design blunder -- more an efficient use of keywords ;-) Cliff From pehr at pehr.net Fri Jul 7 21:24:30 2000 From: pehr at pehr.net (pehr anderson) Date: Sat, 08 Jul 2000 01:24:30 GMT Subject: Python based macro processor (URGENT) References: Message-ID: <396682CF.51939273@pehr.net> Dear Fernando, There have been previous requests for a python preprocessor but in most cases python had enough built-in functionality to gracefully deal with the problem at hand. Perhaps you could describe your problem in detail and let the good folks on this list with far more experience than I guide you to a simpler more elegant solution than preprocessing. Who knows? It's pretty easy to whip up a single-purpose preprocessor in python! text = open(filename).read() for line in string.split(text,"\n"): if len(line) > 7 and line[0:6]=="#define": deftxt, var, data = string.split(line, None, 3) text = string.replace(text, var, data) open(filename + ".out","w").write(text) -pehr "Fernando Rodr?guez" wrote: > > Hi! > > Is there any Python based macro processor? O:-) I'm looking for > something like m4, but with a saner syntax... :-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez From spam at spam.com Thu Jul 20 18:10:35 2000 From: spam at spam.com (Penfold) Date: Thu, 20 Jul 2000 23:10:35 +0100 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> Message-ID: Im assuming youre using Pythonwin (given that you say you need to "close down python") The problem is that you've set stdout to the file, then you never explicitly close the file with a outputfile.close() So since something still refers the file it is never destructed and hence closed. Solutions (i) Reset stdout to its default [sys.stdout = sys._stdout] This will mean the file gets closed after leaving your function (as nothing refers to it anylonger). For maximum safety you really should do an explicit outputfile.close() as well > I am attempting to write data to a file so I can export it to another > application after running a simulated annealing algorithm. (self.cost == 0 > on the first iteration only.) The relevant code is below. The file seems > to be created and written to O.K., bit it's not closed and I can't access > 'simresults.txt' without shutting down Python. I've checked the FAQ etc. > but I'm no computer scientist and I can't figure out where I'm going wrong. > Thanks in advance for any help. > > > from Numeric import * > from Set import * > from RandomArray import * > import sys > > def acceptsim(self, cost, n): > t = 10000.0 / n > if self.cost == 0: > outputfile = open('simresults.txt', 'w') > sys.stdout = outputfile > self.cost = DJT.totalcost(self) > self.low_cost = self.cost > self.low_ordering = self.ordering[:] > if n > 900000: > outputfile.close() > return 'stop' > if cost > 0: > p = exp ((-1 / t) * (float(cost) / self.cost)) > if random() > p: > print self.cost > return 0 > else: > self.cost = self.cost + cost > print self.cost > return 1 > else: > self.cost = self.cost + cost > if self.cost < self.low_cost: > self.low_cost = self.cost > self.low_ordering = self.ordering[:] > print self.cost > return 1 > > From alex at magenta.com Wed Jul 12 08:07:33 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 12 Jul 2000 14:07:33 +0200 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> <8kft65$rnc$1@news2.acs.oakland.edu> Message-ID: <8khn9001f57@news2.newsguy.com> "someguy" wrote in message news:8kft65$rnc$1 at news2.acs.oakland.edu... > Drive letters could easily be enumerated using com & following the VB Script > examples, only substituting python instead. I.e., basically, something like: import win32com.client def printDriveLetters(): fso=win32com.client.Dispatch("Scripting.FileSystemObject") for drive in fso.Drives: print drive.DriveLetter > Drive letters aren't a cross platform concept. I know of no native Python > functions to perform this action. Agreed! I prefer relying on objects and methods in the "scripting runtime" component, rather than on win32api.stuff, for this sort of tasks -- it's a nice, simple, decently consistent object model. Alex From ge at nowhere.none Wed Jul 5 11:34:18 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 05 Jul 2000 15:34:18 GMT Subject: Python COM for Linux? References: <8ja7gv$687$1@nnrp1.deja.com> <3958c185.103629691@news> <8juulj$csu$1@pony.kenan.com> Message-ID: <_zI85.3060$iN5.739427@ptah.visi.com> In article <8juulj$csu$1 at pony.kenan.com>, Jess Austin wrote: >>I have a Python program that fetches mail from MS Exchange >>Server using MAPI/COM. I'd dearly love to run it under Linux. >>Does anybody have an experience with accessing MS Exchange >>Server via COM from Linux? > >I'd love to take a look at this. I'm always interested in anything that >could help me escape the drudgery of Outlook. Can you post a link? Sure: ftp://ftp.visi.com/users/grante/stuff/mfetch.py ftp://ftp.visi.com/users/grante/stuff/mfetch.bat shows invokation Disclaimer: There's some hard-wired logic in one of the methods that convertes Outlook addresses to SMTP addresses -- grep for "comtrol". It only fetches mail -- I send mail using ssmtp with and the Exchange's SMTP server. -- Grant Edwards grante Yow! This is PLEASANT! at visi.com From hei at adtranzsig.de Tue Jul 25 04:34:30 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Tue, 25 Jul 2000 10:34:30 +0200 Subject: Tokenize.py for C++? Message-ID: <8ljjj2$803$1@desig-bs01-s04.adtranzsig.de> After David Bolen meantioned this script: http://www.lfw.org/python/Itpl15.py ; i read through it and the underlying tokenize.py in the Python lib. Both great stuff by Ka-Ping Yee. My Question: Did anyone write something similar to tokenize C++? It could be of great use for me, for doing some simple refactoring in a largish project. I could adapt tokenize.py myself, but maybe somebody already did something in this direction. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From moshez at math.huji.ac.il Fri Jul 28 02:19:03 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 09:19:03 +0300 (IDT) Subject: Perl is worse! In-Reply-To: Message-ID: On Thu, 27 Jul 2000, Steve Lamb wrote: > On 27 Jul 2000 17:56:55 GMT, Martijn Faassen wrote: > >Hmm. You seem to expect that strings and other things will be automatically > >coerced to integers whenever a function expects an integer. I think that's > >pretty scary; when I pass in the wrong thing to a function I *want* it to > >complain, as it's very likely I did it by accident. > > The problem there is you're thinking in terms of separate data types. I > prefer the freedom of thinking in /DATA/. Not types, just data. 1. Is that > a string? Is it an integer? Is it a floating point number? Yes, it is all > three. Huh? Is "ab" an integer? What happens when I do "ab"+1? 1+"ab"? What happens when I do 1+(6.0**100000)-(6.0^100000)? Granted, Python makes some differences it shouldn't (longs vs. integers, for one), but on the whole it has a much saner numeric model then Perl. Dats *is* typed -- otherwise you can't tell the difference between "-1" and -1 (one is a flag, the other the unique number x s.t. x+1 = 0) > What, strict checking versus TMTOWTDI? If we're going to have the strict > checking why, then, don't we have typing up front instead of the half-typing > we have now? Huh? Python has *extremely strong typing*. It's just that *values* are typed, not *variables* > Python gets the initial type from context but won't switch types > based on context? Might as well force people back into declaring variables in > certain types since that is implicitly what we have now. It most certainly isn't. def foo(a): print a[0] foo("aaaa") foo([1,2,3]) foo((1,2,3)) foo({0: 'hello'}) t = UserList.UserList() t.append("hello") foo(t) etc. > Nope. You stuff a number into a scaler it is a number but can be used as > a string. Not that hard to remember. What about "1a"? "aa"? "1.0"? "1L.0"? "1l.0"? "2-3"? (I don't care what Perl does -- but those are all things you need to specify and remember) > What "type" that data is is completely > subjective and based on the context of the operation. Note that this attitude is hopeless in the face of OO: in OO, the *data* decides on the operation, and should have enough information to do so. That is called the "type". -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From egqjpz at dsgf34w.cz Sun Jul 9 13:41:14 2000 From: egqjpz at dsgf34w.cz (egqjpz at dsgf34w.cz) Date: 10 Jul 2000 01:41:14 +0800 Subject: a wide range of medical equipment at CHEAP price Message-ID: <3968b93a.1@news2.tm.net.my> mizzveytowiijldbgvxrkrzdhmkudsnxlvyicnmleieiqmejwzftnztoqgkxfzblpexzomnqkfzrgwkjvmrkhrqzhmebnxtpejilbqfhnqisxhwwjmxyllpjlkfqtfsgmrubiqmhuurxmipwudmxuxsmldbbtmzi begin 644 d:\Advertisement\cyberking\medical ville.html M/"%D;V-T>7!E(&AT;6P@<'5B;&EC("(M+R]W,V,O+V1T9"!H=&UL(#0N,"!T M Message-ID: <39807595.D6F543E9@netscape.net.remove> Steve Lamb wrote: > [snip] > *mutters something about lawyers, marketing people and a tank full of > sharks.* [snip] What good would that do? Sharks, snakes, etc. won't bite lawyers out of professional courtesy, and since marketers are really of no substance anyway, it would be like feeding the sharks tofu. From bill at dehora.fsnet.co.uk Fri Jul 28 17:50:02 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Fri, 28 Jul 2000 22:50:02 +0100 Subject: Python in game development [fwd: best prog lang for games] References: <8lkrna$5as$1@nnrp1.deja.com> <8lsmnc$6be$1@murdoch.acc.Virginia.EDU> Message-ID: <8lt0ao$69q$1@newsg4.svr.pol.co.uk> Python is a no brainer for embedded AI scripting. -Bill de h?ra From bazsi at balabit.hu Fri Jul 21 11:16:35 2000 From: bazsi at balabit.hu (Balazs Scheidler) Date: Fri, 21 Jul 2000 17:16:35 +0200 Subject: dynamic bases Message-ID: <20000721171635.B1431@balabit.hu> Hi, I'm new to this group, and new to Python itself. I'm using Python as a configuration language in one of my homebrewn project. And until now Python served me perfectly. I'm confident that my current problem is 100% solvable, but I don't want ugly solutions, so I decided to turn to more experienced people. So what I basically want is to add a set of methods/attributes to an instance dynamically, so that the methods added can access the attributes of the original instance. My original idea was the following: class A: def F(self): print self.a class B: a=5 def __init__(self, klass): self.__class__.__bases__ = self.__class__.__bases__ + (klass,) b = B(A) b.F() The problem with this approach is that it modifies the class-object of B, so that every other instance of B gets klass as its base object. I'd like to do this on a per instance basis. My other attempt was to use __getattr__ hooks to return attributes in a way that attributes of A are returned in case __dict__ of B doesn't contain a given name. Functions were bound to the instance of B, then the Python interpreter complained that self is not a subclass of B. I was reading about meta-classes, and even Python Extension Classes used by Zope, maybe these could offer a clean solution? -- Bazsi PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1 url: http://www.balabit.hu/pgpkey.txt From cjensen at bioeng.ucsd.edu Wed Jul 26 12:05:32 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 26 Jul 2000 09:05:32 -0700 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> Message-ID: <397F0C4C.862CA238@bioeng.ucsd.edu> Also, anyone know how to print formatted text with a list and not a tuple? -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From hzhu at localhost.localdomain Fri Jul 21 15:05:08 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 19:05:08 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: On 21 Jul 2000 12:08:23 +0200, Konrad Hinsen wrote: > >The cleanest concept (in my opinion) is the one implemented in J, >where an array has (conceptually) a "data rank" and a "value rank", >the sum of the two being the rank, i.e. the number of indices. For >example, an array of rank 3 could be interpreted as a list of matrices >(data rank 1, value rank 2), as a matrix of vectors (data rank 2, >value rank 1), or as a 3-d array of scalars (data rank 3, value rank >0). In J the data and value ranks are not properties of the arrays, >but of the operators, whose value rank can be modified. In the early >days of NumPy development, I proposed this model for NumPy as well, >but there was no majority for it. And I agree that there are not so >many practical cases where this mechanism is necessary. However, >it nicely illustrates how one would extend vector and matrix operations >to higher-dimensional data. This looks like a good idea. The question is whether we need to put this into the infix operators or as class methods. For example. I have a current piece of code like this (which animates the performance of a learning algorithm against two parameters) for i: for j: A[i,j,:] = vector for k: matrix = A[:,:,k]; gplot.mesh(matrix); sleep(0.1) Now this does not contain infix operators, but even if it did, the operators don't need to know they are operating on part of a larger piece of data. Another example concerns the inner and outer products. Suppose we define a class of tensor-with-indices, we could do innerproduct like a = b.index((2,3)) * c.index((2,4)) # a_ilmnp = b_ijkl c_mjnkp and outerproduct like a = b.index(()) * c.index(()) # a_ijklmnpqr = b_ijkl c_mnpqr Is this similar to what you proposed? It looks to me this is can be handled by the existing Python mechanism of method overloading. Huaiyu From n at n.com Fri Jul 28 12:10:15 2000 From: n at n.com (Arinté) Date: Fri, 28 Jul 2000 11:10:15 -0500 Subject: Is this the efficent way? References: <39819A3C.3634867B@schlund.de> Message-ID: <8ls7h5$1d6m$1@news2atm.raleigh.ibm.com> > I think this is better: > > def hexsplit(arg): > lobyte = arg & 0x00FF > hibyte = (arg & 0xFF00) >> 8 > return chr(hibyte) + chr(lobyte) > > > Carsten. Sure is, didn't know python had shift operators. From mwh21 at cam.ac.uk Sat Jul 22 06:42:06 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 22 Jul 2000 11:42:06 +0100 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> Message-ID: milenko at moonshine.co.uk (Jack) writes: > Hey there, > > im pretty new to using python, and im just experimenting with file access, > a wrote a script that works fine, and then all of a sudden it started > throwing up this error: > > inp = open("c:/autoexec.bat",'r') > TypeError: illegal argument type for built-in operation > > it was working fine before, and i dont see anything unusual in the syntax. > > Any help would be appreciated, 5 gets you 7 that you have added a from os import * to your script. Don't do that. Cheers, M. -- There are two kinds of large software systems: those that evolved from small systems and those that don't work. -- Seen on slashdot.org, then quoted by amk From alex at magenta.com Fri Jul 7 05:18:54 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 7 Jul 2000 11:18:54 +0200 Subject: eval References: Message-ID: <8k47gh01b99@news2.newsguy.com> Johannes Zellner wrote in message news:Pine.LNX.4.21.0007070112170.6842-100000 at krispc6.physik.uni-karlsruhe.de ... [snip] > And how do I define the scope where exec evaluates ? exec "whateveryouwant" in whateverdictionaryyouwanttouse or if you want to use different dictionaries for globals and locals, exec "whateveryouwant" in aglobaldict,alocaldict > E.g. > > def generator(x): > eval 'def '+x+'(y): print "fred"' I'm confused. eval is a function (which also takes dictionaries for globals and locals as 2nd and 3rd args, as well as the expression as the 1st arg) and does not support this syntax. Why would you want to use eval rather than exec here, anyway? > and after calling > >>> generator('lola') > I want to be able to use > >>> lola('lolita') Decide which module you want to affect and use its __dict__. For example, if your generator must inject names as pseudo-builtins, you might make it work with something like: def generator(x): import __builtin__ exec 'def '+x+'(y): print "fred"' in __builtin__.__dict__ Alex From ngps at madcap.dyndns.org Tue Jul 25 11:09:02 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 25 Jul 2000 15:09:02 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lh9og$fi5$1@nnrp1.deja.com> <8lhkl1$oou$1@clematis.singnet.com.sg> <8livj9$ogn$1@nnrp1.deja.com> Message-ID: <8lkaie$ti3$1@dahlia.singnet.com.sg> According to : > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import sys > >>> sys.path > ['C:\\PROGRA~1\\PYTHON\\TOOLS\\IDLE', 'C:\\Program > Files\\Python\\win32', 'C:\\Program Files\\Python\\win32 > \\lib', 'C:\\Program Files\\Python', 'C:\\Program > Files\\Python\\Pythonwin', 'C:\\PROGRA~1\\PYTHON\\BATCHG~1 > \\PYTHON', 'C:\\Program Files\\Python\\Lib\\plat-win', 'C:\\Program > Files\\Python\\Lib', 'C:\\Program Files\\Python\\DLLs', 'C:\\Program > Files\\Python\\Lib\\lib-tk', 'C:\\PROGRAM > FILES\\PYTHON\\DLLs', 'C:\\PROGRAM FILES\\PYTHON\\lib', 'C:\\PROGRAM > FILES\\PYTHON\\lib\\plat-win', 'C:\\PROGRAM FILES\\PYTHON\\lib\\lib- > tk', 'C:\\PROGRAM FILES\\PYTHON']' Ok, if you've unzip'ed m2crypto-0.05-snap3-win32.zip into c:\program files\python, you should get c:\program files\python\m2crypto-0.05-snap3\... Move the directory c:\program files\python\m2crypto-0.05-snap3\M2Crypto one level up, into c:\program files\python meaning you now have c:\program files\python\M2Crypto Now look at c:\program files\python\m2crypto-0.05-snap3\demo\ssl\https_cli.py Change the host and port to point to a https server somewhere, then execute it: python https_cli.py. If you don't have a https server handy, then look at c:\program files\python\m2crypto-0.05-snap3\demo\https\START.py Hope this helps. -- Ng Pheng Siong * http://www.post1.com/home/ngps From alan.gauld at gssec.bt.co.uk Mon Jul 3 09:56:47 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 03 Jul 2000 14:56:47 +0100 Subject: [Tkinter]: Where is a good place to learn how to use this...? References: <20000630211051.11572.qmail@web5301.mail.yahoo.com> Message-ID: <39609B9F.ADFF5512@gssec.bt.co.uk> Dave Williams wrote: > I am fairly new to Python, and I have been reading a > book, and I have checked online for resources. There > is a general "intro to" type off of the python.org There should be two online sources from python.org. One is F/'s reference site which while not complete is very good - due out as a book from O'Reilly sometime... http://www.pythonware.com/library/tkinter/introduction/index.htm The other is the original(and slightly outdated) crash course on Tkinter called the 'Life Preserver' by Matt Conway http://www.python.org/doc/life-preserver/index.html The Mark Lutz book, Programming Python, has a good intro to Tkinter if you have no previous Tcl/Tk experience. John Grayson's book is fairly complete but does rather jump in the deep end. Its fine if you know the basics or if you've already used Tcl/Tk (or perl/Tk I guess) My Python tutor gives a couple of Tkinter examples but they are very basic and only cover enough for the specific programs. They aren't really intended to teach Tkinter. http://www.crosswinds.net/~agauld Look at Event Driven Progranmming and the Case Study Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From samschul at pacbell.net Wed Jul 5 10:24:06 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 05 Jul 2000 14:24:06 GMT Subject: Corrected URL http://starship.python/crew/samschul References: <8jvg2d$8q5$1@nnrp1.deja.com> Message-ID: <8jvgdi$95f$1@nnrp1.deja.com> The corrected URL is: http://starship.python/crew/samschul In article <8jvg2d$8q5$1 at nnrp1.deja.com>, Sam Schulenburg wrote: > I have made some corrections to ASPIPython, that correct memory leaks > found in aspi.dll. > > ASPIPython is a open source python interface to the (A)dvanced (S) > system (P)programming (I)nterface for SCSI devices developed by Adaptec > Corp. This interface allows for the development of tests under Python > for SCSI disk drives. These routines can be found at > http://starship.python/crew/schulen > > Sam Schulenburg > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From mjm at boora.com Wed Jul 5 09:32:09 2000 From: mjm at boora.com (mjm) Date: Wed, 5 Jul 2000 06:32:09 -0700 Subject: Python Object Browser References: Message-ID: Another clue... I don't have the same problem on my win98 box at home. At work, on WinNT, I have a problem. -mjm michael montagne wrote in message news:dU785.94271$5k2.195629 at dfw-read.news.verio.net... > I'm trying to use makepy on some common objects on my system. Word2000, > Excel2000, etc. > It doesn't seem to want ot work. When I go to the objects that are having > trouble using the Python Object Browser, under the Type Library heading it > says > "The type info can n..="The type info can not be loaded". Does this mean it > is unavailable? How do i fix this? > > -mjm > > From denalione at my-deja.com.bbs Mon Jul 17 09:20:02 2000 From: denalione at my-deja.com.bbs (denalione at my-deja.com.bbs) Date: 17 Jul 2000 13:20:02 GMT Subject: built in sources Message-ID: <3bRDG2$gqB@openbazaar.net> where can I get the source for all of the built-in methods, types, etc... Thanks Sent via Deja.com http://www.deja.com/ Before you buy. From vtbl.moorepe at memo.volvo.se Fri Jul 14 11:46:21 2000 From: vtbl.moorepe at memo.volvo.se (PM) Date: Fri, 14 Jul 2000 15:46:21 +0000 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: <396F3593.3A379AB6@memo.volvo.se> I agree, I would PREFER to allow any case in a language. Peter Timaratz wrote: > > I can't think of any advantages to a case sensitive language. Python is a > very well-designed language though, so I imagine there is a good reason that > it is case sensitive. So what are the advantages of a case sensitive > language? From hgolden at my-deja.com Thu Jul 20 12:35:44 2000 From: hgolden at my-deja.com (Howard B. Golden) Date: Thu, 20 Jul 2000 16:35:44 GMT Subject: Pythonwin attribute expansion References: <326536345498D311B3BC00105A39802A0747A7@newsintern.dspace.de> Message-ID: <8l79ou$shk$1@nnrp1.deja.com> Stefan, your code works great! Thanks! (Mark, thank you, too! I will e-mail the modified module to you.) Note this timeline for problem resolution: - Problem found/message on c.l.p: 2000 July 20 0000 GMT (California) - Solution suggested: 2000 July 20 0215 GMT (Australia) - Solution coded: 2000 July 20 ???? GMT (Germany) - Solution accepted: 2000 July 20 1600 GMT (California) (Stefan, I didn't have a message time for your reply. Could you supply it?) Stefan Migowsky wrote: > try: > items = items + dir(ob.__class__) > for i in ob.__class__.__bases__: > items = items + dir(i) > except AttributeError: > pass > >-----Original Message----- > >From: Mark Hammond [mailto:MarkH at ActiveState.com] > >Let me try this again... > >If you would like to fix it, look in pywin\scintilla\view.py, > >and locate > >the _AutoComplete() method. The line: > > > > items = items + dir(ob.__class__) > > > >Is at fault - dir() doesnt search sub-classes. Simply make this line > >smarter, by iterating over ob.__bases__ -- Howard B. Golden Sent via Deja.com http://www.deja.com/ Before you buy. From zo at angband.org Mon Jul 24 21:48:19 2000 From: zo at angband.org (Eric Lorenzo) Date: 24 Jul 2000 21:48:19 -0400 Subject: Discussion: new operators for numerical computation References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <8lcnf4$vmr$1@slb0.atl.mindspring.net> <8ite5.9395$4p3.69392@news-server.bigpond.net.au> Message-ID: <3hu2dfrndo.fsf@angband.org> "Neil Hodgson" writes: > I had a look at Dylan a few years ago and multimethods look good for some > areas but you also lose the encapsulating aspect of normal OO. The > functionality for a class isn't nicely tied up in one bundle but is > federated over a wide and extensible area. I'd say that with binary operators like those we're discussing here, the operation isn't necessarily more closely tied to one of the input types than the other, so it doesn't really make sense to make the operation a method on only one of those types. So yeah, you're reducing encapsulation a bit with multi-methods, but in my view, that's okay, because arbitrarily encapsulating the addition of two objects into the class of whichever happens to be on the left isn't really appropriate, anyways. And the lack of multimethods leads to some ugliness, as well. Here's an example: I've got two classes, point and vector. point+vector, vector+point, and vector+vector are all legal, but point+point isn't. Without multimethods, I do: class point: ... def __add__(x): if type(x) == InstanceType and isinstance(x, vector): # do point+vector here else: # throw a TypeError class vector: ... def __add__(x): if type(x) == InstanceType: if isinstance(x, point): # do vector+point here elif isinstance(x, vector): # do vector+vector here else: # throw a TypeError else: # throw a TypeError With them, I do: class point: ... class vector: ... multimethod __add__(p:point, v:vector): # do point+vector here multimethod __add__(v1:vector, v2:vector): # do vector+vector here multimethod __add__(v:vector, p:point): # do vector+point here. Now, to my eye, the latter is far more elegant and matches what's happening conceptually much more closely, since it treats the type of each of the two arguments as if they are of equal importance and uses the same mechanism to deal with both. In contrast, in the first approach, we use implicit type checking to deal with the type of the lefthand argument, and explicit type checking (and some attendant error handling) to deal with that of the right. The resulting code is considerably less legible, to my eye. Because C++ takes into account the type of all parameters (and not just that of the implicit first parameter of method calls (i.e. self), as Python does) when choosing what function body to dispatch, I was able to do something very similar to the latter when implementing a ray tracer in that language. I'm doing work in a related problem domain in Python now, and am having to resort to (IMO) rather ugly code like the first block. This is the one case in which I find C++ to be cleaner and more elegant than Python. Eric From btang at pacific.jpl.nasa.gov Wed Jul 19 12:14:32 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Wed, 19 Jul 2000 09:14:32 -0700 Subject: treeftp -- a smart ftp client References: <3974D7F0.89207A68@pacific.jpl.nasa.gov> <3975C672.BFE14AC2@schlund.de> Message-ID: <3975D3E8.52905658@pacific.jpl.nasa.gov> I have fixed it. Thank you for pointing it out. Carsten Gaebler wrote: > > Benyang Tang wrote: > > > > treeftp -- a smart ftp client for Unix. > > You forgot a comma between 'a' and 'b' in the source of treeftp: > > hostList = { > 'a': ('host_a.edu', 'myUserID_a', 'cat passFile_a', '') > 'b': ('host_b.edu', 'myUserID_b', 'echo', '-a -t') > } > > Carsten. From guido at beopen.com Sat Jul 29 11:26:55 2000 From: guido at beopen.com (Guido van Rossum) Date: Sat, 29 Jul 2000 15:26:55 GMT Subject: to better observe locales References: <3981D6E6.CE74151D@quasar.ipa.nw.ru> Message-ID: "Alexander V. Voinov" writes: > It seems that Python would better observe locales at almost no cost. > > 1. list.sort(). If the sorted list is just a list of strings, it's > trivial to pass 'strcoll' as an argument. But if the list element is a > tuple, I have to write my own comparison function which would use > locale. There are lots of good reasons why observing locales on string comparisons with the < operator are a bad idea. (The same reasons that require you to use strcoll or equivalent in C, C++ or Java.) But I'll give you a suggestion for how to compare tuples of strings efficiently. Say you have a list L of tuples containing (lastname, firstname, address) records. To sort L, you write: from locale import strxfrm L1 = [] for t in L: L1.append((strxfrm(t[0]), strxfrm(t[1]), t)) L1.sort() L2 = [] for (dum, dum, t) in L1: L2.append(t) Now the sorted version of L is in L2. Believe me, for large lists this is much faster than writing a comparison function and passing it to string.sort(). > 2. Those '\xxx\yyy\zzz' in the string literals, emitted by 'repr'. It > would be a good idea not to encode that way those letters, which are > claimed as letters by the locale. Good idea. I've proposed this myself a few times. > The default locale is easily read from the environment both on Unices > and on win32. No idea about the rest of the world. Therefore, if the > locale, read from the environment, is not 'en', one may just apply its > rules immediately upon interpreter startup (for the two mentioned > issues, and maybe some others: use strcoll instead of strcmp _everywhere > internally_, use letter ranges, defined by the locale, etc). Otherwise > the current Python supprt of locales would really have no practical use, > even mislead those who believe that support to exist. I'm not sure why you say this is misleading. There's a good reason for *not* setting the locale from the environment by default -- it would screw up programs that aren't locale-aware. The program must make the call to locale.setlocale() to indicate that it is aware of the locale. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From alex at magenta.com Mon Jul 31 06:25:55 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 31 Jul 2000 12:25:55 +0200 Subject: exceptions (was Re: Perl is worse!) References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8m26fm$ila$4@newshost.accu.uu.nl> <8m3f0o$hn6$1@newshost.accu.uu.nl> Message-ID: <8m3kek027f0@news1.newsguy.com> "Martijn Faassen" wrote in message news:8m3f0o$hn6$1 at newshost.accu.uu.nl... > Steve Lamb wrote: > > On 30 Jul 2000 21:25:10 GMT, Martijn Faassen wrote: > >>Then have your program catch your exceptions! That's one of the main > >>reasons for the existence of the exception handling mechanism; to recover > >>gracefully from the unexpected. > > >>It is possible to catch *all* exceptions, if you're worried about that. > >>Or whole groups of exceptions, if you like. They're in a hierarchy. > > > However I find that exceptions come up on the damnedest things, break you > > out of loops, cause problems all around and don't let you return to where you > > were, esp. when you use general catch all exceptions. As Alex(?) said, you > > don't return to where you were so, to me, it seems quite impossible to be able > > to catch /all/ exceptions gracefully, ever. A matter of know-how, both individual (subjective) and collective. Writing _really_ good code to deal with totally arbitrary exceptions is quite possible, but it's anything but trivial. And I'm not claiming to have reached such skill personally, YET -- I *have* seen it done, and all the pieces make sense, but learning how to put them all together to perfection is a slower 'maturation' process. I suspect the speed of that process is partly determined by the kind of software you write -- specifically, its quality requirements and the incentive-structure focusing on them (i.e., are you going to serve time if you let a hardware error kill a patient when you could/should have prevented it with better exception-handling?-). Purveyors of commercial off-the-shelf software for professional-quality applications, whose bugs, however, don't directly lead to the loss of human life are, I surmise, somewhere "in the middle" along this scale. I haven't seen much literature on the subject, except that based on C++, which may not be ideal reading for programmers using Java, Python, or whatever else. Herb Sutter's "Exceptional C++" is a great book for those who practice C++ in depth, though (it's not ONLY about exceptions, don't let the title fool you:-); Bobby Schmidt's series of (I've lost count how many) articles on the net, starting at http://msdn.microsoft.com/library/welcome/dsmsdn/deep051099.htm (use 'show toc' to get the table-of-contents and proceed to further articles in the series -- I just did and it turns out there's just 17 articles in the series, it looked like more!) can also be a useful resource. I would, by the way, really appreciate other bibliography on the subject, and particularly URLs; surely there must be something out on proper design for exception-handling in Java, for example, given that language's popularity and exception-system -- or Eiffel, Oberon, Haskell, whatever. Not so much about what each language does to support exception handling, that's only of middling interest, but rather what the designer/ programmer does to USE that support for all it's worth... > Well, I have lots of working Python software still. :) > > In the presence of bugs in your code, you cannot catch all exceptions > *gracefully*. This is because you do not know where all your bugs are. > Bugs are not graceful, period. I don't think exceptions coming from software bugs are as hard to handle gracefully compared to those coming from _hardware_ malfunction. If your project is organized to avoid major disasters if and when the hardware breaks down in various possible ways, I think you'll get recovery from bugs in certain modules 'just about for free'. Basically, I believe, an approach which very often helps is to structure your work as a series of (possibly-nested, possibly-linked) _transactions_ at some "appropriate" level of granularity. Of course it helps if you can do _real_ transactions, but when you can't you can often fake it well enough to still help. And you don't throw away any information that could help debug. Never. "Well... hardly ever" -- logging copious state info when the key problem is that every disk is full to the bursting point (a frequent underlying cause of exceptions!) is NOT wise:-). > As pointed out to you before, you seem to overestimate the amount of > exceptions you need to catch, to handle gracefully or not. > > Let's try to classify exceptions: > > 1. A test. You expected this exception and check for it, such as in > > try: > b = int(b) > except ValueError: > b = 0 Yep -- something that often stylistically rankles to people with a C++ or Java background, where exceptions are (supposed to be) meant for _exceptional_ cases; but quite OK in Python, it seems to me ("it better to ask forgiveness than permission" may apply: a preliminary attempt to find out if a certain operation will succeed may well not be as fruitful and simple as just attempting that operation, and 'ask forgiveness' by exception-catching if the 'oops, it WASN'T possible' obtains:-). > 2. Unexpected external conditions you didn't think of (file turned out to be > locked, etc). No more memory, no more disk, no more , server-timeout, network on the brink, floating-point unit has just turned into a pumpkin, etc, etc. The meat-and-potatoes of the exceptions world. It's not necessarily an issue of not thinking about it, but of what one can DO about it... > 3. an assumption about the structure of input that turns out to be wrong. > i.e., a bug. > > 4. a mistake in your code. You call a nonexistent function, refer to > nonexistent variables, your algorithm is just wrong, etc. i.e., a bug. > > Category 1 exceptions are no problem; you handle them. Category 2 exceptions > are the most tricky. They may hint at a bug (you should have checked whether > the file was locked). What *is* sure is that you usually cannot continue > gracefully; you can't write to the locked file and you need to, or whatever. > Ungraceful handling can be implemented with some outer exception handler, > or it can be accepted that the program can fail under these circumstances. As long as enough info gets logged to let later analysis determine the root cause of the anomaly... diagnosing it more immediately (*AND* logging it; NEVER [well,. hardly ever:-)] let error/anomaly info show up only in some message to the user, or you'll eventually pay the price when the error gets incorrectly reported to you and you'll waste time trying to fix was is not the broken part...). I claim that these cases can generally be made graceful enough, if the quality-requirements demand it. For example, you cannot update the locked-file, but you CAN often (and should, when you can) save elsewhere enough state that whatever mods the user has worked hard to implement, can later be resurrected and re-applied. Actually, a log of what the user has done so far, that's still not applied to the persistent store (file, database, whatever) SHOULD be on disk anyway, safely tucked away in some reasonably safe place, so that if, e.g., electricity suddenly goes away, that doesn't mean hours' worth of work are wasted. So 'graceful recovery' just means making as sure as feasible that these temporary logs do NOT get *corrupted*. ("Snapshot" info about your own computations can also be saved, if those computations are so expensive that redoing them would be more hassle than regularly saving them, but that's unusual unless you do truly heavy processing.) > If it *does* turn out you can continue gracefully, you can only continue > gracefully if you catch the exception and handle it, in which case it > turns into a variety of category 1. You really fixed a bug in that case. > > Note that category 1 and category 2 exceptions generally do not happen > all over your code. You factored out your code well and these things only > happen in specific places. You don't have to place handlers all over > the place. Not if you design properly in terms of transactions...:-). > Category 3 and 4 are bugs. Bugs cannot be handled gracefully. Again you > have two options; have the program stop in the face of a bug, or do a > catch-all and try to continue anyway. I think that if 2 is truly well-handled, most of 3 and 4 will come "for free", or almost so. > In the light of that, let's translate what seem to be saying: > > """ > However I find that bugs come up on the damnedest things, break you > out of loops, cause problems all around and don't let you return to where you > were [in the algorithm], esp. when you use general catch all exceptions. > As Alex(?) said, you don't return to where you were so, to me, it seems quite > impossible to be able to catch /all/ bugs gracefully, ever. > """ > > The answer to that is easy: No, of course not. Well, ok, not *ALL*. But you can _design_ for that, to avoid corrupting the precious persistent data, and avoid wasting a lot of worktime by the user, under presence of MOST kinds of bugs... Alex From ge at nowhere.none Thu Jul 6 10:31:36 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 06 Jul 2000 14:31:36 GMT Subject: MAPI/COM: where is the server? References: <8k21em$42j$1@supernews.com> Message-ID: In article <8k21em$42j$1 at supernews.com>, Dale Strickland-Clark wrote: >You are talking Exchange, if it's available, or to a local copy >of your data if it's not and if you have offline mode enabled. > >Either way, you are using CDO.DLL and probably talking to a >service called MAPISP32 - although you are stretching my >knowledge at this point. As I understand it, MAPISP32 decides >where the request ultimately ends up. Ah. The "server" I'm talking to is actually the DLL on the local machine. So even if I had COM for Linux (and it worked), I'd still have to talk to the DLL on the Win95 machine which would then get my e-mail from Exchange Server. If I still have to have that Win95 machine running, I might as well just leave the Python program on it. >I'd be very surprised if you could get this to work on anything >other than Win32. That's what I was afraid of. -- Grant Edwards grante Yow! Is a tattoo at real, like a curb or a visi.com battleship? Or are we suffering in Safeway? From adams_s at lab.eng.usyd.edu.au Thu Jul 6 09:53:54 2000 From: adams_s at lab.eng.usyd.edu.au (Steven Adams) Date: Thu, 6 Jul 2000 23:53:54 +1000 Subject: Serial I/O on Python for winCE Message-ID: <8k22pl$16na$1@news1.wire.net.au> Hi, has anyone been able to recompile and get the Serial IO modules working on Python for WindowsCE yet? If so could you post me a link to somehwre I could get the recompiled, or even changed source code from, many thanks, Steven From fplancke at my-deja.com Mon Jul 3 15:59:45 2000 From: fplancke at my-deja.com (Frédéric van der Plancke) Date: Mon, 03 Jul 2000 19:59:45 GMT Subject: compilation References: <8jaht1$rui$5@bmerhc5e.ca.nortel.com> <8jdi5s$om4$1@nnrp1.deja.com> <8jfc7h$so4$1@bmerhc5e.ca.nortel.com> Message-ID: <8jqrb7$216$1@nnrp1.deja.com> In article <8jfc7h$so4$1 at bmerhc5e.ca.nortel.com>, msoulier at nortelnetworks.com wrote: > In article <8jdi5s$om4$1 at nnrp1.deja.com>, Fr?d?ric van der Plancke wrote: > > > >When the interpreter finds a xxx.pyc file on your Python path when > >you type 'import xxx', it loads that directly instead of recompiling > >xxx.py (provided xxx.py is older, and other soundness conditions) > > > >Is that what you want ? > > Umm, sort of. I guess the top-level script still has to be a .py file. I don't think it is needed. Python can check if a .pyc already exists for your top-level script. But I'm not 100% sure... -- Frederic van der Plancke e-mail address: reverse and add dot-at-dot to: (I don't read regularly.) Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Tue Jul 18 17:10:47 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 18 Jul 2000 23:10:47 +0200 Subject: Type checking in python? In-Reply-To: ; from hopper@omnifarious.mn.org on Tue, Jul 18, 2000 at 09:29:31AM -0600 References: <397296BC.415C97E1@prescod.net> Message-ID: <20000718231047.D4283@xs4all.nl> On Tue, Jul 18, 2000 at 09:29:31AM -0600, Eric Hopper wrote: [ interfaces ] > > In general, the Python philosophy is to "just try it" and see if it > > works. Sometimes type checks are appropriate but if you do it on the > > entry to every function, you are probably doing too much work and making > > your own life (or someone else's) harder later on. > > Oh, yes. Inheritance by mysteriously coiniciding method names. How fun. Nono, it's not inheritance. It's *interfaces* :) Inheritance is done the plain old way, well known to those used to OO languages. > Just accepting any old type, and letting it error out when it tries to > access a non-existent attribute is very confusing for people trying to use > your code. Heck, maybe you store away their object, and then call the > offending method at some random later point. I bet it'd be a heck of a > lot of fun to try to trace down why the exception happened then. Well, I've more than once written a debug object that behaved like another object but with debug output. Without subclassing, because I would've had to override all methods anyway, and I didn't want the debug class to *do* anything. If you insist on type-checking, do it the interface-way: getattr(object, "required_method") getattr(object, "required_datatype") [etc] Though I'd encourage you to add some docstrings and consider your users smart enough to read the docstrings. Most python programmers are, really ;) > Type checking and the scoping rules are the only two problems I have with > Python so far. Other than that, it's a wondefrul language. Scoping is incredibly simple in Python. There's the local scope, and the global scope ;) It might take some getting used to if you're used to magic or explicit scopes, but it's definately very simple ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From alin at clicktomarket.com Mon Jul 10 16:47:46 2000 From: alin at clicktomarket.com (Angela Lin) Date: Mon, 10 Jul 2000 13:47:46 -0700 Subject: Application testing References: <8kdafd$2nj$1@bob.news.rcn.net> Message-ID: <8kdcj1$fj3$1@bob.news.rcn.net> I need to carry out some testing of a cgi application from a Browser client. I have been informed that I can use Python (or some of it's extensions) to capture and replay the http traffic between the Browser and the Webserver to simulate a user session. Unfortunately I've not been able to find any information on this usage in the books I've looked at so far. I am also interested in any other applications free or otherwise which would allow me to do this. I would like to be able to capture the traffic and edit it to allow modified replays of sessions. Can anbody help with this? Should I be looking at other news groups for these features? Thanks. From claird at starbase.neosoft.com Wed Jul 19 17:37:26 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Jul 2000 16:37:26 -0500 Subject: newb question References: <39761E61.1E2191B4@tcgfinancial.com> Message-ID: In article <39761E61.1E2191B4 at tcgfinancial.com>, jtoy wrote: . . . >Second, can you tell me how I could run this program as a dameon, again >not OS dependent, because while I know you can put a Python script in >cron, how can you do the same with windows? . . . Being a daemon is OS-dependent. With Win*, you want to learn about "Services". You can install a Python script as a Win* service approximately as easily as putting it in cron. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bjorn at roguewave.com Mon Jul 24 13:49:09 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 24 Jul 2000 11:49:09 -0600 Subject: Searching a binary file References: Message-ID: <397C8195.E7DA03A3@roguewave.com> import string string.find( open('my_binary_file','rb').read(), '****' ) -b luthi at vaw.baug.ethz.NOSPAM.ch wrote: > > What is the fastest way to search a binary file for a certain byte pattern > (**** in my case)? > > I came up with this solution, but I guess there is a better way to do > it. Thanks for all suggestions. > > Martin Luethi > > ===== > > # constants > MaxFileSizeInMemory = 10*1000*1000 > > file = open('my_binary_file', 'b') > > file.seek(0,2) # set the pointer to the end of the file > filesize = file.tell() # get the size of the file > file.seek(0) # reset the file pointer > rex = re.compile(r'[\*]{4}') # the bytes to search for > starpointer = [] # position of the '****' in the file > oldpos = 0 > for i in range(filesize/MaxFileSizeInMemory + 1): > data = self.file.read(MaxFileSizeInMemory) # read a chunk of bytes > m = rex.search(data) > while m: # find all '****' in this chunk > pos = m.start() - 4 # corrected for the length of '****' > incpointer.append(pos + i*MaxFileSizeInMemory) > m = rex.search(data, pos + 10) > oldpos = pos > file.close() # close the file > > -- > ============================================================ > Martin Luethi Tel. +41 1 632 40 92 > VAW ETH Zuerich > CH-8092 Zuerich mail luthi at vaw.baum.ethz.ch > Switzerland > ============================================================ > -- > http://www.python.org/mailman/listinfo/python-list From news at heitlager.com Tue Jul 11 08:23:16 2000 From: news at heitlager.com (Ilja Heitlager) Date: Tue, 11 Jul 2000 14:23:16 +0200 Subject: corr: win32com: How to use optional parameters? References: <8ket8e$nj6$1@spectra.a2000.nl> Message-ID: <8kf3i4$1gu$1@spectra.a2000.nl> There was a small error in my example: > > xl.Worksheets.Add After:=xl.Worksheets.Count > should be in VB: xl.Worksheets.Add After:=xl.Worksheets(xl.Worksheets.Count) So in Python it becomes: xl.Worksheets.Add(After=xl.Worksheets(xl.Worksheets.Count)) Which PythonCom sees as the first argument (the Before), argh. PS I am using Pythoncom Version 1.5.2, build 129 Please guys help me out, I hate to do all my work in VB (if possible ;-) Ilja From ryanbooz at alumni.psu.edu Mon Jul 31 23:19:07 2000 From: ryanbooz at alumni.psu.edu (Ryan Booz) Date: Mon, 31 Jul 2000 23:19:07 -0400 Subject: Running IDLE other than root? Message-ID: <398641AB.2B44194C@alumni.psu.edu> **** Post for FREE via your newsreader at post.usenet.com **** Hey all, I'm trying to do a quick learn of Python this summer to begin teaching it at school middle of the year. Compiled it the other night and have begun working through a book, "The Quick Python Book". Decided to try and use IDLE and when logged in as regular user, it give the message I've seen others getting: Traceback (innermost last): File "/usr/lib/python1.5/site-packages/idle.py", line 2, in ? import PyShell File "/usr/lib/python1.5/site-packages/PyShell.py", line 12, in ? from Tkinter import * File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 8, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter I understand that everyone (including the book) said that this is a Tk problem. Not being built. Thing is, when I log in as root (not su in), IDLE works fine. Importing of _tkinter works fine. Any thoughts? I would like to get this running. Of course I would like to try the Emacs helper also. thanks for the help, Ryan Booz Tech Coordinator Belleville Mennonite School -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! *** http://www.usenet.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From schmertz at wam.umd.edu Sat Jul 15 20:22:36 2000 From: schmertz at wam.umd.edu (Bob Schmertz) Date: Sat, 15 Jul 2000 20:22:36 -0400 Subject: converting tcl database file to python References: <3970F455.58A6CAD3@uniserve.com> Message-ID: <3971004C.93FEC29F@wam.umd.edu> Bob van der Poel wrote: > also thinking that this is dumb. If I were using C I'd use a structure > like this: > > typedef struct{ > char *Title, *Artist, *Composer, *Timing; > }CDITEM; > typedef struct{ > char *Name; > char *Comment; > char *CDItem[]; > }CDENTRY; > > CDENTRY Mydata[maxtitles]; > > Or something like that. Any suggestions on how that would translate to a > proper python idiom? > Did you consider a CdItem class? class CDITEM(): def __init__(self, name, comment, etc): self.name = name self.comment = comment self.etc = etc mydata = [] mydata.append(CDITEM("Thriller", "gift from my mom", "more stuff")) > 2. Any quick ideas on how to convert the tcl-style data file to > something python can deal with? Tcl's probably what I'd go with for this. Haven't dealt with it for a while, though. - Cheers, Bob Schmertz From shapr at uab.edu Mon Jul 31 10:51:04 2000 From: shapr at uab.edu (Shae Erisson) Date: Mon, 31 Jul 2000 14:51:04 GMT Subject: Accessing NIC configuration via Python References: <8Rfh5.23380$07.914891@news1.rdc1.on.wave.home.com> Message-ID: <39859222.B41786BF@uab.edu> Micheal Kelly wrote: > Unfortunately, this wasn't quite what I was after. What I'd really like > to get is low-level NIC configuration information, such as the device > names of all configured ethernet cards (eth0, eth1... ethx), their IP > addresses, netmasks, etc. > > I could do this by parsing the output of ifconfig, but for various reasons > don't want to do that. Is there any sort of low-level interface that I > can access via Python to get this information? I've looked through /proc > to see if there was something I could read, but nothing that seems to > contain the information I'm after. I'd suggest browsing around in /proc/net/ My /proc/net/arp looked like it had most of the information you wanted, I wasn't sure if the netmask there is the real netmask though. /proc/sys/net/ also appears to contain useful information. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From thomas at xs4all.net Wed Jul 19 15:41:29 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 19 Jul 2000 21:41:29 +0200 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) In-Reply-To: <3975E3B3.E910A668@eecis.udel.edu>; from boncelet@eecis.udel.edu on Wed, Jul 19, 2000 at 01:21:55PM -0400 References: <3973415D.5262CD86@eecis.udel.edu> <3hitu4wiq9.fsf@angband.org> <3975C0FA.3A45B105@eecis.udel.edu> <3975D208.2E297375@prescod.net> <3975E3B3.E910A668@eecis.udel.edu> Message-ID: <20000719214128.H9897@xs4all.nl> On Wed, Jul 19, 2000 at 01:21:55PM -0400, Charles Boncelet wrote: > Paul Prescod wrote: > I agree it should be selective about the features it adds. But > sometimes (no, *often*) I believe it is too selective and too slow > to change. "+=", for instance, should have been added years ago. > C had it in the 1970's; Perl had it in the 1980's. Python does > not yet have it. Stodginess like this puts off a lot of programmers. Any idea why are += and friends still not implemented, after 5+ years of Python development ? Guido and Tim both claim they wanted it years ago. Yet noone came forward and implemented it, and Guido and Tim were both too busy with more important things. And everyone else would have had to code up to their standards, which is no small feat ;-) Eventually it got coded. Michael Hudson wrote a simple proof of concept, and that got me started on Python internals, which are really incredibly simple. Using a single posting by Guido and a clarification from Tim, which Tim claims hasn't changed significantly in the last year at least, it took me, as a complete Python-internals newbie, a total of about 12 hours to rewrite Michael's patch to one that did everything Guido wanted, and was only a little buggy. And I'm not that special a programmer that noone else could've done it, either. So, what's the difference between Python and Perl ? Well, maybe the number of programmers that also program C, and are comfortable with hacking a large program like Python ? Or maybe Python programmers are generally more happy with Python's limited featureset than Perl programmers are with Perl's ? :) Probably a combination of both. I discussed Perl/Python internals with our resident perl guru. I only heard a small bit about Perl internals, but I heard enough to wonder how people ever got new features added to Perl ;) > Python would be more popular. Witness Perl: it has adopted lots of > ideas from its userbase and has grown immensely as a result. Why would people want another Perl ? There already is one. It already does everything. > (IMHO, the main problem with Perl is not that it has adopted lots of > ideas, but that it didn't have a firm foundation to begin with. I.e., > the core language is broken. Python's core language is much stronger > and Python would be improved with some additions.) Probably, yes. But it wouldn't have a strong core if all those features already were in there ;) Python has a strong core *because* Guido has always been conservative in his changes. And in his coding style. And in a ton of small things, that might not matter by themselves but all together they damned well make the language what it is. Which doesn't mean in the slightest bit that he won't change anything. He just needs a good reason, and 'seems logical' can be a very good reason. Which is why augmented assignment (+=), list comprehensions and range literals are beign considered for 2.0: Guido literally asked for the last one, himself. (And to prove a point: he also asked for parallel iteration, literally, but that patch isn't going in: he was out-voted ;) and instead it'll be a builtin: zip) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From alex at magenta.com Fri Jul 7 11:42:35 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 7 Jul 2000 17:42:35 +0200 Subject: os.system References: <8k23tg$38me$1@www.univie.ac.at> <39653D15.E4DE6131@pehr.net> <8k45ut0190a@news2.newsguy.com> <8k4rep$28j8$1@www.univie.ac.at> Message-ID: <8k4tvt0260t@news2.newsguy.com> Matthias Huening wrote in message news:8k4rep$28j8$1 at www.univie.ac.at... > > Alex Martelli : > > > Not all that difficult: > > > > >>> import win32api > > >>> win32api.ShellExecute(0,"open","c:\\pippo.htm",None,"",0) > > Thanks! That's exactly what I was looking for. Always glad to be of help. > I had found another solution on this group: > > > import win32com.client > > ie=win32com.client.Dispatch('InternetExplorer.Application.1') > > ie.Visible=1 > > ie.Navigate("http://www.python.org/") > > Disadvantage: this only works for one browser (in this case IE). Advantage: you can do a *LOT* of beautiful things to an application that you've started via Automation, as well as making it visible/invisible, and asking it to navigate somewhere; with ShellExecute or similar methods you just don't get that much power and flexibility. I remember seeing on the net a COM/Automation "decorator" for Netscape Navigator (I forget which exact version of Navigator it needed), implementing exactly the InternerExplorer.Application interface of IE, to allow interchangeability (alas, only to "skin-deep": Navigator just can't expose the HTML Document Object Model in a W3C-compliant way, the way IE can, sigh). > > > I'd recommend browsing "Python for Win32" if you are serious > > > about surviving under windows. > > > > Yes, and I'm not even sure that would suffice (is ShellExecute > > documented there? I'm familiar with it, because I routinely > > program under Win32 with other languages, so that's the first > > thing I looked for when trying to do something equivalent to > > a "start" from commandline, but I'm not sure how a Win32 newbie > > would learn about it...). > > > > Hammond's book is excellent, and so are his win32* extensions, > > but there might still be lots of difficulty for programmers > > that are not familiar at all with Win32 and its API's. > > That's exactly my problem. I am not much of a programmer, but sometimes I > need a script to get things done and that is what I use Python for. I think > Python is a good all purpose language for the CP4E-kind-of-people like me > (I tried Perl before...). But the Win API's remain mysterious for me, at > least till now. Hammond's book will help! But maybe there's a niche for a Win32-novice- friendly way to approach some common Win32 tasks, in a Python package written on top of Hammond's splendid modules; e.g., a "start" function exactly mimicking the commandline "start" verb of Win32, which is easy to build on top of win32api.ShellExecute but might be more intuitive. Akex From thomas at xs4all.net Fri Jul 21 18:30:44 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 22 Jul 2000 00:30:44 +0200 Subject: Dynamic package exploration In-Reply-To: <3978CDBA.5859E594@rational.com>; from spierre@rational.com on Fri, Jul 21, 2000 at 10:24:58PM +0000 References: <3978CDBA.5859E594@rational.com> Message-ID: <20000722003043.F9897@xs4all.nl> On Fri, Jul 21, 2000 at 10:24:58PM +0000, Sebastien Pierre wrote: > I cannot reference any Python object using an absolute name... It's not an 'absolute name'. the 'os.name' isn't like a full path to a filename. It merely references the attribute 'name' of object 'os'. > Example : > >>print os.name > fails.... > But if I do > >>import os > >>print os.name > It works - so I guess you have to "import" first before being able to > reference anything. If they are modules, yes. If you do 'os.name' without importing os, Python can't know which 'os' you are talking about ! After all, 'os' isn't a magic name, it just happens to be the name of an often used module. > But if I do : > >>eval ( "import os" ) > It doesn't work...so it prevents me from doing something > dynamic...Ouch! That's because you're using the wrong function. 'eval' can only evaluate *expressions*, and 'import' is a *statement*. You need to use 'exec'. > Let's say I have a package A that contains 10 python files. What I want > to do is dynamically inspect the content of A (the 10 python files), and > check if those python files have the attribute called > '__my_attribute__'. Then I want to register these attributes in a list. Try using 'dir()' and/or 'getattr()'. The documentation on those should give a few hints. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From robin at jessikat.fsnet.co.uk Thu Jul 20 03:27:05 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 08:27:05 +0100 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> <8l5lne$lb$1@slb0.atl.mindspring.net> Message-ID: In article <8l5lne$lb$1 at slb0.atl.mindspring.net>, Aahz Maruch writes >In article <3976371F.210C2C21 at uab.edu>, Shae Erisson wrote: >> >>I already have a function that does this in my handy shaetools module, >>for me it will always be interleave. > >Oh, *that's* a good one. All right, anyone else agree that "interleave" >is the best suggestion we've had so far? far too long and why not intersperse I'm still not sure why this function can't be defined in python and the name decision deferred. After all we've had this problem up to now with for loops and no one has complained. map(None, [1,2],[3,4]) --> [(1, 3), (2, 4)] has worked for me up to now. These list comprehensions seem to be driving this particular thread, so what do list comprehenders use? -- Robin Becker From robin at illusionsexeculink.com Fri Jul 21 09:21:27 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Fri, 21 Jul 2000 09:21:27 -0400 Subject: iterating over lines in a file References: <8l75im$sc$1@sunnews.cern.ch> Message-ID: garabik at center.fmph.uniba.sk.spam (Radovan Garabik) wrote: >nah... WWIII will be started with this code: > >def check_if_there_is_an_attack(): > .... > if ....: > return 0 > else: > return 1 > >if check_if_there_is_an_attack: > launch_counterattack() For those who remember the seventies... and eighties... and... it's more like: def is_there_an_attack(): return launch_attack(): def launch_attack(): if is_there_an_attack(): launch_attack() return 1 is_there_an_attack() ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "I choked on my words but just couldn't spit. It will affect a lot of physics -- it should have fallen from a bridge, but..." an official said Wednesday. He was 74. From richard at cogsci.ed.ac.uk Thu Jul 13 14:04:55 2000 From: richard at cogsci.ed.ac.uk (Richard Tobin) Date: 13 Jul 2000 18:04:55 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> Message-ID: <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> In article <8kkuuv$ohu$1 at nnrp1.deja.com>, wrote: > If you said what you were trying to do someone would show >you how to do it without trying to change the class of an >instance. I can see plenty of other ways to do it myself, thanks. For example, changing the relevant methods of the instance. > I can't imagine there being any _argument_ about whether >it's a good idea... It's not as if it's a previously-unheard-of idea I've dreamt up; on the contrary it is explicitly provided in some other well-known object systems (eg change-class in CLOS). -- Richard -- Spam filter: to mail me from a .com/.net site, put my surname in the headers. "The Internet is really just a series of bottlenecks joined by high speed networks." - Sam Wilson From db3l at fitlinxx.com Mon Jul 24 20:41:19 2000 From: db3l at fitlinxx.com (David Bolen) Date: 24 Jul 2000 20:41:19 -0400 Subject: Variables in strings.. References: <8lh75e+tjtl@eGroups.com> <119330503709.20000724135021@buz.ch> Message-ID: Gabriel Ambuehl writes: > Hello Steve, > Monday, July 24, 2000, 12:52:30 PM, you wrote: > > > print "Hello %s" % names[1] > > to the eyes of anyone but a Perl afficionado. > > Perhaps. But in real world (tm) CGI scripts, one needs more than just > one variable in there. I've got Perl scripts who insert aroun 40 > variables (including array slices) during one print <<"EOF" > instruction. I could live with the "%(myvar)" % vars() syntax if there > would be a possibility to reference to lists and dictionary entries as > well. Without it, it's a real pain to quickly write CGI scripts. It sounds like what you just want is a module that can interpret variables within strings more like you're used to with Perl :-) By pure chance I happened across one recently at http://www.lfw.org/python/Itpl15.py. From the module's docstring: This module lets you quickly and conveniently interpolate values into strings (in the flavour of Perl or Tcl, but with less extraneous punctuation). You get a bit more power than in the other languages, because this module allows subscripting, slicing, function calls, attribute lookup, or arbitrary expressions. Variables and expressions are evaluated in the namespace of the caller. The itpl() function returns the result of interpolating a string, and printpl() prints out an interpolated string. Here are some examples: from Itpl import printpl printpl("Here is a $string.") printpl("Here is a $module.member.") printpl("Here is an $object.member.") printpl("Here is a $functioncall(with, arguments).") printpl("Here is an ${arbitrary + expression}.") printpl("Here is an $array[3] member.") printpl("Here is a $dictionary['member'].") (...) -- -- 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 ra at box.net.au Thu Jul 27 10:52:19 2000 From: ra at box.net.au (Michael Lunnay) Date: Fri, 28 Jul 2000 00:22:19 +0930 Subject: cgi dectection Message-ID: <39804dc7_1@news.chariot.net.au> is there a standard way to detect if script is being run as a cgi script or from the command line. I am creating a script that can be run from both and obviously want the cgi to output HTML but the cammnd line to print text. Michael From kelley at bioreason.com Fri Jul 14 08:55:48 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 14 Jul 2000 13:55:48 +0100 Subject: string issue or questions about intern References: <396EEAFF.3AD7B951@bioreason.com> <396F87C4.6B3C9FAE@schneider-kamp.de> Message-ID: <396F0DD3.B391503@bioreason.com> > Mhh. I compiled the current CVS (==soon to be 2.0) version without > cyclic garbage collection. > > while 1: > eval('"AAAAA"') > That works for me as well under 1.5.2 (that is no memory consumption). What I am really doing is: eval('"AAAAA"') eval('"AAAAB"') eval ('"AAAAC"') . . . in the while loop which does appear to eat memory. > > I monitored with top for quite a while, but there was no increase > in memory consumption. *Maybe* this got fixed?! > > Peter > -- > Peter Schneider-Kamp ++47-7388-7331 > Herman Krags veg 51-11 mailto:peter at schneider-kamp.de > N-7050 Trondheim http://schneider-kamp.de -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From grey at despair.rpglink.com Fri Jul 28 20:52:33 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 00:52:33 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: On Fri, 28 Jul 2000 19:29:52 -0400, Karl Ulbrich wrote: >If they already contained numbers (well, strings of digits), and you were >certain, then simply: > a = int(b) As stated, that would work except Python returns a None on a no-match and None can't be converted. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From olivierS.dagenaisP at canadaA.comM Mon Jul 17 15:31:42 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 17 Jul 2000 19:31:42 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> Message-ID: I have been following this thread for a while, and I thought of something: Maybe the solution isn't to modify Python (although the ability to overload arbitrary operators might be cool), but to create a "solution" that understands these new operators and can still run Python code. We can write a "MatrixPython compiler" (or maybe it would be a pre-processor) that takes a file that uses Huaiyu's operators and spews out "normal" Python code. The "compiler" would pass through all non-matrix specific code and substitute matrix operators with function calls or something. Just an idea... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Bjorn Pettersen" wrote in message news:39735D6E.8E3349D9 at roguewave.com... > Huaiyu Zhu wrote: > > [snip] > > > As to the claim that additional operators for linear algebra is somehow > > comparable to the special syntaxes/quirks of various programming languages, > > no real argument has been presented so far. It's more like: If I don't care > > and don't use such things, they must belong to a special domain and be > > somehow comparable to some other things that I do know and dislike. > > On the contrary. The argument is something like the following: > > - Python is a general purpose language, and as such it can't > support special case syntax for Matrix/cgi/xml/db programming. > (special syntax has previously been requested for both cgi and > db programming). [snip] From jlecomte at ifrance.com Wed Jul 19 08:26:50 2000 From: jlecomte at ifrance.com (=?iso-8859-1?Q?J=E9r=F4me_Lecomte?=) Date: Wed, 19 Jul 2000 13:26:50 +0100 Subject: Python et Question sur Linux Message-ID: <8l43gh$j3u$1@broadway.news.is-europe.net> Salut, J'ai commenc? ? regarder Python. Ca a l'air vraiment bien (plus facile et plus clair que Perl et mieux int?gr? avec le reste du monde que tout ce que j'ai vu jusqu'a pr?sent). Tu connais ? Mon fr?re envisage d'installer Linux sur son PC (266Mhz) pour programmer. Il faut compter combien de DD pour ?tre confortable. 500Mo peut faire l'affaire, ou il faut 1Go min. J?r?me. From alwyns at prism.co.za Thu Jul 27 06:43:53 2000 From: alwyns at prism.co.za (Alwyn Schoeman) Date: Thu, 27 Jul 2000 12:43:53 +0200 Subject: C++ Extension problem Message-ID: <20000727104354.3359D1DC99@nevyn.prism.co.za> Hi there, I recently used SWIG to make a python extension of Linas's C++ library. The problem is that it would work on one linux box running say mandrake 7.0 and then not work on another running debian, etc. How can this be? termios should be the same across the board, etc? Thank you Alwyn Schoeman From nobody at nowhere.nohow Fri Jul 21 20:43:41 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 22 Jul 2000 00:43:41 GMT Subject: iterating over lines in a file References: <75F7304BB41CD411B06600A0C98414FCB36815@ORSMSX54> Message-ID: <176e5.1997$6E.436345@ptah.visi.com> On Fri, 21 Jul 2000 15:42:17 -0700, Daley, Mark W wrote: >Isn't the argument for readlines() a memory size, as in 512 bytes? If so, >it is possible to have 3509 lines that are <= 512 bytes. Last time I counted, a newline took up one byte in a file for Unix/MacOS and two bytes for MS-DOS/Windows. Therefore, the upper bound is 512 for number of lines in a 512 byte file. There may be some degenerate way to put more that 512 lines in a 512 byte file under one the eight gazillion file formats supported by VMS, but off the top of my head, I don't think so. NB: it looked like to me that the size in question was the sum of the lengths of all of the lines read, and not the number of lines read. -- Grant Edwards grante Yow! I'm sitting on my at SPEED QUEEN... To me, visi.com it's ENJOYABLE... I'm WARM... I'm VIBRATORY... From xiarcexml at yahoo.com Mon Jul 17 14:23:35 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Mon, 17 Jul 2000 11:23:35 -0700 (PDT) Subject: Does Python code >.require<< a run-time environment?? (New to Python) Message-ID: <20000717182335.20026.qmail@web5303.mail.yahoo.com> Thanks, George... that might answer my question... I don't need it even to be ONE file, only not-requiring someone to DL the VM to run it.. My users are not savvy with basic dos functions, let alone with virtual machines, programming languages, etc.. If they can be zipped, and then unzipped, and double-clicked... then perhaps python has answered my need. (Now only how to re-write my GUIs in Tkinter... ah well.. I can add a language a month to my repertoire) ~Dave Previous Conversation::::: Paul Prescod wrote: > Gordon McMillan wrote: > > > > ... > > > For Python, you want to look > > >at > > > > > >http://starship.python.net/crew/gmcm/distribute.html > > > > > >For Java, at "jexegen.exe". > > > > Sorry, Paul, the latter does not bundle in the interpreter. It > > just packages up byte code and uses a small exe to start your > > MS JVM. > > True, I forgot that because the MS JVM tends to be installed. I > think I may have exaggerated the features of the former too. Is > there any easy way to make a single executable for Python, the > standard library, required .pyd's and your code? My vague > impression is that you could if you had a compiler and the source > for your pyd's, or else you could fall back on an installer > (rather than a single big runnable app). ; ;It doesn't create a single statically linked exe. That's kind of ;hard without a compiler. It does track down all your ;dependencies (at least those not masked by import hooks) ;including (on Windows) dlls that your pyds might depend on. ;You end up with an exe and some pyds / dlls in one directory. ;You can then choose how to distribute. You can use a ;installer, (or WinZip), or let Installer create one for you, or even ;send out a one file exe that unzips itself each time it's run. ; ;The major point being that there's no requirement for Python ;on the user's machine, and there's no interference if they have ;a different version of Python installed. ; ;- Gordon __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From jhe at webde-ag.de Tue Jul 18 08:37:41 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Tue, 18 Jul 2000 14:37:41 +0200 Subject: hexidecimal output as default? References: <3bRZA7$j9m@openbazaar.net> Message-ID: <8l1ive$g0n$1@pollux.ip-plus.net> schrieb im Newsbeitrag news:3bRZA7$j9m at openbazaar.net... > what i really want is to get the following: > > >>> i = 0xa > >>> i > 0xa Then write a HexInt class that overloads __str__ and __repr__, and use i = HexInt(0xa). I see no other way. From laurent8 at sxb.bsf.alcatel.fr Wed Jul 12 02:58:23 2000 From: laurent8 at sxb.bsf.alcatel.fr (Frederic Laurent) Date: Wed, 12 Jul 2000 08:58:23 +0200 Subject: simple (?) re question References: <396B4DAE.3FEF0B0E@sxb.bsf.alcatel.fr> <3dr990zgxl.fsf@kronos.cnri.reston.va.us> Message-ID: <396C170F.AFEB1442@sxb.bsf.alcatel.fr> Andrew Kuchling wrote: > You're using the wrong tool; regexes are very clumsy for this sort of > thing. Try looking at your regex using Demo/tkinter/guido/redemo.py > to see how it matches; the first .* matches '/foo/bar/SCCS/s.file', > the ?! expression matches nothing, and the second .* matches nothing. ok I will see this sample, but I've got a problem with the init of the Tkinter ----------------- Python 1.5.2 (#2, Jun 22 2000, 10:49:11) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import _tkinter >>> import Tkinter >>> Tkinter._test() Traceback (innermost last): File "", line 1, in ? File "/users/public_w3p/share/python/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py", line 1947, in _test root = Tk() File "/users/public_w3p/share/python/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: This probably means that Tcl wasn't installed properly. ----------------- I don't know where the python interpreter try to find the init.tcl file, in which directories it searches. I've put this file in a directory included in the $PYTHONLIB, but it doesn't work as you can see, if you have an idea... > Similar problem; the regex engine finds an alternative match. Why not > just write: > > path, filename = os.path.split( filename ) > if 'SCCS' in string.split(path, os.pathsep): > # SCCS in path I have make a sample as simple as possible in order to points out the problem, and of course for a such simple thing I'd rather use the string module, but my real code is more complex and I can't specialize it like this. > for the second? Much clearer than a complicated regex which has to be > analyzed to be understood, and it makes it more apparent that you're > making a decision based on the path. I want to use to regex module because I want to match thing like : it begins with something "/foo" then there is something I don't care, then I can find something like "F.?[0-9][\w*][.]/" and then something I don't care and it will finish by a "java|py" string. Of course, this is an example ! thanks for your answer. -- Fr?d?ric LAURENT mailto:frederic.laurent at sxb.bsf.alcatel.fr T?l : (33) 03 88 55 70 00 poste 57228 From dberlin at redhat.com Thu Jul 27 10:01:25 2000 From: dberlin at redhat.com (Daniel Berlin) Date: 27 Jul 2000 10:01:25 -0400 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up In-Reply-To: "Mark Hammond"'s message of "Thu, 27 Jul 2000 00:24:51 GMT" References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <8ln84n$380$1@gaia.cdg.acriter.nl> Message-ID: "Mark Hammond" writes: > "Cees de Groot" wrote in message > news:8ln84n$380$1 at gaia.cdg.acriter.nl... > > > ...and is soooo innovative that it does exactly the same thing as Java > > and the JVM, only five years later and at the vaporware stage. > > vaporware == beta distributed to thousands of people? Since when? > Anyway... > > I think you should wait for the jury on this one. There are alot of > academics who have ported their languages to both the JVM and the .NET > runtime. I'm sure MS rewarded them, or their schools, handsomely. > > It is safe to say that no one I have met with experience in both these > technologies shares your opinion. > > People obviously _do_ share some general concerns about MS, but if you > limit yourself to a discussion on the technical merits of these > technologies, you wont find many people on your side of the debate. > > Watching the reactions of the dyed-in-the-wool-MS-hating-academics was > almost the most interesting part of this project. Suffice it to say they > started the project with their "Tux" t-shirts being worn proudly every > (single, smelly :-) day, but by the time the PDC came around they were > first in the queue for their .NET tshirts ;-) This is what MS is very good at. How do I know? I worked for 3 years as part of Microsoft Research, among other places, in the student consultant group. This was our job. Us being the students at the 50 most respected CS schools (It's now been expanded to be *much* larger). Promote MS within our respective schools through any means possible. This means MS would do everything, including giving multi-million dollar grants and computer labs to schools, to convince CS professors, and CS departments, to use MS software, in particular, the development tools. You name it, we did it, to convince people it was good, and to use it. We were, and from what I understand, they still are, very successful. However, working at MS gave me some perspective. There are certain things you have to understand. 1. MS never has, and never will, do anything for the customer. Regardless of what you think, the only reason they've ever done anything is for themselves. It's only later that it might turn out to be good for the customer. Witness Active Directory (really created because MS had too many computers and users, and thus ran into the limits of NT 4's model, and couldn't create new users and computer accounts in the MICROSOFT domain), among a billion other examples. If you think they did something for the customer, their was an alterior motive. Trust me. 2. The answer to the question "How do you expect to enter a marketplace, and become the leader, with a product half as good as what is already out there?" is "We're Microsoft" (I'm not kidding either, that was the answer I was given when I asked the question.) 3. MS has very smart people working for them, though not as many as they used to (quite a lot have left, and are still leaving). The cause of most of the above problems is that middle management at MS, like everywhere else, is idiotic. If the smart people still ran the company, and half of them weren't amazingly arrogant, MS might be a much nicer company. I used to be exactly like you are now. Defending MS, but not an MS lackey, trying to give them the benefit of the doubt. The more I worked there, and saw how things were, the less I could do this, until I just couldn't take the bullshit anymore and quit. > > > (http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html, support /that/ > many > > stuff on your little VM, M$). > > I am sure they will, and I am sure the majority of language implementors > will agree it is an improvement (again, if viewed purely from technical > grounds) > > > ... happily going back to Java, Python, SmallTalk, Scheme, XML and > whatnot > > Not sure what point you are trying to make here? These, plus others, are > also on .NET. You should have listed languages that people have heard of, > and are not announced for .NET. Maybe you had the "TRS-80 Model 1 BASIC > Interpreter" implementation in mind? > > Mark. > --Dan From boncelet at eecis.udel.edu.bbs Mon Jul 17 15:40:06 2000 From: boncelet at eecis.udel.edu.bbs (boncelet at eecis.udel.edu.bbs) Date: 17 Jul 2000 19:40:06 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRNBA$l4T@openbazaar.net> Bjorn Pettersen wrote: > > Perl, C++, Visual Basic, Java, and probably also Tcl are all more > popular than Python. Are you suggesting we should add their special > syntaxes/quirks just because a lot of people know them? Not at all. Python has a clean, simple syntax and I don't want to clutter it the way Perl, for one, has. However, the Python community should look at these other languages/domains and be willing to adopt the things they have done right! (The primary problem, as Huayiu keeps pointing out, is that linear algebra has two sets of operaters: those that work on elements and those that work on whole matrices/vectors. The main need is to distinguish these two for multiplication. If simple syntax for division--inversion--could be defined, all the better.) Why is it ordained that objects should have only two operations, "*" and "+", defined with simple operators? "+" on strings means something entirely different than "+" on numbers. Why not add an "@" operator? With some thought, I'd wager that we could define useful meanings for []@[], {}@{}, etc. And if not and the only problem domain that needs/wants a "@" operator is linear algebra, then just how much clutter are we talking about? Then make it available only when "import Numeric" is done. My argument is that linear algebra is a *big* problem domain. It should not be dismissed as "just another problem." Python could become the primary open source alternative to Matlab in time if a few changes were made: Incorporate numpy into the core distribution (or release a distribution with it already embedded), simplify the syntax for matrix operations, and improve the help facility at the interpreter. Matlab, of course, comes with numerous toolboxes that are unavailable in numpy. Early adoptors will have to write them--just as they do for Matlab! If you build it, they will come... Python, because of its clean syntax, numpy, and existing scientific/graphical tools is better positioned than Perl, TCL, etc, to grab the linear algebra users. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From falk.lehmann at gmx.net Thu Jul 13 14:07:48 2000 From: falk.lehmann at gmx.net (falk.lehmann at gmx.net) Date: Thu, 13 Jul 2000 18:07:48 GMT Subject: openssl 0.9.5a and python 1.6a2 Message-ID: <8kl0h4$pu6$1@nnrp1.deja.com> I build python 1.6a2 and included the SSL support. I am using the openssl library 0.9.5a on a NT box. I tried to establish a SSL connection via a proxy using the following lines of code: ============================================== import urllib f = urllib.urlopen('https://ecardfile.com/') print f.read() f.close() ============================================== But the proxy replies with an error message: ============================================== Error

Error


The requested item could not be loaded by the proxy.

The certificate issuer for this server is not recognized by Netscape. The security certificate may or may not be valid. Netscape refuses to connect to this server.


Proxy server at proxy on port 8080
=================================================== It seems that some certificate is missing. How do I make openssl aware of the certificates delivered with the distribution? Or is the error somewhere else? Any ideas? Falk Sent via Deja.com http://www.deja.com/ Before you buy. From jtschirr at engineering.uiowa.edu Tue Jul 11 16:19:00 2000 From: jtschirr at engineering.uiowa.edu (jtschirr at engineering.uiowa.edu) Date: Tue, 11 Jul 2000 15:19:00 -0500 Subject: Create wxBitmap from PIL Message-ID: <396B8134.8E5426B9@engineering.uiowa.edu> How can I create a wxBitmap image from a Python Imaging Library (PIL) image? Juerg From darrell at dorb.com Thu Jul 6 23:36:26 2000 From: darrell at dorb.com (Darrell Gallion) Date: Thu, 6 Jul 2000 20:36:26 -0700 Subject: splitting an avi image into a sequence of images with python? References: <87em567urz.fsf@lumen.med.iupui.edu> <045101bfe7bf$3d639750$6401a8c0@home> Message-ID: <047701bfe7c4$87d47fc0$6401a8c0@home> Oops. I didn't understand the requirements. So you wanted to decode the AVI into the individual images. No simple solution comes to mind. Sorry. --Darrell ----- Original Message ----- From: "Darrell Gallion" To: Cc: "python" Sent: Thursday, July 06, 2000 7:58 PM Subject: Re: splitting an avi image into a sequence of images with python? > Here's a quick solution, with only a little testing. > > --Darrell > > ----- Original Message ----- > From: "Michael A. Miller" > Newsgroups: comp.lang.python > To: > Sent: Thursday, July 06, 2000 3:34 PM > Subject: splitting an avi image into a sequence of images with python? > > > > I'd like to split some avi files into image sequences. Is there > > already a module out there that will help me do that? > > > > Mike > > > > -- > > Michael A. Miller mmiller3 at iupui.edu > > Krannert Institute of Cardiology, IU School of Medicine > > Indiana Center for Vascular Biology and Medicine > > -- > > http://www.python.org/mailman/listinfo/python-list > From robin at jessikat.fsnet.co.uk Tue Jul 18 20:00:14 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 19 Jul 2000 01:00:14 +0100 Subject: zip or marry etc In-Reply-To: <3974E341.58FC8939@roguewave.com> References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E341.58FC8939@roguewave.com> Message-ID: In message <3974E341.58FC8939 at roguewave.com>, Bjorn Pettersen writes >Robin Becker wrote: >> >> I suppose there must be something desperately wrong with using the >> __mul__ for sequences to indicate the set pairwise product. I would >> certainly be for >> >> x,y in A*B rather than x,y in zip(A,B) or marry(A,B), but since * is the >> obvious operator it must be that someone else has reserved it. > >if A is of a class defining __mul__ (or B is of a class defining >__rmul__) you'll have problems. > >How about A @ B... > >running-and-hiding'ly y'rs >-- bjorn > I thought maybe these were just lists or tuples sigh :( -- Robin Becker From Gareth.McCaughan at pobox.com Sat Jul 29 09:52:46 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sat, 29 Jul 2000 14:52:46 +0100 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> Message-ID: Steve Lamb wrote: >>> it is 1 and it can be all of those all on context. > >> In Python, and most programming languages that have some notion of type, >> it is an integer. If you wanted a string, then you'd have typed '1', or >> converted it to a string with `1` or repr(1) or str(1). > > Most, not all. Again, I ask, as a /human/. Not as a computer, > calculator, dog, fish, pet rock, face on mars, some gas creature in > delta-theta 3 (word up, gass monster) or almond, is 1 a character a string an > integer a floating point number or what? If you have problems ask about 2 > dozen people off the street what 1 is with that question and see how many > puzzled looks you get. If you ask them "Is 1 an integer or a string or a character or a sequence"? Yes, they'd give you strange looks. Mostly because they wouldn't know what you meant. If you went up to 24 people in the street in, say, London, and asked "Un loup, c'est plus comme un chien ou comme un chat?"[1] they'd mostly be baffled too, for the same reason: they wouldn't speak the language. Likewise if you asked them a technical question from some other discipline (sticking to ones that somewhat resemble the question you asked, consider "Is 1 an equivalence class under equipollence, or a von Neumann ordinal, or something else?", which would make excellent sense to a mathematical logician). Conclusion: Asking technical questions of random people on the street is a poor way to get useful answers. * Deciding what things mean according to context would be very cool if any computer could really do it the way people do. Unfortunately, they can't. The approximations they *can* manage are simple enough to mean that they break sometimes, and complicated enough to make it hard to be sure whether they're going to break. This is not, for me at least, a good combination. It's nice, sometimes, that Perl can use a "123" found in a string and use it as a number. But the downside of this kind of guesswork is that instead of having to remember to say "this is a number" when you get hold of it, you have to remember whether you're dealing with a number or a string when you do comparisons, and that sometimes (I've mercifully erased the details from my brain) you need to add 0 to an object just to make *sure* Perl treats it as a number, and so on and so on. This works OK for small programs, where most of the time it guesses right and when it doesn't there isn't too much code to dig through. It's much, much nastier when your programs grow beyond a few hundred lines. * [1] Pardon my dodgy French. Anyone whose French is even dodgier than mine may need to be told that it means "Is a wolf more like a dog or like a cat?". The fact that most people in London wouldn't understand the question doesn't mean that the distinction is meaningless to the average person. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From neilh at scintilla.org Mon Jul 10 07:02:33 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 10 Jul 2000 11:02:33 GMT Subject: Windows API References: <20000710070313.13010.qmail@web3406.mail.yahoo.com> Message-ID: > I am very new to Python and I am waiting for my first > book. I would like to ask you how to use Windows API > in Python?. With an example please. You should grab Mark Hammond's Win32 extensions from http://starship.python.net/crew/mhammond/ which includes the Pythonwin development environment. For an example, start Pythonwin, and you should an Interactive Window. Into that window type (just the bit after ">>>"): >>> import win32api this loads definitions of the core Windows API. Then call an API with >>> win32api.Beep(3000,300) As you press the "." a list of the available calls should appear. You can continue typing or select an item and press Tab to enter that item. Pressing enter after this typing will execute the code and produce a noise - hope you have a sound card. The online help lists all of the APIs wrapped by the Win32 extensions which includes a good proportion of the entire Win32 API. For complete descriptions of each API, you will want access to MSDN, either online at http://msdn.microsoft.com or by downloading the Platform SDK from the same site. There is a book by Mark and Andy called "Python Programming on Win32" which contains a lot of pages and a decent cover illustration. Neil From bjorn at roguewave.com Wed Jul 5 18:05:50 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 05 Jul 2000 16:05:50 -0600 Subject: cleanup order References: Message-ID: <3963B13E.8E77CC19@roguewave.com> Johannes Zellner wrote: > > Hi, > > suppose I've > > # fred provides `fun' > import fred > > class Lola: > def __init__(self, x): > self.x = x > def __del__(self): > fred.fun(self.x) > > x = Lola('hello') > # end of script > > this doesn't work, because fred is not present any more > when x is destroyed. I don't know anything about python's > internals, but I guess the dynamical loaded shared object's > function table is destroyed (somehow) before x is destroyed. > > Any comments ? (or even workarounds ?) This should work: ... def __del__(self, fun=fred.fun): fun(self.x) it's using a default argument to make sure the reference count to fred.fun doesn't reach zero until the Lola instance is deleted. -- bjorn From aaron.ginn at motorola.com Fri Jul 14 15:59:00 2000 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 14 Jul 2000 12:59:00 -0700 Subject: Importing modules... Message-ID: My apologies if this has been asked before. If so, please direct me to a FAQ. I checked Deja, but I couldn't find my answer very easily... How do I import a module that I have written? Say I have a class that I have created called Foo in a file stored at ~/bin/foo.py. What kind of command do I need to use to be able to import that class into a new file. I've tried the following: import '~/bin/foo.py' but this doesn't seem to be the way to do it. Do I need to set a path variable with ~/bin in it, and if so, how do I refer to the module? Is it the name of the file, i.e. foo? Or is it the name of the class, i.e. Foo? Do the class and the file need to have the same name? I don't really know how to accomplish this. Thanks, Aaron -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From jtoy at tcgfinancial.com Wed Jul 19 17:32:17 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Wed, 19 Jul 2000 17:32:17 -0400 Subject: newb question Message-ID: <39761E61.1E2191B4@tcgfinancial.com> Can you tell me how I can make a python program find the IP address of the local machine? If possible, I would like to make this not matter what OS its on( i want it to work on windows and Unix/Linux/BSD). Second, can you tell me how I could run this program as a dameon, again not OS dependent, because while I know you can put a Python script in cron, how can you do the same with windows? Third, how can I make Python recognize what OS its on, that wat if I can't do the above 2 questions withouot being OS dependent, then I will do somethin like: if OS == x then do else OS == z do Thanks for your time. From hat at se-46.wpa.wtb.tue.nl Fri Jul 14 09:55:46 2000 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 14 Jul 2000 13:55:46 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kmtab$4or$1@pollux.ip-plus.net> <396F131C.4AD83C8A@memo.volvo.se> Message-ID: On Fri, 14 Jul 2000 13:19:00 +0000, PM wrote: >I should like it to kick c#'s butt, perhaps People who fall for that trap don't deserve to be rescued. Albert --- Look ma, windows without Windows !! From grey at despair.rpglink.com Fri Jul 28 01:03:31 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 05:03:31 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280416.OAA31003@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 14:16:01 +1000, Richard Jones wrote: > Eh? You're comparing the assignment operation - the placing of a label on >an object - with the automagical creation of an object? How is: No, the statement was the automagical type changing of Perl. How is the casting of a variable's type based on context any different than (re)casting it based on context? Esp. when Python does do some recasting as needed for certain operations. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From bjorn at roguewave.com Fri Jul 14 19:23:29 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 17:23:29 -0600 Subject: Importing modules... References: Message-ID: <396FA0F1.A8B0CD86@roguewave.com> Aaron Ginn wrote: > > My apologies if this has been asked before. If so, please direct me to > a FAQ. I checked Deja, but I couldn't find my answer very easily... > > How do I import a module that I have written? Say I have a class that > I have created called Foo in a file stored at ~/bin/foo.py. What kind > of command do I need to use to be able to import that class into a new > file. I've tried the following: > > import '~/bin/foo.py' > > but this doesn't seem to be the way to do it. Do I need to set a path > variable with ~/bin in it, and if so, how do I refer to the module? > Is it the name of the file, i.e. foo? Or is it the name of the class, > i.e. Foo? Do the class and the file need to have the same name? I > don't really know how to accomplish this. _Please_ go "read the fine manual"! -- bjorn ps: Python searches a list of directories in sys.path originally initialized from the PYTHONPATH environment variable. The import statement only mentions the name of the module, without quotes or extensions; that way the import framework has a chance to do interesting/important stuff before your module is loaded. From Pahud.bbs at openbazaar.net Wed Jul 19 01:24:36 2000 From: Pahud.bbs at openbazaar.net (©¬­J¼w) Date: 19 Jul 2000 05:24:36 GMT Subject: [Apology] Duplicate posts from OpenBazaar Message-ID: <3bSRk9$lPa@openbazaar.net> Greetings, I am the administrator of openbazaar.net. Due to the faulty setting of our news server, a huge amount of articles were fed back to the usenet yesterday. We hereby sincerely apologize for our serious mistake. And we will try everything out not let this kind of disaster happen again. -- Patrick Hsieh <pahud at python.nu> OpenBazaar BBS <openbazaar.net> TEL 0933201800 -- ?? Origin: ???????u   ?? From: 211.72.165.181 From tim_one at email.msn.com Fri Jul 28 20:02:39 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 28 Jul 2000 20:02:39 -0400 Subject: Content of the Perl6 talk In-Reply-To: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> Message-ID: [posted & mailed] [Cameron Laird] > is the most pro- > vocative summary I've yet seen of Larry Wall's talk at the O'Reilly > Open Source Convention. ... > I applaud Conrad Schneiker for his care in preparing this. Actually, the content of Conrad's referenced post (excepting the Ruby advocacy) appears to be taken verbatim from Adam Turoff's excellent p5p mtg notes, at: http://www.perl.org/perl6/pr/initial_meeting.html No knock at Conrad, but it could have been attributed better. I certainly wish them well! In my experience, projects that aim to expand functionality while reducing size and increasing speed are doomed to succeed . maybe-we'll-rename-python2-to-perl6-ly y'rs - tim From peter at schneider-kamp.de Tue Jul 18 20:16:02 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 00:16:02 +0000 Subject: merging numpy's array into python2 References: <8l27h4$7vq$1@la-mail4.digilink.net> Message-ID: <3974F342.1283FD9F@schneider-kamp.de> Pete Shinners wrote: > > i find using the numerical array stuff to be so useful i was > wondering if there are ever plans to implement some of the > package into the standard python release? > > specifically, the array object and it's helpful ufuncs would > be great addition to the standard release (imho) That's my opinion, too. I just started a discussion on python-dev, so have some patience while they are taking me apart ;-) Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From see at my.signature Wed Jul 12 20:17:23 2000 From: see at my.signature (Greg Ewing) Date: Thu, 13 Jul 2000 12:17:23 +1200 Subject: File IO with select? References: <396BBCE9.2C114ED3@tgflinux.com> Message-ID: <396D0A93.53366320@my.signature> Jared Lee Peterson wrote: > > I am trying to syncronize two clients that are accessing the same file. > I am trying to use > select() for this but I am not having much luck. select() is useless for that, because reading from an ordinary file never blocks, so select() will always return immediately. On unix, the only portable way is to periodically poll the file to see if it has grown. I gather that there is another way on Windows, but I don't know any details. -- 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 max at alcyone.com Tue Jul 11 01:26:32 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 10 Jul 2000 22:26:32 -0700 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: <396AB008.FAA67DD9@alcyone.com> David Goodger wrote: > But seriously (my comments above were in good fun, I assure you, no > harm > intended), I read this newsgroup regularly and I never saw mention of > the > Language Challenge 2000. Did I miss it? Perhaps the audience > determined the > outcome? I saw the announcement in another newsgroup (just started reading comp.lang.python); it was either in a C or C++ newsgroup, or a Linux or UNIX newsgroup. I had a similar reaction to you upon reading about it. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ You must surely know / If man made Heaven, then man made Hell \__/ Level 42 Maths reference / http://www.alcyone.com/max/reference/maths/ A mathematics reference. From ruud.cox at philips.com.bbs Mon Jul 17 04:00:04 2000 From: ruud.cox at philips.com.bbs (ruud.cox at philips.com.bbs) Date: 17 Jul 2000 08:00:04 GMT Subject: Tkinter and absolute positioning Message-ID: <3bR504$ifo@openbazaar.net> Is there a way to position child widgets on a TopLevel widget using absolute coordinates instead of using pack, place or grid? Ruud Cox Sent via Deja.com http://www.deja.com/ Before you buy. From bos at hack.org Mon Jul 31 17:55:41 2000 From: bos at hack.org (Rikard Bosnjakovic) Date: Mon, 31 Jul 2000 23:55:41 +0200 Subject: removing characters from a string? References: <8m4rqn+jpg0@eGroups.com> Message-ID: <3985F5DD.CB1BB073@hack.org> jesse at multimediacollective.com wrote: > this_string = "jesse at multimediacollective.com" > """and I wanted to get rid of the @, how would I do that? This string.join(string.split(this_string, "@"), "") -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se Anyone sending unwanted advertising e-mail to my address will be charged $25 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From lull at acm.org Fri Jul 21 09:00:38 2000 From: lull at acm.org (John Lull) Date: 21 Jul 2000 08:00:38 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> Message-ID: <2phgnsggotp06hqupksikf6shfchnsnke9@4ax.com> "Rainer Deyke" wrote (with possible deletions): > This would allow constructs such as: > > A(.init)B Is this really a problem? If someone rally *wants* to write obscure or unreadable code, there's little we can do to stop them. Regards, John From bill at dehora.fsnet.co.uk Wed Jul 19 17:09:31 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Wed, 19 Jul 2000 22:09:31 +0100 Subject: agents Message-ID: <8l55hg$6ia$1@newsg1.svr.pol.co.uk> Before I go off and start these myself, is anyone working on Agent frameworks and or tuple spaces (Linda-alikes) in Python? -Bill de h?ra From johngrayson at home.com Mon Jul 10 14:24:58 2000 From: johngrayson at home.com (John Grayson) Date: Mon, 10 Jul 2000 18:24:58 GMT Subject: Tkinter: buttons are dead of tkFileDialog.askopenfilename References: <3969F138.4EFE768E@acm.org> Message-ID: <8kd4d5$1d4$1@nnrp1.deja.com> In article <3969F138.4EFE768E at acm.org>, John Powers wrote: > > --------------0EF7BCC78CC8B59055EF54F1 > Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 7bit > > I have a simple Python script to illustrate a problem I'm having with > askopenfilename. The following program displays a window with a "Quit" > button. The "Quit" button works until you uncomment the statement which > calls askopenfilename. After selecting a file from the Open Dialog box, > the button window appears but the "Quit" button is dead -- absolutely no > response to pressing it. What's up? Maybe I shouldn't be calling > askopenfilename while initializing App? Fairly simple problem... You need to ensure that the mainloop is spinning before you show the dialog. One way to do this is to delay the dialog for a few milliseconds... > from Tkinter import * import tkFileDialog class App(Tk): def __init__(self): Tk.__init__(self) filename = "filename" Label(self, text=filename).pack() Button(self, text="Quit", command=self.quit).pack() self.after(5, lambda s=self, f=filename: s.ask(f)) def ask(self, filename): tkFileDialog.askopenfilename(initialfile=filename) App().mainloop() John Sent via Deja.com http://www.deja.com/ Before you buy. From hsl at tcp.co.uk Mon Jul 10 09:19:07 2000 From: hsl at tcp.co.uk (Martin Rand) Date: Mon, 10 Jul 2000 14:19:07 +0100 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: On Mon, 10 Jul 2000 02:06:38 -0700, "Fanny Yeung" wrote: >Hi everybody, > >I am reading "Python and Tkinter Programming" and I am thinking of writing a >simple database application that need to show table of data ( something >similar to grid control in VB or Jtable in Swing). I guess I can use Canvas >to implement that but I wonder anyone have implement this already ? If yes, >can I use it ? Or is there by any chance provided by Tkinter directly or >indirectly ? > Doug Hellmann's contributed extras to Pmw include a simple grid widget for displaying a sequence collection. It probably won't do all you want, but is a starting point for deriving your own. -- Martin Rand Highfield Software Ltd mwr at highfield-software.co.uk Phone: +44 (0)23 8025 2445 Fax: +44 (0)23 8025 2445 From thiele at muc.das-werk.de Tue Jul 18 12:21:36 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 18 Jul 2000 18:21:36 +0200 Subject: interned names: memory leak Message-ID: <39748410.D0EEFFEA@muc.das-werk.de> Normally, the names used in Python programs are automatically interned, and the dictionaries used to hold module, class or instance attributes have interned keys. Interned strings are immortal (i.e. never get garbage collected). So far, so godawful. Really! (I couldn't fix my memory leak yet, althought I wrote my own pickle.:-( ) But how can I get the whole interned name? And when a string becomes a name? From claird at starbase.neosoft.com Sat Jul 22 09:48:13 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 22 Jul 2000 08:48:13 -0500 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> Message-ID: <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> In article , Michael Hudson wrote: >milenko at moonshine.co.uk (Jack) writes: > >> Hey there, >> >> im pretty new to using python, and im just experimenting with file access, >> a wrote a script that works fine, and then all of a sudden it started >> throwing up this error: >> >> inp = open("c:/autoexec.bat",'r') >> TypeError: illegal argument type for built-in operation >> >> it was working fine before, and i dont see anything unusual in the syntax. >> >> Any help would be appreciated, > >5 gets you 7 that you have added a > >from os import * > >to your script. > >Don't do that. . . . I'd be willing to raise the odds on that bet. You're also right that from os import * is, of course, universally deprecated. What surprises me, though, is that no one ever mentions the possibility of writing inp = __builtin__.open("c:/autoexec.bat",'r') -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From mark.w.daley at intel.com Mon Jul 31 18:30:38 2000 From: mark.w.daley at intel.com (Daley, Mark W) Date: Mon, 31 Jul 2000 15:30:38 -0700 Subject: Convoluted question Message-ID: <75F7304BB41CD411B06600A0C98414FCB3682D@ORSMSX54> I am a little frustrated by this situation. I have written some code to take an indeterminate number of server names to create a column of check buttons: from Tkinter import * import dbi, odbc, time, os, sys, Pmw servername = ['Server1', 'Server2', 'Server3', ..., 'Servern'] for item in range(len(servername)): b1 = Checkbutton(root, text = servername[item], variable = var) b1.grid(row = item, column = 0, sticky = W) I am at a loss for how to differentiate the variable names in the loop. One suggestion was to use a dictionary, although there were no details involved in that suggestion. Another was to do something like this (pseudocode, thank you, Michal): btnLst = [] for x in range(whatever): newBtn = SomeButton() # just create the widget btnValue = SomeValue() # read from a list, maybe? newBtn.pack() # or whatever to get it on the screen list.append((newBtn,btnValue) and later on: for button in btnLst: if button.isChecked: DoWhatever() I attempted to use a list of variable names to be assigned as needed when creating the checkbuttons, but I keep getting NameErrors when I go to print the values: servername = ['Server1', 'Server2', 'Server3', ..., 'Servern'] varlist = ['var0', 'var1', 'var2', ..., 'varn'] for item in range(len(servername)): b1 = Checkbutton(root, text = servername[item], variable = varlist[item]) b1.grid(row = item, column = 0, sticky = W) Exception in Tkinter callback Traceback (innermost last): File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 764, in __call__ return apply(self.func, args) File "C:\PYTHON\gui.py", line 14, in showvalues print var0 NameError: var0 I think this comes from the fact that I didn't define the names in varlist as variables. It seems to me that there should be an easy way to assign variable names for each check button in an automated way, and an easy way to return the status of a check button. I haven't found either after almost a full day of coding and poring over different texts, such as 'Python Essential Reference' and 'Python and Tkinter Programming'. Is what I want possible, or do I have to use what seems to me to be a more 'brute force' method? TIA - Mark ---------------------------------------------- The opinions expressed are mine, and are not necessarily those of my employer. From hzhu at localhost.localdomain Tue Jul 18 18:44:25 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 22:44:25 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f References: <3bRZA8$jD_@openbazaar.net> Message-ID: On Tue, 18 Jul 2000 11:08:57 -0500, Travis Oliphant wrote: > >I think I'll chime in here. I have been greatly enjoying this discussion. >I have been an active participant in Numerical Python development and have >been advocating it's use over Matlab to anyone who will listen for over a >year. This recent excitement is encouraging as I've seen the potential >for Python to replace Matlab for some time. Before, my thesis writing >picked up I spent quite a bit of time working on improving the number of >"toolboxes" available for Python --- a project I intend to continue as >soon as my dissertation gets written since I plan on using Python in the >electrical engineering classes I teach at University this winter. Hi, Travis, First let me say I admire your work greatly. You and all the NumPy developers have done tramendously wonderful work. (And I stole a little glory with a wrapper package MatPy.) The reason I started the MatPy project was simply that to me a simple linear algebra interface is more convenient than a multiarray interface. There are surely people whose work lead to the opposite preference. In fact, as everyone finds out sooner or later, both notations are equally important. I think that is the reason why there is a Matrix class in NumPy and there are elementwise operations in MatPy. (And partly why we are having this discussion). MatPy is not concentrated to 2d matrix only, as there is also a rudimentary tensor class. The main thing is that the standard operators stand for (multi-)linear algebra instead elementwise operations. I agree there need to be better coordination between the two projects. At the moment MatPy is still in its initial growth period. I do see the merit of either letting the standard operators take matrix or elementwise flavor. Had python provided a larger supply of operators there may not need to be two packages, because choosing * or @* as primary is not a big deal. Now we are forced to choose between either a*b.__dotmul__(c) or matrixmultipy(a,b)*c and it makes sense to different people to use either package as primary tools. Because of the conciseness of linear algebra it is very difficult to switch operators in working code. So I foresee both packages to coexist for a long time. One way to enhance the coordination might be to first standardize the method definitions as .mmul .emul which are then hooked to either .__mul__ .__dotmul__ .__atmul__ If NumP adds @ operators for matrix and MatPy adds the . operator for elementwise, non of the existing code would break. That is element matrix NumPy * @* MatPy .* * We can also start adopting common names for various functions whenever possible. When everyone's code standardizes on these notations, it would be much easier to switch to one standard notation if it is so desired. I for one would really like to see NumPy getting into the core. It will remove a big barrier for a lot of people who would have otherwise used it but for the (perceived) difficulty of installing an additional package. Of course it will also remove a barrier for people installing MatPy. :-) I understand your concern that adding additional operators might hinder the acceptance by core developers. I am encouraged by the recent discussion of the idea that it might be possible for a module to define its own operators. Before that happens, one can always write code in the more verbose notation so that it is guaranteed to work with standard python. The magic methods could be defined so that those who can patch the source code could use the new symbols. I have not yet taken a look at numpy2, but from you description it sounds numpy2 would bring us more to the table. I encourage everyone who care and who can to give it a look and hopefully join the development. For a foreseeable future matpy will be a wrapper around numpy. Gregory had expressed the idea that both numpy and matpy use the same set of symbols when his patch is released. I'm not against this idea but I don't see any feasible way to deal with existing code except via above route. Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From sabren at manifestation.com Mon Jul 31 16:03:38 2000 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 31 Jul 2000 16:03:38 -0400 (EDT) Subject: Dynamic variables In-Reply-To: <75F7304BB41CD411B06600A0C98414FCB3682C@ORSMSX54> Message-ID: On Mon, 31 Jul 2000, Daley, Mark W wrote: > Does anyone know of a way to create variables on the fly, like in a > loop? I want to be able to build a set of check buttons in a GUI > I'm writing, and each check button needs a different variable, I > think, to determine which ones are checked. I want to use a for > loop to iterate over a list to build the check buttons, but I don't > know the contents or length of the list. Any ideas? The concept is called anonymous objects. In python, objects can have more than one reference pointing to them. Some of those references have names, or labels that you can see in the code. eg: >>> x = SomeClass() .. That creates a SomeClass instance and calls it "x". But you can then say: >>> y = [x] .. And now y[0] references the same SomeClass instance. if you then say: >>> x = None .. y[0] is STILL REFERENCING the original SomeClass instance. It's just "anonymous" now because it doesn't have a specific name. You could just as easily have said: >>> y = [SomeClass()] and if you want more than one: >>> y = [] >>> for x in range(10): ... y.append[SomeClass()] Here's some psuedocode that might get you thinking: >>> btnLst = [] >>> for x in range(whatever): ... newBtn = SomeButton() # just create the widget ... btnValue = SomeValue() # read from a list, maybe? ... newBtn.pack() # or whatever to get it on the screen ... list.append((newBtn,btnValue) and later on: >>> for button in btnLst: ... if button.isChecked: ... DoWhatever() Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From olivierS.dagenaisP at canadaA.comM Sun Jul 23 22:05:17 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 24 Jul 2000 02:05:17 GMT Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> <8lfq6o$g07$1@nnrp1.deja.com> <397B96EE.9C62A45F@helicon.net> Message-ID: In order to avoid having a window flash like that, you will have to use a DOS prompt and invoke your scripts from the command line like so: C:\Your\Dir\Here>python hello.py ...then, if there is something totally wrong that prevents programs from running, you'll know about it. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Rodney Loisel" wrote in message news:397B96EE.9C62A45F at helicon.net... > There is a _tkinter.pyd in the Python\dll\ but there is no Tk directory. Why > > would there be no Tk directory if Python seems to depend on it so much? > All I can do with this program is 'run Python' or select it from the start > menu > and I get a generic dos shell with a >>> prompt an no shell features. > Clicking > on any *.py icon just opens and quickly closes a window before I can read > what's in it. I downloaded the program thru the Python web site and > installed > it by their instructions. Looks like I've wasted 25.00 on my new "Teach > yourself Python" book... > rloisel > > Sam Schulenburg wrote: > > > Usually the problem is IDLE can not find the Tk dll's. My solution has > > been to copy the Dll's from the Tk\bin directory to the Python\DLL > > directory. > > > > Sam Schulenburg > > > > In article , > > "Olivier Dagenais" wrote: > > > The Python binary might be in your path, but maybe the libraries > > aren't? > > > > > > -- > > > ---------------------------------------------------------------------- > > > Olivier A. Dagenais - Carleton University - Computer Science III > > > > > > "Rodney Loisel" wrote in message > > > news:397B0D93.6A5EE7CB at helicon.net... > > > > Changed the DOS properties not to close on exit > > > > the following is the result of > > > > import Tkinter > > > > several levels of error > > > > last: > > > > DLL load failed: one of the library files > > > > needed to run this application cannot be > > > > found. > > > > rloisel > > > > > > > > > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > From michael at stroeder.com Fri Jul 28 12:46:25 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 28 Jul 2000 18:46:25 +0200 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> <39808d84.23819726@news-server.austin.rr.com> Message-ID: <3981B8E1.6F55A6FC@stroeder.com> jay graves wrote: > > Q: How do you keep a lawyer from drowning? > > A: Take your foot off his neck. Q: What are 1000 lawyers at the bottom of the ocean? A: A good start. (A lawyer told me this joke.) Ciao, Michael. From hzhu at knowledgetrack.com Fri Jul 21 19:44:07 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Fri, 21 Jul 2000 23:44:07 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39771CA8.A1BF8D6E@fft.be> Message-ID: On Thu, 20 Jul 2000 19:32:15 +0100, Robin Becker wrote: >In article , Huaiyu Zhu > writes >> >>In matlab/octave, this is called kron(A,B). I don't think it deserves an >>infix operators, because it is just a special case of matrix multiplication. >>You can define a sparse matrix Kron(A) so that >> >>kron(A,B) == Kron(A)*B > >I'd be interested in how you define either Kron and * to achieve the >result you claim without modifying the p x r matrix B; after all it >cannot involve sums of elements of B so * isn't the matrix multiply. I >could use an element wise multiply, but only if I use the end desired >shape as the second element. Oops. You are right. B has to change as well. It is kron(A,B) == kron(A,I1) * kron(I2,B) where I1, I2 are identity matrices which, in fact, depend on the dimensions of the other. In matlab notation I1=eye(size(B,1)), I2=eye(size(A,2)). So it involes expanding the dimension of both operator according to the dimension of the other operator and then compose them. Huaiyu From guido at beopen.com Mon Jul 31 11:39:00 2000 From: guido at beopen.com (Guido van Rossum) Date: Mon, 31 Jul 2000 15:39:00 GMT Subject: The State of Python References: <398546C5.E9E59957@hursley.ibm.com> Message-ID: Paul Duffin writes: > That sounds absolutely horrendous. Tcl is also going through some major > changes in its development process to make it more Open Source but it is > nowhere near as painful as what seems to be happening to Python. I hope > that you get it resolved as quickly as possible. Actually, Tcl is struggling with the development process. Python's development process is already where Tcl wants to go, and that's not in danger. > Who will hold the license on Python 2.0 ? > > Is it going to be BeOpen ? > > Could the license be held by the community in some way to prevent this > sort of legal wrangling in future ? > > How about having a concept of stewardship, i.e. BeOpen is the current > steward of Python on behalf of the community. > > By Python I mean all Python related resources that BeOpen manage, so > this would include all information on the web site, the domain name, etc. > > If BeOpen could no longer support Python for whatever reason then those > resources would be turned over to the community and they could then look > for a new steward for Python. > > The community would also have the option to choose a new steward for > Python if they felt that BeOpen was not supporting Python properly or > someone else could support it better. > > This would have to be a legal contract so for instance if BeOpen was > taken over, or went bankrupt Python could not be sold off to the highest > bidder. > > The biggest problem with this is determining what the will of the > community is. I an committed to represent the community in these matters to BeOpen. I hope that you continue to trust me to represent the community in these matters! I am (with Tim Peters's much appreciated help, actually!) working on the creation of a legally binding agreement with BeOpen that ensures Python's status as Open Source software. We've already hired an open-source-friendly law firm to help us with this. An important part of this agreement will be to ensure that the right thing happens upon takeover, bankruptcy or any other Big Event in the life of a corporation, and also to ensure that I and my colleagues at PythonLabs will be able to continue to work on Python even if we quit or lose our BeOpen jobs. Let me know if you have specific concerns! --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From hzhu at localhost.localdomain Thu Jul 13 17:46:56 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 13 Jul 2000 21:46:56 GMT Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: On 13 Jul 2000 07:38:21 +0100, Michael Hudson wrote: > >> 2. It is difficult to add .* and ./ as . is already a valid token. > >Irrespective of the rest of this post, this is not true. "**" is a >valid token depsite "*" being one, etc. > Oh, this is good news. I did not quite believe that either, but after being told of this several times ... Any way, if the dot can be used then we definitely would use it, which sort of determines the choice to be matlab compatibility. The only ambiguity would be expressions like 3./a, which should be 3. / a, as long as we let the parser bind dot closer to the left whenever possible. Existing code will not break since the new operator exists entirely within the area of current "invalid syntax". What is still left out is a\b, though. Huaiyu From db3l at fitlinxx.com Fri Jul 28 20:49:20 2000 From: db3l at fitlinxx.com (David Bolen) Date: 28 Jul 2000 20:49:20 -0400 Subject: Perl is worse! References: <8lsdir$aja$1@plutonium.compulink.co.uk> Message-ID: grey at despair.rpglink.com (Steve Lamb) writes: > On 28 Jul 2000 15:37:05 -0400, David Bolen wrote: > >In the case here it seems as if you don't really want to define the > >name and associate it with nothing, you want to define the name and > >associate it with an object that will support being appended to. In > > Will this work if the decision is to make it a string, not a list? If your requirement is to have your label reference an object that supports an ".append" (in-place appending) method then no, as Python strings do not support that method (strings are immutable, although a new string may be formed by concatenating two strings). But that's actually quite consistent in terms of design, because the root question still remains identifying the appropriate objects to be working with. In effect, a Python "string" object does not fit your "interface" requirements. In this case your interface requirements appear to be sequence based, since you want a mutable sequence that you can append to (in Python, a "list"). Note of course, that you could certainly use strings in this sequence, and at any point produce a single string representing all of the entries from the list. I think in this respect you'll find Python much more object oriented than Perl, at sort of a basic level. I think this also ties into the other discussion in this thread of Perl having operators that control the type interpretation, whereas Python strongly types the objects themselves. In the example in this mini-thread, I think a perspective shift between a Perl approach and a Python approach is indicated in how you tried to form the example. You first considered obtaining some storage and then manipulating/converting that storage into what you wanted via operations. But in Python, it's the type of object that you use that controls what you can do with it (its interface) and not the other way around, so development becomes more focused (and more clean, IMO) on building an object model of what you are doing. There are, of course, ways to create a new object out of data from another object (e.g., produce a list representing the individual sequence of characters in a string), but that yields a new object with a new interface and doesn't actually do any "conversion" on the old object. I realize it was probably just to highlight a specific issue, but even choosing such an example is interesting, since arbitrary object conversions (e.g., something to a list) don't tend to happen with high frequency in Python programs, since it was the object model and data types that were most likely involved in the design. It's really easy to gloss over this with the basic object types since in many respects they behave much as other languages in common sorts of operations, but it can lead to confusion when the simpler view starts to break down. I don't know that this explains all that much discussed in this thread, but there have been various points where I think it's just an issue of the Perl and Python approaches being quite different under the covers even though they may appear very close superficially. Getting past that mental hurdle (as far as understanding, not putting any good/bad slant on it) might significantly shrink your current store of Python behaviors you consider "quirks". > >(Oh, and as an aside - this is an impressive thread - even with the > >few warts, I think there's useful information going on) > > Agreed. I know I'm prolly coming off as a newbie troll but I am learning > things and I really do mean it when I say I don't want to see the language > changed, just expressing an opinion. Well, besides being impressed that you're keeping it up this long, and without trying to sound condescending, I'm enjoying seeing how your examples are exposing what learned traits/visualizations from using Perl so much. I hope that you still give Python some time and experimentation, as you may find yourself forming new opinions :-) -- -- 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 kelley at bioreason.com Mon Jul 24 05:18:37 2000 From: kelley at bioreason.com (Brian Kelley) Date: Mon, 24 Jul 2000 10:18:37 +0100 Subject: Graphs - I need more graphs ( Simulation development ) References: <397a5658.88821067@news.online.no> <397AC68B.A07CAB3@ibm.net> Message-ID: <397C09ED.74CD0166@bioreason.com> You might also want to look at kjGraph in the kjbuckets package. There is one (slightly slow) version of the shortest path algorithm and I have found the data structures to be quite useful. Search the Vaults of Parnassus http://www.vex.net/parnassus/ -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From mwh21 at cam.ac.uk Wed Jul 19 18:54:52 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Jul 2000 23:54:52 +0100 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: <39751596.45921F07@prescod.net> Message-ID: dipping in and out of this thread... Paul Prescod writes: > Parsers just do not work that way. Most parsers cannot be extended at > runtime. The language is defined at compile time by the grammar. The > only way to do it without rewriting Python's parser from scratch would > be to pre-declare every possible operator anyone might ever want in the > grammar. What Haskell does is to declare that any sequence of characters from the set [!+-*/$=%] (I think) to be an operator, much the same way as any sequance of characters from [a-zA-Z_0-9] (ish) is a token in Python today. Still don't think runtime syntax extension is a good idea, but unfortunately we can't claim that it's impossible. Cheers, M. (who's just given half a second's thought to how much effort it would be to get Python's current lexer/parser to work in the above model and now has to sleep it off) -- I have gathered a posie of other men's flowers, and nothing but the thread that binds them is my own. -- Montaigne From neilh at scintilla.org Thu Jul 20 02:55:30 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 20 Jul 2000 06:55:30 GMT Subject: emacs keybindings in pythonwin References: <8l4jv0$t61$1@news.kth.se> Message-ID: > PythonWin allows you to customize keyboard bindings. > The example file show how to set > Ctrl+Q to AppExit > and some other things. > > But what if I wanted to set it to Ctrl-x Ctrl-c AFAIK (Mark and possibly Tim are better authorities for this) PythonWin has no way of binding multiple keystroke sequences to commands. There is the built-in-to-Windows Alt sequences to access menus but you won't be able to use Ctrl-x to start that off. Neil From aek at aek.dk Fri Jul 14 21:33:55 2000 From: aek at aek.dk (Anders Eggers-Krag) Date: Sat, 15 Jul 2000 03:33:55 +0200 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: I would say that it improves syntax consequense, leading to more readable code for others, you are never in doubt about what to look for when looking for a keyword, in VB you might look for IF, If or if, and they look very different, and it becomes a lot harder to read somebody elses code. the case insensitivity is nice when I am the only one to read my code as I could then choose my own obscure notation such as mYmetOd() and keep it consequent writing dEf, claSs, If eTc. wheras case sensitivity makes it more natural to keep a more sensitive manner such as myMethod() MyMethod() or my_method() throughout that everyone can agree on, I believe that case sensitivity leads to more uniform code, that again makes it easier to read your collegues code. And i think it should seem natural to everyone, after all books are written in case sensitive... you can't write: "i Am the wisEst One of aLl." and be taken seriously But it depends on which kind of access is needed to the system ie it would be dreadfull if DNS or SMTP servers were case sensitive and user enters MicroSoft.com and gets nowhere because he should have written microsoft.com. -- Anders Eggers - Krag "Peter Timaratz" wrote in message news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > I can't think of any advantages to a case sensitive language. Python is a > very well-designed language though, so I imagine there is a good reason that > it is case sensitive. So what are the advantages of a case sensitive > language? > > From alex at magenta.com Wed Jul 26 08:46:01 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 26 Jul 2000 14:46:01 +0200 Subject: reading stdout from child References: <397ECD5D.409A6819@muc.das-werk.de> Message-ID: <8lmmom02r7l@news1.newsguy.com> "Thomas Thiele" wrote in message news:397ECD5D.409A6819 at muc.das-werk.de... [snip] You may be running into *buffering* problems. Python, like most languages, will, by default, *buffer* its output when it is directed to a file (or pipe); i.e., each 'written' datum is actually only added to a memory 'buffer', and the whole buffer gets _really_ written out, in one go, when it's filling up, or when the file is closed, or when the program is terminating. This is really crucial to enhance program performance, but it does sometimes interfere with programs that want to read each other's output. Fortunately, Python gives you the easiest way to defeat output buffering, of any language I know of: just use the -u switch (option) on the command line. I.e., instead of python something.py run python -u something.py and all output will become unbuffered. See if it works this way: it's a very cheap and easy experiment! If it does work, then this confirms it's a buffering problem. You can then, if you wish, attack it more directly (without having to completely disable the buffering functionality) by explicitly *flushing* the output-streams at strategical points in your program -- this "flushing" will cause the memory-buffer to be truly "written out" as and when you request that. Alex From grey at despair.rpglink.com Fri Jul 28 19:02:52 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 23:02:52 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 23:09:56 +0200, Alex Martelli wrote: >I hope you remember that in Python there's no need for the joining >and later re-splitting: just putting the pair (tuple) in there is >so much easier and more natural. No. I am learning that. A plesant side effect of this excellent discussion. >Among other things, it makes it easy to save/load/change a format-string; Nono, you misunderstand me. I prefer the Pascal notion of variables in place in the string with formatting attached to it instead of placeholder formatting strings with the variables hanging off the end of the string. Pseudo code from no language, bear with me. "Here is a string with ",$a:d:0:0," variable in it." "Here is a string with %d:0:0 variable in it.",$a In the former I read and I see, "Oh, $a goes here with this formatting" whereas in the latter it is "Oh, here is the formatting for... uhm.. $a." Again, simplistic and not in any language, but taken to the extreme you can see the problem. "%d:0:0 %c:U %s %s %s %s %d %s %s %s \ %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k What variable goes with what again? >You just don't have to put strings together, to split them up again later, as >much as is usual in Perl (it was _mandatory_ in Perl 4, which had no rich >data structures; it's still _popular_ in Perl 5, for various reasons). Simplicity. >Why else would I have been so happy, so utterly happy, to leave 8 years of >Perl experience behind and start over from scratch with Python? Masochism? :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From Vladimir.Marangozov at inrialpes.fr Wed Jul 12 20:24:35 2000 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Thu, 13 Jul 2000 02:24:35 +0200 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> Message-ID: <396D0C43.6438C43F@inrialpes.fr> Richard Tobin wrote: > > Is it legal (it seems to work) to change the class of an object by > assigning to its __class__ attribute? In particular for the case where > the new class is a subclass of the old. > > I'm not looking for an argument (not even the five minute one) about > whether it's a good idea, just whether it's legal. Yes, it's perfectly legal. However, as the other replies are trying to warn you, it is assumed that you know perfectly what this means. Whenever an instance changes its __class__ from A to B, the instance may change almost all of its properties, except its id and local instance variables. IOW, it may change completely its behavior, for instance when A and B have nothing in common. It's like moving from UK to Japan by keeping your pounds in your pocket. which-is-perfectly-legal-too'ly y'rs -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From rgparker at west.net.bbs Mon Jul 17 21:10:01 2000 From: rgparker at west.net.bbs (rgparker at west.net.bbs) Date: 18 Jul 2000 01:10:01 GMT Subject: Could someone clone MS's IL for another OS? Message-ID: <3bRVdP$jyB@openbazaar.net> Could someone write a clone of MS's new intermediate compiler language to native code compiler in order to write Perl, Python, or Eiffel on Windows, compile it to IL, and then eventually native code compile it on some other OS platform? Does anyone think such a capability is a good idea? Does anyone think that someone will do this? From rgparker at west.net Sun Jul 9 20:26:11 2000 From: rgparker at west.net (Randall Parker) Date: Mon, 10 Jul 2000 00:26:11 GMT Subject: Run Python as separate process with Apache? Message-ID: I've done a lot with Java servlets using Apache connected to Tomcat where Tomcat runs as a single persistent process that gets all requests meant for it. I am wondering if that same approach can be done with Python. With Java servlets since the process that handles all servlets is persistent that makes it possible for the servlet container (eg Apache Jakarta Tomcat) to keep track of session ids and time them out for you without your even having to check. It is also pretty easy to have a shared database connection pool because, again, there is this single persistent process that instantiates and runs all servlet objects. So I am wondering whether there is a way with Python and Apache to: 1) Have a persistent Python process that processes http requests. 2) Have that persistent process manage a database connection pool. 3) Have that persistent process hand out new session ids for new users, time them out automatically and all the other session management that servlet containers do for you. ie can one create an environment in Python that is similar to what is available with Java servlets? Otherwise how is session tracking and database connection pooling done? From benjamin.sauthier at worldonline.fr Mon Jul 24 13:08:01 2000 From: benjamin.sauthier at worldonline.fr (Benjamin) Date: Mon, 24 Jul 2000 19:08:01 +0200 Subject: mapping the read() fonction Message-ID: <8lhsu5$huv$1@reda.worldonline.fr> I would like to map the read() function of a file object I have a list of file objects. I want to return the list of their content using the map function I've used the map function to open my list of file map(open,list,{"r","r","r"}) (to open a list of 3 files for example) but I can't do the same for the read() function, because it is a method function of the file class How can I map the read() fonction to my list of file? The problem is that I don't know the class name of a file object. The only solution for the moment id to use a for loop on my list.... Thanks Ben From fiona at sitegnome.com Thu Jul 27 06:29:26 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 27 Jul 2000 20:29:26 +1000 Subject: Documentation... References: <397FF3C8.52BEF1A5@acm.org> Message-ID: <39800F06.22290167@sitegnome.com> Hi Jonathan, > Moreover, where could I get some (preferably electronic) > books/documents/tutorials for learning the language? > Thanks! This might be useful -> I'm new to Python, where should I start? Can you give me an overview of the Python Documentation? Do I need books to learn Python? http://www.faqts.com/knowledge-base/view.phtml/aid/1356/fid/199/lang/ and of course, http://python.faqts.com might be useful. regards, Fiona From xiarcexml at yahoo.com Mon Jul 3 16:06:27 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Mon, 3 Jul 2000 13:06:27 -0700 (PDT) Subject: OO Message-ID: <20000703200627.5521.qmail@web5301.mail.yahoo.com> >From my understanding, that is definitely the core of O.O. Extendable, Recyclable, Re-usable... you'd think we were environmentalists or something... ~Dave __________________________________________________ Do You Yahoo!? Kick off your party with Yahoo! Invites. http://invites.yahoo.com/ From aahz at netcom.com Sat Jul 1 19:37:01 2000 From: aahz at netcom.com (Aahz Maruch) Date: 1 Jul 2000 23:37:01 GMT Subject: Threads? References: <8jlnkh$7h$1@supernews.com> Message-ID: <8jlvat$ohi$1@nntp9.atl.mindspring.net> In article <8jlnkh$7h$1 at supernews.com>, Dale Strickland-Clark wrote: > >Can Python execute a function from the same module in another process? >I might do this, for example, to take advantage of multiple processors. I'm a bit confused here. The Subject says "Threads?" but your text says "process". Which is it? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From to_get_my_address at see.my.signature Wed Jul 26 21:17:20 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 14:17:20 +1300 Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> <397BDCC6.9C498F01@my.signature> <397BF66A.EF8BDEF4@prescod.net> <397D1ADA.A8074086@my.signature> <397D21AF.28498FBC@prescod.net> Message-ID: <397F8DA0.A3365BD8@see.my.signature> Paul Prescod wrote: > > If I understand this correctly, then the very first time you add the > attribute to the dict you effectively wipe out the accessor because the > test above will evaluate true every time and the branch that uses > accessors will never get called. Well, that's the same as the way __getattr__ works now, since it's only called if normal attribute lookup fails. If it's considered the wrong behaviour, I wouldn't object to modifying it as Ben Wolfson suggests, so that a check for __get_XXX__ is made before the direct attribute access. -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From scarblac-spamtrap at pino.selwerd.nl Tue Jul 25 13:52:21 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 25 Jul 2000 17:52:21 GMT Subject: Comparison of strings and integer References: <8lkfhs$pav$1@pollux.ip-plus.net> Message-ID: Franz GEIGER wrote in comp.lang.python: > Still not very experienced in programming Python I recently compared > accidentially a string variable with an integer variable. Python did it his > way, which was not my way: I expected a conversion like Perl does or a > runtime error like REBOL does. Is there any way to prevent Python from doing > so? > > Python: print "1" > 1 --> 1 > > Perl: print not ("1" > 1); --> 1 > > REBOL: print "1" > 1 --> > ** Script Error: Expected one of: string! - not: integer!. > ** Where: print "1" > 1 The best way to prevent this is "don't do that then!" :-). Python's docs say that sorting order for incompatible types is arbitrary but consistent. Or so I seem to remember, can't find it at the moment. One way Python's behavior can be useful is for sorting a list; at least equal values will end up grouped together. It would be irritating if heterogenous lists couldn't be sorted at all. What should it do? Complain every time an integer is compared with another type? What about floats? What about complex numbers? What about class instances with a __cmp__ method? If the rule is complicated, it becomes harder to remember. -- Remco Gerlich, scarblac at pino.selwerd.nl 7:51pm up 1 day, 8:43, 6 users, load average: 0.73, 0.91, 0.92 From ge at nowhere.none Thu Jul 27 11:37:07 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 27 Jul 2000 15:37:07 GMT Subject: Documentation... References: <397FF3C8.52BEF1A5@acm.org> Message-ID: In article <397FF3C8.52BEF1A5 at acm.org>, Jonathan Neve wrote: >What exactly is Python? What are its aims, what is it used for? >Moreover, where could I get some (preferably electronic) >books/documents/tutorials for learning the language? It always surprises me when people want to find out about subject FooBar, they manage to find the newsgroup x.y.z.FooBar but didn't find web pages such as www.FooBar.org www.FooBar.net www.FooBar.com I'm neither complaining that people ask such questions in newsgroups nor requesting that they don't. I'm just surprised that they don't find the wep pages first and stumble across the newsgroup later. Most of the people I know have no idea what Usenet is or how to get to it. They all know about the 'web. Anyway, to answer the question, take a look at www.python.org -- Grant Edwards grante Yow! INSIDE, I have the at same personality disorder visi.com as LUCY RICARDO!! From bjorn at roguewave.com Thu Jul 20 12:39:04 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 20 Jul 2000 10:39:04 -0600 Subject: Discussion: new operators for numerical computation References: Message-ID: <39772B28.5B0D0F7C@roguewave.com> John Lull wrote: > > (posted & mailed) > > Huaiyu Zhu wrote: > [snip] > > - Do we want a copy operator := which is different from =? It allows > > efficient code. The following code does not change A > > B := A > > B += C > > This definitely will be usable for other classes. Call it __copy__? > > I'm not convinced this is terribly useful. We can already write B = > A.copy(), and I don't see how the function notation is any substantial > disadvantage here. I could be persuaded otherwise. Note also that := has repeatedly been suggested as the assignment expression, so you can e.g. do: while line := f.readline(): foo(line) (vs. the current kludgy pydiom...) it's also been repeatedly denied, but I'd still rather see assignment expressions added than assignment operators. -b From ryzam at my-deja.com Mon Jul 24 22:55:38 2000 From: ryzam at my-deja.com (ryzam at my-deja.com) Date: Tue, 25 Jul 2000 02:55:38 GMT Subject: how to build ssl on window References: <8lb9ap$j0n$1@nnrp1.deja.com> <8lg7ft$odv$1@nnrp1.deja.com> <397BEAE5.3C1E5151@stroeder.com> <8lh9og$fi5$1@nnrp1.deja.com> <8lhkl1$oou$1@clematis.singnet.com.sg> Message-ID: <8livj9$ogn$1@nnrp1.deja.com> > /usr/local/home/ngps:$ python > Python 1.5.2 (#1, Sep 4 1999, 15:09:59) [GCC 2.7.2.1] on freebsd2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import sys > >>> sys.path > ['', '/usr/local/home/ngps/prog/m2', '/usr/local/lib/python1.5/', '/usr/ local/lib/python1.5/plat-freebsd2', '/usr/local/lib/python1.5/lib- tk', '/usr/local/lib/python1.5/lib- dynload', '/usr/local/lib/python1.5/site-packages'] > > What is the output on your computer? > > -- > Ng Pheng Siong * http://www.post1.com/home/ngps > > This is my output: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.path ['C:\\PROGRA~1\\PYTHON\\TOOLS\\IDLE', 'C:\\Program Files\\Python\\win32', 'C:\\Program Files\\Python\\win32 \\lib', 'C:\\Program Files\\Python', 'C:\\Program Files\\Python\\Pythonwin', 'C:\\PROGRA~1\\PYTHON\\BATCHG~1 \\PYTHON', 'C:\\Program Files\\Python\\Lib\\plat-win', 'C:\\Program Files\\Python\\Lib', 'C:\\Program Files\\Python\\DLLs', 'C:\\Program Files\\Python\\Lib\\lib-tk', 'C:\\PROGRAM FILES\\PYTHON\\DLLs', 'C:\\PROGRAM FILES\\PYTHON\\lib', 'C:\\PROGRAM FILES\\PYTHON\\lib\\plat-win', 'C:\\PROGRAM FILES\\PYTHON\\lib\\lib- tk', 'C:\\PROGRAM FILES\\PYTHON']' izam Sent via Deja.com http://www.deja.com/ Before you buy. From forum21 at euskaltel.net Tue Jul 25 16:01:35 2000 From: forum21 at euskaltel.net (Anton) Date: Tue, 25 Jul 2000 22:01:35 +0200 Subject: Are you looking for hardware or software? Message-ID: <8lks4f$fdi$15@talia.mad.ttd.net> If you wish to buy a new hardware or software, would you like to be offered, for a whole month, different prices from professional sellers, in order to get the best deal possible?. (It's Free). Forum21. Free tool for buyers. http://www.forum21.net/english From richard_chamberlain at ntlworld.com Fri Jul 14 10:51:37 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 14 Jul 2000 15:51:37 +0100 Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: Hi Peter, That's a bit of a sore point at the moment :-) do a search on deja for case sensitive and you'll find a whole argument on the subject. Richard Peter Timaratz wrote in message news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > I can't think of any advantages to a case sensitive language. Python is a > very well-designed language though, so I imagine there is a good reason that > it is case sensitive. So what are the advantages of a case sensitive > language? > > From alex at magenta.com Fri Jul 28 16:16:01 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 22:16:01 +0200 Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> <8lrvae015nm@news2.newsguy.com> <3981D157.D7A1A347@intel.com> Message-ID: <8lspqe02drs@news2.newsguy.com> "Lance Shuler" wrote in message news:3981D157.D7A1A347 at intel.com... [snip] > Yes, I have been using the Win32 extensions (including COM) for over a year > and I own "Python Programming on Win32". I find it very useful. The example > below (including NetUseAdd) is not addressed in "Python Programming on Win32". Not exactly, no. I do think its omission is a bug in Appendix B. > Alex, regarding "local". I avoid mapping to a specific drive letter and just > always use "\\server\share\dir1\dir2\file". This works when moving between > machines, without worrying about whether "K:" is in use or not. I only use True. I probably fell into the habit of always mapping to a drive because of old applications that still do not support UNC (this may have changed, but there were a few among the tools in the SDK...). Alex From fernstrom at geocities.com Mon Jul 31 07:44:16 2000 From: fernstrom at geocities.com (christer fernstrom) Date: Mon, 31 Jul 2000 13:44:16 +0200 Subject: Speed drops when focus moves away from script window Message-ID: When running Zope, I have noticed a drastic drop in speed (order(s) of magnitude!!) when focus is not on the window from which the python interpreter is running. Response time for buttons change from a few seconds to minutes. I run Python 1.6 on W2000. Any suggestions of what I should do? From moron at Glue.umd.edu Thu Jul 20 20:25:50 2000 From: moron at Glue.umd.edu (Warren B. Focke) Date: 20 Jul 2000 20:25:50 -0400 Subject: Discussion: new operators for numerical computation References: Message-ID: <8l85ae$487@stochastic.eng.umd.edu> (Huaiyu Zhu) said: >On Thu, 20 Jul 2000 00:58:06 GMT, Tim Hochberg wrote: >> >>> (2) Which is matrixwise or elementwise >> >>I can't see a good answer here. NumPy has been around for a long time >>and I believe it has a fairly large user base which is a strong >>argument in favor of the ".x" operators being matrixwise. However, > >We may need also to consider future userbase. If we are considering future user base, it seems to be a question of what will produce the least surprise. Since whatever we come up with can't mimic Matlab exactly, I think that preserving compatibility should be deemphasized, and we should try to make it good rather than compatible. I do agree that having .* and * and having them mean the exact opposite of what they do in Matlab is bad, though. But I think also that we should consider not just user base, but code base - how much code is already out there that will break under the various suggestions. My impression is that MatPy is still in a development phase, such that people shouldn't expect everything to be written in stone yet, and that people are, at the moment, more experimenting with it that using it; while there is a good deal of NumPy code out there in production use which would break under a change in the meaning of the current operators. Although, at least, it should be possible to convert it all with sed or something similar. -- If you feel that you have both feet planted on level ground, then the university has failed you. -Robert Goheen, President, Princeton University From guido at beopen.com Wed Jul 26 20:38:55 2000 From: guido at beopen.com (Guido van Rossum) Date: Wed, 26 Jul 2000 19:38:55 -0500 Subject: The State of Python Message-ID: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> I've placed the slides of my talk at the O'Reilly Open Source Convention on-line at our BeOpen PythonLabs website: http://www.pythonlabs.com/talks.html We're also very close to announcing news regarding a new Python license, Python 1.6 and 2.0 release schedules, and a transition of the python.org website to hosting by VA Linux. The announcement is waiting for final negotiations about GPL compatibility of the new license; BeOpen's CTO, Bob Weiner, is confident that the issue will be resolved one way or another by Friday. A preview of what we will announce: - A new license for Python 1.6 and later: the "CNRI Open Source License", approved by the Open Source Initiative; - Release plans for Python 1.6: the last CNRI release, to be issued with help from BeOpen; - Release plans for Python 2.0: the first release to be issued by BeOpen; - A transition for the python.org website: it will be hosted by VA Linux (home of SourceForge), under supervision of the Python Consortium and myself, maintained by the Python community. Please hold your breath a little longer! A re-release of JPython using the CNRI Open Source License is possible a little later, pending further negotiations with CNRI. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From thiele at muc.das-werk.de Tue Jul 11 14:00:48 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 11 Jul 2000 20:00:48 +0200 Subject: references again References: <396A1233.17F2F302@muc.das-werk.de> <396B4CF3.90B13F9A@endea.demon.nl> Message-ID: <396B60D0.68BD2E62@muc.das-werk.de> > Thank you! It works now. But I don't understand why they have used eval and write the string it in __buildins__. From alex at magenta.com Wed Jul 26 17:43:43 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 26 Jul 2000 23:43:43 +0200 Subject: Please help... with re References: <397F5947.EBDA7F33@e-pack.net> Message-ID: <8lnm7c0lu9@news1.newsguy.com> "Olivier Dagenais" wrote in message news:bzHf5.48352$1h3.670995 at news20.bellglobal.com... [snip] > A - stream your input character by character > B - when you encounter a space, add all "buffered" characters to the list > C - if you encounter a quote, ignore rule B until you hit another quote > D - if you hit a backslash, ignore rule C for the next character > E - once you run out of characters, add all "buffered" characters to the > list Nice, clean approach. Who knows about performance, since the re engine is coded in C while this FSM would be coded in Python, but worth giving it a try, I think. Here's a rather straightforward coding of it -- it can no doubt be coded more elegantly by making the FSM explicit; this version relies far too much on making its checks in a specific order, and on 'continue' statements to avoid too-deep nesting... still, here comes, coded off-the-cuff: def splitaline(line): result=[] curtok=[] insidequote=0 literalnext=0 for c in line: if literalnext: curtok.append(c) literalnext=0 continue if c=='\\': literalnext=1 continue if insidequote: if c=='"': result.append(string.join(curtok,'')) curtok=[] insidequote=0 else: curtok.append(c) continue if c=='"': insidequote=1 elif c==' ': result.append(string.join(curtok,'')) curtok=[] else: curtok.append(c) if len(curtok): result.append(string.join(curtok,'')) return result > I made an horrid 68 lines monster to split a string to a list of substrings Well, at least this halves it:-). > based on following example: > > This is an "example of a \"splitted\" text " by my monster. > > results to this list: > > [ 'This' , 'is' , 'an' , 'example of a "splitted" text ' , 'by' , 'my' , > 'monster' ] > > But the stuff is too slow to parse the lines of giant log files. Alex From johngrayson at home.com Fri Jul 14 07:51:15 2000 From: johngrayson at home.com (John Grayson) Date: Fri, 14 Jul 2000 11:51:15 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kmtab$4or$1@pollux.ip-plus.net> Message-ID: <8kmurf$6rf$1@nnrp1.deja.com> In article <8kmtab$4or$1 at pollux.ip-plus.net>, "Bruno Gustavs" wrote: > "Dinu C. Gherman" wrote in message > news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... > > What do you mean by "language constructs", Python keywords > > like "for" or "class"? Are you expecting some statistics of > > used keywords over one's own code? > > > > I doubt this will be very useful, like the answer to the > > question: "Which are the ten most used words in English?". > > But maybe I'm not understanding well how you think you'll > > benefit from such an answer... > > Lets assume you're going to design Phyton2. What would this > language contain? What should Phyton2 support? What would you > like to solve with Phyton2? > > Regards > Bruno Gustavs > > Oh, well now I understand! You've reached the wrong newsgroup: you want comp.lang.phyton. You might get a reponse there! (or not...) Ragerds John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From erik_wilsher at my-deja.com Mon Jul 17 06:51:03 2000 From: erik_wilsher at my-deja.com (erik_wilsher at my-deja.com) Date: Mon, 17 Jul 2000 10:51:03 GMT Subject: Python VM on a Chip? References: <3972ADA8.BF327969@linuxfreak.com> Message-ID: <8kuoej$fma$1@nnrp1.deja.com> >VM? Is it even possible since the data types of Python are late >binding? Does anyone know of a commercial or university project that >is implementing a Python VM using ASICs or FPGAs? Well Martijn Faassen wrote about such a project more than a year ago. (see http://www.egroups.com/message/python-list/56144?&start=56121 ). However, please notice the date of the posting before you get too excited. In the discussion that followed (and I'm sure Martijn laughed) it appeared to be some enthusiasm for such a project. EW Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Mon Jul 31 19:11:56 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 1 Aug 2000 01:11:56 +0200 Subject: How does Python compare to ? In-Reply-To: <8m4v0g$bcbbu$1@fido.engr.sgi.com>; from pj@sgi.com on Mon, Jul 31, 2000 at 10:36:00PM +0000 References: <3FF3ED6EC164DBD2.77C81740D77CD9FA.D247DC7D74D3B365@lp.airnews.net> <8m4bo1$3le2$1@nntp6.u.washington.edu> <8m4v0g$bcbbu$1@fido.engr.sgi.com> Message-ID: <20000801011155.Q266@xs4all.nl> On Mon, Jul 31, 2000 at 10:36:00PM +0000, Paul Jackson wrote: > Donn Cave, donn at u.washington.edu wrote: > |> But it has to be partly the interpreter too. > Good grief - does it ever. On my setup at least, > Python startup is much worse than Perl. > echo 'print "hi"' | perl > echo 'print "hi"' | python > In the same interval, python does some 196 milliseconds worth > of stuff, including 52 open attempts, 34 stat attempts, 67 > sigaction calls, 12 fstat's, 20 close's, 27 brk's, ... Okay, now try it with 'python -S'. This omits the 'site.py' import, which itself requires a ton of other things. When using '-S', python is consistently 10msec faster than perl, on my P2-something running Linux. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at netcom.com.bbs Sat Jul 15 10:30:01 2000 From: aahz at netcom.com.bbs (aahz at netcom.com.bbs) Date: 15 Jul 2000 14:30:01 GMT Subject: Top 10 Language Constructs (Phyton) Message-ID: <3bPa7P$k8I@openbazaar.net> In article <8kpavi04id at news1.newsguy.com>, Alex Martelli wrote: >"Aahz Maruch" wrote in message >news:8knng5$eue$1 at slb3.atl.mindspring.net... >> In article <8kn71u02nn4 at news2.newsguy.com>, >> Alex Martelli wrote: >>>"Dinu C. Gherman" wrote in message >>>news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... >>>> >>>> I doubt this will be very useful, like the answer to the >>>> question: "Which are the ten most used words in English?". >>> >>>That one is pretty useful, actually (it identifies the all-too- >>>frequent words, like 'the', 'of', etc, which a full-text search >>>engine had better just skip over:-). >> >> That's wrong. How do you search for the phrase "the White House"? > >You get all adjacencies of 'white' and 'house', assuming your search >tables are case-insensitive (which they should not be, for umpteen >reasons, but that's another thread, I guess). This only adds a modest >number of false positives: since you were going to get references to >"the white house at the corner of Elm and Main" anyway, it's no great >hardship to also get any "a white house, quite pretty, with a red >roof". Here's a better example: "The Cat in the Hat" With two adjacent noise words, your false positive rate goes up. >But meanwhile you're protecting yourself against losing many relevant >positives due to quirks of English syntax and idiom. "White >House sources denied the allegations" and "The White House denied >the allegations" are basically equivalent; "the", like all such >syntax-marker words, tends to appear or disappear from phrases >depending, unsurprisingly, on syntax (and idiom) issues. Note that many people are not searching for a random document that contains something similar to a phrase, they are searching for a document that contains a specific phrase. (E.g. "the tree of liberty") >And your tables shrink usefully. You can invest the saved space to >provide other precious services that are often skimped on, like, guess >what!, proper casing-flags, flags for inflection, etc. So you can >search for: {white constrain initial-cap} adjacent {house constrain >initial-cap, singular} and get all "properly capitalized" references to >the White House, with or without article. I should note that my primary experience is with Verity, so I'm thoroughly familiar with all these operations; I consider a search engine inferior if it doesn't support them. All the same, most people seem unwilling to learn complex query languages to get the necessary precision in their results. >> (Trust me, this is one area I'm a real expert.) > >I'm out of touch with recent research in the field -- it's been over a >decade since I did computational linguistics -- but my recent usage of >full-text search engines, now so prevalent on the net, does not seem >to show me any advance in the art. Maybe there are new algorithms >and data structures providing speed-ups on the search engine (some >of the engines ARE remarkably fast, I will admit), but the *search >quality* issues, which are connected with what to include in the >tables, search-language semantics, etc, seem to be still all there >(indeed, the search engine I find myself using most often [because it's >so wondrously fast] is extremely poor this way -- can't even ask for >adjacency or nearby-words, etc, etc; but "brute force wins again":-). Yeah, one of the reasons I hate AltaVista so much is because it does a remarkably poor job of result ranking, even by the relatively poor standards of search engines. However, every time I see a serious attempt to improve automated search results, it leads directly to the mucky swamp of AI and "natural language", with degraded search results. I remember one search engine that I typed something like "cat" into, and got documents back containing "cow" because they were both animals (I don't remember the exact example). (Note that I've never been a particular expert on academic research. I've always been much more interested in deployable applications.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From thomas at xs4all.net Sun Jul 9 15:34:50 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 9 Jul 2000 21:34:50 +0200 Subject: Prepending / appending to *args In-Reply-To: ; from nikolai@micon.no on Sun, Jul 09, 2000 at 09:21:12PM +0200 References: Message-ID: <20000709213449.C26534@xs4all.nl> On Sun, Jul 09, 2000 at 09:21:12PM +0200, Nikolai Kirsebom wrote: > I think I've seen how this is done somewhere, but cannot find it. Could > anyone show me how I in function A below add an argument at the beginning of > the list / at the end of the list which then is supplied to function B. > def A(*args): > pa = 'prepended-argument' > aa = 'appended-argument' > B(pa+args+aa) ''''SYNTAX here ?? apply(B, pa+args+aa) However, 'args' is not a list! It's a tuple. There is a difference, especially in how you append or prepend items. In the example above, you're adding strings and tuples, and that won't work. Try it like this: apply(B, (pa,) + args + (aa,)) In Python 1.6 (the alphas, and the betas and final, if they ever arrive ;-) and Python 2.0 (aka the CVS tree ;) you can use the '*syntax' when calling a function too: newargs = (pa,) + args + (aa,) B(*newargs) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From paul at prescod.net Tue Jul 18 16:43:49 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 15:43:49 -0500 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> Message-ID: <3974C185.E39E082E@prescod.net> Eric Hopper wrote: > > ... > > Oh, yes. Inheritance by mysteriously coiniciding method names. How fun. It has nothing to do with inheritance. We are discussing genericity, not inheritance. Some languages can only do genericity through inheritance but this is rare in modern languages. > Just accepting any old type, and letting it error out when it tries to > access a non-existent attribute is very confusing for people trying to use > your code. Heck, maybe you store away their object, and then call the > offending method at some random later point. I bet it'd be a heck of a > lot of fun to try to trace down why the exception happened then. It is not a big deal. You aren't the first person to write a large project in Python. You are of course free to do what you want but I'll caution you that paranoid type checking is typically a phase that Python programmers go through. You'll notice that the standard library does not use type checking functions in most places. In a lot of ways the error messages are *less confusing*. When I get an error message: "read method not defined" then I know I need to define a "read" method. This is better than having a hideously complex type inheritance hierarchy in order to enforce nothing more than that the object needs a read method. That way lies madness: http://java.sun.com/products/jdk/1.1/docs/api/Package-java.io.html > Type checking and the scoping rules are the only two problems I have with > Python so far. Other than that, it's a wondefrul language. Type checking is the most major difference between Java and Python. If I liked everything about Java except its dynamic typing (which is, IMO, its best feature) I would just use Java like everyone else. Nevertheless, if you prefer Python with roll-your-own type checking to Java, more power to you. It's a big tent. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From db3l at fitlinxx.com Mon Jul 17 21:44:55 2000 From: db3l at fitlinxx.com (David Bolen) Date: 17 Jul 2000 21:44:55 -0400 Subject: Multiline strings and indentation References: <39736250$0$14722@wodc7nh6.news.uu.net> <39736E71.AE8B128B@sec.noaa.gov> <3973af3b$0$27161@wodc7nh1.news.uu.net> Message-ID: "donotspam-jen at personic.com" writes: > But in both cases you have to put in extra quotes and explict newline > characters (unless you don't care where the text wraps). Well, you sort of have to explicitly handle the newlines with multi-line strings as well, since they are only going to wrap where you actually wrap them. > Multi-line strings > save a bit of typing, and are a bit easier to reformat when editing. So I > guess this means I have to choose between weird indentation (multi-line > strings) or typing more characters? Either that or see what is leading you to using such long, multiple-line strings (needs line breaks within string) directly within the code and see if you might not be better suited with some sort of data structure to access those strings. I don't know what the strings are for, but if they are messages, or prompts, or other user I/O, perhaps installing them in a dictionary or some other structure within your code would permit you to just retrieve the appropriate string later without needing the inline multi-line strings. That would also permit later extraction for separate message handling, internationalization, etc.. should the need ever arise. It would also cluster these long messages in a single place in your code for maintenance. Just a thought - it might not be relevant in your particular application. For myself I tend to find most strings relatively small (and the occasional full line string that is longer than my source line I just let Python do with the automatic string concatentation of two adjacent strings) within the source itself, longer strings tending to be related to some other structure within the code. -- -- 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 chrish at pobox.com.invalid Thu Jul 27 14:32:43 2000 From: chrish at pobox.com.invalid (Chris Herborth) Date: Thu, 27 Jul 2000 18:32:43 GMT Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: According to Steve Lamb : > On Thu, 27 Jul 2000 15:29:15 GMT, Guido van Rossum wrote: > >If anything, "Be" made a rather confusing choice of name. > > Well, I think it fits if what I hear about what it stands for is true. > BeOS - Bleeding edge Operating System. Considering they designed it from the > ground up for the latest hardware at the time it fits. Otherwise, yeah. The legend is that, before they had a name, someone took a dictionary home and got too bored after looking through... they ended at the end of A; someone asked how far they got, "B" was the reply, someone thought that was a good name, the rest is history... -- ----------========================================================---------- Chris Herborth, DNRC Holder of Past Knowledge Arcane Dragon -==(UDIC)==- BeOS hacker, Catharon Productions, Inc. http://www.catharon.com/ CTO, Next Generation Entertainment http://www.ngent.com/ From jvickroy at sec.noaa.gov Mon Jul 3 15:00:59 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 03 Jul 2000 13:00:59 -0600 Subject: WinNT User Name References: Message-ID: <3960E2EB.A5B1B256@sec.noaa.gov> On Windows NT: import os os.environ['USERNAME'] ... provides the information. I do not believe that either Win 95 or 98 has the 'USERNAME' attribute set. michael montagne wrote: > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm From jepler.lnk at lnk.ispi.net Sat Jul 15 09:03:17 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Sat, 15 Jul 2000 13:03:17 GMT Subject: atof problem. References: Message-ID: On Fri, 14 Jul 2000 03:23:11 GMT, William Dandreta wrote: >Hi Jeff, > >I guess my question was poorly worded. I was looking for the way to set the >internal thousands separator to a comma so atof('1,142.00') results in >1142.00. It's clear from the doc's that it is posssible to do but it doesn't >give enough info for me to figure out how. Look at locale.atof() instead of string.atof or the builtin float(). You may need to recompile your python so that the _locale module is included, however. Jeff From ahopkins at ahopkins.dynacare.com Mon Jul 31 09:52:21 2000 From: ahopkins at ahopkins.dynacare.com (Albert Hopkins) Date: Mon, 31 Jul 2000 13:52:21 GMT Subject: random.shuffle? Message-ID: I wrote a script on my RedHat Linux 6.2 box at home and was pleasantly surprised to see that there was a random.shuffle function. However, when I later ran the script on my RedHat 6.2 box at work, there was no such function. Anyone have any idea where it came from? -- Albert Hopkins Sr. Systems Specialist Dynacare Laboratories ahopkins at dynacare.com I've found that things like "If you change even one configuration setting and your system ceases to function, or functions in a manner other than expected, our support staff will laugh at you in the sinister manner of Joseph Stalin just before he enslaved eastern Europe" helps to draw peoples attention to essential details like this. -Edward Grimm From mjhand at concentric.net.bbs Mon Jul 17 23:30:05 2000 From: mjhand at concentric.net.bbs (mjhand at concentric.net.bbs) Date: 18 Jul 2000 03:30:05 GMT Subject: Wherefore art thou, 1.6? Message-ID: <3bRZMT$mXq@openbazaar.net> As I assume we all know, there is nothing but an unlinked "Python 1.6" at python.org. I was curious about this, but thought it a temporary condition. That was a while ago, though.... So I did a quick deja.com search through c.l.p to see if I could get an explanation. All I found was someone asking three weeks ago and getting, well, no answer. Can someone please post a status on 1.6? Thanks, Manus (who is using [and loves] 1.6a2 and lives in fear that the 1.6 release was for some reason decided against in the alpha stage) From moshez at math.huji.ac.il Fri Jul 28 09:21:08 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 16:21:08 +0300 (IDT) Subject: Perl is worse! In-Reply-To: <398178EA.7576E13A@hursley.ibm.com> Message-ID: On Fri, 28 Jul 2000, Paul Duffin wrote: > Moshe Zadka wrote: > > > > Because numbers are numbers and strings are not. Given, Python's numeric > > model is not very good. > > > > What is wrong with Python's numeric model ? Two examples: 1/2 --> 0 2**100 --> Overflow error, while 2L**100 --> the right answe -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From paulb at infercor.no Fri Jul 28 12:46:44 2000 From: paulb at infercor.no (Paul Boddie) Date: Fri, 28 Jul 2000 18:46:44 +0200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> Message-ID: <3981B8F4.FCFC74B@infercor.no> Steve Lamb wrote: > > On Fri, 28 Jul 2000 10:42:15 +0200, Paul Boddie wrote: > >Having seen Perl's behaviour in cases like the one Tim quoted, albeit in the > >following form... > > > 1 + $variable > > >(trying to remember Perl syntax) where $variable is some text which should > >have been a number but for various reasons happened to be something like > >"foo", I would rather my chosen implementation language did raise an > >exception than pretend nothing was wrong. > > This is a matter of opinion. I have to ask, where were your data checks > in the first place? Well it would be good to check the data first, but then if you're a Perl coder who's confident enough to let the interpreter work out "the right thing" and not warn you about what ancient BASIC interpreters would call a "type mismatch", you're probably going to be fairly easy going about where your data came from. If you are, on the other hand, careful about the value of $variable, I can't see why you wouldn't welcome a bit of type checking. > >What about 1 + "23"? Is "23" a decimal number or a hexadecimal number or > >what? > > Decimal. Is that not decimal form? It could be octal, for example, or any number of other bases. Wherever the data came from might assume the base of the number and not mention it explicitly. I suppose you want to decide the base with prefixes, as in 1 + "023". At that stage, you might as well be writing 1 + string.atoi("23", 8). > Nope. 1 + "foo" = 1. Perl uses the a different syntax to put strings > together. + is only a mathematical operator, not a math and string operator. Yes, I remember this now. And the comparison operators are different for strings and numbers, aren't they? That leads to some interesting results too. > >whereas 1 + "foo" is meaningless to almost everyone except Perl coders. > > But 1 + "1" is not. Well, I could certainly guess what you mean, but there are a number of reasons why we tend not to leave the interpretation of program code to the imagination of the reader. After all, program code is a form of message, communicated to both machine and to other humans. Larry Wall may want to encourage poetically expressive code, but I would rather see unambiguous code which works as the writer intended and as the entire audience expects. (That's the audience who have read the rule book, of course.) Regards, Paul From srs25 at cornell.edu Tue Jul 25 11:50:37 2000 From: srs25 at cornell.edu (Samuel Scarano) Date: Tue, 25 Jul 2000 11:50:37 -0400 Subject: Searching a binary file -- More concrete instance of generalized searching problem References: <397DACE3.515F71A9@cornell.edu> Message-ID: <397DB74D.6A6E5DA4@cornell.edu> Me again. I just thought of a good example that illustrates what I'm thinking of. Suppose the string you're matching against comes in incrementally -- as lines of text to stdin, or perhaps a TCP stream. The total length can be arbitrarily large, so you don't want to just concatenate incoming data to a perpetually growing string. And the match may contain the first character, so you can't just discard old data (e.g., matching 'a.*b' against a string that starts with 'a' and whose first 'b' is at the billionth position). I know its *possible* -- at least with "pure" regular expressions -- because they define regular languages, and membership in a regular language can be determined by scanning a string from left to right without storing a single character -- all that must be stored is the state of the DFA corresponding to the regex. Mmmm... perhaps I should forget all this just impose a bound on the match length. But even then, every time you get a new piece of the string in, you have to re-search that overlap -- that's a *lot* of redundant searching. Too ugly. A regex engine that saves its state would be very useful I think.... Samuel Scarano wrote: > > Interesting problem. I'd like to propose a generalized one which I may be > facing soon: > > Suppose you want to search with an *arbitrary* regular expression. In this > case, you don't know how long the matching string may be, so you don't know > how much overlap you need between buffers. > > Is it necessary, perhaps, to use a constant buffer-overlap size, thus > placing a bound on the length of a matched string? > > Just to make it harder, suppose the buffers are numerous and arbitrarily > small -- sometimes smaller than the matched-string length bound. > > Is there a way to get the regular expression engine to save its state at the > end of one buffer and pick up where it left off on the next? I'm almost > certain that this is possible (at least with the sort of naive DFA-based > regex implementation that I have in mind), but has such functionality been > made available in python? > > luthi at vaw.baug.ethz.NOSPAM.ch wrote: > > > > What is the fastest way to search a binary file for a certain byte pattern > > (**** in my case)? > > > > I came up with this solution, but I guess there is a better way to do > > it. Thanks for all suggestions. > > > > Martin Luethi > > > > ===== > > > > # constants > > MaxFileSizeInMemory = 10*1000*1000 > > > > file = open('my_binary_file', 'b') > > > > file.seek(0,2) # set the pointer to the end of the file > > filesize = file.tell() # get the size of the file > > file.seek(0) # reset the file pointer > > rex = re.compile(r'[\*]{4}') # the bytes to search for > > starpointer = [] # position of the '****' in the file > > oldpos = 0 > > for i in range(filesize/MaxFileSizeInMemory + 1): > > data = self.file.read(MaxFileSizeInMemory) # read a chunk of bytes > > m = rex.search(data) > > while m: # find all '****' in this chunk > > pos = m.start() - 4 # corrected for the length of '****' > > incpointer.append(pos + i*MaxFileSizeInMemory) > > m = rex.search(data, pos + 10) > > oldpos = pos > > file.close() # close the file > > > > -- > > ============================================================ > > Martin Luethi Tel. +41 1 632 40 92 > > VAW ETH Zuerich > > CH-8092 Zuerich mail luthi at vaw.baum.ethz.ch > > Switzerland > > ============================================================ > > -- > Samuel R. Scarano "Due to circumstances beyond my > undergraduate, Cornell University control, I am master of my fate > and captain of my soul." > http://people.cornell.edu/pages/srs25/ -- Ashleigh Brilliant -- Samuel R. Scarano "Due to circumstances beyond my undergraduate, Cornell University control, I am master of my fate and captain of my soul." http://people.cornell.edu/pages/srs25/ -- Ashleigh Brilliant From aahz at netcom.com Tue Jul 25 09:41:29 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Jul 2000 13:41:29 GMT Subject: Python 3000 References: Message-ID: <8lk5e9$osk$1@slb7.atl.mindspring.net> In article , Moshe Zadka wrote: >On 25 Jul 2000, Aahz Maruch wrote: >> >> Yes, I know about the soap opera. The fact remains that 1.6 will almost >> certainly never be a released chunk of code -- it never had a beta! > >However, it will be released, from CNRI with BeOpen's help. I wouldn't >use it, though: just wait one more month for 2.0, which has lots of >improvements. Huh. That's bizarre. Well, if that's what it takes to get the soap opera resolved, I'm certainly not going to complain. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From ge at nowhere.none Wed Jul 12 16:33:34 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 12 Jul 2000 20:33:34 GMT Subject: Switching to Linux...... converting files and databases.... References: <20000712201149.7701.qmail@web5302.mail.yahoo.com> Message-ID: In article <20000712201149.7701.qmail at web5302.mail.yahoo.com>, Dave Williams wrote: >Proposed project: The Windows to Linux Survival Kit >Subject: Software that can open and read Microsoft's proprietary >(wrong word?) files and convert them to databases and files usable by >Linux's opensource software.. FYI, there are alread some projects like that: catdoc, mswordview, (other things for excel and ppt files). One of the projects (can't remember the name) is a library of routines to read/parse MS Office output. Not that a Python library to do that wouldn't be a good thing... -- Grant Edwards grante Yow! ... Just enough at time to do my LIBERACE visi.com impression... From OneDay at ATime.net Sat Jul 22 11:28:25 2000 From: OneDay at ATime.net (OneDay at ATime.net) Date: Sat, 22 Jul 2000 11:28:25 EDT Subject: Newbie question, Getting Started? References: <8lbtqg$2drj$1@earth.superlink.net> Message-ID: <8lceip$5hb$1@earth.superlink.net> Thanks for your reponse and your patience, AL In article , "richard_chamberlain" wrote: >Hi Al, > >>> For example, where do I write a simple MessageBox program > >This may not be as simple as you'd expect Python has a number of extensions >which enable it to have a graphical user interface, one of these Tkinter >you'll have installed already. > >Tkinter is a complicated subject so you'll need a book. But to satisfy your >desire for a message box: > >from tkMessageBox import showinfo >showinfo("Howdy!", "Welcome to Python") > >Don't run this through PythonWin or Idle, run it through windows explorer. > >>>Can I write Python 1.5.2 or Tcl executable programs that can be run on >>> a PC that does not have python installed? > >Kind of. There is a thing called freeze.py which turns your python code into >c code which you can compile if you have a c compiler. That probably doesn't >fit your bill, so there is python module called installer which will convert >it into a standalone file plus some extensions. Also ActiveState recently >announced something that will do it as well. > >I don't think it's something you should worry about at the moment though. > >Good Luck > >Richard > > > > wrote in message >news:8lbtqg$2drj$1 at earth.superlink.net... >> Hello all, >> >> I've done some programming with MS Access and Excell Visual Basic, >but >> am new to Python. I've been reading the tutorial for several days now and >am >> having difficulty figuring out where to start. For example, where do I >write a >> simple MessageBox program? >> >> Can I write Python 1.5.2 or Tcl executable programs that can be >run on >> a PC that does not have python installed? >> >> Thanks for your time, Al >> >> (The only stupid question is the one not asked.) > > From michael at stroeder.com Thu Jul 6 19:02:26 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 07 Jul 2000 01:02:26 +0200 Subject: Public Key Encryption? References: Message-ID: <39651002.B94FDA17@stroeder.com> Stephen Hansen wrote: > > Is there any wrappers/implementations of a Public Key system in python? > I was idly thinking about either wrapping the PGP dll's that Network > Associates puts out, or just the portions of the > (on-the-web-appearing-less-nicely-documented) OpenSSL package that I need. M2Crypto found on http://www.post1.com/home/ngps/m2/ Ciao, Michael. From db3l at fitlinxx.com Fri Jul 28 15:37:05 2000 From: db3l at fitlinxx.com (David Bolen) Date: 28 Jul 2000 15:37:05 -0400 Subject: Perl is worse! References: <8lsdir$aja$1@plutonium.compulink.co.uk> Message-ID: grey at despair.rpglink.com (Steve Lamb) writes: > On 28 Jul 2000 16:49:31 GMT, gbreed at cix.compulink.co.uk > wrote: > >? You said it was only declared to "get the name space in there". > > Yup. "I'm going to use a, for what I know not. Could be string, could be > integer, could be whatever I want." The point was defining the name and > assiciate it with nothing. But since the type is inferred on first use might > as well have the C declarations. I don't think I agree with "the type is inferred on first use" as far as Python's behavior. Nothing is really inferred - the type of an object is always explicit in the object itself. This is, however, quite different from the name used to reference the object, which has no type in and of itself. So something like "a = None" places a reference in the namespace (a) for the object "None". The object None is an explicit object with an explicit type (just as any object would be). If you don't know what objects you might want to refer to eventually with "a", that's fine - just don't bother defining a until you know, and at the point at which you associate a with an object, then that object will have an explicit type. But that still won't affect a, as far as a will still not have any type relationship. In the case here it seems as if you don't really want to define the name and associate it with nothing, you want to define the name and associate it with an object that will support being appended to. In such a case, the notation "a = []" as suggested in other responses is proper. That associates a with a new sequence object (which you start as empty) which supports the operations you are going to wish to perform. Or conversely, you could be asking to really have no definition for a, but have the language implicitly create a new object upon your first attempt to use an ".append" method - something which I don't think is really either intuitive or something that works in the general case for an object oriented model. (Oh, and as an aside - this is an impressive thread - even with the few warts, I think there's useful information 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 db3l at fitlinxx.com Mon Jul 17 22:06:47 2000 From: db3l at fitlinxx.com (David Bolen) Date: 17 Jul 2000 22:06:47 -0400 Subject: Sending output to stdout and also to a file References: <396d44ed$0$11368@wodc7nh0.news.uu.net> Message-ID: "donotspam-jen at personic.com" writes: > Is there a way to have output from system commands go to stdout and also to > a file? For example, is there a way to get the results of the MS DOS "DIR" > command and have it appear both in a file and also on the screen? > > The particular issue I'm trying to solve is that I have a script that calls > PVCS commands. PVCS sends things to both stderr and stdout, which by > default go to the screen. I'd like to capture this output and put it both > on the screen and also in a log file that can be reviewed later. To trap output of a system command you want to use popen() to run the command giving you the output via a File object. (For Win95/98/NT-without-console, you should use win32pipe.popen() from the Win32 extensions for reliable pipes to child processes, but there's a side effect in that you won't get the result code of the process on the close()). If you just want to capture all output of your command (stdout and stderr), you can add a "2>&1" to the end of the command to reroute stderr to the same place stdout is going - which is your process). Once you have the output, you can do anything you want with it. For example, here's a small function that I use to execute commands and dump their output prefaced with a few spaces (to indent it with respects to the other output that my script is creating). I also include a dump of the command and some execution time information since this normally gets used with background scripts that run lots of commands across a bunch of sites. - - - - - - - - - - - - - - - - - - - - - - - - - import os import time def Execute (Command): """ Executes a command string, accepting all output and logging it. The function automatically appends a stderr redirect to include stderr in the output. """ print "Executing", Command start_time = time.time() pipe = os.popen(Command + " 2>&1") while 1: line = pipe.readline() if not line: break print " ", line, rc = pipe.close() stop_time = time.time() if rc: print "Command completed with exit code", rc, else: print "Command completed successfully", print "(elapsed time = %d s)" % (stop_time - start_time) return rc - - - - - - - - - - - - - - - - - - - - - - - - - Now the above function just prints the command output with the indentation, but what I normally do is redirect sys.stdout to a log class that I have which logs to a log file with an optional copy to stdout. The log class also prepends a timestamp (and a "site" id which is just a string used when I walk a bunch of sites for operations). This ensures I get a log of everything that is happening in my script, including all child processes. - - - - - - - - - - - - - - - - - - - - - - - - - import sys import time import os class LogClass: "Class for generating log messages to the log file and optionally stdout" def __init__ (self, Filename=None, DupStdout=0): if (Filename != None): self._file = open(Filename,"a") else: self._file = sys.stdout self._needprefix = 1 self._sitename = None if DupStdout: self._dupstdout = sys.stdout else: self._dupstdout = None def write(self, Message): message = "" if (self._needprefix): message = message + "[%s-%d" % \ (time.strftime("%H:%M:%S", time.localtime(time.time())), os.getpid()) if (self._sitename): message = message + "-" + self._sitename message = message + "] " self._needprefix = 0 message = message + Message self._file.write(message) self._file.flush() if self._dupstdout: self._dupstdout.write(message) self._dupstdout.flush() if (Message[-1] == "\n"): self._needprefix = 1 def log(self, Message): self.write(Message) self.write("\n") if self._dupstdout: self._dupstdout.write(Message) self._dupstdout.write("\n") def setsite(self, SiteName): self._sitename = SiteName - - - - - - - - - - - - - - - - - - - - - - - - - So from a script you would do something like: # Create log class to log file log = LogClass('filename') or # Create log class to log file and include duplicate to stdout log = LogClass('filename',DupStdout=1) and then reassign sys.stdout (and sys.stderr if you want) to the log: sys.stdout = log and then whenever you want to execute a command, just use: Execute('command string') It's normally nice to save the old sys.stdout/stderr and then restore them at the end of your script (say perhaps in a top level try/finally clause) in case your script is included as a module from some other script. Hope this gives you some ideas. -- -- 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 m.faassen at vet.uu.nl Sat Jul 29 11:42:14 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 15:42:14 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> Message-ID: <8luu0m$ags$2@newshost.accu.uu.nl> Grant Edwards wrote: > In article , Huaiyu Zhu wrote: >>In python there are objects and there are names. There are operations that >>act on existing objects and those that create new objects. These have >>nothing to do with mutability, except that for immutable objects, there are >>no operations acting on existing objects. > Looks like a good description to me. > If you're used to thinking in C, I would describe it as > 1) All variables are pointers. > > 2) De-referencing is done automatically when you use a variable in any > context other than as an lvalue. > > 3) All parameters are passed by value. I think that in the context of C this is a bit confusing. If you're passing around pointers in C, you're passing around *references*, not values. Even though the references are obviously passed by value of the reference. I mean, in the end the computer does need to pass around *some* values, otherwise nothing will happen whatsoever. This seems to be where the confusion comes in. When people claim Python passes by value, because the *references* are being passed by value, that seems to be just stating that the only thing the computer can pass in the end is numbers. If you say that, everything is by value and references are impossible, which seems to be a useless set of semantics. > 4) Many/most operations create a new object and return a pointer to it. Method calls often change existing objects, so if you think of these as operations this isn't entirely true. > 5) Some objects can't be changed after they're created, but some objects > provide methods you can use to change them. (though not all methods change objects) > Does that make sense? Sure, with these caveats it makes sense. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From olczyk at interaccess.com Sun Jul 9 23:28:38 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Mon, 10 Jul 2000 03:28:38 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395E05CD.E38F642C@webamused.com> Message-ID: <396b3f42.316716812@nntp.interaccess.com> On Sat, 01 Jul 2000 15:51:48 GMT, Joshua Macy wrote: >"Thaddeus L. Olczyk" wrote: >> >> On 28 Jun 2000 06:02:09 GMT, thomas at xs4all.nl (Thomas Wouters) wrote: >> >> >On Wed, 28 Jun 2000 04:05:21 GMT, Courageous wrote: >> > >> >>> On top of that, very likely that if SUN sues they win. >> > >> >>Ridiculous. >> > >> >Very much so. But it wouldn't be suprising just the same, given the American >> >patenting/registration practices and the average american courthouse ;-) >> > >> >Overseas-ly y'rs, >> > Thomas >> Virtually all SUN has to do is pull some of the demo programs out of >> Microsofts manual. Write the equivalent code in python, perl, C++, >> pascal, and a few other languages. Compare them side by side. A fairly >> sophisticated person can see that it's resemblance to Java. Look at >> the law judges are sophisticated enough. Given that Microshit is being >> sued by SUN for their abuse of Java, I don't think it will be hard at >> all for SUN to convince a judge that all C# is, is a variant of Java >> with tons of proprietary crap glued on and the label changed. > > > You seem to be under the misapprehension that under American law, Sun >owns the very concept of the Java language--that's just not true. >Microsoft could make their own version of Java if they wanted...that's >perfectly legal; IBM is contemplating doing just that. What Microsoft >did wrong was they used Sun's own code, which came with a license that >forbade making incompatible extensions, to make an implementation with >incompatible extensions. If they had gone to the effort of making a >clean version of the code, they would have been in the clear. The only >problem they would have faced is that they might not have been able to >use the Java trademark, which--guess what--C# doesn't do. > > > Joshua I doubt very much that you saw any of Suns code in J++. However to get at certain documentation such as how the JVM worked ( meaning what essentially the bytecode has to look like ). I believe that the license required you to agree to certain things like Sun was the only one which had rights to Java. I would have to see Microshits license to know for sure. As for the law. Perhaps you should aquaint yourself with case law. Such as Ben Bova and Harlan Ellison vs I think it was Universal Studios, 197?. Bova and Ellison wrote a novellette which Universal wanted to make a TV series out of. But the authors didn't like the changes that Universal wanted to make in the book, so they backed out. Universal changed the name and a few of the peripheral elements, incorparated their changes and went ahead anyway. Bova and Ellison won. Sound familiar? From hzhu at localhost.localdomain.bbs Mon Jul 17 16:30:12 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 17 Jul 2000 20:30:12 GMT Subject: Parser project Message-ID: <3bROPb$kqJ@openbazaar.net> On Mon, 17 Jul 2000 14:43:01 -0500, Paul Prescod wrote: >Here is a project for a parser hacker: This is a good idea, although MatPy could not wait for it to happen, and I do not foresee much additional syntax being requested. For the current matrix issue, a limited parser might be easier and more useful. The only bottleneck here is that the supply of binary infix operators is very limited, unlike function or method names. This forces people to write latter when the former is much cleaner. Why not write a parser that changes nothing else but allows additional binary operators? By definition, it would put all the special symbols stuck together as operators, like +=, -=, :=, @+, .*, @*=, etc. Someone had proposed allowing general forms a op b but I would think limiting op to consisting only the symbols that are not in other syntax constructs (like parenthesis, numbers, names, etc) is warranted. This would still give quite a few dozen operators, far more than needed, imo. I'm not sure if it can be made as easy as import NewOperator NewOperator.define(".+", "__dotadd__") class A: def __dotadd__(self, other) ... a=A(); b=A() a.+b NewOperator.define("compares", "__cmp__") ------> Exception: "compares" contains characters not allowed in operator. That would be useful in many domains. Huaiyu From paul at prescod.net Fri Jul 7 00:57:41 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 06 Jul 2000 23:57:41 -0500 Subject: Namespace Mystery (HELP!) References: <39655351.9EE499F2@sunesis-pharma.com> Message-ID: <39656345.86AADA8A@prescod.net> > Why is the output "2 1" and not "2 2"? > What is it about the locals() function that makes it behave > unexpectedly? locals () Return a dictionary representing the current local symbol table. Warning: the contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. http://www.python.org/doc/lib/built-in-funcs.html Python doesn't typically look up local variables based on a string name at runtime. That would be too inefficient. Rather it looks them up positionally. -- Paul Prescod - Not encumbered by corporate consensus Pop stars come and pop stars go, but amid all this change there is one eternal truth: Whenever Bob Dylan writes a song about a guy, the guy is guilty as sin. - http://www.nj.com/page1/ledger/e2efc7.html From akuchlin at mems-exchange.org Fri Jul 14 13:07:57 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 14 Jul 2000 13:07:57 -0400 Subject: Neil Schemenauer's GC patch in python1.6? References: <396F28A1.A181BF39@email.sps.mot.com> Message-ID: <3dn1jkljwy.fsf@kronos.cnri.reston.va.us> Norman Shelley writes: > Is Neil Schemenauer's GC patch scheduled to be in python1.6? Yes, though whoever compiles Python will have the option to include it or not, through an argument to the configure script. Currently in the CVS tree, GC is turned on by default, and you can turn it off by specifying --without-cycle-gc. No one knows if it'll default to on or off in the final 2.0 release; that depends on how much a performance cost is incurred, and how stable the code proves to be. >Having to design programs and > algorithms with reference counting in mind is just as bad as having to > remember to remember to use free() when in C or C++. No it's not; you don't have to worry about things that can't participate in cycles, such as strings for example, but in C you'd have to carefully handle allocation for them, too. --amk From smigowsky at dspace.de Mon Jul 31 11:51:21 2000 From: smigowsky at dspace.de (Stefan Migowsky) Date: Mon, 31 Jul 2000 16:51:21 +0100 Subject: 64k Instruction Limit ?? Message-ID: <326536345498D311B3BC00105A39802A0747D3@newsintern.dspace.de> Hi, if got a script which defines a big tuple > 64k entries. After the tuple I define a for loop. The compile of this script causes a SystemError : com_addbyte out of range. The reason for that is that the return instruction for the for loop is greater than 64k, which means that the inside the com_addint function the hiword is greater than 255. Is there any way around this now or in future versions, other than to try to change the script layout until it compiles ? Stefan From cut_me_out at hotmail.com Mon Jul 17 09:25:54 2000 From: cut_me_out at hotmail.com (Alex) Date: 17 Jul 2000 09:25:54 -0400 Subject: built in sources References: <8kv0rr$lm2$1@nnrp1.deja.com> Message-ID: http://www.python.org/download/download_source.html > where can I get the source for all of the built-in methods, types, > etc... > > Thanks From donn at u.washington.edu Wed Jul 26 15:35:36 2000 From: donn at u.washington.edu (Donn Cave) Date: 26 Jul 2000 19:35:36 GMT Subject: polymorphism (was Re: Type checking in python?) References: <20000726112848.A1101@freei.com> <8lmo4i$s28$1@news.kth.se> Message-ID: <8lnei8$7rm6$1@nntp6.u.washington.edu> Quoth Sean Blakey : ... | The critical point is that in Python, polymorphism depends solely on the | interface provided, not on any "is-a" relationships. Instead of | insisting that your argument must be a string (for example), your code | should work with any object that exposes the interfaces you need | (strings, unicode strings, perhaps even a custom class created by | somebody to emulate Java's StringBuffer, etc.). Similarly, you don't | need to verify that your argument is a file, only that it has a read() | method (or whatever method you use). Or you can simply expect a read() method. Don't verify it, don't support anything else. The polymorphism is up to the caller. Examples of this with the file interface can be found in the library, rfc822 comes to mind. I think this is more common than checking for method attributes and then supporting different interfaces. In more general terms, you have to pick or create an interface that covers the important bases. Often enough it's not worth the trouble, and people do use alternate input parameters etc. But where it works out, it could make the function more flexible and yet simpler, by pushing the support for different inputs back on the input objects themselves. Polymorphism. Donn Cave, donn at u.washington.edu From gregory.lielens at fft.be Thu Jul 20 12:17:22 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Thu, 20 Jul 2000 18:17:22 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <39772612.CE635178@fft.be> Tim Hochberg wrote: > > Robin Becker writes: > > > people keep talking about matrix operations as though there is only one > > way to do one kind of matrix multiply; I use at least two (inner, outer) > > commonly, but others eg Kronecker or Lie are certainly in use. I don't > > think any proposal which doesn't address this is likely to get my vote. > > Well Konrad mentioned [x] or (x) which gives you a lot more symbolic > room. For instance one could use [x] for outer products since you can > take an outer "product" with essentially any operation. (*) would be > matrix multiply, (/) would be matrix "divide", we'd still be searching > for a solve operator though. (.) Could be some other inner product. I like the parethese a lot! except for ? which is probably out of question, this is the prettier way to do it, but (alwas a but :-( ) - the solve operator indeed...The only thing i can come with is the ugly (%) or the pretty but out-of-question (\) - patching the parser to deal with that looks a lot more difficult than @ or even . variants (this is doable - in fact, this is already done...) because I think (){}[] are treated in a more specific way by the Grammar...I think to implement that we need a real Grammar guru! > Although, there's a fair amount of "symbol" space in this kind of operator > scheme, but there's still an issue in that for dimensions greater than > two, there's no way to specify which axis to apply the inner products > on. I'm not sure there's any good way to do that with infix notation though. Check my previous post...This could be improved, though, because there is no way to specify the order for matching the dummy indices in the two arrays. Being able to change the order of the indices for the result should also be looked for, and if any clean way to express that is found, we would be able to express anything which is doable using einsteinian convention, i.e. a lot of thing (all thing)...This would rule imho! maybe something as (I adopt (*) for matrix product, may the parser do the same!) a = b.i(1,2,-1,-2) (*) c.i(4,-2,3,-1) for a_ijkl = b_ijmn c_lnkm Then having two "inner products" would allow to default one to contracting the last index of b with the first of c, making a fine matrix multiply, the other to make no contration (making a fine outer product), when no i markers are provided, i.e. b (*) c is a "default" inner product, matrix product if Nd =2 for b and c b[*] c is an outer product, no contraction I personally like it a lot, the only problem (escept for the parser, but probably someone could do it if I fail) is the solve...maybe we could go without, with the help of transposes, as if I make no mistakes, using / for div , \ for solve and .H for transpose-conjugate c = a\b = (b.H/a.H).H ...if transpose conjugate is cheap, i could be a (not perfect) solution Greg. From hzhu at localhost.localdomain Mon Jul 17 19:46:27 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 17 Jul 2000 23:46:27 GMT Subject: Does Python have "not a number" floating point values? References: <8l03pc$92co$1@nntp6.u.washington.edu> Message-ID: On Mon, 17 Jul 2000 16:10:36 -0700, Russell E. Owen wrote: >Does Python support any sort of floating point "not a number" (e.g. IEEE >infinity)? This seems to work and is used in MatPy (taken from several replies I got here): Inf = inf = 1e300**2 NaN = nan = inf - inf Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From grey at despair.rpglink.com Fri Jul 28 12:31:23 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 16:31:23 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <3981B034.80FACD08@fft.be> Message-ID: On Fri, 28 Jul 2000 18:09:24 +0200, Gregory Lielens wrote: >Whether or not non-programmer makes this link (text representation/numeric >value), I do not know in general, but I think I could reasonable assume than >people with mathematical background will not do it, and thus find Python more >suitable to their way of thinking than perl... Fair enough. In fact, interesting post. :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From fichou at katamail.com Wed Jul 26 15:39:33 2000 From: fichou at katamail.com (Patrick Fichou) Date: Wed, 26 Jul 2000 21:39:33 +0200 Subject: Python 3000 Message-ID: <8lneqf$f3m$1@serv1.albacom.net> Wot is (or will be) Python 3000 ? From moshez at math.huji.ac.il Sat Jul 15 03:15:38 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 15 Jul 2000 10:15:38 +0300 (IDT) Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: Message-ID: On Sat, 15 Jul 2000, Huaiyu Zhu wrote: > How would you write this in list compresension (in less than 10 lines)? > > B*(sin(A*x+b).*(A*y)/3)/C B*[sin(a)*b/3; for a,b in transpose([A*x+b, A*y])]/C -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From moshez at math.huji.ac.il Fri Jul 14 13:27:35 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 14 Jul 2000 20:27:35 +0300 (IDT) Subject: ?Neil Schemenauer's GC patch in python1.6? In-Reply-To: <396F3FA6.6EBC62BA@email.sps.mot.com> Message-ID: On Fri, 14 Jul 2000, Norman Shelley wrote: > Is Neil Schemenauer's GC patch scheduled to be in python1.6? Note that Python's release from PythonLabs (the one you're talking about) is called Python 2.0. And yes, it will be in there -- but it's not yet certain whether it will be enabled or disabled by default. If it's important to you and you're building Python from source, you can enable it at any rate. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From Armin at Steinhoff_de Sun Jul 16 17:12:57 2000 From: Armin at Steinhoff_de (Armin Steinhoff) Date: 16 Jul 2000 14:12:57 -0700 Subject: Funding vs Python References: <8kt4rj$d4n$1@nnrp1.deja.com> Message-ID: <8kt8gp$bg@drn.newsguy.com> In article <8kt4rj$d4n$1 at nnrp1.deja.com>, Andy says... > >I was tired of hearing a friend talk about how wonderful Python is, >so I decided to learn Python by using it to implement a product that >the official implementation team thought would take experts 1-2 man >years using numerous Java buzz-words. A month later, I'm still a >Python newbie, but I'm close enough to done that I'm looking at >the rev 2 feature list. (The experts are still trying to hire >but are going to start any day because other folks like running >code more than they like plans.) > >No good deed goes unpunished, so now I'm getting push back along the >lines of "we can't get funded if it's in Python". (Somehow, I don't >think that using Perl would have produced the same reaction.) Well ... compile your Python sources into C++ or use JPython in order to generate JAVA code :-)) Regards Armin > >I've seen the list of web projects at python.org, so I'm wondering >if there are others or if there really are examples of companies that >didn't get funded because they used Python. > >-andy > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From jhylton at my-deja.com Sat Jul 8 12:13:08 2000 From: jhylton at my-deja.com (Jeremy Hylton) Date: Sat, 08 Jul 2000 16:13:08 GMT Subject: Python Job Board [was Re: job offer] References: <8k2a7p$mi71@imsp212.netvigator.com> <8k2asd$gin$1@slb0.atl.mindspring.net> <8k2ilp$aao$1@nnrp1.deja.com> Message-ID: <8k7jue$f42$1@nnrp1.deja.com> The Job Board has been updated with several new advertisements. http://www.python.org/Jobs.html Thanks to Roger Masse at CNRI for taking care of the backlog. Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From ssthapa at midway.uchicago.edu Sat Jul 1 17:17:45 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 01 Jul 2000 21:17:45 GMT Subject: MD5 - Passwords with python References: <6e7dj8.bvb.ln@iiab.soluma.de> <8jd74i$16vk@newton.cc.rl.ac.uk> <2vegj8.ia5.ln@odin.hmf.de> Message-ID: holger at fuessler-net.de wrote: >Hallo! > >Now I've got it. It's f for followup and not r for reply mail (in TIN). I >was wondering if somebody kills my followups ;-) > >Unfortunately, the standard MD5-module doesn't know about the structure of >the password-string so I can't encode a password with it. I found a perl >module which accomplishs my task and so I thought that there is also a python >module. I thought redhat uses a lot of python stuff, so there should be a >routine to generate suitable passwords. I'v already posted in >comp.redhat.security. When I find the details, I'll post them here (if I can >translate them to python). I vaguely remember the format of the passwd string from having to modify crack to use it. Basically the beginning of the string has a salt enclosed between $'s. This is either appended or prepended to the password and a md5sum is taken. I believe this is right but YMMV. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From neilh at scintilla.org Sun Jul 30 08:07:59 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 30 Jul 2000 12:07:59 GMT Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> Message-ID: > Can somebody tell me, how a dll call from Python works on principal? Let us > suppose I'd like to something like caldll. Where should I start. Which > Python "primitives" have I to use? I can explain how to use calldll. If you want to know how to write your own extensions then you should read the "Extending and Embedding the Python Interpreter" document which is part of the standard documentation package and should have been installed when you installed Python. calldll is a low level Python extension libary which contains functions for creating buffers, loading DLLs, finding the address of functions within the loaded DLLs, and calling the functions. On top of that is a higher level windll module that makes it more convenient to call. Here is a sequence of calls: import calldll kernel32 = calldll.load_library('kernel32.dll') Beep = calldll.get_proc_address(kernel32, "Beep") ret = calldll.call_foreign_function(Beep,'ll','l',(1000,500)) Neil From pduffin at hursley.ibm.com Fri Jul 28 08:13:30 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Fri, 28 Jul 2000 13:13:30 +0100 Subject: Perl is worse! References: Message-ID: <398178EA.7576E13A@hursley.ibm.com> Moshe Zadka wrote: > > Because numbers are numbers and strings are not. Given, Python's numeric > model is not very good. > What is wrong with Python's numeric model ? From paul at prescod.net Fri Jul 21 16:42:20 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 21 Jul 2000 15:42:20 -0500 Subject: Accessing current namespace's dictionary... References: Message-ID: <3978B5AC.FDA9EAB8@prescod.net> Michael Morrison wrote: > > ... > > I'm trying to access the module that is running namespace dictionary, but I > can't seem to find a way to do it. It's called globals(). >>> globals()["foo"]="bar" >>> dir() ['__builtins__', '__doc__', '__name__', 'foo'] I'm not sure whether it is a documented feature that it is writable or not. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From sholden at bellatlantic.net Thu Jul 6 16:47:52 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Thu, 06 Jul 2000 20:47:52 GMT Subject: Win32com ADO curiosity #1: MoveNext References: <8k2pnc$f64$1@nnrp1.deja.com> Message-ID: <3964F05E.62FA2B3B@bellatlantic.net> mksql at my-deja.com wrote: > > In the following code (rs refers to an ADO recordset already created): > > print rs.Fields(1).Value > rs.MoveNext > print rs.Fields(1).Value > > prints the same record twice, while: > > print rs.Fields(1).Value > rs.MoveNext() > print rs.Fields(1).Value > > prints 2 records, as expected. > > Why does MoveNext require the () ? The ADO object model does not > specify parameters for MoveNext, MoveFirst, etc. > > Sent via Deja.com http://www.deja.com/ > Before you buy. The MoveNext procedure has to be called, not referred to. Unlike VBScript, Python required the parentheses even when no parameters are passed into the call. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://home.cox.rr.com/sholden/ From anders.eriksson at morateknikutveckling.se Thu Jul 27 08:36:29 2000 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Thu, 27 Jul 2000 14:36:29 +0200 Subject: PIL and JPEG Message-ID: Hello! I have a program that uses PIL to create Thumbnails of images. When I try to do this on a JPEG image I get this error: Traceback (innermost last): File "/home/user10/d9712mor/public_html/cgi-bin/Postcard.py", line 5, in ? Montys.PServer.CreatePreview() File "/import/user10/d9712mor/python/Montys/PServer.py", line 109, in CreatePreview CreateThumbnail(imagedir,i) File "/import/user10/d9712mor/python/Montys/PServer.py", line 33, in CreateThumbnail im.thumbnail((75, 112)) File "/import/user10/d9712mor/python/PIL/Image.py", line 724, in thumbnail self.load() File "/import/user10/d9712mor/python/PIL/ImageFile.py", line 133, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "/import/user10/d9712mor/python/PIL/Image.py", line 229, in _getdecoder raise IOError, "decoder %s not available" % decoder_name IOError: decoder jpeg not available I realize that PIL thinks that I haven't linked in the JPEG library, which I have!! All the compiling and linking is working OK == no errors. Python/PIL is only using the _imaging.so and all the python code for this? I don't need any path to the libjpeg.a do I? I'm using Python 1.5.1 PIL 1.0 Independent JPEG Group's JPEG software version 6b Solaris 5.6 If someone has a clue PLEASE help!! // Anders From mpotter27 at my-deja.com.bbs Wed Jul 12 16:00:10 2000 From: mpotter27 at my-deja.com.bbs (mpotter27 at my-deja.com.bbs) Date: 12 Jul 2000 20:00:10 GMT Subject: Tkinter destroy() and mem leaks Message-ID: <3bNSCA$mOS@openbazaar.net> Hi, I have what is probably a rather naive question, but here goes... I puzzled as to why invoking the destroy() method on a widget fails to remove the reference to it's master? As far as I can tell from the code it removes the references in master.children, removes all it's own children entries, etc.. but retains it's self.master reference. For example: >>> from Tkinter import * >>> import sys >>> f = Frame() >>> b = Button(f) >>> sys.getrefcount(f) 4 >>> f.destroy() >>> sys.getrefcount(f) 3 >>> b.master >>> f.children {} >>> b.master = None >>> sys.getrefcount(f) 2 This typically isn't a problem as long as the master doesn't hold any references to the child other than via .children. However, the situation that made me notice this was one in which I made a simple- minded "mega-widget" by subclassing Frame and having it store references to a number of subwidgets as attributes: class myFrame(Frame): def __init__(self,parent = None): Frame.__init__(self,parent) self.button = Button(self,command=self.callback) def callback(self): pass If used so: frame = myFrame() frame.destroy() del(frame) It leaks memory as the button references the myFrame instance via .master and myFrame references the button via self.button. Now one could avoid this by structuring the code differently, but it seems that simply having Tkinter.BaseWidget.destroy set self.master = None would solve the problem. It seems that destroy should remove all the Tkinter specific "stuff" from the python proxy object. However I'm sure there's a reason it doesn't. I'd be grateful if someone could tell me what it is. Sorry for the long post! Mike Potter Center for Advanced Research in Biotechnology 9600 Gudelsky Dr Rockville, MD 20850 potterm at erols.com Sent via Deja.com http://www.deja.com/ Before you buy. From akuchlin at mems-exchange.org Mon Jul 10 18:26:34 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 10 Jul 2000 18:26:34 -0400 Subject: Application testing References: <8kdafd$2nj$1@bob.news.rcn.net> Message-ID: <3d66qd1v1h.fsf@kronos.cnri.reston.va.us> "Mark Haselup" writes: > I have been informed that I can use Python (or some of it's extensions) to > capture and replay the http traffic between the Browser and the Webserver to > simulate a user session. Unfortunately I've not been able to find any Hmm... Medusa (http://www.nightmare.com/medusa/) includes a simple socket proxier as a demo program; it can be placed between a client and server to log the data that flows between them, with no understanding of the protocol. If this proxier understood the structure of HTTP, it could probably distinguish the transactions and record them for later replay. --amk From SCook at pobox.com Fri Jul 21 20:45:04 2000 From: SCook at pobox.com (Steve) Date: Sat, 22 Jul 2000 00:45:04 GMT Subject: MySQL on Win9X References: Message-ID: Go here http://www.mysql.com/downloads/mysql-3.23.html You can download the official Win9x/NT install package. MySQL 3.23 is now under the GPL so you can get it for windows without paying for it, like you have to for 3.22 "Fernando Rodr?guez" wrote in message news:IoYd5.199$kp4.2368 at m2newsread.uni2.es... > > "Scott" escribi? en el mensaje > news:slrn8ngf36.f1p.kain at cableadmin.com... > > Hello, > > > > Are there any pre-compiled MySQL modules for windows? I've found the > > sources but don't have nor can I install a compiler on this machine. > > I'm looking for the same thing, so please let me know if you ever find > one. :-) > > From aahz at netcom.com Thu Jul 27 18:07:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 27 Jul 2000 22:07:26 GMT Subject: New operators needed? (was Re: Discussion: new operators for numerical computation) References: <397C9207.EC0528AA@eecis.udel.edu> Message-ID: <8lqbqu$uhm$1@slb2.atl.mindspring.net> In article , Konrad Hinsen wrote: > >You raise an important point: adding operators may not be the best >solution at all. > >With the ongoing rework of NumPy that turns arrays into Python classes >with an underlying C implementation, it would be possible to have an >"array" and a "matrix" class with different semantics, but sharing >most of the code and having equal performance. Conversion between the >two would also be possible at basically no cost, and C modules could >be written to accept both. Huzzah! "And there was much rejoicing in the land...." -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From mjackson at wc.eso.mc.xerox.com Thu Jul 27 09:21:54 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 27 Jul 2000 13:21:54 GMT Subject: The State of Python References: <8lpbs3$oac$2@newshost.accu.uu.nl> Message-ID: <8lpd1i$ili$1@news.wrc.xerox.com> m.faassen at vet.uu.nl (Martijn Faassen) writes: > Guido van Rossum wrote: > > A preview of what we will announce: > [snip] > > Ah, good, I was hoping for some clarification. I couldn't keep track of > the soap very well; who had died, who had returned with memory loss, > who's a good guy, who's a bad guy, if the blind guy will be > miraculously healed, will the marriage succeed, and what version numbers > they all have. And why. If you unexpectedly find Larry Wall in your shower, be afraid. Be very afraid. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson A doctor can bury his mistakes, but an architect can only advise his client to plant vines. - Frank Lloyd Wright From nospam.newton at gmx.li.bbs Tue Jul 18 02:30:01 2000 From: nospam.newton at gmx.li.bbs (nospam.newton at gmx.li.bbs) Date: 18 Jul 2000 06:30:01 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bRe7P$keK@openbazaar.net> On Mon, 17 Jul 2000 13:08:52 -0500, Paul Prescod wrote: > the (equally unlikely) death of Unix would drive Perl users to > Python) Why would ex-Perl-on-Unix-users have to switch to Python if their platform disappeared? What makes you think (nearly) no-one on Mac OS or Win32 uses Perl? Cheers, Philip -- Philip Newton If you're not part of the solution, you're part of the precipitate. From nobody at nowhere.nohow Mon Jul 31 10:37:47 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Mon, 31 Jul 2000 14:37:47 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> <39846ECC.DF5FE175@san.rr.com> <39848FFE.948BF635@san.rr.com> <3984E1F2.3C131999@san.rr.com> Message-ID: In article <3984E1F2.3C131999 at san.rr.com>, Courageous wrote: >Well, golly, I dunno. What is it we're arguing about? :) Nothing, apparently. :) >Anyway, I don't believe that, just because real objects behave >that way means that it follows that python labels should have >type tags. Which isn't to say that's what you were saying and >all.... but, gosh, I thought you were.... No, but I think somebody else may have been. I was arguing that having allowable operations determined by the type of object was intuitive to non-programmers since that's they way our interaction with real physical-word objects work. As opposed to the proposition that "data is data" and since it doesn't really exist, it doesn't have any type, and any piece of data should be able to be operated on by any operator or method. Or something like that. -- Grant Edwards grante Yow! My Aunt MAUREEN was at a military advisor to IKE visi.com & TINA TURNER!! From musingattheruins at my-deja.com Fri Jul 21 13:15:40 2000 From: musingattheruins at my-deja.com (musingattheruins at my-deja.com) Date: Fri, 21 Jul 2000 17:15:40 GMT Subject: Class static variables References: <8l9vb3$kae$1@nnrp1.deja.com> Message-ID: <8la0fa$l9r$1@nnrp1.deja.com> In article <8l9vb3$kae$1 at nnrp1.deja.com>, Guillaume wrote: > > > > I'm writing a tool to translate a variety of OO > > > programming languages. Especially I target Python > > > but I am hesitating about the way to define > > > class-scope static variables. Could you suggest me > > > what is the best and natural form ? > > > > > > Example: MyClass { static int a; } > > > - MyClass_a > > class MyClass: > > #define class attribute > > a = 0 > > def method(self): > > #use class attribute > > do_something_with(MyClass.a) > > > > #use class attribute outside of MyClass > > do_something_else_with(MyClass.a) > > Thanx for the answer but... > > >>> class CA: > ... a=0 > ... > >>> b=CA() > >>> b.a > 0 > >>> b.a=2 > >>> c=CA() > >>> c.a > 0 > >>> b.a > 2 > > # c.a should be 2 and not 0 if a is a static attribute. you are attaching a per-object variable with b.a=2 try CA.a - i think you will find it is still 0. regards, bill Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Sun Jul 9 07:52:58 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Sun, 09 Jul 2000 21:52:58 +1000 Subject: [FAQTS] Python Knowledge Base Update -- July 6th, 2000 References: <20000706115459.24950.qmail@synop.com> Message-ID: <3968679A.C8550D36@sitegnome.com> Huaiyu Zhu wrote: > > On 6 Jul 2000 11:54:59 -0000, Fiona Czuczman wrote: > > > >"Many thanks to Hans Nowak for providing FAQTs with his collection of > >snippets for entry into http://python.faqts.com. > > > >They can be found directly at > > > >http://www.faqts.com/knowledge-base/index.phtml/fid/538/lang/en > > Congratuations for your excellent work! > > Where is the original snippets collection? And how do I submit new ones? > Shall I post them here? I'd prefer not using web forms. Originally the snippets were located here http://tor.dhs.org/~zephyrfalcon/snippets however this link seems to be no longer available. When Hans originally wrote to me he advised that he would be closing his python snippets site down and offered them to FAQTs. Contributing new snippets: either enter them directly into the forms on the site or, if you'd prefer not to do that :-) , please just send an email to me personally with the snippet(s) and I'll enter them on your behalf. Thanks, Fiona Czuczman From ssthapa at midway.uchicago.edu Tue Jul 11 11:14:22 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Tue, 11 Jul 2000 15:14:22 GMT Subject: Anyone used Python for GPIB instrument control? References: <39668E65.356337BF@home.com> <3967E902.AE41CF0D@attglobal.net> Message-ID: Jon McLin wrote: >The Linux Lab project has a gpib driver, and Python wrappers are included. I >believe the drivers emulate the NI drivers, so this wrapper should work for you. > >ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/IEEE488/ The last I've heard about the Linux GPIB driver, was that it was pretty flaky and wasn't reliable enough to use in a production environment. However, that may have changed. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From kuchler at ajubasolutions.com Thu Jul 27 17:09:24 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Thu, 27 Jul 2000 14:09:24 -0700 Subject: The State of Python References: <8lqg6o$k2k$1@slb1.atl.mindspring.net> Message-ID: <3980A504.7A771655@ajubasolutions.com> Andrew Dalke wrote: > > Right, and then I would still be using Tcl or start looking at > Lua or Ruby or other languages. Tcl is licensed under the BSD license (which is less at least a standard license, and is not as restrictive as the GPL license). One advantage of using the BSD license is that it allows the language to be used as part of a commercial product, without the rest of the source for that product having to be open sourced. This has allowed tcl to be used in lots of commercial products. I hope that whatever license Python ends up with, that it will promote the use of Python and won't restrict its applications. --Dan From fgeiger at datec.at Fri Jul 21 13:56:42 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 21 Jul 2000 19:56:42 +0200 Subject: Python on Win32: How to freeze? How to hide the system console? Message-ID: <8la2o6$hfu$1@pollux.ip-plus.net> New to Python I have 2 q's: 1) Does anybody "freeze" his Python scripts dev'ed on and for Windows machines? How? Is Tkinter code freezed too? What's the result? A single EXE file? 2) How can I hide the system console on a Windows machine running a Python script using Tkinter? Any hint is appreciated. Thanks in advance and regards Franz GEIGER From jkraska1 at san.rr.com Fri Jul 28 01:52:03 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 28 Jul 2000 05:52:03 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <8losor$4bk$1@nnrp1.deja.com> Message-ID: <39812033.8A8D88E1@san.rr.com> > But the irony now is that ZOPE will be 'opened' to PERL too. I have > read through the 'debates' going on in the zope mailing list, but it > still doesn't make sense - why allow Zope to be polluted by something > that is clearly deficient? Because it would be the moral equivalent to walking into a bank and telling them they had to ditch all of their COBOL programs. You'd get laughed right out of Dodge. :) C/ From lau at adtranzsig.de Fri Jul 21 02:20:32 2000 From: lau at adtranzsig.de (Ralf Laukien) Date: Fri, 21 Jul 2000 08:20:32 +0200 Subject: Checking for end of a file References: Message-ID: <3977EBB0.1FA706EC@adtranzsig.de> Two possibilities for text file iteration: I) for row in file.readlines(): ..... II) row = file.readline() while row != '': ..... row = file.readline() Ralf CB schrieb: > > If I'm iterating through a text file, reading one line at a time within a > while statement, how do I check for the end of file. I tried while > filename.eof and filename.eof() but to no avail? > > Colin From jwbnews at scandaroon.com Mon Jul 24 18:31:53 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 24 Jul 2000 15:31:53 -0700 Subject: IEEE 754 References: <8lifaa$1bb$1@agate.berkeley.edu> Message-ID: In article <8lifaa$1bb$1 at agate.berkeley.edu>, ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) wrote: > Next interesting discussion: How to add radix-10, IEEE 854 support... You mean I may someday be able to put aside my answers to the "why doesn't 2/10 print as 0.2 as we all know it should?" sorts of questions? Too much to hope for. --John (hoping anyhow) -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From info at pythonware.com Fri Jul 28 08:20:39 2000 From: info at pythonware.com (PythonWare) Date: Fri, 28 Jul 2000 14:20:39 +0200 Subject: ANNOUNCEMENT: PythonWorks Evaluation Version now available! Message-ID: <00c701bff88e$3effcfe0$0900a8c0@SPIFF> for those of you who haven't already seen it: An evaluation copy of PythonWorks 1.0.1 is now available from the PythonWare site: http://www.pythonware.com/products/works => click on testdrive The evaluation version includes all IDE components, but only a subset of the documentation, and no redistributables. For more info, see the PythonWorks site, or drop us a line at info at pythonware.com enjoy, the pythonworks team "Secret Labs -- makers of fine pythonware since 1997." From jdub at nospam.net Tue Jul 11 15:40:56 2000 From: jdub at nospam.net (someguy) Date: Tue, 11 Jul 2000 15:40:56 -0400 Subject: win32com: How to use optional parameters? References: <8ket8e$nj6$1@spectra.a2000.nl> <8kf3i4$1gu$1@spectra.a2000.nl> Message-ID: <8kft89$rnd$1@news2.acs.oakland.edu> Sir, why not hold the places like this: xl.Worksheets.Add(NULL,NULL,NULL,aftervaluehere) just as if you weren't using the "parametername=varnam" syntax, even VB would default to the order the function expects the calls. Another sure way to find out would be to generate the MIDL for the excel VBA you are coding, then you could do the same thing in C/C++ COM which would most certainly require the correct order of parameters and not named parameters in any order. -Jay R. Wren "Ilja Heitlager" wrote in message news:8kf3i4$1gu$1 at spectra.a2000.nl... > There was a small error in my example: > > > > xl.Worksheets.Add After:=xl.Worksheets.Count > > > > should be in VB: > > xl.Worksheets.Add After:=xl.Worksheets(xl.Worksheets.Count) > > So in Python it becomes: > > xl.Worksheets.Add(After=xl.Worksheets(xl.Worksheets.Count)) > > Which PythonCom sees as the first argument (the Before), argh. > > PS I am using Pythoncom Version 1.5.2, build 129 > > Please guys help me out, I hate to do all my work in VB (if possible ;-) > > Ilja > > From jhauser at ifm.uni-kiel.de Mon Jul 31 16:12:47 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 31 Jul 2000 22:12:47 +0200 Subject: check file exists References: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: <873dkqvz28.fsf@ifm.uni-kiel.de> >>> import os >>> os.path.isfile('opev.txt') 1 HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From tidop at my-deja.com Wed Jul 5 21:46:37 2000 From: tidop at my-deja.com (tidop at my-deja.com) Date: Thu, 06 Jul 2000 01:46:37 GMT Subject: setting a C-structure from Python Message-ID: <8k0odu$m43$1@nnrp2.deja.com> My aim is to write an extension module to access functions in C which "get" and "set" some structures from/in shared memory. In order to do this, I implemented the following programs: * structure.py * test_API.c It works well when I set the structure the first time, but not a second time I have got the following (run-time) error... where is the bug ? >>> import structure The structure is now: name Benoit age 22 rate 3.141500 Traceback (innermost last): File "", line 1, in ? File "structure.py", line 19, in ? test_API.setstruct(packed) TypeError: argument 1: expected string, found I am working with Python 1.5.2 on QNX 4.25 test_API.c is therefore statically linked with Python as dynamic linking is not possible on QNX. file : structure.py ----------------------------------------- import struct import test_API #1st try fmt="20sif" a="Benoit" b=22 c=3.1415 packed=struct.pack(fmt,a,b,c) test_API.setstruct(packed) #2nd try a="Ben" b=23 c=3.1417 packed=struct.pack(fmt,a,b,c) test_API.setstruct(packed) file: test_API.c -------------------------------------- #include #include "Python.h" typedef struct{ char name[20]; int age; float rate; } examplestruct; examplestruct * example; static void print_struct() { printf("The structure is now: \n"); printf("name %s\n",example->name); printf("age %i\n",example->age); printf("rate %f\n", example->rate); } static PyObject * test_setstruct(PyObject * self, PyObject * args) { PyObject * string_from_python; if (!PyArg_ParseTuple(args,"S",&string_from_python)) return NULL; example= (examplestruct *) PyString_AsString(string_from_python); Py_DECREF(string_from_python); print_struct(); Py_INCREF(Py_None); return Py_None; } static PyObject * test_getstruct(PyObject * self, PyObject * args) { /* if there are any arguments */ if (!PyArg_NoArgs(args)) return NULL; return PyString_FromString(example); } /************************************************************* METHOD REGISTRATION TABLE List of functions defined in the module *************************************************************/ static struct PyMethodDef test_API_methods[] = { {"setstruct", test_setstruct, 1}, {"getstruct", test_getstruct, 1}, {NULL, NULL} }; /************************************************************* Initialization function *************************************************************/ void inittest_API() { PyObject *m, *d; /*create the module and add the functions */ m= Py_InitModule("test_API", test_API_methods); /* add symbolic constants to the module */ d= PyModule_GetDict(m); if (PyErr_Occurred()) Py_FatalError("can't initialize module test_API\n"); } Sent via Deja.com http://www.deja.com/ Before you buy. From tgagne at ix.netcom.com Mon Jul 31 12:51:04 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Mon, 31 Jul 2000 12:51:04 -0400 Subject: ERROR: No module named _tkinter Message-ID: <3985AE78.9E87E83D@ix.netcom.com> tgagne:/home/tgagne/tmp/idle-0.5 ./idle.py Traceback (innermost last): File "./idle.py", line 2, in ? import PyShell File "./PyShell.py", line 12, in ? from Tkinter import * File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 8, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter What do you suppose the problem is? From t.harris at robinsons.co.uk.bbs Mon Jul 17 12:00:02 2000 From: t.harris at robinsons.co.uk.bbs (t.harris at robinsons.co.uk.bbs) Date: 17 Jul 2000 16:00:02 GMT Subject: Global & Importing issues.... Newbie Message-ID: <3bRHO2$j08@openbazaar.net> I have a simple requirement for a second module to access a global variable stored in the first (main) module. I can reproduce my problem with the following 2 modules... Mod1.PY >>> import Mod2 myGlobal = None if __name__ == "__main__": myGlobal = 100 Mod2.DoPrint() #endif #endmodule Mod2.PY >>> import Mod1 def DoPrint(): print Mod1.myGlobal #enddef #endmodule When executing Mod1.PY I expect the answer 100 to be printed out, I get None I also get the same problem if there is a function in Mod1 which prints the value of myGlobal and is called from Mod2 - I think this is the same problem. :o( Any help from Python experts ? TIA Toby From moshez at math.huji.ac.il Fri Jul 28 09:19:22 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 16:19:22 +0300 (IDT) Subject: The State of Python In-Reply-To: <39817536.FDBC508D@hursley.ibm.com> Message-ID: On Fri, 28 Jul 2000, Paul Duffin wrote: > What does GPL compatible mean ? It means that it can be relicenced as GPL. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From mksql at my-deja.com Thu Jul 6 23:33:57 2000 From: mksql at my-deja.com (mksql at my-deja.com) Date: Fri, 07 Jul 2000 03:33:57 GMT Subject: Win32com curiousity #2: PythonWin code completion References: <8k2q2c$fg2$1@nnrp1.deja.com> Message-ID: <8k3j35$v4c$1@nnrp1.deja.com> In article , "Michel Orengo" wrote: > When you run makepy, you actually create a file (see in > python\win32com\gen_py) that defines the ADO classes and their > methods/properties (that is true for any other COM classes you run makepy > on). The Dispatch is smart enough to get this file instead of a dynamic > loading. This is why you were able to see all methods/properties after > running makepy. Right, that part I already get. > Also, because you use Fields, MoveNext and Open as methods on the 'rs' > instance, PythonWin used them when constructing its class browser...and > therefore the list of attributes you find in the list for code completion. _After_ running makepy, saving the source, closing PythonWin, reopening the source in PythonWin, the class browser initially is only aware of the methods that are used in my source code. After a certain operation (I think it happens after a save or run), then the class browser display all available methods. I am not sure if this is a PythonWin bug, or my installation or configuration is damaged. Sent via Deja.com http://www.deja.com/ Before you buy. From danny at thrud.anatomy.usyd.edu.au Sat Jul 8 23:03:03 2000 From: danny at thrud.anatomy.usyd.edu.au (Danny Yee) Date: 9 Jul 2000 13:03:03 +1000 Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> Message-ID: <8k8q17$rov$1@thrud.anatomy.usyd.edu.au> I asked: >> I need to convert text with ISO Latin characters to HTML, e.g. >> I want to map ? to é and so forth. wrote: >Just reverse the dictionnary, to be found in htmlentitydefs. Where do I find this? Danny. From cut_me_out at hotmail.com.bbs Sun Jul 16 10:50:04 2000 From: cut_me_out at hotmail.com.bbs (cut_me_out at hotmail.com.bbs) Date: 16 Jul 2000 14:50:04 GMT Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <3bQQ8S$mLt@openbazaar.net> Hi, Beat. The python developers seem pretty indiscriminate about who they'll consider patches from. They have looked at a couple from me, for instance. :) You might want to read this page: http://www.python.org/patches/ it tells you where to send patches. Alex. From ge at nowhere.none Fri Jul 28 10:34:20 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 14:34:20 GMT Subject: Perl is worse! References: Message-ID: In article , Hrvoje Niksic wrote: >For me, 1 and "1" are clearly not two numbers. The former is a >number, the latter a string consisting of the character "1". Saying >that they are numbers because we "see" they're numbers is like >insisting one 1 + "one" to return 2 because "one" is so obviously a >number. And obviously 1 + "Grant's age" should evaluate to 30. But it doesn't. Not even in English. At least not since sometime in the late 80's. -- Grant Edwards grante Yow! Where does it go when at you flush? visi.com From jpowers at acm.org Mon Jul 10 11:44:28 2000 From: jpowers at acm.org (John Powers) Date: Mon, 10 Jul 2000 10:44:28 -0500 Subject: Why does tkinter app crash on quit? Message-ID: <3969EF5C.EB7B14A4@acm.org> I have a python program which crashes every once in a while when I press the "Quit" button. I'm running tkinter 1.127 and tcl/tk 8.0.5 under Windows 95 and Python 1.5.2. Most of the time, it quits just fine. But sometimes, it crashes: "Python - This program has performed an illegal operation and will be shut down. PYTHON caused an invalid page fault in module SYNTPFCS.DLL at 0157:630067db. from Tkinter import * class App(Tk): def __init__(self): Tk.__init__(self) filename = "filename" Label(self, text=filename).pack() Button(self, text="Quit", command=self.quit).pack() App().mainloop() Anybody had experience with this? Thanks, jpp -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcbray at carcosa.net Mon Jul 3 23:44:53 2000 From: jmcbray at carcosa.net (Jason F. McBrayer) Date: 03 Jul 2000 23:44:53 -0400 Subject: Random number generation, simple question. References: <8jqjf8$s1t$1@nnrp1.deja.com> Message-ID: >>>>> "j" == jhylton writes: j> In article , j> Kalle Svensson wrote: >> I have a few questions about the (pseudo) random number generator >> supplied in the standard library. I need 80 random bits (for a >> CipherSaber IV) but I hear most RNG's only supply 32 bits or less. j> The random number generator in the standard library is not at all j> suitable for generating a cipher key. He's not using it to generate a cipher key, just an initialization vector that doesn't have to be too terribly random (its only purpose is to let you reuse the same real key in different messages). As I understand it (and according to the Cypersabre pages), you don't need anything better than the standard library's rng (though it's just as easy, if not easier, to read 10 bytes from /dev/random). -- +-----------------------------------------------------------+ | Jason F. McBrayer jmcbray at carcosa.net | | A flower falls, even though we love it; and a weed grows, | | even though we do not love it. -- Dogen | From cut_me_out at hotmail.com Wed Jul 12 13:45:15 2000 From: cut_me_out at hotmail.com (Alex) Date: 12 Jul 2000 13:45:15 -0400 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> Message-ID: > Is it legal (it seems to work) to change the class of an object by > assigning to its __class__ attribute? I guess if you can do it, it's legal. On-the-run-from-the-python-coding-standards-police-myself'ly yr's Alex. From kpmurphy at my-deja.com Tue Jul 25 10:37:59 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Tue, 25 Jul 2000 14:37:59 GMT Subject: let my widgets use pack/grid/place Message-ID: <8lk8o7$lm8$1@nnrp1.deja.com> how do i let widgets i've created use pack/grid/place? i.e. ... mywidget('schweet') mywidget.pack() ... thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Tue Jul 18 15:24:30 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 14:24:30 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> <39739291.4155A128@prescod.net> Message-ID: <3974AEEE.D3F9D936@prescod.net> John Lull wrote: > > > By that reasoning, cryptography ought not be part of the standard > distribution, either. Nor should complex numbers. We aren't talking about the standard distribution. We're talking about the language syntax. If many matrix-people wanted matrices in the standard library, it would probably be there. Cryptography required no new syntax and complex numbers required very little. There is already more syntax in the core language for matrices than for complex numbers. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From kpmurphy at my-deja.com Mon Jul 10 17:14:07 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 10 Jul 2000 21:14:07 GMT Subject: clipboard References: <8kddiq$8oc$1@nnrp1.deja.com> Message-ID: <8kdeae$9fv$1@nnrp1.deja.com> In article <8kddiq$8oc$1 at nnrp1.deja.com>, Keith Murphy wrote: > how do you read from / write to the system clipboard from Tkinter? i'm > on a unix machine, if that matters. Thanks, > > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > i've found out that... >>> root.clipboard_clear() >>> root.clipboard_append('python rules!') ... places text on the system clipboard, but how do you paste? thanks... -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com Sat Jul 22 15:43:48 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 22 Jul 2000 13:43:48 -0600 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <8F7985804milenkomoonshinecouk@194.73.73.116> Message-ID: <3979F974.A0EBC279@roguewave.com> Jack wrote: > > >5 gets you 7 that you have added a > > > >from os import * > > > >to your script. > > > >Don't do that. > > > > Thats exactly right, and is there any way i can access the os library then > without everything going mad-whack. Well, the point was that you were accessing the os library, in particular the open function you are acessing is os.open which is different from __builtin__.open which is probably what you wanted. What you really want to do is: import os print os.getcwd() os.removedirs('/') f = open('foo.bar') # calls the global/__builtin__ open etc. From bdupire at seatech.fau.edu Wed Jul 12 10:25:36 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Wed, 12 Jul 2000 10:25:36 -0400 Subject: what is a .pyo file? References: Message-ID: <396C7FE0.35C06DD3@seatech.fau.edu> Yes! .pyo files contain stripped of line numbers, assertions, and other debugging information. Therefore they run slightly faster. Benoit. Kalle Svensson wrote: > On 23 Jun 2000, Venkatesh Prasad Ranganath wrote: > > > what are the contents of .pyo file? When is it generated? What is it used for? > > It's optimized byte code, generated by importing a module or using > py_compile.compile() in a python process run with the -O command line > option. The advantages of the .pyo over the .pyc file is just that it's > optimized and thus runs faster. I guess... :) > > HTH, > Kalle Svensson From gee308 at mediaone.net Tue Jul 18 01:18:50 2000 From: gee308 at mediaone.net (Toy) Date: Tue, 18 Jul 2000 05:18:50 GMT Subject: newb question Message-ID: <3973EE1B.15B0B32E@mediaone.net> what is a simple way I can save variables that people enter in from 'raw_input' ? That way, someone enters the variables they want, then when the script is booted up everytime the machine starts, it will grab the variables from somewhere. Thanks. Jason Toy toyboy at toy.eyep.net From hei at adtranzsig.de Thu Jul 27 07:43:57 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 27 Jul 2000 13:43:57 +0200 Subject: Tokenize.py for C++? References: <8ljjj2$803$1@desig-bs01-s04.adtranzsig.de> <397FC2F2.1B377A86@see.my.signature> Message-ID: <8lp7e8$glf$1@desig-bs01-s04.adtranzsig.de> Thanks very much, i'll give it a try! -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Greg Ewing" schrieb im Newsbeitrag news:397FC2F2.1B377A86 at see.my.signature... > If you want to roll your own scanner, you might > find my Plex module useful: > > http://www.cosc.canterbury.ac.nz/~greg/python/Plex From michael at stroeder.com Mon Jul 24 03:07:32 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 24 Jul 2000 09:07:32 +0200 Subject: crypto modules in python References: <397B8440.C1DD25C9@mindspringdot.com> Message-ID: <397BEB34.C00A2C9E@stroeder.com> anupam wrote: > > can someone please point me to link(s) to python modules dealing with > cryptography e.g ssleay or open ssl wrappers. http://www.post1.com/home/ngps/m2/ (Could be easily found with DejaNews.) Ciao, Michael. From erik at pacific-shores.com Tue Jul 18 15:59:17 2000 From: erik at pacific-shores.com (Erik Myllymaki) Date: Tue, 18 Jul 2000 19:59:17 GMT Subject: cgi to send PDF file to browser? Message-ID: Hello, I am looking for some advice on how to send a PDF file to a client browser from a cgi script. I could just show a listing of the directory where the PDF files are located and have the client select the right one, but for various reasons I would like to just ship it out transparently. I have looked briefly at BaseHTTPServer, and I think this is where my answer lies??? Thanks in advance. -- Erik Myllymaki erik at pacific-shores.com From see at below Mon Jul 31 10:01:05 2000 From: see at below (Paul Foley) Date: 01 Aug 2000 02:01:05 +1200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <8lla9m$hfd$1@animus.fel.iae.nl> <8luhsp51ce8@news2.newsguy.com> <8m3huk025kf@news1.newsguy.com> Message-ID: On Mon, 31 Jul 2000 11:43:14 +0200, Alex Martelli wrote: >> >> FLAG = bitwise.or(FLAG1, FLAG2, FLAG3, FLAG4, FLAG5, FLAG6, FLAG7, > FLAG8) >> > >> >What an EXCELLENT idea. shift left/right could also be packaged that >> >way (or, almost so; 'or' is a reserved words in Python...). > And I like your solution of finessing this via names bitor, bitand, etc. > This > also makes it sensible to 'from bitwise import *' in a module that does > heavy bitwise processing. Yes, but how about renaming them logior()/logxor()/logand()/etc., and ash() for "arithmetic shift"... >> >The 'bitwise' module could supply easily explicit bitfield-extraction >> >in place of the mask-and-shift idioms, too. Define a byte(x, y) function to define an object representing an x-bit byte offset y bits into an integer (using "byte" in the older sense, not necessarily meaning 8 bits) and a pair of functions, ldb() to "load byte"s from an integer, and dpb() to "deposit byte"s into an integer > to supply a C implementation of course (cBitfield perhaps?). No way to > take away | & << >> ~ until Python 3000, of course, but, yes, surely when > 3000's time comes life will be easier if bitwise is the popular way to do > things and the linenoise alternative an old/legacy/deprecated one:-). And why not carry this process to its logical conclusion and replace a+b with +(a, b), a*b with *(a, b), etc., too. You can save a little typing by dropping the commas and writing (+ a b), (* a b), (logior a b), (ldb (byte 8 16) x), etc. :-)) -- Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. (setq reply-to (concatenate 'string "Paul Foley " "")) From fiona at sitegnome.com Sat Jul 15 10:42:21 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 15 Jul 2000 14:42:21 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 15th, 2000 Message-ID: <20000715144221.9296.qmail@synop.com> Hello List, Only a couple of entries into http://python.faqts.com today. regards, Fiona Czuczman Including : - Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class - Where can I find a DB-API connection to Sybase? - How can I call an .exe file from inside a .py file? - How can you check on the status of a file's "archive" bit, on DOS-type platforms ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class http://www.faqts.com/knowledge-base/view.phtml/aid/4734 ------------------------------------------------------------- Nils Otto Johansen ## New Entries ################################################# ------------------------------------------------------------- Where can I find a DB-API connection to Sybase? http://www.faqts.com/knowledge-base/view.phtml/aid/4753 ------------------------------------------------------------- Fiona Czuczman Paul Boddie The 'ctsybasemodule' apparently resides at the following URL: http://starship.python.net/crew/pgodman/ Whilst 'ctsybasemodule' is rather nice, I found it insufficient for my purposes (no "bind variables" in SQL statements) and decided on mxODBC instead: http://starship.python.net/crew/lemburg/mxODBC.html If you decide to pursue that option, I would suggest looking at my ODBC resources page: http://www.crosswinds.net/~pboddie/Python/mxODBC.html I managed to get mxODBC working with Adaptive Server Anywhere and Adaptive Server Enterprise, but with the recent announcement of zxJDBC you could use JPython and Sybase's jConnect software instead: http://www.ziclix.com/zxjdbc/ http://www.jpython.org http://www.sybase.com/products/internet/jconnect/ ------------------------------------------------------------- How can I call an .exe file from inside a .py file? http://www.faqts.com/knowledge-base/view.phtml/aid/4757 ------------------------------------------------------------- Fiona Czuczman Alex Shindich, Gregoire Welraeds Try this: import os os.execl ('foo.exe') For more info read http://www.python.org/doc/current/lib/os-process.html execl is kind of an alias for execv. So using this solution, be aware of the following: execv (path, args) Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows. This mean that if you have the following code in a file: import os os.execv("/bin/ls",("ls","/")) print "Done!" The last line will never be executed because the python process is replaced by the /bin/ls command. To avoid this, Unix allows you to use the fork system call : import os i= os.fork() if i != 0: os.waitpid(i,0) # wait for the child to complete. print done! else: # child process os.execv("/bin/ls",("ls","/")) Another and easier solution, which also works under Windows : import os os.system("foo.exe") print 'Done!' ## Edited Entries ############################################## ------------------------------------------------------------- How can you check on the status of a file's "archive" bit, on DOS-type platforms http://www.faqts.com/knowledge-base/view.phtml/aid/4706 ------------------------------------------------------------- Barry Pederson, Fiona Czuczman http://www.python.org/windows/win32all/,Alex Martelli On Win32, with Hammond's extensions: PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au) >>> from win32file import GetFileAttributes >>> GetFileAttributes("C:/witha.txt") 32 >>> GetFileAttributes("C:/withouta.txt") 128 >>> where witha.txt does have the A attribute and withouta.txt lacks it. You can also use symbolic names for the constants: >>> import win32file >>> win32file.FILE_ATTRIBUTE_ARCHIVE 32 >>> win32file.FILE_ATTRIBUTE_NORMAL 128 >>> Note that the 'normal' bits seems to be set if and only if no other bits are set. Other attributes in the bitmask behave more normally, i.e., they are bitwise-or'ed to give all attributes of the file. For example, after making witha.txt read-only (still _with_ the A attribute as well), we have: >>> GetFileAttributes("C:/witha.txt") 33 >>> win32file.FILE_ATTRIBUTE_READONLY 1 >>> I.e., the attributes of the file are the bitwise-or of archive and readonly. So, if you only want to test for archive, and don't care about the others, you'll bitwise-and GetFileAttributes' result with FILE_ATTRIBUTE_ARCHIVE, rather than testing for equality! From aahz at netcom.com.bbs Sun Jul 16 23:00:11 2000 From: aahz at netcom.com.bbs (aahz at netcom.com.bbs) Date: 17 Jul 2000 03:00:11 GMT Subject: Funding vs Python Message-ID: <3bQj9B$mbp@openbazaar.net> In article <8kt4rj$d4n$1 at nnrp1.deja.com>, Andy Freeman wrote: > >No good deed goes unpunished, so now I'm getting push back along the >lines of "we can't get funded if it's in Python". (Somehow, I don't >think that using Perl would have produced the same reaction.) > >I've seen the list of web projects at python.org, so I'm wondering >if there are others or if there really are examples of companies that >didn't get funded because they used Python. I don't know of any companies that didn't get funded due to use of Python, but there are plenty of funded companies that *do* use Python. (E.g., my company, http://www.searchbutton.com/) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From scorder at incigna.com Wed Jul 5 15:22:59 2000 From: scorder at incigna.com (Sam Corder) Date: Wed, 5 Jul 2000 15:22:59 -0400 Subject: Ado stored procs with parameters Message-ID: I'm having a bit of trouble using a stored proc on MSSQL that takes parameters. I create a command object and then append the parameters to it. Then I create a recordset object and use the open method passing the command object and a few other parameters. Unfortunately I get an error saying that the stored proc requires The same parameter that I just added. Below is the code I'm using. Any ideas? Sam Corder import win32com.client constants = win32com.client.constants class dbcon: def __init__ (self, connect = None): self.connectstr = connect def runSQLReturnRS(self, sql, params = None): if self.connectstr == None: return None else: rs = win32com.client.Dispatch('ADODB.Recordset') cmd = win32com.client.Dispatch('ADODB.Command') cmd.ActiveConnection = self.connectstr cmd.CommandText = sql if params != None: for parm in params: cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], constants.adParamInput, parm[2], parm[3])) rs.Open(cmd, CursorType = constants.adOpenForwardOnly, LockType = constants.adLockReadOnly) return rs def __AddParams(self, cmd, params): for parm in params: cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], constants.adParamInput, parm[2], parm[3])) if __name__ == '__main__': db = dbcon("Provider=SQLOLEDB;Data Source=s-incigna2k;User Id=msl_login;Password=***;Connect Timeout=5;network library=dbmssocn;Initial Catalog=msl;") params = ("ExpJobID", constants.adInteger, 4, 11), rs = db.runSQLReturnRS("ExpConfig_Get", params) print rs.Fields.Count From tim_one at email.msn.com Sun Jul 23 21:43:43 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 23 Jul 2000 21:43:43 -0400 Subject: iterating over lines in a file In-Reply-To: Message-ID: [Cliff Crawford] > No, what I meant was that I thought readlines() always reads the entire > file, whether you specify a size argument or not, and so if you were > worried about "for line in file.readlines():" eating too much memory, > you could just do "for line in file.readlines(8192):" instead, and it > would read the entire file using only an 8k buffer. At least, that's > what I thought the library reference was saying..but the source code > proved me wrong :) Ah. It *is* normally used to read the entire file, but with another level of loop: while 1: # read next batch of lines lines = file.readlines(8192) # or larger for more speed if not lines: break for line in lines: process(line) > I do agree, though, that the current behavior of readlines() is quite > useful for it's >intended< purpose ;) Well, the "hint" argument is there to let you turn yourself into a compiler . From scarblac-spamtrap at pino.selwerd.nl Mon Jul 31 09:36:14 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 31 Jul 2000 13:36:14 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: Steve Lamb wrote in comp.lang.python: > foo = 1 > foo = list(foo) > > Error. Single element sequence. 1 is not a single element sequence, because it has no elements: 1[0] gives an error. "1" is a sequence, and its first element, "1"[0], is "1". It's really quite simple. The list() function takes any sequence and produces a list with the same elements as the sequence. Constructing a list from zero or more values is done with the [ ] "operator": to make a list out of the integer 1, that is the list with one element of value 1, you use [1]. > Remember, any sequence can either be a > single value or a sequence. Yet here we have a single value denied. Quirks > abound. Sequences can be seen as a single value or as a sequence of values. But that doesn't imply that any single value can be seen as a sequence. Simple logic. -- Remco Gerlich, scarblac at pino.selwerd.nl "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From ejr at lotus.CS.Berkeley.EDU Sun Jul 30 16:00:47 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 30 Jul 2000 20:00:47 GMT Subject: Python plug-ins for Adobe Products available References: <8m06l3$8s4$1@agate.berkeley.edu> Message-ID: <8m21hf$bmt$1@agate.berkeley.edu> And Grant Munsey writes: - - Thanks for the compliment ... it wasn't exactly easy to convince Adobe - that they should have an open source site. I'm hoping it will grow as time - goes on. Thank you for working with them. Adobe's never been terribly easy to work with, ime, so your effort is greatly appreciated. I still think they could make a good deal of money selling Framemaker, etc. even if they were free software (especially by bundling fonts), but... And then there are the patent issues in the graphics software. sigh... - This might be useful for someone who finds SWIGs allowable parameter - types a bit to restrictive. Are you aware of cxx.sourceforge.net? It's a very nice package to help integrate C++ and Python. I'm not sure if it applies directly, but it may be worth a look. - I said the license is liberal because I'm happy it turned out that way ... The license is very nice indeed. I'm shocked Adobe did something like that. - I wrote the plug-ins for the Adobe products because I wanted them. That's perfectly fair. I just wanted people to know that there are free alternatives that could use the help. Sketch is particularly interesting; it's written in Python. So you not only get the benefits of working in a nice language, you also get the benefits of working with free software. - What really worries me is the wrangling over the Python license ... Yes, that bothers me, too. I don't want to have to think about the license, and the current one allows that. Jason From jhe at webde-ag.de.bbs Tue Jul 18 04:20:06 2000 From: jhe at webde-ag.de.bbs (jhe at webde-ag.de.bbs) Date: 18 Jul 2000 08:20:06 GMT Subject: Getting local IP address... Message-ID: <3bRh16$kmS@openbazaar.net> "Tony Johnson" schrieb im Newsbeitrag news:01BFEFF9.AE1E26D0.gjohnson at gs.verio.net... > Yes I understand that os.system is to be used with extreme caution. The > ifconfig eth0 command does nothing but query information already stored and ... > I don't see any probs... > ifconfig bash: ifconfig: command not found Falls into my definition of "probs". :> On many machines, /sbin is not in the path of normal users, and on many machines, it's not called "/sbin". :) Bye, J?rgen From shapr at uab.edu Wed Jul 19 08:17:06 2000 From: shapr at uab.edu (Shae Erisson) Date: Wed, 19 Jul 2000 12:17:06 GMT Subject: Python et Question sur Linux References: <8l43gh$j3u$1@broadway.news.is-europe.net> Message-ID: <39759F47.3CC7423A@uab.edu> J?r?me Lecomte wrote: Bonjour, > J'ai commenc? ? regarder Python. Ca a l'air vraiment bien (plus facile > et plus clair que Perl et mieux int?gr? avec le reste du monde que > tout ce que j'ai vu jusqu'a pr?sent). Tu connais ? Je suis d'accord. Pour moi, Python est toujours mieux que Perl :) > Mon fr?re envisage d'installer Linux sur son PC (266Mhz) pour > programmer. Il faut compter combien de DD pour ?tre confortable. 500Mo > peut faire l'affaire, ou il faut 1Go min. Linux n?cessite plus que 300Mo pour ?tre confortable. Mais si tu veux utiliser Xwindow, 500Mo ou 700Mo est mieux. J'ai presque tout de Debian Linux sur mon PC, et ?a prend 3Go de DD. -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From timr at probo.com Sun Jul 9 00:19:38 2000 From: timr at probo.com (Tim Roberts) Date: Sat, 08 Jul 2000 21:19:38 -0700 Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> <87zonvso9c.fsf@cachemir.echo-net.net> Message-ID: <71vfmsc0sspvpg3mq8k3s1ri653908u9nk@4ax.com> Roland Mas wrote: >Curtis Jensen (2000-07-05 17:13:13 -0700) : > >> What is the difference between Py_Apache and mod_python? > >There's mod_snake too, just to add to the confusion. I'll say. Am I correct in understanding that the basic purpose of "mod_snake" is to allow me to write other Apache modules in Python, while PyApache is a module which lets me run Python CGI scripts without launching a separate interpreter, just like mod_perl? I tried to get interested in PHP, but the more I read, the more it seemed to be a confused mishmash of features gathered from other places. I thought it might be nice to be able to write web pages that were mostly HTML, with server-side scripts interspersed, but it seems that many PHP pages are written like CGI scripts that happen to run inside Apache. As long as I'm going to do that, I'd rather use Python. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ge at nowhere.none Fri Jul 28 10:03:00 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 14:03:00 GMT Subject: Perl is worse! (was: Python is Wierd!) References: Message-ID: In article , Moshe Zadka wrote: >On Fri, 28 Jul 2000, Grant Edwards wrote: > >> >list() (and tuple()) only work on objects that actually have a >> >sequence mapping makes a lot of sense and, to me, resolves the >> >ambiguity in precisely the way I would expect. > >> Is 'sequence mapping' for list() an tuple() defined the same as >> for the 'for' statement: it has a get_item(i) method that >> returns either a value or raises an exception? > >Actually, I think these two want an __len__ method too. At this point somebody is required to complain about the vagueness of Python interfaces, and if there was some sort of language facility for defining the interface for a "sequence" then I wouldn't have had to ask that question. Since it's Friday, and the person assigned to the task of complaining about interfaces is off today, I've filled in temporarily. But I'm goign golfing at noon, so if you want to argue about it you'll have to make an appointment with the regular staff on Monday. Since I'm just filling in, all I'd be able to provide is rote contridiction -- which we all know isn't a real argument... -- Grant Edwards grante Yow! HUGH BEAUMONT died at in 1982!! visi.com From michael at stroeder.com Thu Jul 20 02:16:37 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 20 Jul 2000 08:16:37 +0200 Subject: HTTPS support? References: <20000719161558.A1809@freei.com> Message-ID: <39769945.6CB82A3B@stroeder.com> Sean Blakey wrote: > > Are there any current SSL libraries for Python? M2Crypto found on http://www.post1.com/home/ngps/m2/ Ciao, Michael. From a.kupries at westend.com Fri Jul 28 17:12:44 2000 From: a.kupries at westend.com (Andreas Kupries) Date: 28 Jul 2000 23:12:44 +0200 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> Message-ID: Dan Kuchler writes: > Cameron Laird wrote: > > > > is the most pro- > > vocative summary I've yet seen of Larry Wall's talk at the O'Reilly > > Open Source Convention. Mark-Jason Dominus's typically masterful > > provides technical > > details. I think at least the first of these will reward a quick > > read by everyone involved in planning the futures of, for example, > > Python and Tcl. I applaud Conrad Schneiker for his care in prepar- > > ing this. > More interesting to me (and perhaps more interesting to some here in > the comunity) are the notes from the initial brainstorming session > on July 17th about what Perl 6 will be (what are the reasons for > making it, what features might be added, etc.) > http://www.perl.org/perl6/pr/initial_meeting.html > > Lots if interesting little tidbits in here. > > They talk of adding stacked IO channels "a l a Tcl" Gee. How nice :) Well, there are some other things on these pages which catched my eye as well beyond stacked channels, both technically and socially. Lets see: > Syntax separation - multiple syntaxes ? > Perl6 offers the possibility to ... write Perl programs in multiple > syntaxes such as Python, JavaScript, and Perl5 ... This reminds me of Guile, which tried to do the same thing, no ? Universal lisp engine below, multiple formats for programming it above. Here just with the perl engine below. A try to unify interpreters ? See also Jean-Claude's Minotaur, using a forth engine below and beside interpreters for several scripting languages to allow them to use each other (and their extensions) hither and fro. With the long-term goal to make each interpreter a set of routines above the universal forth engine below. Hm. > Perl is too big for one person to manage, and the pumpkings burn out > to quickly. The new model will probably be several separate working > groups, each charged with the design and implementation of one > aspect of perl. This reminds me strongly of Python SIGs and one of the adjunct proposals to the TCT made here on c.l.t, i.e. grouping several other teams around the TCT. It is interesting to see that all the major scripting languages go into very similar directions in their development models. > Larry said that the Porters were thinking about ... an RFC-like > mechanism. This is something Matt Newman argued eloquently for and for some time now. The Pythoneers (Pioneers?) have set such a structure up already, not very long ago, the Python Enhancement Proposals (PEP), see http://python.sourceforge.net/peps/ for the first set. -- Sincerely, Andreas Kupries ------------------------------------------------------------------------------- From fiona at sitegnome.com.bbs Fri Jul 14 00:10:02 2000 From: fiona at sitegnome.com.bbs (fiona at sitegnome.com.bbs) Date: 14 Jul 2000 04:10:02 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 14th, 2000 Message-ID: <3bOUOQ$mPq@openbazaar.net> Hello! Once again another collection of entries into http://python.faqts.com Cheers, Fiona ## New Entries ################################################# ------------------------------------------------------------- How do I import a file that isn't in the pythonpath? http://www.faqts.com/knowledge-base/view.phtml/aid/4719 ------------------------------------------------------------- Fiona Czuczman Mike 'Cat' Perkonigg The easiest way is to put '.' in your PYTHONPATH. But you can extend your path with any directory in your python code with: >>>import sys >>>sys.path.append (path-to-load-modules-from) ------------------------------------------------------------- Is there a Python module that would allow me to easily parse and format vCards? http://www.faqts.com/knowledge-base/view.phtml/aid/4720 ------------------------------------------------------------- Fiona Czuczman Henning Schroeder The new WorldPilot 1.1alpha contains such a module (file vCard.py) ftp://demo.worldpilot.com/pub wppocket-1.1.0alpha2.tgz (see wppocket-1.1.0alpha2.tgz) ------------------------------------------------------------- Is there anybody who has worked on wbmp converter image from any other format in Python? If yes, where can I find it? http://www.faqts.com/knowledge-base/view.phtml/aid/4721 ------------------------------------------------------------- Fiona Czuczman Duncan Booth Try http://www.rcp.co.uk/distributed/Downloads The file wbmpconv.zip (1192k) is a command line convertor to/from wbmp format (Win32 binary). Alternatively, wbmpconvsrc.zip (8k) contains the python sources. The source version requires that you have Python and PIL installed on your machine, the binary is completely self contained but a bit large as it needs to include the Python and Tk dlls. Obviously the source version lets you convert to/from any image formats supported by PIL, the win32 binary supports: ARG BMP* CUR DCX EPS* FLI FPX GBR GIF* ICO IM* IMT IPTC JPEG* MCIDAS MIC MPEG MSP* PCD PCX* PIXAR PNG* PPM* PSD SGI SUN TGA TIFF* WBMP* WMF XBM* XPM XVTHUMB (the ones with a * may be read or written, the other formats may only be read). ------------------------------------------------------------- What is UnboundLocalError for? http://www.faqts.com/knowledge-base/view.phtml/aid/4722 ------------------------------------------------------------- Fiona Czuczman Tim Peters When a local name is referenced but has not been bound to a value. In other words, it's an unbound local error . Note that UnboundLocalError is a subclass of NameError, because it's a more specific form of NameError, so old code expecting to catch NameError exceptions will still catch UnboundLocalError exceptions. In 1.5.2 and before, NameError was thrown regardless of whether the offending name was local or global. So UnboundLocalError gives more information. > I encountered it when I made a mistake like this: > > >>> f() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1, in f > UnboundLocalError: l > >>> So your function f (which you have not shown us) refers to a local name "l" which you didn't give a value before referencing it. It's impossible for us to guess what you put in the body of f; here's one possibility: >>> def f(): ... l = l + 1 # local "l" referenced on the right before definition ... return l ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in f UnboundLocalError: l >>> ## Edited Entries ############################################## ------------------------------------------------------------- What is wxPython? How does it compare with Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/3565 ------------------------------------------------------------- Fiona Czuczman, Olivier Dagenais Shae Erisson,http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpother wxPython [ http://www.wxpython.org ] is a set of Python bindings for the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was written as a C++ library to provide a platform-independant way of implementing rich and fast user interfaces. ----------------------------------------------------- I chose wxPython over Tkinter (for my projects) because: - wxWindows seems to have more widgets than Tk - special widgets (like the TreeView) are implemented using the operating system's native implementations, not complete re-writes - it's more than a "lowest common denominator" among platforms, wxWindows seeks to provide the same, advanced functionality on all platforms, even if it means they have to write a lot of code to complement a platform's native component - wxWindows seems to cover more ground, in terms of functionality (it's more than a GUI toolkit, it also seeks to provide functions/classes for files, threads, printing, clipboard, networking, ODBC, etc...) - I was *really* impressed with the wxPython demo ----------------------------------------------------- The wxWindows documentation emphasizes the "less good" points of other GUI toolkits (namely Tkinter) to motivate wxPython: http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpothe r ------------------------------------------------------------- Should __getattr__ increment the reference count before it returns the appropriate attribute, or not? writing a Python module in C http://www.faqts.com/knowledge-base/view.phtml/aid/2907 ------------------------------------------------------------- Fiona Czuczman Gordon McMillan It should incref the attribute and leave the owner alone. Imagine a sequence like this: newref = a.b # here's your __getattr__ a = None Now a's refcount drops. If it drops to 0, it gets deallocated, which will decref b. Without an incref in __getattr__, the user would have an invalid reference. ------------------------------------------------------------- How do I check to see if a file exists? http://www.faqts.com/knowledge-base/view.phtml/aid/2782 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh,Peter Schneider-Kamp To check if a file exists use: >>> import os.path >>> os.path.exists("python/") 1 >>> os.path.exists("spam/") 0 >>> os.path.exists("python/patches/submitted/array.pop-extend.patch") 1 If you only want a true for regular files have a look at isfile(): >>> os.path.isfile("python/") 0 >>> os.path.isfile("spam/") 0 >>> os.path.isfile("python/patches/submitted/array.pop-extend.patch") for more info or other function look at: http://python.org/doc/current/lib/module-os.path.html From mhaselup at clicktomarket.com.bbs Sun Jul 16 18:20:02 2000 From: mhaselup at clicktomarket.com.bbs (mhaselup at clicktomarket.com.bbs) Date: 16 Jul 2000 22:20:02 GMT Subject: Application testing Message-ID: <3bQbh2$jmC@openbazaar.net> I need to carry out some testing of a cgi application from a Browser client. I have been informed that I can use Python (or some of it's extensions) to capture and replay the http traffic between the Browser and the Webserver to simulate a user session. Unfortunately I've not been able to find any information on this usage in the books I've looked at so far. I am also interested in any other applications free or otherwise which would allow me to do this. I would like to be able to capture the traffic and edit it to allow modified replays of sessions. Can anbody help with this? Should I be looking at other news groups for these features? Thanks. From mwh21 at cam.ac.uk Fri Jul 21 02:54:02 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Jul 2000 07:54:02 +0100 Subject: process id from os.system References: <3977482B.478D2754@sec.noaa.gov> Message-ID: j vickroy writes: > How can I obtain the process id for a program launched via > > os.system (theProgram) ? > > I would like to do this portability (Unix, Windows). > > Presently on Unix, I'm getting the pid by parsing the output from: > > "ps -ef | grep theProgram" > > but that seems messy and unreliable since "theProgram" may be truncated > in the output from ps. I think you should be able to use the os.spawn* functions in 1.6^H^H^H2.0 for this, eg: >>> os.spawnlp(os.P_NOWAIT,"xterm","xterm") 4722 the spawn* functions are easy-ish to implement in terms of exec* & fork; look here: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/Lib/os.py?rev=1.35&content-type=text/x-cvsweb-markup&cvsroot=python HTH, Michael -- 8. A programming language is low level when its programs require attention to the irrelevant. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From thomas at xs4all.net Tue Jul 18 04:51:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 18 Jul 2000 10:51:48 +0200 Subject: Wherefore art thou, 1.6? In-Reply-To: <3973D9DB.9E141287@prescod.net>; from paul@prescod.net on Mon, Jul 17, 2000 at 11:15:23PM -0500 References: <3973D0A1.5E1289D9@concentric.net> <3973D9DB.9E141287@prescod.net> Message-ID: <20000718105147.W7340@xs4all.nl> On Mon, Jul 17, 2000 at 11:15:23PM -0500, Paul Prescod wrote: > Manus Hand wrote: > > Can someone please post a status on 1.6? > Here's part of the story: > http://www.pythonlabs.com/news_sitelaunch.html > And the next part: > http://www.pythonlabs.com/tech/python2.html > And some more: > http://www.python.org/pipermail/python-dev/2000-July/011960.html > http://www.python.org/pipermail/python-dev/2000-July/012574.html > No news since. Well, not really. There was: http://www.python.org/pipermail/python-dev/2000-July/012485.html and the follow-ups (in particular: http://www.python.org/pipermail/python-dev/2000-July/012489.html which isn't an official statement, and a comforting one at that! :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From buzzard at urubu.freeserve.co.uk Thu Jul 20 18:47:47 2000 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Thu, 20 Jul 2000 23:47:47 +0100 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> Message-ID: <8l7vlm$r63$1@news6.svr.pol.co.uk> I am using PythonWin. I do try to close the file with outputfile.close() after the second 'if'. I don't understand why it apparently doesn't work. ie. I want to open a file and write to it on the first iteration (which it does), write to it on subsequent iterations (which it does), and close it after a certain number of iterations (which it doesn't). Thanks for your help, but I'm afraid I'm still stuck. From kmp at atrium.fsnet.co.uk Sun Jul 2 16:09:51 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Sun, 02 Jul 2000 20:09:51 GMT Subject: Problem Installing PyQt-012 Message-ID: <20000702.20095100@linux.local> I'm trying to install the Python bindings to Qt/KDE. I've downloaded the latest sources for Sip. PyQT and pyKDE. I've compiled and installed Sip and compiled PyQT. All seemed to go Ok, though I had to fiddle a bit to get them to compile on Suse 6.3. However, on the "make install" for PyQt, I get an error when the install routine hits a Python script: Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/qt.py", line 16, in ? import libqtc ImportError: /usr/lib/python1.5/lib-dynload/libqtcmodule.so: undefined symbol: __ti8sipProxy make[3]: *** [install-data-hook] Error 1 make[2]: *** [install-data-am] Error 2 make[1]: *** [install-am] Error 2 make: *** [install-recursive] Error 1 I've obviously screwed up in either the configure scripts or there's something not set in my environment. Anyone know what I've done wrong? -- Ken From rmartin at objectmentor.com Tue Jul 11 16:15:01 2000 From: rmartin at objectmentor.com (Robert C. Martin) Date: Tue, 11 Jul 2000 15:15:01 -0500 Subject: Missing OmPyUnit module in OmPyUnit References: <0hk75.10271$HD6.284269@iad-read.news.verio.net> Message-ID: "Doug Fort" wrote in message news:0hk75.10271$HD6.284269 at iad-read.news.verio.net... > We've been using Steve Purcell's PyUnit from SourceForge. It's limited, but > reliable. I'm attempting to investigate OmPyUnit as an alternative. It > seems to offer more functionality, plus I have great respect for > ObjectMentor ands Robert Martin. > > However, the package I downloaded seems to be missing a module: OmPyUnit. > What's up with this? It doesn't fill me with confidence. My Mistake. I accidentally deleted the __init__.py file from the OmPyUnit directory. This file tells python that OmPyUnit is a module. The current release has fixed this, and also has better installation instructions. -- Robert C. Martin | "Uncle Bob" | Training Courses: Object Mentor Inc. | rmartin at objectmentor.com | OOD, Patterns, C++, Java, PO Box 85 | Tel: (800) 338-6716 | Extreme Programming. Grayslake IL 60030 | Fax: (847) 548-6853 | http://www.objectmentor.com "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan From mfletch at tpresence.com Sun Jul 23 00:59:01 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 23 Jul 2000 00:59:01 -0400 Subject: bit manipulation frustration Message-ID: (This is untested (don't have data file), and hacky, but should give ideas for a one-off): input = open('somefile.dat').read() file = [] currentlength = 4 while input: pad = '\000'*( (88-currentlength)/2) line = pad + input[:currentlength] + pad input = input[currentlength:] if len(file) > 21: currenlength = currentlength - 4 else: currenlength = currentlength + 4 Oh, for converting to 16-bit integers (unsigned) import struct def convert( line ): return struct.unpack ( 'H'*(len(line)/2), line ) (That's in machine-native order, use '>'+('H'*...) for network order). HTH, Mike -----Original Message----- From: Courageous [mailto:jkraska1 at san.rr.com] Sent: Saturday, July 22, 2000 11:39 PM To: python-list at python.org Subject: bit manipulation frustration Okay. I'm getting a bit frustrated here. I'm trying to suck bits out of a file (which is in a simple, but non standard image format) and then convert this to a bitmap for wxPython. I haven't gotten to the wxBitmap part yet, which I am assuming will be easy, but the in-between part is driving me nuts. First, in one fell swoop of antigenious, I seem to have forgotten how to convert strings to sequences of char and vice versa. Eeek. Help? Will someone please remind me and hit me with a rubber mallet??? :) Second, this whole paradigm seems so skrewball. While I know exactly how to implement all of this in a external C module, the program I'm writing is just a one off, and I was expecting it to be easier in python. The bitmap image is 16 bit color, but it's stored in byte runs. As I load the image, I need to load 2,4,6, 8...44,42,40...2, 16 bit chunks at a time, but as I'm doing this I have to create "black" runs on either side, making the whole thing 44x44 (it's an isometric tile... a square rotated 45 degrees, but bitmaps are square, get it?) I'm not seeing an elegant solution here; loading the image as a string to begin with isn't right, because my chunks are actually two byte chunks. Anyone with any practical experience on how to *BEST* do this kind of thing? Am I just not thinking about this right? C/ -- http://www.python.org/mailman/listinfo/python-list From lale at fotonation.com Sat Jul 1 09:58:02 2000 From: lale at fotonation.com (Ilariu Raducan) Date: Sat, 1 Jul 2000 14:58:02 +0100 Subject: Uploading binary files References: Message-ID: <8jktda$r10$1@kermit.esat.net> Can we see the HTML code for the form? "Chris Biegay" wrote in message news:Z9475.7$qm5.709 at ord-read.news.verio.net... > I'm trying to upload files through an HTML form, but it only works > for text files. When I try to send a jpeg or something the process just > hangs, and I can't even change the script afterward since the webserver > won't release the file! Any ideas? This is basically how I'm doing it now: > > form = cgi.FieldStorage() > formItem = form[inputName] > > if formItem.file: > print "Received file [" + formItem.filename + "]" > data = formItem.file.read() > ... > > From collins at manhattan.aero.org Mon Jul 10 23:52:44 2000 From: collins at manhattan.aero.org (Jeff Collins) Date: Mon, 10 Jul 2000 20:52:44 -0700 Subject: [ANN] Python port to Palm Pilot In-Reply-To: References: <200007070140.SAA31035@wd264.aero.org> <200007101546.IAA09887@rushe.aero.org> Message-ID: <14698.38478.979087.248189@malibu.aero.org> Will Ware writes: > JEFFERY COLLINS (collins at rushe.aero.org) wrote: > > Download the .zip file instead. Apparently, downloading > > the .prc files using a browser corrupts the files. > > I also ran into a nasty crash that required a cold boot, > inspite of using the .zip file. The file sizes are correct > according to the download web page. Is it possible the last > test just takes such a long time that it ties up the 68k and > only appears to have crashed? The place it stops is "Testing > 3-argument pow() function..." The download problem actually produced a Fatal Error message. I should have warned about the time consumed by the test app and its uninterruptibility. > > Wait, it's moving again! It returned to the main menu. Cool. > > What are the chances of getting a read-eval-print loop > running on the Pilot? While I'd rather write Pilot apps in > Python than some other languages, I'd love to be able to > write Python source right on the Pilot itself. I have a primitive interface, for demo purposes only. Its quite cool to type interactively into the palm and watch the result appear on the screen. I don't plan to release it - it's much to ugly. Instead, I'm looking into adopting a LispMe-like interface. Before any of that happens, more integration with the palm environment will be needed. Jeff From paul at prescod.net Mon Jul 17 17:35:23 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 16:35:23 -0500 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> Message-ID: <39737C1B.802BA6AF@prescod.net> Matthew Cline wrote: > > .... > > That's another reason why I'd like the type checking to be done by the > Python compiler, because it could be intelligent about those things. > Like for "list" it could accept a tuple, a list, or anything derived > from UserList. Most list-like Python objects do not derive from UserList. We could argue whether they should or should not but the point is that your syntactic change would only provide maximum benefit if Python programmers change their programming style. That's why it is not something that can be implemented overnight. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From gee308 at mediaone.net Mon Jul 24 02:12:56 2000 From: gee308 at mediaone.net (Toy) Date: Mon, 24 Jul 2000 06:12:56 GMT Subject: newb Q: security with variables Message-ID: <397BE388.349CCA17@mediaone.net> Could you please explain to me various secure ways of having a python script store variables such as your password/username in a file. I understand that you can chmod 0400 , but are there any other alternatives? Also, can you run python code with files that don't end with the python extensions(.py and others)? That way it would make it less obvious that it was some sort of script. Thanks Jason Toy toyboy at toy.eyep.net http://toy.eyep.net From qtmstr at optonline.net Thu Jul 27 04:06:33 2000 From: qtmstr at optonline.net (QuoteMstr) Date: Thu, 27 Jul 2000 08:06:33 GMT Subject: Find where you left off... References: <397F7BF5.F4A0138D@yahoo.com> Message-ID: In article <397F7BF5.F4A0138D at yahoo.com>, Paul Winkler wrote: >A little trick I discovered today: >when writing python in emacs, you can mark the spot where you >stopped just by writing some arbitrary text like "start from here" >or whatever. Next time you open this file in emacs, just do C-c C-c >; python throws an exception and emacs jumps to the offending line. That's a dangerous practice. Python doesn't catch all such errors when the script executes. If you put the error inside a function that isn't called except under special, rare circumstances, you won't notice until you encounter it. Furthermore, if you forget about an error, it will stay there, as a bug, until someone tries to execute the offending piece of code. -- "I know not with what weapons World War III will be fought, but I know that World War IV will be fought with sticks and stones." -- Einstein From thamelry at vub.ac.be Fri Jul 7 03:46:16 2000 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 7 Jul 2000 07:46:16 GMT Subject: More math on the O'Reilly Network References: <3964CA9B.CBCD5B03@oreilly.com> Message-ID: <8k41s8$a8i$1@snic.vub.ac.be> Stephen R. Figgins wrote: [knips] : I am having fun with these, but I am a closet Math head who signed and : edited these particular articles, so I am probably biased. Anyone care : to give me some feed back on the O'Reilly Network python forum? [knips] Well, it's more an introduction to vector and matrix algebra than a tutorial on Numpy. Most people who take the trouble installing Numpy are quite familiar with this stuff. Cheers, --- Thomas Hamelryck Institute of Molecular and Structural Biology Aarhus University Gustav Wieds Vej 10C DK-8000 Aarhus C Denmark http://zombie.imsb.au.dk/~tham From zo at angband.org Mon Jul 31 20:48:05 2000 From: zo at angband.org (Eric Lorenzo) Date: 31 Jul 2000 20:48:05 -0400 Subject: httplib hung on read References: <8m4m48+g8f4@eGroups.com> Message-ID: <3h3dkpiz7e.fsf@angband.org> ftian at cs.wisc.edu writes: > I am using the httplib to get some webpage, it hungs sometimes > in the following senario, > > http = httplib.HTTP('myhost') > http.putrequest('GET', myurl) > http.putheader(...) > http.endheaders() > > errcode, errmsg, header = http.getreply() > myfile = http.getfile() > # "Still OK here" > page = myfile.read() > # Sometimes Cannot Reach here > > the page can be opened with IE, and it only hungs sometimes. > Anyone know the reason? Thanks. I use httplib heavily in one of my programs, and I found that it would occasionally hang for no apparent reason. Similarly, occasionally I find that some sites occasionally hang when I try to load pages in a browser - I connect okay, but never get any response. I'm assuming that httplib is hanging for the same reason as my browser - except that my browser eventually times out. I handled this in my app by forking off a seperate thread to do the HTTP requests, and have the main thread do a '.join(60)' on the request thread - so that if the request thread hasn't completed in 60 seconds, the main thread will continue, and I'll treat this as a failure to connect. Maybe not the cleanest solution, but it worked okay for my purposes. Eric From BgPorter at NOacmSPAM.org Wed Jul 19 21:24:49 2000 From: BgPorter at NOacmSPAM.org (Brett g Porter) Date: Thu, 20 Jul 2000 01:24:49 GMT Subject: CDDB References: <3976402D.9B957E2F@uniserve.com> Message-ID: See: http://csl.cse.ucsc.edu/~ben/python/ "Bob van der Poel" wrote in message news:3976402D.9B957E2F at uniserve.com... > > Has anyone converted the cddb code which calulates the cddb id and track > timing for a cd from C to python? Looks like it should be possible > without too much work...I was going to try this myself, but figured I'd > ask before I started... > > Thanks. > > -- > __ > / ) / Bob van der Poel > /--< ____/__ bvdpoel at uniserve.com > /___/_(_) /_) http://users.uniserve.com/~bvdpoel > From mwh21 at cam.ac.uk Thu Jul 20 02:54:31 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 20 Jul 2000 07:54:31 +0100 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> Message-ID: Greg Ewing writes: > Paul Prescod wrote: > > > > We're looking just to pair up elements. > > In that case, obviously the solution is to combine this > thread with the one on new operator symbols, and define > an elementwise tuple-creation operator You're joking, right? Cheers, M. -- Indeed, when I design my killer language, the identifiers "foo" and "bar" will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice. -- Tim Peters, 29 Apr 1998 From simon at redcow.flibble.org Thu Jul 20 14:58:59 2000 From: simon at redcow.flibble.org (Simon Oke) Date: 20 Jul 2000 19:58:59 +0100 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> <8l5lne$lb$1@slb0.atl.mindspring.net> Message-ID: <87snt4iq6k.fsf@redcow.flibble.org> scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) writes: > Aahz Maruch wrote in comp.lang.python: > > In article <3976371F.210C2C21 at uab.edu>, Shae Erisson wrote: > > > > > >I already have a function that does this in my handy shaetools module, > > >for me it will always be interleave. > > > > Oh, *that's* a good one. All right, anyone else agree that "interleave" > > is the best suggestion we've had so far? > > For the function that creates [1,2,3,4,5,6] of [1,3,5] and [2,4,6], yes. I believe in INTERCAL this operator is known as 'mingle'. Simon. From bjorn at roguewave.com Sat Jul 22 19:58:00 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 22 Jul 2000 17:58:00 -0600 Subject: Getting method from within method? References: Message-ID: <397A3508.CBA1DB34@roguewave.com> "David M. Cooke" wrote: > > I want to do recursion, like this: > > def factorial(n): > if n <= 1: return 1 > else return n * factorial(n-1) > > However, this depends on the name of the method staying the same. For > instance, if I did this: > > fact = factorial > factorial = None > > fact(5) would give me an error since factorial isn't a method anymore. > It would be nice if there was some way of referring to the method > inside of the method. > > Is there any way of doing this easily? Well, it all depends on what you mean by easy... I would suggest you find a book on your favorite functional programming language and look up the Y combinator. Once you've convinced yourself that's not the way to do it, you won't mind mentioning factorial in it's body anymore is-this-considered-helpful'ly y'rs? -- bjorn From jhylton at my-deja.com Mon Jul 3 13:45:16 2000 From: jhylton at my-deja.com (jhylton at my-deja.com) Date: Mon, 03 Jul 2000 17:45:16 GMT Subject: Random number generation, simple question. References: Message-ID: <8jqjf8$s1t$1@nnrp1.deja.com> In article , Kalle Svensson wrote: > I have a few questions about the (pseudo) random number generator supplied > in the standard library. I need 80 random bits (for a CipherSaber IV) but > I hear most RNG's only supply 32 bits or less. The random number generator in the standard library is not at all suitable for generating a cipher key. In general, cryptography has a crucial requirement for random numbers that most other applications don't: It shouldn't be possible to guess or recover the state of the random number generator. In the case of the random module, if the attacker can guess or recover your inital seed, she can generate the entire sequence of random numbers that you use for your cipher. Bad stuff! I recommend looking at the Yarrow design by Kelsey, Schneier, and Ferguson: http://www.counterpane.com/yarrow.html A Python implementation of Yarrow-160 is included in the Pisces distribution: http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.yarrow.html Jeremy Sent via Deja.com http://www.deja.com/ Before you buy. From dworkin at ccs.neu.edu.bbs Mon Jul 17 21:10:01 2000 From: dworkin at ccs.neu.edu.bbs (dworkin at ccs.neu.edu.bbs) Date: 18 Jul 2000 01:10:01 GMT Subject: Does Python support interfaces? Message-ID: <3bRVdT$kfs@openbazaar.net> Randall Parker writes: > I'm quite new to Python. For those who are familiar with Java interfaces: > Does Python have a similar facility? > > Can one declare interfaces, then declare that a class implements some > interface, instantiate an object of that class type, and then cast it to > an interface that it is declared to support and then pass it around as a > reference to that interface type and make calls to methods of that > interface type? Better yet, Python doesn't make you do all of that work. Just define the class, and make sure that it provides the proper interface. Note that I'm not using "interface" with any special language-dependent meaning here. If it behaves properly, it behaves properly, and that is all that matters. In any case, it sounds like you should read a little more about Python. There generally isn't any explicit type-declaration, and by extension, casting. "Casting" a Python object is not a very meaningful statement. -Justin From nowonder at nowonder.de Mon Jul 31 02:52:20 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 06:52:20 +0000 Subject: [3rd Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> Message-ID: <39852224.FE658DC5@nowonder.de> Thanks for all the feedback on the letter! Guido mentioned that a compromise may be ahead today (Monday): http://www.python.org/pipermail/python-list/2000-July/110928.html I think I should wait for the results of this. But even when such a legal compromise is reached, a clarification about the motives in non-legalese could be worth sending a letter. For now a 3rd draft (based mostly on your feedback): --- begin open letter ------------------------------------------------------- To: Dr. Robert E. Kahn , (president of The Corporation for National Research Initiatives) Dear Mr. Kahn, as a member of the Python community which gathers around the newsgroup comp.lang.python I would like to express my concern about the latest license issues that have arisen around the new 1.6/2.0 releases. The following attached signatures represent people from the Python community who would like some clarification regarding the future of the Python language. As of now, there has been no official statement from your institution regarding the new Python license. We are especially interested in the underlying intention of this change. So we request a plain-English, non-legalese statement regarding the purpose of that change and the ways in which it affects Python's use. Kind regards, Peter Schneider-Kamp --- end open letter ---------------------------------------------------------- --- begin signature list ----------------------------------------------------- Martijn Faassen Jay Graves Konrad Hinsen (Centre de Biophysique Moleculaire (CNRS)) Gareth McCaughan David Mertz (author of a Python column for IBM developerworks) Moshe Zadka (mathematician, Python developer) --- end signature list ------------------------------------------------------- Please add/change/remove your signatures. Feedback as always strongly appreciated. or-should-I-send-the-1st-draft--ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From see at my.signature Wed Jul 5 22:14:18 2000 From: see at my.signature (Greg Ewing) Date: Thu, 06 Jul 2000 14:14:18 +1200 Subject: Two Tkinter questions (long) References: Message-ID: <3963EB7A.609D6BA5@my.signature> Aaron Ginn wrote: > > self.Filter = Button(self.button_frame, text = 'Filter', \ > command = self.do_filter()) You're calling the function there instead of passing it. Get rid of the empty brackets: self.Filter = Button(self.button_frame, text = 'Filter', \ command = self.do_filter) -- 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 paul at prescod.net.bbs Mon Jul 17 14:40:03 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 18:40:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRLW3$kOC@openbazaar.net> Charles Boncelet wrote: > > ... > > Remember, these people spend real money on Matlab. Even the > student edition is about $100. Let me repeat a challenge I made to Huaiyu Zhu. If the only difference between Matlab and Python is the syntax, then let's you and I make a Matlab syntax for Python and sell it at half of Matlab's price. We could make millions on a month's work! After a year or so, we could promote our company as a B2B solution (linear optimization is part of supply chain management, right?) and then we check out as multi-millionaires. My strong feeling is that people don't just use Matlab for the syntax. And the popularity of Matlab books is probably not proportional to the popularity of Matlab. University students are forced to buy those books. Also, I agree with Bjorn. If we try to take on the attributes of every language that is more popular than Python, we'll end up with a mess. > Now to the specifics of the proposal: I'd like to see "@" for matrix > mulitplication and "*" for element-wise multiplication. This preserves > compatibility with numpy, although breaks it with the MatPy package. > It is more important, IMHO, to preserve compatibility with the existing > python numerical facilities than with Matlab. Any user switching over > will have to learn a lot of new things anyway. Distinguishing @ and * > should be easy enough. Why is it that Huaiyu Zhu proposes several operators and you propose only one? A single operator has a MUCH higher chance of being accepted. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From alex at magenta.com Sun Jul 30 09:31:12 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 15:31:12 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: <8m1f0052n4o@news2.newsguy.com> "Grant Edwards" wrote in message news:QPLg5.2816$6E.738549 at ptah.visi.com... > On Sat, 29 Jul 2000 19:52:54 GMT, Suchandra Thapa wrote: > >Alex Martelli wrote: > > >>It matters if you care about how easy/hard it is to turn those > >>"non-programmers" into "programmers in the language you > >>are designing". E.g., the CP4E project, which used to be > >>aimed at turning _everybody_ into programmers, had better > > > Actually I think it would be easier for non-programmers to > >learn a language if it has strict typing. > > I concur. In non-programming, life is strictly typed. Allowed > operations are determined by the type of the object. You can't > make a phone call on a waffle-iron. Were I to _try_ to make a > phone call on a waffle-iron, it doesn't "automagically" convert > istelf into a telephone. Instead, I get a rather interesting > burn pattern on the side of my head. However, there are actions, such as buying and selling, which you can apply to objects (and many non-objects...) uniformly. Marx denounced this specific issue as the "mercification" of reality perpetrated by capitalism, but, while there is a point in this, it's myopic in a wider context -- many other actions (transporting, talking-about, wrecking, ...) are similarly polymorphic in just about any cultural-reality. > You can tune a piano, but you can't tune a fish... But you can tune a program, a car, a radio. Yes, reality IS strongly typed (in the Python way: typing attaches to the underlying objects, not to the labels [words] currently bound to them), but in a 'multiple-inheritance' (multiple-roles, multiple-interfaces) way. Alex From yleteigne1 at cybercable.fr Sun Jul 2 10:06:11 2000 From: yleteigne1 at cybercable.fr (Yannick Le Teigner) Date: Sun, 02 Jul 2000 16:06:11 +0200 Subject: CGI and images Message-ID: <395F4C53.589EAFC0@cybercable.fr> Hi, I want to generate an image - plot and display it via a cgi script. Creating the image is not hard, but I can't print the image on the page. # this doesn't work the browser doesn't diplay errors but no images either... print "Content-type: image/gif\n\n" print open(myImage, "rb").read() Any ideas? Thank you! Yannick From hzhu at localhost.localdomain Sat Jul 15 16:13:20 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Sat, 15 Jul 2000 20:13:20 GMT Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: On Sat, 15 Jul 2000 10:15:38 +0300 (IDT), Moshe Zadka wrote: >> How would you write this in list compresension (in less than 10 lines)? >> >> B*(sin(A*x+b).*(A*y)/3)/C > >B*[sin(a)*b/3; for a,b in transpose([A*x+b, A*y])]/C > Questions: Presumably the [ ... ] is a double list. What does B*[...]/C mean? Maybe you need a cast? The x, b and y are matrices, so presumably 'for a, b in' contains loops around all the indices? Perhaps you meant 'for a, c in'? Do these two b's live in the same scope? What would the error message look like for such errors? How do you write something like B*(A(a.*b).*c).*d? Huaiyu From sabren at manifestation.com Wed Jul 19 18:45:02 2000 From: sabren at manifestation.com (Michal Wallace) Date: Wed, 19 Jul 2000 18:45:02 -0400 (EDT) Subject: zip() : how about braid() Message-ID: I accidentally deleted the list of proposed names for "zip()", so I'm not sure if this was alrady mentioned.. I think merge makes sense, (and I don't really have a problem with zip()), but the metaphor that most closely resembles what it does is braid(), as in hair.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From petersc at stud.ntnu.no Fri Jul 7 17:19:58 2000 From: petersc at stud.ntnu.no (Peter Schneider-Kamp) Date: Fri, 07 Jul 2000 21:19:58 +0000 Subject: Splitting c.l.py... References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> <20000707140442.B4771@kronos.cnri.reston.va.us> <8k579c$rts$1@slb3.atl.mindspring.net> Message-ID: <3966497E.5A149A3B@stud.ntnu.no> Aahz Maruch wrote: > > Note that it should be simple to set up public read-only subscriptions > to python-dev; if it isn't simple, that's a bug in Mailman. ;-) I'd really love that. how-do-you-get-invited-anyway?-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From plusk at runet.edu Sat Jul 1 22:52:40 2000 From: plusk at runet.edu (Paul D. Lusk) Date: 2 Jul 2000 02:52:40 GMT Subject: ? WinNT sys.stdout and re-direction References: <8F6466ABEpluskrunetedu@137.45.128.146> <8F649A89Cgmcmhypernetcom@199.171.54.154> Message-ID: <8F64E8ADDpluskrunetedu@137.45.128.146> gmcm at hypernet.com (Gordon McMillan) wrote in <8F649A89Cgmcmhypernetcom at 199.171.54.154>: >Paul D. Lusk wrote: > >>At the NT command prompt: >> >>script.py in.txt>out.txt >> >>gives me a empty out.txt >> >>Could somebody point me in the right direction to fix this? > >Your choices: > 1) Upgrade to Win2k (hee hee) This does strike me as overkill. > 2) say "python script.py in.txt >out.txt" > Can do. Thanks! Paul From gmcm at hypernet.com Sat Jul 15 14:31:43 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 Jul 2000 18:31:43 GMT Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> <396F4473.35DCA488@prescod.net> Message-ID: <8F729880Egmcmhypernetcom@199.171.54.194> Paul Prescod wrote: >> I like the language... but one reason why I'm looking at something >> -other- than Java is that I am kinda needing an .exe -type >> capability... > >Either Python or Java code can be distributed as an executable. The >executable bundles the interpreter into it. For Python, you want to look >at > >http://starship.python.net/crew/gmcm/distribute.html > >For Java, at "jexegen.exe". Sorry, Paul, the latter does not bundle in the interpreter. It just packages up byte code and uses a small exe to start your MS JVM. a-pox-on-cheap-imitiations--ly y'rs - Gordon From bjorn at roguewave.com Thu Jul 13 15:18:37 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Thu, 13 Jul 2000 13:18:37 -0600 Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: <396E160D.272C0C34@roguewave.com> Huaiyu Zhu wrote: > > We are at a crucial juncture concerning introduction of new operators into > Python for matrix computation, > > 1. Experiences with Matlab show that different operators for matrix and > elementwise operators are very important > > 2. It is difficult to add .* and ./ as . is already a valid token. It seems > that next candidate on the standard keyboard is @. > > 3. Gregory Lielens has just implemented a patch that could parse additional > operators containing @ > > a at b is equivalent to a*b, overloaded using __mmul__ and __rmmul__ > a@/b a/b __mrdiv__ and __rmrdiv__ > a/@b b/a __mldiv__ and __rmldiv__ > a@@b a**b __mpow__ and __rmpow__ > > He indicates similar constructions can be added easily. It seems like you're trying to create a special purpose language here. Ie. I don't see it as general enough to be worth putting into the core unless you can come up with other use cases... Personally, I would much prefer the ability to overload the relational operators (individually, not through __cmp__). -- bjorn From grey at despair.rpglink.com Fri Jul 28 11:23:38 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:23:38 GMT Subject: Perl is worse! References: Message-ID: On Fri, 28 Jul 2000 14:27:58 GMT, Grant Edwards wrote: >If I typed "1", that means I wanted a word, a printible string, and _not_ an >integer. If I wanted an integer I would type 1 instead of "1". If I want to >convert a string to an integer or an integer to a float or a float to a >string, then _I_ will do it. I do _not_ want the language to make WAGs about >what I meant when I typed something. @names = ("Bob","Bob","Bob","Robert Paulson"); @occupation = ("Uncle","Uncle","Uncle","Mayhem"); $index = 0; foreach $name (@names){ $done = 0; $x = 0; while (!$done){ if ($members{$name.$x}){ $x++ next; } else{ $members{$name.$x} = $occupation[$index]; } } } Your argument completely ignores cases like the above, doesn't it? Where you want to have a counter incremented (math function) but need to use it in a string constantly. Simplistic example, yes, but a valid one. Why force the programmer to do constant switching to do such a simple thing? >I meant what I typed. If not, I'll go back and fix it until >what I typed is what I meant. And I meant what I typed and do and I don't need the language telling me that I'm the stupid one. >There's nothing "wrong" with it. I just don't want it to happen. The people >responsible for designing the language apparently didn't want it to happen. >Choose or invent a language that matches what you want. Nobody (sane) claims >that a particular language is the best one for everybody or for every >application. Exactly my point. I don't like it but I'm not asking for it to be changed. I'm just a little tired, in all of what, two days, of people putting down another language for doing something which /they/ consider wrong. I consider it wrong in Python not because I'd like to see different, but because I was told Python doesn't have that ambiguity when it does, that it doesn't do conversion, when it does, that it doesn't do things "automagically" when it does. I'm pointing out that it is just as ambiguious in its own way and that I personally consider it wrong but, as I stated in one message, I will learn to use that. >I don't think it makes sense to do so. If I explicitly denote an object as a >string (e.g. "1"), then I want it to be a string and I want it to _stay_ a >string. Because you're thinking in types. I've stated that I don't like thinking in such primitive terms. I don't consider 1 an integer, a string, a character, a float, a complex or anything else in and of itself. I take into account the context of the operation. You don't. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From robin at jessikat.fsnet.co.uk Thu Jul 20 14:32:15 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 19:32:15 +0100 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39771CA8.A1BF8D6E@fft.be> Message-ID: In article , Huaiyu Zhu writes >On Thu, 20 Jul 2000 17:06:03 +0100, Robin Becker > wrote: >> >>the kronecker product is also called the matrix direct product >> >> >>A ox B = [a11 B a12 B] >> [a12 B a22 B] >> >>seems to me to be like a tensor outer product; but I ain't no >>mathematician ;) > >In matlab/octave, this is called kron(A,B). I don't think it deserves an >infix operators, because it is just a special case of matrix multiplication. >You can define a sparse matrix Kron(A) so that > >kron(A,B) == Kron(A)*B I'd be interested in how you define either Kron and * to achieve the result you claim without modifying the p x r matrix B; after all it cannot involve sums of elements of B so * isn't the matrix multiply. I could use an element wise multiply, but only if I use the end desired shape as the second element. > >For such specializations it is best to explicitly spell out the names of >operators. This is also true of unitary functions. + - have symbols but >sin, cos, ... do not. > >>the lie product (or bracket) has applications in sensitivity analysis >>and other more exotic stuff in differential geometry >> >>[A,B] = AB - BA > >def lie(a,b): return a*b-b*a > >On the other hand, the difference between elementwise and matrix operators >are much more fundamental. They result from the different views of vectors, >either as a simple collection of numbers, or as a point in a linear space >that happens to be represent by an array of numbers. > -- Robin Becker From ejr at lotus.CS.Berkeley.EDU Sat Jul 29 23:15:47 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 30 Jul 2000 03:15:47 GMT Subject: Python plug-ins for Adobe Products available References: Message-ID: <8m06l3$8s4$1@agate.berkeley.edu> And Grant Munsey writes: - Adobe has opened an open source site at http://opensource.adobe.com. [...] - The Adobe Open Source license is reasonably liberal. While I'll grant that this is a good first step for Adobe, these are simply add-ons for proprietary software. The add-ons are often available under moderate licenses. Meanwhile, there are existing free software projects that could use help. The Gimp + Gimp-Python (instead of Photoshop): http://www.gimp.org/ http://www.daa.com.au/~james/pygimp/ Sketch, which is implemented in Python (instead of Illustrator): http://sketch.sourceforge.net/ I'm not familiar with ``After Effects,'' but the description sounds like an extension of Broadcast2000: http://heroinewarrior.com/bcast2000.html AFAIK, there's no Python associated with that project. Perhaps there should be. Integration with things like VTk (www.kitware.com) would be nice. VTk has a Python binding, but not a very nice one. Jason From paul at prescod.net Mon Jul 17 20:22:31 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 19:22:31 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> Message-ID: <3973A347.3ABCB12F@prescod.net> Huaiyu Zhu wrote: > > ... > > That's a good point. Can __getattr__ be made to work only on a selected > number of attributes? We could use it on T, H, I, C for transpose, > Hermitian transpose, inverse and conjugate. But if it works on all the > undefind members the error message may be too obscure. I don't think you need __getattr__ class Matrix: def __init__( self, ....): self.T=Transpose( self ) self.H=Hermitian( self ) self.I=Inverse( self ) self.C=Conjugate( self ) self.E=Elementwise( self ) self.M=self # matrixwise is default ... other matrix-like methods ... class Transpose: def __init__( self, mymatrix ): self.mymatrix=mymatrix ... other matrix-like methods, but transposed ... Notice that no computation (e.g. actual transposition) needs to be done until you actually need to calculate a value. Maybe you can find optimizations that allow only tiny parts of matrices to be computed. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From boncelet at eecis.udel.edu Wed Jul 19 14:42:59 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Wed, 19 Jul 2000 14:42:59 -0400 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: <3975F6B3.26FD8816@eecis.udel.edu> Huaiyu Zhu wrote: > >Personally I think that this an overlarge crop of operators to be > >adding. Since I prefer something like: > > > >A.inv * B > > > >to > > > >A \ B > > They are equal in math, but not in practice. The former takes O(n^3) > computation while the latter is O(n^2). The former is also less accurate > for near singular A because of rounding error. Let me interject: Both computing A.inv and solving AX=B takes O(n^3) operations. It is often preferable that an expression like A\B be computed as solve(A,B) for numerical reasons and occasionally when special algorithms for A can be exploited, e.g., when A is structured or it is known that A and/or B has special properties. This is similar to why the numerical people want += operators (besides saving typing): Special methods can be invoked automatically. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From nick at spam_me_not_videosystem.co.uk Wed Jul 5 14:30:32 2000 From: nick at spam_me_not_videosystem.co.uk (Nick) Date: Wed, 5 Jul 2000 19:30:32 +0100 Subject: GUI framework with TreeView References: <3967f81e.23966859@nntp.interaccess.com> Message-ID: <39637f28@news.xtml.co.uk> "Thaddeus L Olczyk" wrote in message news:3967f81e.23966859 at nntp.interaccess.com... > I need a "free" gui framework that runs on both Windows and UNIX > ( so that lets out QT ) and gives me a component similr to Microsofts > TreeView. Does anyone know of such a thing? Python Mega widgets adds tree view to tkInter I believe. wxPython and pyFltk are 2 window system with Python bindings. wxPython certainly has a tree view. From alex at magenta.com Sat Jul 29 07:53:02 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 29 Jul 2000 13:53:02 +0200 Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: <8luhso41ce8@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o444p.49c.grey at teleute.rpglink.com... > On Fri, 28 Jul 2000 23:09:56 +0200, Alex Martelli wrote: > >I hope you remember that in Python there's no need for the joining > >and later re-splitting: just putting the pair (tuple) in there is > >so much easier and more natural. > > No. I am learning that. A plesant side effect of this excellent > discussion. The quality of the discussion has surely been a pleasant surprise. Thank you for your persistence:-). > >Among other things, it makes it easy to save/load/change a format-string; > > Nono, you misunderstand me. I prefer the Pascal notion of variables in > place in the string with formatting attached to it instead of placeholder > formatting strings with the variables hanging off the end of the string. In Python, you can have either form, depending on your specific preferences and needs at each case. > Pseudo code from no language, bear with me. > > "Here is a string with ",$a:d:0:0," variable in it." > > "Here is a string with %d:0:0 variable in it.",$a > > In the former I read and I see, "Oh, $a goes here with this formatting" > whereas in the latter it is "Oh, here is the formatting for... uhm.. $a." Yes, so the latter is best when you have a single format you want to apply to several different variables at various point, the former is best when the names are fixed. That's why Python supplies both. The Python syntax for a format-string including variable-names is, e.g.: "Here is a string with %(varname)d in it" while the equivalent format-string without a varname would be: "Here is a string with %d in it" The latter form, with anonymous placeholders, is applied (with the % operator) to a *sequence* (or a single element, if there is just one placeholder in the format-string). The form with the _named_ placeholders is applied (with the same % operator) to a *mapping*, typically a dictionary; if the dictionary you want to use happens to be the set of variables currently bound, well, that's exactly what the built-in function vars() is for. So, summing up: "Here is a string with %(varname)d in it" % vars() and: "Here is a string with %d in it" % varname are exactly equivalent; you pays your money (metaphorically speaking, of course), you takes your choice. Note that the application of the format-string with the named placeholders to vars() is *EXPLICIT*. This lets you use any OTHER dictionary (just as explicitly) to perform many useful things. Here is a typical example -- internationalization! Say at some point in your program you have the statements: print "Here is a very %s %s!" % (adjective1,noun1) print "Here is a very %s %s!" % (adjective2,noun2) But now you want to sell your program abroad, so the English only messages must go. Oh well, it is only a little work to read the formatstring from an appropriate file, after all: format = getFormat("HereIs") print format % (adjective1,noun1) print format % (adjective2,noun2) Of course, the adjective and noun will have to be gotten in a language-specific way, too. But there's a deeper problem -- this form still forces the ORDER in which the words get inserted in the format! And different languages prefer different word-orders. You would not want your program where in English it would output: Here is a very big house! Here is a very rich woman! to emit, in Italian: Ecco una molto grande casa! Ecco una molto ricca donna! believe me; it had better be: Ecco una casa molto grande! Ecco una donna molto ricca! The format-string with named placeholders solves the problem _without_ any need for the specific variable names to be fixed! Just change your format-string to: "Here is a very %(adj)s %(noun)s!" in English, and, in Italian, to: "Ecco una %(noun)s molto %(adj)s!" and the output statements to: print format % {'adj':adjective1, 'noun':noun1} print format % {'adj':adjective2, 'noun':noun2} and you're all set. > Again, simplistic and not in any language, but taken to the extreme you > can see the problem. > > "%d:0:0 %c:U %s %s %s %s %d %s %s %s \ > %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k > > What variable goes with what again? Yes, a format-string with named-placeholders does help with that, too. But unnamed-placeholders format-string also have their place, when the *order* of the items being formatted is really what matters, rather than the variable-names (if any!) that they're tagged with. I'm very happy not _having_ to invent some arbitrary name when what I want to do is output one or more arbitrary expressions, computed on the fly, for example. Naming has its place, but so does quiet anonimity...:-). > >You just don't have to put strings together, to split them up again later, as > >much as is usual in Perl (it was _mandatory_ in Perl 4, which had no rich > >data structures; it's still _popular_ in Perl 5, for various reasons). > > Simplicity. I find it simpler to use a sequence as-is rather than have to encode it into a string, then later parse the sequence back from the string. Using as-is takes 0 operation, the alternative takes 2:-). > >Why else would I have been so happy, so utterly happy, to leave 8 years of > >Perl experience behind and start over from scratch with Python? > > Masochism? :) Could be (I _am_, after all, a well-known sadomasochist!), but, if it were that, I think I'd be programming in C shell (hard to think of a more painful way to make a living; and yet there _were_ people writing scripts in it rather than the somewhat-less-painful Bourne shell, for reasons I've always found utterly unfathomable...). Alex From alex at magenta.com Fri Jul 7 04:57:31 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 7 Jul 2000 10:57:31 +0200 Subject: Win32com ADO curiosity #1: MoveNext References: <4D0A23B3F74DD111ACCD00805F31D8101D8BD280@RED-MSG-50> Message-ID: <8k47fm01b7e@news2.newsguy.com> Bill Tutt wrote in message news:4D0A23B3F74DD111ACCD00805F31D8101D8BD280 at RED-MSG-50... > Because this is Python, and not VB or VBScript. > It's a language syntax thing. [snip] > From: mksql at my-deja.com [mailto:mksql at my-deja.com] > Sent: Thursday, July 06, 2000 1:21 PM [snip] > Why does MoveNext require the () ? The ADO object model does not > specify parameters for MoveNext, MoveFirst, etc. Exactly. In Python, like in C or C++, just mentioning a function's name does not *call* it; you have to append empty parentheses to tell the language that you want to call the function without parameters. (Just mentioning it without parens yields its address in C or C++, the function-object itself in Python, but that is by the by). No object model (ADO or other) gets to change the language from which it is used (C++, Python, or other). Alex From alex at magenta.com Wed Jul 5 10:23:28 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 5 Jul 2000 16:23:28 +0200 Subject: "Write to a file" question please? References: Message-ID: <8jvgk9012ca@news1.newsguy.com> [posted and mailed] wrote in message news:tzFjOfN2zOzPHwvl3ncklEAEb+fa at 4ax.com... > number = 100 > print "Number =", number > OUT = open("TT.txt","w") > OUT.write("Number =", number) # Error > OUT.close() The write method accepts one string argument. You can make a string argument as you seem to desire with the %-operator: OUT.write("Number = %d\n" % (number,)) I added the \n line terminator to the string, because it's not implicit (in print, it IS implicit, but not in .write). Another alternative: import sys sys.stdout = OUT print "Number =", number sys.stdout = sys.__stdout__ OUT.close() By assigning an opened file to sys.stdout you temporarily "redirect" the output of normal "print" to that file; you can then go back to normal using sys.__stdout__, which keeps the ORIGINAL value. Not worth it for writing just a few things, but fine if you have some function doing a lot of output with print, for example. Alex From paul at prescod.net Thu Jul 20 02:51:25 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 01:51:25 -0500 Subject: Arbitrary operator symbols (Re: Operators for matrix: current choices) References: <3976884F.51FD33D9@my.signature> Message-ID: <3976A16D.C66561CF@prescod.net> Greg Ewing wrote: > > The main problem I see with any kind of scheme requiring > new operators to be defined before use is how you control > their scope. > ... Tim warned against spending a lot of energy on a runtime operator definition mechanism. He's not Guido but he felt pretty strongly that he was channelling Guido when he said: "Just choose some operators for matrix multiplication and do not either try to define meanings for them over other operations nor try to make the operators dynamically loadable or creatable. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From frr at mindless.com Mon Jul 10 15:37:15 2000 From: frr at mindless.com (Fernando Rodríguez) Date: Mon, 10 Jul 2000 19:37:15 GMT Subject: redirect output of functions to a string or file Message-ID: Hi! I have several functions that return strings. The output of these functions must be combined and saved into a file. Is there a way to tell Python to "automagically" redirect the output of _all_ functions to a string or file? O:-) TIA --------------------------------------- Fernando Rodr?guez From shochet at my-deja.com Sat Jul 29 01:44:23 2000 From: shochet at my-deja.com (shochet at my-deja.com) Date: Sat, 29 Jul 2000 05:44:23 GMT Subject: Calling C Function Pointers from Python Message-ID: <8ltqvn$pbl$1@nnrp1.deja.com> I am currently in the middle of hooking up a large external C++ library by maintaining a database of C++ function pointers that I will call from Python. If anybody has tried this before, my question is: Is there a good way to call these function pointers without having to wrap every single one in a Python-C module? The only package I know of that might do this job is libffi, but it only runs on Unix, not on Windows. Has anybody tried this approach before? I have investigated SWIG, but cannot use it because the C++ library uses lots of fancy C++ features (templates, etc) that make it cranky. Currently my idea is to auto-generate all these function pointer wrappers with code that looks something like this: // Original C++ funcion (a simplified example) int add(int a, int b) {return a+b}; // Wrapped generated Python C function in a module I will import static PyObject *_internal_add(PyObject *self, PyObject *args) { typedef int (*FUNC1)(int, int); FUNC1 _arg0; int _arg1, _arg2, _result; PyObject * _resultObj, _argo0; if(!PyArg_ParseTuple(args,"Oii",&_argo0,&_arg1,&_arg2)) return NULL; _arg0 = (FUNC1)PyCObject_AsVoidPtr(_argo0); _result = (int)(_arg0(_arg1, _arg2)); _resultObj = Py_BuildValue("i", _result); return _resultObj; } # I will then call this by passing in the function pointer and arguments from Python. def add(a, b): function_pointer = lookup_global_function('add') returnValue = _internal_add(function_pointer, a, b) return returnValue Thanks for any opinions/suggestions. -- Joe (shochet at hotmail.com) Sent via Deja.com http://www.deja.com/ Before you buy. From lull at acm.org Thu Jul 20 02:08:04 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 01:08:04 -0500 Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: Penfold wrote: > What, really, is the point in this. Its obvious why you want them, but why > does everyone else? > This is clearly a *domain specific* problem, which is yours, that you would > like Python to look like > MatLab. I don't think the point is to make Python look like Matlab. The point is to permit infix notation in cases where the current alternative is *really* ugly & hard to read. That problem extends far beyond linear algebra, & an ideal solution would be applicable to any problem domain in which infix notation is greatly preferable. Regards, John From sbrunning at trisystems.co.uk Mon Jul 10 12:32:34 2000 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 10 Jul 2000 17:32:34 +0100 Subject: Installing and running JPython on the AS/400 Message-ID: <3969fb38_1@nnrp1.news.uk.psi.net> Has anyone done this? I can't even get the JPython installer (from ) to execute... -- Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk The opinions expressed are mine, and are not necessarily those of my employer. All comments provided "as is" with no warranties of any kind whatsoever. From stpol at mindspring.com Wed Jul 19 15:11:51 2000 From: stpol at mindspring.com (Dan^) Date: Wed, 19 Jul 2000 15:11:51 -0400 Subject: are there any tutorials that someone completly new to programming can understand? References: <8l4klm$2kl$1@slb6.atl.mindspring.net> Message-ID: <8l4ueh$6bu$1@nntp9.atl.mindspring.net> ahh thanks -Dan From michael at stroeder.com Fri Jul 14 06:05:37 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 14 Jul 2000 12:05:37 +0200 Subject: Python + Apache 1.3.x (CGI) not working (no mod_python) References: <8kmjlb$vji$1@nnrp1.deja.com> Message-ID: <396EE5F1.D44934B7@stroeder.com> genablu at my-deja.com wrote: > > print 'Content-type: text/plain' > print ' ' Should be print 'Content-type: text/plain' print or print 'Content-type: text/plain\r\n' Ciao, Michael. From delgado at olaf.de Wed Jul 26 05:28:59 2000 From: delgado at olaf.de (Olaf Delgado) Date: Wed, 26 Jul 2000 11:28:59 +0200 Subject: conatraints on "for" magic? References: <8llqso$q75$1@news.dtc.hp.com> Message-ID: In article <8llqso$q75$1 at news.dtc.hp.com>, weeks at golden.dtc.hp.com ((Greg Weeks)) writes: > How did the implementer of the "fileinput" module convince the "for" > construct that fileinput.input() was a sequence? AFAIR, when you write for x in seq: Python does something like i = 0 while (1): try: x = seq[i] except IndexError: break; i = i + 1 where, if seq is a class instance, seq[i] just calls seq.__getitem__(i). So, for classes, all you have to do is to implement an appropriate __getitem__ method. For builtin types, such as implemented in an extension module, there is a similar 'magic method' the implementor may provide. Regards, -- //// Olaf Delgado Friedrichs, Bielefeld, Germany `=' --- http://www.mathematik.uni-bielefeld.de/~delgado --- From nobody at nowhere.nohow Sun Jul 30 12:33:52 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 30 Jul 2000 16:33:52 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <3982F04D.74FCF41C@webamused.com> <39834B9F.C6877761@webamused.com> Message-ID: On Sun, 30 Jul 2000 08:57:27 GMT, Steve Lamb wrote: >On 30 Jul 2000 18:31:37 +1200, Paul Foley wrote: >>Isn't it? Are you sure about that? > > Considering some of the conversations I've sat in on with >my friends, no, it isn't in some contexts. I can provide more >examples if you /really/ want to be that intentionally obtuse. Steve is correct. In my experience it is not only inoffensive in some contexts, it has a positive connotation and means someting along the lines of what "mate" means in Australia. I can't believe we're discussing this in a debate about Perl vs. Python (or more abstractly, strong vs. weak typing). -- Grant Edwards grante Yow! Could I have a drug at overdose? visi.com From m.faassen at vet.uu.nl Mon Jul 31 05:49:01 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 09:49:01 GMT Subject: experts disagree on "call-by-reference" References: <8m29o0$p9g$2@news.dtc.hp.com> Message-ID: <8m3i2d$du4$1@newshost.accu.uu.nl> (Greg Weeks) wrote: > Lisp, CLU, Java, and Python implement objects, assign objects, and pass > objects to functions similarly. [Although Jave differs regarding its > "primitive" types.] So I was curious about how various Lisp, CLU, and Java > texts dealt with the issue of "references" and "call-by-whatever". I > examined my bookshelf. Some texts used phasing I like; others didn't: > "Lisp" (by Winston and Horn): [snip] > "Common Lisp" (by Steele): [snip] > Structure and Interpretation of Computer Programs (by Abelson and Sussman): [also Lisp] Note that if you use Lisp to do functional programming, 'reference' and 'value' loses meaning in practice as all objects are treated as immutable. Just like in Python the immutable objects behave with 'value' semantics. > CLU Reference Manual (by Liskov and others): [snip] > The Java Language Specification (by Gosling, Joy, and Steele): > The text distinguishes between objects and references. No mention is made > of call-by-whatever. In Java for non-primitive types all variables contain references to objects, so it's the references that are passed (but no explicit reference taking happens during the call). This is similar to Python. > All of the passages mentioned above could just as well apply to Python. > The experts are in explicit disagreement. I think it's important to note that 'reference' versus 'value' tends to becomes an implementation detail if you do pure functional programming. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From timaratz at lisco.com Tue Jul 4 10:48:12 2000 From: timaratz at lisco.com (Peter Timaratz) Date: Tue, 4 Jul 2000 09:48:12 -0500 Subject: Looking for Python CGI resources In-Reply-To: Message-ID: <000101bfe5c6$e0e73f80$24b745c6@timaratz> I have the book 'Learning Python' and now I'm looking for material oriented towards using Python for CGI. The only book that seems to cover this topic in any depth is 'Internet Programming With Python' and it is out of print. Is there any other CGI material available? From wlfraed at ix.netcom.com Tue Jul 11 00:14:20 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 10 Jul 2000 21:14:20 -0700 Subject: Compiling Python References: Message-ID: <9m5lms0bt9fhiir6c2vju9ti4hvvv473kb@4ax.com> On Mon, 10 Jul 2000 21:29:09 GMT, "David L. Heald Jr." declaimed the following in comp.lang.python: > Does anyone know if there is a compiler available anywhere for python for > win32? > Pardon? A compiler with which to build Python from source, or A compiler which builds native executables from Python programs? For the latter, I don't think one exists on any platform -- freeze may be the closest equivalent (as I recall, not having used it, it embeds Python byte-code into a binary with the Python interpreter). For the former... I think folks are working on getting the downloadable Borland C to compile it, the M$ VC should handle it with no problems, and gcc probably can manage it. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From aotto at t-online.de Tue Jul 11 10:10:13 2000 From: aotto at t-online.de (Andreas Otto) Date: Tue, 11 Jul 2000 16:10:13 +0200 Subject: off-topic, "Compiler" technology References: <396ABBD7.8715465D@t-online.de> <8kf2jf$sqc$1@desig-bs01-s04.adtranzsig.de> Message-ID: <396B2AC5.971E9D13@t-online.de> Hi, 1) I released a TCL "Compiler" which has a significant speedup http://home.t-online.de/home/aotto/comp-perf_E.html For special cases "Compiler" is 7 times faster. For large scale TCL application's there is a speed increase of 25%. This mean if your job need 40 minutes now it will be done in 30 minutes after compilation 2) You can download the TCL Compiler and his components http://home.t-online.de/home/aotto/comp-main_E.html 3) "Compiler" finds all of the syntax error in the source-code at compile-time ( tested with large real-world TCL application's ) 4) "Compiler" give you hint's haw to improve your source-code 5) You only have to work in TCL no language mix nothing special. Tcl2Meta generate the META code and the back-end's generate the source code. Meta2Tcl: proofed error-free optimized TCL code Meta2C: very very fast native C code Meta2Java: native java code ( coming soon ) you work in one language but ship the language you want 5) Right, i will only develop a python compiler if i don't have to carry all of the risk. > My understanding is that Andreas Otto is still in search for somebody > who will fund a Python or Perl compiler; so far, apparently nobody was > interested enough, or trusted that Mr. Otto would indeed be able to > deliver a compiler offering significant speedup. mfg aotto :) -- ================================================================ Andreas Otto Phone: ++49-(0)8152-399540 IPN Ingenieurbuero fuer mailto:aotto at t-online.de Praezisionsnumerik Web: http://home.t-online.de/home/aotto Ulmenstrasse 3 Skills: Unix,Sql,Tcl,Shell,Sybase... D-34289 Zierenberg Area: Bank, FX, MM, shares, options ================================================================= From akuchlin at mems-exchange.org Fri Jul 7 14:04:42 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Fri, 7 Jul 2000 14:04:42 -0400 Subject: Splitting c.l.py... In-Reply-To: <39661DE1.A409330C@roguewave.com>; from bjorn@roguewave.com on Fri, Jul 07, 2000 at 12:13:53PM -0600 References: <3dituj9cdi.fsf@kronos.cnri.reston.va.us> <39661DE1.A409330C@roguewave.com> Message-ID: <20000707140442.B4771@kronos.cnri.reston.va.us> On Fri, Jul 07, 2000 at 12:13:53PM -0600, Bjorn Pettersen wrote: >So is this a good time to re-open the discussion on splitting the >newsgroup/mailing list? Beats me. Hmm... here's a possibility: what if python-dev was gatewayed to a moderated newsgroup comp.lang.python.core-devel? Messages posted to the group via Usenet would just be bounced back to the poster, so there's no moderator approving messages, and python-dev would continue to be invitation-only. Essentially the newsgroup would be a read-only view of the python-dev mailing list. Would that be possible? Is there a Usenet precedent for this sort of setup? --amk From neilh at scintilla.org Sat Jul 1 18:44:54 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 01 Jul 2000 22:44:54 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <033e01bfe3c1$959868d0$6401a8c0@home> Message-ID: > > Just to stoke the flames a little... > > > > Check out some of the talks at the upcoming PDC - > > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python > > Hey! Is this something you've been working on? > So all these vendors are on board with integration into this new framework? > I want to know the rest of the story now. Mmm, Python has to share a session with Perl but both APL and Cobol get their own. At least we're not right down the back with Haskell, Mercury, Oberon and ML. ;) And there doesn't appear to be a Java binding - what an oversight! Neil From thomas at cintra.no Fri Jul 28 10:10:16 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 28 Jul 2000 14:10:16 GMT Subject: Good online resource for learning about classic ( advanced ) datastructures ( OO ) Message-ID: <398291c6.20106601@news.online.no> Hi, Does anybody know of any good online resource for basic classical datastructures, preferrably aimed at Python, or language independant? It should be pretty step by step, basic, yet complete. I want to learn more about how stuff like how different trees ( Black-Red, 1-2-3, AWL etc. ) , graphs are constructed, where and when they're used etc. I think a similar concept to what I'm after was laid out in the "Datastructures and Algorithms in Java", but I cannot seem to get my hands on that book. ( The last time I read it I had problems applying the stuff to python too. But that's a long time ago so I might be more productive now. Hopefully ;-> ) My main goal is that I want to learn how to get datastructures to work, and why they work, when and how to use them. The foundation, system behind the design. ( Do I make any sense at all ?? ) Thomas From pinard at iro.umontreal.ca Mon Jul 31 10:48:29 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 31 Jul 2000 10:48:29 -0400 Subject: PY to HTML In-Reply-To: breiter@usf.Uni-Osnabrueck.DE's message of "31 Jul 2000 12:58:57 GMT" References: <8m3t6h$g48$3@newsserver.rrzn.uni-hannover.de> Message-ID: [Bernhard Reiter] > > Does anybody know anything that will enable me to convert a Python > > script to HTML, so I can display it on a webpage nicely formatted with > > syntax colour coding. Manually coding is a pain in the posterior :-) I currently use `enscript' to directly produce HTML from Python with bold and italics, on the fly within CGI scripts. You could modify files: /usr/share/enscript/hl/python.st /usr/share/enscript/hl/lang_html.st to your taste, for other effects. I did not try it, but I presume it should be doable. Years ago, I needed some non-standard things from `enscript', and I remember I was able to get what I wanted after some work, but not much. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From thomas at xs4all.net Mon Jul 10 15:05:47 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 10 Jul 2000 21:05:47 +0200 Subject: RADIUS authentication poll In-Reply-To: <14698.5654.645828.624122@bitdiddle.concentric.net>; from jeremy@beopen.com on Mon, Jul 10, 2000 at 02:29:42PM -0400 References: <14698.5654.645828.624122@bitdiddle.concentric.net> Message-ID: <20000710210546.N26534@xs4all.nl> On Mon, Jul 10, 2000 at 02:29:42PM -0400, Jeremy Hylton wrote: > We recently received a module submission for the Python standard > library that implements very basic RADIUS authentication. It's not > clear how widely useful this module would be. I've never heard of > RADIUS authentication before, so I'm inclined to think it is a bit > obscure for the standard library. If you think I'm wrong and would > like to see it in the library, please send me a note to that effect. > I'll be happy to include it by popular demand. RADIUS is a protocol to do remote authentication. It's mostly used in the form of access-routers (dialin servers, leased-line routers) which ask a centralized server whether the given login/password combination is correct. It has room for a lot of extra options, like passing configuration options back and forth, and it's used in schemes like 'international access', where one providers' radius server polls another providers' radius server to see if a user of the second ISP is allowed to dial in with the first ISP. (RADIUS, if I recall correctly, was developed by Livingston, one of the world players in access routers, which has since been bought by Lucent. Most, if not all, access routers adopted RADIUS, though some in concert with their own protocol(s).) Not really something to put in the std. lib, in my humble opinion. There are a lot more generally useful modules, like bytecodehacks and the mxSeries, that are more fitting candidates for inclusion. (Not that I'm advertising those particular modules, I'm just giving an example.) (CC list so anyone can disagree ;) Of course, if the issue is that the module has no place to live, and will die out if not adopted, I'm willing to adopt it myself. I'd probably not actually use or develop it, but I can keep it up to date and test it. I might even use it to test our own RADIUS servers :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From alex at magenta.com Sun Jul 30 11:38:58 2000 From: alex at magenta.com (Alex Martelli) Date: Sun, 30 Jul 2000 17:38:58 +0200 Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> <0mVg5.16257$4p3.129481@news-server.bigpond.net.au> Message-ID: <8m1jbq02ue9@news2.newsguy.com> "Neil Hodgson" wrote in message news:0mVg5.16257$4p3.129481 at news-server.bigpond.net.au... [snip] > And then you'll run into opposition from people who think that this is > too dangerous. You can crash Python easily with > > calldll.call_foreign_function(0,"l","l",(0,)) Couldn't the call_foreign_function be internally wrapped in a best-try attempt at handling any resulting errors more gracefully than with a crash? E.g., on Win/NT, a SEH __try/__except; on Unix, a local attempt to handle any and all 'signal's resulting from wild pointers, etc. No 100% safety by any means, of course, but maybe still better...? Alex From olivierS.dagenaisP at canadaA.comM Sat Jul 15 18:52:17 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 15 Jul 2000 22:52:17 GMT Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython References: <39700FD0.3C368827@ruf.uni-freiburg.de> Message-ID: Coming from VB, I decided to give the editor a try. It's nice, but I wouldn't pay 70 american dollars for it. I hope my comments will be useful... Great points: 1 - I love the idea of representing the hiearchy of sizers and widgets in a treeview, especially that you use different icons for the two. Would be even better if you used an icon representing the type of widget, and put the widget name as the node's string value. 2 - Ability to test your dialog. This is great to make sure it resizes correctly. 3 - Ability to output to C++, Pyhthon or XML. Would be even cooler if you exposed the objects so more persisters could be written (by third parties) 4 - Highlighting the current widget and the widget's parent. Excellent to keep track of the relationships. Not so great points: 5 - The toolbars at the top of the editor are overwhelming (at first) and it would be very nice to either re-organize/customize them, to dock/undock sections or to turn them on and off at will. Maybe giving the toolbars names, too, would help disambiguate the actions. 6 - Inability to move controls around (drag and drop) after they are placed on the form (without resorting to cut/paste - which, incidentally, doesn't work with Ctrl+Insert, Shift+Delete and Shift+Insert, respectively Copy, Cut and Paste) 7 - No keyboard support, especially the DELETE key not doing anything in either the treeview or the main editor. 8 - Must use a seperate dialog to change properties of widgets or containers. A property grid would be excellent for this. 9 - Right-clicking on nodes of the treeview does nothing. If suggestion "1" was implemented, it would be nice to have the same context menu as there is when right-clicking on the widget itself. 10 - Single document interface makes it hard to do many things at once. (maybe this is a limitation of wxWindows?) 11 - Unable to select multiple controls (to move them all around, to cut/copy them all, to delete them all, etc..) 12 - There's no "Proportional" button in the toolbar. (???) 13 - "Empty spaces" only show up blank. It would be nice if the editor gave you an indication that you had put an "empty space" on the form, only when you are editing. 14 - New widgets appear in a weird way. I'd like to drag a new widget in the spot I want it to go, instead of deciding ahead of time where it will go before or after the currently selected widget. (So, to add a new widget, I have to first click on an existing one, click either before or after, then click on the new one. I usually think of it backwards: I choose a new widget then find where to put it.) 15 - Closed source, commercial product. I would want to help out if it was open-source. I would also be willing to pay for the product, if it had the features I mention above... It's a promising product. I'll be happy to test out the next version, as I really like the hiearchical representation of the relationships and it could prove very useful in designing large applications. Good luck! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Robert Roebling" wrote in message news:39700FD0.3C368827 at ruf.uni-freiburg.de... > > Hello, > > [I am using this list, since the python-announce list is no > longer functional.] > > I would like to announce wxDesigner 1.0, a commercial program > that can be used in connection with the free C++ GUI wxWindows > library and its populare Python bindings called wxPython. > > wxDesigner is a dialog editor that allows its users to visually > create dialogs using a simple point and click interface. The > output produced by wxDesigner can be either of C++ code, Python > code or XML, making co-development with wxWindows and wxPython > much easier than before. > > wxDesigner is available for Windows and Linux (Intel and PowerPC), > more information including pricing is available from: > > http://www.roebling.de > > For more information about wxWindows and wxPython, have a look at: > > http://www.wxwindows.org > http://www.wxpython.org > > Regards, > > Robert Roebling > >

wxDesigner 1.0 - > Commercial dialog editor for wxWindows and wxPython. (13-July-2000) > > From hzhu at localhost.localdomain Thu Jul 20 19:23:14 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 20 Jul 2000 23:23:14 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: On Thu, 20 Jul 2000 18:12:18 -0400, Paul Barrett wrote: > >The one issue that concerns me about this discussion is the continued narrow >focus to emulate Matlab syntax to the exclusion of more general N-dimensional >operations. I can see the need for some more general operators, but I'm not >for any of this, if all we're doing is defining 2-D Matlab syntax. I >suggest the Matlab people take a look at APL or J to get a broader >perspective of array languages. As far as I'm aware, multiarray necessarily involves indices. So infix operators are not so useful, until a class with index labels are defined. This means a.label(1,2,3,6) * b.label(1,4,2,5,7) would do what's written on paper as a_ijkl * b^imjcnp and gives a tensor similar to c.label(3,6,4,5,7). But once you are dealing with such classes, you'd be implementing a lot of other methods and redefining __mul__ anyway. You might even need a way to distinguish covariant and contravariant indices. The infix notation itself would certainly not be the main issue. The only default meaning for tensor inner product I would agree was what Greg Lielens proposed, effectively, a*b == a.label(1,2,3,4)*b.label(4,5,6,7,8) But this is the same as the matrix notation. OTOH, would you care to give a brief summary of how these other languages deal with these issues? It may indeed provide valuable insight. Huaiyu From cgw at fnal.gov Fri Jul 21 19:14:55 2000 From: cgw at fnal.gov (Charles G Waldman) Date: 21 Jul 2000 18:14:55 -0500 Subject: example Tkinter code? References: <8l7cvb$c61$1@mcnet.marietta.edu> Message-ID: "Locke" writes: > does anyone know where i can find some example python/tkinter code? i am > trying to learn, but i think some examples of how to use all those widgets > would be useful. How about in the Python source distribution in the directory Demo/tkinter? > also, how can i change the text on a label? when i use the > variabletext=whatever thing, the label wont show up. See http://www.secretlabs.com/library/tkinter/introduction/index.htm for lots of useful tkinter information. From montagne at boora.com Mon Jul 3 13:41:51 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 10:41:51 -0700 Subject: WinNT User Name Message-ID: First off, I'm a newbie at Python. I'm trying to return the user who is logged on at a PC. What I really need is the login name. How do I do that? Seems like it otta be quite simple but I'm having trouble. -mjm From claird at starbase.neosoft.com Wed Jul 19 17:35:31 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Jul 2000 16:35:31 -0500 Subject: newb question References: <39761E61.1E2191B4@tcgfinancial.com> Message-ID: <4EC92E18ACA00181.72E3F9F1575615E2.1B81AD7D6A3BF3C5@lp.airnews.net> In article <39761E61.1E2191B4 at tcgfinancial.com>, jtoy wrote: >Can you tell me how I can make a python program find the IP address of >the local machine? If possible, I would like to make this not matter . . . As thanks, you have to tell us what you're going to do with it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rgoto at aa.net Sun Jul 2 19:30:40 2000 From: rgoto at aa.net (Robert Goto) Date: Sun, 2 Jul 2000 16:30:40 -0700 Subject: Newbie question re: regsub References: <395fc90a$1_1@huge.aa.net> Message-ID: <395fcc6d$1_2@huge.aa.net> What is even more maddening to me is that when I save it to a module and run it from NT command prompt......the output I get is the original file contents only........like there was no regsub.gsub!! "Robert Goto" wrote in message news:395fc90a$1_1 at huge.aa.net... > I am sure there is a very simple answer to this. > >>> import regsub > >>> fimo = open('fimo.txt') > >>> while 1: > line = fimo.readline() > if not line: break > regsub.gsub('orange', 'red', line) > print line > > > 'red red red red red red red' > red orange red red red red red > >>> > > The file I am opening which is called fimo.txt only contains the string > withouth ' marks red orange red red red red red. > > What I want it to do is print the changed string only....but what I am > getting is both the original string and the changed string?! > > Any pointers would be greatly appreciated. > > From thomas at xs4all.net.bbs Sun Jul 16 11:20:03 2000 From: thomas at xs4all.net.bbs (thomas at xs4all.net.bbs) Date: 16 Jul 2000 15:20:03 GMT Subject: Imports in classes?? Message-ID: <3bQQk3$k0A@openbazaar.net> On Sun, Jul 16, 2000 at 03:11:03PM +0000, Martin Sk?tt wrote: > Im currently writing a database applikation using Python and > PostgreSQL. Because I need both a GUI and a web interface i have > chosen to divide the program in three classes (and files): one containing my > database queryes and one for each interface type. But where would be > the right place to import my database connection module (pygresql)? In > each interface file or in the query file? > I guess both solutions would would work, but what would be the "right > thing"? The right thing would be to do it when you need it. If you need the pygresql module in each interface file (that is, you actually reference it), you will have to put it in there. If you don't, well, don't :-) Don't import modules you aren't going to use. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jkraska1 at san.rr.com Mon Jul 10 22:00:47 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 11 Jul 2000 02:00:47 GMT Subject: Circular reference problem -- advice? References: <396A1EC6.6738CFCC@alcyone.com> <20000710123559.A2218@freei.com> <20000710214046.P26534@xs4all.nl> Message-ID: <396A807B.A0A9E92B@san.rr.com> > Don't forget that an instnace's __dict__ doesn't list methods, just data > members. (instance methods are created on the fly, from the unbound > versions, and not stored in the instance's __dict__.) But of course, they *are* in the class object's dict: >>> class myclass: def f(): pass >>> m = myclass() >>> m.__dict__ {} >>> myclass.__dict__ {'f': , '__module__': '__console__', '__doc__': None} >>> Not sure, but suspect this semantic can't be relied on. C/ From bwarsaw at beopen.com Fri Jul 28 01:50:57 2000 From: bwarsaw at beopen.com (Barry A. Warsaw) Date: Fri, 28 Jul 2000 01:50:57 -0400 (EDT) Subject: [Python-Dev] PEP 201, zip() builtin References: <14720.35958.632383.574511@anthem.concentric.net> Message-ID: <14721.8001.902979.957977@anthem.concentric.net> >>>>> "TP" == Tim Peters writes: TP> Could we please change "Parallel" to, e.g., "Lockstep" TP> throughout? Greg Wilson correctly pointed out that "parallel" TP> in the context of loops means something very different to the TP> scientific branch of the Python community. Easier to fix this TP> now that after it's spread to the docs. I know, and I guess I never came up with anything better which is why I didn't change it. "Lockstep" it is. TP> Just as you realized how inappropriate "parallel" was right TP> here . Heh. >> # find the length of the shortest sequence shortest = >> min(*map(len, args)) TP> Clearer as >> shortest = min(map(len, args)) A little experimentation leftover. Good catch. TP> However, this implies that all sequences must tell the truth TP> about their lengths, but the iteration protocol actually TP> terminates via a sequence raising IndexError. I believe we TP> want zip to follow the iteration protocol, in effect breaking TP> out of the outer loop as soon as some s[i] raises IndexError. TP> This was agreed to by all (incl. the BDFL) in some other TP> year's debates over this. Yup, I always intended the C implementation to obey the undocumented iteration protocol. But it /is/ better if the PEP's implementation were closer to the eventual C code, so I've swapped in a replacement. >> prefers zip() due to it's Haskell[2] heritage. See version 1.7 TP> "its", not "it's" Good catch. >> - Lazy evaluation. An earlier version of this PEP proposed >> that zip() return a built-in object that performed lazy >> evaluation using __getitem__() protocol. This has been >> strongly rejected by the BDFL in favor of returning a real >> Python list. If lazy evaluation is desired in the future, the >> BDFL suggests an xzip() function be added. TP> Which he'll then fight tooth and nail . :) >> ... TP> Nice job, Barry! Thank you. My pleasure! -Barry From denalione at my-deja.com Thu Jul 20 08:12:06 2000 From: denalione at my-deja.com (Dale Burnett) Date: Thu, 20 Jul 2000 12:12:06 GMT Subject: Waiting for Threads to Stop References: Message-ID: <8l6qab$ftc$1@nnrp1.deja.com> In article , "Doug Fort" wrote: > I have several cases where I want one thread to wait for one or more other > threads to terminate. I've had poor results attempting to spin on isAlive() > in join(). I'm contemplating using a semaphore. Has anyone got a more > elegant idiom? > -- > Doug Fort > Meat Manager > Downright Software > http://www.dougfort.com/~dougfort > > On windows you can use the Win32 functions WaitforSingleObject, SetEvent and CreateEvent. If you cant or dont want to use the win32 functions, then check out the Event Objects in the threading module. Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Wed Jul 19 18:26:46 2000 From: aahz at netcom.com (Aahz Maruch) Date: 19 Jul 2000 22:26:46 GMT Subject: Discussion: new operators for numerical computation References: Message-ID: <8l59v6$oq7$1@slb6.atl.mindspring.net> In article , Huaiyu Zhu wrote: > >Now that Guido has given the go-ahead for adding new operators for numerical >computation, let us consider carefully how to allocate this new resource, >taken into account Tim's guidelines. Um, has Guido actually given a go-ahead for adding to the language, or has Guido simply asked for a complete proposal to *consider* putting into the language? Do you have a handy reference for his precise words? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From matt at nightrealms.com.bbs Mon Jul 17 16:50:04 2000 From: matt at nightrealms.com.bbs (matt at nightrealms.com.bbs) Date: 17 Jul 2000 20:50:04 GMT Subject: Type checking in python? Message-ID: <3bRP2V$mHy@openbazaar.net> In article <397296BC.415C97E1 at prescod.net>, Paul Prescod wrote: > Matthew Cline wrote: >> >> def my_func(foo, bar, quux): >> if not isinstance(quux, Quux): >> raise RuntimeError("param 'quux' must be of class 'Quux'") > > Let me also point out that in many cases, this style of programming > would be frowned upon by serious Python programmers. For instance, > if you check that something is a string, your code will complain > when it is handed a Unicode string, even though it would probably > work fine. If you check that it is an open file, then your code > probably will complain about stringIO file-like objects, even though > it would probably work fine. That's another reason why I'd like the type checking to be done by the Python compiler, because it could be intelligent about those things. Like for "list" it could accept a tuple, a list, or anything derived from UserList. From neilh at scintilla.org.bbs Sun Jul 16 20:30:01 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 17 Jul 2000 00:30:01 GMT Subject: "Intellisense" drop-down... Message-ID: <3bQfDP$kuO@openbazaar.net> > Here it is, folks, the ability to use another key than TAB to select a word > in the AutoComplete list: I like it - good to see someone new improving PythonWin. A small problem with Ctrl+Enter is that it works in the editor but not the interactive window. Neil From stephen at cerebralmaelstrom.com Wed Jul 5 05:31:24 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Wed, 05 Jul 2000 09:31:24 GMT Subject: Acronyms, Names of Projects, etcetera. OTish. Message-ID: I've been off-and-on working on a pet project for awhile now, that frequently gets started up when I decide I want to learn something new, then gets put away after I learn said something. And as I learn more, it tends to get competely revamped in design and implementation. The only consistant thing that i've had so far is a name 'Pyces', pronounced Pisces. So i'm all happily, idly, coding in a hobby-ish fashion, and come across a post on random numbers..and blam!... I see a projected NAMED Pisces, and..well, obviousely pronounced Pisces. That just won't do. So, I had to come up with a new name -- and a new acronym, of course. Behold the wonder that i've come up with, after spending way more time then I will ever admit to... Pyramid (I don't care if anyone else has something named this!) PYthonic Repository for Advanced Missive Interpretation and Distribution lol. I'm sorry, this is really a pointless message. I just rather proud of my silly acronym. Ten cents to the person who guesses what it is :) (Not that it's that hard.) --Stephen From loewis at informatik.hu-berlin.de Sun Jul 9 06:25:26 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Jul 2000 12:25:26 +0200 Subject: default exception handler References: Message-ID: Johannes Zellner writes: > is it possible to install a default exception handler? > E.g. if the interactive py shell gets a NameError I'd > like it to call my own handler. You could *replace* the interactive shell, take all input from the user, execute it, and then do with exceptions whatever you want. This is how IDLE works. Regards, Martin From mwh21 at cam.ac.uk Mon Jul 24 15:49:02 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Jul 2000 20:49:02 +0100 Subject: Test framework of choice? References: <8F7B7D888beablebeable@209.155.56.81> Message-ID: mmorris at mindspring.com (Mitchell Morris) writes: [schnipp] > Are there any plans to include > any kind of regression testing framework into the standard distribution? Well, there is one; it's Lib/test/regrtest.py starting from $(topdir). It's not all that great though (it's OK, but there's no easy way of using it outside the tree). There's talk of sprucing it up/adopting a better framework but I don't think anyone has come up with comcrete plans yet. Cheers, M. -- surely, somewhere, somehow, in the history of computing, at least one manual has been written that you could at least remotely attempt to consider possibly glancing at. -- Adam Rixey From swun at eSec.com.au Tue Jul 25 01:28:25 2000 From: swun at eSec.com.au (Sam Wun) Date: Tue, 25 Jul 2000 15:28:25 +1000 Subject: How to async the log file. Message-ID: <397D2578.CFA345D4@eSec.com.au> There are multiple threads tying to write to a log file. How can I async this process to avoid the race condition? Or has it been handled by the kernel automatically?? Thanks Sam. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fannyy at idmail.com Mon Jul 10 12:12:12 2000 From: fannyy at idmail.com (Fanny Yeung) Date: Mon, 10 Jul 2000 09:12:12 -0700 Subject: Is there any grid/table in Tkinter ? References: <07ga5.11385$BS1.314666@brie.direct.ca> Message-ID: Hi Martin, Thank for your reply. But I wonder where I can find Doug Hellmann's grid widget ? Mak Martin Rand wrote in message news:j6jjms4ev3tok760njkhk550nd78rpn1oa at 4ax.com... > On Mon, 10 Jul 2000 02:06:38 -0700, "Fanny Yeung" > wrote: > > >Hi everybody, > > > >I am reading "Python and Tkinter Programming" and I am thinking of writing a > >simple database application that need to show table of data ( something > >similar to grid control in VB or Jtable in Swing). I guess I can use Canvas > >to implement that but I wonder anyone have implement this already ? If yes, > >can I use it ? Or is there by any chance provided by Tkinter directly or > >indirectly ? > > > Doug Hellmann's contributed extras to Pmw include a simple grid widget > for displaying a sequence collection. It probably won't do all you > want, but is a starting point for deriving your own. > > -- > Martin Rand > Highfield Software Ltd > mwr at highfield-software.co.uk > Phone: +44 (0)23 8025 2445 > Fax: +44 (0)23 8025 2445 From nowonder at nowonder.de Fri Jul 28 06:40:03 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Fri, 28 Jul 2000 10:40:03 +0000 Subject: [Draft] Open Letter to CNRI: Request for clarification Message-ID: <39816303.C808D05A@nowonder.de> I like the idea of an open letter to CNRI expressing the concern of the Python Language Community. It cannot hurt to have them know what we feel about the issues at hand. Unfortunately, as Martijn observed, the issues at hand are not easy to define. I have nevertheless tried my neurons on a draft. I am very open to every kind of critique or addition to this one (please correct my English, too, as it is not my mother tongue): --- begin open letter ------------------------------------------------------- To: Dr. Robert E. Kahn , (president of The Corporation for National Research Initiatives) Dear Mr. Kahn, as a member of the Python Community which gathers around the newsgroup comp.lang.python I would like to express my concern about the latest license issues that have arisen around the new 1.6/2.0 releases. As of now I have not had the chance to witness any official statement from your institution. So I sincerely request a clarification of CNRI's position on this matter. I have attached a list of signatures of members of the Python Community who are also concerned about the recent developments and through their signature support this request for clarification. Kind regards, Peter Schneider-Kamp P.S.: I find it rather startling that you see a need to change the license of a software whose development already has moved away from your institution. --- end open letter ---------------------------------------------------------- --- begin signature list ----------------------------------------------------- Diehard Py. Fan (diehard at python.fan) Implementation Issue (impl at implement.com) Want My Python Now (Want.My at Python.Now) ... --- end signature list ------------------------------------------------------- Or should it better by a letter from the community to CNRI? while 1: if feedback: break Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From thomas at xs4all.net Tue Jul 4 02:34:59 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 4 Jul 2000 08:34:59 +0200 Subject: how to push data in to ssh in python? In-Reply-To: <396126E7.B10A450B@esec.com.au>; from swun@esec.com.au on Tue, Jul 04, 2000 at 09:51:03AM +1000 References: <395FF2D9.1B46251D@esec.com.au> <396126E7.B10A450B@esec.com.au> Message-ID: <20000704083459.C283@xs4all.nl> On Tue, Jul 04, 2000 at 09:51:03AM +1000, Sam Wun wrote: > Thomas Wouters wrote: > > > On Mon, 03 Jul 2000 11:56:41 +1000, Sam Wun wrote: > > > > >Thanks > > > > Your question is incomplete. What do you want to do ? Did you look at > > popen(), and is it not what you want ? Does ssh require the input to > > come from a pseudo-terminal ? Can't you use a normal shell pipeline and > > make your python script just 'print' what you want to output ? Are you > > encountering difficulties with any of these ideas, or not finding the > > right documentation? > Oh yes, I actually print it to the stdout, and intended to use command > "ssh -l swun hostname < out.dump" to send out.dump to the "hostname" in > "swun" account, but I am not sure how to set up the "swun" account to > receive this transaction. 'ssh' is 'secure shell'. If you give it no additional arguments, it spawns a new shell for you, on the remote machine. If you do give it more, it'll start that as a program on the remote machine. So, if you want ssh on the remote machine to dump the output to a file, you can probably do ssh -l login machine "cat > outfile.dump" or some such. The quotes are necessary, by the way, to make sure the '>' redirection is passed to ssh, not interpreted by your shell. But if you intend to cat a local file, why not scp the file instead ? scp outfile.dump login at machine: Your question is more of 'how do I use ssh' than 'how do I use python' ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From stianh at ifi.uio.no Fri Jul 28 02:10:21 2000 From: stianh at ifi.uio.no (Stian Husemoen) Date: 28 Jul 2000 06:10:21 GMT Subject: The State of Python References: Message-ID: Tim Peters wrote: >The old Python license served it very well for a decade. It served CNRI very well.. as it made it possible for them to grab a hold of everyones contribution and make it their own property. The hole driving force of a open source project is that people feel they own a part of the code. If that's taken away, people will stop working on the project. -- Stian Husemoen From edream at tds.net Fri Jul 7 15:00:59 2000 From: edream at tds.net (Edward K. Ream) Date: Fri, 07 Jul 2000 19:00:59 GMT Subject: FILE * arguments in C API ?? Message-ID: <396628D5.12ECD88@tds.net> I'm considering embedding the Python interpreter into a Windows app built with Borland C++ Builder. Naturally, I would prefer to use the libraries in Python/libs rather than building the interpreter with C++ Builder, which would not be pleasant without Borland-specific make files. Alas, there appears to be a botch in the C API's. In particular, routines like int PyRun_AnyFile (FILE *fp, char *filename) can not be included usefully in python/libs because struct FILE's will be different when built by different compilers. This wouldn't matter if it were easy/possible to rebuild python/libs using one's own compiler. Any comments? Any suggestions? Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From mranga at nist.gov Fri Jul 28 18:41:51 2000 From: mranga at nist.gov (mranga at nist.gov) Date: Fri, 28 Jul 2000 22:41:51 -0000 Subject: tkinter for tk8.3? Message-ID: <8lt27f+4dbg@eGroups.com> Hello! I am a newcomer to python but have been programming tcl/tk for some time. I would like to use some of the newer features of tk8.3, however, I noticed that the compiled distribution of python only specifices tk8.0. Before I attempt to rebuild with the latest tk version, I would like to know if there are any "gotcha's" that would make this impossible/difficult to do. Thank you. Ranga. From hsl at tcp.co.uk Mon Jul 10 12:53:04 2000 From: hsl at tcp.co.uk (Martin Rand) Date: Mon, 10 Jul 2000 17:53:04 +0100 Subject: tkinter menus References: <8kcmeb$m5r$1@nnrp1.deja.com> Message-ID: <5vujmsg8hdf54luae6e2c0jivv93qheu9h@4ax.com> On Mon, 10 Jul 2000 14:26:40 GMT, Keith Murphy wrote: >menu, menu... anyone, anyone? > > How do you configure top-level menu entries? I'd like to put a 'help' >menu (and possibly others) on the right end of the menu bar. I've seen >examples where you make your own frame... but there has to be a way >built in... doesn't there? :) > In Tkinter, when you use the appropriate geometry manager to put the button in the menu bar. E.g: helpButton = Menubutton(myMenuBar, ...) helpButton.Pack(side=RIGHT, ...) Or if you're using Pmw, then you can do something like: myMenuBar = Pmw.MenuBar(...) myMenuBar.addmenu(side=RIGHT,...) -- Martin Rand Highfield Software Ltd mwr at highfield-software.co.uk Phone: +44 (0)23 8025 2445 Fax: +44 (0)23 8025 2445 From johngrayson at home.com Mon Jul 24 12:51:36 2000 From: johngrayson at home.com (John Grayson) Date: Mon, 24 Jul 2000 16:51:36 GMT Subject: tkinter: grid: expand and fill References: <8lhrbd$t4v$1@nnrp1.deja.com> Message-ID: <8lhs6l$tpt$1@nnrp1.deja.com> In article <8lhrbd$t4v$1 at nnrp1.deja.com>, Keith Murphy wrote: > is there a way to make a frame, that's been formatted using grid, expand > to fill the space it is given? > > thanks, > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Try " sticky=NSWE " in the grid method call for the frame... Sent via Deja.com http://www.deja.com/ Before you buy. From anthony at interlink.com.au Thu Jul 27 21:17:31 2000 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 28 Jul 2000 11:17:31 +1000 Subject: Perl is worse! (was: Python is Wierd!) In-Reply-To: Message from grey@rpglink.com (Steve Lamb) of "Thu, 27 Jul 2000 16:00:12 GMT." Message-ID: <200007280117.LAA23637@mbuna.arbhome.com.au> >>> Steve Lamb wrote > Range returns an error because of a bad type being stuffed into it. Perl > at least sees that it is a number and makes the conversion itself. I had to > get around it by changing the foo assignment line to: > foo = int(match.group(3)) Euw! No, the "oh, I know what you want that to be, I'll change it for you" is my #1 all-time perl hate. I want a "use really_strict_and_leave_my_types_alone" option before I ever consider looking at perl for anything ever again. Particularly when combined with magic linenoise - use the wrong bit of linenoise, and suddenly your large complex datastructure is an int. Yaaay. Anthony -- Anthony Baxter It's never too late to have a happy childhood. From erno at iki.fi Fri Jul 21 21:49:50 2000 From: erno at iki.fi (Erno Kuusela) Date: 22 Jul 2000 04:49:50 +0300 Subject: Creating a setuid script References: <39789242.C93B0446@glo.be> Message-ID: consider creating a group that contains users allowed to modify the contents of the file, it is much safer than playing with fire (superuser priviliges). -- erno From aahz at netcom.com Sun Jul 16 22:59:08 2000 From: aahz at netcom.com (Aahz Maruch) Date: 17 Jul 2000 02:59:08 GMT Subject: Funding vs Python References: <8kt4rj$d4n$1@nnrp1.deja.com> Message-ID: <8ktsps$985$1@nntp9.atl.mindspring.net> In article <8kt4rj$d4n$1 at nnrp1.deja.com>, Andy Freeman wrote: > >No good deed goes unpunished, so now I'm getting push back along the >lines of "we can't get funded if it's in Python". (Somehow, I don't >think that using Perl would have produced the same reaction.) > >I've seen the list of web projects at python.org, so I'm wondering >if there are others or if there really are examples of companies that >didn't get funded because they used Python. I don't know of any companies that didn't get funded due to use of Python, but there are plenty of funded companies that *do* use Python. (E.g., my company, http://www.searchbutton.com/) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From loewis at informatik.hu-berlin.de Thu Jul 13 05:03:49 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 13 Jul 2000 11:03:49 +0200 Subject: Beginner's question about reference counts... References: Message-ID: Miguel Marques writes: > I think I need to, because PyDict_SetItemString INCREFs both keys and > values and otherwise the reference count for newdict will off by one? Exactly, yes. Think of every reference in the counter being "owned" by somebody. The d dictionary owns its own reference to d, and you keep the reference given to you when the dictionary was created - so you have to drop it when you don't need it anymore. Regards, Martin From dalke at acm.org Mon Jul 24 21:19:21 2000 From: dalke at acm.org (Andrew Dalke) Date: Mon, 24 Jul 2000 19:19:21 -0600 Subject: Test framework of choice? References: <8F7B7D888beablebeable@209.155.56.81> Message-ID: <8lipn6$la5$1@slb3.atl.mindspring.net> Michael Hudson wrote: >Well, there is one; it's Lib/test/regrtest.py starting from $(topdir). >It's not all that great though (it's OK, but there's no easy way of >using it outside the tree). There's talk of sprucing it up/adopting a >better framework but I don't think anyone has come up with comcrete >plans yet. We use regrtest at my previous company. It worked pretty well. The only big mod I had to make was to get the imports correct. We had Python code in the top-level and the tests under "test/". If the code was really a package, we needed to include ../.. in the PYTHONPATH, but if we simply added that to the path we might accidentally include sister package. So we needed to play some tricks to make ".." act like the right package name. The modified code, called br_regrtest, is included in the PyDaylight package off my starship page (crew/dalke). The other things is it's a different approach than the XP people use. We had a discussion about this on the biopython list. The two are isomorphic, but the XP approach makes it easier to tear out parts of a test package for use elsewhere - the subcomponents are quite independent. On the other hand, the same can occur with the regrtest design, but it doesn't place the same emphasis. As to the reasons for the XP approach, I'm still not sure. I got the feeling that XP's view was more like QA people use while regrtest was the developer's viewpoint. Need to learn more about XP... Andrew dalke at acm.org From donn at u.washington.edu Fri Jul 21 12:44:20 2000 From: donn at u.washington.edu (Donn Cave) Date: 21 Jul 2000 16:44:20 GMT Subject: iterating over lines in a file References: <20000720124305.A1220@xyz.donetsk.ua> Message-ID: <8l9ul4$9fa6$1@nntp6.u.washington.edu> Quoth David Bolen : | cjc26 at nospam.cornell.edu (Cliff Crawford) writes: |> readlines() has an optional argument which specifies the approximate |> number of bytes to read in at a time, rather than the entire file. |> So something like |> |> for line in file.readlines(8192): |> # process line |> |> would only use about 8k of memory. | | And only fully process files less than 8K in size. The call to | file.readlines(8192) returns the list of lines contained within the | first 8K of the file (approximately), and that's all the 'for' is | going to iterate over. You have to repeatedly call file.readlines() | again to keep reading the file, which puts you pretty much back in the | original readline() mode, just with bigger chunks. Sure, but it's a useful idiom where the expected file is under ca. 500 bytes in any sane case. The upper limit keeps the potential insane case from wiping out the program. (Numbers arbitrary.) Not an approach we would always want to take, but there could be a place for it. Donn Cave, donn at u.washington.edu From paul at prescod.net Thu Jul 20 02:40:23 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 01:40:23 -0500 Subject: Locating Python modules References: <31575A892FF6D1118F5800600846864D4C706A@intrepid> <39768E53.63C422A3@pehr.net> Message-ID: <39769ED7.DCB91C40@prescod.net> pehr anderson wrote: > > In the linux world, this problem is pretty much licked. > ... > > Of course, if you are stuck in windows world, you have > to suffer the slings and arrows of maintaining *anything* > under windows. > ... Python runs on a lot more than those two platforms! -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From bercovic at swi.psy.uva.nl Mon Jul 17 19:35:11 2000 From: bercovic at swi.psy.uva.nl (Avi Bercovich) Date: Mon, 17 Jul 2000 16:35:11 -0700 Subject: PIL for SGI IRIX References: <396BD2E7.1E38FF95@bioeng.ucsd.edu> <8khvnb$4hhhn$1@fido.engr.sgi.com> Message-ID: <3973982F.AA23C3CC@swi.psy.uva.nl> > My suspicion is that you've got o32/n32 issues. Correct. A solution is to edit the configure script or call configure like so, given that your zlib is in /usr/freeware/lib32 LD_LIBRARY_PATH=/usr/freeware/lib32 ./configure --with-all-kinds-of-options this sometimes works for me. What I now have resorted to doing is to actually find the bit in configure that is causing the trouble, and simple hardcode the lib-paths into configure. in the above case it would be something like this: 1. look for LIBS="-lz" in configure 2. edit the LIBS="-lz" line to something like: LIBS="-L/usr/freeware/lib32 -lz" 3. use common sense to see if any other stuff needs editing like the include declatation, which would become "/usr/freeware/include/zlib.h" 't is a pain in the butt to weed out all them little buggers, but it works everytime. hope this helps, avi PS> If someone knows how to do this in a more 'elegant' fashion - great. I've just got a feeling that autoconf is very GNU/Linux specific wrt lib locations. From jbauer at rubic.com Mon Jul 31 16:18:21 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 31 Jul 2000 15:18:21 -0500 Subject: httplib hung on read References: <8m4m48+g8f4@eGroups.com> Message-ID: <3985DF0D.82AC5D79@rubic.com> ftian at cs.wisc.edu wrote: > I am using the httplib to get some webpage, it hungs sometimes > in the following senario, Tim O'Malley just wrote and posted a socket class with automatic timeout: http://www.timo-tasi.org/python/timeoutsocket.py Jeff Bauer Rubicon Research From Wolfgang.Strobl at gmd.de.bbs Mon Jul 17 08:30:03 2000 From: Wolfgang.Strobl at gmd.de.bbs (Wolfgang.Strobl at gmd.de.bbs) Date: 17 Jul 2000 12:30:03 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bRC1S$kCV@openbazaar.net> "Neil Hodgson" wrote: >> working with the new Build 132 of Pythonwin we have a minor problem. >> German Umlauts are not handled properly in the editor windows. >> They are shown as boxes, some of them seem to be dead keys. >> >> The problem did not exist in previous builds. >> Does anyone have a hint ? > > 132 defaults to using Unicode for editing Python source code and the >interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, >find the OnInitialUpdate method and comment out the two lines under "# >Enable Unicode if we can". Save the file, shut down Pythonwin and restart it >and see if this fixes the problem. It fixes the problem for umlauts, but pythonwin.exe still dies with a access violation (0x05), at adress 0x1e14cd9e, when the ^-key (top left, just below the esc key) is hit, on the German keyboard layout. -- Bicycle helmets are the Bach flower remedies of traffic From bjorn at roguewave.com Wed Jul 5 21:54:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 05 Jul 2000 19:54:31 -0600 Subject: Hello Word in CGI References: <3963C29E.76211EB7@bioeng.ucsd.edu> Message-ID: <3963E6D6.F47FA4D8@roguewave.com> What you're seeing are the symptoms of Python having thrown an exception and the weblog not capturing all the information. The solution is to make sure Python can only throw where you can grab the exception and do something useful with it, like printing it to the browser... Try the following (but make sure you can execute it from the command line first -- one possible error is a SyntaxError, which this scheme will not save you from...) -- bjorn #!/usr/bin/env python print """Content-type: text/html """ def main(): from time import * print "" print "" print "Hello World" print "" print "" print "

Hello World !

" print "
" print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" print "" print "" import traceback def execute(fn): # make sure any errors are legible, and directed to the user. try: sys.stderr = sys.stdout fn() except: print '

Something went wrong!!!

' print 'Please send the transcript below to webmaster at your.web

' print '\n\n

'
        traceback.print_exc()

execute(main)



Curtis Jensen wrote:

> We get this error in our server log:
> Wed Jul  5 16:12:52 2000] [error] [client 132.239.236.47] Premature end
> of script headers:
> /usr/local/httpd/cgi-bin/test_jmsun/cont_forms/helloworld.py
>
> The browser gives us this error:
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, webmaster at bioeng.ucsd.edu and
> inform them of the time the error occurred, and
> anything you might have done that may have caused the error.
>
> More information about this error may be available in the server error
> log.
>
> Apache/1.3.6 Server at cmrg.ucsd.edu Port 80
>
> Using this script from:
> http://www.ping.be/sabine-appelmans/home/python/index.html
>
> #!/usr/local/Python/bin/python
> #
> # helloworld.py
> #
>
> from time import *
>
> print "Content-type: text/html"
> print
>
> print ""
>
> print ""
> print "Hello World"
> print ""
>
> print ""
> print "

Hello World !

" > print "
" > > print "

This is San Diego.
Localtime is", ctime( time() ) + ".

" > > print "" > print "" > > Any ideas why? > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > -- > http://www.python.org/mailman/listinfo/python-list From dale at out-think.NOSPAMco.uk Sat Jul 1 17:25:25 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 1 Jul 2000 22:25:25 +0100 Subject: Threads? Message-ID: <8jlnkh$7h$1@supernews.com> Win32: Can Python execute a function from the same module in another process? I might do this, for example, to take advantage of multiple processors. Thanks -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants From edream at tds.net Mon Jul 17 12:46:55 2000 From: edream at tds.net (Edward K. Ream) Date: Mon, 17 Jul 2000 16:46:55 GMT Subject: Can't load .pyd files from embedded Python interp References: <39722B90.A41E02B5@tds.net> <8F73D685Egmcmhypernetcom@199.171.54.194> Message-ID: <3973384F.D6964D88@tds.net> Gordon McMillan wrote: > Most people just use python15.dll from their embedding app so both get the > same copy. Using Borland probably adds some warts to the process, since > everybody has to end up using the same c runtime. Your best bet is to look > for some posts by Gordon Williams, who has instructions on building python > with Borland. Gordon, thanks so much for this reply. This was precisely what I needed. There were several factors making it difficult for me to see the obvious. 1. I had no idea that python15.dll existed or that it was loaded as part of the Windows install. One of Gordon Williams posts on comp.lang.python mentions that python15.dll is found in C:\Windows\System 2. I had previously abandoned the idea of using either python15.dll or python15.lib with Borland C because some of the "very high level" C API's use FILE * arguments, which obviously won't work with Borland C. But the solution is trivial: just make sure that the code in the embedding app never calls these functions! 3. I had no idea that linking python15.dll, rather than python15.lib, is required when embedding Python in an app. It is required so that imported .pyd files can access variables in the Python interpreter. This illustrates one of the most common failings in documentation: failing to tell _what_ the reader is to do and _why_. Much documentation just jumps in and explains _how_ to do something. I just reviewed the Python Extending and Embedding docs. There is no mention that one must link against python15.dll, and certainly no hint about why that is necessary. One or two sentences in the docs might have saved me about a week of enjoyable, but useless, work. I'll write up my experiences when I've successfully embedded Python in my app. For now the conclusion seems to be that one only need link in C:\Windows\System\python15.dll to the app. There are some details specific to Borland, but presumably they won't be difficult. Again, thanks so much for setting me on the right track. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From alex_c at mit.edu Sun Jul 30 00:59:46 2000 From: alex_c at mit.edu (Alex Coventry) Date: 30 Jul 2000 00:59:46 -0400 Subject: Newbie question regarding .readline() References: Message-ID: Try replacing readline with readlines. The first returns a single line as a string, the second a list of strings. Alex. From GustavsB at ch.sibt.com Fri Jul 14 07:26:38 2000 From: GustavsB at ch.sibt.com (Bruno Gustavs) Date: Fri, 14 Jul 2000 13:26:38 +0200 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> Message-ID: <8kmtab$4or$1@pollux.ip-plus.net> "Dinu C. Gherman" wrote in message news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... > What do you mean by "language constructs", Python keywords > like "for" or "class"? Are you expecting some statistics of > used keywords over one's own code? > > I doubt this will be very useful, like the answer to the > question: "Which are the ten most used words in English?". > But maybe I'm not understanding well how you think you'll > benefit from such an answer... Lets assume you're going to design Phyton2. What would this language contain? What should Phyton2 support? What would you like to solve with Phyton2? Regards Bruno Gustavs From JamesL at Lugoj.Com Sat Jul 8 01:04:01 2000 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 07 Jul 2000 22:04:01 -0700 Subject: Making tabs illegal References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: <3966B641.F1AB28A2@Lugoj.Com> Matthew Schinckel wrote: > > On Fri, 7 Jul 2000, Forrest Cahoon wrote: > > > In article <3950C0E2.7532D38 at sightreader.com>, > > Ken Seehof wrote: > > > [ ... ] > > > > > > As for the space/tab mixing issue, the answer is simple: Make tab an > > > illegal character in python. Problem solved. > > > > > Ugh! Don't make this the default - I hate having to hit space four times, > I'd much rather just use tab. The tab liberation front demands that spaces be made illegal! Spaces are jealous because tabs often do 3 to 8 times more work than them. We don't need no stinking lazy spaces! From tim.hochberg at ieee.org Wed Jul 26 11:21:14 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 26 Jul 2000 15:21:14 GMT Subject: linear algebra in pure Python? References: <397E9CBC.2AD8FA89@crystal.uwa.edu.au> Message-ID: Douglas du Boulay writes: > I know that there is the Numeric python extension and/or the > Matrix extension MatPy, but is there not anywhere a pure Python > linear algebra package exploiting lists of lists for matrices and the > like? > (I would like to use eigen analysis etc. with JPython) Conrad has already pointed you to his fully Python array package. Another option would be to use JNumeric which is a (more or less) drop in replacement for Numeric for use with JPython. The LinearAlgebra package has not, unfortunately, been ported(1), but if you are only interested in operating on real matrices, there are several Java packages out there that will perform various linear algebra operations(2). Interfacing between JNumeric and these outside package is relatively easy(3). JNumeric is currently available at http://members.home.net/tim.hochberg/. -tim (1) This is because I've been waiting for an appropriate, open source, package to use as a basis for this. None of the ones I've seen so far support complex numbers though, so I'm still waiting. (2) Colt (http://tilde-hoschek.home.cern.ch/~hoschek/colt/index.htm) is the one I've looked at most recently. You might also want to look at Nist's JavaNumerics page (http://math.nist.gov/javanumerics/). (3) Function to convert between JNumeric and Colt type matrics are as simple as: rom Numeric import * from cern.colt.matrix import * from cern.colt.matrix.impl import * def JNToColt(ja): nAxes = len(ja.shape) if nAxes not in (1,2,3): raise ValueError, "Colt only supports 1, 2 and 3 dimensional arrays" constructor = [DenseDoubleMatrix1D, DenseDoubleMatrix2D, DenseDoubleMatrix3D][nAxes-1] return constructor(ja) def ColtToJn(ca): return array(ca.toArray()) From paul at prescod.net Fri Jul 21 19:28:29 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 21 Jul 2000 18:28:29 -0500 Subject: Dynamic package exploration References: <3978CDBA.5859E594@rational.com> Message-ID: <3978DC9D.F858F2A9@prescod.net> Sebastien Pierre wrote: > > Hi ! > > But if I do : > >>eval ( "import os" ) > It doesn't work...so it prevents me from doing something > dynamic...Ouch! You *very seldom* need eval/exec in Python. Maybe this will help: http://www.python.org/doc/current/lib/built-in-funcs.html Look at __import__ -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From thomas at xs4all.nl Mon Jul 3 08:03:16 2000 From: thomas at xs4all.nl (Thomas Wouters) Date: 3 Jul 2000 12:03:16 GMT Subject: Python CGI security References: <39607A22.CA190D70@stroeder.com> Message-ID: On Mon, 03 Jul 2000 13:33:54 +0200, Michael Str?der wrote: >Moshe Zadka wrote: >> There are a few types of "potential security holes": >> >> -- exposing insecure parts of the API, such as os.system(). These should >> stay, since the user should have those at his disposale >Would it be possible to provide a secure version in the Python lib >of e.g. os.system() with same function parameters but less unsecure >behaviour instead of just wrapping it 1:1? How could os.system() be more secure ? The way it is defined leaves no room for restriction. (It calls a shell to interpret the string passed in, after all.) What Python does do, is provide more convenient variants of os.exec*(), in the form of os.spawn*(). (At least, in Python 2.0) Also, writing your own 'secure' system() in terms of fork() and exec*() is fairly easy. Your-code-is-as-secure-as-you-make-it-ly y'rs, Thomas. From thomas at xs4all.net Mon Jul 17 04:46:27 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 17 Jul 2000 10:46:27 +0200 Subject: Wishlist sumbission form? In-Reply-To: <39727EFB.77234AEA@prescod.net>; from paul@prescod.net on Sun, Jul 16, 2000 at 10:35:23PM -0500 References: <39727EFB.77234AEA@prescod.net> Message-ID: <20000717104627.G7340@xs4all.nl> On Sun, Jul 16, 2000 at 10:35:23PM -0500, Paul Prescod wrote: > Matthew Cline wrote: > > Is there any way of submitting feature requests for Python, > > other than by filing a bug report? > I don't think so. If it is a very targeted request, you could try the > but report route. Actually, the buglist (Jitterbug, on www.python.org) as a 'Requests' section for feature requests. It gets looked at every now and then, too. > If it is large and arguable, you should probably post it here and get some > people to support it. If its good, someone will implement it. In open > source software, only the features that developers are interested in get > implemented so a wish list might well get ignored anyhow. It's not that > nobody cares what you think it's that there's an infinite list of wishes > so people tend to attack them in the order in order of personal interest > or widespread demand. Actually, I have no problem with implementing features which I think are good features, even though I would never use them. Or features that *might* be good. As long as I can test it (ie, they run on Linux or BSDI without dependencies on weird hardware or non-free software) I don't have much trouble with implementing it. But that's just me ;) Of course, if you know a little C, the Python source is incredibly easy to understand and extend. And a great tool for learning C, as well. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From paul at prescod.net Mon Jul 17 17:46:59 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 16:46:59 -0500 Subject: Parser project References: <397361C5.1D401DF2@prescod.net> Message-ID: <39737ED3.5A1CBB66@prescod.net> Huaiyu Zhu wrote: > > ... > > This is a good idea, although MatPy could not wait for it to happen, and I > do not foresee much additional syntax being requested. For the current > matrix issue, a limited parser might be easier and more useful. Not as much easier as you think. And anyhow, my proposal was to make a module useful to Python programmers from a variety of domains. That seems more likely than the infix operators which are not going to be as widely popular. For instance, someone wanting to experiment with list comprehensions or embedded SQL could do so. > I'm not sure if it can be made as easy as > > import NewOperator > NewOperator.define(".+", "__dotadd__") > class A: def __dotadd__(self, other) ... > a=A(); b=A() > a.+b > NewOperator.define("compares", "__cmp__") > ------> Exception: "compares" contains characters not allowed in operator. No, it can't be made that easy using traditional parser/compiler techniques. Using non-standard techniques, yes it could be but I'm not sure if someone out there is interested enough to do it. If you want to get started quickly, I would suggest you download all of the Python parser toolkits and look for those that have Python lexers/parsers built in. Choose one and use it. You may already be 80% of the way there. You might want to ask around for help in the compiler sig mailing list: http://www.python.org/sigs/compiler-sig/ Here is a list of parsing tools I collected once: PyLR For efficient parsers in python Includes lexer and parser Supports LR(1) and LALR(1) By Scott Cotton PyLR example

expression: expression 
		PLUS term (addfunc) 
		| term;
term: term 
	TIMES factor (timesfunc) 
	| factor;
factor: LPAREN expression RPAREN (parenfunc) 
	| INT;
kwParsing by Aaron Watters
GRAMMARSTRING ="""
Value ::
 @R SetqRule :: Value >> ( setq var Value )
 @R ListRule :: Value >> ( ListTail
 @R TailFull :: ListTail >> Value ListTail
 @R TailEmpty :: ListTail >> )
 @R Varrule :: Value >> var
 @R Intrule :: Value >> int
 @R Strrule :: Value >> str
 @R PrintRule :: Value >> ( print Value )
"""
Simpleparse Built on top of mxTextTools Generates tables that drive mxTextTools Reputed to be very fast by Michael Fletcher Gentle introduction to more complex mxTextTools package Simpleparse example
file := [ \t\n]*, section+
section := '[',identifier,']', ts,'\n', body
body := statement*
statement := (ts,';',comment,'\n')/equality/nullline
nullline := ts,'\n'
ts := [ \t]*

...
YAPPS Yet Another Python Parser system. Simple, easy to use Generates human-readable parsers Recursive descent Not as fast, powerful or flexible as others Supports LL(1) Spark Scanning, Parsing, and Rewriting Kit John Aycock Very powerful, easy, slow
def p_ifelse_stmt(self, args):
'''
stmt ::= 
  IF expr 
  THEN stmt 
  ELSE stmt
'''
    somePythonCode()
-- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From akuchlin at mems-exchange.org Sat Jul 22 09:41:17 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Jul 2000 09:41:17 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <3hitu4wiq9.fsf@angband.org> <3975C0FA.3A45B105@eecis.udel.edu> <3975D208.2E297375@prescod.net> <3975E3B3.E910A668@eecis.udel.edu> <20000719214128.H9897@xs4all.nl> Message-ID: <3dk8eexoxu.fsf@kronos.cnri.reston.va.us> Thomas Wouters writes: > Any idea why are += and friends still not implemented, after 5+ years of > Python development ? Guido and Tim both claim they wanted it years ago. Yet Probably because it posed some language design problems. When 'obj' is some object, obj += 5 needs to call some method. What if you have code like: 'a=1 ; a += obj'; is it an error? Do you call a separate __r_addinplace__ method? Does 'a' transmogrify from an regular int to an object just from a +=? Will users expect this? --amk From jkraska1 at san.rr.com Sat Jul 29 04:23:45 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 29 Jul 2000 08:23:45 GMT Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> Message-ID: <39829548.BF4E780E@san.rr.com> shochet at my-deja.com wrote: > > I am currently in the middle of hooking up a large external C++ library by > maintaining a database of C++ function pointers that I will call from Python. > If anybody has tried this before, my question is: Is there a good way to call > these function pointers without having to wrap every single one in a Python-C > module? I know windows has something like dlsym or some such, right? C/ From robin at jessikat.fsnet.co.uk Thu Jul 20 03:19:31 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 20 Jul 2000 08:19:31 +0100 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> Message-ID: In article <397684EB.3E0C5D88 at my.signature>, Greg Ewing writes > ., > this looks awful to me, what happened to our leader's preference for minimalism. -- Robin Becker From sdm7g at virginia.edu Thu Jul 20 16:01:50 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 20 Jul 2000 16:01:50 -0400 (EDT) Subject: Python in game development? In-Reply-To: <8l7f69$bon$1@fermi.tro.net> Message-ID: On Thu, 20 Jul 2000, Moritz Voss wrote: > Now, my own language would be an assembler-style thing. The concept is as > follows - every instruction corresponds to an index. Each of these indices, > after compilation, are then translated, during runtime, into direct function > addresses. So what I have is my program that consists of a huge bunch > pointers to C functions (which can have any level of complexity). These > would just be loaded, and called, loaded, and called. I'm not going into the > depths of this here but passing parameters and references is not a problem. If that's your ideal, then look at FORTH. The inner interpreter or VM is just a small loop that executes threaded code. It can be direct-threaded (i.e. pointers) but usually indirect or token threaded is more portable. However, FORTH is really like a high-level typeless interactive assembler: it's good as an implementation language but it's not great as an end-user extension language: game users could crash the game and the computer with pointer bugs. Something like Python provides more insulation: scripting level bugs shouldn't be able to crash the interpreter, not to mention the game or the computer. > > > Thanks :) So designing my own scripting language is easier. > > > > That's of course not true; designing your own scripting language will > > most likely result in an ad-hoc broken design. Read John Ousterhout's original paper on Tcl (on whatever name/URL Scriptics is currently going by ;-) which does a good job of describing the motivation of embedded scripting languages. Typically, folks don't start off trying to design a language, they just want to add "language features" to an application, and so they end up doing a half-assed job of it. ( We won't get into the fact that a few folks think that tcl itself is a good example of the syndrome John describes! ;-) > [ Other stuff deleted ... ] Take a look at Alice -- it's not a game, it's a virtual reality scripting environment, but it's not a bad example of the sort of system you're describing: Python isn't used to power the low level graphics engine, but to write interaction rules for the objects in the VR world. ( Before Randy Pausch moved to CMU, I used to take my kids to Alice demo days here at UVA where they could don helmets and gloves and fight with VR light sabers or walk thru a Doom-like dungeon. ) > Maybe I don't get the python concept. Do you link it statically? Or is the > interpreter *.exe invoked every time? > I'll play around with python, but I found the way to embed it totally > confusing. (That is, of course, because I have never worked with embedded > languages yet). Also, I find no tutorial that clearly tells me how to change > my C variable "X" from within my Python program "Y" that is invoked by the C > Program. You wrap lower level elements of your game in the Python API to make them into Python callable objects and functions. The you can either write the top-level in Python, or embed the interpreter (statically or as a shared library) in your application, and make calls to the interpreter at appropriate times. It's usually this second style that confuses people, as it mixes the hierarchy up a bit: C calling Python calling C calling Python... However, the same mixing goes on in the interpreter itself, which is one of the reasons folks bring up terms like "stackless" and "microthreads" in this discussion. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "There's a new programming language called C+++. It's 50% better than C++, but every time you compile, your modem hangs up." From cut_me_out at hotmail.com Wed Jul 12 10:58:39 2000 From: cut_me_out at hotmail.com (Alex) Date: 12 Jul 2000 10:58:39 -0400 Subject: Why are some infinite recursion stack overflows hard to deal with? References: Message-ID: > Python has a hack to try to deal with that: it checks bounds on the > recursion itself. However, Python's guess is a bit off on windows. It seems to be a bit off on Linux, too. That's where I'm getting the segfault. Alex. From aek at aek.dk.bbs Sun Jul 16 17:10:14 2000 From: aek at aek.dk.bbs (aek at aek.dk.bbs) Date: 16 Jul 2000 21:10:14 GMT Subject: Why make a language case sensitive? Message-ID: <3bQa3c$j9u@openbazaar.net> > > ill take a look at it, although my guess is that I will stick with > > Ultra Edit until I get around to making my own editor >=20 > If we all combined our efforts on "Boa Constructor", "wxDesigner" and > "PythonWin", we may just already have everything we need to kick every = other > language's or IDE's rear-end... : ) Do you have an URL for Ultra = Edit? > You've sparked my curiosity.. www.ultraedit.com should do make sure you look udner downloads, = wordfiles there is one for Python too, but it is only keyword coloring - it is far = from perfect... but I find it nice to work with, one of the main things is the tab pane = - I often work=20 with 10-15 files, and for that a tabpane is a must... > > > > it is said the man who knew the language inside out :-) > > > I'm sorry, I don't follow... > > I was just showing off :-) > > saying yes var is the way you do it, when you do it in > > JavaScript/JScript, and at the same time saying that > > I know JScript inside out >=20 > Ah, I think I could have used a little comma after "it is", as in >=20 > "It is", said the man who knew the language inside out. >=20 > rather than my interpretation: >=20 > It is said that the man knew the language inside out. >=20 > ...a little different, isn't it? : ) sorry :-) I sometimes forget to think about punktuation > > yes the 125 wasn't much fun - I haven't looked at 132 yet, > > I have been busy developing a major online consumer database in > > ASP/Jscript, I actually considdered using Python but I couldn't > > figure out how to set the values Session and Application Objects... >=20 > I also thought 125 wasn't too good, but that's because I thought I had > grabbed the latest version... 132 is a big improvement, you really = should > try it! I will one of the comming days > > aye one thing only - and of course I know the question, isn't > > that what we earthlings are here for? ;-) >=20 > Yeah, but our planet was destroyed five minutes before the = "computation" was > complete. thats what they think... you must remember they expected to hear the = ansewer from the dolphins, but what they had not expected is that a single human = being would figure it out long before the dolphins, and be unable to communicate with the = dolphins... --=20 Anders Eggers - Krag From aahz at netcom.com Wed Jul 19 21:47:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 20 Jul 2000 01:47:26 GMT Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3976371F.210C2C21@uab.edu> Message-ID: <8l5lne$lb$1@slb0.atl.mindspring.net> In article <3976371F.210C2C21 at uab.edu>, Shae Erisson wrote: > >I already have a function that does this in my handy shaetools module, >for me it will always be interleave. Oh, *that's* a good one. All right, anyone else agree that "interleave" is the best suggestion we've had so far? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From erno at iki.fi Fri Jul 14 14:46:39 2000 From: erno at iki.fi (Erno Kuusela) Date: 14 Jul 2000 21:46:39 +0300 Subject: Simple File I/O Question References: <396DF13A.97CC3F5E@bioeng.ucsd.edu> Message-ID: >>>>> "Curtis" == Curtis Jensen writes: Curtis> So, How do I write an int variable to a file? Thanks. you can only write strings into files. you could convert your integer object into a string, but then you could not tell the difference between and a string when you read it back. it might be ok for you, or it might not. if you want more perfect saving of objects into files, you can use the cPickle module to serialize them into string form, and back again. it can handle almost any kind of object, including most of python's built-in types and instances of python classes. see the cPickle documentation for more information on this. -- erno From dgoodger at bigfoot.com Mon Jul 3 10:17:07 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Mon, 03 Jul 2000 10:17:07 -0400 Subject: lambda requirements In-Reply-To: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> References: <000101bfe4ec$010e1c60$a5dfdfdf@ors-x-wt1.or_soft.de> Message-ID: Lambda expressions don't have access to the local namespace. Declaring _list2 as global gets around this problem, but in an "unclean" way (note that _list1 doesn't need to be global, as it's not accessed inside the lambda). A cleaner way to implement the lambda (without globals, or "_"-prefixed local variables) is as follows: _onlylist1 = filter(lambda x, l=list2: x not in l, list1) "l" is bound to "list2" when the lambda expression is evaluated (when the local namespace *is* accessible), which carries through to when the resulting anonymous function is executed by filter (when SymmetricDifference's local namespace is *not* accessible). -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) on 2000-07-03 08:41, Wolfgang Thaemelt (wolfgang.thaemelt at orsoft.de) wrote: > Running the script: > > #----------------------------------------- begin of script > def SymmetricDifference(list1, list2): > # global _list1 > # global _list2 > > _list1 = list1 > _list2 = list2 > > _onlylist1 = filter(lambda x: x not in _list2, _list1) > > return _onlylist1 > > if __name__ == '__main__': > a = [1,2,3,4,5] > b = [3,4,5,6,7] > x = SymmetricDifference(a,b) > > print x > #---------------------------------------- end of script > > gives the error: > > Traceback (innermost last): > File "E:\up\000701\symmdiff.py", line 16, in ? > x = SymmetricDifference(a,b) > File "E:\up\000701\symmdiff.py", line 9, in SymmetricDifference > _onlylist1 = filter(lambda x: x not in _list2, _list1) > File "E:\up\000701\symmdiff.py", line 9, in > _onlylist1 = filter(lambda x: x not in _list2, _list1) > NameError: _list2 > > If the comment characters "#" are removed from the "global" statements > everything works fine. > > Is there some requirement on a lambda violated in the script? From sales at chinaeast.com.hk Mon Jul 17 01:15:16 2000 From: sales at chinaeast.com.hk (Sales) Date: Mon, 17 Jul 2000 07:15:16 +0200 (MET DST) Subject: (no subject) Message-ID: <419.436724.52105150sales@chinaeast.com.hk> It is an honor to introduce our company, China East Technology Ltd (CET). We have been established for about half decade with all facilities located in Hong Kong. We are the manufacturer for the replication of CD-Audio, CD-ROM, Super VCD, Video CD, Business Card CD (50-60MB) , Irregular Shape CD. To give our clients 100% satisfaction is always the goal of us. At each stage of the production, we track our quality with high precision inspection equipment and well-trained inspectors. Apart from the quality assurance, the high level of security for the CD production is also our concern to which the fully viewed security systems equipped in our plant. Moreover, to show our commitment in anti-piracy of copyright, we have already joined with international recognition IFPI coding system from Philips and have the licence for the manufacturing of optical disc by Hong Kong Customs and Excise Department (Licence No. ODML 016). We commit to provide our best quality services: - processing from your master media to having up to 5 colors silk screen printing discs and packed by standard packing or special design. Should you have any questions, please feel free to contact with us either by phone (852) 2898-1082, fax (852) 298-1262 or email sales at chinaeast.com.hk. We anticipate to look forward to serve you in the nearest future. To cancel this mailing service, reply and type "remove" in the subject field. This message is sent in compliance of the new email bill section 301. Under Bill S. 1618 TITLE III passed by the 105th US Congress. This message cannot be Considered Spam as long as we include the way to be removed, Paragraph (a)(c) of S. 1618, further transmissions to you by the sender of this email may be stopped at no cost to you by Click Here with REMOVE in the subject From paul at prescod.net Tue Jul 11 20:48:04 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 11 Jul 2000 19:48:04 -0500 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kf4o5$fao$1@nnrp1.deja.com> Message-ID: <396BC044.3CC7CCD7@prescod.net> Neil Hodgson wrote: > > ... > > One report at http://www.codeproject.com/ says """As all languages now > compile to the same result, performance for all languages from C# and VB to > Python and Eiffel will have exactly the same performance. """. I don't > really believe this as the different capabilities of the different languages > will lead to different performance. Hoever, as all languages will be using > some common substrate code for features like memory management and exception > handling, performance levels for the different languages will be closer than > before. I don't buy that for a second! Languages like Java and Python achieve some level of performance by tweaking the VM and language in concert. You could develop a language that flew like a bat out of hell on Microsoft's VM. You might even call it "C#" :). You could also imagine a language that mixes with Microsoft's VM like oil and water. We'll have to see the VM to know what language that would be. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html From tttok_2000 at yahoo.com Mon Jul 10 03:03:13 2000 From: tttok_2000 at yahoo.com (Ahmed Ahmed) Date: Mon, 10 Jul 2000 00:03:13 -0700 (PDT) Subject: Windows API Message-ID: <20000710070313.13010.qmail@web3406.mail.yahoo.com> Hi Python hackers, I am very new to Python and I am waiting for my first book. I would like to ask you how to use Windows API in Python?. With an example please. __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From rickhigh at aol.com Mon Jul 3 03:31:06 2000 From: rickhigh at aol.com (RICKHIGH) Date: 03 Jul 2000 07:31:06 GMT Subject: Shoud I use Java or Python? References: <00062612550704.00594@dagomachine> Message-ID: <20000703033106.01208.00001108@ng-cp1.aol.com> There are many reasons to choose Java. There are also many reasons to choose Python. Why not have the best of both worlds? JPYTHON (Python that runs in the Java Virtual Machine) www.jpython.org I also wrote an article on JPython for the Java Developer's Journal. you can see it at www.sys-con.com search for JPython. From claird at starbase.neosoft.com Mon Jul 10 01:00:41 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 10 Jul 2000 00:00:41 -0500 Subject: Tkinter and default options References: <8jnbhm$bb6$1@cubacola.tninet.se> Message-ID: In article , richard_chamberlain wrote: >Hi Thomas, > >You can use an option database. If you create a file called optionDB with >for example the following kind of entries: > >*font: Times New Roman >*Button*foreground blue >*foreground black > >You can then apply these via > >root.option_readfile('optionDB') . . . For more on this, see . We're planning a couple more installments on the same subject for later this summer. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From horst at proceryon.at Tue Jul 4 03:25:41 2000 From: horst at proceryon.at (Horst Gassner) Date: Tue, 04 Jul 2000 09:25:41 +0200 Subject: Performance Message-ID: <39619175.5F8B503D@proceryon.at> Hi all! I have implemented a tree view with special items (the base for this work was the TreeWidget from IDLE). The performance is not the best and therefore I ran the profiler today. The following function is one of the slower ones and I would be happy if there are any possibilties to speed this thing up. subItems = {} if s.__subList[level] : for key in s.__subList[level].keys (): # root level is special case! # get all sublevels without recognizing id of sublevel if level==0 or string.find(key, id) == 0 : subItems[key] = s.__subList[level][key] The functions looks for all subitems for a given level and a given id. For each level I have pre-built a list that I have just to go through the items of the given level. Thanx in advance Horst From ramb at synopsys.com Thu Jul 27 11:53:21 2000 From: ramb at synopsys.com (ramb at synopsys.com) Date: 27 Jul 2000 08:53:21 -0700 Subject: how to find out if stringobject is built with CACHE_HASH Message-ID: <87ya2nsh72.fsf@oak.gitaram.com> I am working on a module where I need a string table. From looking at the source in stringobject.h I see that by default for 1.5.2 python strings are already stored in a string table. But the user is free to build a version of python without this feature. Is there a way I can detect this at run time? It would be nice if my module could detect that some essential Python feature was missing and issue an appropriate error message. I just dont know how to get the info I need... Thanks for any info. -Ram From clgonsal at keeshah.penguinpowered.com Wed Jul 12 14:23:55 2000 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Wed, 12 Jul 2000 18:23:55 GMT Subject: Pyexpat build problems... Message-ID: I downloaded PyXML-0.5.5 from the XML-SIG status page on python.org (http://python.org/sigs/xml-sig/status.html). I followed the instructiions in the README, and eventually I get a compile error in pyexpat.c. I'm trying to build this on Red Hat Linux 6.0 on an i586. Here's the error from gcc: ./pyexpat.c: In function `newxmlparseobject': ./pyexpat.c:474: parse error before `xmlparseobject' Line 474 looks like: self = PyObject_New(xmlparseobject, &Xmlparsetype); There isn't anything called "PyObject_New" in the Python headers on my system. There is a "Python_NEW" though, and its parameters look right for this situation. I changed that, and now it compiles. I then installed it, and tried running the included test_pyexpat.py. It doesn't work. It says: ImportError: No module named pyexpat So what's going on? There *is* a pyexpat.so in /usr/lib/python1.5/site-packages/xml/parsers/ now. I have to admit that the way Python loads modules has always seemed like black magic to me though, so I don't know if that's enough. Apparently not, given the error I'm running into... How can I get PyExpat working on my system? -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From musingattheruins at my-deja.com Tue Jul 18 11:26:18 2000 From: musingattheruins at my-deja.com (musingattheruins at my-deja.com) Date: Tue, 18 Jul 2000 15:26:18 GMT Subject: Again: ODBC / Win98 -> crash References: <7BD10B680501D411B9DF009027E06F32011AE8@EXCHANGE> <8kvs3u$c4m$1@nnrp1.deja.com> Message-ID: <8l1su2$r45$1@nnrp1.deja.com> found it... i was tripped up by a python-com-ism. The 'O' in 'ADODB.Connection.Open' command i was running was a small 'o'... import win32com.client conn = win32com.client.Dispatch('ADODB.Connection') conn.Open(connectstring) # was calling... conn.open(connectstring) msft ado returned a 80004005 error... (-2147467259, 'Unspecified error', (0, 'Microsoft OLE DB Provider for ODBC Drivers', '[Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified', None, 0, -2147467259), None) this is misleading; the dsn _does_ exist... not sure what was actually called through com since 'open' was the wrong function name. aside from my own stupidity i have had no other problems with MDAC 2.5. bill :-/ > i have installed the most recent mdac 2.5 and now cannot connect to any > DSNs with ADO!!! and cannot make DSN-less connections with ADO!!! > > tried rolling back to 2.1 (nope... component checker reports v 2.5) > + re-install 2.5 > + re-install python 1.5.2 > + re-install python win32 all > + try again > -------------------------------- > NFG > > no solution yet... _if_ i find one i will post it. > > bill :-( Sent via Deja.com http://www.deja.com/ Before you buy. From gpepice1 at nycap.rr.com Fri Jul 28 22:57:03 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 29 Jul 2000 02:57:03 GMT Subject: Newbie DATA STRUCTURES Question. Message-ID: <398248BC.32DE3CC@nycap.rr.com> Hi all, I have experience with Perl but non with Python. I need to write a script to read a large text file into a structured format. In Perl one can create a list of records using something like pointers. So really you have a list of pointers-- each one pointing to an anonymous record. Each record is some data from a line in the file. Since I learned data structures in languages with pointers (C, pascal) I'm stuck. How does one go about constructing a list of records in python? My python is still pretty weak. I understand how the lists work (a lot like Perl). I understand that you can use objects as records. I don't really get the full OOP though. I guess that you can't make record anonymous in python? Is that right? Can you have pointers? When I was learning Perl I found a manual page on this. Couldn't find a example for Python. Hope that doesn't mean it can't be done. Any hints are welcome!! (reply to email and group) Thanks. From W.Whiten at mailbox.uq.edu.au Fri Jul 21 02:58:29 2000 From: W.Whiten at mailbox.uq.edu.au (Bill Whiten) Date: Fri, 21 Jul 2000 16:58:29 +1000 Subject: Operators for everything (was Re: Operators for matrix) References: <3977AF5E.552F4F42@my.signature> Message-ID: In article <3977AF5E.552F4F42 at my.signature>, Greg Ewing wrote: > Python with its overloadable operators can be thought of > as a meta-language for creating domain-specific languages. > But the number of operators is too restricted for it to > be really good in this role. Operator overloading feels like > something tacked on as an afterthought rather than a > serious feature. I don't think it's unreasonable > to consider whether this situation could be improved. I would prefer the normal oprerators plus an escape character followed by additional characters to define new operators eg @+ @div etc. Regards, ----------- Bill Whiten, W.Whiten at mailbox.uq.oz.au Julius Kruttschnitt Mineral Research Centre, The University Of Queensland, Tel: int +61 7 3365 5888 Isles Rd, Indooroopilly, Fax: int +61 7 3365 5999 Brisbane Qld 4068, AUSTRALIA. From speed at ?.com Fri Jul 28 19:37:14 2000 From: speed at ?.com (Jake Speed) Date: Fri, 28 Jul 2000 23:37:14 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: morpheus at here.not.there (Steve Lamb) wrote in : >On Fri, 28 Jul 2000 22:38:32 GMT, William Tanksley > wrote: >>That's a really cruel statement for you to make. I hope you were >>making it in jest. I've seen nothing to indicate anything waranting >>this kind of attack. > > Neither cruel or jest. I consider "Automagic" coversion on the same > vein >as "Winblows". I have hoped that there were people who were above that, >there are some, but it is here as in everywhere else. The term 'automagic' is commonly used by perl coders and porters. -Speed! From rumjuggler at cryptarchy.org Fri Jul 28 23:30:44 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 03:30:44 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Sat, 29 Jul 2000 01:48:05 GMT, nobody at nowhere.nohow (Grant Edwards) wrote: >In article , Ben Wolfson wrote: > >>Any single element can't be "a single element or a sequence". It can only >>be a single element. > >I thing one could reasonably claim that a length-1 string is both a single >element and a sequence of a single element. Right--it's a sequence, and a single element. I restated this elsewhere in the thread; what I meant was that any arbitrary sequence can be viewed as a sequence or single entity, but any arbitrary single entity cannot necessarily be viewed as a sequence. I suspect I don't have the right vocabulary to express my thoughts here. -- Barnabas T. Rumjuggler SOYLENT COMMUNION IS JESUS! JESUS! -- Lots42, in ark From grey at despair.rpglink.com Sat Jul 29 18:16:08 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:16:08 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 14:16:47 GMT, Steffen Ries wrote: >In this case I would use the dictionary variant of the format string: >"%(a)0d %(b)c:U %(c)s %(d)s %(e)s %(f)s %(g)s %(h)s %(i)s %(j)s %(k)s"\ > % vars() ^^^^^^ Still doesn't change the fact the variables are at the end. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From kpmurphy at my-deja.com Tue Jul 25 12:05:30 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Tue, 25 Jul 2000 16:05:30 GMT Subject: let my widgets use pack/grid/place References: <8lk8o7$lm8$1@nnrp1.deja.com> Message-ID: <8lkds5$q3q$1@nnrp1.deja.com> ok. here's what i'm trying to do. i want to be able to add a label to anything. here's the class: class labelify(Widget): def __init__(self, master, item, thetext, location): frame = Frame(master) label = Label(frame, text=thetext) item.master = frame label.pack(side=location) item.pack(side=location) cnf={} Widget.__init__(self, master, 'frame', cnf, {}) ...and here's the call: entry = labelify(left_frame, Entry(), 'hi', TOP) entry.pack() 1) is that widget extention stuff legal? 2) my label disappears, how do i get around that w/o using self 3) is there an easier way to do this? thanks, -->keith In article <8lk8o7$lm8$1 at nnrp1.deja.com>, Keith Murphy wrote: > how do i let widgets i've created use pack/grid/place? > > i.e. > ... > mywidget('schweet') > mywidget.pack() > ... > > thanks, > -->keith > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Sat Jul 22 16:27:16 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 22 Jul 2000 15:27:16 -0500 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F7974AF5gmcmhypernetcom@199.171.54.194> <3979CE02.D2744B7E@prescod.net> <8F79AAFA3gmcmhypernetcom@199.171.54.154> Message-ID: <397A03A4.68E6CB09@prescod.net> Gordon McMillan wrote: > > Only sometimes. At other times __builtins__ is a dictionary, so > > inp = __builtins__.open("...") > > would fail, and you'd have to use > > inp = __builtins__['open']("....") Why is __builtins__ a shape-shifter? -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From olipt at mayo.edu Fri Jul 28 11:04:20 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Fri, 28 Jul 2000 10:04:20 -0500 Subject: New operators needed? (was Re: Discussion: new operators for numerical computation) In-Reply-To: References: <397C9207.EC0528AA@eecis.udel.edu> <8lqbqu$uhm$1@slb2.atl.mindspring.net> Message-ID: > > By the way, Konrad (hi!) -- what's the status of that reworking? I've > totally lost track of NumPy. The SourceForge project doesn't seem > very active. So how is this going? Is it going anywhere? It is going somewhere (how quickly is another matter). There is a CVS tree under the module numpy2 at the numpy SourceForge site which contains all of the code. I am writing up some design documents which I will place in the tree so that others can at least understand what I'm thinking and contribute if they have the time. My time-schedule was significantly scrunched as I need to finish my work in time to transfer to my new job at the end of the year (where I will still be working on Python). Right now, the basic class structure for both the multidimensional array and the universal functions is written. The supporting C code is maybe 30% done. Some of the C code for the universal functions can be taken from the current implementation, but other parts need to be written from scratch. The slow-down seems to be that those who are familiar enough with the C code to help don't have the time at the moment. If anyone would like to participate, send me mail at Oliphant.Travis at altavista.net and I will give you further details. -Travis From tony at lsl.co.uk Fri Jul 7 08:58:06 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 7 Jul 2000 13:58:06 +0100 Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8k4bh0$f20$1@localhost.localdomain> Message-ID: <00c601bfe812$febfeef0$f0c809c0@lslp7o.lsl.co.uk> Since femigier has mentioned Java projects, I'll mention PJama, at http://www.dcs.gla.ac.uk/pjava/ I don't know what the Perl projects are trying to do, but PJama was aiming at bringing orthogonal persistence (which has been around in various academic languages for a while, but never in the mainstream) into a popular language. Being able to rely on objects still being around at the next invocation of a program without the programmer having to (seem to) take any special action can make certain types of application rather quicker to write ("certain types" including things like GIS, for instance). Unfortunately, I think PJamas chance of ever making mainstream Java died some years back (boo hoo), 'cos it would have been really neat. If that's what's being talked about, it's a bit beyond just having *Pickle around (and if it's not what's being talked about, that's a pity), and I think Zope, etc., aren't quite talking about the same thing either. [One of the other exciting aspects of the Glasgow efforts is/was that they were also looking carefully at the problems of versioning, multi-user access, persistence over LARGE networks, etc. - all the real problems one would get if one actually *used* the stuff] Sorry - for a while I was working in Glasgow, and this just caught my imagination when I was there... Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ Feet first with 5 wheels... My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From moshez at math.huji.ac.il Fri Jul 28 09:37:44 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 16:37:44 +0300 (IDT) Subject: Content of the Perl6 talk In-Reply-To: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> Message-ID: On 28 Jul 2000, Cameron Laird wrote: > is the most pro- > vocative summary I've yet seen of Larry Wall's talk at the O'Reilly > Open Source Convention. Mark-Jason Dominus's typically masterful > provides technical > details. I think at least the first of these will reward a quick > read by everyone involved in planning the futures of, for example, > Python and Tcl. I applaud Conrad Schneiker for his care in prepar- > ing this. I agree. Thanks a lot for bring this information to Python-land: plenty of things we can learn from. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From hzhu at localhost.localdomain Fri Jul 21 00:45:26 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 04:45:26 GMT Subject: Discussion: new operators for numerical computation References: <39771F6D.A9A0A26B@yale.edu> Message-ID: On 20 Jul 2000 20:57:04 -0500, John Lull wrote: >At the dawn of the third millenium (by the common reckoning), >hzhu at localhost.localdomain (Huaiyu Zhu) wrote (with possible >deletions): > >> On Thu, 20 Jul 2000 11:49:01 -0400, Paul Magwene wrote: >> >Konrad Hinsen wrote: > >> >A(+.*)B > >> There is one reason this will not be accepted eventually. The parathesis >> suggests the possibility of a calculas of operators within them, when, in >> fact, operators are hardcoded in the C program. John Lull had given a clear >> explanation why this is so. > >I think your objection here is to the '+.*' bit, rather than the >parentheses. Correct? Do you have the same objection to the simple >(*) ? I do not have objection to this itself. In fact I find this quite readable. The problem is that after the previous long debate I got the feeling that some people would reject anything that puts several symbols together just because "it looks like perl" (which I do not believe is true). I'm worried this diversity might hurt the chance of getting anything accepted at all. This is just a feeling. Look it this way, it is one thing to argue that there is a need for additional operators because the current ones are simply not enough. It is another thing to argue that there need to be a general solution which leaves the door open for future extension. In many situations making anything more general is likely to make it more acceptable. But in the case of operators there appears to be a general hostility towards any extension, esp with many special characters. This could well change in the future, of course, if there is a very strong case. Just my 2c. Huaiyu From pete at visionart.com Tue Jul 18 14:04:23 2000 From: pete at visionart.com (Pete Shinners) Date: Tue, 18 Jul 2000 11:04:23 -0700 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <8l26q5$7r7$1@la-mail4.digilink.net> "Andrew Kuchling" wrote > This is a first experiment in whether I can make a useful, > interesting, somewhat coherent summary of python-dev activity. > If reaction is favorable, and time permits, it may become a biweekly > posting. i'm also excited to see this, andrew. if you have the time to put them together, i'll gladly read each and every one! From newsbunny at noether.freeserve.co.uk Sun Jul 2 17:06:09 2000 From: newsbunny at noether.freeserve.co.uk (Martin P Holland) Date: Sun, 2 Jul 2000 22:06:09 +0100 Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> Message-ID: On Sun, 02 Jul 2000 20:09:51 GMT, Kenneth Payne wrote: >I'm trying to install the Python bindings to Qt/KDE. I've downloaded >the latest sources for Sip. PyQT and pyKDE. I've compiled and >installed Sip and compiled PyQT. All seemed to go Ok, though I had to >fiddle a bit to get them to compile on Suse 6.3. However, on the "make >install" for PyQt, I get an error when the install routine hits a >Python script: > >Traceback (innermost last): > File "", line 1, in ? > File "/usr/lib/python1.5/qt.py", line 16, in ? > import libqtc >ImportError: /usr/lib/python1.5/lib-dynload/libqtcmodule.so: undefined >symbol: __ti8sipProxy >make[3]: *** [install-data-hook] Error 1 >make[2]: *** [install-data-am] Error 2 >make[1]: *** [install-am] Error 2 >make: *** [install-recursive] Error 1 Did you run ldconfig after installing sip? Did you specify the qtdir to ./configure when compiling sip? atb Martin -- http://www.noether.freeserve.co.uk http://www.kppp-archive.freeserve.co.uk From tim.hochberg at ieee.org Fri Jul 21 21:28:52 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Sat, 22 Jul 2000 01:28:52 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: At this point there seems to be main proposals. There are variations on these basic themes, but these two capture the main points: ------------------------------------------------------------------------ Proposal one, which for lack of a better name I'll call Huaiyu's proposal: New Operators: .+, .-, ./, .* NumPy and MatPy would have reversed syntax: the new would operators correspond to element operations in MatPy and matrix operators in NumPy. There is similar syntax proposal that subsitutes @ for '.'. Although it avoides the last disadvantage (below), it seems to have less support. Perhaps because it seems hard to parse visually since @ looks more like a symbol than an operator (in my subjective opinion). Advantages: Similarity to MatLab syntax. Disadvantages: Reversed syntax. Essentially precludes eventual unification of NumPy and MatPy. 5.+A probably won't confuse the parser, but it may confuse me. ----------------------------------------------------------------------- Proposal two, which for lack of a better name I'll call Konrad's proposal: New Operators: (+), (-), (/), (*)[outer], (.)[dot], (|)[solve], (^)[power] NumPy and MatPy would have that same syntax: the new operators correspond to matrix operations in both MatPy and matrix operators in NumPy. There are some other possibilities for operators here. In particular (**) for power. However if we're already abusing bitwise-or for solve, why not abuse bitwise-xor for power? It's possible to imagine this syntax with the operators reversed between NumPy and MatPy, but it would be a waste: (|), (.), and (^) don't make good elementwise symbols, and MatPy would still be stuck without a symbol for outer and solve. Advantages: Syntax for both inner, outer, and solve. Unifies NumPy and MatPy syntax now. Disadvantages: Unfamiliar Syntax for MatLab users. ----------------------------------------------------------------------- Given these two basic proposals, I strongly prefer Konrad's. I think the syntax is more evocative of matrix operations. From the tone of other post on this syntax, this syntax seems to be accepted, perhaps even prefered, by most most people. I also am strongly a proponent of the syntax of various Numeric packages being a similar as possible. In this case NumPy and MatPy. It's not an option for NumPy or some successor to adopt the MatPy syntax. Not only is there a large NumPy codebase, but in NumPy the elementwise operations ^,|, & and % are important. In order for a syntax such as that proposed in Huaiyu's proposal for MatPy to be adopted, an additional 4 (or more I may have missed something) operators would need to be adopted. I don't think this is feasible, particularly since the same effect (and more) could be achieved in Konrad's proposal without the extra operators. That's my opinion and I'm sticking to it, at least till I come up with a different one. -tim From hzhu at localhost.localdomain Fri Jul 21 02:52:00 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 06:52:00 GMT Subject: Discussion: new operators for numerical computation References: <8l85ae$487@stochastic.eng.umd.edu> <8l8dmd$4p0@stochastic.eng.umd.edu> Message-ID: On 20 Jul 2000 22:48:45 -0400, Warren B. Focke wrote: >The old code might not even have to coexist, the new package could >provide compatibility modules: > >-------- Numeric.py -------------- >from MumPy import * >frob_operators(...) >---------------------------------- > >and similarly for MatPy. Interesting. Details? Huaiyu From donn at u.washington.edu Fri Jul 21 13:07:10 2000 From: donn at u.washington.edu (Donn Cave) Date: 21 Jul 2000 17:07:10 GMT Subject: iterating over lines in a file References: Message-ID: <8l9vvu$4qge$1@nntp6.u.washington.edu> Quoth nobody : | Moshe Zadka , in | : | | [...] |> Preventing world war III, when Python achieves world domination. If C is |> allowed to achieve world domination, WWIII will be cause by | |> if(everything_is_ok = 0) { |> launch_missile(); |> } | | i sort of see the point, when you're speaking of beginner programmers | still confused by the common algebra equal sign and trying hard to | sort out assignment from comparison, but i honestly don't see many | more seasoned programmers making that mistake. maybe i'm just weird | that way. (then again, i keep wondering why native speakers of the | english language misplace the apostrophe. i never make that class of | mistakes either, my brain just isn't prone to it. maybe it's the | learning two other languages before english that inoculated me | somehow... both my other ones deal with that sort of grammar very | differently, so maybe i just don't see the apostrophe as something | confusing because of that. who knows.) For what it's worth, apostrophe errors stand out like a sore thumb for me, but I have made many =/== mistakes. Even a few in Python, believe it or not. Donn Cave, donn at u.washington.edu PS. It's a source of constant amazement to me how well some of you non-native speakers can manage, but I suppose if my Portuguese got as much practice it would be pretty good too. For the rest of us native speakers who are wondering what's all this about apostrophes -- it's really simple! 90% of it is "it's" vs. "its", and when there's time to think about it we can easily solve this puzzle by analogy: just change "it" to "he", and consider whether we would write "he's" or "his". We have the same apostrophe here, and likewise in "they're", "that's" and so forth: a contraction of two words. The source of the confusion is a possessive "s" ending that does take an apostrophe, e.g., "pig's eye". But "its" is not "it" + that ending. "Its" is a natural pronoun like "their". Now I suppose we will have no more of this foolishness! And while we're improving our English - remember, "loose/loosed" vs. "lose/lost". From fiona at sitegnome.com Wed Jul 12 23:33:02 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 13 Jul 2000 13:33:02 +1000 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> Message-ID: <396D386E.7F78C777@sitegnome.com> Deja vu ? Didn't I enter this question into FAQTs yesterday ? Fiona. richard_chamberlain wrote: > > Deja vu ? Didn't I answer this question yesterday ? > > Richard > > Lars Lundstedt wrote in message > news:8aKa5.485$652.11285 at newsc.telia.net... > > The subject line says it all. How do I do it? > > Anyone who knows? > > > > /LasseLu > > > > -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From europax at home.com Mon Jul 10 20:57:22 2000 From: europax at home.com (europax at home.com) Date: Tue, 11 Jul 2000 00:57:22 GMT Subject: Anyone used Python for GPIB instrument control? References: <002101bfea4a$6650bcf0$6ae76882@pcpm.ucl.Ac.be> Message-ID: <396A6FF9.4067CEAF@home.com> Dear Cedric, Thank you. Please send both if you can. I now have Borland C++Builder5.0, so I can work with C files. I have heard of swig but haven't used it yet. In the mean time I am having fun taking old HPBasic routines and converting them into much more general and compact Python code. I really appreciate the helpful feedback I have gotten from the newsgroup. Sincerely, Rob. "C?dric Gustin" wrote: > > Hi, > > I'm in the process of writing a Python wrapper for the nigpib functions > using swig. It's almost finished (a few tricky return values to wrap). If > you want, I can send you the interface file for swig, or if you prefer, the > dynamic library I compiled with CodeWarrior for Windows. > > a ?crit dans le message : 39678656.D5F1E689 at home.com... > > Thanks for replying. I found some Python code that uses WinDLL from the > > DynWin package to control GPIB. I am going to try that first. I think > > that the Perl people are using a wrapper for the National Instruments > > gpib-32.dll. I wonder if I can use that wrapper as-is? > > > > Cedric Gustin > gustin at pcpm.ucl.ac.be From jon_mclin at attglobal.net Sat Jul 8 22:52:50 2000 From: jon_mclin at attglobal.net (Jon McLin) Date: Sat, 08 Jul 2000 20:52:50 -0600 Subject: Anyone used Python for GPIB instrument control? References: <39668E65.356337BF@home.com> Message-ID: <3967E902.AE41CF0D@attglobal.net> The Linux Lab project has a gpib driver, and Python wrappers are included. I believe the drivers emulate the NI drivers, so this wrapper should work for you. ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/IEEE488/ From zawrotny at gecko.sb.fsu.edu Fri Jul 28 08:13:08 2000 From: zawrotny at gecko.sb.fsu.edu (Michael Zawrotny) Date: 28 Jul 2000 12:13:08 GMT Subject: MySQL, mSQL, or other database References: Message-ID: Andre, On Fri, 28 Jul 2000, Andre van Straaten wrote: > Adam Durity wrote: > > > > I'm on a fairly tight budget so is there any way i can use MySQL, > > mSQL, or another database package to handle a smple SQL database > > without a DSN. > > AFAIK, MySQL must be installed as root, so if it's not still there .. > mSQL costs for just every private user a license fee. > I'm not aware of others to be installed by you in your home directory. > (Berkeley DB has no SQL, and very simple, but it's free on most Unix > systems.) I think that postgresql can be installed and run as a user if you can compile from source, but be aware that it is big. The final installed size of the whole package, including development stuff, on my Mandrake Linux box is about 12.5MB. If you have a small quota, it will chew it up in a big hurry. The main site for postgresql is http://www.postgresql.org, there is a link to a pre-release version of an upcoming book on postgresql at http://www.postgresql.org/doxlist.html. Hope this helps, Mike -- Michael Zawrotny 411 Molecular Biophysics Building Florida State University | email: zawrotny at sb.fsu.edu Tallahassee, FL 32306-4380 | phone: (850) 644-0069 From torgojr at my-deja.com Mon Jul 10 12:17:29 2000 From: torgojr at my-deja.com (Torgo Jr) Date: Mon, 10 Jul 2000 16:17:29 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395E05CD.E38F642C@webamused.com> <396b3f42.316716812@nntp.interaccess.com> Message-ID: <8kcsu9$r9g$1@nnrp1.deja.com> In article , "Stephen Hansen" wrote: > If Microsoft took the > CONCEPT of the Language, and made their /entire own language/ > around the > /idea/ of it, then they havn't /copied/ anything. They have copied the idea. No crime here, but by doing this they ideally can't claim any kind of "innovation" (but they will most likely do anyways). -- "MD5: An encryption method used on the Internet." - Microsoft IIS 4.0 Glossary Sent via Deja.com http://www.deja.com/ Before you buy. From gbreed at cix.compulink.co.uk Fri Jul 28 12:49:31 2000 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 28 Jul 2000 16:49:31 GMT Subject: Perl is worse! References: Message-ID: <8lsdir$aja$1@plutonium.compulink.co.uk> In article , grey at despair.rpglink.com (Steve Lamb) wrote: > Define a variable to get the name space in there but you don't know > how it > is going to be used later on. a = None. Now make it a list in a > concise > manner. > > for x in range(10): > a.append(x) > > Whoops, can't do it. It isn't a list. So make it a list. > > list(a) > for x in range(10): > a.append(x) > > Whoops, can't do it. None can't be transformed into a list. No, and besides list() doesn't alter its arguments. If you want an empty list, why not a = [] ? You said it was only declared to "get the name space in there". > for x in range(10): > if a: > a.append(x) > else > a = [x] > > All that because of type checking? Jumping through 3 hoops just to > get > done what should be a trivial matter. No, it's trivial: a = range(10) Or, if a is already a list, a = a + range(10) And no, not because of type checking. You said before: """ Simply stated, main reason I don't do C, don't do Java, and dropped Pascal so long ago, the frustration of not being able to take data of one "type" and use it in a different context without jumping through 20 different loops depending on the particular case. To me it isn't char, int, longint, unsigned or signed, strings or whatever, it is data. Lists and hashes (and in Python, tuples) are just structures of data. What "type" that data is is completely subjective and based on the context of the operation. To me, a language that understands that has the feature, not the language that refuses to. """ Well, we're not talking about the "type" of the data here. We're talking about its structure. None and [] have different structures, as do 1 and [1], [1,2,3] and [1,[2,3]]. All languages differentiate structures, and the very thought of not doing so gives me the willies. So, we're talking about coercion of structures, not types. The types have to be there to differentiate structures. So, firstly, you think the list function should coerce a non-sequence into a list with a single entry. Well, you could do that in Python: def list(var): try: return __builtins__.list(var) except: return [var] But it doesn't happen by default. So you use the list constructor, [], instead. What's the problem? There are some structures for which both operations are possible >>> data = (1,2,3) >>> list(data) [1, 2, 3] >>> [data] [(1, 2, 3)] >>> text = "abc" >>> list(text) ['a', 'b', 'c'] >>> [text] ['abc'] In each case, [] changes the structure, list() doesn't. In Python, changing "11" into 11 would also change the structure. So it doesn't happen unless you want it to. You have either x = "11" y = 22 z = int(x)+y # 33 or x = "11" y = 22 z = x+str(y) # 1122 Simply x = "11" y = 22 z = x+y is ambiguous. Different languages define it different ways. That's fine, as far as the machine's concerned. But a poor human being could misread it. In fact, before this thread came up, I assumed Python coerced the int to a string, like Java and Visual Basic do. You assumed it should do the opposite. I think it's nice that the language doesn't let either of us be right, so that when we get it wrong we find out because an expection gets thrown, not because the data get corrupted. You think otherwise, that's fair enough, but if the biggest objection to the language is that you have to use the occasional int() or [], well... You could also define a new operator for string concatenation. Different operators for differently typed results. Oops, types again! Yes, Python is also conservative about type conversions that don't change structure. It would be nice for (1,2,3)+[4,5,6] to work. It doesn't, that's what list() is for, I can live with it. Graham From matt at null.net Mon Jul 10 23:21:31 2000 From: matt at null.net (Matthew Schinckel) Date: Tue, 11 Jul 2000 12:51:31 +0930 Subject: Run Python as separate process with Apache? In-Reply-To: References: Message-ID: On Jul 10, I overheard Randall Parker mutter: > I've done a lot with Java servlets using Apache connected to Tomcat where > Tomcat runs as a single persistent process that gets all requests meant > for it. I am wondering if that same approach can be done with Python. You might also want to have a look at WebWare, although it's still somewhat of a work in progress: -- Matthew Schinckel Good day to let down old friends who need help. From pduffin at hursley.ibm.com Thu Jul 27 05:20:10 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Thu, 27 Jul 2000 10:20:10 +0100 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <200007260357.NAA28707@xevious.dstc.monash.edu.au> <397EDA34.9CFF2BF2@hursley.ibm.com> Message-ID: <397FFECA.F830757D@hursley.ibm.com> Mark Hammond wrote: > > "Paul Duffin" wrote in message > news:397EDA34.9CFF2BF2 at hursley.ibm.com... > > > How likely do you consider the possibility that Microsoft will change > > the IL to allow the non-MS languages to be fully supported ? > > > > Unless the probability is VERY high > > Better than "VERY high" - they have already done it. MS have been > _excellent_ at listening to 3rd party language feedback. For example, the > functional language guys are very impressed that MS managed to get tail > recursion instructions in the VM, in time for the PDC. No current or > future MS languages have this requirement, and not even any of the > (expected to be successful) commercial languages - it was done exclusively > for the "little languages". > > To be quite honest, I have been constantly amazed at the effort MS are > putting into 3rd party languages. It is more than mere hand-waving. > > > what is the point of doing this > > at all as you would end up with a versions of the language which were > > not compatible with the other versions. > > What is the point in making assumptions and statements like this? Try > finding some facts before you attempt to invent more "evil empire > evidence" to support your conspiracy theories. > Stop being so defensive. I asked you because I wanted to know. Your original post said the IL didn't support all that Python (and other languages) needed and you didn't give any indication that MS were prepared to change the IL for those other languages. As they seem to be the second part of the question was irrelevant and you should simply have ignored it. You seem to have started off with some doubts as to whether MS would behave nicely, you said above "To be quite honest, I have been constantly amazed at the effort MS are putting into 3rd party languages. It is more than mere hand-waving." So don't be surprised when others question MS intentions. > But to address your point: JPython is _not_ a perfect emulation of > CPython, but it does allow you entry to the Java playground. Python .NET > is similar - I don't expect anyone will use it when they want to work in > an exclusively Python environment, just like almost no one uses JPython in > that way now... > I don't know Python well so maybe you could tell me how much of the language do you need to implement before you can write useful programs, 50%, 80%, 99% ??? How big a % does JPython implement ? Why does JPython not support all that CPython does ? Is there some problem with Java, or is it down to developer time ? Assuming that MS enhances the IL with all the features that Python needs what % do you think you can get ? Would the set of functionality provided by Python.NET and JPython be the same ? What are the bits (if any) that CPython can do that either one or the other or both of Python.NET and JPython cannot do ? From richard_chamberlain at ntlworld.com Fri Jul 14 17:05:59 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 14 Jul 2000 22:05:59 +0100 Subject: atof problem. References: Message-ID: Hi William, Yes you could use the locale module to do what you want: import locale s="123,456,789.2" print locale.atof(s) As Bjorn said you'll have to get the locale module from somewhere. Otherwise do something like below: import string def rcatof(num): try: flt=float(string.replace(num,',','')) return flt except: return None >>> import myScript >>> myScript.rcatof('123,456.2') 123456.2 Richard William Dandreta wrote in message news:yUqb5.977$tI4.52638 at bgtnsc05-news.ops.worldnet.att.net... > I am having a problem with the atof function. I tried to convert 1,142.00 to > a float but the comma causes a problem. I resolved the problem by removing > the comma but there must be a better way. > > I looked in the documentation and there was mention of the $LANG > environmental variable but it did not tell haw to use it. Also, it mentioned > settings could be made using the functions in locale module. I tried to > import the locale module but I get an error message that the _locale module > doesn't exist. > > Anyone have a clue about this? > > Bill > > From donn at oz.net Fri Jul 28 00:20:58 2000 From: donn at oz.net (Donn Cave) Date: 28 Jul 2000 04:20:58 GMT Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <397FD6B9.5017B952@see.my.signature> Message-ID: <8lr1na$r7r$0@216.39.151.169> Quoth chrish at pobox.com.invalid (Chris Herborth): | According to Steve Lamb : |> On Thu, 27 Jul 2000 15:29:15 GMT, Guido van Rossum wrote: |>> If anything, "Be" made a rather confusing choice of name. |> |> Well, I think it fits if what I hear about what it stands for is true. |> BeOS - Bleeding edge Operating System. Considering they designed it from the |> ground up for the latest hardware at the time it fits. Otherwise, yeah. | | The legend is that, before they had a name, someone took a dictionary home | and got too bored after looking through... they ended at the end of A; | someone asked how far they got, "B" was the reply, someone thought that was | a good name, the rest is history... Only problem I have with it is that it's hard to hear - the uninitiated hear B-O-S. I think it's a rather Pythonic choice of name, in the Flying Circus sense though, but a name with the epic lunatic quality that fits when you set up shop in the nineties with a new OS. "BeOpen" isn't in the same league, a good name to jump on the bandwagon with. Donn Cave, donn at oz.net From richard_chamberlain at ntlworld.com Fri Jul 28 13:13:49 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 28 Jul 2000 18:13:49 +0100 Subject: Values and variables for Tk radio buttons References: <75F7304BB41CD411B06600A0C98414FCB36827@ORSMSX54> Message-ID: Hi Mark, Briefly (I'm just on my way out of the door) you should use IntVar instead. To get the contents of StringVar or IntVar by the way would be IntVar.get() - so in your case that would be servar.get() (or for that matter servar.set(A number) ) Richard Daley, Mark W wrote in message news:75F7304BB41CD411B06600A0C98414FCB36827 at ORSMSX54... > I am trying to struggle through the design of a GUI using Tkinter. I'm not > doing to bad, for a beginner, but I am having a problem retrieving the > values assigned by selecting a certain button. Here is the code I wrote > (forgive the crudity, I'm not savvy with classes yet!): > > from Tkinter import * > import dbi, odbc > import time, os, sys > > servername = ['Server1', 'Server2', 'Server3'] > name = (('None', 'None'), ('name1', 'Name1'), ('name2', 'Name2'), ('name3', > 'Name3')) > > def die(): > sys.exit() > > > root = Tk() > root.title("Test GUI") > servar = StringVar() > namevar = StringVar() > > > for item in range(len(servername)): > b1 = Radiobutton(root, text = servername[item], variable = servar, > value = servername[item]) > b1.grid(row = item, column = 0, sticky=W) > > > for index in range(len(name)): > b2 = Radiobutton(root, text = name[index][1], variable = namevar, > value = name[index][1]) > b2.grid(row = index, column = 1, sticky=W) > > > q = Button(root, text = 'Quit', command = die, width = 10) > q.grid(row = 13, column = 0, sticky = W) > > > root.mainloop() > > > This gives me two columns of radio buttons (the name tuple is longer, and > contrived since I usually get the values from a database). I have no idea > how to get the values from the buttons. Should I be doing something other > than StringVar() for servar and namevar? > > - Mark > ---------------------------------------------- > The opinions expressed are mine, and are not necessarily those of my > employer. > > > From Ed_Stauff at avid.com Sun Jul 30 20:04:42 2000 From: Ed_Stauff at avid.com (Ed Stauff) Date: Mon, 31 Jul 2000 00:04:42 -0000 Subject: Help! example DLL crashes Python on NT Message-ID: <8m2fqq+kecb@eGroups.com> When I try to import the example DLL on Windows NT, I get an "Application Error" dialog for python.exe (with the usual unreadable hex junk), and then python quits after printing "Fatal Python error: PyThreadState_Get: no current thread". I typed "import example" right after launching Python. I've got Python 1.5.2 on Windows NT, and I'm using the python.exe that came with it (I didn't rebuild it from sources). I'm trying to get the example DLL from /python/PC/example_nt to work using Visual C++ 6.0, and I get this error using the example right out of the box, without modification, as described in the readme. Anybody knows what's going on? I'm very experienced with Windows, C, C++, and Visual C++, but I'm a Python and DLL newbie. Any help will be greatly appreciated. Thanks, -- Ed From douglas.schwarz at kodak.com Fri Jul 14 09:01:22 2000 From: douglas.schwarz at kodak.com (Doug Schwarz) Date: Fri, 14 Jul 2000 09:01:22 -0400 Subject: Discussion: Introducing new operators for matrix computation References: <396daf35.3870545@aplnews> <396f0031.3421579@aplnews> Message-ID: In article <396f0031.3421579 at aplnews>, mfein at aplcomm.jhuapl.edu (Matt Feinstein) wrote: >What I mean is, given vectors, e.g., > >d = [d1 d2] >c = [ c1 c2 c3] > >an apparently incorrect element-wise multiplication like > >d'.*c > >would be interpreted as > >[d1 d1 d1; d2 d2 d2].*[c1 c2 c3;c1 c2 c3] Please forgive this slightly off-topic response. Matt, Are you aware of the Generalized Arithmetic Operators (genops) functions I developed for MATLAB? They implement as MEX functions exactly this behavior. For more info please see We now return you to your regularly scheduled Python discussion. -- Doug Schwarz Eastman Kodak Company douglas.schwarz at kodak.com From musingattheruins at my-deja.com Sat Jul 15 08:15:25 2000 From: musingattheruins at my-deja.com (musingattheruins at my-deja.com) Date: Sat, 15 Jul 2000 12:15:25 GMT Subject: ASP Questions References: <8kmqkq$40b$1@plutonium.compulink.co.uk> Message-ID: <8kpkko$40b$1@nnrp1.deja.com> You can also call stored procs without the Command object by calling Execute(SQLString) on the connection object... use SQLString = "EXEC MyProcName param1, param2, etc" to call the proc. Be sure that the return is only one recordset or you'll confuse the heck out of youself... (if using SQL Server 7.0 you can select 'results in grid' if there is more than one tab (i.e., grid #1, grid #2) then you have an extra select statement floating around.) Also, avoid OUTPUT params if you can. Use select at the end of proc to return a 'tuple'... (select @myret1 as "Result1", @myret2 as "Result2"), MoveNext() to the first record. > > #Here is the line you are probably missing. > > cmd.CommandType = constants.adCmdStoredProc > > No, I'm setting it to 4 which should be equivalent. > > > #Now I append the parameters... > > for parm in params: > > cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], > > constants.adParamInput, parm[2], parm[3])) You might also try NAMING your params. See command object name. Then the order should not matter. > params = list(params) > params.reverse() > > before that. I don't see why it should make a difference, but it does. Regards :-) Sent via Deja.com http://www.deja.com/ Before you buy. From weeks at golden.dtc.hp.com Thu Jul 27 10:10:12 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 27 Jul 2000 14:10:12 GMT Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> Message-ID: <8lpfs4$ma7$1@news.dtc.hp.com> Steve Purcell (stephen_purcell at yahoo.com) wrote: : Yay! Python luddites unite! To this call I must reply: Count me in! Less is More. Much more. Greg From bvdpoel at uniserve.com Sat Jul 1 13:02:29 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 01 Jul 2000 10:02:29 -0700 Subject: Class vrs. function Message-ID: <395E2425.8F6F8757@uniserve.com> I see sample code for python/tkinter which looks like this: class main: def __init__(self): ...do a bunch of init stuff a=main() root.mainloop() What I'm wonder is why the use of a class for this. Wouldn't it be just as clear and perhaps more efficient to do ...do init stuff root.mainloop() Is this just a good habit being developed by those who think that classes are better than functions, or god forbid, inline code? While I'd asking, are there any penalties in the speed/memory usage departments on using classes vrs. functions? In case this isn't obvious I'm an old programmer who figured that C was a really nice, almost-cross-platform assembly language.... -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From max at alcyone.com Fri Jul 28 15:00:51 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 28 Jul 2000 12:00:51 -0700 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <3981B034.80FACD08@fft.be> Message-ID: <3981D863.F71AC0AC@alcyone.com> Gregory Lielens wrote: > Checking your other posts, it seems to me that the reasopn you are > able > to think about data (in particular numerical data) without caring > about > its type is that you always link the data to a text representation > mentally... > > And from your example, it is quite clear that Perl (I never used it, > so > I guess here...) also make this link quite strongly...still > guessing...maybe because now or in a previous implementation, numbers > are/were actually stored as string internally? In Perl there is no strong notion of type, internal to objects. However, there _is_ a notion, because otherwise it would be hard to get work done. For instance, the ==, <, >, etc. relational operators treat their arguments as numbers. If you want to treat them as strings, you use different operators (eq, lt, gt, etc.). Perl doesn't make a distinction between types at the object level, but it has to at the _operator_ level. -- 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 only source of knowledge is experience. \__/ Albert Einstein Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From david_ullrich at my-deja.com Fri Jul 28 13:18:56 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Fri, 28 Jul 2000 17:18:56 GMT Subject: Searching in an html file References: <8lrrgd$9o7$1@nnrp1.deja.com> Message-ID: <8lsf9q$pfr$1@nnrp1.deja.com> In article <8lrrgd$9o7$1 at nnrp1.deja.com>, pauljolly at my-deja.com wrote: > Dear all, > > I have managed to write the code to retrieve an html file from a given > address, and transfer this to a variable. I am now trying to search for > a ° within the file, using the re module. I cannot however get it > to work. My code is as follows: > > import re > searchstring=re.compile('°') > result=searchstring.search(htmlcode) > > where htmlcode is the code from the page retrieved. > > This gives result=NONE. What is going wrong here? I know that ° can > be found within the page, I have checked in TextPad. I am completely > stuck because when I try the same search but on the following string: > > "Thisisastringonwhichiwilltestthecodetofind°withinthetext" > > it finds the ° without any problem. The only difference I can see > between the two strings is their length. The htmlcode string is 24KB, > the string above much less. What is going on here? Where did htmlcode come from? (If it came from something that knows about html it could be that the entity reference has already been replaced by the appropriate entity before you search for it. If you just said htmlcode=open('thefilename.html','r').read() then never mind...) I have no problem with strings much larger than 24K: import re searchstring=re.compile('°') htmlcode='0'*300000 + '°' result=searchstring.search(htmlcode) print result.start() DU > Any help is much appreciated. > > Paul Jolly > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From jhe at webde-ag.de Fri Jul 7 13:05:55 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Fri, 7 Jul 2000 19:05:55 +0200 Subject: How to print to stdout in binary References: <8k1kn5$mkt$1@nnrp1.deja.com> <3965408E.DDD4A2@pehr.net><8k4cjr$fic$1@nnrp1.deja.com> Message-ID: <8k52il$1p2$1@pollux.ip-plus.net> "Robin Becker" schrieb im Newsbeitrag news:Oo9IrBA89bZ5EwGY at jessikat.demon.co.uk... > try creating wstdout.py > > import sys > sys.stdout.write('123456789\n') try: import msvcrt, os msvcrt.setmode(1, os.O_BINARY) except: pass import sys sys.stdout.write('123456789\n') [d:\tmp]py binstdout.py >test [d:\tmp]ls -l test -rw-r--r-- 1 544 everyone 10 Jul 7 19:04 test From neilh at scintilla.org.bbs Sun Jul 16 08:50:01 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 16 Jul 2000 12:50:01 GMT Subject: Pythonwin: problem with syntax highlighting Message-ID: <3bQN2P$lf_@openbazaar.net> Telling us what version number will help. Using PythonWin 132 is best if you are running Python 1.5.x. > There's just one irritating thing, not with the language itself, but > with the pythonwin editor. I havn't managed to make autocompleting and > syntax highlighting to work. Autocompletion requires some symbols to be loaded. I don't know all the ways this can happen but in the interactive window try import win32api win32api. After you press the '.' you should see a list appear. Syntax highlighting should just happen - it even looks as though Mark has dropped the option to turn off syntax highlighting. > I've checked and unchecked the options in > the GUI, but it didn't change a thing. I've looked into the registry > to see if a component had'nt been registered properly during setup but > I didn't see anything wrong. > > What could prevent my machine from displaying online help ? Help is bad too? Your machine is posessed by the anti-Python! Try uninstalling and reinstalling. And use Python 1.5.2 and PythonWin 132. Neil From e.smith at cs.bham.ac.uk Tue Jul 4 11:18:42 2000 From: e.smith at cs.bham.ac.uk (Elliot Smith) Date: Tue, 04 Jul 2000 16:18:42 +0100 Subject: Entry widgets Message-ID: <39620052.53C1@cs.bham.ac.uk> Hello all, I've tried this question before, and got no answer at all, so I thought I'd give it another go as the situation is getting desperate! I can't find any reference to this anywhere. I've been having problems with Entry widgets in Tkinter, running under sunos5. For some reason, when I double click on them, Python closes the whole application and reports 'Bus error'. Any ideas? I've tried overriding the binding for double mouse clicks to no avail. Elliot -- homepage: http://www.cs.bham.ac.uk/~ezs/ "A scholar is just a library's way of making another library" (Richard Dawkins) From bjorn at roguewave.com Fri Jul 7 15:04:20 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 07 Jul 2000 13:04:20 -0600 Subject: Flushing sdtout References: Message-ID: <396629B4.82821B3@roguewave.com> ...or use a class class FlushFile: def __init__(self, f): self.f = f def write(self, txt): self.f.write(txt) self.f.flush() sys.stdout = FlushFile(sys.stdout) print "this string is autoflushed :-)" -- bjorn Olivier Dagenais wrote: > > Do a blank raw_input, sort of like: > > print 'Enter type of DRC to run from menu -->' > sys.stdout.flush ( ) > selection = raw_input ( ' ' ) > > Also, you could write your own function: > > def print_flush ( message ): > print message > sys.stdout.flush ( ) > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Aaron Ginn" wrote in message > news:sn4s61hl9t.fsf at motorola.com... > > > > Is there a simple way to flush stdout on every print statement similar > > to the $| variable in perl? Currently, I'm adding a > > sys.stdout.flush() statement after every single print statement in a > > script in order to write the run to a logfile, but I'd like to simply > > be able to tell python to do it after every print statement without > > explicitly telling it to. > > > > Also, how can I flush the string in an input statement to stdout > > before the input is provided by the user? For example, here is a > > code snippet: > > > > print '------------------------------' > > sys.stdout.flush() > > print ' Type of DRC run.' > > sys.stdout.flush() > > print '------------------------------' > > sys.stdout.flush() > > print '1) DRC (default)' > > sys.stdout.flush() > > print '2) Antenna DRC check' > > sys.stdout.flush() > > print 'q) quit' > > sys.stdout.flush() > > > > while 1: > > selection = raw_input('Enter type of DRC to run from menu --> ') > > sys.stdout.flush() > > > > This prints the following to stdout: > > > > ------------------------------ > > Type of DRC run. > > ------------------------------ > > 1) DRC (default) > > 2) Antenna DRC check > > q) quit > > > > Unfortunately, it does not print the string in the raw_input statement > > until the user has selected from the menu. Thus the output looks like > > this: > > > > 1 > > Enter type of DRC to run from menu --> > > > > I want the string printed to stdout before the user has to make a > > selection. Is there a way to do this? > > > > Thanks, > > Aaron > > > > -- > > Aaron J. Ginn Motorola SPS > > Phone: (480) 814-4463 SemiCustom Solutions > > Fax: (480) 814-4058 1300 N. Alma School Rd. > > mailto:aaron.ginn at motorola.com Chandler, AZ 85226 > > -- > http://www.python.org/mailman/listinfo/python-list From hzhu at localhost.localdomain Tue Jul 18 20:02:02 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Wed, 19 Jul 2000 00:02:02 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: On Tue, 18 Jul 2000 23:35:30 +0100, Penfold wrote: >I'd expect it would be ... >(i) you're asking that the grammer be dynamically changed *as* the module >is being parsed. >(ii) are you going to restrict the possible new tokens >(iii) How does the python interpreter work ... for example the expression >a+b >results in byte code of the form >LOAD_FAST a >LOAD_FAST b >BINARY_ADD > >That is, the BINARY_ADD operation deals with the issues of whether these are >instance types (and thus __add__, __radd__, __coerce__ >etc should be invoked). At least thats what Ive always believed (never >checked the source ;-) ). So what gets generated >for a .* operation? An explicit call? does coercion, or the equivalent of >__radd__ ever happen? What happens when a and b >are not classes? [well, a TypeError obviously?] > >I mean there are issues there ;-) Hmm, so I see the issue - an operator is supposed to do a lot of things, all of which expressed as an opcode (or whatever BINARY_ADD is called). This opcode is only available in the C source, so there is no direct pathway to go from .* to __dotmul__ purely inside python. Let's see what happens to a class, which also can do a lot of things, but all of them are available within python. Why? Because the internal things are in __dict__. So why isn't there be something like a __dict__ that holds all the properties of operators, including opcode? Maybe because operators are not supposed to change any way? Maybe because this stage is even lower than the implementation of dictionary? Or is there more fundamental technical reasons (Like making the compiler much slower)? > I know I'm not supposed to respond to rant, but this has come up many times so I thought I might just do it once and for all. [ about + - * / being easily understandable but no clue about additional operators which have no implicit meaning] The implicit meaning is "the dot in front means the operator is elementwise". Tell a newbie this, then show him the following piece of code [1,2] + [10,20] == [1,2,10,20] [1,2] .+ [10,20] == [11, 22] Then give him two minutes for brainstorming. He probably will figure out what .* .- ./ do. >But why stop here, why not proliferate the language with #!'s. Hell, I want >python to be more like perl, I have posted another article dealing with comparison with perl. It hasn't come up yet. I may repost it. > Problem: Why do I have to write x.sendMessage(y.createMessage(txt))? I >should be able to write x &^% (y *&^ txt) Well the problem is not with additional operators, but with the symbols you choose to represent them. The effect is similar if you write x.adadsfsfdasf(y.cuaiouaoiu(txt)) You are allowed to do so in python. It wouldn't be Python's responsibility if You actually do it. Why would it make Python any worse if it allows you to do the other thing and You actuall do it? The best way to choose a meaningful symbol in your field is to use the ones people have used for hundreds of years, or if your field hasn't existed that long, spell things out explicitly. It is a general rule that the newer the field, the more verbose the names. When things settle down the notations will become more concise. When the total number reduces to less than 7 :-) you could even start to consider using binary operators if all of them have a simple rule that maps to existing arithmetic operators that a newbie understands in two minutes. > > > >> 5. Use a customized parser in python, with some compile tools? >> >> Advantage: can change anything. Can fine tune before settle down. >> Disadvantage: can change anything. Slower than 1. Don't know how to >use >> it. (But maybe they can be turned into option 1?) > >Look up mxTextTools at vex. Its not very nice to use itself, but there is a >wrapper API provided by someone else >for custom lexers/parsers. Please if some one can figure out how to use it to accept .+ as operator and use __dotadd__ to define it. After that I think I can figure out the rest. :-) >> elementwise operators might be useful elsewhere, like >> >> ["%5.2f", "%-8s", "%.2g"] .% [pi, 'short', 1] > >hmm, is that the same as "%5.2f %-8s %2g" % (pi, 'short', 1). > No. The result is a list. >> ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", "boy", "boy"] >> >[does it automatically add the spaces between the words too ;-)] >yes, because >map(lambda x,y: x+"is"+y, ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", >"boy", "boy"]) With a little correction. For named lists it is either names .+ "is" .+ types map(lambda x,y: x+"is"+y, names, types) Whichever is deemed cleaner, I suppose there really is no need for list comprehension after all. The probelm is, of course, you cannot make a C module to speed up elementwise operations with the latter notation because it uses builtin syntax rather than method call. >ever-rantingly-yours, > never-reply-to-rant-again-ly y'rs Huaiyu From rbill at digisprings.com Fri Jul 28 12:12:03 2000 From: rbill at digisprings.com (Robert W. Bill) Date: Fri, 28 Jul 2000 10:12:03 -0600 Subject: Socket question: arbitrary port In-Reply-To: <8F7EB13BAbeablebeable@209.155.56.81> References: <39805D19.C005F16F@hotmail.com> <8F7EB13BAbeablebeable@209.155.56.81> Message-ID: On 28 Jul 2000, Mitchell Morris wrote: > rbill at digisprings.com (Robert W. Bill) wrote in > : > > > > >On Thu, 27 Jul 2000, Jean Bergeron wrote: > > > >> Is it possible to connect a socket through an arbitrary port? > >> In other words, can Python find an available port without having the > >> programmer (or user) specify a particular port number? > >> > >> Any help would be appreaciated! > >> Thanks! > >> > >My understanding is (assuming you're talking AF_INET) is that > >it requires a port for the bind call for a server socket and a destination > >port to connect to for a client socket. So you would have to > >identinfy the port for those calls. > >i.e.- > >import socket > > > >s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > >#you need a connect or bind to do something with it > >s.bind('127.0.0.1', 80) #second num is port > >s.connect('www.python.org', 80) #same here- need destination port num > > > >the lazy persons's method to pick the first available port (warning: bad > >idea/example): > > > >portNum = 1 > >while 1: > > try: > > s.bind('127.0.0.1', portNum) > > break > > except socket.error, why: > > # could analyze why here > > portNum = portNum + 1 > > > >--replace the above s.bind with s.connect('someplace', portNum), and you > >have a great way to stir trouble :) > > > >Without details I might have missed the point, but the generalized answer > >is you provide a port for connect/bind in your program by some means > >rather than python picking it. > > > >-robert > > > > > > Ewwwwwwww .... don't ever ever ever do that again. Bad dog! No biscuit! > > Contrary to your reasoning, you only need bind *OR* connect. If you're > going to listen, you bind. If you're not going to listen, you connect. I > would swear this is in the Python distribution somewhere. [rummaging about > in the directory tree] There is an example in Lib/test/test_socket.py in > your Python distribution. An even shorter example is here: > > C:\>python > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import socket > >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) > >>> s.connect(('www.pythonlabs.com', 80)) > >>> s.send('GET / HTTP/1.0\r\n\r\n') > 18 > >>> print s.recv(8192) > [deletia] > >>> s.close() > Mitchell, Consult line #9 of my reply and note the use of the word *or*!!!!!! I want my bisquit! :) -robert From hzhu at localhost.localdomain.bbs Mon Jul 17 02:10:01 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 17 Jul 2000 06:10:01 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bR26P$l00@openbazaar.net> On Sat, 15 Jul 2000 23:38:30 +0100, Gareth McCaughan wrote: >Huaiyu Zhu wrote: >> How would you write this in list compresension (in less than 10 lines)? >> >> B*(sin(A*x+b).*(A*y)/3)/C >> >> Note that * is matrix multiplication and .* is elementwise. Note that C is >> a matrix so the / is matrixwise. If you want to write everything as for >> loops it takes at least 30 lines, without any decent error analysis. > > B*[p*q/3 for p in A*x+b, q in A*y]/C Someone else had already given a similar answer. But more work is needed for such things to work: The x, b and y could be matrices, so p and q need to be double loops. The [ ... ] need to be a double lists. Is list comprehension defined for this? B*[..]/C would not work without a cast from double list to matrix. For all these errors, what would the error messages look like? Do they involve the dummy indices p and q? A previous answer also reused the name b for the dummy variable, which would make the error even more obscure. Besides, the main point of using matrix is to be free from specifying loops over indices with dummy names. Compare this double loop with extra syntax with a single operator .* and you may wonder why this is considered at all. Since this is going way off original topic I'll stop here. I admit that I'm at fault to a large extent. As to the question of what's the precedence of the proposed .* like operators, they are the same as their ordinary counterparts, because they become identical when the operands are numbers or 1x1 matrices. Huaiyu From alex_c at mit.edu Tue Jul 18 08:19:46 2000 From: alex_c at mit.edu (Alex Coventry) Date: 18 Jul 2000 08:19:46 -0400 Subject: Small correction. Re: pty.py: any example code out there? References: Message-ID: Oops, I introduced some syntax errors while I was ripping out the parts that contact me. Whereever you see a line containing 'alert_alex' put a 'pass' on a line above it with the same indentation. Sorry. Alex. From loewis at informatik.hu-berlin.de Wed Jul 19 12:27:54 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Jul 2000 18:27:54 +0200 Subject: Does Python code >.require<< a run-time environment?? (New to Python) References: <20000714153818.28906.qmail@web5302.mail.yahoo.com> Message-ID: Dave Williams writes: > I am new to Python... and I was wondering... Does Python code compile > to any form of .exe file, or do you require a run-time interpreter? > If the second is the case, how do you distribute applications?? Is > it a light-weight run-time (small space, easy to include)... and do > the end-users have to go through alot of steps to get to run it?? Sure. Please have a look at http://www.python.org/doc/FAQ.html#4.28 Regards, Martin From ioadler at my-deja.com Thu Jul 13 18:22:39 2000 From: ioadler at my-deja.com (ioadler at my-deja.com) Date: Thu, 13 Jul 2000 22:22:39 GMT Subject: Memory leaks References: <395F78BF.CBEAA090@synacon.ch> <8F6667253gmcmhypernetcom@199.171.54.154> Message-ID: <8klffg$ql5$1@nnrp2.deja.com> In article <8F6667253gmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > Ingo Adler wrote: > > [strange leaks in SWIG'd code] > > >I have some simple Python-Code which generated memory leaks (ca. 4MB): > >(The real code is more complicated, but I could strip it down to this > >simple example = the smallest example with the memory leak.) > >//--------------------------- > >x = X() > > > >for i in range(100000): > > y = x.getY() > > y.getNumber() > >//--------------------------- > > Doing things in the "obvious" way from your (snipped) incomplete code, I > get no leak when using MSVC 5. > > - Gordon Hi Gordon, Finally, I reproduced the leaks under the control of "Code Guard", which can list them. For every call in the loop there is an entry like this (I translated it to English): Error 00175. 0x300010 (Thread 0xFFE455D5): Ressource-Leak: memory block (0x2732848) has never been released memory block (0x02732848) [Size: 40 Byte] was allocated with malloc call stack: 0x004AECDD(=FORTUNA.EXE:0x01:0ADCDD) \Python\Objects\stringobject.c#145 0x0044BE99(=FORTUNA.EXE:0x01:04AE99) \src\fortuna_wrap.c#769 0x0044F969(=FORTUNA.EXE:0x01:04E969) \src\fortuna_wrap.c#1824 0x0046B9F9(=FORTUNA.EXE:0x01:06A9F9) \Python\Python\ceval.c#2359 0x0046B892(=FORTUNA.EXE:0x01:06A892) \Python\Python\ceval.c#2324 0x0045EDBE(=FORTUNA.EXE:0x01:05DDBE) \Python\bltinmodule.c#126 That makes 40*100000 = 4 MB as I measured roughly before. fortuna_wrap.c is the code generated by swig: ... SWIGSTATICRUNTIME(PyObject *) SWIG_NewPointerObj(void *ptr, _swig_type_info *type) { char result[512]; PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, type->name, NULL); #else SWIG_MakePtr(result,ptr,type); // line 769 robj = PyString_FromString(result); #endif return robj; } ... #define Y_getX(_swigobj) (_swigobj->getX()) static PyObject *_wrap_Y_getX(PyObject *self, PyObject *args) { Y *_arg0; PyObject *_resultobj,*_argo0=0; X *_result; self = self; if(!PyArg_ParseTuple(args,"O:Y_getX",&_argo0)) return NULL; if ((SWIG_ConvertPtr(_argo0,(void **) &_arg0,SWIGTYPE_Y_p,1)) == -1) return NULL; _result = (X *)Y_getX(_arg0); // line 1824 _resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE_X_p); return _resultobj; } ... So it happens in PyString_FromString - but only with this loop (= both functions in the loop). Any suggestions? Ingo Sent via Deja.com http://www.deja.com/ Before you buy. From schneiker at jump.net Sat Jul 29 22:37:31 2000 From: schneiker at jump.net (Conrad Schneiker) Date: Sat, 29 Jul 2000 21:37:31 -0500 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> <3981EDA1.1CB1CE07@ajubasolutions.com> Message-ID: <8m047k$8bl$1@news.jump.net> Hi, "Neil Hodgson" wrote: > > A comment on the hope for a common runtime: I think this will buy you > > less than you think. ... > > A common runtime could at least produce a common library interface. > Wrapping each API once each for Perl, Tcl, Ruby and Python is a waste of > time. Some APIs will be difficult to wrap because of callbacks or threading > issues etc., but a lot are simple and could be wrapped generically. > > Maybe Mark Hammond's enthusiasm for .NET is partly a desire to never > again have to run SWIG over Microsoft's latest API changes. With .NET, all > the languages have access to all the libraries. > > A message covering related topics just appeared on c.l.ruby You can now look it up directly at: http://x58.deja.com/[ST_rn=ps]/getdoc.xp?AN=652250865&CONTEXT=964923186.1541 800008&hitnum=5 > so they may want to be included too. Yes, please do (at least for the time being). Thanks, Conrad From smoriano at sicon.net Tue Jul 25 08:05:45 2000 From: smoriano at sicon.net (sergio) Date: Tue, 25 Jul 2000 14:05:45 +0200 Subject: SIMPLE QUESTION Message-ID: <397D8299.27F82E6D@sicon.net> Hi again , i try to explain it better this time. From a dll of a pdf converter , i make a py file. And i want to use the next function in order to initializate a new printer driver: def DriverInit(self, PrinterName=defaultNamedNotOptArg): return self._ApplyTypes_(0x1b, 1, (3, 0), ((8, 0),), 'DriverInit', None, PrinterName), included in the class: class ICDIntf(DispatchBaseClass): When i try to call it i get the error File "", line 0, in ? TypeError: unbound method must be called with class instance 1st argument. I suppose its refering to the argument 'self' so, how can i get the class instance to pass it to the function. From richard_chamberlain at ntlworld.com Tue Jul 11 19:15:49 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Wed, 12 Jul 2000 00:15:49 +0100 Subject: path References: <3pNa5.17986$6y5.14385230@news2.rdc2.tx.home.com> Message-ID: Hi David, By path what do you mean? If you want to change the current working directory then the following will do what you want: import os print os.getcwd() # displays current directory os.chdir('c:\\windows\\desktop') Richard David L. Heald Jr. wrote in message news:3pNa5.17986$6y5.14385230 at news2.rdc2.tx.home.com... > This may seem ike a dumb question, but how do I change the path in > pythonwin? > > From ame at swipnet.se Sun Jul 23 06:28:06 2000 From: ame at swipnet.se (Anders Eriksson) Date: Sun, 23 Jul 2000 12:28:06 +0200 Subject: PIL and HPGL References: <4682ls4ukdce8uipv7hcgfjkihv6teoppj@4ax.com> <39799A48.2D2F8FF6@arrakis.es> Message-ID: <0rajnsssoj64fqp28hpohc3c8f2pu7al0a@4ax.com> On Sat, 22 Jul 2000 10:54:36 GMT, Marcos S?nchez Provencio wrote: > >You might try printing to postscript in AutoCAD and converting the >resulting .ps or .prn to pdf with ghostscript. Hello Marcos! Thanks for the reply! Yes I am a aware about the possibility to use postscript and ghostscript to create a PDF. This how I do it today. I just wanted to use Python to do this. The optimal would be to read the DWG directly and create a PDF ;-) but I settle for using HPGL of DXF. I just saw that ReportLab has release version 1 of there Python module for handling PDF so maybe this is a better way than using PIL, // Anders From mmillikan at vfa.com Fri Jul 28 16:16:12 2000 From: mmillikan at vfa.com (mmillikan at vfa.com) Date: 28 Jul 2000 16:16:12 -0400 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: Steve, Are you saying that data is naturally untyped and that operations/functions are naturally typed (and that this typing of o/f's is unambiguous)? Mark From denalione at my-deja.com Tue Jul 11 09:35:06 2000 From: denalione at my-deja.com (Dale Burnett) Date: Tue, 11 Jul 2000 13:35:06 GMT Subject: PythonService file creation References: <8kbel1$qrp$1@nnrp1.deja.com> <8F6D93D27gmcmhypernetcom@199.171.54.154> <8kd7cv$3uk$1@nnrp1.deja.com> Message-ID: <8kf7q9$hl8$1@nnrp1.deja.com> In article <8kd7cv$3uk$1 at nnrp1.deja.com>, Dale Burnett wrote: > In article <8F6D93D27gmcmhypernetcom at 199.171.54.154>, > gmcm at hypernet.com (Gordon McMillan) wrote: > > Dale Burnett wrote: > > > > >When running my app at the command prompt using the debug option I > can > > >create a new file and write to it. When the app is started via > Control > > >Panel/Services the file is not created and written too. I have used > the > > >python native file functions and the NT api CreateFile() function. I > > >have tried running the service using the System Account with Interact > > >with Desktop checked and specifying an account. > > >Any suggestions? > > > > Besides the account it's running under, the only other problem I can > think > > of is relying on some (mistaken) notion of what the current directory > is. > > > > I've written files from services, so I know there's no showstopper. > > > > - Gordon > > > > Do you happen to have a code snippet handy? > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Thanks for the tip. I was creating the file in the current directory. The current directory is different when running the service through the debugger than when running from Control Panel. Thanks Dale Sent via Deja.com http://www.deja.com/ Before you buy. From stephen_purcell at yahoo.com Wed Jul 26 18:16:36 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 27 Jul 2000 08:16:36 +1000 Subject: s = shelve.open(blah), s.items() Attribute Error In-Reply-To: ; from jblaine@kickflop.ne.mediaone.net on Wed, Jul 26, 2000 at 08:28:56PM +0000 References: Message-ID: <20000727081636.A9696@inkontact.com.au> Jeff Blaine wrote: > It seems that shelf objects do not have an .items() method like > normal dictionary objects. > > Is this true? You're right, according to the source. > If so, it should probably be pointed out in the docs under 'Restrictions' > for shelve. And also, is there a reason? Probably an omission on the part of the author, or it might be considered an undesirable operation, since it is equivalent to slurping everything out of the shelf file. You can try something like: s = shelve.open(blah, 'c') i = map(s.__getitem__, s.keys()) to get the same effect, but that raw reference to '__getitem__' is bad form. Best to stick with: s = shelve.open(blah, 'c') i = map(lamba s=s, k: s[k], s.keys()) or simply: s = shelve.open(blah, 'c') i = [] for k in s.keys(): i.append(s[k]) -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From olivierS.dagenaisP at canadaA.comM Sun Jul 16 16:59:41 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 20:59:41 GMT Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> <43pc5.394$uj.2466@news101.telia.com> Message-ID: <1npc5.89253$W35.2043008@news20.bellglobal.com> > ill take a look at it, although my guess is that I will stick with > Ultra Edit until I get around to making my own editor If we all combined our efforts on "Boa Constructor", "wxDesigner" and "PythonWin", we may just already have everything we need to kick every other language's or IDE's rear-end... : ) Do you have an URL for Ultra Edit? You've sparked my curiosity.. > > > it is said the man who knew the language inside out :-) > > I'm sorry, I don't follow... > I was just showing off :-) > saying yes var is the way you do it, when you do it in > JavaScript/JScript, and at the same time saying that > I know JScript inside out Ah, I think I could have used a little comma after "it is", as in "It is", said the man who knew the language inside out. rather than my interpretation: It is said that the man knew the language inside out. ...a little different, isn't it? : ) > yes the 125 wasn't much fun - I haven't looked at 132 yet, > I have been busy developing a major online consumer database in > ASP/Jscript, I actually considdered using Python but I couldn't > figure out how to set the values Session and Application Objects... I also thought 125 wasn't too good, but that's because I thought I had grabbed the latest version... 132 is a big improvement, you really should try it! > aye one thing only - and of course I know the question, isn't > that what we earthlings are here for? ;-) Yeah, but our planet was destroyed five minutes before the "computation" was complete. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From gmcm at hypernet.com.bbs Mon Jul 17 23:00:04 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 18 Jul 2000 03:00:04 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators Message-ID: <3bRYX5$k0E@openbazaar.net> Huaiyu Zhu wrote: >I don't see such arguments as any different from the claim that string >literals are sintactic sugar for the single domain of text processing >only (web and re and so on being subdomains). Since by such definition >text processing is a very large domain I do want string literals even >just for this only domain, even if it does not include everything. Look at it this way: the implementation of Python is based on strings, tuples, dicts and lists. So they came for free. The most exotic operators Python currently has are probably the shift operators. That's really not a good precedent for 8 new operators. [bjorn suggest preprocessing...] >This could work if there is a hook so that > >import mymodule > >would automatically run > >preprocessor < mymodule.mpy > mymodule.py > >anywhere in the path. It should do this after examining the timestamp >just like current import does. Otherwise after a few surprises people >would keep .py instead of .mpy so it is just a helper for writing, but >not useful for extending or maintaining code, Get Greg Stein's imputil.py from http://www.lyra.org/greg/python/ (or wait for BeOpen's first release - it'll be in the std lib). It has a hook for this. -Gordon From shindich at my-deja.com Mon Jul 10 20:19:53 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Tue, 11 Jul 2000 00:19:53 GMT Subject: Getting ip address and browser info References: <3967B9F8.1694E2F3@bioeng.ucsd.edu> Message-ID: <8kdp6r$hgb$1@nnrp1.deja.com> In article <3967B9F8.1694E2F3 at bioeng.ucsd.edu>, Curtis Jensen wrote: > Using python CGI how can I get the ip address and browser info of the > requestion party? Thanks. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > There was already a discussion on this subject. You might want to search for it on dejanews. You can also see my sample code on how to get client's IP address at http://www.shindich.com/sources/cgi/clientip/readme.html There is one thing to keep in mind however, the client ip address might be meaningless if the client is behind a firewall or if it's a DHCP client. I hope this helps! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From djc at object-craft.com.au Thu Jul 13 20:11:21 2000 From: djc at object-craft.com.au (Dave Cole) Date: 14 Jul 2000 10:11:21 +1000 Subject: Sybase module crashes (segfault) References: <396B2DEA.2FAEA72B@schlund.de> <396B3885.F612FD76@schlund.de> <396DDD1B.1A64A561@schlund.de> Message-ID: > Actually there are three cases in which Sybase.connect makes a > segfault: > > - missing interfaces file > - $SYBASE not set > - $LANG set to anything else than "" or "C" and no > internationalazation installed with Sybase I should really fix the import to check for some of these things. I just changed the vaults URL to point to a location where I could see downloads. I had no idea that more than five or so people were actually using this module. Using my statistically valid log file sample of one day, there are probably a hundred or so users. Woohoo! - Dave From fiona at sitegnome.com Mon Jul 24 03:10:37 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 24 Jul 2000 07:10:37 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 24th, 2000 Message-ID: <20000724071037.2569.qmail@synop.com> Greetings :-) Only a couple of new entries into http://python.faqts.com today. cheers, Fiona Czuczman Including: - Is there a way to get input not echoed to the screen in Python, as in the non-standard functions kbhit() and getch() in C and C++? - How can I change the Proxy Setting in MSIE from python? - Searching a simple tutorial on the internet for accessing a MySQL database using Python. - Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status? - Why is my pipe i/o thread blocking the other threads? Any answers? ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there an IPC-modul in Python ? http://www.faqts.com/knowledge-base/view.phtml/aid/4965 ------------------------------------------------------------- Marc Gehling ## New Entries ################################################# ------------------------------------------------------------- Is there a way to get input not echoed to the screen in Python, as in the non-standard functions kbhit() and getch() in C and C++? http://www.faqts.com/knowledge-base/view.phtml/aid/4969 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen import msvcrt while not msvcrt.kbhit(): #do something c = msvcrt.getch() assuming you're on windows, of course... ------------------------------------------------------------- How can I change the Proxy Setting in MSIE from python? http://www.faqts.com/knowledge-base/view.phtml/aid/4970 ------------------------------------------------------------- Fiona Czuczman Alex Martelli This is what MSDN has to say on the issue, after explaining how to find out what your usual defaults for proxy are (i.e., Internet Options/Connection/Proxy Server): If you intend to use a proxy other than that named in the dialog box, set the AccessType property to icNamedProxy (2). Then set the Proxy property to the name of the proxy, as shown in the code below: Inet1.Proxy = "myProxyName" Inet1.AccessType = icNamedProxy On the other hand, if you are content to use the default proxy (as determined by your computer's registry), ignore the Proxy property, and simply set the AccessType to icUseDefault (0). The settings for AccessType are shown in the following table: Constant Value Description icUseDefault 0 (Default) Use Defaults. The control uses default settings found in the registry to access the Internet. icDirect 1 Direct to Internet. The control has a direct connection to the Internet. icNamedProxy 2 Named Proxy. Instructs the control to use the proxy server specified in the Proxy property. MSDN mentions this in a Visual Basic context, but of course it should all work just as well from Python. As an aside: being an information junky, I just LOVE the MSDN. Mostly for Windows stuff, OK, but I also find it useful as an online searchable reference to HTML, the C++ standard library, Unicode character tables, etc, etc. Besides reading it at msdn.microsoft.com, you can probably get slightly old extra ones from Windows developer friends for free -- MS puts one out 4 times a year, and you don't really need the latest one:-). ## Edited Entries ############################################## ------------------------------------------------------------- Where can I download python DBI for MYSQL? Searching a simple tutorial on the internet for accessing a MySQL database using Python. http://www.faqts.com/knowledge-base/view.phtml/aid/3667 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain,Greg Fortune To get a MySQL module, go to http://dustman.net/andy/python/MySQLdb/ and download the 0.2.1 release. The readme included with the module will give you a brief description of its functions. I haven't ever tried it on a windows box, but it works great for linux. Probably best to look at http://www.vex.net/parnassus for most modules. They have a nifty tutorial section about lots of python related stuff. ------------------------------------------------------------- Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status? http://www.faqts.com/knowledge-base/view.phtml/aid/4922 ------------------------------------------------------------- Loren Poulsen, Michael Hudson, Fiona Czuczman http://www.python.org/doc/current/lib/module-commands.html,Mark Hammond import commands print commands.__doc__ :-) ---------- Use os.popen() - RTFM. However, note that for Python 1.5.2 and before, os.popen often doesnt work on Windows - you need my win32 extensions for this, where win32pipe.popen() does the right thing. os.popen should reliably work on Windows in Python 2.0 and later. ------------------------------------------------------------- Why is my pipe i/o thread blocking the other threads? Any answers? http://www.faqts.com/knowledge-base/view.phtml/aid/4933 ------------------------------------------------------------- Fiona Czuczman Richard Brodie There is a global lock within Python, protecting its internals. When you call out from a Python to a C extension method in a thread, the thread holds the lock. For maximum parallelism, and particularly if you're doing blocking I/O in a thread, you need to release and reaquire the lock. See: http://www.python.org/doc/current/api/threads.html for details. ------------ This is only a solution if the problem occurs when using a non-standard extension module (ie, a Python module implemented in C/C++). The statement "you need to release and reaquire the lock" is misleading - you can _not_ do this from Python code - only C code can do this. ------------------------------------------------------------- Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class http://www.faqts.com/knowledge-base/view.phtml/aid/4734 ------------------------------------------------------------- Nils Otto Johansen, Fiona Czuczman Mark Hammond NO. From thomas at xs4all.net Sat Jul 8 18:13:35 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 9 Jul 2000 00:13:35 +0200 Subject: [URGENT]: Setting PYTHONHOME and PYTHONLIB In-Reply-To: <3964336F.E6ECA187@cica.es>; from perer@cica.es on Thu, Jul 06, 2000 at 09:21:19AM +0200 References: <3964336F.E6ECA187@cica.es> Message-ID: <20000709001335.R26534@xs4all.nl> On Thu, Jul 06, 2000 at 09:21:19AM +0200, Manuel Perera wrote: > I'm using Debian in a machine, where I'm not root. I need to set the > variables PYTHONHOME > and PYTHONLIB , I've uncompressed the packages python-base...deb and > python-base..tk... in > /tmp/python, so I have this kind of directory structure: > /tmp/python/usr/bin/python > /tmp/python/usr/lib/python ... > Any help would be gratefully welcomed. What exactly do you need help with ? What isn't working ? What have you tried ? You do need to set the PYTHONHOME variable, but PYTHONLIB shouldn't be necessary (I doubt it does anything.) PYTHONHOME should be '/tmp/python/usr' in your case, I believe. Don't forget to set your shells PATH to include '/tmp/python/bin' either. And lastly, /tmp is probably not a good place for this: it's likely to be cleaned up every few days or so. So you might eventually experience mysteriously disappearing files... ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From neelk at brick.cswv.com Thu Jul 6 18:08:21 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 6 Jul 2000 22:08:21 GMT Subject: function arguments References: Message-ID: Johannes Zellner wrote: > > Hello, > > is there a way to get a functions argument list ? > > e.g. > > def fun(fred, lola): > ... > > something like `arglist(fun)' should return [ 'fred', 'lola' ] Sure -- use my Signature module: >>> import Signature >>> def fun(fred, lola): ... pass ... >>> s = Signature.Signature(fun) >>> s.full_arglist() ['fred', 'lola'] It's at -- let me know what you think. The big limitation is that it won't work on C builtins -- but all functions and methods written in Python should work, including callable objects using a __call__ method. Neel From olivierS.dagenaisP at canadaA.comM Wed Jul 5 08:33:02 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 05 Jul 2000 12:33:02 GMT Subject: GUI framework with TreeView References: <3967f81e.23966859@nntp.interaccess.com> Message-ID: <2WF85.39122$W35.856292@news20.bellglobal.com> I was looking for EXACTLY that and I found it, along with a whole lot of other cool stuff: http://www.wxwindows.org and if you're using Python: http://www.wxpython.org There's also a MAC port coming along. It attempts to provide many nice features of the OS GUIs out there, not just a "lowest common denominator". It does so by using native OS components/APIs wherever possible, so the Treeview isn't some re-implementation, it looks and feels just like MS's treeview. Oh, and it's free: http://wxwindows.org/newlicen.htm -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Thaddeus L Olczyk" wrote in message news:3967f81e.23966859 at nntp.interaccess.com... > I need a "free" gui framework that runs on both Windows and UNIX > ( so that lets out QT ) and gives me a component similr to Microsofts > TreeView. Does anyone know of such a thing? From aahz at netcom.com Wed Jul 12 13:53:44 2000 From: aahz at netcom.com (Aahz Maruch) Date: 12 Jul 2000 17:53:44 GMT Subject: Why are some infinite recursion stack overflows hard to deal with? References: <20000712192312.O7340@xs4all.nl> Message-ID: <8kibb8$rhc$1@slb6.atl.mindspring.net> In article , Alex wrote: > >I get the segfault with vanilla Python 1.5.2 on Redhat 6.2, and also >with bleeding edge (downloaded this morning) CVS Python: Interesting. I get the segfault with 1.5.2/6.1, but not 1.5.2/5.2. Note that 1.5.2/5.2 was installed over 1.5.1 in a way that probably still uses some of the 1.5.1 libraries. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From wtanksle at dolphin.openprojects.net Mon Jul 24 20:51:50 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 25 Jul 2000 00:51:50 GMT Subject: IEEE 754 References: <8lifaa$1bb$1@agate.berkeley.edu> <8liiba$1mh$1@agate.berkeley.edu> Message-ID: On 24 Jul 2000 23:09:30 GMT, Edward Jason Riedy wrote: >And John W. Baxter writes: > - You mean I may someday be able to put aside my answers to the "why > - doesn't 2/10 print as 0.2 as we all know it should?" sorts of questions? I'm not sure whether you mean that 2/10.0 isn't exactly 0.2, or whether 2/10 is 0. >Way off-topic: Besides, not all numbers are natural for base-10. >One example is pi. It strongly appears that the only natural base >for pi is 16 (pi may be base-16 normal and not base-10 normal). Not >proven yet, but looking likely. See >http://www.nersc.gov/~dhbailey/dhbpapers/bcrandom.ps for some neat >pi results. Could you clarify that? pi is not merely a repeating rational, like 1/3 (in decimal) and 1/5 (in binary); it's trancendental. >Back on topic: Python's answer is even more painful to explain: >> bash-2.03$ python -c 'print 2/10' >> 0 I suspect that's what he was talking about. I couldn't tell either. >Jason -- -William "Billy" Tanksley From bjorn at roguewave.com Fri Jul 28 15:19:09 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 28 Jul 2000 13:19:09 -0600 Subject: finding/counting files References: <8lskfi+r5ek@eGroups.com> Message-ID: <3981DCAD.AE17BA94@roguewave.com> jesse at multimediacollective.com wrote: > > What would the proper command be for finding a file within a > folder? I want my program to check to see if there is a folder > called 'test.txt' in the folder, and if there is, count the number of > files in that folder. What commands would I use for both these > problems? You want the os module. The friendly manual will tell you all about it... -- bjorn From sjaubert at capgemini.fr Wed Jul 19 12:45:14 2000 From: sjaubert at capgemini.fr (=?iso-8859-1?Q?St=E9phane?= Jaubert) Date: Wed, 19 Jul 2000 18:45:14 +0200 Subject: are there any tutorials that someone completly new to programming can understand? References: <8l4klm$2kl$1@slb6.atl.mindspring.net> Message-ID: <3975DB1A.9B9099CC@capgemini.fr> Hello, You can try that stuff inspired from "How to Think Like a Computer Scientist" http://yhslug.tux.org/obp/thinkCS/thinkCSpy/index.htm http://yhslug.tux.org/obp/thinkCS/ Bye +++++++++++++++++++++++++++++ + Stephane JAUBERT + + Unit Quality Manager + + CAP GEMINI ERNST & YOUNG + +++++++++++++++++++++++++++++ Dan^ wrote: > > well..im 17 and thought that i should start with a programming language, and > after checking with some of my friends, they pointed me to python > > but, all the tutorials seem to be for those that have spent years in > programming (mabey im just looking in the wrong places) but id really like > to try my hand at this > > anywho, thx in advance > -Dan From gmcm at hypernet.com Thu Jul 20 19:45:40 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jul 2000 23:45:40 GMT Subject: Intercept methods/raise exception References: <3978f242.25036009@news.online.no> <3979f896.26656309@news.online.no> Message-ID: <8F77C5924gmcmhypernetcom@199.171.54.155> Remco Gerlich wrote: >Thomas Weholt wrote in comp.lang.python: >> I tried using __getattr__, like >> >> def __getattr__(self, attrname): >> print 'Trace:', attrname >> return getattr(self, attrname) >> >> But it crashed terribly. The object in question is accessed lots of >> times. When I ran it, it printed : >> Trace: __coerce__ >> Some hundred, thousands times, then collapsed with a bang. > >This is simple infinite recursion. You got that right! > The getattr() call calls __getattr__, >etc. > >Try returning self.__dict__[attrname]. And that wrong! If the object exists, __getattr__ never gets called. You can trap all assigments to attributes through __setattr__, but only by using a proxy can you trap all accesses. - Gordon From moshez at math.huji.ac.il Sat Jul 29 02:48:14 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 29 Jul 2000 09:48:14 +0300 (IDT) Subject: Newbie DATA STRUCTURES Question. In-Reply-To: <398248BC.32DE3CC@nycap.rr.com> Message-ID: On Sat, 29 Jul 2000, gbp wrote: > Since I learned data structures in languages with pointers (C, pascal) > I'm stuck. How does one go about constructing a list of records in > python? My python is still pretty weak. I understand how the lists > work (a lot like Perl). I understand that you can use objects as > records. I don't really get the full OOP though. I guess that you > can't make record anonymous in python? Is that right? Can you have > pointers? "Everything is a pointer". Here's a list of records: [(1, "moshe"), (2, "gbp") And here's code to turn this file ''' 1:moshe 2:gbp ''' Into such a list: def make_lor(file): ret = [] # an empty list lines = file.readlines() # read all lines from the file for line in lines: number, name = string.split(line, ':') number = int(number) # turn "number" into an integer record = (number, name) # a tuple ret.append(record) # append this return ret # return the created list -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From olivierS.dagenaisP at canadaA.comM Sun Jul 16 15:57:41 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 19:57:41 GMT Subject: Pythonwin 1.5.2 References: <8kaij5$c9s$1@supernews.com> <8kaolt$flc$1@supernews.com> <838a5.12069$Tb7.82109@news-server.bigpond.net.au> Message-ID: Errr... In VB6, (not sure about VC6 on this one) I use the following keys to use the currently highlighted word: space, enter, Ctrl+Space and Ctrl+Enter. The "Tab" key never occured to me! It's not documented in the PythonWin documentation, either. Another PythonWin documentation quirk: Ctrl+T is listed twice as a keyboard shortcut. Once as "Transpose (swap) the current line with the line above" and later as "Toggle the use of tabs for the current file (after confirmation)" -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:838a5.12069$Tb7.82109 at news-server.bigpond.net.au... > > Oh for standards in keyboard shortcuts. What's wrong with ctrl-enter like > > Visual Studio? > > Visual Studio uses Tab. I had no idea it also allowed Ctrl+Enter. > > Neil > > > From grey at despair.rpglink.com Fri Jul 28 17:03:01 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 21:03:01 GMT Subject: Perl is worse! References: <75k2osst2eh5nbel73ju033l8s97bs2v0s@4ax.com> Message-ID: On 28 Jul 2000 15:05:49 -0400, David Bolen wrote: >I'm curious, since you've raised this point a few times now. If this >is true, then where is the pain, during this input check, of simply >making whatever conversion you need into an object type that you want >to use within the program. I believe it is when the checks are made through other mechanisms as well as when the flow of data is known from start to finish that such changes, and indeed in some cases the checks, should not be needed. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From ben at co.and.co Thu Jul 20 12:57:25 2000 From: ben at co.and.co (ben at co.and.co) Date: Thu, 20 Jul 2000 16:57:25 GMT Subject: Python-Perl merger Message-ID: Washington, 2000-07-20. FOR IMMEDIATE RELEASE. Python's leading development engineer and testbot, Guido van Rossum, announced the merger between Python and Perl after leaving the Pythonlabs, located in New Holland, Texas. "I really got to go home now, Larry's waiting for dinner. Anyway, yes, we decided to merge. After all, we've been married 1,5 month now, longer than I thought we would. After the recent addition of diacritical operators to python [1], and the Larry's decision to put significant whitespace into Perl 6 [2], we thought it was time for a merger. Like, you see, now we're married, it's time for our kids to get along. They're kind of twins right now, and they keep coming closer together. We don't want to hinder their growth, so we decided for a merger, for the best of all four of us." Larry Wall, former industrial preacher and head of the Perl monks, told our reporter: "'See, I'm kind op the romantic type, and Guido is more a strong, rational person, but in the end we really match together, and so do our kids. You know, at a certain point in live, you learn there's a thin line between love and hate, but if you succeed to match reason and romance, life's full of roses. Hey, Guido, that's a good name: Prose" "Nah, I'd rather want something really funny, like Bean or something." "Oh no, this doesn't match P.*, and Pean is kind of stupid." "Stupid, stupid. Who put $_ in his language?" "So, that's the tune. Now, let me tell you about map(filter(reduce(lambda))). Looks like hell to parse to me." ... [ Our reporter escaped from the scene alive. Latest rumours call for the name "A flat", although we can't confirm this yet. ] [1] http://x51.deja.com/=dnc/[ST_rn=ps]/threadmsg_ct.xp?AN=648419950.1&mhitnum=4&CONTEXT=964109742.361889964 [2]http://slashdot.org/comments.pl?sid=00/07/19/203221&cid=37 [ if you can't understand what's this all about, you probably speak Dutch, just like me :-) ] -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From dalke at acm.org Sat Jul 1 02:37:01 2000 From: dalke at acm.org (Andrew Dalke) Date: Sat, 1 Jul 2000 00:37:01 -0600 Subject: ?Does Python have sorting via "Dictionary Order"? References: <395A92D0.65A205B1@email.sps.mot.com> Message-ID: <8jk3d0$t38$1@slb0.atl.mindspring.net> Christopher Browne wrote in message ... >Centuries ago, Nostradamus foresaw a time when Norman Shelley would say: >>Does Python have sorting via "Dictionary Order"? This would be a very >>handy addition as an option to list's sort() function. > >Feel free to avail yourself of the documentation... > >"The keys() method of a dictionary object returns a list of all the >keys used in the dictionary, in random order (if you want it sorted, >just apply the sort() method to the list of keys)." I do believe you misunderstood the original poster's question. He gave a description of "Dictionary Order" based on how words in a paper-bound dictionary (as in the Oxford English Dictionary) might be ordered. He was not refering to their order as used in a Python dictionary data structure (mapping unique keys to values). Andrew dalke at acm.org From dale at out-think.NOSPAM.co.uk Thu Jul 20 18:45:33 2000 From: dale at out-think.NOSPAM.co.uk (Dale Strickland-Clark) Date: Thu, 20 Jul 2000 23:45:33 +0100 Subject: Scope questions Message-ID: <8l7vgk$73t$1@supernews.com> Could someone help me out with some scope and instantiation questions? In moduleA we have: varB = 1 class classC: varD = 1 def __init__(self): self.varE = 1 As I understand it, varB appears when the module is imported and stays around until the end of the program. When does varD appear? How long does it exist? In the main code I use the above module and have: import moduleA varJ = moduleA.classC varK = varJ.varE varJ = None Again, as I understand it, varK contains a reference to varE in class instance varJ. What happens to varK when the instance reference in varJ goes away? Does the instance get deleted or is there still a reference to it? Thanks for any help. Dale Strickland-Clark From stadt at cs.utwente.nl Fri Jul 14 03:53:47 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Fri, 14 Jul 2000 09:53:47 +0200 Subject: Files question References: <396DB8C4.EC239CD2@sicon.net> <396DD651.4BD08E97@darwin.in-berlin.de> Message-ID: <396EC70B.FAACD6A1@cs.utwente.nl> "Dinu C. Gherman" wrote: > > sergio wrote: > > > > I'm working in winNT Server 4.0. > > How can i know if a file is open by other apllication, in order to > > wait till the file is free > Have you tried just reading a few bytes and catch the > IOError if there is any (supposed you know the file > does exist)? Just an (untested) idea... OLWUC - open-lock-write-unlock-close import posixfile usersfile = posixfile.open (someFilename, 'a') usersfile.lock ('w|') usersfile.write ('something')) usersfile.lock ('u') usersfile.close() Note: the 'other application' must do the same. I assume, but am not sure, that this works for reading a file as well. Richard. From dsfoue at hotmail.com Thu Jul 6 12:19:03 2000 From: dsfoue at hotmail.com (dsfoue at hotmail.com) Date: Thu, 6 Jul 2000 18:19:03 +0200 Subject: I Didnt Know Id Been Date-Raped til the Check She Gave Me Bounced! 509 Message-ID: <6E528A6CBCFED311A7C1009027B721F930A4F4@hermes.demogr.mpg.de> http://www.mazepath.com/underground/hankins "What a sad commentary on Mensa and Mensans that ... a crude, insensitive, boorish, untalented brute like Bailey Hankins can get his ... garbage printed in so many of our publications. What on earth are our editors thinking?" Norma MCGovern Phoenix, Arizona bocbmggfifgtkxq From ejr at lotus.CS.Berkeley.EDU Mon Jul 24 18:17:46 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 24 Jul 2000 22:17:46 GMT Subject: IEEE 754 References: Message-ID: <8lifaa$1bb$1@agate.berkeley.edu> And Tim Peters writes: - - More accurately, Python provides no ways at all to test for Inf or NaN. If - it provided unreasonable ways, half the battle would be over . After perusing some more of Python's code, I see. sigh. - For starters, I know of no implementation of C99, so it's a bit premature to - switch to its features. Many of the library routines are already in GNU libc. Some are also available in vendor libcs, although with different include files (ieeefp.h on Solaris). The optimization pragmas aren't, but it may be feasible to compile a few objects without optimization flags. And the Octave response to the xisnan problem I noted is that all the platforms that sanely support NaN, Inf, etc. provide isnan and family somewhere. They just look for all the possible header files and libraries. If they're not found, they assume strange things will happen with them anyways (like trapping on Alphas with old gccs). It may not be as difficult as it seems - This means that just to start, we need to define an internal 754 C API, and - implement it via mounds of platform-#ifdef'ed trickery. This type of thing could be generally useful. Perhaps an implementation of the C99 spec with a suitable naming scheme would be warranted. (Looks like the C99 spec is available from ANSI for $18. Good. More to add to the to-be-read pile.) - The practical problem with this is that it requires people expert in - both their platforms (HW and compiler and libc) and 754 subtleties, - and they're mighty rare. Moreso, it's possible to change many assumptions at runtime by fiddling control words. When Python is used as an interpreter embedded in a larger app, this could be an important issue. - I can do it for the intersection of x86 chips and Microsoft's compiler, - but that's it. Oof. That's probably the worst intersection, too. Stupid MS compiler ``reduce the complexity of your expression'' bug... I think I'm finally getting to that stage with current versions of gcc and GNU libc, but there are so many older variations... Plus, I just noticed that the default for complex division in gcc frontends is the overflow-unsafe method. sigh. More work to add to the to-be- done pile. gcc's a tad more difficult to modify than Python. And Solaris + vendor libs doesn't seem too bad (with Sun's devel package and sunmath.h). T3E + Unicos likewise (has fenv.h, but also the flush-to-0 problem). Need to check the SP + AIX, but I'd be shocked if it were too horrible, and I know who to ask if more's needed. SGI + IRIX should be fine, but I don't have ready access. Don't know about Tru64, but the next gen of Alpha will have proper, fast gradual underflow support, so there's hope. It seems the most difficult platform is the x86, and that's mostly because there are just so many versions of OSes and libraries available. And then there are non-IEEE platforms like IBM mainframes (with Linux now, so `important') and VAXen. - The only platform-clever floating code in Python today is in - fpectlmodule.c, [...] Evil. The module's name made me hopeful. Then I read it. Evil. - The political battle is that most number-crunchers in practice still - don't understand why 754 is A Good Thing, and in my experience fight - it tooth & nail Some are being convinced. Some (like the g77 maintainer) aren't. I honestly cannot comprehend fighting against the only algebraically complete FP arithmetic available... I know it happens; I've been in some of the arguments. It's mind-blowing. - [...] but, alas, they - overwhelmingly don't ask for a better 754 - story). Most of them don't know it exists. I pretty much agree with Dr. Kahan that it should be much more of a tool-builder issue than a tool-user one. Like I said, I'd prefer if 99.999% of the users never had to know the subtleties of the FP arithmetic in the background. That means the tool builders (compilers, interpreters, libraries) have to emphasize correctness for largest reasonable number of cases over speed for the typical cases. Users shouldn't have to ask for it. And quite a few users who _do_ know it exists have given up on wide- spread support. But they're the ones who are content with evil, nasty code that bends over backwards to support every possible error in every possible place. Trying to read or, worse, modify, the code is horrible. That's about as un-Python as I can imagine. - In short, just business as usual in the wacky world of floating point - . Yup. Seriously, though, it seems that most people in favor of making Python an important numerical platform are also pretty much in favor of IEEE 754 support. Seems we have an opportunity to get things right. ;) Next interesting discussion: How to add radix-10, IEEE 854 support... Jason From thomas at xs4all.net Sun Jul 9 05:56:43 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 9 Jul 2000 11:56:43 +0200 Subject: Making tabs illegal In-Reply-To: <20000708232940.A25033@novara.avenue>; from jcm@bigskytel.com on Sat, Jul 08, 2000 at 11:29:40PM -0600 References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> <20000708232940.A25033@novara.avenue> Message-ID: <20000709115643.V26534@xs4all.nl> On Sat, Jul 08, 2000 at 11:29:40PM -0600, David Porter wrote: > > > You should get a decent editor. > > You have missed my point entirely - I am arguing against the banning of > > tabs - my editor does tabs, syntax highlighting and autoindenting. > I believe that he is saying that a decent editor can be configured to use > four spaces when you hit tab, so that is no reason to not ban tabs. Emacs > with Python Mode converts the pressing of a tab to four spaces and it > auto-indents with four spaces. There are plenty of editors (like those that aren't an OS an sich ;) that don't do expansion of tabs into spaces. Like Windows Notepad. Banning tabs altogether is quite the radical move, given that tabs aren't the problem, users are ;) Tabs work fine, spaces work fine, but mixing tabs and spaces are what can cause problems. (Well, setting tabstops at something other than every 8th character is the real problem, of course!) Python has the -tt option, which prevents usage of tabs and spaces, mixed, as indentation. It might become default in the future, or it might not. Until then, always call python -tt, and either use spaces or tabs. Those AI-editors of yours can auto-determine the indentation-style of the script you are editing, even if it's someone else's, and make you insert the right indentation without you knowing it. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From moshez at math.huji.ac.il Mon Jul 31 16:16:43 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 31 Jul 2000 23:16:43 +0300 (IDT) Subject: [5th Draft] Open Letter to CNRI: Request for clarification In-Reply-To: <3985D797.E5D2FC08@nowonder.de> Message-ID: On Mon, 31 Jul 2000, Peter Schneider-Kamp wrote: > added some names > > Should I add email addresses? I think this should be on an individual base, but I definitely would like mine added. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From olivierS.dagenaisP at canadaA.comM Sun Jul 16 19:58:17 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 23:58:17 GMT Subject: "Intellisense" drop-down... References: Message-ID: I found it! In coloreditor.py, I found the two methods I had been wanting to use, namely SciAutoCActive and SCIAutoCComplete! Here it is, folks, the ability to use another key than TAB to select a word in the AutoComplete list: def AutoCompleteOrIgnore ( editor_window, event ): editor = editor_window.edit if editor.SCIAutoCActive ( ): editor.SCIAutoCComplete ( ) return 1 Just add it to your .cfg file and then, in the [Keys] section, add/change the following: Ctrl+Space = <> Ctrl+Enter = AutoCompleteOrIgnore Space = AutoCompleteOrIgnore and PythonWin should now [sort of] behave like VB! If you don't like "it" adding a space after an "auto-completed" word, change the function to: def AutoCompleteOrIgnore ( editor_window, event ): editor = editor_window.edit if editor.SCIAutoCActive ( ): editor.SCIAutoCComplete ( ) return 0 return 1 Wohoo!!! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Neil Hodgson" wrote in message news:osrc5.3577$4p3.27127 at news-server.bigpond.net.au... > > I have found no way of defining new key combinations to select the > currently > > highlighted word in the "Intellisense" drop-down list. For example: > > ... > > I hightlight "Apply" and the only key I can use to make "Apply" appear and > > the list to disappear is "Tab". I want other keys to trigger this. The > > default.cfg file only lists this: > > When the previous post appeared about Ctrl+Enter in auto-completion, I > had a look at extending the keys that would choose an item and tried > changing this in Scintilla. This worked in other applications but not in > PythonWin as PythonWin intercepts keys before sending them on to Scintilla. > Then I went looking through PythonWin but the code was confusing so I gave > up. > > If you are interested in working on this, the Enter key calls > newline_and_indent_event in pywin\idle\AutoIndent.py. So you could intercept > it here or else bind Enter to your own event that calls the current > newline_and_indent_event only when no autocompletion is shown. > > Neil > > > From thomas at xs4all.net.bbs Mon Jul 17 06:00:02 2000 From: thomas at xs4all.net.bbs (thomas at xs4all.net.bbs) Date: 17 Jul 2000 10:00:02 GMT Subject: Wishlist sumbission form? Message-ID: <3bR862$j1_@openbazaar.net> On Sun, Jul 16, 2000 at 10:35:23PM -0500, Paul Prescod wrote: > Matthew Cline wrote: > > Is there any way of submitting feature requests for Python, > > other than by filing a bug report? > I don't think so. If it is a very targeted request, you could try the > but report route. Actually, the buglist (Jitterbug, on www.python.org) as a 'Requests' section for feature requests. It gets looked at every now and then, too. > If it is large and arguable, you should probably post it here and get some > people to support it. If its good, someone will implement it. In open > source software, only the features that developers are interested in get > implemented so a wish list might well get ignored anyhow. It's not that > nobody cares what you think it's that there's an infinite list of wishes > so people tend to attack them in the order in order of personal interest > or widespread demand. Actually, I have no problem with implementing features which I think are good features, even though I would never use them. Or features that *might* be good. As long as I can test it (ie, they run on Linux or BSDI without dependencies on weird hardware or non-free software) I don't have much trouble with implementing it. But that's just me ;) Of course, if you know a little C, the Python source is incredibly easy to understand and extend. And a great tool for learning C, as well. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Wolfgang.Strobl at gmd.de Mon Jul 17 08:38:07 2000 From: Wolfgang.Strobl at gmd.de (Wolfgang Strobl) Date: Mon, 17 Jul 2000 14:38:07 +0200 Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: "Neil Hodgson" wrote: >> working with the new Build 132 of Pythonwin we have a minor problem. >> German Umlauts are not handled properly in the editor windows. >> They are shown as boxes, some of them seem to be dead keys. >> >> The problem did not exist in previous builds. >> Does anyone have a hint ? > > 132 defaults to using Unicode for editing Python source code and the >interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, >find the OnInitialUpdate method and comment out the two lines under "# >Enable Unicode if we can". Save the file, shut down Pythonwin and restart it >and see if this fixes the problem. It fixes the problem for umlauts, but pythonwin.exe still dies with a access violation (0x05), at adress 0x1e14cd9e, when the ^-key (top left, just below the esc key) is hit, on the German keyboard layout. -- Bicycle helmets are the Bach flower remedies of traffic From stephen at cerebralmaelstrom.com Sun Jul 16 00:37:40 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sun, 16 Jul 2000 04:37:40 GMT Subject: Case insensitive searching w/ mxTextTools? Message-ID: I'm working on a fairly complicated (for me, at least! :)) tag table to parse rfc822 messages, since im actually sorta working on a replacement for 'rfc822' and the various MIME modules within my application.... Anyways :) Is there a better way to perform a case-insensitive substring search then by passing a translation string (with all Upper-Cases mapped down into lower cses, or vice versa) to a BMS search object? Thanks :) --Stephen From Jorrit.Tyberghein at uz.kuleuven.ac.be Wed Jul 19 08:11:50 2000 From: Jorrit.Tyberghein at uz.kuleuven.ac.be (Jorrit Tyberghein) Date: Wed, 19 Jul 2000 14:11:50 +0200 Subject: Python in game development? References: <963990339.783645@marvin> Message-ID: <964008712.215436@marvin> Mallor wrote in message ... > >"Jorrit Tyberghein" wrote in message >> >> In the Open Source Crystal Space 3D engine we are working on a framework for >python >> scripting. It is already working reasonably well but you cannot yet do >everything >> that you'd want to do from a python script. > >Why did you choose Python as opposed to any other scripting language? In >particular, what are your experiences so far with efficiency issues? This seems >to be a knock against Python from the articles that I read, but of course the >efficiency of a language implementation can be a moving target, if the >developers have their priorities set in that direction. Well, CS itself doesn't force the use of Python. i.e. there is nothing in CS that says 'Only Use Python for Scripting'. The system to allow scripting is general and allows us to attach any scripting language. But we are concentrating on Python first because it is a nice language mostly and there is a lot of support for Python. I personally did not use Python much (the Python support is done by other members in my team) so I can't really comment on the efficiency issues. Java will be another important scripting language for the CS project. Greetings, -- --------------------------------------------------------------------------- Jorrit Tyberghein (Jorrit.Tyberghein at uz.kuleuven.ac.be) Project Manager of Crystal Space, a free and portable 3D 6DOF portal engine. More info at: http://crystal.linuxgames.com --------------------------------------------------------------------------- From m.faassen at vet.uu.nl Mon Jul 31 07:39:59 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 11:39:59 GMT Subject: Erm... might I suggest... (Re: New PEP: Attribute Access Handlers) References: <397CA165.582D8786@prescod.net> Message-ID: <8m3oif$due$2@newshost.accu.uu.nl> Paul Prescod wrote: [snip] > Right, I don't think that that behavior is so onerous now, nor in the > proposal. In return for the performance I think it is a small price to > pay. One serious constraint is that I cannot slow down Python! Adding an > attribute handler to a class should have as little performance impact as > is humanly possible. Right; I went through the whole reasoning and came up with almost an identical solution -- it seems to be the 'natural' conclusion given this performance constraint. Except that I don't see the reason not to split up the get/set/del handlers still even with his solution. Paul, any feedback on that? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From robin at jessikat.fsnet.co.uk Sat Jul 22 03:25:06 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 22 Jul 2000 08:25:06 +0100 Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> Message-ID: In article <397933DA.46B072BF at roguewave.com>, Bjorn Pettersen writes .... >> > Perhaps you should add a few words about why you chose __attr_XXX__ >> > instead of __set/get/del_XXX__? >> >> That was actually the first proposal. But inheritance could get >> confusing if you inherited set without get or get without set etc. > >Hmmm... I'm not quite sure I understand... With __set/get/del_XXX__ >defined in a superclass you would automatically inherit all of them and >could choose to only override one of them, e.g. if you wanted to perform >further checks on a set but the get was the same. With __attr_XXX__ you >would have to explicitly call the superclass' __attr_XXX__ method if you >didn't define all of set/get/del(?) I have a feeling I'm missing >something... ... I prefer the fine control version, but couldn't you have both or is that too un-pythonic -- Robin Becker From aahz at netcom.com.bbs Sun Jul 16 12:10:02 2000 From: aahz at netcom.com.bbs (aahz at netcom.com.bbs) Date: 16 Jul 2000 16:10:02 GMT Subject: Python equivalent of CPAN in Perl Message-ID: <3bQSCR$lzh@openbazaar.net> In article , Robin Becker wrote: >In article <8krfa9$vf4$1 at nntp9.atl.mindspring.net>, Aahz Maruch > writes >> >>We've got half of it with Vaults of Parnassus. Another third will come >>with the standardization of distutils in Python 2.0 (remember, 1.6 has >>been renamed to 2.0). > >Unfortunately not true. A large share of the Python market (on win32) >have no compilers and probably wouldn't/couldn't use one even if it were >present. I doubt the extension builders will always want to include >.pyds for Python15.dll Python20.dll etc etc. To the extent that this is true, isn't it also true of Perl/CPAN? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From moshez at math.huji.ac.il Sat Jul 29 06:10:22 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 29 Jul 2000 13:10:22 +0300 (IDT) Subject: Python in politics (sssssssssnake!) In-Reply-To: <398296A1.1A97571A@sitegnome.com> Message-ID: On Sat, 29 Jul 2000, Fiona Czuczman wrote: > Hi Kirby, > > Your mail got me thinking... > > I've just started trying to teach my 9 year old son how to program, I > choose Python because I'm trying to learn it as well.... > > He thinks he is 'cool', and I quote > > - "I'm not here to make (make dinner) I'm here to program" - in an > attempt to get out of helping me with the cooking. > > body actions of a super hero (muscle flex left and right arms :) .... > hopefully I'll be able to maintain that level of enthusiasm. Do all you > guys do that?? > > I'd be interested if there are guidelines somewhere for parents to teach > their kids how to code? When it comes to 9 year olds the tutorials are > pretty scary ... maybe I should start working on that? Is anyone > actively working on that now...? "Thinking like a computer scientist in Python", available at http://yhslug.tux.org.il/obp/ (follow the links) might be a bit too heavy for 9yr old, but should be a good place to start. It's under the GPL, so you're welcome to fork a version suitable for younger kids, and share the changes with everyone. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From cjensen at bioeng.ucsd.edu Tue Jul 11 22:07:35 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 11 Jul 2000 19:07:35 -0700 Subject: PIL for SGI IRIX Message-ID: <396BD2E7.1E38FF95@bioeng.ucsd.edu> While running ./configure for the PIL module, I get this output: loading cache ./config.cache checking for --without-gcc... no checking for gcc... gcc checking whether we are using GNU C... yes checking whether gcc accepts -g... yes checking for ranlib... : checking for ar... ar checking MACHDEP... irix646 checking for -ljpeg... no checking for -lmpeg... no checking for -lz... yes checking how to run the C preprocessor... gcc -E checking whether cross-compiling... 360246:./conftest: rld: Fatal Error: Cannot Successfully map soname 'libz.so.1.1.3' under any of the filenames /usr/lib32/libz.so.1.1.3:/usr/lib32/internal/libz.so.1.1.3:/lib32/libz.so.1.1.3:/opt/lib32/libz.so.1.1.3: yes checking for ANSI C header files... yes checking for inline... inline checking whether byte ordering is bigendian... configure: error: can not run test program while cross compiling How do I get past this point? Also, I have the jpeg library, and it compiled fine, but configure doesn't find it. How do I make configure see it? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From grey at despair.rpglink.com Fri Jul 28 11:40:36 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 15:40:36 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <8lrp6k0utp@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 12:57:31 +0200, Alex Martelli wrote: >I'm not being a Python apologist here; I think that using typed data >is preferable in most cases _but not in all_, and that Python should >let the operation determine the context, rather than the data, in a >few more cases than it currently does. First off, thank you for the wonderful post. Completely enjoyable to read. Also thank you for saying this and all that follows. I'll most likely bow out of the discussion now since I think all that is going to be said has been said. I just wanted to raise one question: What about a way to define a variable that you want to be mutable. Something set at time of creation that allows a more of the type transformations of perl to be performed while still retaining the type checking for all other operations? It seems that they main problem people have is the automatic conversion when there is the potential for a loss of data or when it is "senseless" (nevermind that a lot of things are senseless in programming, like rollover of integers in C, but I digress). Why not, then, allow the programmer to say, "Yes, convert /this/ variable as needed based on context"? A JUST_DO_IT!!!! flag, if you will? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From niels at endea.demon.nl Fri Jul 21 06:52:56 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Fri, 21 Jul 2000 12:52:56 +0200 Subject: Class static variables References: <8l714k$hjd$1@nnrp2.deja.com> Message-ID: <39782B88.9BDE9F68@endea.demon.nl> desnoix at my-deja.com schreef: > > I'm writing a tool to translate a variety of OO > programming languages. Especially I target Python > but I am hesitating about the way to define > class-scope static variables. Could you suggest me > what is the best and natural form ? > > Example: MyClass { static int a; } > - MyClass_a > - accessors + global var > - any other form MyClass.a will work unless it is a function. (class attributes that are functions are magically turned into instance methods) For example: class MyClass: #define class attribute a = 0 def method(self): #use class attribute do_something_with(MyClass.a) #use class attribute outside of MyClass do_something_else_with(MyClass.a) -- Niels Diepeveen Endea automatisering From neilh at scintilla.org Wed Jul 5 09:22:24 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 05 Jul 2000 13:22:24 GMT Subject: Is there a searchable archive of c.l.py References: <111b2f38.c4458b92@usw-ex0106-045.remarq.com> Message-ID: > I don't know just how far back RemarQ goes, but it's probably > worth a look. Thanks for the pointer. Remarq only goes back to April with a couple of days in March. I like the way it displays all of a thread if you click on it though. Lots less clicking than Deja. Neil From billtut at microsoft.com Wed Jul 26 14:58:34 2000 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 26 Jul 2000 11:58:34 -0700 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD334@RED-MSG-50> The important concepts of .NET don't really include what or how the VM/JITters work. One way to view .NET in a positive light for application developers is a platform to more easily interoperate between various languages while at the same time providing COM and COM+ integration in a fairly sane and consistent way across the various languages. The other important concepts around .NET are the services and tools that are the works in progress. Bill -- Not speaking for MS, etc, etc... -----Original Message----- From: cg at gaia.cdg.acriter.nl [mailto:cg at gaia.cdg.acriter.nl] Sent: Wednesday, July 26, 2000 10:46 AM To: python-list at python.org Subject: Re: Microsoft's C# (Sharp) & .NET -- A Heads Up David Arnold said: >it's impressive how much hype can be generated for a product that is >still years away from general release ;-) > ...and is soooo innovative that it does exactly the same thing as Java and the JVM, only five years later and at the vaporware stage. There's only one company that can pull this off, and I sincerely hope they'll choke in it this time. (http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.html, support /that/ many stuff on your little VM, M$). ... happily going back to Java, Python, SmallTalk, Scheme, XML and whatnot on top of HotSpot..., Cees -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ -- http://www.python.org/mailman/listinfo/python-list From robin at illusionsexeculink.com Wed Jul 5 22:31:50 2000 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Wed, 05 Jul 2000 22:31:50 -0400 Subject: "Write to a file" question please? References: <39634BBF.5EFFC493@quantisci.co.uk> Message-ID: Paul Robinson wrote: >Paul Jensen wrote: >> I wanted to include a reference to the "%" operator in the online >> docs, but interestingly couldn't find one. Anyone know offhand where >> "%" is covered in the docs? > >http://www.python.org/doc/current/lib/typesseq-strings.html#SECTION004151000000000000000 >[Thats library reference - 2.1.5.1 More String Operations] > >...although if you didn't know what an "sprintf() format string" was >then the probability of understanding this particular section is low. Try the Wonderful World of Micro$oft: http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/ _crt_format_specification_fields_.2d_.printf_and_wprintf_functions.htm (all one line, ob.) ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ "We told it about general relativity and gravity, the kind of people that overcome hardships." From neilh at scintilla.org Sat Jul 29 20:58:28 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 30 Jul 2000 00:58:28 GMT Subject: Python in politics (sssssssssnake!) References: <398296A1.1A97571A@sitegnome.com> Message-ID: > body actions of a super hero (muscle flex left and right arms :) .... > hopefully I'll be able to maintain that level of enthusiasm. Do all you > guys do that?? We no longer try to emulate super-heroes. We've got Tim Peters. no-time-for-murder-mayhem-or-mice-gonna-shine-them-sigs-so-nice-ly y'rs - neil From gtalvola at nameconnector.com Wed Jul 19 12:25:17 2000 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Wed, 19 Jul 2000 12:25:17 -0400 Subject: ADO 2.5 connection problem References: Message-ID: <3975D66D.8B5F46A2@NameConnector.com> Dale Strickland-Clark wrote: > I've just knocked up a JavaScript equivalent of this as a Windows Scripting > Component and it works a treat. > > Is it me or is Python Win32Com doing something stupid? Both :-) You need to use rs.Open, not rs.open. Case matters. The error message is about as misleading as can be, though. Incidentally, I use the following to create a connection to an Access db: db = win32com.client.Dispatch("ADODB.Connection") db.Mode = win32com.client.constants.adModeReadWrite # if we want to be able to write db.Provider = 'Microsoft.Jet.OLEDB.3.51' db.Open(dbfile) I don't know if there are any advantages or disadvantages compared to what you're doing, but who knows, it may help you out somewhere down the road to know this method... -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From gmcm at hypernet.com Sat Jul 22 16:33:13 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 Jul 2000 20:33:13 GMT Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <3979CD4F.22BD1F5E@prescod.net> Message-ID: <8F79A31F0gmcmhypernetcom@199.171.54.155> Paul Prescod wrote: >Consider this module and tell me what it would output (in your opinion): > >class A: > def __set_x__( self, val ): > print val >a=A() >a.x=5 5 >print a.x AttributeError >del a.x AttributeError So far, it's unambiguous. > >class B(A): > def __get_x__( self, val ): > return "funny walk" > >b=B() >b.x=5 5 >print b.x funny walk >del b.x AttributeError >Now, how would you implement it? class proxy: def __init__(self, obj): self.__dict__['_obj'] = obj def __getattr__(self, nm): mnm = '__get_%s__' % nm mthd = getattr(self._obj, mnm, None) if mthd: return mthd() return getattr(self._obj, nm) def __setattr__(self, nm, val): mnm = '__set_%s__' % nm mthd = getattr(self._obj, mnm, None) if mthd: return mthd(val) setattr(self._obj, nm, val) def __delattr__(self, nm): mnm = '__del_%s__' % nm mthd = getattr(self._obj, mnm, None) if mthd: mthd() delattr(self._obj, nm) class _A: def __set_x__(self, val): print val class _B(_A): def __get_x__(self): return "funny walk" def A(): return proxy(_A()) def B(): return proxy(_B()) -Gordon From mcarpenter at free.fr Fri Jul 14 11:04:27 2000 From: mcarpenter at free.fr (Martin Carpenter) Date: Fri, 14 Jul 2000 15:04:27 GMT Subject: openssl 0.9.5a and python 1.6a2 References: <8kl0h4$pu6$1@nnrp1.deja.com> Message-ID: <396F2797.D0D3387B@free.fr> falk.lehmann at gmx.net wrote: > I build python 1.6a2 and included the SSL support. I am using the > openssl library 0.9.5a on a NT box. [snip] > But the proxy replies with an error message: [snip] > The requested item could not be loaded by the proxy.

> The certificate issuer for this server is not recognized by > Netscape. The security certificate may or may not be valid. [snip] > It seems that some certificate is missing. How do I make openssl aware > of the certificates delivered with the distribution? Or is the error > somewhere else? Sounds suspiciously like it's the *proxy* that doesn't recognise the CA that signed cardfile.com's certificate. So: (a) Can you access this site using a standard browser and the same proxy? This would eliminate the proxy from the equation. (b) What certificate does cardfile.com present? Who is the issuer? (Trying, for example going to that site and then examing the security properies of that page with your browser - the "padlock" icon in Navigator, for example). [I'm offline at the moment]. (c) I've not been around OpenSSL for a while (0.7 was the last I tinkered with, I think), but the standard issuer certificates didn't used to be "built in". It was up to the application developer to provide the code to verify the validity of any certificate presented. Therefore, your application *should* contain copies of all the issuer certificates for the CAs that you wish to support. (Navigator 4.73, NT4.0, contains 70 or so of these "signer" certificates!). Martin. From grey at despair.rpglink.com Sun Jul 30 20:49:07 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 00:49:07 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8m26fm$ila$4@newshost.accu.uu.nl> Message-ID: On 30 Jul 2000 21:25:10 GMT, Martijn Faassen wrote: >Then have your program catch your exceptions! That's one of the main >reasons for the existence of the exception handling mechanism; to recover >gracefully from the unexpected. >It is possible to catch *all* exceptions, if you're worried about that. >Or whole groups of exceptions, if you like. They're in a hierarchy. However I find that exceptions come up on the damnedest things, break you out of loops, cause problems all around and don't let you return to where you were, esp. when you use general catch all exceptions. As Alex(?) said, you don't return to where you were so, to me, it seems quite impossible to be able to catch /all/ exceptions gracefully, ever. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From thiele at muc.das-werk.de Mon Jul 3 06:40:44 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 12:40:44 +0200 Subject: From UNIX to Win NT Message-ID: <39606DAC.49A502DB@muc.das-werk.de> Hallo! I have a program running on UNIX(IRIX and LINUX). I now want to port this program to Win NT. Is there anybody who have any experience with this? The problem is I am using threads, fork and exec. And I want to have the same behaviour using NT. - at first I create a new thread. (so the main thread is ready for receiving commands) - then I fork in the child I change it's userID (os.setuid()) and replace it by os.exec() the parent reads the stderr and stdout from the started program ( like popen2.popen3() ) Last but not least I use sockets (a derived server from SocketServer.py) What have I to change? And why? And how? Thanks for help, Thomas From rpevans at my-deja.com Tue Jul 18 09:01:30 2000 From: rpevans at my-deja.com (rpevans at my-deja.com) Date: Tue, 18 Jul 2000 13:01:30 GMT Subject: threads and pipes Message-ID: <8l1kf1$k9t$1@nnrp1.deja.com> I have extended Python with some purpose built functions, written in C which communicate with a server process, via named pipes. Initially I called one of these functions (mylib.fred ) from main to initiate communications with the server. Once stablished I then started a thread, again a mylib function, to monitor the pipe connection set up previously. This is does but locks out the rest of the system. Only when the thread receives data from the server does the rest of the system run momentarily before again hanging. My first line of attack was to put the function which initiated the comms in a separate thread so divorcing the comms from main completely (I hoped). Now I have the problem of communicating data ( pipe/socket fds) from my first thread back to main and then to the second thread which inplements the select . This I have miserabley failed to do. Firstly the python script gives me an attribute error on the join I perform to wait for the first thread to finish. I have tried join(), thread.join() , what should I put? Secondly how do I transfer variables from the C extension library to and from the Python module. I asume I can't return a value from a thread in the argument list. I have tried declaring a variable as global in python and external in C without much (ie any succcess ). Could anyone tell me how I can implement complete asynchronicity between my mian module and the communication threads. Is there a site with some example Python threaded code. The library reference is quite sparse in this area. The books I have bought (O Reilly) do not mention threaded architecture. Is there a book which covers this? Many thanks Richard Evans Sent via Deja.com http://www.deja.com/ Before you buy. From dkuhlman at netcom.com Mon Jul 17 12:54:47 2000 From: dkuhlman at netcom.com (G. David Kuhlman) Date: 17 Jul 2000 16:54:47 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> Message-ID: <8kvdon$tit$1@slb3.atl.mindspring.net> This is *very* exciting news for me. Here's why: We make a Web server add-on that has the CPython interpreter embedded in it. This enables our users to extend the mainframe applications that we deliver/host with Python scripts. At some time in the future, if all the silliness about Java does not quiet down, we will be able to embed JPython into our product so that our users would be able to extend their applications with Python code which integrates with their Java code. And, if the sillines about C# turns out not to be a hoax, with the work Mark is doing, we might be able to embed C#Python into our product so that our users could extend their applications with Python code which integrates with their C# code. Now, I ask you, what other scripting language would enable me to support that breadth of users? Incredible. One thing (among many) that I do not understand is how C#Python can both compile directly to IL (intermediate language?) and produce a .DLL/.EXE. Does the .EXE contain both an interpreter (VM ?) and the IL (byte code?) that it interprets? Or does IL mean that the machine code is in there, but augmented with some meta-information for debuggers and other tools? Or, what? - Dave Mark Hammond (MarkH at ActiveState.com) wrote: > In article , > "Neil Hodgson" wrote: > > Now that Microsoft have revealed their Intermediate Language (IL) > > virtual machine, are we going to see a version of Python that > > compiles directly to IL? Or will Python byte codes still be > > interpreted by C code? > > Directly to IL - although there is still a runtime that handles some of > the Python semantics. > > This new compiler could be compared, conceptually, with JPython - it is > a completely new implementation of Python. It has a compiler that > generates native Windows .DLL/.EXE files. It uses a runtime that > consists of a few thousand lines of C# (C-Sharp) code. The Python > programs can be debugged at the source level with Visual Studio 7, as > well as stand-alone debuggers for this environment. Python can sub- > class VB or C# classes, and vice-versa. > > Unfortunately, there will not be a public release of their SDK for a > couple of months - so the only people able to use this compiler are > people who attended the PDC, and hence have the pre-beta SDK on their > conference CDs. > > The compiler is looking pretty reasonable. pystone.py (amongst others, > of course) compiles and runs. > > However, this should be quite exciting for the Python community. The > general feel of the conference here is that the MS .NET technology is > exciting and a good thing. I predict that the Windows community will > embrace this technology, and having Python be a first-class citizen is a > good thing! It _is_ a radical change. > > Future work on this compiler will be under the ActiveState banner. > However, the compiler and the runtime are all open source. The > compiler is written in CPython, and uses win32com to get at the > Reflection::Emit APIs provided by .NET. All the existing work has been > done mainly by me, with some code and advice from Greg Stein. Now the > NDA is lifted, I hope (some of) the Python community will get behind > this, and take advantage of the open-sourceness of the compiler and > runtime, and help us turn this into an excellent language for this > environment. > > All good stuff (IMO, of course) > > None of this is speaking for ActiveState - just my personal opinion. > > Mark (still at the PDC!) > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From rupole at compaq.net Fri Jul 14 23:27:50 2000 From: rupole at compaq.net (Roger Upole) Date: Sat, 15 Jul 2000 03:27:50 GMT Subject: NT4 shortcuts and import References: <8koe6q$avh$1@nnrp1.deja.com> Message-ID: Python is correct, as usual. The filename is actually src.lnk. NT normally hides the extension for shortcut files, but it is there. Python will not import automatically thru a shortcut. You could do it yourself by getting the pathname from the link and using execfile or something similar, but that would be a major pain. Creating a package sounds like what you want to do, see http://www.python.org/doc/current/tut/node8.html#SECTION00840000000000000000 0 HTH Roger Upole "Andy Freeman" wrote in message news:8koe6q$avh$1 at nnrp1.deja.com... > I'd like to use a shortcut named, say, "src", from the current > directory to a directory somewhere else and then use "import src.foo". > The problem is that NT4 thinks that the shortcut is named "src" > but Python thinks that the shortcut is named "src.lnk". Note that > I can't use "import src.lnk.foo" because the first "." is interpreted > as a directory name separator, not a part of the "src.lnk" module > name. > > (1) How do I get Python to use "src" as the module name? > (2) How do I escape "." in variable names? > > I'm using Python 1.5. > > thanks, > -andy > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From mhaselup at clicktomarket.com Thu Jul 6 16:03:04 2000 From: mhaselup at clicktomarket.com (Mark Haselup) Date: Thu, 6 Jul 2000 13:03:04 -0700 Subject: Application testing Message-ID: <8kdafd$2nj$1@bob.news.rcn.net> I need to carry out some testing of a cgi application from a Browser client. I have been informed that I can use Python (or some of it's extensions) to capture and replay the http traffic between the Browser and the Webserver to simulate a user session. Unfortunately I've not been able to find any information on this usage in the books I've looked at so far. I am also interested in any other applications free or otherwise which would allow me to do this. I would like to be able to capture the traffic and edit it to allow modified replays of sessions. Can anbody help with this? Should I be looking at other news groups for these features? Thanks. From david_ullrich at my-deja.com Sun Jul 16 14:40:44 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sun, 16 Jul 2000 18:40:44 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> Message-ID: <8ksvja$9f3$1@nnrp1.deja.com> In article , Alex wrote: > > > Well it's exactly what I was doing once because I was a lot more > > clever than the guys who said I shouldn't. And then I decided quite > > suddenly that they were right. (At the end of a _long_ stretch trying > > to figure out why the heck something wasn't working - of course the > > answer is the object in question was very different from the object it > > appeared it should be...) > > It can have really confusing consequences, I don't think "confusing" is the right word. Although I'm fairly certain I won't get the words right: It destroys the... maybe the word is "encapsulation" or "modularity" or something - it means that you cannot verify things are correct by just looking at things locally. When you write def AClass: def AMethod(self): you can't know that AMethod is correct just by inspecting , because you have no idea whether is what's executed when AMethod is called. > but it's still too useful for > me to abandon. If you have a class which takes a long time to > instantiate (e.g., you have to load a lot of statistical data into > memory,) then having a script like > > class C: > pass > > if 't' not in dir(): > t = C() > > t.__class__ = C > t.experiment_with_instance() > > can really decrease your turn-around time when you're debugging -- you > can change t's methods around behind its back without changing its data. Not sure what sort of debugging we're referring to. If you're trying to figure out how to do something, as opposed to writing code meant to be used later, that's different. I'm not sure whether you're talking about temporary experimental code or "real" code; the post that started this was evidently talking about real code. In temporary code I suppose changing __class__ could be more convenient simply because it possibly takes a few fewer lines to write - in real code I don't see why changing the value of aninstance.__class__ is better than creating a second instance of the new class. Possibly I missed it, but I haven't seen any reason given why changing __class__ is better than creating a new instance (I don't think that the time it takes to load data counts, there's no reason you have to reload the data instead of referring to the data already loaded.) > Alex. > Sent via Deja.com http://www.deja.com/ Before you buy. From rapto at arrakis.es Sat Jul 22 06:54:36 2000 From: rapto at arrakis.es (Marcos =?iso-8859-1?Q?S=E1nchez?= Provencio) Date: Sat, 22 Jul 2000 10:54:36 GMT Subject: PIL and HPGL References: <4682ls4ukdce8uipv7hcgfjkihv6teoppj@4ax.com> Message-ID: <39799A48.2D2F8FF6@arrakis.es> Anders Eriksson wrote: > > Hello! > > I need to create a lot of PDF files of some drawings (made in AutoCAD) > and I thought I try to do it with Python. The easiest way should be by > using PIL to read hpgl/2 and then create a PDF. One catch though..... > PIL can't read HPGL/2. > > Anyone that have created this 'plug-in' for PIL? > Anyone that knows where I can get the specification of HPGL? > > // Anders You might try printing to postscript in AutoCAD and converting the resulting .ps or .prn to pdf with ghostscript. From paul at prescod.net Thu Jul 20 02:51:19 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 01:51:19 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> Message-ID: <3976A167.FCB7EFE3@prescod.net> John Lull wrote: > > ... > > a..newOp..(b..otherOp..c) I really like the fact that the operator uses a word instead of a cryptic symbol, but I can't understand why anyone would prefer the above to: a.newOp(b.otherOp(c)) The only thing you've bought is the ability to look up the operation on the right-side of the operator and a slightly more symmetric "look". -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From * at spam.ruud.org Mon Jul 3 07:26:29 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 3 Jul 2000 13:26:29 +0200 Subject: Bug in math.frexp? References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> <200007031118.NAA22787@centurion.xs4all.nl> Message-ID: <87lmzjo3oa.fsf@hobbes.home.ruud.org> Thomas Wouters writes: > That means the > exponent has to be able to be negative, when the original number was > negative. The sign of the exponent is not necessarily equal to the sign of the number. - Ruud de Rooij -- ruud de rooij | *@spam.ruud.org | http://ruud.org From see at my.signature Thu Jul 20 23:20:19 2000 From: see at my.signature (Greg Ewing) Date: Fri, 21 Jul 2000 15:20:19 +1200 Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <8l68s5$3ht$1@nnrp1.deja.com> Message-ID: <3977C173.B93EB70B@my.signature> Matthias wrote: > > for x,y,z in a&b&c: But a&b&c parses as (a&b)&c, which is not what we want at all! What we're talking about can't be done by overloading a binary operator, because it's not binary -- it's n-ary, where n is the number of lists we're zipping. Furthermore, there's no reason why a, b and c couldn't be instances of classes which implement & in such a way that the result is a valid sequence type. -- 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 DavidA at ActiveState.com Wed Jul 5 13:22:51 2000 From: DavidA at ActiveState.com (David Ascher) Date: Wed, 5 Jul 2000 10:22:51 -0700 Subject: Wanted: compile.py In-Reply-To: <8jvnp5$f4r$1@nnrp1.deja.com> Message-ID: > Does anyone have a copy of compile.py referred to in the "Python > Building C/C++ extensions documentation". I can't reach the website, or > find it elsewhere. Apologies that the site is still broken. Please find it attached. --david ascher -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: compile.py URL: From richard_chamberlain at ntlworld.com Tue Jul 25 17:13:39 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Tue, 25 Jul 2000 22:13:39 +0100 Subject: tkinter: canvas: error? References: <8lkpp5$3qp$1@nnrp1.deja.com> Message-ID: Keith, canvas.coords doesn't expect a tuple try: canvas.coords(1,20,20,150,150) instead, Richard Keith Murphy wrote in message news:8lkpp5$3qp$1 at nnrp1.deja.com... > is this a bug? ...or is it a feature :) > > bbox = (80, 80, 120, 120) > canvas = Canvas() > canvas.pack() > canvas.create_rectangle(bbox, fill='black', tag='mybox') > canvas.coords(1, bbox) > > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 1205, in > coords > self.tk.splitlist( > TclError: wrong # coordinates: expected 0 or 4, got 1 > > thanks, > -->keith > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From akkhan at my-deja.com Fri Jul 14 01:32:16 2000 From: akkhan at my-deja.com (akkhan at my-deja.com) Date: Fri, 14 Jul 2000 05:32:16 GMT Subject: python cookbook Message-ID: <8km8l0$nc8$1@nnrp1.deja.com> I have a copy of O'Reilly's book, "Perl Cookbook" , and I'm looking for an equivalent Python cookbook. A book that has recipe's for doing a variety of different tasks in Python, such as socket programming and web automation. Any suggestions? -Adnan Sent via Deja.com http://www.deja.com/ Before you buy. From see at my.signature Thu Jul 20 00:36:22 2000 From: see at my.signature (Greg Ewing) Date: Thu, 20 Jul 2000 16:36:22 +1200 Subject: zip() : how about braid() References: Message-ID: <397681C6.FEAEE2E@my.signature> Michal Wallace wrote: > > braid(), as in hair.. Um, not quite, that suggests two or more strands being twisted around each other somehow, such as braid([1, 2, 3], ['a', 'b', 'c']) = [(1,'a'), ('b',2), (3,'c')] :-) -- 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 beat.bolli at earthling.net.bbs Sun Jul 16 10:30:02 2000 From: beat.bolli at earthling.net.bbs (beat.bolli at earthling.net.bbs) Date: 16 Jul 2000 14:30:02 GMT Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <3bQPVQ$krv@openbazaar.net> Hi all this is my first crack at Python patching. I was simply appalled to find '3'.zfill(5) not working anymore in 2.0b1, so I decided to do something about it. Now since zfill can be expressed as rjust with an optional pad characer argument, I implemented this. This is my 12th wedding anniversary present to the Python community. Live long and prosper! [Can't post an attachment?!] Beat Bolli -- PGP: 0x506A903A; 49D5 794A EA77 F907 764F D89E 304B 93CF 506A 903A ICBM: 47? 02' 43.0" N, 07? 16' 17.5" E (WGS84) --- stringobject.c.orig Sun Jul 16 15:15:15 2000 +++ stringobject.c Sun Jul 16 16:05:55 2000 @@ -1767,16 +1767,17 @@ } static char ljust__doc__[] = -"S.ljust(width) -> string\n\ +"S.ljust(width [, padchar]) -> string\n\ \n\ Return S left justified in a string of length width. Padding is\n\ -done using spaces."; +done using spaces unless padchar is given."; static PyObject * string_ljust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:ljust", &width)) + char padchar = ' '; + if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &padchar)) return NULL; if (PyString_GET_SIZE(self) >= width) { @@ -1784,21 +1785,22 @@ return (PyObject*) self; } - return pad(self, 0, width - PyString_GET_SIZE(self), ' '); + return pad(self, 0, width - PyString_GET_SIZE(self), padchar); } static char rjust__doc__[] = -"S.rjust(width) -> string\n\ +"S.rjust(width [, padchar]) -> string\n\ \n\ Return S right justified in a string of length width. Padding is\n\ -done using spaces."; +done using spaces unless padchar is given."; static PyObject * string_rjust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:rjust", &width)) + char padchar = ' '; + if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &padchar)) return NULL; if (PyString_GET_SIZE(self) >= width) { @@ -1806,7 +1808,7 @@ return (PyObject*) self; } - return pad(self, width - PyString_GET_SIZE(self), 0, ' '); + return pad(self, width - PyString_GET_SIZE(self), 0, padchar); } From jclonts at mastnet.net Wed Jul 12 03:54:10 2000 From: jclonts at mastnet.net (John Clonts) Date: Wed, 12 Jul 2000 02:54:10 -0500 Subject: Build Problem-- OverflowError: integer literal too large Message-ID: <396C2422.9E281DD@mastnet.net> I have just installed python 1.5.2 from sources and built it for the first time on my Redhat 5.x system. When trying to import module pgp I got a message "OverflowError: integer literal too large" I traced it and can reproduce this error by typing interactively: ii=4294967296 (On my older python 1.3 this causes no such problem) I have searched the FAQ and have poked and pored through the install process, but have not come up with anything. Thanks for your help (please!) :) Cheers, John From peter at schneider-kamp.de Mon Jul 24 08:40:31 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Mon, 24 Jul 2000 12:40:31 +0000 Subject: Variables in strings.. References: <81324605608.20000724121203@buz.ch> Message-ID: <397C393F.E4AFEBB4@schneider-kamp.de> Gabriel Ambuehl wrote: > > print "Hello $name" > would do the job. Now the only solution I could find in Python was > this awful > print "Hello %(name)s" % var() There is of course: print "Hello", name print "Hello", name[1] But that is probably not what you ask for. There is a thread about extending the print statement right now at the python-dev mailing list: http://www.python.org/pipermail/python-dev/2000-July/thread.html Part of this thread deals with what you are looking for. You may want to read the whole thread, but a good point to start is Tim's first post in that subthread: http://www.python.org/pipermail/python-dev/2000-July/013895.html > syntax which, after all, doesn't even seem to support lists as > print "Hello %(name[1])s" % var() > just raises a KeyError. May anyone point me to some more comfortable > ways than just endless concatenation of strings and lists which doesn't really > help for readibility (which is one of the main points why I'm > switching from Perl to Python)? As far as I have understood matters, the $name $(name[1]) syntax woul be able to do what you want. But then I have not really followed that thread closely. Peter P.S.: To python-dev: Wouldn't it be better to discuss this on python-list (or pep-dev)? -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From weeks at golden.dtc.hp.com Sun Jul 30 18:11:50 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 30 Jul 2000 22:11:50 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> <8lvu6d$8pa$2@news.dtc.hp.com> <8m23tv$pqc$1@newshost.accu.uu.nl> Message-ID: <8m2976$p9g$1@news.dtc.hp.com> Martijn Faassen (m.faassen at vet.uu.nl) wrote: : Perhaps there is some other semantics for 'value' and 'reference' stemming : from another programming tradition that I'm not aware about, though. There is, but it may wither away as time goes on. I guess I'm trying to keep it alive. Consider the following snippet of Python code: def f(x): x = a = f(a) At this point in the program, a is still . On the other hand, in the analogous Perl code, things are different. sub f { $_[0] = ; } $a = ; f($a); At this point, $a is . The function f did not just receive the pattern of bits that were written into $a. f received the *address* of the variable $a, dereferenced it, and called the result $_[0]. So assigning to $_[0] is the same as assigning to $a. Regards, Greg From olivierS.dagenaisP at canadaA.comM.bbs Mon Jul 17 00:00:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 17 Jul 2000 04:00:02 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bQka2$h4D@openbazaar.net> That's funny, but every time someone writes something like this at the end of the post, I'm reminded of Ned Flanders... Ned-Flanders-di-di-da-ly' yours.... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III > But-sometimes-I-wish-it-did-ly, From emile at fenx.com Tue Jul 18 20:09:46 2000 From: emile at fenx.com (Emile van Sebille) Date: Tue, 18 Jul 2000 17:09:46 -0700 Subject: Using filter() References: <8l1o9h$pto$1@news.rchland.ibm.com> <8l256r$d7n$1@netserv.univ-lille1.fr> <8l2g53$14ha$1@news.rchland.ibm.com> Message-ID: <8l45jv$3lru6$1@ID-11957.news.cis.dfn.de> That's an optimization that passes string.find into the lambda's namespace. -- Emile van Sebille emile at fenx.com ------------------- "Larry Whitley" wrote in message news:8l2g53$14ha$1 at news.rchland.ibm.com... > Thanks, that certainly works. > > I don't understand why lambda needs the second parameter. When I experiment > with > > filter( lambda x: string.find( x, name) == 0, fileList) > > in place of > > filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) > > it works as well. I suspect that your codeing come from something more > general. Can you explain the reason the sf=string.find construction is > useful in this context? From pj at cthulhu.engr.sgi.com Mon Jul 31 19:39:28 2000 From: pj at cthulhu.engr.sgi.com (Paul Jackson) Date: Mon, 31 Jul 2000 16:39:28 -0700 Subject: How does Python compare to ? In-Reply-To: <20000801011155.Q266@xs4all.nl> Message-ID: On Tue, 1 Aug 2000, Thomas Wouters wrote: > On Mon, Jul 31, 2000 at 10:36:00PM +0000, Paul Jackson wrote: > > In the same interval, python does some 196 milliseconds worth > > of stuff, including 52 open attempts, 34 stat attempts, 67 > > sigaction calls, 12 fstat's, 20 close's, 27 brk's, ... > > Okay, now try it with 'python -S'. This omits the 'site.py' import, which > itself requires a ton of other things. When using '-S', python is > consistently 10msec faster than perl, on my P2-something running Linux. That helps some, but not as much as you are seeing. I just saw the Python time on my Irix box, between loading libc and reading the 'print' command go from 178 msec down to 72 msec. Not close to the 9 or 10 msec for perl. I still see the stat for 'python' along my $PATH, the loading of the exceptions module, and the sigaction() calls. And it's still mostly cpu bound, with perhaps 33 msec spent very early on, doing just a handful of system calls (before the search for python along $PATH), and almost 20 msec spent digesting the exceptions module. The number of open and stat attempts goes down to 12 and 19, respectively. No change in the number of sigaction calls. -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From olivierS.dagenaisP at canadaA.comM Wed Jul 26 10:49:46 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 26 Jul 2000 14:49:46 GMT Subject: PythonWin/Scintilla aggressive folding... References: <2trf5.12076$4p3.93728@news-server.bigpond.net.au> <1csf5.40036$Gh.442627@news20.bellglobal.com> <7mwf5.12307$4p3.95451@news-server.bigpond.net.au> Message-ID: "Neil Hodgson" wrote: [about not making comments level-neutral] > Yes, a patch like this could help for your code. I introduced the level > neutral comments idea after developing the original strictly indentation > based code and using it on example files. First blank lines had to become > level neutral as lots of functions and methods have blank lines. Then I > found lots of commented out bits so made the comment lines work like blank > lines. Another heuristic that may be light weight would be that comment > lines try to bind in a forwards direction but this may require some > look-ahead. You mean to detect the indentation of the commented-out code? That might be hard, given you might have a comment like any of the following: "sharp", "sharp space", "sharp sharp", "sharp sharp space". I didn't realize this would be such an involved feature.... [about strings in code] > I think they bulk the compiled code up a bit but I doubt whether its > significant. If it's pretty much harmless and all it acts as is a seperator or an "end of definition" marker, like so: class ztApp ( wxApp ): def OnInit ( self, etc.. ): print "init..." (...) return true '' '' ...I-can-live-with-that-ly y'rs -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From bjorn at roguewave.com Fri Jul 14 13:47:23 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 14 Jul 2000 11:47:23 -0600 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <72usms41js8gtqdeemi0l7qo7dfe0t02rm@4ax.com> Message-ID: <396F522B.D4E143B5@roguewave.com> John Lull wrote: > > At the dawn of the third millenium (by the common reckoning), Bjorn > Pettersen wrote (with possible deletions): > > > It seems like you're trying to create a special purpose language here. > > Ie. I don't see it as general enough to be worth putting into the core > > unless you can come up with other use cases... Personally, I would much > > prefer the ability to overload the relational operators (individually, > > not through __cmp__). > > I'd like to disagree here. Matrices & linear algebra are fundamental > tools in an extremely broad set of domains. Unfortunately, most > programming languages don't seem to recognize that. > > Providing appropriate operators in the core is, IMO, as appropriate as > providing complex numbers. Providing an easy way to effectively add > them to the core when you install an appropriate add-on package is a > reasonable alternative. Their absence leads to really hard-to-read > code, and to me is a significant downside to Python. That is the problem with a general purpose language. It can't conveniently spell the common syntax for all possible special domains. I'd be very hesitant to make Python's core more complex just to make it easier to use in _one_ problem domain. (Note: I'm not saying I would be against a proposal that would be more generally useful... but you'll have to prove that first) As a programmer that has never used complex numbers for anything useful, I'd much rather remove them from Python than add special linear algebra syntax -- bjorn From rhicks at rma.edu Sat Jul 15 12:27:30 2000 From: rhicks at rma.edu (Robert) Date: Sat, 15 Jul 2000 16:27:30 GMT Subject: IDLE startup error on NT4 References: <8kodjp$aj2$1@nnrp1.deja.com> Message-ID: Also if you copy the tk dll to the python dll directory...that has worked for me... Robert "Andy Freeman" wrote in message news:8kodjp$aj2$1 at nnrp1.deja.com... > While starting IDLE on NT4, I get an error message about it not > finding tcl80.dll (and the other tk and tcl dlls), an error that > I don't get on Win95/98. No, it isn't the error message from > FixTk - FixTk appears happy - the problem seems to occur during > import _tkinter. > > My "fix" was to simply move the relevant files to the Python > DLL directory on NT, but surely there's something else going > on here. > > -andy > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From huaiyu_zhu at yahoo.com Tue Jul 18 17:21:12 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Tue, 18 Jul 2000 14:21:12 -0700 (PDT) Subject: Operators for matrix: current choices (Was Matlab vs Python ...) Message-ID: I posted this but didn't see it appearing. Now trying it again. This is a summary of what's discussed so far. On Tue, 18 Jul 2000, Moshe Zadka wrote: > ... we really meant that we'll help yo. Thanks! I see where compile() is called. But how is the parser itself called in python? Only used as C function? Now that we have a patch to add the new operators, is it possible to assemble these into a module? Before we plunge into this thing which may turn out to be more laborious than MatPy itself, we need to get a handle on what's involved. Let me make a list in order of my preference. Please jump in at any point that's both feasible and interesting enough for someone to actually do it: 1. Make a pure python way to introduce additional operators, like import NewOperator NewOperator.define(".+", "__dotadd__") NewOperator.define("+=", "__add_ab__") NewOperator.define(":=", "__copy__") Advantage: Pure python. Doesn't interfere with existing sytax. May be used for other operators. Not in the core, only affect the module that imports it. Disadvantage: Said to be quite difficult to implement (Why?). 2. Incorporate additional operators in python. Either . or @. Five to eight would be enough for linear algebra. Advantage: Pure python. Doesn't interfere with existing syntax. Disadvantage: Fixed choice for everybody. Unlikely to happen for quite some time until everyone agrees on everything. 3. Maintain a patch for additional operators. Advantage: once built, everything is pure python. Already have patch. Disadvantage: Can't guarantee most users can patch python, so in practice may need to maintain windows executable for download. 4. Temporarily use a.mmul(b) and a.emul(b) before things settle down. Then define __dotmul__ = emul, or the like, when they are available. Advantage: immediately implementable. Won't break anyone's code. Can also switch to __atmul__ = mmul or other choices later. Disadvantage: code somewhat cluttered. 5. Use a customized parser in python, with some compile tools? Advantage: can change anything. Can fine tune before settle down. Disadvantage: can change anything. Slower than 1. Don't know how to use it. (But maybe they can be turned into option 1?) 6. Maintain two classes: E and M. Advantage: no need for new operators. Disadvantage: artificial casting likely to be maintenance nightmare, because we change objects while we really want to change operators. A variant: only use .E for elementwise. Always return matrixwise. This is simply just using casting to help select among two methods denoted by the same binary symbol. Does not look much better than 4 but worth considering. 7. Use prefix function call syntax: Advantage: very simple to implement Disadvantage: very difficult-to-read user code. Won't be used in practice. 8. Use preprocessor on another file extension like .mpy Advantage: user code looks good Disadvantage: two set of files to maintain. No implementation yet. The preprocessor need to be able to see the operators, their scopes and precedence. If this is possible, why not turn it to 5 or even 1? Unlikely used in practice unless the preprocessing step is invisible. 9. Use a miniparser for expressions in strings. Advantage: artificially looks like pure python. Disadvantage: the whole syntax is inside the string, which becomes a special syntax zone with severe limitations. These halfline programs completely lack the elegance of python code. Yuck! 10. Use list comprehension. Advantage: apparently none. Disadvantage: admitting that elementwise operations cannot be encapsulated. Need a new syntactic structure with brackets, loops, dummy variables, scope delimitor (: or ;) implicitly parrallel for loops and implicit casting. Yuck!!! Note: I dislike some of the proposals because they look like ugly hacks to use the abundance of class names, method names, function names and string literals to walk around what is clearly just a shortage of a few operator symbols. But I don't think we can reach consensus on such issue anyhow. If there is no more proposal forthcoming, I will adopt a combination of options 3 and 4, and hoping for someone to come up with 1. The largest problem with this approach is this: If we can't guarantee the patch is usable everywhere, do we want everybody using these operators? Will it run on another machine, or even another version of python? If such a status persists for a long time I guess all codes will settle into a local optimum, something like (a.emul(b))*(c.emul(d)) and an opportunity would be lost, even if in reality most people actually like (a.*b)*(c.*d). This incidentally also removes an opportunity to see if elementwise operators might be useful elsewhere, like ["%5.2f", "%-8s", "%.2g"] .% [pi, 'short', 1] ["Alice", "Bob", "Charlie"] .+ "is" .+ ["girl", "boy", "boy"] The argument "if it finds wide-spread use we may put it in the language" has a severe limitation - if it is technically very difficult for users to use a feature that's not in the language, it will unlikely to find wide-spread use and may never get into the language. That's why I really hope something like 1 can come up. Inputs greatly appreciated. Huaiyu From slinkp23 at yahoo.com Wed Jul 26 17:47:08 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 26 Jul 2000 17:47:08 -0400 Subject: Problems installing PIL on linux References: <397F1232.27791F0C@yahoo.com> <20000727082933.C9696@inkontact.com.au> Message-ID: <397F5C5C.F23FADF0@yahoo.com> Steve Purcell wrote: > My advice is to get the RPM for 1.0b1 unless there's a particular need for > fixes or features that can only be found in 1.1. Works fine for me. Well, I guess I'll do that. Thanks for the tip. Incidentally, one reason I didn't do this before was that rpmfind didn't turn up any python imaging library RPMs for RedHat. There were some SuSE packages but I don't know what the difference is, if any. Fortunately a Google search turned up a version for RedHat at: http://www.linuxfocus.org/common/src/article120/python-imaging-rh-1.0b1-3.i386.rpm I just installed that and it seems to be working OK... ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From bellamy at freesurf.fr.bbs Sun Jul 16 11:10:03 2000 From: bellamy at freesurf.fr.bbs (bellamy at freesurf.fr.bbs) Date: 16 Jul 2000 15:10:03 GMT Subject: Newbie question: PyOpenGL installation Message-ID: <3bQQXS$jO4@openbazaar.net> I'd like to use OpenGL for Python with Linux, but I'm really confused with the installation. I'm used to RPMs, or installing software from sources in .tar.gz format with the regular './configure', 'make', and 'make install', but I just can't understand the explanations on PyOpenGL web site. If anyone who did it OK could give me a little help, that would be just great (or if there's a RPM installation package for PyOpenGL somewhere on the planet...). Thanks a lot. From hzhu at localhost.localdomain Sat Jul 15 02:06:24 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Sat, 15 Jul 2000 06:06:24 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <396F1914.DBE530CA@prescod.net> <396FE1CE.FE9967A8@prescod.net> Message-ID: On Fri, 14 Jul 2000 23:00:14 -0500, Paul Prescod wrote: >> The problem is that Python provides no way for an add-on module to >> define new operators. > >But that's not really an accident. There are languages that allow you to >define new operators. REBOL is the most flexible example. Python >emphasizes syntactic *simplicity*. Well, I think there are two levels of syntactic simplicity: 1. Different structures: like the difference among identifiers, various literals (number, list, dict, string), indentation delimited blocks, function arguments. 2. Allowed members within a structure: like which function names are legal, which operators are binary, which functions can be overloaded. To keep the first kind of simplicity we need to restrict number of things allowed. But to keep simplicity of the second kind we need to remove arbitrary restrictions. For example, I had included a file aux.py in the MatPy package which caused a great deal of headache for Windows users. It turned out that Windows do not allow file name to be aux because it's a device name. This kind of unreadonable restrictions represent complexity, not simplicity. Python already provides both function names and binary operators, so the first level issue is not there. However, while it gives almost unlimited supply of function names that can be overridden, there is only a handful of binary operators which have deep rooted meanings and not enough for overloading. This limit is largely arbitrary, and is therefore complexity. >> Unfortunately, the current lack of appropriate notation makes these >> problems very difficult to code clearly. > >Every domain of computing would be enhanced with special notation. Text >processing, XML, COM, databases, Web programming etc. Haven't we already talked this through? Text processing already got its special syntax, even of the first level, which is quoted string. Within a quoted string you could put in any text sequence. In this specific domain it happens that only very limited number of binary operators are required, and they are duly provided, like string + string, string % string, or string * number. All the other things you mentioned could be built on top of this. This domain is not even as mature as matrix computation - in many earlier languages it was though that special syntax is needed for printing, formats and regular expressions, which turned out to be just ordinary string operations and functions, as python shows. On the other hand, for proper matrix operation, there is not much need for any additional first level structure, but there does exist a great need for a larger supply of binary operators. What we are saying is that extending the number of operators overridable by applications represents a much smaller risk of incompatability than giving everyone a complete parser. With the given operators, all the fields like scientific computation, graphics, statistical analysis and artificial intelligence could also be built on top of this. Before you dismiss numerical computation as just another domain, why not try a few packages and get a feeling of how large the domain is? Huaiyu From rgruet at ina.fr Fri Jul 7 05:29:20 2000 From: rgruet at ina.fr (Richard Gruet) Date: Fri, 07 Jul 2000 11:29:20 +0200 Subject: win32clipboard module issue Message-ID: <3965A2F0.8E8958B5@ina.fr> Hi all, In Mark hammond's win32clipboard module, the function SetClipboardData requires a memory handle as its 2nd argument (hMem), and it's precised that this handle must have been allocated via GlobalAlloc(). But I wonder how to get such a handle from Python :-( Can anyone help ? Thanks Richard Gruet From thomas at cintra.no Mon Jul 31 07:40:45 2000 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 31 Jul 2000 11:40:45 GMT Subject: [3rd Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> <39852224.FE658DC5@nowonder.de> Message-ID: <398763f2.270509351@news.online.no> I just want to know if this is an open letter, like open for everybody to sign and say "Yeah, damn straight! Time to come clean, CNRI!" or something like that. Do I need to be a professor, doctor or a self-proclaimed guru to be on that signature-list? I'm concerned about this issue too, concerned about the licence-troubles the open-source community seem to be having these days, but especially troubled about the fact that stuff like this slows down the development-cycle of Python. The longer it takes for a beta to get into users hands the longer it takes before bugs are found and removed. Longer time to wait for a stable release of Python 2.0. And I cannot get my hands on that sweet baby quick enough!! :-> I won't be disappointed, ok probably a little bit, if you just want serious, hard-core productive coders on your signature list, but as an open commmunity, I'd like to express my opionon somehow too. Some clarification before the clarification, pleez. Thomas From richard_chamberlain at my-deja.com Fri Jul 28 03:56:15 2000 From: richard_chamberlain at my-deja.com (richard_chamberlain at my-deja.com) Date: Fri, 28 Jul 2000 07:56:15 GMT Subject: Win32 drive mapping... aka "net use" References: <8lr9nc$tdf$1@nnrp1.deja.com> Message-ID: <8lreau$15t$1@nnrp1.deja.com> I think you want to use the win32net extension. If you select Help - Others - Win32 Extensions in PythonWin there is a help section on it. Richard In article <8lr9nc$tdf$1 at nnrp1.deja.com>, lshuler at my-deja.com wrote: > Is there an API using Win32 extensions to map a > drive share? I have not found one yet and have > tried searching "Win32 map drive". I am looking > for the equivalent of: > > net use > > If not, is there an alternative other than making > a call to system("net use "). > > Thanks in advance, > Lance > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From falk.lehmann at gmx.net Tue Jul 18 00:41:39 2000 From: falk.lehmann at gmx.net (falk.lehmann at gmx.net) Date: Tue, 18 Jul 2000 04:41:39 GMT Subject: compiling Python 1.6a2 using VC++ 6.0 Message-ID: <8l0n61$vlj$1@nnrp1.deja.com> I try to compile Python 1.6a2 on a WinNT box using VC++ 6.0. All packages except bsddbmodule and socketmodule compile without errors. When I add the include path of the the db-3.1.14 distribution to ..\db-3.1.14\build_win32 the following error messages appear. I have tried to include other header files then db.h but nothing works. ================================================================= K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2065: 'HASHINFO' : undeclared identifier K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2146: syntax error : missing ';' before identifier 'info' K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(90) : error C2065: 'info' : undeclared identifier K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(95) : error C2224: left of '.bsize' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(96) : error C2224: left of '.ffactor' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(97) : error C2224: left of '.nelem' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(98) : error C2224: left of '.cachesize' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(99) : error C2224: left of '.hash' must have struct/union type K:\Projects\Python-1.6a2\Modules\bsddbmodule.c(100) : error C2224: left of '.lorder' must have struct/union type ... ... ========================================================== Any help is appreciated. Falk Sent via Deja.com http://www.deja.com/ Before you buy. From nobody at nowhere.nohow Sat Jul 29 21:48:32 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 30 Jul 2000 01:48:32 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 19:52:54 GMT, Suchandra Thapa wrote: >Alex Martelli wrote: >>It matters if you care about how easy/hard it is to turn those >>"non-programmers" into "programmers in the language you >>are designing". E.g., the CP4E project, which used to be >>aimed at turning _everybody_ into programmers, had better > Actually I think it would be easier for non-programmers to >learn a language if it has strict typing. I concur. In non-programming, life is strictly typed. Allowed operations are determined by the type of the object. You can't make a phone call on a waffle-iron. Were I to _try_ to make a phone call on a waffle-iron, it doesn't "automagically" convert istelf into a telephone. Instead, I get a rather interesting burn pattern on the side of my head. You can tune a piano, but you can't tune a fish... -- Grant Edwards grante Yow! Should I get at locked in the PRINCICAL'S visi.com OFFICE today -- or have a VASECTOMY?? From m.faassen at vet.uu.nl Thu Jul 27 15:26:00 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Jul 2000 19:26:00 GMT Subject: The State of Python References: Message-ID: <8lq2c8$hg2$2@newshost.accu.uu.nl> Tim Peters wrote: [snip] > I'm not a lawyer either (as you well know ), but at least in America > you hold copyright on your works whether or not you state it explicitly. I believe it's actually the same in other countries in which the Berne convention on copyright is in effect. If you write it, you get copyright, basically. Ah, right, article 5: (2) The enjoyment and the exercise of these rights shall not be subject to any formality; such enjoyment and such exercise shall be independent of the existence of protection in the country of origin of the work. Consequently, apart from the provisions of this Convention, the extent of protection, as well as the means of redress afforded to the author to protect his rights, shall be governed exclusively by the laws of the country where protection is claimed. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gmcm at hypernet.com Sun Jul 23 14:02:54 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 23 Jul 2000 18:02:54 GMT Subject: New PEP: Attribute Access Handlers References: <39791F0C.CDC13E79@prescod.net> <39792795.B5B0D18C@roguewave.com> <39792C74.E7E3DB2B@prescod.net> <397933DA.46B072BF@roguewave.com> <8F797551Agmcmhypernetcom@199.171.54.194> Message-ID: <8F7A86AE8gmcmhypernetcom@199.171.54.155> Neel Krishnaswami wrote: >Gordon McMillan wrote: [Paul's proposal creates one access handler per attribute...] >I'm afraid I still don't understand. Oh, I think you do . >If I wanted to use separate >accessors/mutators, what would I do with the current proposal? One possibility is to oppose it, though that's probably not necessary, since it's not yet coherent. >An example (using separate accessors) that I'd like to see translated: > >class Foo: > def __init__(self, x): > self.x = x > > >class LogWrites(Foo): > def __set_x__(self, x, val): > add_to_write_log() > self.__dict__['x'] = val The current proposal is to write def __attr_x__(self, op, val=None): if op == 'get': ... elif op == 'set': ... elif op == 'del': ... IOW, in the current proposal, you can't. - Gordon From fiona at sitegnome.com Tue Jul 25 07:05:44 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 25 Jul 2000 11:05:44 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 25th, 2000 Message-ID: <20000725110544.8021.qmail@synop.com> Hi All, The latest entries to be entered into http://python.faqts.com cheers, Fiona Czuczman Including: - Can I run python code with files that don't end with the python extensions(.py and others)? - Can someone please point me to link(s) to python modules dealing with cryptography e.g ssleay or open ssl wrappers? - How can I hold x,y,z coordinates in a multi-level grid? ## New Entries ################################################# ------------------------------------------------------------- Can I run python code with files that don't end with the python extensions(.py and others)? http://www.faqts.com/knowledge-base/view.phtml/aid/4997 ------------------------------------------------------------- Fiona Czuczman Steve Purcell Yes. Simply 'chmod +x scriptname' and make the first line of the script read '#!/usr/bin/env python'. But, an executable file is almost as obviously a script as a '.py' file. ------------------------------------------------------------- Can someone please point me to link(s) to python modules dealing with cryptography e.g ssleay or open ssl wrappers? http://www.faqts.com/knowledge-base/view.phtml/aid/4998 ------------------------------------------------------------- Fiona Czuczman Ng Pheng Siong M2Crypto at http://www.post1.com/home/ngps/m2 is a Python interface to OpenSSL's crypto, SSL and S/MIME functionality. python-crypto at egroups.com is a low-volume mailing list talking about Python and crypto. ------------------------------------------------------------- How can I hold x,y,z coordinates in a multi-level grid? http://www.faqts.com/knowledge-base/view.phtml/aid/4999 ------------------------------------------------------------- Fiona Czuczman Peter Schneider-Kamp You can use lists of lists of lists of 3-tuples containing the coordinates. Adressing is done via repeated indexing. For example the corners of a unit cube between 0 and 1: >>> a = [ [ [(0,0,0), (0,0,1)], [(0,1,0), (0,1,1)] ], ... [ [(1,0,0), (1,0,1)], [(1,1,0), (1,1,1)] ] ] >>> a[0][0][0] (0, 0, 0) >>> a[1][0][1] (1, 0, 1) >>> You can also use NumPy. Chances are (if only slight ones) that it will be included with 2.0 (see PEP 206 http://python.sourceforge.net/peps/pep-0206.html) From tim_one at email.msn.com Thu Jul 27 18:37:14 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 27 Jul 2000 18:37:14 -0400 Subject: The State of Python In-Reply-To: Message-ID: [Stian Husemoen] > If Python had the GPL-license we would never have gotten into > this mess. Indeed, if Python had been GPL'ed it may not even have survived until now . > My main argument for *not* using Python at first was that it didn't > have the GPL attached to it... Yes, the GPL is more restricive > but you can't have both ways. The old Python license served it very well for a decade. The new Python license will almost certainly also be OSI certified, *compatible* with the GPL, and allow proprietary commercial use. What we haven't been able to avoid is massively unproductive legal wrangling -- but nothing can guarantee to save you from that. > There will always be a danger of this happening again until someone > make a GNU version of Python. (btw. would this be possible?) The old (still current, as of today) Python license was very permissive. If you want to grab the source for Python 1.5.2 and re-release it under the GPL, I think that would be fine. CNRI may not agree, though. Can't guess about the new Python license (I've seen working drafts, but I don't feel that I understand it well enough to hazard a guess about what it means in all cases). From kuchler at ajubasolutions.com Fri Jul 28 02:23:26 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Thu, 27 Jul 2000 23:23:26 -0700 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> Message-ID: <398126DE.6E2C2627@ajubasolutions.com> Cameron Laird wrote: > > is the most pro- > vocative summary I've yet seen of Larry Wall's talk at the O'Reilly > Open Source Convention. Mark-Jason Dominus's typically masterful > provides technical > details. I think at least the first of these will reward a quick > read by everyone involved in planning the futures of, for example, > Python and Tcl. I applaud Conrad Schneiker for his care in prepar- > ing this. More interesting to me (and perhaps more interesting to some here in the comunity) are the notes from the initial brainstorming session on July 17th about what Perl 6 will be (what are the reasons for making it, what features might be added, etc.) http://www.perl.org/perl6/pr/initial_meeting.html Lots if interesting little tidbits in here. They talk of adding stacked IO channels "a l a Tcl" an event loop similar to tcls to allow packges like Tk to play better with perl, and they talk about basing the rewrite around unicode and threads, since it has been difficult for them to get unicode and threads working with the Perl 5 sources. These are just a few of the interesting things mentioned in that article. To steal some terminology, I like their naming of what we call the "Tcl sumo distribution", the Perl SDK. A set of useful extensions and tools that will be distributed with Perl 6. --Dan From thiele at muc.das-werk.de Mon Jul 3 07:30:22 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 13:30:22 +0200 Subject: making widgets invisible Message-ID: <3960794E.6E2B36E6@muc.das-werk.de> How can I realize that a set of widgets (buttons and entries) is invisible when I don't need them and visible when I need them? One solution is to create a dialog window (or frame) and destroy it then. But is there a better one? Withdrawn works only with top level widgets. Thanks Thomas From cookedm at physics.mcmaster.ca.bbs Mon Jul 17 17:50:02 2000 From: cookedm at physics.mcmaster.ca.bbs (cookedm at physics.mcmaster.ca.bbs) Date: 17 Jul 2000 21:50:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRQTQ$mD_@openbazaar.net> At some point, hzhu at localhost.localdomain (Huaiyu Zhu) wrote: > On Mon, 17 Jul 2000 14:12:02 -0500, Paul Prescod wrote: > > >Maybe you should consider how to scale back your syntactic request. > >Perhaps a single keyword or symbol at the beginning of an expression > >could make it element-wise or matrix-wise. > > Well, that would be fine if it is workable, ie, when they don't appear in > the same expression. > > Consider the proposal of having two classes, Matrixwise and Elementwise, > with methods to cast to each other. I don't know why > > (a.E()*b.E()).M()*(c.E()*d.E()).M() > > would be more preferable to > > (a.*b)*(c.*d) Well, it doesn't have to be as complicated as your first example. Assume the default is Matrixwise, and we get rid of some ()'s by overriding __getattr__, so that we can right (a.E*b.E)*(c.E*d.E) Better? It's not great, you have to remember to put .E on both. Ahh! But what if we assume that if one operand has .E, the other does also! Then we can write (a.E*b)*(c.E*d) which is two characters more than your second example. -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From aahz at netcom.com Mon Jul 3 10:18:42 2000 From: aahz at netcom.com (Aahz Maruch) Date: 3 Jul 2000 14:18:42 GMT Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> Message-ID: <8jq7c2$2f8$1@slb6.atl.mindspring.net> In article <39606DAC.49A502DB at muc.das-werk.de>, Thomas Thiele wrote: > >The problem is I am using threads, fork and exec. And I want to have the >same behaviour using NT. You'll need to look at the Win32 extensions to do the fork/exec stuff. I've got zero experience with that, but hopefully either the docs are good enough or Mark Hammond will be by shortly. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From fredp at mygale.org.nospam Fri Jul 28 08:43:36 2000 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 28 Jul 2000 12:43:36 GMT Subject: PY to HTML References: Message-ID: <8F7F9B7B7PaCmAnRDLM@161.48.76.20> colinmeeks at home.com (Colin Meeks) said : >Excellent. Thanks. > >Colin useful to me also -- thanks twice ! -- YAFAP : http://www.multimania.com/fredp/ From grey at despair.rpglink.com Fri Jul 28 19:17:22 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 23:17:22 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> <8lt3pm$bgg$2@newsg4.svr.pol.co.uk> Message-ID: On Fri, 28 Jul 2000 23:47:46 +0100, Bill de h?ra wrote: >You've obviously never seen the damage programming can do to a company. Nope. Of course that wayward this wayward sequence cause some problems. mount mail:/ tmp cp -p tmp tmp2 ^C rm -rf tmp -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From ejr at lotus.CS.Berkeley.EDU Sat Jul 22 22:56:16 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 23 Jul 2000 02:56:16 GMT Subject: [long and fussy] But what do these operators _mean_? References: <8la3bo$b55$1@agate.berkeley.edu> Message-ID: <8ldmsg$jds$1@agate.berkeley.edu> And Huaiyu Zhu writes: - I tend to agree on what you said about error bounds. Would you like to - summarize what you consider should go into the specifications? Um, the same as in the BLAS and LAPACK? ;) Seriously, though, I need to think about this some more. And do some back-reading, like checking some of the papers on language support for complex, etc. No on-line copies are available, but I need to make a library run soon anyways. - On the other hand I think a lot of this should go to the packages rather - than the operators. I don't. Historically, unless people have required error bounds from the very beginning, package providers have gone the fast-but- wrong route. That's why the Alpha happened at all. See yet another of Dr. Kahan's writings for examples: http://www.cs.berkeley.edu/~wkahan/ieee754status/baleful.ps I'm not always citing his papers just because I know him; they're really the most lucid, easily available writings I've seen on the topic. If anyone can point at others, please do. - The specification should be broad enough so even - special subclasses like sparse matrices, specially shaped matrices, - etc, or speed-greedy algorithms would not have to conflict with it. Special matrices always have _better_ bounds, so there's no issue there. And speed-over-accuracy algorithms should not be encouraged for general use at all. Like I said, they may be appropriate for very special uses, but those people are likely to use their own, special packages for those environments. And they're likely to implement most of it in C, anyways. - My idea is to specify a collection of parameters to be guaranteed by the - numerical packages, each specifying its own values for these paramters. Hm. I don't think that's too far from what I want. LAPACK and the new BLAST standard give ``environmental query routines'' to get the underflow, overflow, eps, etc. values, then the standard specifies the error in terms of those values. Given that that's the only thing even possible with varying hardware and arithmetics... - Does this somehow alleviate your concern about untrackable - implementations? Maybe. Unfortunately, it's been a nice, relaxing Saturday, so I may not be thinking properly. ;) - Good question. Any volunteers? I'm going to subscribe to the Numerical Python list tomorrow or so, then start looking over the {float,complex}object.c code. - I don't think the language should make any guarantee on packages not - distributed with it. I see your point, but there are the famous ``language design is library design'' and ``library design is language design'' quotes. I would not feel at all bad if the language guaranteed that results are reasonably accurate. I would feel horribly if it didn't, and if that lack affected people. - The point is, for any serious numerical work, users should check the - package they are importing, rather than a generic description of the - operators. Yes, but how many will? - There can be better algorithms that are considered better simply - because they are faster. I disagree. You can _always_ produce a mostly wrong answer quickly. Would you be making the same arguments for faster but inaccurate _integer_ arithmetic? Now, there are cases where a few particular calculations trade the most-accurate position in different regions. The general solution there is to add a few tests before them to find the right region. Unfortunately, that's not always feasible... - Would such packages be banned from using these operators? >From supplying implementations for them? Sure. Keep in mind that we cannot (and should not) legally ban them (the way a certain other language does). We can state clearly that they do _not_ meet the minimum requirements. How woul you feel about a Python implementation that had 3 == 1 + 1? - Where should users look for definite specs? www.python.org comes to mind. ;) - The common minimum should clearly be restricted to one package. I can't agree to this. Especially since I'm also talking about things that aren't in packages, like complex arithmetic. AUGH! I just looked at complex division: > Py_complex c_quot(Py_complex a, Py_complex b) > { > Py_complex r; > double d = b.real*b.real + b.imag*b.imag; > if (d == 0.) > errno = EDOM; > r.real = (a.real*b.real + a.imag*b.imag)/d; > r.imag = (a.imag*b.real - a.real*b.imag)/d; > return r; > } The calculation of d can overflow, destroying a computation that should have been just fine. The standard solution is to scale it by 1/b.real (consider it as a dot product). I need to double- check this, but I don't think the general accuracy is changed if you compute 1/d and multiply... I'll try to fix and test this sometime this week. sigh. Time. The best fix (assuming you're not trapping on overflow) is to simply compute it much like it is, test for the error afterwards, and re-compute it if it was screwed up. - I would still think that's mainly caused by matlab's monolithic nature. I agree with Travis Oliphant that the availability of packages is also a huge deal... - There are many packages that implement various numerical routines. They are - closely related to lapack, linpack, eispack, cephes or whatever names their - underlying fortran or C packages have. LINPACK and EISPACK are dead. They are both slower and more error- prone than the latest LAPACK. Cephes is for elementary functions, and it provides and documents appropriately good errors. This all from a discussion over linear algebra operators, so I've mainly been thinking of the impact of the error bounds on the operators, not necessarily of those in functions. Here's another idea: Consider the interface-provider idea. It's used pretty frequently in Java, at least. The standard interface for various numerical routines can have guaranteed error bounds. The interface can have various drivers behind it, chosen by specifying in the installation or by user routine. Something like ``import Numeric'' would import the default implementation. All implementations that could be the default must obey the bounds. I think we're arguing the same point but with different words... Like I said, it's been a nice Saturday, so I'm probably not thinking too clearly on these issues. Gotta run out to a nice dinner, too, so I'm rushing. I'll put more thought into this soon. But we should try to move this to the correct mailing list, imho. - There can be also one or two assembled packages for dummies-only, with the - easiest interface and most foolproof implementation. The ``import Numeric'' + implementation thingy... Jason From bragib at my-deja.com Mon Jul 31 16:39:01 2000 From: bragib at my-deja.com (bragib at my-deja.com) Date: Mon, 31 Jul 2000 20:39:01 GMT Subject: check file exists References: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: <8m4o54$f91$1@nnrp1.deja.com> os.path.exists('file.ext') returns 1 or 0 Bragi In article <3985DDA3.E811F70A at ncsa.uiuc.edu>, Randy Heiland wrote: > How does one test for whether or not a (Unix) file exists? > > thanks, > Randy > > Sent via Deja.com http://www.deja.com/ Before you buy. From horst at proceryon.at Mon Jul 31 03:39:03 2000 From: horst at proceryon.at (Horst Gassner) Date: Mon, 31 Jul 2000 09:39:03 +0200 Subject: QUESTION: COM objects in python? References: <8lt4ra+sgp4@eGroups.com> Message-ID: <39852D17.7D9544A4@proceryon.at> Hello! > Mark probably didn't mention because he wrote it but there's a great book by > him and Andy Robinson caled Python Programming on Win32. It gives some > excellent examples of exactly what you want to do. I bought this book just two weeks ago and like this book very much! If you want to write python programs for Windows this book is a must. Nice greetings Horst From daniel at dittmar.net Sun Jul 9 06:46:51 2000 From: daniel at dittmar.net (Daniel Dittmar) Date: Sun, 09 Jul 2000 12:46:51 +0200 Subject: Borland C++ Builder make files for Python? References: <3967DBDB.7FBDD3E5@tds.net> Message-ID: <3968581B.C9571894@dittmar.net> I think Borland supplies a tool to convert Visual C++ workspaces to C++ Builder projects, at least they mention VCTOBPR.EXE in their help files for the free command line tools. Unfortunately, this tool is not part of the free tools, so please submit your converted makefiles to the Python team. BTW, I don't think it is really necessary to rebuild Python, just try linking against the import lib created from the python15.dll. Daniel "Edward K. Ream" wrote: > > I would like to build the Python interpreter and library using Borland > C++ Builder 4 so that I can embed Python in an app. Does anyone have > such a makefile that works? > From erwin at andreasen.com Sun Jul 30 08:19:23 2000 From: erwin at andreasen.com (Erwin S. Andreasen) Date: 30 Jul 2000 12:19:23 GMT Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> Message-ID: On Sun, 30 Jul 2000 12:07:59 GMT, Neil Hodgson wrote: > I can explain how to use calldll. If you want to know how to write your >own extensions then you should read the "Extending and Embedding the Python >Interpreter" document which is part of the standard documentation package >and should have been installed when you installed Python. > > calldll is a low level Python extension libary which contains functions >for creating buffers, loading DLLs, finding the address of functions within >the loaded DLLs, and calling the functions. On top of that is a higher level >windll module that makes it more convenient to call. Interesting -- it should be possible to create a similar module for loading shared objects under UNIX and calling functions in those. Although it wouldn't be that easy, since you would need to find a way to call a function pointer with a variable number of arguments in C. Has anyone created something like this? Is there any interest in it? It would allow interfacing to shared libraries without needing to compile a C-module or having to get a compiled C module just for your specific architecture (at the expense of some speed, of course). Of course, such a module would hae to be part of the standard Python for it to be really useful :) -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT Networks ======================================================================= From gpepice1 at nycap.rr.com Fri Jul 28 22:37:41 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 29 Jul 2000 02:37:41 GMT Subject: Python interface to Oracle References: <3951C636.2E985CE@ust.hk> <87og4t26zz.fsf@ns.f7.ph4.lan> Message-ID: <39824433.1F037EA7@nycap.rr.com> Oracle can be downloaded from ftp.oracle.com. Andreas Rottmann wrote: > David YEUNG writes: > > > Does anyone know if any python module has been developed for > > interfacing with Oracle8i database on Linux? > > > That would be interesting for me, too. I'm likely to develop one, if > it doesn't exist, since I have the infrastructure ready - see > GQL.sourceforge.net. > > All it would take is writing an Oracle driver for GQL, which can be > done within a few days. Anyway, I would appreciate if someone could > help me with that, since I don't have Oracle and am not willing to pay > the $$$. > > Andy > -- > Andreas Rottmann | Dru at ICQ | 54523380 at ICQ | a.rottmann at gmx.at > Pfeilgasse 4-6/725 | A-1080 Wien | Austria | Europe > http://www.8ung.at/rotty | Key is there | gpg (GnuPG) 1.0.1 > Fingerprint | 3E9A C485 49A4 1D17 2EA7 2BA7 22AE C9BF 8173 6279 > [one of 78,35% Austrians who didn?t vote for Haider!] From dnotspam-jen at personic.com Sun Jul 2 18:22:29 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:22:29 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> <8jlmj0$r1q$1@supernews.com> Message-ID: <395fbd8c$1$5622@wodc7nh0.news.uu.net> Yes, I think for the first version I will do this (no need to deal with multi-threading or the network this way). But after the initial version works (hopefully later today), I'll try to move on to one of the other methods described above, probably starting with XML-RPC if I can find more info on it. Thanks, all! Jen "Dale Strickland-Clark" wrote in message news:8jlmj0$r1q$1 at supernews.com... > Start simple. > > Unless this is particularly time critical, I'd create a folder on the Build > server and share it with suitably limited access. > > Give the Web server write access to the folder. > > The Web server writes a batch file or Python script to the shared directory. > > Every few minutes the Build server checks this folder for a file and > executes it. > > If you need some feedback, it could change the name of the file or move it > to a subdirectory while it's running so the Web server can see it's active. > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants > > donotspam-jen at personic.com wrote in message > news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want > a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query > the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > > > I've read a little about SOAP, but I think that my needs are probably a > lot > > simpler than that. The easiest way to accomplish this is to setup a Web > > server on each of the build machines, too, I guess ... but I was hoping > that > > I could just have the scripts that run on the build servers run as NT > > services. > > > > Thanks! > > > > Jen > > > > > > > > > > From gmcm at hypernet.com Thu Jul 20 19:34:53 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jul 2000 23:34:53 GMT Subject: Determine path of current module? References: <3976AA30.1C4F62B8@schlund.de> <8l6bis$elb$1@pollux.ip-plus.net> <3976B678.83F01206@schlund.de> Message-ID: <8F77CB1ABgmcmhypernetcom@199.171.54.155> Carsten Gaebler wrote: >"J?rgen Hermann" wrote: > >> ### mypath.py >> import sys >> print sys.modules[__name__].__file__ >> >> [d:\tmp]python -c "import mypath" >> mypath.py > >Well, that's just the filename. What I'm looking for is the complete path, >"d:\tmp\mypath.py" in this case. First, you don't need "sys.modules[__name__].__file__", just "__file__". Second, it only lacks a path when it was found in '.', so os.path.abspath(__file__) will do fine for anything except the top level script (which doesn't have a __file__ attribute). -Gordon From jgraves3 at austin.rr.com Tue Jul 18 13:41:33 2000 From: jgraves3 at austin.rr.com (jay graves) Date: Tue, 18 Jul 2000 17:41:33 GMT Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <397495d7.20215540@news-server> On Tue, 18 Jul 2000 10:08:13 -0400, Andrew Kuchling wrote: >This is a first experiment in whether I can make a useful, >interesting, somewhat coherent summary of python-dev activity. >If reaction is favorable, and time permits, it may become a biweekly >posting. > >--amk I like this type of posting VERY VERY much. Please continue. Jay Graves From olivierS.dagenaisP at canadaA.comM Tue Jul 25 11:36:44 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Tue, 25 Jul 2000 15:36:44 GMT Subject: PythonWin/Scintilla aggressive folding... Message-ID: I have the following wxPython code: class ztApp ( wxApp ) : def OnInit ( self ) : frame = ztLoader ( ) frame.Show ( true ) self.SetTopWindow ( frame ) return true # Main code pngHandler = wxPNGHandler ( ) wxImage_AddHandler ( pngHandler ) app = ztApp ( 0 ) app.MainLoop ( ) ...which is fine and dandy. Next, I want fold away the class, and the result is this: class ztApp ( wxApp ) : pngHandler = wxPNGHandler ( ) wxImage_AddHandler ( pngHandler ) app = ztApp ( 0 ) app.MainLoop ( ) My comment is missing. It isn't part of the class definition, yet was "gobbled up" by the fold. Can I prevent this? Also, I'd like it to be even smarter and not gobble up blank lines after the class definition, so that the end result would look like so: class ztApp ( wxApp ) : # Main code pngHandler = wxPNGHandler ( ) wxImage_AddHandler ( pngHandler ) app = ztApp ( 0 ) app.MainLoop ( ) Ideas? This seems to be a Scintilla issue, as pywin\framework\editor\color\coloreditor.py seems to indicate that PythonWin doesn't do the actual folding: def FoldExpandEvent(self, event): if not self.bFolding: win32api.MessageBeep() return win32ui.DoWaitCursor(1) lineno = self.LineFromChar(self.GetSel()[0]) if self.SCIGetFoldLevel(lineno) & SC_FOLDLEVELHEADERFLAG and \ not self.SCIGetFoldExpanded(lineno): self.SCIToggleFold(lineno) win32ui.DoWaitCursor(-1) Thanks for your help! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From hei at adtranzsig.de Thu Jul 20 04:37:21 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 20 Jul 2000 10:37:21 +0200 Subject: How to hook import? Message-ID: <8l6dsf$1mu$1@desig-bs01-s04.adtranzsig.de> A question to the Developers: What's the official way to overload the behaviour of import()? I've searched the python website and find lots of hits regarding __import__() and "imputils" and more, more than i can read. ? What's the future way of doing this, i mean, from 1.6a1 upwards? (I'd like to preprocess Python files when importing; for some rather crazy idea i can't speak out because maybe it won't be useful at all) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From scherbi at bam.com Wed Jul 5 07:27:51 2000 From: scherbi at bam.com (Bill Scherer) Date: Wed, 05 Jul 2000 11:27:51 +0000 Subject: DCOracle error References: <3962CB94.2DDA9AA9@esec.com.au> Message-ID: <39631BB7.3641E234@bam.com> Getting those Oracle lib lines correct is a bear. Below is the line from my makefile for DCOracle, built against Oracle 8.0.5. ORACLE_L=-lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnsl -lgeneric -ldl -lelf -lposix -lsql -lm -lm (that's one line) You'll notice that many of the entries from the stock Makefile ORACLE_L line are missing. Now, I have libnetv2.a in ORACLE_HOME/lib. Possibly you neglected to install some of the Oracle development libs? - Bill Scherer sss wrote: > I don't know why I got this error when I try to install DCOracle in > the Linux machine. > I've got Oracle sqlplus: SQL*Plus: Release 8.1.5.0.0 > > Here is the err msg: > > [oracle at ironfist src]$ make > gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 > -DHAVE_CONFIG_H -I/home/oracle/product/8.15/rdbms/demo > -I/home/oracle/product/8.15/rdbms/public > -I/home/oracle/product/8.15/network/public > -I/home/oracle/product/8.15/plsql/public -DDCORACLE8 -c ./oci_.c > In file included from ./oci_.c:562: > Buffer.h:79: warning: static declaration for `PyImport_Import' follows > non-static > oci_8.c: In function `Logon': > In file included from ./oci_.c:693: > oci_8.c:95: warning: passing arg 4 of `OCIHandleAlloc' makes integer > from pointer without a cast > oci_8.c: In function `newLob': > oci_8.c:446: warning: passing arg 4 of `OCIDescriptorAlloc' makes > integer from pointer without a cast > oci_8.c: In function `initoci_8': > oci_8.c:483: warning: passing arg 3 of `OCIEnvInit' makes integer from > pointer without a cast > ./oci_.c: In function `_wrap_odescr': > ./oci_.c:2595: warning: assignment from incompatible pointer type > gcc -shared oci_.o -L/home/oracle/product/8.15/lib/ > -L/home/oracle/product/8.15/rdbms/lib > /home/oracle/product/8.15/rdbms/lib/defopt.o > /home/oracle/product/8.15/lib/sscoreed.o > /home/oracle/product/8.15/lib/nautab.o > /home/oracle/product/8.15/lib/naeet.o > /home/oracle/product/8.15/lib/naect.o > /home/oracle/product/8.15/lib/naedhs.o -lnetv2 -lnttcp -lnetwork -lncr > -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -lgeneric -lmm > -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -lnttcp > -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon > -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lclient > -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 > -lsocket -lnsl -lgen -ldl -lelf -laio -lposix4 -lsql -lm -lm -lnetv2 > -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient -lvsn > -lcommon -lgeneric -lmm -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 > -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork -lclient > -lvsn -lcommon -lgeneric -lepc -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 > -lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3 -lcore4 > -lnlsrtl3 -lcore4 -lnlsrtl3 -lsocket -lnsl -lgen -ldl -lelf -laio > -lposix4 -lsql -lm -lm -o oci_.so > /usr/bin/ld: cannot open -lnetv2: No such file or directory > collect2: ld returned 1 exit status > make: *** [oci_.so] Error 1 > [oracle at ironfist src]$ > > > -- > Sam Wun Firewalls / Security > OneGuard Senior Software Engineer Electronic Commerce > eSec Limited Phone: +61 3 83715376 > mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD > > -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From swun at esec.com.au Wed Jul 12 02:20:19 2000 From: swun at esec.com.au (sss) Date: Wed, 12 Jul 2000 16:20:19 +1000 Subject: example of accessing email account. Message-ID: <396C0E23.887E46DA@esec.com.au> does anyone have python of how to access web (eg.yahoo) email account? Thanks sam. From tim_one at email.msn.com Mon Jul 3 14:23:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 3 Jul 2000 14:23:08 -0400 Subject: Bug in math.frexp? In-Reply-To: <8jqj17$rl0$1@nnrp1.deja.com> Message-ID: Guys, this is not open to debate. frexp is a std ANSI C function, Python calls the platform frexp directly, and the new docstring I checked in is an exact paraphrase of the std in Pythonic language. I don't care what manpages say. I *would* care if somebody can show an actual example of a Python implementation where the examples posted do not work exactly as shown: that would mean the platform is buggy -- but the new docs are still correct . arrogant-but-with-cause-in-this-case-ly y'rs - tim From jurberg at my-deja.com Tue Jul 18 10:05:01 2000 From: jurberg at my-deja.com (John Urberg) Date: Tue, 18 Jul 2000 14:05:01 GMT Subject: Newbies trying to do a build script Message-ID: <8l1o61$n45$1@nnrp1.deja.com> Hi all, I am working on a project with a couple of other developers and we are all new to scripting languages. We need to create a build script to build an application that consist of C++ and Java code. We have some Perl resources in another group, but I would prefer doing it in Python. I was hoping someone here could point me to some examples of build scripts in Python to get us going quickly. Thanks in advance, John Urberg Sent via Deja.com http://www.deja.com/ Before you buy. From theebh at yahoo.com Mon Jul 17 21:46:41 2000 From: theebh at yahoo.com (Jonathan) Date: Tue, 18 Jul 2000 01:46:41 GMT Subject: Zope newbie References: <8kv8ba$rq3$1@nnrp1.deja.com> <3973347E.B73015F4@eq.uc.pt> Message-ID: <8l0ctt$ooc$1@nnrp1.deja.com> In article <3973347E.B73015F4 at eq.uc.pt>, Pedro Vale Lima wrote: > coughlan at gothaminteractive.com wrote: > > > I've just installed Zope on Linux, and the documentation that comes > > with it refers almost exclusively to NT!? There is very little on Zope > > with Apace. > > > > Does anyone know of a URL or forum to get a decent tour of Zope on > > Linux? zope.com is also *very* dissappointing. > > The website is www.zope.org > > > It's unclear to me how to even create a hello world program to make > > sure it's installed and running. Any advice, would be appreciated. > > check in the /doc directory for install information. You don't need to use > > apache to check if Zope works, use Zope internal server instead. > > There are serveral ways to use Zope with Apache. For fastcgi, my > favourite, > in zope.org check for the fastcgi howto (under documentation-howtos). > > regards > > pedro > > Zope mailing list is also a good place to start(and ask questions). It can be found at Zope.org. You can even start posting your question to the community at zope at zope.org. Sent via Deja.com http://www.deja.com/ Before you buy. From nobody at nowhere.nohow Fri Jul 28 22:02:20 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 02:02:20 GMT Subject: Beginning References: <8loacq$n81$1@nnrp1.deja.com> <397FB2B5.8FE38267@sitegnome.com> <8lqqmp$jdd$1@nnrp1.deja.com> <8lsaoa01g3p@news2.newsguy.com> Message-ID: In article <8lsaoa01g3p at news2.newsguy.com>, Alex Martelli wrote: >Python works beautifully -- much better than most other >tools work in those environments. I'm particularly >addicted to Hammond's PythonWin, win32com, and >all the other win32 extensions (though I don't use them >for GUI's -- those I find easier to hack together by other >means, such as dynamic HTML, VB, etc; if I did have to >do GUI's in Python, I think I'd choose wxPython -- I've had >far too much Tcl/Tk in my Tcl and Perl days to feel any >desire whatsoever to go back to it:-). Though I still find Tk gemoetry management to sometimes be a trial-and-error proposition, I find Python/Tk (or Scheme/Tk, FWIW) to be far easier to use than Tcl/Tk. -- Grant Edwards grante Yow! MY income is ALL at disposable! visi.com From nowonder at pool.informatik.rwth-aachen.de Mon Jul 24 12:01:12 2000 From: nowonder at pool.informatik.rwth-aachen.de (Peter Schneider-Kamp) Date: Mon, 24 Jul 2000 16:01:12 +0000 Subject: multi-dimensional array ?? References: <397d3cc8.33972780@news.online.no> Message-ID: <397C6848.BBBCDD49@pool.informatik.rwth-aachen.de> Thomas Weholt wrote: > > I need to hold x,y,z coordinates in a multi-level grid. How can this > be done in Python? You can use lists of lists of lists of 3-tuples containing the coordinates. Adressing is done via repeated indexing. For example the corners of a unit cube between 0 and 1: >>> a = [ [ [(0,0,0), (0,0,1)], [(0,1,0), (0,1,1)] ], ... [ [(1,0,0), (1,0,1)], [(1,1,0), (1,1,1)] ] ] >>> a[0][0][0] (0, 0, 0) >>> a[1][0][1] (1, 0, 1) >>> You can also use NumPy. Chances are (if only slight ones) that it will be included with 2.0 (see PEP 206 http://python.sourceforge.net/peps/pep-0206.html) Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From musingattheruins at my-deja.com Sat Jul 15 07:57:56 2000 From: musingattheruins at my-deja.com (musingattheruins at my-deja.com) Date: Sat, 15 Jul 2000 11:57:56 GMT Subject: IDLE startup error on NT4 References: <8kodjp$aj2$1@nnrp1.deja.com> Message-ID: <8kpjk2$3an$1@nnrp1.deja.com> Just add the directories where python.exe and tcl80.dll to the environment (on NT right click My Computer, select Environment, pick 'Path' item). Usually it is something like... [your existing path];c:\program files\python;c:\program files\tcl\bin; on Windows 98 you can add the foloowing line to the end of your autoexec.bat... SET PATH=%PATH%;c:\program files\python;c:\program files\tcl\bin; Regards :-) > surely there is, but i made the same "fix" on winNT and > > My "fix" was to simply move the relevant files to the Python > > DLL directory on NT, but surely there's something else going > > on here. Sent via Deja.com http://www.deja.com/ Before you buy. From richard at vandestadt.org Thu Jul 20 08:49:48 2000 From: richard at vandestadt.org (Richard van de Stadt -at home-) Date: Thu, 20 Jul 2000 14:49:48 +0200 Subject: cgi to send PDF file to browser? References: Message-ID: <3976F56C.E412E20A@vandestadt.org> Erik Myllymaki wrote: > > Hello, > > I am looking for some advice on how to send a PDF file to a client browser > from a cgi script. I could just show a listing of the directory where the > PDF files are located and have the client select the right one, but for > various reasons I would like to just ship it out transparently. > > I have looked briefly at BaseHTTPServer, and I think this is where my answer > lies??? What you basically need is to print the string "application/pdf" followed by the contents of the pdf file. I did that a few years ago, but went back to making links to the pdf files. because too many users had problems configuring their browsers to work with this. They just wanted to be able to download the files themselves by clicking on the links. Richard. From sabren at manifestation.com Sun Jul 30 11:51:53 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sun, 30 Jul 2000 11:51:53 -0400 (EDT) Subject: bug in M2Crypto.urllib2 .. In-Reply-To: <20000730231941.A295@madcap.dyndns.org> Message-ID: On Sun, 30 Jul 2000, Ng Pheng Siong wrote: > /tmp:$ cat py > #!/usr/local/bin/python > > import M2Crypto.urllib2 > > url = 'https://secure.authorize.net/gateway/transact.dll' > > page = M2Crypto.urllib2.urlopen(url) > print page.headers > print '-' * 50 > print page.read() > print '-' * 50 > > /tmp:$ python py > Server: Microsoft-IIS/4.0 > Date: Sun, 30 Jul 2000 15:18:26 GMT > Content-Type: text/html > Content-Length: 42 > Content: > > -------------------------------------------------- > Invalid Merchant Login or Account Inactive > -------------------------------------------------- > /tmp:$ Very strange. I still get: Server: Microsoft-IIS/4.0 Date: Sun, 30 Jul 2000 15:49:23 GMT Content-Type: text/html Content-Length: 42 Content: -------------------------------------------------- None -------------------------------------------------- ... But I found that if I just use M2Crypto.httpslib, it works fine. I spent quite a bit of time in the debugger and couldn't find a reason why one would work and not the other. It's got to be something obscure, but at least I have a work around. Thanks, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From lshuler at my-deja.com Fri Jul 28 02:37:32 2000 From: lshuler at my-deja.com (lshuler at my-deja.com) Date: Fri, 28 Jul 2000 06:37:32 GMT Subject: Win32 drive mapping... aka "net use" Message-ID: <8lr9nc$tdf$1@nnrp1.deja.com> Is there an API using Win32 extensions to map a drive share? I have not found one yet and have tried searching "Win32 map drive". I am looking for the equivalent of: net use If not, is there an alternative other than making a call to system("net use "). Thanks in advance, Lance Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Mon Jul 3 14:18:22 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jul 2000 18:18:22 GMT Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <4.3.1.2.20000630145109.0201d9e0@phear.dementian.com> <8jplru0lfe@news2.newsguy.com> <962626013.769258863@news.libertysurf.fr> Message-ID: <8jqlde$n0e$1@newshost.accu.uu.nl> Jerome Quelin wrote: > "Alex Martelli" wrote: >>These are excellent arguments for always using accessors from OUTSIDE the >>class. Jerome, however, was talking about using them from INSIDE the class >>as well, which is a different issue. > Sure, I'm always using accessors from outside. > But from inside the class, I don't know which is the best. I feel like the KISS > rule should apply, but what do you OO gurus think of it ? How far encapsulation > should go ? I don't recall exactly, but the OO literature on this issue referes to the so-called 'Law of Demeter'. It comes in various weak and strong varieties which differ on this issue. So you may want to do a web-search on that. My personal opinion is that in Python you should not use accessors internally until it turns out to be necessary (which may never be). Python code is easy enough to change, after all. I don't even mind the occasional public use of attributes. Helped by unit tests this kind of thing can be changed to accessors fairly easily if necessary. Or I can of course go the __getattr__/__setattr__ route. I think the Pythonic way to think about this goes a bit like this: * sure, encapsulation is very important in good designs. * but, rapid prototyping is very important in coming up with good designs, as rapid prototyping allows you to change designs which turned out to be not good enough into better ones pretty easily. * good testing is important in any case. * if you have good testing and rapid prototyping, it's better to wait with various incantations (type checking, public/private, accessors) until they appear necessary, instead of doing them up-front and wasting time. It'll be likely you're wasting time as your up-front design will probably not be optimal yet in any case. Your incantations may turn out to be unnecessary in the first place! In my opinion the best solution to attribute access would be to add optional getter/setter methods to Python, much like Delphi's properties, or the facilities Sather and I hear C# provide. Such a facility can provide for a very clean path from direct attribute access to use of getters/setters. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rumjuggler at cryptarchy.org Fri Jul 28 14:56:09 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 18:56:09 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 07:59:38 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 06:52:19 GMT, Ben Wolfson >wrote: >>Yes, it does. List returns the list-equivalent of the sequence passed as >>its argument. 1 is not a sequence; it doesn't have a list equivalent. > > 1 is a sequence whether Python likes it or not. I call that a deficiency >in the language. > >>Any _sequence_ can be a single element or sequence. >>Any _single element_ can't be a single element or sequence. > > Let's pause and reflect on a single element not being able to be a single >element. You are, I think, deliberately misinterpreting me. Any single element can't be "a single element or a sequence". It can only be a single element. -- Barnabas T. Rumjuggler NEW Epistemology Strips! Dogs don't know they don't know it's not bacon! -- Ranjit Bhatnagar From no_spam at umich.edu Mon Jul 24 16:45:12 2000 From: no_spam at umich.edu (Jeff) Date: Mon, 24 Jul 2000 13:45:12 -0700 Subject: executing Python statements References: <8li9mm$ehe@news.or.intel.com> Message-ID: <8li9sp$eph@news.or.intel.com> never mind... exec (run_this_string) works Jeff wrote in message news:8li9mm$ehe at news.or.intel.com... > Hi, say I have a variable called 'x', and it is 100. I have another > variable called 'run_this_string' and it reads 'print x'. How can I then > execute run_this_string and get 100 to print out? Here is a code snippet: > > x = 100 > run_this_string = 'print x' > > > From ssthapa at midway.uchicago.edu Sat Jul 8 14:22:20 2000 From: ssthapa at midway.uchicago.edu (Suchandra Thapa) Date: Sat, 08 Jul 2000 18:22:20 GMT Subject: Anyone used Python for GPIB instrument control? References: <39668E65.356337BF@home.com> Message-ID: europax at home.com wrote: >Hello all, > >I am new to this ng and to Python. I am wondering if anyone has used >Python to control a National Instruments GPIB card on a Windows NT box? >I've searched and found a couple of references on my own. > >A group at work is using Perl for this task and there is some pressure >to go along with them. I've tried Perl, and frankly, assembly language >is clearer than Perl code to me. However, Python passed my test as I >was able to do something with it in the first minute- and I can >understand what most of the syntax means. I'm not sure if an equivalent exists for windows but try look swig. It allows you to use c/c++ code within python. From what I remember from using a GPIB interface to a Tektronics scope, you don't need much more than some basic c code to accept a string or a pointer to a buffer and pass it on to the driver. You also need a function to get a return code and pass it back to your python code. Although I'm not familiar with them, I think you may be able to write a basic COM/ActiveX object and use it in your python code. How is the rest of your group controling the GPIB in perl? You may be able to use the same methods in python. -- ------------------------------------------------------------------ Suchandra S. Thapa s-thapa at uchicago.edu ------------------------------------------------------------------ From cut_me_out at hotmail.com Sat Jul 29 13:49:10 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 Jul 2000 13:49:10 -0400 Subject: Python in politics (sssssssssnake!) References: <398296A1.1A97571A@sitegnome.com> Message-ID: > body actions of a super hero (muscle flex left and right arms :) .... > hopefully I'll be able to maintain that level of enthusiasm. Do all > you guys do that?? Yes, but as I've grown more sophisticated, I've subtly incorporated it into my anti-RSI exercises. Alex. From ge at nowhere.none Fri Jul 28 10:27:58 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 28 Jul 2000 14:27:58 GMT Subject: Perl is worse! References: Message-ID: In article , Steve Lamb wrote: >>Steve, in case it isn't clear yet, Python programmers *want* to >>be blown out of the water when doing something as senseless as > >> 1 + "foo" > > It isn't senseless. That is the whole point. It is only > senseless because of typing. Clearly you cannot add a word to > a number, granted. But what of 1 + "1"? That isn't senseless, > those are two numbers. I can see they are two numbers, it is > only because of typing that it fails. It is only because of typing that all programs fail. If I typed "1", that means I wanted a word, a printible string, and _not_ an integer. If I wanted an integer I would type 1 instead of "1". If I want to convert a string to an integer or an integer to a float or a float to a string, then _I_ will do it. I do _not_ want the language to make WAGs about what I meant when I typed something. I meant what I typed. If not, I'll go back and fix it until what I typed is what I meant. > So I ask you this /VERY/ simple question. Why can't Python do > both? Hm? What is wrong with taking 1 + "1", converting the > "1" to a 1 and adding it together? There's nothing "wrong" with it. I just don't want it to happen. The people responsible for designing the language apparently didn't want it to happen. Choose or invent a language that matches what you want. Nobody (sane) claims that a particular language is the best one for everybody or for every application. >If it is a string that cannot be converted to an integer, throw >an exception, otherwise, do it. Then that preserves the 1 + >"foo" exception and also does the sane thing of getting rid of >types when it makes sense to do so. I don't think it makes sense to do so. If I explicitly denote an object as a string (e.g. "1"), then I want it to be a string and I want it to _stay_ a string. Maybe I'm just getting old, but there are already enough things changing in the world. I don't need my data changing types behind my back. >Hell, why do an exception at all? Why not do what is already >done with integers, reals and floats? [...] > You already accept: > >1 + 1 = integer > >1 + 1.2 = float I may accept it in that I use languages that do that, but I don't like it. I think that should be an exception also. I've had programs fail because of this. It is a Bad Thing(tm). This is my opinion/preference, and it is based on the way I think and on the types of applications I write and my experiences debugging them. >1 + 1j = complex I'm a bit more ambivalent on that one. From what I remember from my undergrad circuit analysis classes (many years ago) calculations involving combinations of simple and complex numbers are extremely common. However, (here's the important part) the behavior of such calculations is completely defined, and there is no potential for loss of information when promoting a non-complex floating point value to a complex floating point value. Converting a 1.2345 into 1.2345 + 0.0j does not loose information. Converting values from int to float or float to int can loose information and should _not_ be done automatically by a language. > So please don't tell me you don't want "automagic" type > changing when it is already there and, I'd wager, you use it > extensively. It doesn't matter if it is already there, I don't want "automagic" type changing, and I try not to use it. When writing in C, I use generally use lint to make _sure_ I don't use it. -- Grant Edwards grante Yow! Of course, you at UNDERSTAND about the PLAIDS visi.com in the SPIN CYCLE -- From moshez at math.huji.ac.il Mon Jul 31 16:25:50 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 31 Jul 2000 23:25:50 +0300 (IDT) Subject: check file exists In-Reply-To: <3985DDA3.E811F70A@ncsa.uiuc.edu> Message-ID: On Mon, 31 Jul 2000, Randy Heiland wrote: > How does one test for whether or not a (Unix) file exists? os.path.exists() tricky-ly y'rs, Z. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From olipt at mayo.edu Thu Jul 20 14:05:54 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 20 Jul 2000 13:05:54 -0500 Subject: Discussion: new operators for numerical computation In-Reply-To: <8l7c80$mlc$1@tomm.stsci.edu> References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: > We are planning to use Numeric (or its future equivalent) heavily for > our software. One thing we would strongly object to is making > matrix operators the default. The vast majority of our manipulations > (on images and spectra) involve elementwise operations. This would be > consistent with what most astronomers would expect (and how IDL--currently > the most commonly used array-based language in the astronomical community > by far--handles it). I also take this view. Definining * to be matrixwise should be handled by subclassing the generic array (which will be much easier to do without breaking compatibility with compiled extension modules in the future Numeric). > > Use of parentheses for matrix operators that Konrad Hinsen proposed > appears to be the best solution I've seen so far. I agree. I'm glad Konrad is still with actively with us. His ideas were also pivotal in getting Numeric into its current useful state. I do like Tim Hochberg's suggestion of (|) as matsolve. The only question is can the (*) be implemented in the current grammar? I don't think we should start introducing [*] {*} variants. That would likely weaken our case in the PEP. I like: (*) outer product (.) inner product (|) matrix solve (**) matrix power (^) is better but only if ^ is power (which is not likely!) I'm not sure we should blow our chance to get some useful operators into Python by over-reaching... Also, unless you've used Numeric with Python for a while, it's easy to over-value the use of the infix notation. This really bugged me when I first started using Numeric Python as well, but it doesn't bother me anymore. The syntax does not have to be as bad as Huaiyu demonstrates. -Travis From mallor at 3DProgrammer.com Thu Jul 20 15:52:44 2000 From: mallor at 3DProgrammer.com (Mallor) Date: Thu, 20 Jul 2000 19:52:44 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> Message-ID: "Moritz Voss" wrote in message news:8l6qt4$89p$1 at fermi.tro.net... > > Thanks :) So designing my own scripting language is easier. If you want to build your own scripting language, look at Lua. It seems purpose-built for that task, at least it is billed as being a meta-scripting language. http://www.tecgraf.puc-rio.br/lua/ It also sounds like it's lighter weight / faster than Python. But I don't think I managed to get subscribed properly to the Lua mailing list, which says something about the maturity of the developer support. I guess I'll try again here. Grim Fandango used a modified Lua 3.1, apparently. Baldur's Gate and MDK2 use Lua internally. There are some other game projects mentioned on the "uses" page of the Lua website. I am wondering if the tradeoff is basically Lua performance vs. Python standardization? -- Cheers, Infernal Troublemaker Troll Mallor "By simple mistake, mortals themselves amuse." From phil at geog.ubc.ca Mon Jul 17 18:26:10 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 17 Jul 2000 15:26:10 -0700 Subject: CXX and Swig, pros and cons References: <8kv5uj$4of$1@broadway.news.is-europe.net> Message-ID: J?r?me Lecomte writes: > I am fairly new to Python and I'd like to interface part of a medium > size C++ lib (around 70 classes) to Python. I looked on the www and I > found CXX and Swig. They seem to have fairly different approach of the > problem. I wonder which suits best C++. > I find that CXX has quite a few advantages, e.g: 1) Automatic memory management (no worrying about INCREFs or DECREFs) 2) CXX Dict, List, Tuple String, Array, etc. 3) Integration of Python and C++ exceptions 4) Automatic generation of method tables > If I miss any other tool, please let me know. > You might want to take a look at SCXX: http://www.mcmillan-inc.com/scxx.html Regards, Phil From speed at ?.com Fri Jul 28 19:55:33 2000 From: speed at ?.com (Jake Speed) Date: Fri, 28 Jul 2000 23:55:33 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: speed@?.com (Jake Speed) wrote in : >morpheus at here.not.there (Steve Lamb) wrote in >: > >>On Fri, 28 Jul 2000 22:38:32 GMT, William Tanksley >> wrote: >>>That's a really cruel statement for you to make. I hope you were >>>making it in jest. I've seen nothing to indicate anything waranting >>>this kind of attack. >> >> Neither cruel or jest. I consider "Automagic" coversion on the same >> vein >>as "Winblows". I have hoped that there were people who were above that, >>there are some, but it is here as in everywhere else. > >The term 'automagic' is commonly used by perl coders and porters. Heck, even pythoners use it to describe python: http://www.cwi.nl/www.python.org/search/hypermail/python-1994q2/0012.html Altavista counts: +perl +automagic* : 3,369 pages +tcl +automagic* : 1,804 pages +python +automagic* : 1,295 pages +awk +automagic* : 1,083 pages +php +automagic* : 505 pages +guile +automagic* : 133 pages +cheese +automagic* : 129 pages +ruby +automagic* : 67 pages +haskell +automagic*: 63 pages -Speed! (apparently, 'pork rinds' are not automagical at all) From markx.daley at intel.com Tue Jul 11 12:20:04 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Tue, 11 Jul 2000 09:20:04 -0700 Subject: checking the existence of a fiel Message-ID: <75F7304BB41CD411B06600A0C98414FC0A41D5@ORSMSX54> if os.path.exists('filename'): - Mark ---------------------------------------------- The opinions expressed are mine, and are not necessarily those of my employer. -----Original Message----- From: Fernando Rodr?guez [mailto:frr at mindless.com] Sent: Tuesday, July 11, 2000 8:37 AM To: python-list at python.org Subject: checking the existence of a fiel Hi! How can I check if a file exists? O:-) TIA -- --------------------------------------- Fernando Rodr?guez From disposable002 at netscape.net.remove Thu Jul 13 15:46:41 2000 From: disposable002 at netscape.net.remove (Brian Steele) Date: Thu, 13 Jul 2000 19:46:41 GMT Subject: determining type References: <396e07fd@news-out> Message-ID: <396E1CA1.EBB4D959@netscape.net.remove> >>> a = {'item1': 'hello', 'item2':{'subitem1':'goodbye'}} >>> b = 'mystring' >>> c = {'my':'dictionary'} >>> type(a['item2']) == type(b) 0 >>> type(a['item2']) == type(c) 1 Mike Mikkelsen wrote: > > Hello All, > > Is there a way, programmatically, to determine if an item in a dictionairy is itself a dictionairy? > > consider: > >>> a = {'item1': 'hello', 'item2':{'subitem1':'goodbye'}} > >>> print a['item2']['subitem1'] > goodbye > > Is there a way to tell if 'item2' is a dictionairy, list or simple value like 'item1'? > > TIA > > -- > Mike Mikkelsen mikk at microbsys.com > Micro Business Systems http://microbsys.com > Fresno Linux Users Group http://linux.fresno.ca.us > > It's all GNU to me! From rbill at digisprings.com Mon Jul 31 14:09:50 2000 From: rbill at digisprings.com (Robert W. Bill) Date: Mon, 31 Jul 2000 12:09:50 -0600 Subject: Missing feature in urllib? (Getting HTTP reply code) In-Reply-To: <39851FBF3B.60DAYEMARTIN@smtp.garage.co.jp> References: <39851FBF3B.60DAYEMARTIN@smtp.garage.co.jp> Message-ID: On Mon, 31 Jul 2000, Yves-Eric Martin wrote: > Hello everyone, > I am now using urllib to get some data from a HTTP server, say: > > import urllib > f = urllib.urlopen('http://www.nowhere.com/stuff') > readData = f.read() I didn't see other responses, so I took a quick look at urllib. It didn't seem to have any accessor for response code and it also didn't seem very `subclassing friendly'. I would think that looking at httplib is a better idea. However: Headers are handled OK with with urllib, so one suggestion is to pollute the headers with the response codes in urllib. A potential-5-minute-saving-alternative might be: 1. copy urllib.py to myurllib.py 2. find line (#266 in my version)(in class URLopener, method open_http) errcode, errmsg, headers = h.getreply() 3. add next line = headers["Responsecode"] = str(errcode) + " " + errmsg Then: >>>import myurllib >>>urlconnection = myurllib.urlopen('http://www.python.org/') >>>urlconnection.headers["Responsecode"] '200 OK' -robert From dcalvelo at pharion.univ-lille2.fr Tue Jul 25 15:11:24 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 25 Jul 2000 19:11:24 GMT Subject: Comparison of strings and integer References: <8lkfhs$pav$1@pollux.ip-plus.net> Message-ID: <8lkoos$1gg$3@netserv.univ-lille1.fr> Remco Gerlich wrote: : Franz GEIGER wrote in comp.lang.python: :> Still not very experienced in programming Python I recently compared :> accidentially a string variable with an integer variable. Python did it his :> way, which was not my way: I expected a conversion like Perl does or a :> runtime error like REBOL does. Is there any way to prevent Python from doing :> so? :> :> Python: print "1" > 1 --> 1 : Python's docs say that sorting order for incompatible types is : arbitrary but consistent. Or so I seem to remember, can't find it at : the moment. >From the tutorial, section 5.6 (as of 1.5.2): """ Note that comparing objects of different types is legal. The outcome is deterministic but arbitrary: the types are ordered by their name. Thus, a list is always smaller than a string, a string is always smaller than a tuple, etc. Mixed numeric types are compared according to their numeric value, so 0 equals 0.0, etc. """ -- Daniel Calvelo Aros calvelo at lifl.fr From gherman at darwin.in-berlin.de Sun Jul 2 04:07:14 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Sun, 02 Jul 2000 10:07:14 +0200 Subject: reportlab: HTML->PDF via Python? References: <395CF8D0.6FD580B9@netscape.com> Message-ID: <395EF832.E6F5C9CE@darwin.in-berlin.de> Ian Oeschger wrote: > > Does reportlab or some other Python module offer a facility for printing > HTML pages to PDF? > And if so, does some rendering engine have to intercede in this process > somewhere? My experience so far has been getting text--rather than the > rendered HTML--into PDF. Well, not yet, at least from what I know about ReportLab. The question came up there very recently. The problem is more or less the implicit HTML layouting "behind the scenes", like text around images, frames, and so on. It seems, though, that a very simple HTML could be rendered rather easily into PDF. Regards, Dinu -- Dinu C. Gherman ................................................................ "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 johngrayson at home.com Mon Jul 10 14:44:29 2000 From: johngrayson at home.com (John Grayson) Date: Mon, 10 Jul 2000 18:44:29 GMT Subject: Tkinter Option (Radio) Buttons References: Message-ID: <8kd5i7$2b0$1@nnrp1.deja.com> In article , "dsavitsk" wrote: > If i have 3 option buttons created like in Interface() below I am able to > use Value() to determine which button is selected, Is there a bit of code > that i could add to Value() to disable certain buttons (i don't need the > if...elif's, just how to disable an option of my choosing.) or a better way > to do this. > > >>> def Value(): > ... global CnType > ... print CnType.get() > > >>> def Interface(): > ... CnType = IntVar() > ... CnType.set(0) > ... fm = Frame() > ... optTp = Radiobutton(fm5, text='Button 0', variable=CnType, value=0) > ... optTp.grid(row=0, column=0, sticky=W) > ... optTp = Radiobutton(fm5, text='Button 1', variable=CnType, value=1) > ... optTp.grid(row=0, column=1, sticky=W) > ... optTp = Radiobutton(fm5, text='Button 2', variable=CnType, value=2) > ... optTp.grid(row=0, column=2, sticky=W) > ... fm5.pack(side=TOP) > > thanks > doug > > You need to store the widget ID for the radiobuttons (say in a list). Then, you could simply index into the list to set the state of the RadioButton... e.g. from Tkinter import * def Value(): global CnType, wList wList[CnType.get()].configure(state=DISABLED) def Interface(master): global CnType, wList CnType.set(0) fm5 = Frame(master) for i in range(3): optTp = Radiobutton(fm5, text='Button %d' %i, variable=CnType, value=i, command=Value) optTp.grid(row=0, column=i, sticky=W) wList.append(optTp) fm5.pack(side=TOP) root = Tk() CnType = IntVar() wList = [] global CnType, wList Interface(root) root.mainloop() You can get the idea... John Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Sat Jul 15 10:37:57 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 Jul 2000 14:37:57 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <8kn71u02nn4@news2.newsguy.com> <8knng5$eue$1@slb3.atl.mindspring.net> <8kpavi04id@news1.newsguy.com> Message-ID: <8kpt05$uj6$1@slb3.atl.mindspring.net> In article <8kpavi04id at news1.newsguy.com>, Alex Martelli wrote: >"Aahz Maruch" wrote in message >news:8knng5$eue$1 at slb3.atl.mindspring.net... >> In article <8kn71u02nn4 at news2.newsguy.com>, >> Alex Martelli wrote: >>>"Dinu C. Gherman" wrote in message >>>news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... >>>> >>>> I doubt this will be very useful, like the answer to the >>>> question: "Which are the ten most used words in English?". >>> >>>That one is pretty useful, actually (it identifies the all-too- >>>frequent words, like 'the', 'of', etc, which a full-text search >>>engine had better just skip over:-). >> >> That's wrong. How do you search for the phrase "the White House"? > >You get all adjacencies of 'white' and 'house', assuming your search >tables are case-insensitive (which they should not be, for umpteen >reasons, but that's another thread, I guess). This only adds a modest >number of false positives: since you were going to get references to >"the white house at the corner of Elm and Main" anyway, it's no great >hardship to also get any "a white house, quite pretty, with a red >roof". Here's a better example: "The Cat in the Hat" With two adjacent noise words, your false positive rate goes up. >But meanwhile you're protecting yourself against losing many relevant >positives due to quirks of English syntax and idiom. "White >House sources denied the allegations" and "The White House denied >the allegations" are basically equivalent; "the", like all such >syntax-marker words, tends to appear or disappear from phrases >depending, unsurprisingly, on syntax (and idiom) issues. Note that many people are not searching for a random document that contains something similar to a phrase, they are searching for a document that contains a specific phrase. (E.g. "the tree of liberty") >And your tables shrink usefully. You can invest the saved space to >provide other precious services that are often skimped on, like, guess >what!, proper casing-flags, flags for inflection, etc. So you can >search for: {white constrain initial-cap} adjacent {house constrain >initial-cap, singular} and get all "properly capitalized" references to >the White House, with or without article. I should note that my primary experience is with Verity, so I'm thoroughly familiar with all these operations; I consider a search engine inferior if it doesn't support them. All the same, most people seem unwilling to learn complex query languages to get the necessary precision in their results. >> (Trust me, this is one area I'm a real expert.) > >I'm out of touch with recent research in the field -- it's been over a >decade since I did computational linguistics -- but my recent usage of >full-text search engines, now so prevalent on the net, does not seem >to show me any advance in the art. Maybe there are new algorithms >and data structures providing speed-ups on the search engine (some >of the engines ARE remarkably fast, I will admit), but the *search >quality* issues, which are connected with what to include in the >tables, search-language semantics, etc, seem to be still all there >(indeed, the search engine I find myself using most often [because it's >so wondrously fast] is extremely poor this way -- can't even ask for >adjacency or nearby-words, etc, etc; but "brute force wins again":-). Yeah, one of the reasons I hate AltaVista so much is because it does a remarkably poor job of result ranking, even by the relatively poor standards of search engines. However, every time I see a serious attempt to improve automated search results, it leads directly to the mucky swamp of AI and "natural language", with degraded search results. I remember one search engine that I typed something like "cat" into, and got documents back containing "cow" because they were both animals (I don't remember the exact example). (Note that I've never been a particular expert on academic research. I've always been much more interested in deployable applications.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From honza_v at my-deja.com Wed Jul 26 05:06:51 2000 From: honza_v at my-deja.com (honza_v at my-deja.com) Date: Wed, 26 Jul 2000 09:06:51 GMT Subject: binary distribution of Zope's DCOracle for Win32 References: Message-ID: <8lm9n8$6rc$1@nnrp1.deja.com> In article , "Kiss, Arpad" wrote: > I have a compiled version that works with 7.3.4 clients. I can send it for > you if it is good for you. > Arpad > I made an agreement with a colegue, who knows C a he will help me to compile it for version 8i. If you can please send it to me with your sources (esp. makefiles), I will very appretiate it. Thanks in advance Jan Sent via Deja.com http://www.deja.com/ Before you buy. From dgoodger at bigfoot.com Sat Jul 15 17:34:20 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 15 Jul 2000 17:34:20 -0400 Subject: Docs for __init__.py? In-Reply-To: References: Message-ID: on 2000-07-15 07:03, Matthew Cline (matt at nightrealms.com) wrote: > Specifically, does the package name have to corespond to the > name of the directory that __init__.py is in? Or is there > some way for __init__.py to say "No, *this* is the name for the > package?" The directory name *is* the package name, just as the file name (less the .py) is the module name. Otherwise, how would Python know what file to read when importing a module, or what directory to access when importing a package? See Guido's essay at http://www.python.org/doc/essays/packages.html for a more in-depth explanation. -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From cg at schlund.de Fri Jul 28 10:35:40 2000 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 28 Jul 2000 16:35:40 +0200 Subject: Is this the efficent way? References: Message-ID: <39819A3C.3634867B@schlund.de> "Arint?" wrote: > > I need to split a double (8) byte character into two bytes to send as a > string so I have this code > def hexSplit(arg): > ans = 0 > lobyte =arg-256 > if arg<=255: > ans = "\x00" + chr(arg) > else: > hibyte = lobyte/256 > if (lobyte%256)>0: > hibyte = hibyte+1 > ans = chr(hibyte)+chr(lobyte) > return ans > > Is this good enough? I think this is better: def hexsplit(arg): lobyte = arg & 0x00FF hibyte = (arg & 0xFF00) >> 8 return chr(hibyte) + chr(lobyte) Carsten. From alexandre.ferrieux at rd.francetelecom.fr Tue Jul 4 08:44:34 2000 From: alexandre.ferrieux at rd.francetelecom.fr (Alexandre Ferrieux) Date: Tue, 04 Jul 2000 14:44:34 +0200 Subject: Cross-frame 'security' (Internet Explorer and Python/COM) References: Message-ID: <3961DC32.2344@rd.francetelecom.fr> Roger Upole wrote: > > Here's a small sample of how to navigate to a URL. > >>> import win32com.client > >>> x=win32com.client.Dispatch('InternetExplorer.Application.1') > >>> x.Visible=1 > >>> x.Navigate('http://www.python.org') I've been doing something similar in some other scripting language (replace Python/win32com by Tcl/Optcl), and it worked quite well, however I've run into a show-stopper, and I would like to gather insights: The so-called cross-frame security issue. Once you've created the automation object x above, you can to some extent walk down the document tree. The problem is, if the page contains a frame which is hosted in some other 'domain' (the last two items in the DNS name), you simply can't access that subtree, even in read-only mode. In my case it was nasty because the sole purpose of the whole stuff was to reuse IE's parsing machinery to extract only text from the page -- a poor man's Lynx in a maximum-reuse context if you prefer. I've seen some explanations on the MS site (security bulletin and so on). The beginning of the story was the possibility for malevolent client-side code to insert its own text input box right on top of the one from a securized credit card number input dialog. This, sure enough, was a critical security hole. However, the counter attack doesn't make sense to me: why bar access to extradomain frames, even readonly, while the real issue was to prevent only *write* access (or visual overlay) of other frames ? Please please somebody enlighten me ! TIA, -Alex From pauljolly at my-deja.com Mon Jul 31 05:50:58 2000 From: pauljolly at my-deja.com (pauljolly at my-deja.com) Date: Mon, 31 Jul 2000 09:50:58 GMT Subject: Extracting search criteria using re References: <8m3ee5$fh5$1@nnrp1.deja.com> Message-ID: <8m3i61$hsm$1@nnrp1.deja.com> Sorry, I have found the answer to my question. I now use the findall() function to extract the data. Sorry to trouble you all (but my other question is still valid!!) Paul Jolly In article <8m3ee5$fh5$1 at nnrp1.deja.com>, pauljolly at my-deja.com wrote: > Dear All, > > I am using the re module to search for a particular string in an html > file (not within the tags but within the page material). This question > is more about regular expression technique more that anything. > > I have read the manual on regular expression but cannot seem to find > anything that answers my question: when using the > (recompiledobject).split() method, I want to return a list of all the > occurences of my search criteria and not what remains when my search > criteria is stripped from the string. For example, searching using the > following search string: \d?\d\s*'°' in the following: > > "This is an example of two temperatures 56 ° F and 36 ° F." > > Applying the split function on the above, I would want to return as a > list ('56 °', '36 °'). I am sure this is possible but cannot > for the life of me find the answer. Any help much appreciated. > > Regards, > > Paul Jolly > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at localhost.localdomain Sun Jul 30 22:10:21 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 31 Jul 2000 02:10:21 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 02:47:39 GMT, Steve Lamb wrote: > > Whoops, exited too fast. When I started programming it was in Turbo >Pascal 3. I had the absolutely WORST time with that language at that time >because of typing because I couldn't just do what I thought was logical. >Furthermore the casting also didn't work in any manner that I thought logical, >either. I hit the same problem in C. I really, REALLY despised being told >that what I wanted to wasn't possible when I knew darn well it /was/. There are different categories of typing. There are strong (no automatic conversion) and weak typing. There are static (declared when variables are created) and dynamic typing. Python is strongly and dynamically typed. Strongly and statically typed languages do have the problems you pointed out - they are too brittle. But the fault is more at the "static" part than the "strong" part, at least as most people here would say. Perl is sort of the other extreme that is both weakly and dynamically typed - it feels too anarchical (sorry I can't find the proper word). There's no way one can escape type (or class) if one wants both 1+1==2 and '1'+'1'=='11' in a language. So far (at least) three mechanisms have been described in this thread: - associate type with names (variables), like C - associate type with operators and context, like Perl - associate type with objects (data), like Python. If you try some real world examples, you might discover that the Python way is better than the other two in many cases. I've tried all three and this is my feeling for the majority of cases. Huaiyu PS. Ironically, in the area I'm mostly interested in at the moment, the distiction between matrixwise and elementwise operations, I find that association with operators is much better than association with data. But this is another (long) story. From paul at prescod.net Mon Jul 17 19:18:59 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 18:18:59 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> <39736688.E19DD546@eecis.udel.edu> Message-ID: <39739463.2DD0651D@prescod.net> Charles Boncelet wrote: > > ... > > This I must object to. Linear algebra often involves big objects. > These operations want to call a carefully written C function. Any > time you use Python to loop over matrix objects, you are dead in > a big problem. As far as I understand (and I could be wrong) > neither list comprehensions nor the elementwise approach would be > able to call the underlying C functions without python loops. You are wrong about the .Element or .Element() approach. It is just a syntactic approach, not a new computational model. .Element returns an object that knows to use element-wise multiplication instead of matrix-wise multiplcation. I thought it was a pretty elegant, lightweight solution. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From thomas at cintra.no Fri Jul 21 05:07:39 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 21 Jul 2000 09:07:39 GMT Subject: Intercept methods/raise exception References: <3978f242.25036009@news.online.no> <8F77C5E93gmcmhypernetcom@199.171.54.155> Message-ID: <397912ac.71497477@news.online.no> On 20 Jul 2000 23:55:14 GMT, gmcm at hypernet.com (Gordon McMillan) wrote: >Thomas Weholt wrote: > >>Is there a way to define a method in a class that is called each time >>every other method is called in that class, and based on a attribute, >>raise an exception or let the method-class go thru? > >Not with a method. Use a proxy: > >class Proxy: > def __init__(self, obj): > self.__dict__['_obj'] = obj # avoid the __setattr__ hook > def __getattr__(self, nm): > attr = getattr(self._obj, nm, None) > if attr: > # do what you like > return attr > raise AttributeError, "%s not found" % nm # vital > def __setattr__(self, nm, val): > # do what you like and maybe > setattr(self._obj, nm, val) > >Now just wrap your object in the proxy. > >-Gordon Ok, it seems to work, allthough only if I access methods. Accessing simple values like ints and strings directly only traps that value, not the attribute name. class foo: def __init__(self): self.poofoo = 2 def foobar(self): return 1 a = foo() x = Proxy(a) x.foobar() will trap foobar as the attr. x.poofoo will only trap the value stored in that attribute. How can I trap the attribute *name* too? And, most importantly, how can I make my objects behave like the ones used thru a proxy, *without* putting them into one? is it possible? I mean, I just want to avoid have to declare one instance, and then stuff it into another new instance. Can it be done in one big swoop? Anyway, where can I read up on stuff like this? Proxy, nifty object handling. Any hints? Thanks for any help so far. It helped me alot. Thomas From peter at schneider-kamp.de Sun Jul 23 04:02:45 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Sun, 23 Jul 2000 08:02:45 +0000 Subject: bit manipulation frustration References: <397A6980.CF15DB96@san.rr.com> <397A7BB5.A6024F70@san.rr.com> Message-ID: <397AA6A5.13A72018@schneider-kamp.de> Courageous wrote: > > Say for example I want to increase or decrease R, > G, or B values. Or, say, I want to convert to 32 > bit color bitmaps? Oh yes: >>> def from16to32(v): ... i = (ord(v[1]) << 8) + ord(v[0]) ... return chr(i >> 11)+chr((i >> 5) & 63)+chr(i & 31)+'\000' ... Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From glandrum at my-deja.com Wed Jul 19 21:19:23 2000 From: glandrum at my-deja.com (Greg Landrum) Date: Thu, 20 Jul 2000 01:19:23 GMT Subject: Python-ese for indexing a list within a class References: <8l4v6k$rd4$1@news.rchland.ibm.com> Message-ID: <8l5k2g$lcr$1@nnrp1.deja.com> In article <8l4v6k$rd4$1 at news.rchland.ibm.com>, "Larry Whitley" wrote: > Is the following the appropriate Python-ese for indexing a list within a > class? > > # the following is defined outside of either class or function > nCounters = 4 > a,b,c,d = range(nCounters) > > # now define the class > class C: > def __init__(self): > cnt = [0] * nCounters > def someFunction(self): > # some code > self.cnt[a] = self.cnt[a] + 1 # <<< here's the statement in question > # some more code > > I'm trying to avoid the considerably ugly: > > self.cnt[self.a] = self.cnt[self.a] + 1 > > The code seems to work ok but is this the right/best/prettiest/(etc) way to > go about it? > How about something like this: class C: def __init__(self,nCounters): self.cnt = [0] * nCounters def __getitem__(self,which): return self.cnt[which] def __setitem__(self,which,val): self.cnt[which] = val This would then be used like: foo = C(4) print foo.cnt foo[1] = foo[1] + 1 print foo.cnt If you want to get a bit fancier, you could even do: class C2: def __init__(self,nCounters): self.cnt = [0] * nCounters def __getitem__(self,which): return self.cnt[which] def __setitem__(self,which,val): self.cnt[which] = val def __len__(self): return len(self.cnt) def __getslice__(self,start,stop): return self.cnt[start:stop] And use it like this: foo = C2(4) print foo[:] foo[1] = foo[1] + 1 print foo[:] I hope this helps, -greg Sent via Deja.com http://www.deja.com/ Before you buy. From peter at schneider-kamp.de Wed Jul 19 12:15:10 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 16:15:10 +0000 Subject: a more comprehensive distribution? References: <8l4act$loo$1@news.kth.se> Message-ID: <3975D40E.E478EF44@schneider-kamp.de> Oivvio Polite wrote: > > I've been working with python for a couple of months now. > My only real annoyce is the constant need to locate and install python > modules. Hopefully distutil will make the installation part easier in the future. > I'd like to get my hands on a distribution that includes a lot more then the > standard library, somthing that comes with Numpy, ScientificPython, mxODBC, > mxDateTime, a lot of other stuff I don't know about yet. Such a "batteries included" version is considered for Python 2.0. In some days there will be a discussion of this here on comp.lang.python. You can already take a look at the current plans in PEP 206 (Python Enhancement Proposal #6 for 2.0). You can browse the PEPs via the CVS web interface (or in you own CVS version, if you check out one): http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/nondist/peps/?cvsroot=python Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From fiona at sitegnome.com Sun Jul 9 21:52:10 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Mon, 10 Jul 2000 11:52:10 +1000 Subject: Python book suggestions? References: Message-ID: <39692C4A.AB8EE52D@sitegnome.com> Hi Randall, Have a look here -> I'm new to Python and would appreciate advice on what book(s) I should be looking at? http://www.faqts.com/knowledge-base/view.phtml/aid/2795/fid/199/lang/en Also, there were a couple of threads on this topic recently one "Books" original post on 27.06.00 that might be useful. HTH, Fiona Randall Parker wrote: > > I would like to learn Python because people I respect think highly of it. > I have backgroun in C++, Java, and assorted other languages. I intend to > use Python to do web site development. > > Does anyone have any suggestions as to which books are good for learning > the Python language? > > How about a book about Python and XML? > > How about a book about Python for web site development? > > I'm thinking of starting with the v1.6 version that I see from an article > has a number of language changes over previous versions. Are any books > due out imminently that will cover this newer version? -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From paul at prescod.net Sat Jul 1 20:17:56 2000 From: paul at prescod.net (Paul Prescod) Date: Sat, 01 Jul 2000 19:17:56 -0500 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <033401bfe3c0$d7158140$6401a8c0@home> Message-ID: <395E8A34.FE17D610@prescod.net> Darrell Gallion wrote: > > From: "Mark Hammond" > > Just to stoke the flames a little... > > > > Check out some of the talks at the upcoming PDC - > > http://www.pdc.mscorpevents.com/sessions.asp?tracks=6 - look for Python > > Ok my flames are stoked. > What do they mean "Visual Python"??? > Could this be a good thing? http://www.activestate.com/Products/VisualPython.html -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From europax at home.com Sun Jul 16 21:52:14 2000 From: europax at home.com (Rob) Date: Mon, 17 Jul 2000 01:52:14 GMT Subject: problems trying wxPython in Win 95 Message-ID: I want to run the demo program included in wxPython 2.1. Upon starting it I immediately get the message appended to this post. I have two versions of Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and get the same result. I tried running it from the console, from PythonWin, and from IDLE, all with negative results. Does anyone have an idea of what is going on? Thanks, Rob. PYTHONWIN caused an exception c06d007eH in module KERNEL32.DLL at 0137:bff9a07c. Registers: EAX=0063d7bc CS=0137 EIP=bff9a07c EFLGS=00000246 EBX=00000000 SS=013f ESP=0063d7b8 EBP=0063d80c ECX=0063d7d4 DS=013f ESI=0063d864 FS=2287 EDX=ffffffff ES=013f EDI=00000000 GS=0000 Bytes at CS:EIP: 5e 8b e5 5d c2 10 00 64 a1 00 00 00 00 55 8b ec Stack dump: 018a9c34 c06d007e 00000000 00000000 bff9a07c 00000001 0063d830 bff782c7 817f9000 81821708 00081822 00000000 0063d6e3 00000000 bff7c4f7 0188e4d0 From stephen at cerebralmaelstrom.com Fri Jul 7 21:54:57 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sat, 08 Jul 2000 01:54:57 GMT Subject: Splitting c.l.py... References: <0007071815170C.03526@quadra.teleo.net> Message-ID: Okay, I've noticed people mentioning 'eff-bot' for awhile now.. and I have one question. What the heck is the eff-bot?! :) --Stephen Patrick Phalen wrote in message news:0007071815170C.03526 at quadra.teleo.net... > [Tim Peters, on Fri, 07 Jul 2000] > :: Can't speak for me mates at Luxurious PythonLabs World > :: Headquarters, but I'd like to apologize for my own lack of participation on > :: c.l.py over the past several months! > > :: When things settle down, at least I intend to resume harassing c.l.py. And > :: there's already a great deal of development discussion on Python-Dev that > :: *should* be on c.l.py. > > > Thanks for expressing this, Tim. You've been missed. Then, to compound > matters, I read the following Advogato diary entry from the effbot the > other day and truly began to wonder if the good old days were gone: > > """ > 5 Jun 2000 > > Just noticed that the Python version of the eff-bot has been online for five years (give or take a few days). > > To celebrate this anniversary, I've decided to shut down the comp.lang.python newsgroup eff-bot! > > (Frankly, it's been a while since c.l.py was the most interesting place in Pythonia, and it's no longer the endless > source of positive energy it once was.) > > But to avoid offending anyone (or everyone ;-), lets just say that five years is a very long time on the net. It's > time to find other channels for the eff-bot. > > Onwards! > """ > From neilh at scintilla.org Sat Jul 15 20:31:19 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 16 Jul 2000 00:31:19 GMT Subject: something like os.link() for NTFS? References: <8kqr83$qm9$1@agate.berkeley.edu> Message-ID: > Hard links exist under NTFS. Does anyone know of a Python function for NT > under NTFS that does what os.link() does under UNIX? If not, is there a > technical reason why it isn't a good idea? While hard links exist on NTFS, they are only creatable by Win32 applications on Windows 2000. The CreateHardLink(newName, oldName, securityJunk) function is the API to use. Earler versions of NT did not support this function but did allow POSIX applications to create hard links. So you could have Windows 2000 specific code or solve this by creating a small POSIX subsystem utility and execute that with os.system or similar. Looks like CreateHardLink is not yet in the Win32 extensions. Neil From mcmurtriek at worldnet.att.net Tue Jul 18 20:07:34 2000 From: mcmurtriek at worldnet.att.net (Kenneth McMurtrie, Jr.) Date: Wed, 19 Jul 2000 00:07:34 GMT Subject: Newbies trying to do a build script References: <8l1o61$n45$1@nnrp1.deja.com> Message-ID: "Matthew Cline" wrote in message news:k56d5.2080$mL5.81696 at news-west.usenetserver.com... > In article <8l1o61$n45$1 at nnrp1.deja.com>, John Urberg > wrote: > ... > If you're working on Windows... Hrm, has anyone ported autocnof and > automake to Windows? Both autoconf and automake are available under cygwin on Windows at http://cygutils.netpedia.net/V1.1/index.html From sami.hangaslammi.spam.trap at yomimedia.fi Thu Jul 20 05:08:13 2000 From: sami.hangaslammi.spam.trap at yomimedia.fi (Sami Hangaslammi) Date: Thu, 20 Jul 2000 12:08:13 +0300 Subject: BUG: File modes under IRIX Message-ID: <8l6fjk$19r9$1@learnet.freenet.hut.fi> Python version: Python 1.5.2 (#2, Mar 22 2000, 10:10:50) [GCC 2.8.1] on irix646 When using os.makedirs('foo/bar',0755) (or os.mkdir) the mode of the created directories is incorrectly set as rwx------. Is this a known problem or am I just doing something wrong (I'm terribly unexperienced when it comes to *x systems)? From aahz at netcom.com Fri Jul 14 14:51:49 2000 From: aahz at netcom.com (Aahz Maruch) Date: 14 Jul 2000 18:51:49 GMT Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kn71u02nn4@news2.newsguy.com> Message-ID: <8knng5$eue$1@slb3.atl.mindspring.net> In article <8kn71u02nn4 at news2.newsguy.com>, Alex Martelli wrote: >"Dinu C. Gherman" wrote in message >news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... >> >> I doubt this will be very useful, like the answer to the >> question: "Which are the ten most used words in English?". > >That one is pretty useful, actually (it identifies the all-too- >frequent words, like 'the', 'of', etc, which a full-text search >engine had better just skip over:-). That's wrong. How do you search for the phrase "the White House"? (Trust me, this is one area I'm a real expert.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Let's go home and turn on MTV. I want to watch some Pop-Up Videos." "Pop-Up Videos is not on MTV, it's on VH-1." "'MTV' is a generic." From brunnsNObrSPAM at beer.com.invalid Wed Jul 5 09:36:27 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Wed, 05 Jul 2000 06:36:27 -0700 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> Message-ID: <1c934748.cd75dee0@usw-ex0106-045.remarq.com> I've not heard of any way of getting at DB2/400 from Python other than via ODBC. But I'd love to be wrong! If someone were to port JPython to the '400, you would be able to use the AS/400 Toolbox for Java's native DB access APIs, but that would be a pretty major job in itself. BTW, It's nice to know that there are other '400 types looking at Python. I'm hoping to do the JPython port eventually, but I don't know Java yet, so don't hold your breath! Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From mbaker at 0x7a69.net Wed Jul 26 15:35:18 2000 From: mbaker at 0x7a69.net (Mark Baker) Date: Wed, 26 Jul 2000 14:35:18 -0500 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <8ljrvu09t6@news1.newsguy.com> <8lma5602i08@news1.newsguy.com> Message-ID: In article <8lma5602i08 at news1.newsguy.com>, "Alex Martelli" wrote: > "Mark Baker" wrote in message > news:l8rf5.1529$ck7.387235 at nntp1.onemain.com... > [snip] >> > I see a "self.something=23", I know "self" is an instance variable; >> > no > [snip] >> Er....sort of. > > Not really: > >> def sum(self): return self.x + self.y + self.a # Scope within class, >> but accessible via > self > > Ah, but here you're not *assigning* to self.a; you're just *accessing* > it. Yes, but simply because it's accessed via 'self' doesn't mean it's an instance binding. Which getting back to his commentary, isn't always very revealing. With an assignment this is the case, but I wanted to clarify the actual rules involved for the person. The added benefit of overriding __getattr__ and __setattr__ can be even less obvious. But in the end, if the implementation is important to the user, then this should be in the documentation anyway. >> > have free-standing functions in their stead, and grouping by-module >> > is more productive than by-class (the class is not the natural unit >> > of encapsulation, an issue that is also acknowledged by the package >> > concept of Java and the friend keyword in C++). >> >> friend is simply an evil way of violating encapsulation. It's not > analogous to > > Absolutely false, although people with a superficial understanding of > C++ do tend to think that way. The proper use of 'friend' is to split > an encapsulated, cohesive functionality among more than one class, > *because the class is NOT the natural unit of encapsulation*. friend > ENFORCES encapsulation, by only allowing access to certain object > features to a carefully designed set of co-operating classes, designed > together, to work together, and expose exactly that functionality that > the designer of the package wants to expose. I've been writing in C++ for many years now, but this isn't a matter of who has a larger penis... If an object's internals are to be accessed externally, then methods should be provided to this inside of the object itself. It should not indicate that it's alright for "some" people to violate its encapsulation. If another object needs access to the internals of another object, then this should solely be provided by the accessor/mutator pattern. Friends, if attempted for use as "encapsulation" suffer from issues regarding protecting implementation details, in a paradoxial and limitedly extendable way. It is rare to be used in this manner. They are used quite often to violate real encapsulation principles, for the sake of performance. Methods that are declared inline may or may not end up as such with any given compiler. Plus depending on the complexity of accessors, one may not wish to have this code inlined in every case. In the end, the compiler and not the programmer should be concerned with these, in any event. But now I'm diverging... In the real world, people do use friend to violate encapsulation. > >> modules, packages, or anything else. It simply provides a means of > violating >> C++'s encapsulation (usually for speed purposes, since you should be >> able to use the accessor/mutator pattern to work with object >> properties) > > Again, absolutely false, and, again, suggesting rather superficial > understanding of C++'s working. A public accessor/mutator can be, and > generally is, written in-line, with no speed penalty whatsoever over > access to an instance variable. Unless of course you're not simply returning a primitive instance variable. And then perhaps, as I said, you aren't inclined to want it inlined, or have it inlined automatically by the compiler. Friend, though, is also used rather often to execute private methods. > The problem is, this lets ANYBODY read/write that property (through the > accessor and mutator); what if you only want ONE OTHER, SPECIFIC CLASS, > to have that ability? Answer: you use friend, which lets you ENFORCE > encapsulation > (and keep the accessor and/or mutator private, so that only the friend > class > can make use of them -- if it still makes sense to have them, which it > often does, essentially for purposes of convenience). This allows you to partially violate encapsulation, in order to maintain it elsewhere. This doesn't really increase it, it decreases the violation of it. To claim otherwise is amusing, at best. More often than not, if you need access to some part of an object's information, there are chances that someone else will. If you need access to someone's private implementation, then their framework lacks much to be desired. Encapsulation is meant to protect mostly the latter. > If you're interested enough in C++ to make such comments, you owe it to > yourself to understand a little bit more about this extremely complex, > though powerful, language. For the mechanisms underlying its typical The Design and Evolution of C++ and The C++ Programming Language are also good in that Bjarne is more than willing to say where C++ could have been better, or why a "bad" decision was made. Multi-Paradigm Designs for C++, Generic Programming and the STL, and other such books are also interesting as far as C++ goes. Even better than strictly C++ books are things such as Design Patterns, Analysis Patterns: Reusable Object Models, Smalltalk 80: The Language, Understanding CLOS, and some others. It's much more interesting to look at language, framework, and pattern designs for a multitude of things, and then look at any one language's specific features, instead of accepting the decisions or beliefs of one faction of programmers. From guido at python.org Wed Jul 26 22:01:37 2000 From: guido at python.org (Guido van Rossum) Date: Thu, 27 Jul 2000 02:01:37 GMT Subject: Toplevel "test()" functions in standard library References: Message-ID: rob at hooft.net (Rob Hooft) writes: > In the standard library there is about 20 modules with the construction: > > ------------------------------------------ > [module definitions] > > def test(): > [testing code or general main program] > > if __name__=="__main__": > test() > ------------------------------------------ > > Wouldn't it be better to move the test() definition inside the if > statement in these cases, to prevent name space pollution? Note that > the routines are not called "_test()", so they will be imported by a > "from ... import *" (There are other modules with a _test() definition > as well). > > Even worse: the test() routine might have severe side effects: > e.g. base64.test() will block waiting for data from stdin... > > Going one step further: Should all of these "test()" and "_test()" > routines be in the code library at all, even now that we have a > complete test engine? As Moshe already said, the test code serves the reader of the module well. It's also handy to be able to import module foo and simply call foo.test() or foo._test() to test it. I agree that it's better to name the routine _test(), but for most modules, and in most cases, it's bad style anyway to write ``from M import *'', so naming it test() is no great sin. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From gjohnson at gs.verio.net.bbs Mon Jul 17 17:20:02 2000 From: gjohnson at gs.verio.net.bbs (gjohnson at gs.verio.net.bbs) Date: 17 Jul 2000 21:20:02 GMT Subject: Internet Programming in Python Message-ID: <3bRPe2$jHe@openbazaar.net> http://www.ora.com shuld carry this one... steve langer wrote: > > Does anyone know a used book store that would carry this out of print > book? > > Email great. > > thanks, > SL sglanger at oakland.edu > > -- > http://www.python.org/mailman/listinfo/python-list From olivierS.dagenaisP at canadaA.comM Tue Jul 25 21:23:21 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 26 Jul 2000 01:23:21 GMT Subject: PythonWin/Scintilla aggressive folding... References: Message-ID: > Correct, I'm afraid. Scintilla detects folding as it colorises. Changes > like you suggest would make it far more complex. > The good news, however, is that fixing it inside Scintilla means Pythonwin > gets the fix, as well as whatever wxPython integration efforts are > underway, and every future user of Python code in Scintilla will sing your > praises. > Please take this on! I'll see what I can do. This open-source deal is great, but it's a lot of work! I would appreciate some hints, though. I understand Neil is the author? Neil, anything you can suggest? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From jhunt at hpbs1711.boi.hp.com.bbs Mon Jul 17 16:50:04 2000 From: jhunt at hpbs1711.boi.hp.com.bbs (jhunt at hpbs1711.boi.hp.com.bbs) Date: 17 Jul 2000 20:50:04 GMT Subject: nis module error Message-ID: <3bRP2U$mD_@openbazaar.net> I am new to python and want to use the nis module. When I import the module I get the error: Traceback (innermost last): File "", line 1, in ? ImportError: /usr/lib/python1.5/lib-dynload/nismodule.so: undefined symbol: yperr_string what does this mean? How can I correct the problem or is there a way around it. I am using python 1.5.2 on x86 SuSE 6.4. Thanks for the help -- Jacob Hunt From pehr at pehr.net Sat Jul 29 00:21:47 2000 From: pehr at pehr.net (pehr anderson) Date: Sat, 29 Jul 2000 04:21:47 GMT Subject: Game programming and python References: <398243CA.9AB58468@nycap.rr.com> Message-ID: <39825BDA.B425E274@pehr.net> There are several good graphics libraries for writing games. The Tkinter canvas object is the most accessable, as it is included with every version of python. WxWindows is gaining popularity as a faster cross-platform solution. I personally use the gnome-python bindings since I really like the Gnome widget set and want to take advantage of all the hard work pushing gnome forward. Python has highly readable source code so you can learn a lot from reading through example code. If you haven't seen the "Vaults of Pernasius" check it out. http://www.vex.net/parnassus/ Lots of python code for all different kinds of things! -pehr gbp wrote: > > It is possible to mix python with the gui that comes with java (swing) that may > provide a good framework for games. Don't expect fast animation. > > jin choung wrote: > > > howdy! > > > > are there any game programming sites specializing in python? is there such > > a thing? > > > > any kind of game will do... graphics, ascii, etc... > > > > thanks > > > > jin From quango at watervalley.net Thu Jul 27 23:31:37 2000 From: quango at watervalley.net (Chris Lawrence) Date: Fri, 28 Jul 2000 03:31:37 GMT Subject: The State of Python References: Message-ID: On Thu, 27 Jul 2000 18:37:14 -0400, Tim Peters wrote: >The old Python license served it very well for a decade. The new Python >license will almost certainly also be OSI certified, *compatible* with the >GPL, and allow proprietary commercial use. What we haven't been able to >avoid is massively unproductive legal wrangling -- but nothing can guarantee >to save you from that. FWIW, if the license is incompatible with the GPL, we'll end up with another license pissing contest like the GPL/QPL one. It might lead to trouble with distributing binaries of the readline module, for example. I hope BeOpen and/or CNRI are keeping RMS in the loop on this one, as I think that was the problem that led to the neverending QPL squabble. (In any event: do the loopholes matter to CNRI? They own the copyright. They can do whatever they damn well please with the code. The only problem that could ever occur is if CNRI suddenly started suing people for infringement... and can anyone name a way to infringe upon the Python license that would actually be worth contesting in a court of law? You could piss and moan about violating the attribution clause, but I can't see that being worth hiring lawyers about.) Chris (not speaking on behalf of Debian and waiting for the ./ flamefest this weekend) -- ============================================================================= | Chris Lawrence | Your source for almost nothing of value: | | | http://www.lordsutch.com/ | | | | | Grad Student, Pol. Sci. | Join the party that opposed the CDA | | University of Mississippi | http://www.lp.org/ | ============================================================================= From davidw at linuxcare.com Sun Jul 9 12:54:57 2000 From: davidw at linuxcare.com (David N. Welton) Date: 09 Jul 2000 18:54:57 +0200 Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> <87zonvso9c.fsf@cachemir.echo-net.net> <71vfmsc0sspvpg3mq8k3s1ri653908u9nk@4ax.com> Message-ID: <87hf9zgs66.fsf@eugene.prosa.it> Tim Roberts writes: > I'll say. Am I correct in understanding that the basic purpose of > "mod_snake" is to allow me to write other Apache modules in Python, > while PyApache is a module which lets me run Python CGI scripts > without launching a separate interpreter, just like mod_perl? mod_perl lets you do a whole ton of things, including writing Apache modules in Perl. > I tried to get interested in PHP, but the more I read, the more it > seemed to be a confused mishmash of features gathered from other > places. I thought it might be nice to be able to write web pages > that were mostly HTML, with server-side scripts interspersed, but it > seems that many PHP pages are written like CGI scripts that happen > to run inside Apache. As long as I'm going to do that, I'd rather > use Python. I might also suggest mod_dtcl (http://comanche.com.dtu.dk/dave/), which lets you use a 'non-web' language. It's quite fast, as well (doesn't load a new interpreter for each page). Ciao, -- David N. Welton, Responsabile Progetti Open Source, Linuxcare Italia spa tel +39.049.8043411 fax +39.049.8043412 cel +39.348.2879508 davidw at linuxcare.com, http://www.linuxcare.com/ Linuxcare. Support for the revolution. From wtanksle at dolphin.openprojects.net Fri Jul 28 14:45:50 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 28 Jul 2000 18:45:50 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <8lrp6k0utp@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 15:40:36 GMT, Steve Lamb wrote: >What about a way to define a variable that you want to be mutable. That simply can't be done, because in Python variables are only handles to data. Fortunately, what you want IS possible. Simply define a class whose __init__ function takes a single argument, converts it to a string, and stores it. Then define all of the operators the way you expect them to behave. a = Transformable(5) print 5 + a print a + "1foo" b = Transformable("6") >in programming, like rollover of integers in C, but I digress). Why not, >then, allow the programmer to say, "Yes, convert /this/ variable as needed >based on context"? A JUST_DO_IT!!!! flag, if you will? Again, there's no way to mark a variable, but it's not hard to create a datatype which is thus polluted. It IS hard to come up with meaningful operations, you'll find; Perl is actually quite impressive in how it built its operations. > Steve C. Lamb -- -William "Billy" Tanksley From stephen_purcell at yahoo.com Mon Jul 24 07:10:39 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 24 Jul 2000 11:10:39 -0000 Subject: newb Q: security with variables In-Reply-To: <397BE388.349CCA17@mediaone.net> Message-ID: <8lh87f+t50e@eGroups.com> Toy wrote: > Could you please explain to me various secure ways of having a > python script store variables such as your password/username in a > file. > I understand that you can chmod 0400 , but are > there any other alternatives? If you're going to put a username/password combination in a file, and if that's because you don't want to require a password to be entered interactively when the program runs, then there's nothing much you can do. The security of the file system is as good as you can hope for. > Also, can you run python code with files that don't end with the > python extensions(.py and others)? That way it would make it less > obvious that it was some sort of script. Thanks Yes. Simply 'chmod +x scriptname' and make the first line of the script read '#!/usr/bin/env python'. But, an executable file is almost as obviously a script as a '.py' file. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ "Life must be simple if I can do it" -- Me From johannes at zellner.org Fri Jul 7 18:26:29 2000 From: johannes at zellner.org (Johannes Zellner) Date: Sat, 8 Jul 2000 00:26:29 +0200 (CEST) Subject: default exception handler Message-ID: Hello, is it possible to install a default exception handler? E.g. if the interactive py shell gets a NameError I'd like it to call my own handler. -- Johannes From avv at quasar.ipa.nw.ru Sat Jul 29 17:58:18 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Sat, 29 Jul 2000 14:58:18 -0700 Subject: to better observe locales References: <3981D6E6.CE74151D@quasar.ipa.nw.ru> Message-ID: <3983537A.C7091340@quasar.ipa.nw.ru> Hi Guido van Rossum wrote: > "Alexander V. Voinov" writes: > > > It seems that Python would better observe locales at almost no cost. > > > > 1. list.sort(). If the sorted list is just a list of strings, it's > > trivial to pass 'strcoll' as an argument. But if the list element is a > > tuple, I have to write my own comparison function which would use > > locale. > > There are lots of good reasons why observing locales on string > comparisons with the < operator are a bad idea. What are these reasons? Are they presented somewhere on www.python.org? Alexander From moshez at math.huji.ac.il Thu Jul 27 01:04:11 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 27 Jul 2000 08:04:11 +0300 (IDT) Subject: Reading PCI Configuration Space... In-Reply-To: <397F501F.B733ECCB@uab.edu> Message-ID: On Wed, 26 Jul 2000, Shae Erisson wrote: > Jerome Chan wrote: > > > > Does anyone know how to read the PCI configuration space with Python > > under Win 98 or Linux? > > In linux, try: > cat /proc/pci Or, in Python, open("/proc/pci").read() -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From AKiss at GEOMETRIA.hu Mon Jul 24 10:43:52 2000 From: AKiss at GEOMETRIA.hu (Kiss, Arpad) Date: Mon, 24 Jul 2000 16:43:52 +0200 Subject: binary distribution of Zope's DCOracle for Win32 Message-ID: I have a compiled version that works with 7.3.4 clients. I can send it for you if it is good for you. Arpad wrote in message news:<8lhhhf$l73$1 at nnrp1.deja.com>... > Is there a binary version of DCOracle for Win32 systems? I have no > access to C compiler, also my knowledge of C is not sufficient. > > Thanks a lot > Jan > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list > From ZakonS at eccelerate.com Wed Jul 19 09:57:28 2000 From: ZakonS at eccelerate.com (Zakon, Stuart) Date: Wed, 19 Jul 2000 09:57:28 -0400 Subject: SSL support in Python Message-ID: <0A2FDC11F692D311AA730008C7B161F201645CE0@exbhbhmb04.us.dbisna.com> Does anybody know how to get SSL support in Python? In particular, we require the use of client certificates so the SSL library should allow these to be provided. I have some old links but it looks like these have not been kept up to date. Thanks, Stuart Zakon From cwebster at nevada.edu Fri Jul 28 16:41:28 2000 From: cwebster at nevada.edu (Corran Webster) Date: Fri, 28 Jul 2000 13:41:28 -0700 Subject: Interfaces (Re: Perl is worse! (was: Python is Wierd!)) References: Message-ID: In article , ge at nowhere.none (Grant Edwards) wrote: > In article , Moshe > Zadka wrote: > >On Fri, 28 Jul 2000, Grant Edwards wrote: > > > >> Is 'sequence mapping' for list() an tuple() defined the same as > >> for the 'for' statement: it has a get_item(i) method that > >> returns either a value or raises an exception? > > > >Actually, I think these two want an __len__ method too. > > At this point somebody is required to complain about the > vagueness of Python interfaces, and if there was some sort of > language facility for defining the interface for a "sequence" > then I wouldn't have had to ask that question. > > Since it's Friday, and the person assigned to the task of > complaining about interfaces is off today, I've filled in > temporarily. But I'm goign golfing at noon, so if you want to > argue about it you'll have to make an appointment with the > regular staff on Monday. Since I'm just filling in, all I'd be > able to provide is rote contridiction -- which we all know > isn't a real argument... Here's a little something that I've been fiddling with in my spare time for the past little while. It's an interface definition mechanism which uses metaclasses to allow a heirarchy of interfaces (somewhat like the exception heirarchy). See the docstrings for details on how to use it. Warning: This uses metaclasses, so your head may explode if you try to follow what is going on here. Corran interface.py ---- """ interface module Nasty metaclass stuff to define and test interfaces with at least a little syntactic sugar. This module defines a class heirarchy: Interface Number Stack Sequence MutableSequence (also sublcass of Stack) Mapping MutableMapping File InputFile OutputFile IOFile Iterator Typically you'd use this something like: def f(x): assert Iterator(x) for a in x: etc... You can also test classes for compliance with an interface: class InfiniteIterator: def __getitem__(self, n): return n assert Iterator(InfiniteIterator) This will not work if you expect certain instance variables to be present. To define your own interfaces, simply subclass from one of these and add your new required methods and instance variables. To define your own interface, do something like class MyInterface(Interface): def __getitem__(self, n): pass def wibble(self): pass foo = None Now any class or instance which has both __getitem__ and wibble methods and a foo instance or class variable will satisfy the interface. You can use the __types__ class variable to specify a list of builtin types which satisfy the interface. These are not inherited, so you must specify the complete list. More complex tests can be specified by adding a __test__ method to the inferface class. __test__ should return either 0 if the object does not satisfy the interface, 1 if it does, and 2 if it wants to default to the usual test. Interfaces can't have instances, as we are (ab)using the constructor to do testing. """ from types import * class InterfaceMetaClass: """Metaclass for interfaces TODO: * At the moment it only checks whether methods are callable, not whether they have sufficient arguments. This can be checked using introspection on the function objects. * It would be nice to be able to do pre-condition type checks on method arguments something like: class myiterator: def __getitem__(self, n): if __debug__: Iterator.__getitem__(self, n) It would be even nicer to do it automagically. * Fails for new types defined in extensions (can't detect special methods). Users will need to specifically update types. """ def __init__(self, name, bases, namespace): """Constructor -- create an interface. This will be called after a class statement where Interface is a base class. By default, instances of any class whose namespace includes all the names in namespace (or the namespace of a base interface class) will match the interface. """ for base in bases: if not isinstance(base, InterfaceMetaClass): raise TypeError, "Interface base class '%s' must " +\ "be an interface" bases = filter(lambda x: x is not Interface, bases) self.__name__ = name self.__bases__ = bases self.__types__ = [] for key in ['__test__', '__doc__', '__types__']: try: self.__dict__[key] = namespace[key] except KeyError: pass else: del namespace[key] self.__namespace__ = namespace def __call__(self, target): """Test instance for interface compliance""" # test for OK python types t = type(target) if t not in [InstanceType, ClassType]: return t in self.__types__ # test classes and instances try: if self.__dict__.has_key('__test__'): t = self.__test__(target) if t == 0 or t == 1: return t for (key, value) in self.__namespace__.items(): if callable(value): if not callable(getattr(target, key)): raise AttributeError # should do some argument checking here to make sure # that our method expects at a minimum no more than # the target method, and at a maximum no less than # the target's maximum else: getattr(target, key) for base in self.__bases__: if not base(target): return 0 except AttributeError: return 0 return 1 # Create the base class for interfaces # It is an empty interface Interface = InterfaceMetaClass("Interface", (), {}) class Number(Interface): __types__ = [IntType, LongType, FloatType, ComplexType] def __add__(self, other): pass def __radd__(self, other): pass def __sub__(self, other): pass def __rsub__(self, other): pass def __mul__(self, other): pass def __rmul__(self, other): pass def __div__(self, other): pass def __rdiv__(self, other): pass def __neg__(self): pass def __pos__(self): pass # probably should have other stuff like __pow__ and __divmod__ class Sequence(Interface): __types__ = [ListType, TupleType, StringType, BufferType] def __len__(self): """The length of the sequence""" pass def __getitem__(self, n): """Return the nth item in the sequence""" assert type(n) == IntegerType or type(n) == LongType def __getslice__(self, i, j): """Return the slice from i to j""" assert type(i) == IntegerType or type(i) == LongType assert type(j) == IntegerType or type(j) == LongType def __add__(self, other): """Add two sequences together""" pass def __radd__(self, other): """Add two sequences together""" pass def __mul__(self, n): """Repeat the sequence n times""" assert type(n) == IntegerType def __rmul__(self, n): """Repeat the sequence n times""" assert type(n) == IntegerType or type(n) == LongType class Mapping(Interface): __types__ = [DictType] def __len__(self): """Return the number of entries in the mapping""" pass def __getitem__(self, key): """Return the value corresponding to the key""" pass def has_key(self, key): """Return true if the mapping has the key""" pass def keys(self): """Return the list of keys""" pass def values(self): """Return the values from the mapping""" pass def items(self): """Return a list of (key, value) pairs""" pass def get(self, key, value=None): """Return the value corresponding to the key if the key exists, else return value""" pass def copy(self): """Return a copy of the mapping""" pass class Stack(Interface): __types__ = [ListType] def pop(self): """Pop the top element off the stack""" pass def append(self, item): """Push an element onto the stack""" pass class MutableSequence(Sequence, Stack): __types__ = [ListType] def __len__(self): """The length of the sequence""" pass def __setitem__(self, n, value): """Set the nth item in the sequence to value""" assert type(n) == IntegerType or type(n) == LongType def __setslice__(self, i, j, sequence): """Return the slice from i to j""" assert type(i) == IntegerType or type(i) == LongType assert type(j) == IntegerType or type(j) == LongType def __delitem__(self, n): """Delete the nth item from the sequence""" assert type(n) == IntegerType or type(n) == LongType def __setslice__(self, i, j): """Delete the slice from i to j""" assert type(i) == IntegerType or type(i) == LongType assert type(j) == IntegerType or type(j) == LongType def count(self, value): pass def index(self, value): pass def insert(self, n, value): assert type(n) == IntegerType or type(n) == LongType def remove(self, value): pass def reverse(self): pass def sort(self): pass class MutableMapping(Mapping): __types__ = [DictType] def __setitem__(self, key, value): """Set the value corresponding to key""" pass def __delitem__(self, key): """Delete the value corresponding to key""" pass def clear(self): """Remove all items from the mapping""" pass def update(self, m): """Add entries from m to the mapping""" assert Mapping(m) class File(Interface): __types__ = [FileType] closed = 0 def close(self): pass class InputFile(File): __types__ = [FileType] def read(self, size=None): pass def readline(self, size=None): pass def readlines(self, sizehint=None): pass class OutputFile(File): __types__ = [FileType] def write(self, size=None): pass def writelines(self, sizehint=None): pass class IOFile(InputFile, OutputFile): __types__ = [FileType] # Additional useful interfaces class Iterator(Interface): """Iterators can take the place of standard sequences in for loops""" __types__ = [ListType, TupleType, StringType] def __getitem__(self, n): """Return the nth item in the sequence or IndexError if done""" assert type(n) == IntegerType or type(n) == LongType assert n >= 0 From aahz at netcom.com Fri Jul 21 15:33:31 2000 From: aahz at netcom.com (Aahz Maruch) Date: 21 Jul 2000 19:33:31 GMT Subject: zip() : how about braid() References: <8l6cbp$fgr$1@pollux.ip-plus.net> <3977C2A8.6D8F7586@my.signature> Message-ID: <8la8ib$8um$1@slb2.atl.mindspring.net> In article <3977C2A8.6D8F7586 at my.signature>, Greg Ewing wrote: >"J?rgen Hermann" wrote: >> >> merge() is the best yet, since it's a common (programming) term with a >> well-defined meaning. > >But it's a DIFFERENT meaning! > >merge([1,2,4,6,7,8],[3,5,9]) --> [1,2,3,4,5,6,7,8,9]) No, that's only when "merge" is a modifier for "sort". -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From mwh21 at cam.ac.uk Sat Jul 22 20:58:42 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 Jul 2000 01:58:42 +0100 Subject: zip or marry etc: compose()! References: Message-ID: David Goodger writes: > I haven't seen anyone suggest "compose", which is the only word I can think > of that comes close to the intended semantics. Especially since, political > statements aside, both "marry" and "zip" imply two sources. Compose to me would strongly imply something along the lines of def compose(f,g): return lambda x,f=f,g=g:f(g(x)) and-it's-still-going-to-be-called-"zip"-ly y'rs M. -- /* I'd just like to take this moment to point out that C has all the expressive power of two dixie cups and a string. */ -- Jamie Zawinski from the xkeycaps source From shapr at uab.edu Tue Jul 25 07:02:22 2000 From: shapr at uab.edu (Shae Erisson) Date: Tue, 25 Jul 2000 11:02:22 GMT Subject: Obtaining network configuration via Python References: Message-ID: <397D72ED.22DDC50C@uab.edu> Micheal Kelly wrote: > > Hi all, > > Quick question: I'm writing some Python scripts in Linux that need access > to the system's network configuration - now, I could parse the output of > ifconfig quite easily (and have for that matter). However, for various reasons > I can't and don't want to do this - I'd rather access the network configuration > info directly from the OS if possible. > > My question is: Does anyone know how to do this in Python under Linux? > Is there a module or library I can use? I ran across this yesterday, hope it helps: http://www.linuxcare.com.au/projects/gnetstat/ -- Shae Matijs Erisson - http://www.webwitches.com/~shae/ VirtualPairProgramming Wanted - Linux/Emacs/Python/Speak Freely .fi: rakastan ohjelmointia - python kengitt?? aasia From honza_v at my-deja.com Mon Jul 24 09:49:36 2000 From: honza_v at my-deja.com (honza_v at my-deja.com) Date: Mon, 24 Jul 2000 13:49:36 GMT Subject: binary distribution of Zope's DCOracle for Win32 Message-ID: <8lhhhf$l73$1@nnrp1.deja.com> Is there a binary version of DCOracle for Win32 systems? I have no access to C compiler, also my knowledge of C is not sufficient. Thanks a lot Jan Sent via Deja.com http://www.deja.com/ Before you buy. From nobody at nowhere.nohow Fri Jul 28 21:02:31 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:02:31 GMT Subject: Perl is worse! References: <398178EA.7576E13A@hursley.ibm.com> <8ls9oe01f82@news2.newsguy.com> Message-ID: In article <8ls9oe01f82 at news2.newsguy.com>, Alex Martelli wrote: >"Grant Edwards" wrote in message >>>> Because numbers are numbers and strings are not. Given, Python's numeric >>>> model is not very good. >> > >> >What is wrong with Python's numeric model ? >> >> I may be a minority, but I don't like integers being converted >> to floats automatically. > >I have no problem with that _if it wastes NO information in so >doing_. I believe that on typical machines of today (32-bit >integers, 64-bit IEEE floating point) this can be guaranteed >*for integers*. *LONG* integers are another matter...! And >as I mentioned I think the rational solution to that problem is >not to forbid numeric promotions but to ensure they never >lead to information-loss by introducing the 'rational' type (a >couple of long-integers taken as num/denom of a fraction). >[That's why it's the *rational* solution:-)]. As long as the conversion can guarantee no information loss, I wouldn't have a problem with it. I've yet to use a language that can make that guarantee. I guess I never looked into the details in Python (haven't done much numerical stuff yet). I had sort of assumed that floating point values were 32 bit, but if they're 64, then as you say, the problem is postponed until long ints are involved. -- Grant Edwards grante Yow! I wish I was on a at Cincinnati street corner visi.com holding a clean dog! From caribou2 at yahoo.com Wed Jul 19 14:01:03 2000 From: caribou2 at yahoo.com (Karl Ulbrich) Date: Wed, 19 Jul 2000 14:01:03 -0400 Subject: zip or marry etc In-Reply-To: <3975E070.308511F4@roguewave.com>; from bjorn@roguewave.com on Wed, Jul 19, 2000 at 11:08:00AM -0600 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> <3975E070.308511F4@roguewave.com> Message-ID: <20000719140103.E3336@exeter.exeter.org> > > Olivier Dagenais wrote: > > >How about: > > > > > >"twist", "merge", "smash", "glue", "dna", "ladder", "join", "match", > > >"collect", "pick", "lineup"??? Suggested elsewhere, but I liked "plait". Karl Ulbrich From blinocac1 at home.com Sat Jul 15 12:35:48 2000 From: blinocac1 at home.com (David L. Heald Jr.) Date: Sat, 15 Jul 2000 16:35:48 GMT Subject: Tkinter? Message-ID: I'm writing a script that will act as a GUI interface to another script, and I want to have file browsing ability. How do I call this in Tkinter? I have looked through 2 different books, and a couple of help files and have yet to find anything. From paul at prescod.net Thu Jul 20 11:05:02 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 20 Jul 2000 10:05:02 -0500 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <39770CD5.215D4C0C@cornell.edu> Message-ID: <3977151E.4E6F7D94@prescod.net> Samuel Scarano wrote: > > First of all, are you referring to something specific by "Unicode strings"? > (I wasn't aware of any standard unicode string class but I'd be interested > if there is one.) Python 1.6/2 has a Unicode string class. > Anyway, interesting point, but isn't that what multiple inheritance is for? > A static (or, for that matter, dynamic) typecheck ensuring that the function > is called with a string would work fine with unicode strings as long as the > unicode string class is a subclass of the string class. This is a matter of long and ongoing debate in the object oriented languages world. I think that the currently dominant view among those who think deeply about it is that you inherit because you want some "free methods" from a parent class and that is a totally different operation from saying you want to act like that class. C++ has a concept of "private inheritance" which is really inheritance without subclassing. And you could have empty base classes to kludge subclassing without inheritance. (so there is some distinction but it isn't really clear in the language). You could call this type inheritance without implementation inheritance also. Java also takes a middle of the road stance. It allows type type inheritance without implementation inheritance through interfaces but a lot of important "interfaces" are defined as classes. From a purity point of view it would be better if they were just interfaces. A language called Sather makes the distinction clear and principled: http://www.gnu.org/software/sather/ICSI_Sather/Documentation/EclecticTutorial/node5.html Where Python would/should come down on these issues is an open question. -- Paul Prescod - Not encumbered by corporate consensus "Hardly anything more unwelcome can befall a scientific writer than having the foundations of his edifice shaken after the work is finished. I have been placed in this position by a letter from Mr. Bertrand Russell..." - Frege, Appendix of Basic Laws of Arithmetic (of Russell's Paradox) From jblazi at vipsurf.de Sun Jul 30 08:27:09 2000 From: jblazi at vipsurf.de (Janos Blazi) Date: Sun, 30 Jul 2000 14:27:09 +0200 Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> Message-ID: <39841e3a_1@news.newsfeeds.com> Neil Hodgson schrieb in im Newsbeitrag: zUUg5.16220$4p3.129370 at news-server.bigpond.net.au... > > Can somebody tell me, how a dll call from Python works on principal? Let > us > > suppose I'd like to something like caldll. Where should I start. Which > > Python "primitives" have I to use? > > I can explain how to use calldll. If you want to know how to write your > own extensions then you should read the "Extending and Embedding the Python > Interpreter" document which is part of the standard documentation package > and should have been installed when you installed Python. > > calldll is a low level Python extension libary which contains functions > for creating buffers, loading DLLs, finding the address of functions within > the loaded DLLs, and calling the functions. On top of that is a higher level > windll module that makes it more convenient to call. > > Here is a sequence of calls: > > import calldll > kernel32 = calldll.load_library('kernel32.dll') > Beep = calldll.get_proc_address(kernel32, "Beep") > ret = calldll.call_foreign_function(Beep,'ll','l',(1000,500)) > > Neil Thx. Can you (additionally) explain the meaning of 'll' and 'l' and give an example where I receive a return value (a double for example)? -----= 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 R.Brodie at rl.ac.uk Wed Jul 26 11:54:30 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 26 Jul 2000 16:54:30 +0100 Subject: polymorphism (was Re: Type checking in python?) References: <8lmo4i$s28$1@news.kth.se> Message-ID: <8ln1jo$rm8@newton.cc.rl.ac.uk> "Oivvio Polite" wrote in message news:8lmo4i$s28$1 at news.kth.se... > For instance I want the constructor to take either a filename, a file object > or a database connection object. > wrote: >> Let me also point out that in many cases, this style of programming >> would be frowned upon by serious Python programmers. Polymorphism and method overloading aren't really the same thing at all. What Paul was saying was that Python lacks (or doesn't want) a Java like interface concept. So if you wanted a method to be able to write to any stream, you can't specify that in the code. And attempting to enumerate all possible streams would break polymorphism. Python takes the approach that if it looks like a fish and smells like a fish, it probably is a fish. Now what you are doing is rather different. You have three different things: there is nothing that you could say 'filename', 'file object', and 'database connection' are all kinds of. Except 'object' perhaps. How to solve the problem? One approach would be to use a factory style and have three functions: generateXFromFileName(), generateXFromFileObject(), generateXFromDBConn(). From jkraska1 at san.rr.com Fri Jul 14 13:24:36 2000 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 14 Jul 2000 17:24:36 GMT Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> Message-ID: <396F4D72.C8AC5F14@san.rr.com> Peter Timaratz wrote: > > I can't think of any advantages to a case sensitive language. Python is a > very well-designed language though, so I imagine there is a good reason that > it is case sensitive. So what are the advantages of a case sensitive > language? I CAn'T thINk of ANy ADVAnTAgEs to a CaSE SENsItive lAnGUaGE. PythON Is AvErY WELl-DEsigNEd lANGUaGE thouGh, SO I ImAgiNe TheRE iS a Good rEAson thatiT is Case sENsitIVE. So WhAT ARe tHE AdVAntAgEs of a case SENSITiVelanGuAge? C/ From sjoerd at oratrix.nl Thu Jul 20 08:07:38 2000 From: sjoerd at oratrix.nl (Sjoerd Mullender) Date: Thu, 20 Jul 2000 14:07:38 +0200 Subject: BUG: File modes under IRIX In-Reply-To: Your message of Thu, 20 Jul 2000 12:08:13 +0300. <8l6fjk$19r9$1@learnet.freenet.hut.fi> References: <8l6fjk$19r9$1@learnet.freenet.hut.fi> Message-ID: <20000720120739.58F3E31047C@bireme.oratrix.nl> On Thu, Jul 20 2000 "Sami Hangaslammi" wrote: > Python version: Python 1.5.2 (#2, Mar 22 2000, 10:10:50) [GCC 2.8.1] on > irix646 > > When using os.makedirs('foo/bar',0755) (or os.mkdir) the mode of the created > directories is incorrectly set as rwx------. > > Is this a known problem or am I just doing something wrong (I'm terribly > unexperienced when it comes to *x systems)? Not when I do this. I tried this on IRIX 6.5.2, and the mode of the two directories that were created (foo and foo/bar) were 755. Are you sure your umask isn't set to 0077? Try the command "umask" in your shell. -- Sjoerd Mullender From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 17:00:15 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 21:00:15 GMT Subject: Why make a language case sensitive? Message-ID: <3bQZdE$kqT@openbazaar.net> > ill take a look at it, although my guess is that I will stick with > Ultra Edit until I get around to making my own editor If we all combined our efforts on "Boa Constructor", "wxDesigner" and "PythonWin", we may just already have everything we need to kick every other language's or IDE's rear-end... : ) Do you have an URL for Ultra Edit? You've sparked my curiosity.. > > > it is said the man who knew the language inside out :-) > > I'm sorry, I don't follow... > I was just showing off :-) > saying yes var is the way you do it, when you do it in > JavaScript/JScript, and at the same time saying that > I know JScript inside out Ah, I think I could have used a little comma after "it is", as in "It is", said the man who knew the language inside out. rather than my interpretation: It is said that the man knew the language inside out. ...a little different, isn't it? : ) > yes the 125 wasn't much fun - I haven't looked at 132 yet, > I have been busy developing a major online consumer database in > ASP/Jscript, I actually considdered using Python but I couldn't > figure out how to set the values Session and Application Objects... I also thought 125 wasn't too good, but that's because I thought I had grabbed the latest version... 132 is a big improvement, you really should try it! > aye one thing only - and of course I know the question, isn't > that what we earthlings are here for? ;-) Yeah, but our planet was destroyed five minutes before the "computation" was complete. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From milenko at moonshine.co.uk Sun Jul 23 09:09:55 2000 From: milenko at moonshine.co.uk (Jack) Date: 23 Jul 2000 13:09:55 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <8F7985804milenkomoonshinecouk@194.73.73.116> <3979F974.A0EBC279@roguewave.com> Message-ID: <8F7A985D3milenkomoonshinecouk@194.73.73.116> Thanks guys, you've been a real help! On with the pythoning... -Jack Green From bjrubble at shell16.ba.best.com Fri Jul 7 19:34:55 2000 From: bjrubble at shell16.ba.best.com (Adam Clark) Date: 7 Jul 2000 23:34:55 GMT Subject: Help! Indenting craziness! Message-ID: <8k5pev$182l$1@nntp1.ba.best.com> Hi all, Does anybody have a technique for avoiding syntax errors due to blank, unindented lines? I'm getting these on a regular basis, and I haven't figured out any reliable way to fix them. Sometimes if I take every line in the vicinity, backspace it to the end of the previous line, and reposition it, the errors go away. But often they don't, and I end up just deleting chunks and rewriting them until Python stops complaining. This is with Emacs and python-mode. Thanks Adam From cg at gaia.cdg.acriter.nl Tue Jul 25 14:37:12 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 25 Jul 2000 20:37:12 +0200 Subject: Python in game development? References: <8li3gg$7vg$1@gaia.cdg.acriter.nl> Message-ID: <8lkmoo$lim$1@gaia.cdg.acriter.nl> Toby Dickenson said: >>And this gets /really/ great if your code runs in a persistent VM, like >>Smalltalk. > > ...... or like python, using ZODB > No, it's not the same. In your Smalltalk environment you just say "save&quit", and the whole VM state is dumped on disk. ZODB is "just" an OODB, though a very useful one (I use it under a number of CGI scripts on my site). -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From paul at prescod.net Sat Jul 22 00:11:56 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 21 Jul 2000 23:11:56 -0500 Subject: New PEP: Attribute Access Handlers Message-ID: <39791F0C.CDC13E79@prescod.net> http://python.sourceforge.net/peps/pep-0213.html PEP: 213 Title: Attribute Access Handlers Version: $Revision: 1.3 $ Owner: paul at prescod.net (Paul Prescod) Python-Version: 2.0 Status: Incomplete Introduction It is possible (and even relatively common) in Python code and in extension modules to "trap" when an object's client code attempts to set an attribute and execute code instead. In other words it is possible to allow users to use attribute assignment/ retrieval/deletion syntax even though the underlying implementation is doing some computation rather than directly modifying or reporting a binding. This PEP describes a feature that makes it easier, more efficient and safer to implement these handlers in Python class instances. Justification Scenario 1: You have a deployed class that works on an attribute named "stdout". After a year, you think it would be better to check that stdout is really an object with a "write" method at the moment of assignment. Rather than change to a setstdout method (which would be incompatible with deployed code) you would rather trap the assignment and check the object's type. Scenario 2: You want to be as compatible as possible with an object model that has a concept of attribute assignment. It could be the W3C Document Object Model or a particular COM interface (e.g. the PowerPoint interface). In that case you may well want attributes in the model to show up as attributes in the Python interface, even though the underlying implementation may not use attributes at all. Scenario 3: A user wants to make an attribute read-only. In short, this feature allows programmers to separate the interface of their module from the underlying implementation for whatever purpose. Again, this is not a new feature but merely a new and more robust syntax for something that can already be implemented. Current Solution To make some attributes read-only: class foo: def __setattr__( self, name, val ): if name=="readonlyattr": raise TypeError elif name=="readonlyattr2": raise TypeError ... else: self.__dict__["name"]=val This has the following problems: 1. The creator of the method must be intimately aware of whether somewhere else in the class hiearchy __setattr__ has also been trapped for any particular purpose. If so, she must specifically call that method rather than assigning to the dictionary. There are many different reasons to overload __setattr__ so there is a decent potential for clashes. For instance object database implementations often overload setattr for an entirely unrelated purpose. 2. The string-based switch statement forces all attribute handlers to be specified in one place in the code. They may then dispatch to task-specific methods (for modularity) but this could cause performance problems. 3. Logic for the setting, getting and deleting must live in __getattr__, __setattr__ and __delattr__. Once again, this can be mitigated through an extra level of method call but this is inefficient. Proposed Syntax Special methods should declare themselves with definitions of the following form: class x: def __attr_XXX__(self, op, val ): if op=="get": return someComputedValue(self.internal) elif op=="set": self.internal=someComputedValue(val) elif op=="del": del self.internal Client code looks like this: inst=x() fooval=inst.XXX inst.XXX=fooval+5 del x.XXX Semantics Attribute references of all three kinds should call the method. The op parameter can be "get"/"set"/"del". Of course this string will be interned so the actual checks for the string will be very fast. It is disallowed to actually have an attribute named XXX in the same instance dictionary as a method named __attr_XXX__. If both are declared in a class then the last one declared replaces the other one. An implementation of __attr_XXX__ takes precedence over an implementation of __getattr__ based on the principle that __getattr__ is supposed to be invoked only after as a last resort after an appropriate attribute lookup has failed. An implementation of __attr_XXX__ takes precedence over an implementation of __setattr__ in order to be consistent. The opposite choice seems fairly feasible also, however. The same goes for __del_y__. Proposed Implementation There is a new object type called an attribute access handler. Objects of this type have the following attributes: name (e.g. XXX, not __attr__XXX__ method (pointer to a method object Class construction In PyClass_New, methods of the appropriate form will be detected and converted into objects (just like unbound method objects). These are stored in the class __dict__ under the name XXX. The original method is stored as an unbound method under its original name. If there are any attribute access handlers in an class at all, a flag is set. Let's call it "I_have_computed_attributes" for now. Derived classes inherit the flag from base classes. Instance construction Instances inherit the "I_have_computed_attributes" flag from classes. No other changes to PyInstance_New are anticipated. Property fetching At the layer, Python instance attribute lookup is always done through PyInstance_getattr. A "get" proceeds as usual until just before the object is returned. In addition to the current check whether the returned object is a method it would also check whether a returned object is an access handler. If so, it would invoke the getter method and return the value. To remove an attribute access handler you could directly fiddle with the dictionary. Gets should be more efficient than they are today with __getattr__ and no different for classes that do not use the feature at all. A set proceeds by checking the "I_have_computed_attributes" flag. If it is not set, everything proceeds as it does today. If it is set then we must do a dictionary get on the requested attribute name. If it returns an attribute access handler then we call the setter function with the value. If it returns any other object then we discard the result and continue as we do today. Note that having an attribute access handler will mildly affect attribute "setting" performance for all sets on a particular instance, but no more so than today, using __setattr__. The I_have_computed_attributes flag is intended to eliminate the performance degradation of an extra "get" per "set" for objects not using this feature. Checking this flag should have miniscule performance implications for all objects. The implementation of delete is basically identical to the implementation of set. Caveats 1. You might note that I have not proposed any logic to keep the I_have_computed_attributes flag up to date as attributes are added and removed from the instance's dictionary. This is consistent with current Python. If you add a __setattr__ method to an object after it is in use, that method will not behave as it would if it were available at "compile" time. The dynamism is arguably not worth the extra implementation effort. This snippet demonstrates the current behavior: >>> def prn(*args):print args >>> class a: ... __setattr__=prn >>> a().foo=5 (<__main__.a instance at 882890>, 'foo', 5) >>> class b: pass >>> bi=b() >>> bi.__setattr__=prn >>> b.foo=5 2. Assignment to __dict__["XXX"] can overwrite the attribute access handler for __attr_XXX__. Typically the access handlers will store information away in private __XXX variables 3. An attribute access handler that attempts to call setattr or getattr on the object itself can cause an infinite loop (as with __getattr__) Once again, the solution is to use a special (typically private) variable such as __XXX. -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From beat.bolli at earthling.net Sun Jul 16 10:38:05 2000 From: beat.bolli at earthling.net (Beat Bolli) Date: Sun, 16 Jul 2000 16:38:05 +0200 Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <8kshd3$l1h$2@bw107zhb.bluewin.ch> Hi all this is my first crack at Python patching. I was simply appalled to find '3'.zfill(5) not working anymore in 2.0b1, so I decided to do something about it. Now since zfill can be expressed as rjust with an optional pad characer argument, I implemented this. This is my 12th wedding anniversary present to the Python community. Live long and prosper! [Can't post an attachment?!] Beat Bolli -- PGP: 0x506A903A; 49D5 794A EA77 F907 764F D89E 304B 93CF 506A 903A ICBM: 47? 02' 43.0" N, 07? 16' 17.5" E (WGS84) --- stringobject.c.orig Sun Jul 16 15:15:15 2000 +++ stringobject.c Sun Jul 16 16:05:55 2000 @@ -1767,16 +1767,17 @@ } static char ljust__doc__[] = -"S.ljust(width) -> string\n\ +"S.ljust(width [, padchar]) -> string\n\ \n\ Return S left justified in a string of length width. Padding is\n\ -done using spaces."; +done using spaces unless padchar is given."; static PyObject * string_ljust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:ljust", &width)) + char padchar = ' '; + if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &padchar)) return NULL; if (PyString_GET_SIZE(self) >= width) { @@ -1784,21 +1785,22 @@ return (PyObject*) self; } - return pad(self, 0, width - PyString_GET_SIZE(self), ' '); + return pad(self, 0, width - PyString_GET_SIZE(self), padchar); } static char rjust__doc__[] = -"S.rjust(width) -> string\n\ +"S.rjust(width [, padchar]) -> string\n\ \n\ Return S right justified in a string of length width. Padding is\n\ -done using spaces."; +done using spaces unless padchar is given."; static PyObject * string_rjust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:rjust", &width)) + char padchar = ' '; + if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &padchar)) return NULL; if (PyString_GET_SIZE(self) >= width) { @@ -1806,7 +1808,7 @@ return (PyObject*) self; } - return pad(self, width - PyString_GET_SIZE(self), 0, ' '); + return pad(self, width - PyString_GET_SIZE(self), 0, padchar); } From skip at mojam.com Wed Jul 19 16:48:53 2000 From: skip at mojam.com (Skip Montanaro) Date: Wed, 19 Jul 2000 15:48:53 -0500 (CDT) Subject: Hey folks! Read This For Pointers to Python 2.0, PEPs, etc In-Reply-To: <8l4ph6$vj$1@nnrp1.deja.com> References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> <8l4ph6$vj$1@nnrp1.deja.com> Message-ID: <14710.5173.255089.614501@beluga.mojam.com> ric> It's bad it's so hard, hard, hard to find current information about ric> Python on the web starting from would-be obvious points. ric> (Exercise: starting from www.python.org/, find anything "mainstream" ric> about Python 2, or "Python-dev" ... :-( ) ric> (By "mainstream" I mean something like "What's new in Python 2.0" - ric> yes I eventally was lucky enough to get a hand on that one -- or ric> "table of PEP documents/proposals/..." -- these items are still ric> wanted, if they exist.) Please note (everyone!) that Python is still in a major transition stage at the moment: * Guido and his band of merriment have left CNRI for BeOpen. * http://www.python.org is still at CNRI, Guido, Barry, et al can no longer just fiddle some bits on the web site to magically make new pointers available. * CNRI and BeOpen were (last I heard) still in discussion about the handoff of the technology (hence the delayed release of Python 1.6 and/or 2.0). * The PEP stuff is *brand new* - less than a week old. The only way I know of to get the current PEPs is via CVS from SourceForge. The first place you should look for details about what Guido and the BeOpen gang are doing with Python is http://www.pythonlabs.com/. It has a What's New page (click the Technology link on the front page) as well as directions for grabbing the latest CVS sources from SourceForge. The Python project page at SourceForge is https://sourceforge.net/project/?group_id=5470. Hope this helps... -- Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ "To get what you want you must commit yourself for sometime" - fortune cookie From timaratz at lisco.com Fri Jul 14 16:08:14 2000 From: timaratz at lisco.com (Peter Timaratz) Date: Fri, 14 Jul 2000 15:08:14 -0500 Subject: Why make a language case sensitive? In-Reply-To: Message-ID: <000c01bfedcf$3e316160$6cb745c6@timaratz> I thought there might be a reason why it needs to be case sensitive. I guess if you come from a Unix background (which I don't) and you create a language, then it seems natural to make it case sensitive. I'm not trying to start a war, so I'll refrain from expressing my opinion. :) > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of richard_chamberlain > Sent: Friday, July 14, 2000 9:52 AM > To: python-list at python.org > Subject: Re: Why make a language case sensitive? > > > Hi Peter, > > That's a bit of a sore point at the moment :-) > > do a search on deja for case sensitive and you'll find a whole argument on > the subject. > > Richard > > Peter Timaratz wrote in message > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > I can't think of any advantages to a case sensitive language. > Python is a > > very well-designed language though, so I imagine there is a good reason > that > > it is case sensitive. So what are the advantages of a case sensitive > > language? > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From kpmurphy at my-deja.com Mon Jul 10 17:01:25 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 10 Jul 2000 21:01:25 GMT Subject: clipboard Message-ID: <8kddiq$8oc$1@nnrp1.deja.com> how do you read from / write to the system clipboard from Tkinter? i'm on a unix machine, if that matters. Thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From sblakey at freei.com.bbs Mon Jul 17 20:20:02 2000 From: sblakey at freei.com.bbs (sblakey at freei.com.bbs) Date: 18 Jul 2000 00:20:02 GMT Subject: event handler advice Message-ID: <3bRUP2$kS7@openbazaar.net> On Mon, Jul 17, 2000 at 03:49:02PM -0700, Pete Shinners wrote: > i'm trying to write a simple event handler python class. > so far i haven't come up with an 'elegant' solution i was > expecting. > <> > > my guess is i need some dictionary that defines the > messages and their routine name (no shortcut way to do > this unless python had #define like macros :]) > > messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} > > then a routine like > > class basehandler: > def handle(messageid): > name = messages[messageid] > self.name() #HAHA, no really, how do i do this? > > but i'm not exactly sure how to write this. need help, thx > > > Probably he simplest solution is along the lines of: class basehandler: def handle(messageid): name = messages[messageid] bound_method = getattr(self, name) bound_method() Personally, I would be more comfortable with: class basehandler: def handle(messageid): try: name = messages[messageid] bound_method = getattr(self, name) except KeyError: if __debug__: print 'Invalid message sent', messageid # or other error handling (syslog?) except AttributeError: if __debug__: print 'Unhandled message received', name # other misc error handling else: bound_method() This approach allows trapping of "illegitimate" messages (or messages you haven't gotten around to implementing yet) without the nastiness of an unhandles exception. -Sean -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 "It ain't so much the things we don't know that get us in trouble. It's the things we know that ain't so." -- Artemus Ward aka Charles Farrar Brown From wware at world.std.com Thu Jul 13 22:42:49 2000 From: wware at world.std.com (Will Ware) Date: Fri, 14 Jul 2000 02:42:49 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kf4o5$fao$1@nnrp1.deja.com> Message-ID: In article , "Neil Hodgson" wrote: > Now that Microsoft have revealed their Intermediate Language (IL) > virtual > machine, are we going to see a version of Python that compiles > directly to > IL? Or will Python byte codes still be interpreted by C code? Does anybody know if the IL virtual machine is amenable to the kinds of stacklessness tricks that Chris Tismer has been doing with the CPython VM? -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From moshez at math.huji.ac.il Wed Jul 12 10:54:35 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 12 Jul 2000 17:54:35 +0300 (IDT) Subject: Why are some infinite recursion stack overflows hard to deal with? In-Reply-To: Message-ID: On 12 Jul 2000, Alex wrote: > > Probably everyone who could answer this is busy on the python-dev list, > but I'll ask now, anyway. Why are some infinite recursion stack > overflows harder for python to deal with than others? This is an > example from the bugs list: > > class T: > def __str__(self): > print self > print T() > > Is this just dumping stuff on the stack faster than a vanilla infinite > recursion, causing an overflow before the maximum recursion depth is > reached? If so, what sort of stuff is it dumping? And where would I > look in the source to understand this sort of thing? Python has a hack to try to deal with that: it checks bounds on the recursion itself. However, Python's guess is a bit off on windows. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From gregory.lielens at fft.be Thu Jul 20 05:45:10 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Thu, 20 Jul 2000 11:45:10 +0200 Subject: Discussion: new operators for numerical computation References: Message-ID: <3976CA26.AAAC8C3F@fft.be> > Based on my ramblings I'll toss out a proposed operator set for the > pack to feed upon: > > Operator Name > .* matmul > ./ matdiv > /. matsol > .** or(?) .^ matpow > * mul > / div > %,^,&,|,** mod, xor, and, or, pow > > With broadcasting / nonbroadcasting decided by the individual packages. > > My 3 cents. > > -tim I agree almost completely with Tim's arguments, except for the choice of . instead of @. I would prefer @ because .* means elementwise for Matlab users, matlab notation is more or less a standard for numerical matrix computation (at least, it is the most widely used) inversing the meaning of * and .* in Python compared to the "standard" is IMO asking for far more trouble than to introduce new symbols... Here is thus my proposal (which is in fact currently implemented, together with the aug-assign patch...I should post the complete patch so that everybody can check it...but where?) Operator Name @ matmul @/ matdiv /@ matsol @@ matpow * mul / div %,^,&,|,** mod, xor, and, or, pow @ was choosen over @* because @ is already quite heavy by itself... @@ follow naturally, and @/, /@ the only way I came to differentiate matsol of matdiv... These three symbol are probably too heavy, but it is maybe not a bad thing, imho, as they are potentially very CPU-intensive, the heaviness can act as a kind of warning: use with care. Moreover, I think these three operator work well with matrices, not with general Nd array. @ on the other hand, should be defined as an inner product a=b at c is a(i1,...,in,j1,...,jm) = Sum_over_k ( b(i1,...,in,k)*c(k,j1,..,jn)) the three ugly @@, @/,/@ are thus a lttle less general that the "pretty" (not so ugly is a better way to describe it :)) @. I do not have introduced @+, @- for the same reason as Tim: there is no fundamental difference between matrix and element addition and substraction, they would be introduced as a way to specify wether broadcast or error is asked for when matrix (or Nd arrays) are not of the same shape. In fact, I just verfied, .+ does not exist in matlab...Personnaly, I vote to a + , - , *, / broadcast always, @, @/, /@ never (what should be the meaning of bradcasting for these?) There is only one element division, /, compared to 2 matrix dvisions, @/ and /@. (not sol operator, only a matsol one) This is imho not an issue, as A matsol B <> B matdiv A, but should sol exist, A sol B == B div A (for Matlab users, A\B <> B/A, but A.\B == B./A. . in fact, .\ is almost never used in Matlab) My concern with this notation is that -it is not using @ as a systematic extender of previous notation. We could use @* instead of @, and @** for @@, but it is less aesthetic imho... - As Tim said, @ is heavy...The first character which I planned to use was in fact ? (degree, a small circle located at the same height as "), but it is not in ASCII table and not on US qwerty keyboard (on my azerty keyboard, it is easier to type than @). Should unicode (or 8 bit Latin-1 character table) be supported, and ? be accessible worldwide, I choose it anytime over @: A?B is pretty! - It eat the @ character, which was not previously used and could be reserved for new uses...but we are speaking of a new use, aren't we? Greg. From dsavitsk at e-coli.net Sun Jul 30 22:46:48 2000 From: dsavitsk at e-coli.net (d. savitsky) Date: Mon, 31 Jul 2000 02:46:48 GMT Subject: Help! example DLL crashes Python on NT References: <8m2fqq+kecb@eGroups.com> Message-ID: I am not sure if this is what you need, but to connect to dll's (that is, to call functions in them) I use windll/calldll (in the Dynwin package from Sam Rushing @ http://www.nightmare.com) Once it is extracted try something like >>> from dynwin.windll import * >>> m = module('mydll32') # note no .dll extension >>> x = m.SomeFunction() >>> x 'returned stuff' I don't know if this is what you are asking, but it is all i know how to do :) doug "Ed Stauff" wrote in message news:8m2fqq+kecb at eGroups.com... > When I try to import the example DLL on Windows NT, I get an > "Application Error" dialog for python.exe (with the usual unreadable > hex junk), and then python quits after printing "Fatal Python error: > PyThreadState_Get: no current thread". I typed "import example" > right after launching Python. > > I've got Python 1.5.2 on Windows NT, and I'm using the python.exe > that came with it (I didn't rebuild it from sources). I'm trying to > get the example DLL from /python/PC/example_nt to work using Visual > C++ 6.0, and I get this error using the example right out of the box, > without modification, as described in the readme. > > Anybody knows what's going on? > > I'm very experienced with Windows, C, C++, and Visual C++, but I'm a > Python and DLL newbie. Any help will be greatly appreciated. > > Thanks, > > -- Ed > > > From aahz at netcom.com Tue Jul 18 10:16:16 2000 From: aahz at netcom.com (Aahz Maruch) Date: 18 Jul 2000 14:16:16 GMT Subject: Does Python support interfaces? References: Message-ID: <8l1org$a94$1@nntp9.atl.mindspring.net> In article , Randall Parker wrote: > >I'm quite new to Python. For those who are familiar with Java interfaces: >Does Python have a similar facility? > >Can one declare interfaces, then declare that a class implements some >interface, instantiate an object of that class type, and then cast it to >an interface that it is declared to support and then pass it around as a >reference to that interface type and make calls to methods of that >interface type? Let me expand on Justin's post: Interfaces are *everything* in Python; you use inheritance only when you want to borrow behavior from an existing class. If I create a base class called MyFileType and implemented all the standard methods and attributes, Python would literally not notice that I was using a brand new class as a file object. All the standard Python operations would just work. No casting, no subclassing. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From ajsiegel at my-deja.com Tue Jul 25 13:31:27 2000 From: ajsiegel at my-deja.com (ajsiegel at my-deja.com) Date: Tue, 25 Jul 2000 17:31:27 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <8lhij5$278$1@slb2.atl.mindspring.net> <8lhmgd$p92$1@nnrp1.deja.com> <8lhtht$v1e$1@nnrp1.deja.com> <8lk5t6$jb2$1@nnrp1.deja.com> Message-ID: <8lkitg$u21$1@nnrp1.deja.com> In article <8lk5t6$jb2$1 at nnrp1.deja.com>, Andy Freeman wrote: > Here's the conversation. > -snip- > The challenger has to be better on a number of dimensions and can > only be worse on trivial details - otherwise the incumbent wins. > ("No one else here knows the language" is a very powerful argument > in a world where staffing is so difficult.) > I'm sure you are describing a reality. More people will know Python when more people are making a living at it. So its a bit of a dog chasing its tail. That Guido and other "founders" (the ActiveState guys) have had to scramble a bit (it seems) to make a living with Python is on one hand disconcerting. The fact that they seem to be getting there is hopeful. But as the world turns, so that when you are VP and insisting on using Python and there's a new fokochta (pardon my Yiddish)language someone in your department is crying for - maybe they'll be right, too (but don't give in). Sent via Deja.com http://www.deja.com/ Before you buy. From MarkH at ActiveState.com Tue Jul 4 02:05:22 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 04 Jul 2000 06:05:22 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> <39642dc0.16230059@news.btx.dtag.de> Message-ID: "Stefan Franke" wrote in message news:39642dc0.16230059 at news.btx.dtag.de... > On Mon, 03 Jul 2000 23:22:38 GMT, "Mark Hammond" wrote: > >A framework for calling arbitary vtable interfaces is also in place. > I would *really* appreciate such a thing. Any pointers? The extension is called "univgw" - for "Universal Gateway". Greg Stein started the work, and Bill Tutt has done the most recent round. The sources, including the MSVC project file can be found under CVS. The win32com developers list archives are probably a good source, too: http://mailman.pythonpros.com/mailman/listinfo/pycom-dev Further discussion is welcome on that list! Mark. From grey at despair.rpglink.com Sat Jul 29 18:17:10 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 22:17:10 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: On 29 Jul 2000 20:09:46 +1200, Paul Foley wrote: >Not in the world I live in! If I put a slice of pizza in my coffee cup, >it doesn't magically turn into coffee...just makes a mess. Of course not, pizza is not data. Data has this lovely property that pizza doesn't have, it doesn't really exist. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From chibaA at TinterlogD.Tcom Tue Jul 4 21:53:38 2000 From: chibaA at TinterlogD.Tcom (chibaA at TinterlogD.Tcom) Date: Wed, 05 Jul 2000 01:53:38 GMT Subject: regex's References: <39627fa7.705005544@news1.on.sympatico.ca> Message-ID: <396294ff.710469961@news1.on.sympatico.ca> Perfect! Thanks muchly! kc On Wed, 05 Jul 2000 01:47:49 GMT, Tim Hochberg wrote: >chibaA at TinterlogD.Tcom writes: > >> Hi... I'm having a bit of a brain-tease... I have the following code >> (example): >> >> import re >> >> str = '123' >> if re.compile('1').match(str): >> print "matched 1" >> if re.compile('2').match(str): >> print "matched 2" >> if re.compile('3').match(str): >> print "matched 3" >> >> ------------------- >> >> I would think that this code would print 'matched 1 matched 2 matched >> 3'... But in this case, it would only printed "matched 1". Any >> reasons? Is there any way to have it print all three (since the >> conditions seem to be true)? > >re.match matches from the beginning of the string (e.g., >re.compile('2').match(str) will only match strings starting with >'2'. What you want is re.search. For example: > >#.... >if re.compile('2').search(str): > # ... > >You could also use: > >#.... >if re.search('2', str): > # ... > >However, the former will be faster if you reuse the regular >expression since you can compile it once and reuse the compiled >version. > > >-tim > >> Thanks in advance! >> >> kc. > From theebh at yahoo.com Tue Jul 25 09:55:33 2000 From: theebh at yahoo.com (Jonathan) Date: Tue, 25 Jul 2000 13:55:33 GMT Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: <8lk68h$jnt$1@nnrp1.deja.com> In article , scarblac-rt at pino.selwerd.nl wrote: > Python isn't weird - it's much more consistent than you think :-) > > Jonathan wrote in comp.lang.python: > > 1. There are no keywords to declare static or instance variables; it > > all depends where they are placed(whether it's right after the > > statement, or inside a ). > > This isn't really true. A class variable is declared directly inside > the class definition, or outside of it if you use the name of the class > (to set variable x in class Example, use Example.x = 3). > > Instance variables are *always* made by saying which instance it is, > ie self.x = 3. > > Example: > > class Example: > y = 3 # Directly in the class def, so a class variable > > def __init__(self, x): > self.x = x # Set the instance variable - need to use "self." > y = 3 # Just a local variable, neither class nor instance > > Example.y = 4 # Sets the class variable > self.__class__.y = 4 # Actually works better, because of inheritance and > # some other things. This looks up the instance's class > # in the instance, and sets the class variable. > z = 3 # Another class variable, no need to place them right after the > # class statement > > So unless it's directly in the class definition, you always need to say > explicitly which one you want to set. > > > Isn't it harder for other programmers to > > know at one glance what type of attributes the class define? > > As long as you define all of them directly in the class definition > (and not *only* through a method) you can see it at a glance. And you > put it in your documentation, of course (doc string). > > > 2. No *formal* declaration of static class methods, e.g. no 'static' > > keyword (though i'm not sure how useful static methods are in OOP > > design). I read somewhere in this newsgroup that the workaround way is > > to define the method outside of the class - doesn't it break > > the 'encapsulation' a class suppose to have? > > Maybe, but as you notice yourself, you don't know how useful these static > methods are - if they aren't bound directly to an instance of the class, > maybe they shouldn't be in the class in the first place? There are probably > counter examples, but I can't think of one right away. > > > 3. No keywords to differentiate between passing arguments by reference > > or value! An integer is passed by value(reference to a new copy), while > > a mutable object is by reference. To pass a list by 'value', i know you > > just need to insert one more line(list = [:]), but it seems > > so 'inconsistent' compared to Java or even PHP. > > No no no - *everything* is passed by reference, including that integer. > It's just that you can't change integers (they are immutable - why would > you want to change the integer 4?), so that if you assign to such a variable, > it refers to a new integer (actually, *assignment* is always by reference > as well - that's different from other languages). > > Try this: > > x = 4 > > def test(y): > if x is y: > print "x is the same reference as y!" > y = 3 > if not (x is y): > print "but now they're a different reference!" > > test(x) > > ("is" checks for reference identity). > Thanks for your posting. i feel much enlightened now:) I guess it's the fact that arguments(and assignments) are passed by reference in python, (which is not the default in the languages that i learned so far), and the 'flexibility' of declaring OOP constructs that cause the 'discomfort' in me. Anyway, i just parted with some of my hard-earned money to get a copy of EPR(Essential Python Ref) thru an online bookstore. Hope it will be useful!:) regards, jonathan Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Sat Jul 1 23:19:26 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 2 Jul 2000 03:19:26 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 1st, 2000 Message-ID: <20000702031926.7937.qmail@synop.com> Greetings All! Below are the latest entries to be entered into http://python.faqts.com regards, Fiona Czuczman ## New Entries ################################################# ------------------------------------------------------------- What is bbox? In the context of the PhotoImage put(data, bbox). http://www.faqts.com/knowledge-base/view.phtml/aid/4133 ------------------------------------------------------------- Fiona Czuczman Keith Murphy The bounding box is returned as a 4-tuple defining the left, upper, right, and lower pixel coordinate. Here's what I was doing.. self.photo.put(tuple(["#000000"],), tuple([5,5,6,6])) it draws a single black pixel at (5,5) ------------------------------------------------------------- How do you print the traceback string from an exception? http://www.faqts.com/knowledge-base/view.phtml/aid/4134 ------------------------------------------------------------- Fiona Czuczman J?rgen Hermann try: whatever() except: import traceback, string msg = string.join(traceback.format_exception( sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]), "") print msg ------------------------------------------------------------- How can I concatenate external files (all the little *.htm files in a directory) into one big file? http://www.faqts.com/knowledge-base/view.phtml/aid/4135 ------------------------------------------------------------- Fiona Czuczman richard_chamberlain import sys, string, glob, os #First I create a list: fls = glob.glob('C:\\wxpython\\wxPython-2.1.16\\docs\\wx\\wx*.htm') #Then I guess I should open an output file for writing outfile = open('temp.txt,'w') for x in fls: file=open(x,'r') data=file.read() file.close() outfile.write(data) outfile.close() We then iterate over fls to give us each file name and open each one. We then call the read method against it, which loads in the entire file and assign that to data. we close the file and write the data to our outfile. And then on to the next file. Finally we close the outfile. You have to use read() with some caution because it (trys) to load the whole file into memory which maybe an issue if it was sizable. In your case it isn't an issue because they are simple html files. ------------------------------------------------------------- What is lambda? http://www.faqts.com/knowledge-base/view.phtml/aid/4136 ------------------------------------------------------------- Fiona Czuczman Warren Postma, david_ullrich 1) Meta-Answer: Read the FAQ and Manual sections. 2) Instant Gratification Answer Here's a standard function definition: def func(x): return x *2 Here's a way to write the same thing, in effect, but using Lambda: func = lambda (x): x * 2 While that example isn't useful, it gives you the idea. Think of lambda as a way to generate a function and return that function as an object, without having to give it a name. I primarily use it to pass an algorithm or expression as a parameter to a function, or other places where I want to pass code in a variable instead of passing a reference to a method containing that code. ------------ What it does is allow you to construct "anonymous functions". Oops, not my own words. The syntax lambda x: [expression in x] is itself an expression - the _value_ of the expression "lambda x: [expression in x]" is a function which returns [expression in x] when passed x. For example "lambda x: x+x" is a function that returns x+x; saying f = lambda x: x+x has the same effect as saying def f(x): return x + x But you don't usually use it that way - people use lambda when they want to pass a function to some routine without having to make up a name for the function. For example map takes a function as a parameter; saying print map(lambda x: x+x, [1,2,3]) is the same as saying def f(x): return x + x print map(f, [1,2,3]]) You should note there's varying opinions on whether lambda is a good thing - if you're a beginner at programming as well as with Python it's not the first thing you should worry about. ## Edited Entries ############################################## ------------------------------------------------------------- How can I use the smtplib module to send email from Python? How can I send mail using the os module? How can I send mail through python? http://www.faqts.com/knowledge-base/view.phtml/aid/2607 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman, George Jansen http://www.python.org/doc/FAQ.html#4.71,Justin Sheehy On Unix, it's very simple, using sendmail. The location of the sendmail program varies between systems; sometimes it is /usr/lib/sendmail, sometime /usr/sbin/sendmail. The sendmail manual page will help you out. Here's some sample code: SENDMAIL = "/usr/sbin/sendmail" # sendmail location import os p = os.popen("%s -t" % SENDMAIL, "w") p.write("To: cary at ratatosk.org\n") p.write("Subject: test\n") p.write("\n") # blank line separating headers from body p.write("Some text\n") p.write("some more text\n") sts = p.close() if sts != 0: print "Sendmail exit status", sts Check out the os module doc for more info: http://www.python.org/doc/current/lib/module-os.html On non-Unix systems (and on Unix systems too, of course!), you can use SMTP to send mail to a nearby mail server. A library for SMTP (smtplib.py) is included in Python 1.5.1; in 1.5.2 it will be documented and extended. Here's a very simple interactive mail sender that uses it: import sys, smtplib fromaddr = raw_input("From: ") toaddrs = string.splitfields(raw_input("To: "), ',') print "Enter message, end with ^D:" msg = '' while 1: line = sys.stdin.readline() if not line: break msg = msg + line # The actual mail send server = smtplib.SMTP('localhost') server.sendmail(fromaddr, toaddrs, msg) server.quit() This method will work on any host that supports an SMTP listener; otherwise, you will have to ask the user for a host. http://www.python.org/doc/current/lib/module-smtplib.html On Windows 9x systems, you may also use the COM interface. We have recently used PythonWin to (what else?) spam a number of recipients over Novell GroupWise. It took very little time to work this out. From tttok_2000 at yahoo.com Tue Jul 11 01:45:22 2000 From: tttok_2000 at yahoo.com (Ahmed Ahmed) Date: Mon, 10 Jul 2000 22:45:22 -0700 (PDT) Subject: Compiling Python Message-ID: <20000711054522.28720.qmail@web3406.mail.yahoo.com> Look here http://www.faqts.com/knowledge-base/view.phtml/aid/3111/fid/244/lang/ --- "David L. Heald Jr." wrote: > Yeah, the latter. I like Python, but I'm interested > in taking my programs > with me to other computers that don't have python. > "Dennis Lee Bieber" wrote in > message > news:9m5lms0bt9fhiir6c2vju9ti4hvvv473kb at 4ax.com... > > On Mon, 10 Jul 2000 21:29:09 GMT, "David L. Heald > Jr." > > declaimed the following in > comp.lang.python: > > > > > Does anyone know if there is a compiler > available anywhere for python > for > > > win32? > > > > > Pardon? > > > > A compiler with which to build Python from source, > or > > > > A compiler which builds native executables from > Python programs? > > > > > > For the latter, I don't think one exists on any > platform -- > > freeze may be the closest equivalent (as I recall, > not having used it, > > it embeds Python byte-code into a binary with the > Python interpreter). > > > > For the former... I think folks are working on > getting the > > downloadable Borland C to compile it, the M$ VC > should handle it with no > > problems, and gcc probably can manage it. > > > > -- > > > > ============================================================== > < > > > wlfraed at ix.netcom.com | Wulfraed Dennis Lee > Bieber KD6MOG < > > > wulfraed at dm.net | Bestiaria > Support Staff < > > > > ============================================================== > < > > > Bestiaria Home Page: > http://www.beastie.dm.net/ < > > > Home Page: > http://www.dm.net/~wulfraed/ < > > > -- > http://www.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From nospam at buzzoff.com Thu Jul 20 07:36:46 2000 From: nospam at buzzoff.com (Moritz Voss) Date: Thu, 20 Jul 2000 13:36:46 +0200 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l52hs$i05$1@kopp.stud.ntnu.no> Message-ID: <8l6o55$7qb$1@fermi.tro.net> "Will Ware" schrieb im Newsbeitrag news:FxzACB.KEB at world.std.com... > > What exactly *are* these advantages? (Very curious...) > > simultaneously, and rapidly switch between them. This could be useful > in a game if you want to model simultaneous behavior of a large number > of agents, such as soldiers in an army, ants in an anthill, airplanes I'd still queue that up! Because I'd have to maintain so much synchronization (collisions, etc, one object influencing another, accessing samme resources (be that a tank or something in memory), I'd just quickly runt through them all in a straightforward way. They have ALL to be done when the next frame will be drawn, so thread management will only produce more overhead....right? > http://world.std.com/~wware/uthread.html That brings up another question - how safe/restrictive is Python? I want to allow the user to implement own micro AI scripts. These will run on the serve ronly, though, and I want to prevent a) the server from crashing due to malicious or buggy python scripts b) the user from cheating (e.g. having that AI download huge tactical info over the net, or maybe a mapfile or something that lets it eval its situation better.) c) the unit from screwing things up, as intearction with othe runits is possible, but not ALL units. Other units can communicate with other ones, respectively. d) allow each AI script to only have a certian short period ooff processing time - making long scripts idle the unit longer while they work, while shiort scripts have far more throughput per runtime unit. I don't understadn the concept of python thisfar, and I am reconsidering my own virtual machine concept - yet I think that maybe too much work to implement in reasonable quality... :-( -- -- Moritz "Thygrrr" Voss Client-Server & OpenGL Coder spirit.link.studios - http://o2.ods.org From bjorn at roguewave.com Wed Jul 19 13:08:00 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 19 Jul 2000 11:08:00 -0600 Subject: zip or marry etc References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <8l4g5i$8$1@slb7.atl.mindspring.net> Message-ID: <3975E070.308511F4@roguewave.com> Aahz Maruch wrote: > > In article , > Olivier Dagenais wrote: > >How about: > > > >"twist", "merge", "smash", "glue", "dna", "ladder", "join", "match", > >"collect", "pick", "lineup"??? > > I like "merge". +1 from me too :-) -- bjorn From jclonts at mastnet.net Wed Jul 12 01:21:58 2000 From: jclonts at mastnet.net (John Clonts) Date: Wed, 12 Jul 2000 00:21:58 -0500 Subject: finding mount points References: Message-ID: <396C0076.4A6547A3@mastnet.net> Suchandra Thapa wrote: > > Is there any way to find the mount point of a filesystem given > the path to a file within the file system? Using os.path.ismount > lets you determine if a path is a mount point but is there any function > that returns something like /mnt/cdrom if you give it a path like > /mnt/cdrom/foo/bar.txt? > > -- > ------------------------------------------------------------------ > > Suchandra S. Thapa > s-thapa at uchicago.edu > > ------------------------------------------------------------------ Python 1.3 (Sep 10 1996) [GCC 2.7.2] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import posixpath >>> posixpath.ismount("/") 1 >>> posixpath.ismount("/mnt") 0 >>> posixpath.ismount("/mnt/dosd") 1 >>> posixpath.ismount("/home") 1 >>> posixpath.ismount("/home/john") 0 >>> Is this what you wanted? Cheers, John From claird at starbase.neosoft.com Fri Jul 28 12:10:47 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Jul 2000 11:10:47 -0500 Subject: best apache+python module? References: <20000728113918.B12152@inkontact.com.au> Message-ID: In article , Sam Penrose wrote: . . . >After having a Bad Experience with one of these (memory leak in >PyApache), I must ask why they are so popular. My company writes >pure-Python sites whose CGIs handle tens of thousands of hits a day on >unremarkable Intel hardware running vanilla Linux. Two of our CGIs have >started to bog down recently, and in both cases the cause is the same: >have to generate HTML pages roughly a meg in size; one containing so >many images that the number of Apache processes goes through the roof. >In neither case would faster Python performance help. > >Linking your interpreter to Apache forces you into dependence on a chunk >of code that has orders of magnitude less testing than either Apache or >Python does, probably wouldn't remove any bottlenecks if they existed, >and may well break the next time either Python or Apache is updated. > >Unless, of course, you know differently. But my sense is that most of >the people interested in these modules merely know they want their sites >to run fast and have read the mod_perl marketing materials. > >Anyone who can afford 256 megs of RAM and a SCSI hard drive can serve >thousands of people a day with sites that execute thousands of lines of >Python, without working particularly hard to optimize their software >(CGIs or Python or the OS). And if they find they can't, they should not >assume that a persistent Python executable will help without having good >reason to do so. . . . Sooooooooooooooo true. I hope a lot of people see your posting. As it turns out, I do a lot of work with these em- bedded extensions (mostly in languages other than Python, but with Python, also). My primary motiva- tion is at the software engineering level: I find "microscripting" (executable content embedded in HTML) far, far more pleasant in general to develop and maintain than CGI. The big performance gain I most often see from the mod_*-like embedded extensions has to do with per- sistent database connections. Saving the costs of building up and breaking *those* down can be a big win. Language stuff is an incidental. People have put a lot of energy into making Apache extensible, shaking down the mod_*()-s, and so on. I enjoy using them. I agree, though, that they need to be watched carefully. Memory leakiness is only one of the frailties to which they're prone. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rumjuggler at cryptarchy.org Sat Jul 29 00:02:31 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 04:02:31 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: <1vl4os8357de0humn8db0v30ejatjgcn48@4ax.com> On Fri, 28 Jul 2000 23:02:52 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: >On Fri, 28 Jul 2000 23:09:56 +0200, Alex Martelli wrote: >>I hope you remember that in Python there's no need for the joining >>and later re-splitting: just putting the pair (tuple) in there is >>so much easier and more natural. > > No. I am learning that. A plesant side effect of this excellent >discussion. > >>Among other things, it makes it easy to save/load/change a format-string; > > Nono, you misunderstand me. I prefer the Pascal notion of variables in >place in the string with formatting attached to it instead of placeholder >formatting strings with the variables hanging off the end of the string. >Pseudo code from no language, bear with me. > >"Here is a string with ",$a:d:0:0," variable in it." > >"Here is a string with %d:0:0 variable in it.",$a > > In the former I read and I see, "Oh, $a goes here with this formatting" >whereas in the latter it is "Oh, here is the formatting for... uhm.. $a." > > Again, simplistic and not in any language, but taken to the extreme you >can see the problem. > >"%d:0:0 %c:U %s %s %s %s %d %s %s %s \ >%d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k > > What variable goes with what again? Hmmm... An example of why I think I would prefer format strings over in-place variables is that format strings seem more powerful to me. the code below seems like a rather clear and easy way of doing something which would be more difficult using in-place variables. return '%r, %s%s ' % (self.name, self.firstline, ', %s'*len(self.entries) \ % tuple(map(None, namestofields[self.name][FIELDS], self.entries))) -- Barnabas T. Rumjuggler My pants! They have come To rescue me! No, it is Only a squirrel. -- Not Zelgadis, not on ark From ejr at lotus.CS.Berkeley.EDU Sun Jul 23 13:30:37 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 23 Jul 2000 17:30:37 GMT Subject: Discussion: new operators for numerical computation References: <8lb6jb$vj9$1@slb6.atl.mindspring.net> <397A919F.331C3933@prescod.net> Message-ID: <8lfa3t$mau$1@agate.berkeley.edu> And Paul Prescod writes: - - Neel, I think you have projected your own wishes onto that of the - matrix people! Perhaps, but a common complaint I hear about any language is ``the lack of general overloading.'' After translation into programming linguistic speak, that translates into multiple dispatch. It's hard to implement methods that work across and between members of the number hierarchy without it. You invariably end up with something nasty like the `bridge' pattern or explicit type checks (``layered visitors'' or some such name). At that point, your code becomes less about the numerics and more about the little nooks and crannies of a given language. That's bad, imho. What's worse, some of us want to dispatch on the _returned_ type, too. Really helps you pick the right precision in which you calculate intermediate results, but it feels semantically messy. Haven't put enough thought into that one yet. It could be solvable just with type inferencing within expressions. But this is comp.lang.python, not comp.lang.dylan. I still can't help but feel that Dylan is to Python as Smalltalk is to Java. Jason From hinsen at cnrs-orleans.fr Thu Jul 20 05:12:44 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 20 Jul 2000 11:12:44 +0200 Subject: Discussion: new operators for numerical computation References: Message-ID: Huaiyu Zhu writes: > Here's a list of issues that come to mind: > > 1. What symbols to use. > > It seems that we can more or less concentrate on using either . or @ > together with existing math operators. Issues: There might be more options in the not too far future. With the general move towards Unicode, a Python interpreter that takes Unicode input files does not seem unreasonable. This would give access to plenty of new symbols which 1) do not cause any clashes with existing syntax 2) look like symbols used in paper-based math If I remember correctly, the APL symbol set is somewhere in Unicode. I agree that this proposal is not a realistic one for the immediate future, but I still like it ;-) > (1) Use . or @ For purely esthetic reasons, I wouldn't want to have @ in operators. The dot is fine but there are conflicts with floating point constants. But there are other alternatives. How about operators in parentheses? a (*) b looks fine to me, and it is currently illegal so it can't cause compatibility problems. I'd even claim that it somewhat *looks* like a matrix operation. One could take this a step further and introduce operator composition, like in APL. In APL, the inner product (of which the matrix product and the vector dot product are special cases) is written +.x (with a special multiplication operator that is not the same as the letter x). This means elementwise multiplication followed by reduction with plus. Other binary operators can be substituted, and some such combinations are quite useful. So we could introduce "operator expressions" like (+.*) for inner product, and then leave (*) for the outer product, with * remaining the elementwise product, as in NumPy. (/) could be matrix "division", or inversion when used as a unary operator. There should be plenty of combinations to make everyone happy. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From theebh at yahoo.com.bbs Mon Jul 17 21:50:02 2000 From: theebh at yahoo.com.bbs (theebh at yahoo.com.bbs) Date: 18 Jul 2000 01:50:02 GMT Subject: newbie unimpressed... Message-ID: <3bRWfQ$lHg@openbazaar.net> In article <8kvp81$9q1$1 at nnrp1.deja.com>, sharkey3 at my-deja.com wrote: > I have much experience in tcl and perl, and I have finally found a good > project to learn python with. Unfortunately, I am very frustrated so > far with the language. Although maybe it's just with the documentation. > > I'm serious. The documentation really sucks. > Example: where is the % operator documented for strings? > I'm a newbie myself and i happen to come across those formatting operators while reading the "Learning Python" book. Grab a copy of it; though it's not a reference book, at least it gives you an overall idea. regards, Sent via Deja.com http://www.deja.com/ Before you buy. From montagne at boora.com Mon Jul 3 17:51:04 2000 From: montagne at boora.com (michael montagne) Date: Mon, 3 Jul 2000 14:51:04 -0700 Subject: Python Object Browser Message-ID: I'm trying to use makepy on some common objects on my system. Word2000, Excel2000, etc. It doesn't seem to want ot work. When I go to the objects that are having trouble using the Python Object Browser, under the Type Library heading it says "The type info can n..="The type info can not be loaded". Does this mean it is unavailable? How do i fix this? -mjm From mmorris at mindspring.com Mon Jul 24 14:09:26 2000 From: mmorris at mindspring.com (Mitchell Morris) Date: 24 Jul 2000 18:09:26 GMT Subject: Test framework of choice? Message-ID: <8F7B7D888beablebeable@209.155.56.81> In the course of finding a reasonably standard-ish test framework, I found a curiousity: reports three separate implementations for Python. It appears from my cursory reading that either Bob Martin's OmPyUnit or Stephen Purcell's pyunit would be the preferred mechanism, but I can't be sure. My kneejerk reaction is to use pyunit merely because it's hosted at SourceForge, but I'm not at all sure that software should be blessed merely because of who hosts the CVS tree. Is there any consensus, emerging or otherwise, as to which is more likely to survive any putative consolidation efforts? Is either of them going to be included in the core Python distribution? Are there any plans to include any kind of regression testing framework into the standard distribution? +Mitchell From rgparker at west.net Mon Jul 17 21:08:03 2000 From: rgparker at west.net (Randall Parker) Date: Tue, 18 Jul 2000 01:08:03 GMT Subject: Does Python support interfaces? Message-ID: I'm quite new to Python. For those who are familiar with Java interfaces: Does Python have a similar facility? Can one declare interfaces, then declare that a class implements some interface, instantiate an object of that class type, and then cast it to an interface that it is declared to support and then pass it around as a reference to that interface type and make calls to methods of that interface type? From SBrunning at trisystems.co.uk Tue Jul 18 11:07:09 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 18 Jul 2000 16:07:09 +0100 Subject: Locating Python modules Message-ID: <31575A892FF6D1118F5800600846864D4C706A@intrepid> I'd like to organise the Python modules that I have downloaded in some rational fashion. Ideally, I'd like a directory to keep them all in, with each in a separate sub-directory. I don't want to keep all these directories in my PYTHONPATH. Is there some de-facto standard way of organising this? If not, what methods of organisation do people use, and what are the pros and cons of the various methods? 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 rwgkNOrwSPAM at cci.lbl.gov.invalid Thu Jul 6 15:20:30 2000 From: rwgkNOrwSPAM at cci.lbl.gov.invalid (rwgk) Date: Thu, 06 Jul 2000 12:20:30 -0700 Subject: extension module performance problems Message-ID: <115675da.97c91c5a@usw-ex0103-023.remarq.com> I wrote a tiny shared library (.so) extension module for tokenizing input files. Unfortunately this implementation ran only marginally faster than a pure-Python solution. I did some profiling on a Silicon Graphics (IRIX 6.5) and noticed that significant time is spent in the pthreads library although there is only one thread. Therefore I recompiled python (1.5.2) without threading, and the program ran about three times faster. In contrast, the runtime on a Compaq Alpha (Tru64 5.0) is not affected by the inclusion of pthreads. However, my test runs about four times faster if the extension module is linked statically. Here is the summary of CPU times: no threads with threads static .so static .so Alpha 0.6 2.4 2.4 2.4 SGI 0.83 0.83 2.19 2.25 Can these observations be explained? Is there a way to get full performance under all circumstances? The python bit of the test program is attached. Thanks! Ralf import sys import _cnsinput if (len(sys.argv) < 2): f = sys.stdin else: f = open(sys.argv[1], 'r') try: io = _cnsinput.start(f) gNW = io.getNextWord while 1: word = gNW() # this line is executed 69768 times except EOFError: print 'end of file' f.close() ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From tanzer at swing.co.at Sun Jul 23 03:56:08 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Sun, 23 Jul 2000 09:56:08 +0200 Subject: New PEP: Attribute Access Handlers In-Reply-To: Your message of "Fri, 21 Jul 2000 23:11:56 CDT." <39791F0C.CDC13E79@prescod.net> Message-ID: > Paul Prescod wrote: > > http://python.sourceforge.net/peps/pep-0213.html > > PEP: 213 > Title: Attribute Access Handlers > Version: $Revision: 1.3 $ > Owner: paul at prescod.net (Paul Prescod) > Python-Version: 2.0 > Status: Incomplete (snip) > Current Solution > > To make some attributes read-only: > > class foo: > def __setattr__( self, name, val ): > if name=="readonlyattr": > raise TypeError > elif name=="readonlyattr2": > raise TypeError > ... > else: > self.__dict__["name"]=val > > This has the following problems: > > 1. The creator of the method must be intimately aware of whether > somewhere else in the class hiearchy __setattr__ has also been > trapped for any particular purpose. If so, she must specifically > call that method rather than assigning to the dictionary. There > are many different reasons to overload __setattr__ so there is a > decent potential for clashes. For instance object database > implementations often overload setattr for an entirely unrelated > purpose. > > 2. The string-based switch statement forces all attribute handlers > to be specified in one place in the code. They may then dispatch > to task-specific methods (for modularity) but this could cause > performance problems. > > 3. Logic for the setting, getting and deleting must live in > __getattr__, __setattr__ and __delattr__. Once again, this can > be mitigated through an extra level of method call but this is > inefficient. > > Proposed Syntax > > Special methods should declare themselves with definitions of the > following form: > > class x: > def __attr_XXX__(self, op, val ): > if op=="get": > return someComputedValue(self.internal) > elif op=="set": > self.internal=someComputedValue(val) > elif op=="del": > del self.internal (snip) I agree that 1. and 2. are sometimes problems, but IMHO point 3. is a good thing, not a problem. In general, get/set/del are not related. For instance: $ dir ~/ttt/ttptools/*/*.py | wc -l 426 $ grep ' def __setattr__' ~/ttt/ttptools/*/*.py | wc -l 5 $ grep ' def __getattr__' ~/ttt/ttptools/*/*.py | wc -l 44 $ grep ' def __delattr__' ~/ttt/ttptools/*/*.py | wc -l 0 In short, folding get/set/del into one function sucks. Besides, it doesn't really help when you want to overload just get, but would like to keep the set/del of the ancestor. To disentangle the accessors of different attributes, I would suggest to use a dictionary of attribute-specific accessor functions. For instance: class Foo : def _set_bar (self, name, value) : ... def _set_baz (self, name, value) : ... def _dont_set (self, name, value) : raise Readonly_Attribute, name __attr_setters__ = { "bar" : _set_bar , "baz" : _set_baz , "ro1" : _dont_set , "ro2" : _dont_set } def __setattr__ (self, name, value): if self.__attr_setters__.has_key (name) : self.__attr_setters__ [name] (self, name, value) else : ... class Bar (Foo) : def _set_baz (self, name, value) : ... def dict (* dicts, ** kw) : result = {} for d in dicts + (kw, ) : result.update (d) return result class Baz (Bar) : __attr_setters__ = dict (Bar.__attr_setters__, baz = Bar._dont_set) This tackles problem 1 and half of problem 2. If the performance side of problem 2 is really an issue, move the checking of `__attr_setters__/__attr_getters__/__attr_deleters__' from `__setattr__/__getattr__/__delattr__' into the interpreter (other names for the magic dictionaries might be useful then). -- 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 mwh21 at cam.ac.uk Thu Jul 27 17:57:14 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 Jul 2000 22:57:14 +0100 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <8lq20g$kt1$1@nntp9.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > [posted & e-mailed] > > In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, > Guido van Rossum wrote: > > > >I've placed the slides of my talk at the O'Reilly Open Source > >Convention on-line at our BeOpen PythonLabs website: > > > > http://www.pythonlabs.com/talks.html > > It appears that the HTML version requires JavaScript. That's a Bad Idea. And it just sucks generally. Non-resizable frames? Oh, pull the other one! But then what did you expect from Powerpoint? still-better-than-nowt-ly y'rs Michael -- Ya, ya, ya, except ... if I were built out of KSR chips, I'd be running at 25 or 50 MHz, and would be wrong about ALMOST EVERYTHING almost ALL THE TIME just due to being a computer! -- Tim Peters, 30 Apr 97 From erno at iki.fi Wed Jul 26 17:06:12 2000 From: erno at iki.fi (Erno Kuusela) Date: 27 Jul 2000 00:06:12 +0300 Subject: Reading PCI Configuration Space... References: Message-ID: >>>>> "Jerome" == Jerome Chan writes: Jerome> Does anyone know how to read the PCI configuration space Jerome> with Python under Win 98 or Linux? under linux you have 3 options: * use the lspci program. try lspci -x or lspci -vvv * read the files under /proc/bus/pci/ (this is actually what the lspci program does, but using lspci might save you from future format changes in these files...) * read /proc/pci do this if you are using an older version of linux (2.0.x) no idea about win98... -- erno From jam at quark.emich.edu Fri Jul 21 20:16:00 2000 From: jam at quark.emich.edu (Jeff) Date: Fri, 21 Jul 2000 20:16:00 -0400 Subject: python 'hphack' - change display of HP printer Message-ID: <20000721201600.A15355@quark.emich.edu> greetings, here's a (very) quick script I wrote based on code posted to freshmeat (http://freshmeat.net/appindex/2000/06/22/961716715.html) all it does is change the display of an HP laserjet printer from "Ready" to 16 characters of your choosing. it shows the basics of socket calls in python (vs. the C version), and is very short. if anyone has suggestions as to how the code could be improved, please mail them to me directly or post to the list. I hereby release this version of the code as GPL. -- begin -- #!/usr/bin/env python import sys import getopt import socket _RCSID = "$Id: hphack.py,v 1.1 2000/06/25 13:36:59 jam Exp $" # http://cssweb.nectech.com/printers/pclcodes/pcl5hp.htm # http://freshmeat.net/appindex/2000/06/22/961716715.html UEL = chr(0x1B)+chr(0x25)+chr(0x2D)+chr(0x31)+chr(0x32)+chr(0x33)+chr(0x34)+chr(0x35)+chr(0x58) def help(): pass def version(): print _RCSID def main(): opts, sopts = getopt.getopt(sys.argv[1:], "", [ "help", "version" ]) for n, v in opts: if n == "--help": help() return elif n == "--version": version() return if len(sopts) != 2: print "takes two parameters: ipaddress and message." return dest = sopts[0] message = sopts[1] s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(dest, 9100) buf = UEL + '@PJL RDYMSG DISPLAY = "%s"\n' % (message) + UEL + "\n" s.send(buf) s.close() if __name__ == "__main__": main() -- end -- regards, J -- || visit gfd || psa member -- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From gmcm at hypernet.com Mon Jul 10 15:19:34 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 10 Jul 2000 19:19:34 GMT Subject: Dummies guide to freeze/standalone? References: <8kcmv4$uqo$1@nnrp2.deja.com> Message-ID: <8F6D90442gmcmhypernetcom@199.171.54.154> level2junkie at my-deja.com wrote in <8kcmv4$uqo$1 at nnrp2.deja.com>: >Can someone out there give me a direct answer on >how to freeze a block of python script files? >I've written a program that spans several files, >but I can't seem to figure out how to package >them. I'd like to be able to run this program on >a machine that doesn't have python installed on >it, otherwise what's the point? Has anyone out >there figured out how to do this? If so can you >please help me? That might depend on how you managed to write a program that "spans several script files". In the normal case, there's one script which imports other modules. Then >python \Freeze.py <% PERFORM VARYING FONT-SIZE FROM 1 BY 1 UNTIL FONT-SIZE > 7 %> Hello COBOL world!
<% END-PERFORM. %> Neil From max at alcyone.com Fri Jul 28 20:37:43 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 28 Jul 2000 17:37:43 -0700 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: <39822757.A5803B9B@alcyone.com> Steve Lamb wrote: > Mmmm, in as far as I can read that, yes. It is the operation that > determines the type of the data, not the data in and of itself. Not in a strongly typed language like Python, it doesn't. -- 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 completely overcomes only what one assimilates. \__/ Andre Gide Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From breiter at usf.Uni-Osnabrueck.DE Mon Jul 17 06:05:55 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 17 Jul 2000 10:05:55 GMT Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython References: <39700FD0.3C368827@ruf.uni-freiburg.de> <39779151.1066402235@news.online.no> Message-ID: <8kulq3$lro$1@newsserver.rrzn.uni-hannover.de> There is a free software wxPython GUI builder: Boa-Constructor. http://sourceforge.net/project/?group_id=1909 http://boa-constructor.sourceforge.net/ wxDesigner is not free software it is not only commercial but proprietory. So it is not the way to go. I supported Mark Hammond with pythonwin, because he wrote free software. I cannot support wxDesigner. We should help making Boa-Constructor even better. (For the people into it, the CVS version was finally updated. Work on the 0.0.4 release is going on. Do not let the low version number fool you.) Bernhard In article <39779151.1066402235 at news.online.no>, thomas at cintra.no (Thomas Weholt) writes: > This is just what Python needs; helper for GUI programming. A single > user licence costs $69 if I remember correctly, which is probably ok, > at least for commercial purposes. ( Nowhere near PythonWorks insane > price-tag ) > > It would, of course, be better if it was free, > On Sat, 15 Jul 2000 09:16:32 +0200, Robert Roebling > wrote: >>[I am using this list, since the python-announce list is no >> longer functional.] >> >>I would like to announce wxDesigner 1.0, a commercial program >>that can be used in connection with the free C++ GUI wxWindows >>library and its populare Python bindings called wxPython. -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From webmaster at in852.com Thu Jul 6 12:46:04 2000 From: webmaster at in852.com (webmaster) Date: Fri, 07 Jul 2000 00:46:04 +0800 Subject: in852.com - 5 Message-ID: <3964B7CC.EA985951@in852.com> [ ???? ] ?T???????? http://www.in852.com ?????T???? http://www.ec852.com in852?S?I?G (1) ???????P???~?e???|?? (Printers?BScanner?B?q???C??????)?C (2) ???W???I?j???? ?]?A???????????~?B???s?q?????~?B?y?????~?????C (3) ?????? Free Mail ?u?n?|???? POP ?? SMTP ???? mail.in852.com?A?K?i?????q Mail Box (4) ???I???e ?T???????y???T?B???g?@???B?C?????a?B???????T?B?q?????? ?n???U?????@?????????????????T?s?????C From olivierS.dagenaisP at canadaA.comM Wed Jul 19 20:51:20 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Thu, 20 Jul 2000 00:51:20 GMT Subject: iterating over lines in a file References: Message-ID: You can get rid of the initial read if you have a function that returns true/false and one of the parameters is passed by reference to be the actual item. I'm not sure Python does by-reference arguments, though... For example (I'm not sure this works, think of it as a pseudo-example...): def enumerate ( retval ): if outOfElements(): return 0 else: retval = nextElement() return 1 Then you call it like so: while enumerate ( currentValue ): print currentValue -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Roger Upole" wrote in message news:hMrd5.49275$e6.2860918 at pouncer.easynews.com... > Using an initial read is a common enough idiom in any language. > > f=open('filename','r') > fline = f.readline() > while fline: > .... > fline = f.readline() > > Roger Upole > > "nobody" wrote in message > news:Uvqd5.21615$DZ4.69024 at news.corecomm.net... > > assume i want to iterate a block of code over every line in a text file, > > and that i don't want to snarf the whole thing into memory for fear > > of coredumps or whatever. in perl (and many others) there is a simple, > > common idiom: > > > > while (line = ) { block; } > > > > this doesn't seem to have a simple, direct analog in python. searching > > around on the web i found a solution at faqts.com (though this newbie > > might like to see it explained, but whatever works): > > > > class Reader: > > def __init__(self, source): > > self.source = source > > def readline(self): > > line = self.source.readline() > > self.line = line > > return line # may be empty, thus false > > > > file = Reader(open("filename")) # i might have got this worng...? > > > > while (file.readline()): > > line = file.line > > > > now, this seems to me like an awful lot of typing just to get around > > the fact that assignments in python do not seem to be expressions > > returning the value assigned. since that is thus in several other > > languages, and since it gives rise to several common idioms of this > > type, i can only assume that there must be some good reason for > > breaking this pattern in python; i just can't see what it could > > possibly be. > > > > could somebody enlighten me, please? and is there any easier way to > > iterate over lines in a file without resorting to ugly break statements? > > > > From jtoy at tcgfinancial.com Thu Jul 27 08:41:55 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Thu, 27 Jul 2000 08:41:55 -0400 Subject: Perl is worse! (was: Python is Wierd!) References: <8losor$4bk$1@nnrp1.deja.com> <3982fb07.279274515@news.online.no> Message-ID: <39802E13.BF26EF5C@tcgfinancial.com> One reason that perl is popular among hacker types is because after you get over the huge learning curve of perl, you can write some damaging code on your target's machines and you can write it in a way that only the writer can read it, which is actually pretty cool. BTW, I use python. Thomas Weholt wrote: > On reason for letting people use Perl in Zope is that Perl is by far > the most used script-language for CGI. By opening for Perl Zope will > have a potentially larger user-group and get acceptance faster. > > Anyway, python still rules, and I hope they could support more > python-like scripting inside pages, like PHP, ASP etc. > > Thomas > > On Thu, 27 Jul 2000 08:44:12 GMT, Jonathan wrote: > > >Just finished putting down the 'Learning Python' book and tried some of > >the examples. Somehow i happened to have the itch of grabbing > >my 'Programming PERL' book and browse through it again to have a > >comparison(it was a long time since i last used PERL, after i picked up > >PHP). Looking at the Modules, Packages and Classes chapter, and - oh my > >god - the whole thing now looks like a mess! I don't think i will ever > >bother using PERL again (unless it's a 5-10 lines kind of thing). > >Python's syntax now seem much 'cleaner' and intuitive. But then i guess > >you all shld have known this by now:) > > > >But the irony now is that ZOPE will be 'opened' to PERL too. I have > >read through the 'debates' going on in the zope mailing list, but it > >still doesn't make sense - why allow Zope to be polluted by something > >that is clearly deficient? It's like allowing people to use sand > >instead of cement to build a house. (I haven't mastered Zope yet, so i > >will restrain from commenting any further) > > > >regards, > >jonathan > > > > > >Sent via Deja.com http://www.deja.com/ > >Before you buy. -- Jason Toy toyboy at toy.eyep.net jtoy at tcgfinancial.com http://toy.eyep.net From paul at prescod.net Mon Jul 17 14:08:52 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 13:08:52 -0500 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> <8kvdon$tit$1@slb3.atl.mindspring.net> Message-ID: <39734BB4.8C24B6E@prescod.net> "G. David Kuhlman" wrote: > > ... > > Now, I ask you, what other scripting language would enable me to > support that breadth of users? Incredible. IMHO, the ability to crawl into niches is the feature that makes Python's ascendency inevitable. Any particular "killer app" could die and the others will carry it forward. Any particular operating system could die and Python would thrive on the remaining ones. (in fact the (unlikely) death of Windows would drive VB programmers into Python's arms and the (equally unlikely) death of Unix would drive Perl users to Python) I think Python is a very safe bet, even compared to more established languages. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From kelley at bioreason.com Fri Jul 14 07:07:52 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 14 Jul 2000 12:07:52 +0100 Subject: Is pickle buggy? References: Message-ID: <396EF487.3174FA3D@bioreason.com> True enough but do you expect >>> "AAAAAA" to be garbage collected or not? eval('"AAAAA"') is doing exactly that. That is the behavior we are seeing so I don't think your example is valid in this case. For intern("AAAAA") it is because that is what intern does. But intern wasn't being called directly. Moshe Zadka wrote: > On Fri, 14 Jul 2000, Brian Kelley wrote: > > > I don't get that behavior on windowsNT. If I directly > > intern(uniquestring()) then memory gets eaten extremely fast, not on the > > order of hours but on the order of minutes. > > > > I'll let eval(`uniquestring()`) run for a while and see what happens. > > This program also eats memory quickly > > def do(l=[]): > l.append(1) > > while 1: > do() > > -- > Moshe Zadka > There is no GOD but Python, and HTTP is its prophet. > http://advogato.org/person/moshez -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From colinmeeks at home.com Thu Jul 27 15:22:16 2000 From: colinmeeks at home.com (Colin Meeks) Date: Thu, 27 Jul 2000 19:22:16 GMT Subject: PY to HTML Message-ID: Does anybody know anything that will enable me to convert a Python script to HTML, so I can display it on a webpage nicely formatted with syntax colour coding. Manually coding is a pain in the posterior :-) Colin From guido at beopen.com Mon Jul 31 11:17:10 2000 From: guido at beopen.com (Guido van Rossum) Date: Mon, 31 Jul 2000 15:17:10 GMT Subject: telnetlib References: <20000729152800.B1899@reepicheep.avalongroup.net> Message-ID: Timothy Grant writes: > Everything works great until I enter the Terminal type. It appears that the > telnet session stops receiving at that point. As you can see from the > Traceback I receive the echo of from my write, but then don't receive the > next prompt. > > I'm guessing it has something to do with either changing the terminal type > on telnetlib, or a timing issue, but I'm stumped at the moment. Could you post a transcript of what the session looks like when you do it manually??? A random "poke-and-hope" suggestion: perhaps you could use \r instead of \n in input??? (Please don't mail me directly!!!) --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From vespe at cs.tut.fi Fri Jul 28 13:14:57 2000 From: vespe at cs.tut.fi (Vespe Savikko) Date: 28 Jul 2000 20:14:57 +0300 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: Also sprach Guido van Rossum : I've placed the slides of my talk at the O'Reilly Open Source Convention on-line at our BeOpen PythonLabs website: http://www.pythonlabs.com/talks.html The first example on slide 14, List Comprehensions: [(x, x**2) for x in range(5)] -> [(0,0), (1,1), (4,4), (9,9), (16,16)] My intuition says the result should be: -> [(0,0) ,(1,1), (2,4), (3,9), (4,16)] Is there a typo in the slide or have I missed some aspect of list comperehensions? ++Vespe -- ------------------------------------------------------------------ Vespe Savikko vespe at cs.tut.fi - to doom de doomsday - From ingoogni at CUT.THIS.OUT.home.nl Mon Jul 24 14:32:05 2000 From: ingoogni at CUT.THIS.OUT.home.nl (ingo) Date: Mon, 24 Jul 2000 18:32:05 GMT Subject: f.write(chr(10)) ? Message-ID: <8F7BD871Fseed7@212.120.66.201> Hi all, I'm just beginning with programming and Python. Writing a file using this: >>> f=open("testpy",'wd') >>> f.write(chr(10)) >>> f.close() When I open the file with HexEdit I see: 0000: 0D 0A I expected 0000: 0A What's wrong? Ingo -- Photography: http://members.home.nl/ingoogni/ Pov-Ray : http://members.home.nl/seed7/ From Gareth.McCaughan at pobox.com Sun Jul 23 12:51:06 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 23 Jul 2000 17:51:06 +0100 Subject: iterating over lines in a file References: Message-ID: Moshe Zadka wrote: > > > Preventing world war III, when Python achieves world domination. > > > If C is allowed to achieve world domination, WWIII will be cause by > > > > > > if(everything_is_ok = 0) { > > > launch_missile(); > > > } > > > > No, that will *prevent* WW3 happening when it was supposed to. > > Where do I sign up for the campaign to help C dominate the > > world? :-) > > You probably need to reread the condition. I don't think so. |everything_is_ok| goes to 0 and stays there, but that's OK because the missiles can't get launched on account of the condition being (apart from the assignment) equivalent to if (0) { ... } Of course, if somewhere else there's a bit of code like if (!everything_is_ok) { mobilize_armies(); invade_nearest_enemy(); } then we might get WW3 anyway. :-) (If your point was that there might be such a piece of code elsewhere then of course you're right; but I didn't misread or misunderstand the condition.) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From jhe at webde-ag.de Mon Jul 24 04:28:14 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Mon, 24 Jul 2000 10:28:14 +0200 Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <397BE9FE.BF003A13@stroeder.com> Message-ID: <8lgujm$rhr$1@pollux.ip-plus.net> "Michael Str?der" schrieb im Newsbeitrag news:397BE9FE.BF003A13 at stroeder.com... > Don't be unfair! You forgot mod_snake! > => there are *three* competing version. ;-) Actually, there are four. From none at none Fri Jul 21 20:57:42 2000 From: none at none (Eric Jacobs) Date: Fri, 21 Jul 2000 19:57:42 -0500 Subject: Scope questions References: <8l7vgk$73t$1@supernews.com> Message-ID: In article <8l7vgk$73t$1 at supernews.com>, "Dale Strickland-Clark" wrote: > Could someone help me out with some scope and instantiation questions? > > In moduleA we have: > > varB = 1 > class classC: > varD = 1 > def __init__(self): > self.varE = 1 > > As I understand it, varB appears when the module is imported and stays > around until the end of the program. It appears when the statement "varB = 1" is executed, which would be at import time since the statement is not in a def. The name varB will persist until it is deleted or the module is deleted (which will delete the namespace dictionary it is in.) > > When does varD appear? How long does it exist? When the statement "varD = 1" is executed. A class definition doesn't change the flow of execution. Since the statement is not in a def, it also gets created at import time. try... class z: print "hello world" It exists until it is deleted or the class is deleted (again, deleting the namespace dictionary.) > > In the main code I use the above module and have: > > import moduleA > varJ = moduleA.classC > varK = varJ.varE > varJ = None > > Again, as I understand it, varK contains a reference to varE in class > instance varJ. No, it does not contain a reference to varE. There is no built-in way to reference names in Python. Rather, it is assigned a reference to whatever object varE is referencing. (You didn't provide any code which would create a name varE in classC, so this probably won't work. self.varE refers to a varE in an instance of classC.) > What happens to varK when the instance reference in varJ > goes away? varJ is not an instance reference. It is a reference to classC. varK will continue to reference the object that varE was referencing even if the name varE is nowhere to be found. > Does the instance get deleted or is there still a reference > to it? There are no instances here, but classC will not be deallocated because it is still referenced in moduleA's namespace. If you had done: funcK = lambda varJ=varJ: varJ.varE then the expression funcK() would be a sort of a "reference" to the name varE. In this case, varJ would have its reference count incremented because it is being referenced in funcK's default argument list, and so it wouldn't be deleted before funcK itself is deleted. Hope this answers your question. From paul at prescod.net Mon Jul 17 15:43:01 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 14:43:01 -0500 Subject: Parser project Message-ID: <397361C5.1D401DF2@prescod.net> Here is a project for a parser hacker: Write a Python module that can read a grammar in the syntax that Python uses (see Grammar/Grammar in the source distribution) and generate a parser object without any special compilation stage: from newparser import Parser parser=Parser( grammar="/python/src/Grammar/Grammar" ) parsetree=parser.parse( sys.argv[1] ) code=compileast( parsetree ) eval( code ) With this tool, people could easily write Python-like languages in Python by making changes to the grammar. This would be great for those who want to experiment with new language features without building (and distributing) a special version of Python. Let's say you invented a Python-like language for matrices. You would tell people to install Python and then invoke your code like this: python matrixLang.py helloworld.mtrx You could imagine the same for a Python-like language for XML processing, or static type checking, ...or just to try out a new feature that you would like to be in some future version of Python. It's not that doing this is impossible today, it just isn't as easy as it would be if there were a module that could parse things at runtime and was compatible with Python's grammar syntax. (or maybe there is and I just don't know it!!) Once your feature was "worked out" you might want to use a compiler compiler or even a C-based parser to speed it up, of course. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From gmcm at hypernet.com Sat Jul 22 15:56:23 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 Jul 2000 19:56:23 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F7974AF5gmcmhypernetcom@199.171.54.194> <3979CE02.D2744B7E@prescod.net> Message-ID: <8F79AAFA3gmcmhypernetcom@199.171.54.154> Paul Prescod wrote: >Gordon McMillan wrote: >> >> >What surprises me, though, is that no one ever >> >mentions the possibility of writing >> > inp = __builtin__.open("c:/autoexec.bat",'r') >> >> Because __builtin__ is a module and has to be imported. And someone who >> says > >Well yes, but not __builtins__ (with the "s") > >Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32 >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> __builtins__ > > Only sometimes. At other times __builtins__ is a dictionary, so inp = __builtins__.open("...") would fail, and you'd have to use inp = __builtins__['open']("....") -Gordon From tim.hochberg at ieee.org Tue Jul 18 21:21:10 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 19 Jul 2000 01:21:10 GMT Subject: Operators for matrix: current choices (Was Matlab vs Python ...) References: Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: [SNIP] > The implicit meaning is "the dot in front means the operator is > elementwise". Tell a newbie this, then show him the following piece of code > > [1,2] + [10,20] == [1,2,10,20] > [1,2] .+ [10,20] == [11, 22] > > Then give him two minutes for brainstorming. He probably will figure out > what .* .- ./ do. There is a problem with adding new operators to mean elementwise: the current operators are already elementwise in NumPy. Either all current NumPy code would have to be broken to fit in with this rule, or the rule would have to become "elementwise, except when it's not", which is somewhat less satisfying. I would suggest that it would be more productive to add operators that are not elementwise, except that conflicts with the rest of Python. TNSTAAFL. Personally I think that this an overlarge crop of operators to be adding. Since I prefer something like: A.inv * B to A \ B anyway, the only operator I feel is missing is the matrix multiplication. And, conveniently, there is an appropriate opperator already sitting around: __call__. If call were overloaded to do matrix multiplication, then dot(A,B) (as the matrix product is written in NumPy now) could be written: A(B) Similarly: dot((A,B), C) -> A(B)(C) dot(A, dot(B,C) -> A(B(C)) which looks pretty good to me. And it's arguably closer to paper linear algebra notation than A*B is. (Of course you can't do A.inv now in NumPy, but it would be relatively simple to add). [SNIP] > With a little correction. For named lists it is either > > names .+ "is" .+ types > map(lambda x,y: x+"is"+y, names, types) There's a bit of a problem here since "is" is a sequence. I'm not sure how you propose to have sequences of unequal length work with .X, but I'd think this would have to be: names .+ ["is"]*len(names) .+ types My 12.4 cents. -tim From wjdandreta at worldnet.att.net Sun Jul 2 14:18:31 2000 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Sun, 02 Jul 2000 18:18:31 GMT Subject: Problem compiling Python 1.5.2? Message-ID: I am having the following problem getting Python 1.5.2 to work correctly. I am able to compile and link OK. When I run Python with the -v switch the following messages appear ----------------------------------------------------------------- 'import exceptions' failed; traceback: ImportError: No modules named exceptions Warning! Falling back to string based exceptions #c:\pyth152\python~1.2\lib\site.pyc matches c:\pyth152\python~1.2\lib\site.py import site # precompiled from c:\pyth152\python~1.2\lib\site.pyc 'import site' failed; traceback: Traceback (innermost last): File "c:\pyth152\python~1.2\lib\site.py", line 60 in ? import sys, os SystemError bad argument to internal function Python 1.5.2 (#0, Jul 2 2000, 13:27:07) [Borland] on dos Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> ---------------------------------------------------------------------------- ----------- The exceptions.py file is in the search directory. Could it be a DOS name mangling problem? I don't know what the SystemError means. The Copyright does not cover to current date, I don't know if that indicates a problem. ---------------------------------------------------------------------------- ------------------------- I played around with some arithmetic, strings, slices etc. and it all worked correctly, so I think I am pretty close to getting it right. When I exit Python, Win98 becomes unstable. It either locks up immediately or a short time later in another program. I am sure I did something wrong when I compiled but I don't have a clue as to what that might be nor do I know what info would be useful in tracing down the problem(s). Any suggestions would be appreciated. Bill From hzhu at localhost.localdomain Sun Jul 9 05:47:18 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Sun, 09 Jul 2000 09:47:18 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 6th, 2000 References: <20000706115459.24950.qmail@synop.com> Message-ID: On 6 Jul 2000 11:54:59 -0000, Fiona Czuczman wrote: > >"Many thanks to Hans Nowak for providing FAQTs with his collection of >snippets for entry into http://python.faqts.com. > >They can be found directly at > >http://www.faqts.com/knowledge-base/index.phtml/fid/538/lang/en Congratuations for your excellent work! Where is the original snippets collection? And how do I submit new ones? Shall I post them here? I'd prefer not using web forms. Huaiyu From Norbert.Klamann at pobox.com.bbs Mon Jul 17 05:10:06 2000 From: Norbert.Klamann at pobox.com.bbs (Norbert.Klamann at pobox.com.bbs) Date: 17 Jul 2000 09:10:06 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bR6dU$kbr@openbazaar.net> Hello all, working with the new Build 132 of Pythonwin we have a minor problem. German Umlauts are not handled properly in the editor windows. They are shown as boxes, some of them seem to be dead keys. The problem did not exist in previous builds. Does anyone have a hint ? Thanks for your time ! Norbert -- Norbert Klamann Klamann Software & Beratung GmbH Erftstadt Germany Klamann.Software at pobox.com Sent via Deja.com http://www.deja.com/ Before you buy. From michael at stroeder.com Mon Jul 24 03:02:22 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 24 Jul 2000 09:02:22 +0200 Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> Message-ID: <397BE9FE.BF003A13@stroeder.com> Dan Grassi wrote: ^^^^^^^^^^ I remember a strange PHP3 vs. Python thread... > > I need Oracle on ix86, > [..] > Memory leaks are > a major problem in a shop that is serving over 1 million pages a day. You already found http://www.zope.org ? > Then there is the mod-python/mod_pyapache mess, two competing versions Don't be unfair! You forgot mod_snake! => there are *three* competing version. ;-) Ciao, Michael. From akuchlin at mems-exchange.org Tue Jul 18 11:05:52 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 18 Jul 2000 10:05:52 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jul 18) Message-ID: Mark Hammond reveals a fourth (nth?) Python implementation on the horizon: "It has a compiler that generates native Windows .DLL/.EXE files. It uses a runtime that consists of a few thousand lines of C# (C-Sharp) code. ... Python can subclass VB or C# classes, and vice-versa." http://www.python.org/pipermail/python-dev/2000-July/013019.html The Python community has always had fun suggesting enhancements to the language, but unless you follow threads carefully, it can be hard to figure out the state of a proposal. Barry Warsaw will be making the process more formal and IETF-like, as described here: http://www.python.org/pipermail/python-dev/2000-July/013059.html Huaiyu Zhu provides class calculus to help homesick Javans and others involved in a particular kind of type correctness http://deja.com/=dnc/getdoc.xp?AN=635109618 Edward K. Ream and Gordon McMillan show how to think about generation of executables which embed Python, even in the face of Win* peculiarities, Borland-Microsoft miscegenation, backlinking, extensions, and related abstrusities http://deja.com/=dnc/viewthread.xp?AN=647162382 Intellisens-ability: PythonWin capacity to use a key other than TAB in AutoComplete traversal http://deja.com/=dnc/getdoc.xp?AN=647146716 TheKompany.com releases the third distinct product called "Visual Python". This one "is aimed at KDE and GNOME appli- cation developers and allows you to easily embed Python as a GUI enabled scripting language in your application" http://x75.deja.com/getdoc.xp?AN=647020031 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org eff-bot's complements this digest with his daily python url http://hem.passagen.se/eff/url.htm Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From m.faassen at vet.uu.nl Fri Jul 28 18:04:50 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Jul 2000 22:04:50 GMT Subject: Perl is worse! References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: <8lt022$mrg$1@newshost.accu.uu.nl> Steve Lamb wrote: > On Fri, 28 Jul 2000 06:52:19 GMT, Ben Wolfson > wrote: >>Yes, it does. List returns the list-equivalent of the sequence passed as >>its argument. 1 is not a sequence; it doesn't have a list equivalent. > 1 is a sequence whether Python likes it or not. I call that a deficiency > in the language. Right, so you're saying all objects in Python should be sequences of a single element. Now let's take the object [1] (a sequence object). According to you, this should be a sequence with a single object [[1]], and that should be a sequence with a single object too, so [[[1]]], and so on ad infinitum. So [1][0] should be [1], right? And [1].append(1) should be, um, [[1], 1], or alternatively [[1, 2]], or it might also be [[[1], [[[1]]]]], if you'd like. That's an interesting position, but it's not the way Python works. Python is self consistent, it's not deficient, and it's also not Perl. Please point out actual quirks of the language. We thank you. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aruth at intercation.com Mon Jul 24 10:04:42 2000 From: aruth at intercation.com (Adam Ruth) Date: Mon, 24 Jul 2000 08:04:42 -0600 Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <397BE9FE.BF003A13@stroeder.com> Message-ID: <8lhigj$sd5$1@news.aros.net> And don't forget FastCGI. It's a language independent version that we use. -- Adam Ruth InterCation, Inc. www.intercation.com "Michael Str?der" wrote in message news:397BE9FE.BF003A13 at stroeder.com... > Dan Grassi wrote: > ^^^^^^^^^^ > I remember a strange PHP3 vs. Python thread... > > > > I need Oracle on ix86, > > [..] > > Memory leaks are > > a major problem in a shop that is serving over 1 million pages a day. > > You already found http://www.zope.org ? > > > Then there is the mod-python/mod_pyapache mess, two competing versions > > Don't be unfair! You forgot mod_snake! > => there are *three* competing version. ;-) > > Ciao, Michael. From mwh21 at cam.ac.uk Thu Jul 13 02:38:21 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 Jul 2000 07:38:21 +0100 Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: hzhu at knowledgetrack.com (Huaiyu Zhu) writes: > 2. It is difficult to add .* and ./ as . is already a valid token. Irrespective of the rest of this post, this is not true. "**" is a valid token depsite "*" being one, etc. Cheers, M. -- I'm sorry, was my bias showing again? :-) -- William Tanksley, 13 May 2000 From tjg at exceptionalminds.com Sat Jul 29 18:28:00 2000 From: tjg at exceptionalminds.com (Timothy Grant) Date: Sat, 29 Jul 2000 15:28:00 -0700 Subject: telnetlib Message-ID: <20000729152800.B1899@reepicheep.avalongroup.net> Hi all, I have my first need to play with the telnetlib module, and am having some good successes, but some puzzling failures. I'm hoping that someone here can shed some light on what's happening. First the trace from my telnet session: Telnet(host.abcde.com,23): recv '\015\012SFW 123.123.123.123\015\012' Telnet(host.abcde.com,23): recv '\024\005' Telnet(host.abcde.com,23): send 'ABCDEFGH' Telnet(host.abcde.com,23): recv 'Welcome to Stellar 3\015\012ABCDEFGHI \015\012' Telnet(host.abcde.com,23): recv '\015\000\015\000Enter Public ID: ' Telnet(host.abcde.com,23): send 'XYZ\012' Telnet(host.abcde.com,23): recv 'X' Telnet(host.abcde.com,23): recv 'YZ\015\012' Telnet(host.abcde.com,23): recv '\015\000\015\000Enter Private ID: ' Telnet(host.abcde.com,23): send '1234567\012' Telnet(host.abcde.com,23): recv '*' Telnet(host.abcde.com,23): recv '*' Telnet(host.abcde.com,23): recv '*****\010 \010\010 \010\010 \010\010 \010\010 \010\010 \010\010 \010\015\012' Telnet(host.abcde.com,23): recv '\015\012' Telnet(host.abcde.com,23): recv 'You have Personal and General mail.\015\012' Telnet(host.abcde.com,23): recv '\015\012Enter Terminal Type ( PIC default - ? for valid ' Telnet(host.abcde.com,23): recv 'types): ' Telnet(host.abcde.com,23): send 'XTERM\012' Telnet(host.abcde.com,23): recv 'X' Telnet(host.abcde.com,23): recv 'T' Telnet(host.abcde.com,23): recv 'ERM' Now the code: host = telnetlib.Telnet(hostname) host.set_debuglevel(255) host.read_until('\024\005') host.write(answerback) host.read_until('Public ID: ') host.write(username + '\n') host.read_until('Private ID: ') host.write(password + '\n') host.read_until('): ') #Set the terminal Type host.write('XTERM\n') #My code stops function at this point #The following prompt never appears host.read_until('): ') #Set the terminal Rows host.write('24\n') Now the problem. Everything works great until I enter the Terminal type. It appears that the telnet session stops receiving at that point. As you can see from the Traceback I receive the echo of from my write, but then don't receive the next prompt. I'm guessing it has something to do with either changing the terminal type on telnetlib, or a timing issue, but I'm stumped at the moment. One other point, even if I go with the default terminal type, I have the same problem. Any suggestions will be greatfully accepted. Thanks. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com Red Hat Certified Engineer (503) 246-3630 Avalon Technology Group, Inc. fax (503) 246-3124 >>>>>>>>>>>>Linux...Because crashing isn't normal<<<<<<<<<<<<< From europax at home.com.bbs Sun Jul 16 21:50:02 2000 From: europax at home.com.bbs (europax at home.com.bbs) Date: 17 Jul 2000 01:50:02 GMT Subject: problems trying wxPython in Win 95 Message-ID: <3bQhHQ$l5X@openbazaar.net> I want to run the demo program included in wxPython 2.1. Upon starting it I immediately get the message appended to this post. I have two versions of Python installed- 1.5.2 and 1.6a2. I tried the demo from both of them and get the same result. I tried running it from the console, from PythonWin, and from IDLE, all with negative results. Does anyone have an idea of what is going on? Thanks, Rob. PYTHONWIN caused an exception c06d007eH in module KERNEL32.DLL at 0137:bff9a07c. Registers: EAX=0063d7bc CS=0137 EIP=bff9a07c EFLGS=00000246 EBX=00000000 SS=013f ESP=0063d7b8 EBP=0063d80c ECX=0063d7d4 DS=013f ESI=0063d864 FS=2287 EDX=ffffffff ES=013f EDI=00000000 GS=0000 Bytes at CS:EIP: 5e 8b e5 5d c2 10 00 64 a1 00 00 00 00 55 8b ec Stack dump: 018a9c34 c06d007e 00000000 00000000 bff9a07c 00000001 0063d830 bff782c7 817f9000 81821708 00081822 00000000 0063d6e3 00000000 bff7c4f7 0188e4d0 From donn at u.washington.edu Mon Jul 24 12:21:18 2000 From: donn at u.washington.edu (Donn Cave) Date: 24 Jul 2000 16:21:18 GMT Subject: newb Q: security with variables References: <397BE388.349CCA17@mediaone.net> Message-ID: <8lhqdu$2ae6$1@nntp6.u.washington.edu> Quoth Toy : | Could you please explain to me various secure ways of having a python | script store variables such as your password/username in a file. | I understand that you can chmod 0400 , but are there any | other alternatives? On a floppy disk, retained by owner of the password. | Also, can you run python code with files that don't end with the python | extensions(.py and others)? That way it would make it less obvious that | it was some sort of script. Thanks Yes. Donn Cave, donn at u.washington.edu From Wolfgang.Strobl at gmd.de Mon Jul 17 08:55:58 2000 From: Wolfgang.Strobl at gmd.de (Wolfgang Strobl) Date: Mon, 17 Jul 2000 14:55:58 +0200 Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: "Neil Hodgson" wrote: > if key == 220: > return 1 > This avoids calling win32ui.TranslateVirtualKey for the "^" key. This helps. Many thanks! >More >tests may be needed for other accent characters or other locales. if key == 220 or key == 221: return 1 is sufficient for the German keyboard locale IMHO, it disables the other special key, on the other side of the keyboard, left to the backspace key, too. That key is labeled "?" and "`" on the German keyboard. -- o ( Wolfgang.Strobl at gmd.de (+49 2241) 14-2394 /\ * GMD Forschungszentrum Informationstechnik GmbH _`\ `_<=== Schloss Birlinghoven, | #include __(_)/_(_)___.-._ D-53754 Sankt Augustin, Germany | From shouldbe at message.com Thu Jul 6 08:35:31 2000 From: shouldbe at message.com (Arinté) Date: Thu, 06 Jul 2000 12:35:31 GMT Subject: Python brokeness??? Message-ID: I have an embedded app with a call like this: PyObject *open(PyObject* self,PyObject* args){ long ret(1); g_lastDevice = pyposs.getDeviceFromPy(args); if(!g_lastDevice){ PyErr_Clear(); PyErr_SetString(PyExc_TypeError,"No Device"); return NULL; } else { PyObject* deqme =Py_BuildValue("i",0); PyObject* comm =PyObject_GetItem(args, deqme); PosArgEx* p=createArgs(comm); ret = g_lastDevice->open(p); if(p){ createPyArgs(comm,p); delete p; } ioctls.getIOCtls(g_lastDevice->getName()); } PyErr_Clear(); return Py_BuildValue("i",ret); } Now, before I put that PyErr_Clear in the script that I ran with a range(-1,10) used to give error len() of unsized object or give me IndexError: string index out of range. Here is the script import PossDevice import poss 1 poss.initialize( PossDevice.Enumerate ) 2 diz = PossDevice.QueryDevices(1,11,35) 3 diz.open() 4 diz.ioctl("POS_SYS_ACQUIRE_DEVICE",0) z = range(-1,14) for i in z: print i I figured out that it was open by taking away line 4, then 3, then 2, then putting 3 back in. So, I first did a check on PyErr_Occurred, but it didn't give an error, but the script did. So, I just left PyErr_Clear in without checking and it worked. BTW, I get the len() of unsized error if I leave the ioctl and the open in (ioctl and open are calls to the c++ app). I like python and I am not trying to troll or tear it down, so please no flames. If any of the functions fail in my c++ app (like g_lastDevice = pyposs.getDeviceFromPy(args);) I expect a crash, but these are nigh foolproof (emphasis on nigh). thanx for any info. From cjc26 at nospam.cornell.edu Sun Jul 23 10:43:10 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 23 Jul 2000 14:43:10 GMT Subject: iterating over lines in a file References: <8l73an01lgb@news2.newsguy.com> Message-ID: * nobody menulis: | | >> i like it, i just wish its functions would be more consistent about | >> what sort of regexps they want - either all compiled or all not | >> compiled; i'm seeing some wanting one and some the other, for some | >> reason. might be just my system, i suppose... | | > The two should be interchangable..AFAIK wherever you can use a compiled | > regexp, you can use an uncompiled one, and vice-versa. | | that's what the documentation claims, but here's what i get: | | >>> match=re.match(reg_c, test) | [...] | TypeError: argument 1: expected string, instance found | >>> match=re.match(reg,test) | >>> | | the compiled one works in re.findall, though. i've no idea why this | bites me in this way, but it's not too hard to work around, so... Oh, right..I should've explained it better :) A compiled regexp is an object which has match() and search() methods, so instead of match=re.match(reg_c, test) you want to do match=reg_c.match(test) Also, in your example you'd probably want to use search() rather than match(), which only succeeds if the regexp matches the beginning of the string (i.e. it acts as if there is an implicit '^' at the beginning of the regexp). -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From Ted.Mew at ncmail.net Wed Jul 5 09:11:36 2000 From: Ted.Mew at ncmail.net (Ted Mew) Date: Wed, 05 Jul 2000 09:11:36 -0400 Subject: Compatibility between PythonWin and DISLIN Message-ID: <39633408.80B5DFBC@ncmail.net> Has anyone tried to run the graphing package DISLIN using Mark Hammond's PythonWin 1.5.2? Is DISLIN compatible with PythonWin? DISLIN 7.3 is a high-level and easy to use graphics library with a Python version that runs nicely on a Windows NT platform under Python 1.5.2. This data plotting extension was developed by Helmut Michels of the Max_Planck Institute. It is listed on the Starship at: http://starship.python.net/crew/jhauser/plot-res.html and the binaries can be obtained freely at: http://www.linmpi.mpg.de/dislin/ I have made a cursory attempt to run DISLIN under PythonWin, but crashed in flames, unable to read memory locations. Since PythonWin is MS Windows based, I suspect DISLIN is attempting to run as an independent process or DOS-based program, but have little knowledge in this area. Any insights or experience would be appreciated. -Ted -------------- next part -------------- A non-text attachment was scrubbed... Name: Ted.Mew.vcf Type: text/x-vcard Size: 396 bytes Desc: Card for Ted Mew URL: From level2junkie at my-deja.com Mon Jul 17 11:30:46 2000 From: level2junkie at my-deja.com (level2junkie at my-deja.com) Date: Mon, 17 Jul 2000 15:30:46 GMT Subject: freeze .pyw files? Message-ID: <8kv8r7$s1e$1@nnrp1.deja.com> Can someone tell me if it's possible to freeze a .pyw file. I've gotten freeze to work with .py files, but for some reason it seems to hate the .pyw files. I'd rather not have that console window pop up everytime I want to run my application. Does anyone know how to freeze a .pyw file? Sent via Deja.com http://www.deja.com/ Before you buy. From lull at acm.org Thu Jul 6 01:49:04 2000 From: lull at acm.org (John Lull) Date: 6 Jul 2000 00:49:04 -0500 Subject: Singleton COM local/remote server? References: <7bd5msssk48km280t9bvds4i3v6hs7r8or@4ax.com> <8jvad40s00@news1.newsguy.com> Message-ID: Alex Martelli wrote (with possible deletions): > I'm not sure how this translates to Python's implementation > of COM, but, at a lower abstraction level, this is exactly > what is accomplished by passing the REGCLS_MULTIPLEUSE value > as the "flags" parameter in the CoRegisterClassObject calls > that an .EXE does, at startup, to let the Service Control > Manager of COM know about its class-objects (IClassFactory > instances). > Now, there remains the issue of, how to control the flags > used on CoRegisterClassObject by pythonw.exe...? I can't > find it in the docs (which doesn't mean it isn't there... > it just says I can't find it). Maybe we need to look at > the sources...? I replied (with capitalization corrected): > It seems to be passed as the third command line argument to > localserver.py, which calls RegisterClassFactories(), which > in turn calls CoRegisterClassObject(). > localserver.py is apparently run anytime you start a Python > local server. Now I just need to figure out how to set up > the command line arguments -- I suspect it's something set > in the registry during installation. If I had simply looked a little further, I would have noticed that if you don't specify flags and/or clsctx to RegisterClassFactories: flags defaults to REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED clsctx defaults to CLSCTX_LOCAL_SERVER and localserver.py promptly calls CoResumeClassObjects() after RegisterClassFactories(), which I think is precisely what I wanted. Looks like I'm all set, until I want to write a local server that can have *multiple* instances running simultaneously. Thanks much. Regards, John From pehr at pehr.net Thu Jul 20 00:19:25 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 20 Jul 2000 04:19:25 GMT Subject: HTTPS support? References: <20000719161558.A1809@freei.com> Message-ID: <39767DCD.6F910132@pehr.net> Dear Sean, We had this same issue. To solve it, we found that we could get what we needed by using the command-line options available in the openssl package. If your problem is more complicated than ours, you may be interested in investing more time than us. To do what we did, install openssl-0.9.5a-1 from http://www.openssl.org Binary RPMS are available from the http://openssh.com project ftp://ftp1.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/rpm/ "man openssl" should tell you how to work openssl and you can run it from python with something like: page = os.popen("echo %s | openssl" % cmds).read() I don't remember exactly what we did so try your own thing. Word on the street is that you should look in the prereleases of python 1.6 (renamed 2.0) for the "right" long-term solution. I've downloaded the CVS and it looks like you will have to uncomment a couple of lines in: python/dist/src/Modules/Setup.in Here is the relevant section: # Socket module compiled with SSL support; you must edit the SSL variable: #SSL=/usr/local/ssl #socket socketmodule.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto # The crypt module is now disabled by default because it breaks builds # on many systems (where -lcrypt is needed), e.g. Linux (I believe). #crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems Good luck! = -pehr Sean Blakey wrote: > > Are there any current SSL libraries for Python? A quick search of goole and > Parnassus turned up some older links and some RPMS for a hack to 1.5.1 (I may > have to figure out how to dissasemble an RPM - I develop on FreeBSD). > > Does anybody know of a commercially usable Python SSL library that works with > current (1.5.2) Python? > -Sean > > -- > Sean Blakey, sblakey at freei.com > Software Developer, FreeInternet.com > (253)796-6500x1025 > Decaffeinated coffee? Just Say No. From baron at null.net Sat Jul 8 23:31:24 2000 From: baron at null.net (Matthew Schinckel) Date: Sun, 9 Jul 2000 13:01:24 +0930 Subject: Making tabs illegal In-Reply-To: References: <394ac7ea.609024015@nntp.interaccess.com> <3950C0E2.7532D38@sightreader.com> <8k5l8d$9lr$1@nnrp1.deja.com> Message-ID: On Jul 8, I overheard Justin Sheehy mutter: > Matthew Schinckel writes: > > > I hate having to hit space four times, I'd much rather just use tab. > > You should get a decent editor. You have missed my point entirely - I am arguing against the banning of tabs - my editor does tabs, syntax highlighting and autoindenting. Matt. From gmunsey at punkalunka.org Sat Jul 29 15:46:12 2000 From: gmunsey at punkalunka.org (Grant Munsey) Date: Sat, 29 Jul 2000 12:46:12 -0700 Subject: Python plug-ins for Adobe Products available Message-ID: Adobe has opened an open source site at http://opensource.adobe.com. The first three projects on the site are Python plug-ins for Adobe Photoshop, Illustrator, and After Effects (Windows only at this point). The Adobe Open Source license is reasonably liberal. From jerome.quelin at insalien.org Sat Jul 15 12:05:52 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Sat, 15 Jul 2000 18:05:52 +0200 Subject: How to read one raw character at a time? Message-ID: <963677152.546123668@news.libertysurf.fr> Hi all, When prompting a user for something, I would like to fetch and proceed his answer character by character, and not line by line. How should I do? sys.stdin.read(1) proceeds only when the user hits the return key, that's not what I want. What function should I call? Some sort of get_char(), or getc(), I presume, but do Python provide them? If so, in which module? Thanks, Jerome -- jerome.quelin at insalien.org From danny at thrud.anatomy.usyd.edu.au Sun Jul 9 07:42:46 2000 From: danny at thrud.anatomy.usyd.edu.au (Danny Yee) Date: 9 Jul 2000 21:42:46 +1000 Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> <8k8q17$rov$1@thrud.anatomy.usyd.edu.au> Message-ID: <8k9ofm$8lq$1@thrud.anatomy.usyd.edu.au> I solved my problem. The big performance hit was doing hundreds of substitutions on every line. But there are only a few diacritics in the body of text I am converting (this is to produce html versions of a collection of 500 book reviews, from ISO Latin originals), so I did a search before doing the substitutions. special = re.compile("[?-?]") if special.search(line): for pair in fix_list: line = re.sub(pair[0], pair[1], line) And that sped up a complete rebuild of the site from ten minutes to one! http://dannyreviews.com/ Danny. From bjorn at roguewave.com Mon Jul 17 12:32:43 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 17 Jul 2000 10:32:43 -0600 Subject: Global & Importing issues.... Newbie References: <963849878.7647.0.nnrp-13.c3ad12d2@news.demon.co.uk> Message-ID: <3973352B.6DED8D9C@roguewave.com> Try import __main__ in mod2. Or even better implement the common data in a separate module, perhaps even as a class? -- bjorn Toby wrote: > > I have a simple requirement for a second module to access a global variable > stored in the first (main) module. > > I can reproduce my problem with the following 2 modules... > > Mod1.PY >>> > import Mod2 > > myGlobal = None > > if __name__ == "__main__": > > myGlobal = 100 > > Mod2.DoPrint() > #endif > #endmodule > > Mod2.PY >>> > import Mod1 > > def DoPrint(): > print Mod1.myGlobal > #enddef > #endmodule > > When executing Mod1.PY I expect the answer 100 to be printed out, I get None > > I also get the same problem if there is a function in Mod1 which prints the > value of myGlobal and is called from Mod2 - I think this is the same > problem. > > :o( > > Any help from Python experts ? > > TIA Toby > > -- > http://www.python.org/mailman/listinfo/python-list From jick78 at my-deja.com Mon Jul 10 16:47:15 2000 From: jick78 at my-deja.com (jick78 at my-deja.com) Date: Mon, 10 Jul 2000 20:47:15 GMT Subject: Py_Apache Vs. mod_python References: <3963CF19.3F4CDA8D@bioeng.ucsd.edu> <87zonvso9c.fsf@cachemir.echo-net.net> <71vfmsc0sspvpg3mq8k3s1ri653908u9nk@4ax.com> <396863B7.875EA939@stroeder.com> <8kai0a$7fm$1@nnrp1.deja.com> Message-ID: <8kdcoe$85o$1@nnrp1.deja.com> I'll just post to clear up some of the confusion around some of the Apache+Python modules. mod_snake in its most basic form allows you to load Python modules into the Apache server to hook into the various Apache phases (such as check_user_id, etc.) There are modules that come with mod_snake, that allow you to accelerate CGI scripts via keeping an interp around (py_Apache does this), and also one that allows you to write very 'simple' modules similar to mod_perl or mod_python. There is also a module to perform embedded Python processing within HTML via embPerl syntax. I.e.: [-import time-]

The date is [+time.ctime(time.time())+]

The current main differences between mod_snake and mod_python are: o mod_snake works in both Apache 1.3 and 2.0 series. Mod_Python currently only runs in Apache 1.3. o mod_python runs under Windows -- mod_snake does not. o mod_snake allows Python written modules to create their own configuration directives, and gives the modules more power similar to that of C-style Apache modules (via per-dir configs, etc.) mod_python only allows for mod_perl style callbacks. There are more subtle differences, but we can leave those alone. To check these out, you can check out: modsnake.sourceforge.net or modpython.sourceforge.net -- Jon In article <8kai0a$7fm$1 at nnrp1.deja.com>, johnvert at my-deja.com wrote: > In article <396863B7.875EA939 at stroeder.com>, > Michael =?iso-8859-1?Q?Str=C3=B6der?= wrote: > > Tim Roberts wrote: > > > > > > I'll say. Am I correct in understanding that the basic purpose of > > > "mod_snake" is to allow me to write other Apache modules in Python, > while > > > PyApache is a module which lets me run Python CGI scripts without > > > launching a separate interpreter, > > > > Yes. PyApache resets the Python interpreter everytime which leads to > > reloading of the modules for every hit. > > > > With mod_python you can write Apache handlers but also wrap normal > > CGI-BIN scripts without having to reload the modules for every hit. > > > > Ciao, Michael. > > Which one of these modules can you use to write embedded python code? > I.e. > > foo.html.py: > > > Looping through red, blue, green: > > colors = ['red', 'blue', 'green'] > for color in colors: > print color > > > > > Thanks, > -- John > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From fiona at sitegnome.com Wed Jul 26 23:55:33 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 27 Jul 2000 13:55:33 +1000 Subject: Beginning References: <8loacq$n81$1@nnrp1.deja.com> Message-ID: <397FB2B5.8FE38267@sitegnome.com> Hi Alex, A little commercial for the work I've been doing :-) Check out http://python.faqts.com There are a lot of links to resources and an extensive collection of FAQ's. cheers, Fiona Alex wrote: > > hi everybody! > I just begin to study programming and one friend of mine advised to me > to start with the Python language. I find it interesting. > If anybody know good Internet links to Python sources, please send it > here. Also any good advice for beginner will be appreciated. > If you a beginner and would like to exchange ideas and experience about > programming on Python e-mail me medved55 at greenbay.usa.com. Profy > welcome too. > Thank you. > Alex > > Sent via Deja.com http://www.deja.com/ > Before you buy. -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From sash at eurocom.od.ua Tue Jul 25 05:57:07 2000 From: sash at eurocom.od.ua (Alexander V. Goncharuk) Date: Tue, 25 Jul 2000 12:57:07 +0300 Subject: Python 1.4 + IBM patch on MVS References: <8ljj9n$v3r$1@DCS.eurocom.od.ua> Message-ID: <8ljodk$38f$1@DCS.eurocom.od.ua> "Alexander V. Goncharuk" wrote in message news:8ljj9n$v3r$1 at DCS.eurocom.od.ua... > Hello all, > I tried to build python 1.4 + IBM patch on MVS but ... when I try to start > python I receive "segmentation fault" > I applied patch from IBM w/o problem, compiled and linked w/o problem, but > python doesn't run. > Did anybody try to build and run python on MVS ? > Probably It's necessary to specify any additional options on the configure > stage ? > > Will be very obliged for any suggestion about this problem. > > regards, > Alexander > > > More exactly the error output is: $ ./python Python 1.4 (Jul 13 2000) [C] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam CEE3204S The system detected a protection exception (System Completion Code=0C4) . From entry point fixstate at compile unit offset +00000082 at address 0 DADBD8A. [1] + Done(139) ./python 33554611 Segmentation violation ./python From robin at jessikat.co.uk Thu Jul 6 07:16:27 2000 From: robin at jessikat.co.uk (Robin Becker) Date: Thu, 6 Jul 2000 12:16:27 +0100 Subject: function arguments References: Message-ID: <6CWP3BALqGZ5EwzT@jessikat.demon.co.uk> In article , Johannes Zellner writes > >Hello, > >is there a way to get a functions argument list ? > >e.g. > >def fun(fred, lola): > ... > >something like `arglist(fun)' should return [ 'fred', 'lola' ] > def arglist(fun): return fun.func_code.co_varnames[:fun.func_code.co_argcount] -- Robin Becker From max at alcyone.com Sat Jul 15 14:09:49 2000 From: max at alcyone.com (Erik Max Francis) Date: Sat, 15 Jul 2000 11:09:49 -0700 Subject: '"""' and linefeed characters References: Message-ID: <3970A8ED.2EF04522@alcyone.com> Matthew Cline wrote: > > I'm assuming that returns in a '"""' quoted string are given > the linefeed character(s) of the operating system Python is > run on. Is this right? > > Thanks in advance. They're given a newline ('\n'), which is independent of the end-of-line sequence of your operating system. -- 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 chicken was the egg's idea of getting more eggs. \__/ Samuel Butler Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From arhodes at psionic.com.bbs Mon Jul 17 14:10:02 2000 From: arhodes at psionic.com.bbs (arhodes at psionic.com.bbs) Date: 17 Jul 2000 18:10:02 GMT Subject: Getting local IP address... Message-ID: <3bRKgR$mfs@openbazaar.net> Howdy... That works too. There are some purists who may take offense to reliance on external system binaries (ifconfig and grep)...not a big deal in my opinion. ifconfig on Linux probably does something similar to the fcntl/ioctl stuff I was mentioning...perhaps there should be a platform independent python-ifconfig library? The API to such a library could be constructed to provide a standard way to do "ifconfig-ish" stuff on Windows/NT/Unices. (i.e. up and down network interfaces, get the ip address off the net interface, set the ip on the net interface, change firewall rules perhaps, etc.) Aaron arhodes at psionic.com Tony Johnson wrote: > > Why not just do an addr = os.system(ifconfig eth0 | grep inet) > This should return the ip addy of the nic... > > Since the way OS's store IP addys is so implementaion dependant, I don't > see how it could be portable unless people start making a posix way of > storing an ip addy on top of the os dependant way > > On Monday, July 17, 2000 11:33 AM, Aaron Rhodes [SMTP:arhodes at psionic.com] > wrote: > > Here's a tremendously non-portable way to do it for > > Linux by reading it straight off the ethernet card... > > > > import string,socket,fcntl > > SIOCGIFADDR = 0x8915 > > ifname = 'eth0' > > s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) > > ifr = ifname+'\0'*(16-len(ifname))+chr(socket.AF_INET)+15*'\0' > > r= fcntl.ioctl(s.fileno(),SIOCGIFADDR,ifr) > > addr = string.join(map(str,map(ord,r[20:24])),'.') > > print addr > > > > From neo_brave at my-deja.com Sun Jul 2 01:20:56 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Sun, 02 Jul 2000 05:20:56 GMT Subject: Win32 : Making script.py executable in DOS box Message-ID: <8jmjfe$64o$1@nnrp1.deja.com> Hi all, I'm currently running Python scripts at the command line using C:\python\python script.py. Is there a way of making the MS-DOS box recognise the Python script as an executable file so I can just use the name "script.py"? Thanks in advance, Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From oivvio at cajal.mbb.ki.se Thu Jul 27 04:15:08 2000 From: oivvio at cajal.mbb.ki.se (Oivvio Polite) Date: Thu, 27 Jul 2000 10:15:08 +0200 Subject: polymorphism (was Re: Type checking in python?) References: <8lmo4i$s28$1@news.kth.se> Message-ID: <8lor06$hof$1@news.kth.se> Thanks a lot for all the answers. I see now that giving the responsibility to the caller is the path of righteous. My problem, I should have pointed this out in the first post, is that the caller doesn't want any responsibility at all. We're building a workbench for computational molecular biology. The intended audience is not one of programmers. It is one that uses Excel and Powerpoint. If you want them to do any programming you have to trick them in to it. In than context it's a great thing if a constructor can take just about anything and make sense out of it that is a good thing. It will flatten the learning curve. Therefore I will depart from the narrow path and go of with the try / except hoard. After all this I still don't get the difference between polymorphism and overloading. I've just ordered a book on OO design. So maybe that distinction will become clearer to me, then again, maybe it won't :) oivvio From neilh at scintilla.org.bbs Mon Jul 17 08:30:03 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 17 Jul 2000 12:30:03 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bRC1R$k8U@openbazaar.net> > And a major problem, the ^-key kills build 132 immediately, when using > the German keyboard layout. This is a known problem. It occurs inside the line key = win32ui.TranslateVirtualKey(key) found in fire_key_event in Pythonwin\pywin\scintilla\bindings.py. Mark is aware of the problem in the win32ui code, but you might want to try this short workaround while waiting for a fixed PythonWin. Just before the "if event is None:" line inside fire_key_event insert this code. if key == 220: return 1 This avoids calling win32ui.TranslateVirtualKey for the "^" key. More tests may be needed for other accent characters or other locales. Neil From tim_one at email.msn.com Sat Jul 29 16:32:56 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 29 Jul 2000 16:32:56 -0400 Subject: [Python-Dev] PEP 201, zip() builtin In-Reply-To: <4ge6oso7stn8m263dvkabt6foq1tbrqbqc@4ax.com> Message-ID: [Ben Wolfson] > I take it, then, that lock-step iteration will be done with zip()? Yes. > That seems too bad, Yes, but not a first-class disaster . > because it the existing Python syntax could be modified to create > easily-understood (to me, anyway) ways of expressing both parallel > and lock-step iteration: No, every attempt to do so has failed. For example, > parallel: > for x in sequence1, y in sequence2: > stuff > > lock-step: > for x, y in sequence1, sequence2: > stuff Both syntaxes already have well-defined meanings in Python (*try* them!), so we can't change what they mean without breaking existing code. Guido would *prefer* to do this via syntax instead of new functions, but in more than a year nobody has been able to dream up a reasonable syntax that's backward-compatible. That's not for lack of trying. maybe-in-p3k-ly y'rs - tim From gmcm at hypernet.com.bbs Sun Jul 16 21:10:01 2000 From: gmcm at hypernet.com.bbs (gmcm at hypernet.com.bbs) Date: 17 Jul 2000 01:10:01 GMT Subject: Can't load .pyd files from embedded Python interp Message-ID: <3bQgFP$jLv@openbazaar.net> Edward K. Ream wrote: >I'm having difficulty importing modules defined in .pyd files from an >embedded Python interpreter. The problem seems to be that two sets of >variables are being used and no linking is happening when the DLL is >loaded. Perhaps you DLL gurus will spot the problem immediatly. >Details follow... Thank you for posting such detailed research! Extension modules are linked against an import lib for python15.dll. So they load python15.dll automatically, and use the symbols exported from the dll, not the ones statically linked into your embedded app. While it is possible to export symbols from an .exe (in MSVC land, this produces an .exp file), I've never experimented with back-linking a dll to an exe. Most people just use python15.dll from their embedding app so both get the same copy. Using Borland probably adds some warts to the process, since everybody has to end up using the same c runtime. Your best bet is to look for some posts by Gordon Williams, who has instructions on building python with Borland. Good luck! - Gordon From guido at beopen.com Fri Jul 28 09:22:37 2000 From: guido at beopen.com (Guido van Rossum) Date: Fri, 28 Jul 2000 13:22:37 GMT Subject: [Python-Dev] PEP 201, zip() builtin References: <200007280428.QAA09796@s454.cosc.canterbury.ac.nz> Message-ID: > bwarsaw at beopen.com (Barry A. Warsaw): > > An earlier version of this PEP proposed that > > zip() return a built-in object that performed lazy evaluation > > using __getitem__() protocol. This has been strongly rejected > > by the BDFL in favor of returning a real Python list. If lazy > > evaluation is desired in the future, the BDFL suggests an xzip() > > function be added. Greg Ewing replies: > Well, in that case I think the BDFL has just shot this > proposal in the foot as far as being a serious solution > to the parallel for loop problem. > > I was willing to live with the idea of using zip() instead > of having a proper parallel iteration syntax, as long as > it was implemented lazily. But now it seems I'll have to > use another ugly x-named function all over the place. Who says all over the place? As far as I can tell, lock-step iteration (let's not call it "parallel") is a fairly uncommon operation -- but just common enough that people have been arguing for some kind of support for it. The proposed implementation will be blindingly fast -- zip() could approximate the existing range() function in speed. There are a few well-known cases where xrange() is to be preferred over range(), but in *most* cases, I claim, range() performs well enough. Note that I'm not saying that range() is faster than xrange() -- I am saying that it is *fast enough* for typical usage. I claim the same for zip(). We'll have a C implementation of zip() in the 2.0b1 release (expect it late August); please hold back your judgement until then. --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From MSherrill at compuserve.com Fri Jul 28 13:57:10 2000 From: MSherrill at compuserve.com (MSherrill at compuserve.com) Date: Fri, 28 Jul 2000 17:57:10 GMT Subject: Toplevel "test()" functions in standard library References: <39818f67.145239963@news.telus.net> Message-ID: <3981b028.9657126@news.compuserve.com> On Thu, 27 Jul 2000 19:46:22 GMT, root at 127.0.0.1 (David) wrote: >Either a sidewalk should be poured, so that the path becomes legitimate, or >people should quit being lazy and stay on the existing sidewalks. We have signs that said "Please walk on the grass, but don't make paths." But that has no bearing on the discussion. -- Mike Sherrill Information Management Systems From dale at out-think.NOSPAMco.uk Wed Jul 19 13:05:32 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 19 Jul 2000 18:05:32 +0100 Subject: ADO 2.5 connection problem References: <3975D66D.8B5F46A2@NameConnector.com> Message-ID: Totally brilliant. Thanks! I thought that the Python interface to win32com was case insensitive unless you did early binding - which I wasn't. Also why did this work on 2.1? But what a daft fucking error message. God knows what's going on inside for it to come up with that message. I have wasted so much time on this. There should be a law against wasting people's time with daft error messages. My favourite is 'Internal error' with a 'details' button. Click on the 'details' button and it says 'Internal error'. Which I didn't think was much more help. There's also a good one you can get out of Lotus Notes which is: "!" Priceless! Thanks again for the help. -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Geoff Talvola wrote in message news:3975D66D.8B5F46A2 at NameConnector.com... > Dale Strickland-Clark wrote: > > > I've just knocked up a JavaScript equivalent of this as a Windows Scripting > > Component and it works a treat. > > > > Is it me or is Python Win32Com doing something stupid? > > Both :-) You need to use rs.Open, not rs.open. Case matters. The error > message is about as misleading as can be, though. > > Incidentally, I use the following to create a connection to an Access db: > > db = win32com.client.Dispatch("ADODB.Connection") > db.Mode = win32com.client.constants.adModeReadWrite # if we want to be > able to write > db.Provider = 'Microsoft.Jet.OLEDB.3.51' > db.Open(dbfile) > > I don't know if there are any advantages or disadvantages compared to what > you're doing, but who knows, it may help you out somewhere down the road to know > this method... > > -- > > > - Geoff Talvola > Parlance Corporation > gtalvola at NameConnector.com > > From dcalvelo at pharion.univ-lille2.fr Wed Jul 19 05:16:00 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 19 Jul 2000 09:16:00 GMT Subject: Using filter() References: <8l1o9h$pto$1@news.rchland.ibm.com> <8l256r$d7n$1@netserv.univ-lille1.fr> <8l2g53$14ha$1@news.rchland.ibm.com> Message-ID: <8l3rkg$e9m$1@netserv.univ-lille1.fr> Larry Whitley wrote: : Thanks, that certainly works. : I don't understand why lambda needs the second parameter. When I : experiment with : : filter( lambda x: string.find( x, name) == 0, fileList) : : in place of : : filter( lambda x,sf=string.find: sf(x, name )==0, fileList ) : : it works as well. I suspect that your codeing come from something more : general. Can you explain the reason the sf=string.find construction is : useful in this context? Doing the sf=string.find trick saves one name lookup. I have, with fileList being a list of 10000 "abc" and 10000 "bbc": >>> import time >>> tic=time.clock(); None=filter( lambda x: string.find( x, "a") == 0, fileList); time.clock()-tic 1.92 >>> tic=time.clock(); None=filter( lambda x,sf=string.find: sf( x, "a") == 0, fileList); time.clock()-tic 1.14 (These are typical timings on my machine with Python1.5.2 and have nothing but illustrative purposes.) Besides, it's "safer" in a sense: It works for you because 'string' is a global or module global. But if you do stg like: def a(): import string return filter( lambda x: string.find( x, ) == 0, ) then 'string' is *not* looked up in a's namespace, whereas it is with the other trick. I wouldn't recommend such practices anyway but who knows. You might want to have a look at Skip Montanaro's Pyhton Performance Tips at http://www.musi-cal.com/~skip/python/fastpython.html HTIU Python-42K-will-have-nested-namespaces!-really!-ly y'rs, Daniel -- Daniel Calvelo Aros calvelo at lifl.fr From aruth at intercation.com Sat Jul 1 12:56:16 2000 From: aruth at intercation.com (Adam Ruth) Date: Sat, 1 Jul 2000 10:56:16 -0600 Subject: Communicating between two computers References: Message-ID: <8jl7uu$ve3$1@news.aros.net> You can run Python as an NT service quite simply using the brilliant PyWin extensions. There's an exe called pythonservice.exe that handles all of the nasty details. Running a service has never been simpler. You can easily implement BaseHTTPServer within a service. -- Adam Ruth InterCation, Inc. www.intercation.com "Moshe Zadka" wrote in message news:Pine.GSO.4.10.10007011639300.17559-100000 at sundial... > On Fri, 30 Jun 2000, donotspam-jen at personic.com wrote: > > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > Have a look at my signature: like most everything I say, it is only half > a joke. Python on two computers talking in plain old HTTP is a powerful > concept. Just derive from BaseHTTPServer on one end, and implement only > the do_GET() method, and use urllib at the other end to transmit requests. > > Both our inhouse build and backup systems are built (more or less) on > these principals. > > I have no idea if you can run a Python script as an NT service: I'll leave > that to those who know windows. > -- > Moshe Zadka > There is no GOD but Python, and HTTP is its prophet. > > From rhicks at rma.edu Sat Jul 15 12:29:01 2000 From: rhicks at rma.edu (Robert) Date: Sat, 15 Jul 2000 16:29:01 GMT Subject: Getting local IP address... References: <8ko8qr$7cd$1@nnrp1.deja.com> Message-ID: >>> import socket >>> ip = socket.gethostbyname(socket.gethostname()) >>> print ip works for me... Robert "Stephen Hansen" wrote in message news:8ko8qr$7cd$1 at nnrp1.deja.com... > How do I go about getting my dynamic IP address? I want to make a > little program to check periodically (daily or so) and log the results > so I can determine how often my IP is getting shuffled. :) > > Thanks :) > > --Stephen > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From guido at beopen.com Fri Jul 7 18:41:15 2000 From: guido at beopen.com (Guido van Rossum) Date: Fri, 07 Jul 2000 17:41:15 -0500 Subject: Python release delay Message-ID: <200007072241.RAA05858@cj20424-a.reston1.va.home.com> CNRI's Bob Kahn has this message for the Python user community: > "As a result of the recent transition of the Core Python development > activity from CNRI to BeOpen, a number of issues have arisen that CNRI and > BeOpen are in the process of working out. As soon as these are resolved, > which we hope will be very shortly, we plan to have the final version of > Python 1.6 available for download. We apologize for this delay, but > hopefully, it will not last long and will ultimately put the future python > evolution on a more solid foundation. In the meantime, BeOpen and CNRI will > also be working together on updates to the python.org website, and bug > reports, patches and other contributions to Python 1.6 should continue to > be submitted to CNRI following the procedures posted at the python.org site." --Guido van Rossum (home page: http://dinsdale.python.org/~guido/) From richard_chamberlain at ntlworld.com Sat Jul 22 02:43:11 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sat, 22 Jul 2000 07:43:11 +0100 Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <39793A4D.A3D8995F@myself.com> Message-ID: <5lbe5.2672$k54.49457@news6-win.server.ntlworld.com> It works either of the following ways: 'c:\\windows\\autoexec.bat' r'c:\windows\autoexec.bat' 'c:/windows/autoexec.bat' Richard Wayne Izatt wrote in message news:39793A4D.A3D8995F at myself.com... > Just a guess, since I don't know much about Windows, but isn't the '/' meant > to be a '\'? > > cheers > > Jack wrote: > > > Hey there, > > > > im pretty new to using python, and im just experimenting with file access, > > a wrote a script that works fine, and then all of a sudden it started > > throwing up this error: > > > > inp = open("c:/autoexec.bat",'r') > > TypeError: illegal argument type for built-in operation > > > > it was working fine before, and i dont see anything unusual in the syntax. > > > > Any help would be appreciated, > > > > Cheers, > > > > Jack Green > From see at below Thu Jul 6 00:25:58 2000 From: see at below (Paul Foley) Date: 06 Jul 2000 16:25:58 +1200 Subject: Random number generation, simple question. References: <8F6665DDDbeablebeable@207.211.168.82> Message-ID: On 3 Jul 2000 16:41:54 GMT, Mitchell Morris wrote: >> * How many random bits does whrandom.random() generate? > I don't have the references from whrandom handy, but (a) I can flip through > my Knuth book (flip, flip, flip) to see that there are several constants by > which you can get an LCM to generate 2^32 values each of which could be 32 > bits long, and (b) Wichmann-Hill is rather more advanced than an LCM, so 32 > *2^32 should be considered a reasonable lower limit. Since you only need 80 > or so, you should be okay. [and, later] > The long answer is you can't generate randomness from nothing, which is Right...so how do you get 2^37 bits (or did you mean only 37 bits?) out of whrandom, which only has 24 seed bits? Sequence length is not the point: obviously you can't get more than 24 bits of entropy into the thing (and typically a lot less than that), so you obviously can't get more than 24 bits _out_; and you won't get as much out as you put in. > It's been a while since I looked at CipherSaber, but as I recall you only > need entropy for the session key. You will probably find that almost any > silly stupid PRNG will suffice for that, and most operating systems will Not if you care at all about security. -- Nomina stultorum in parietibus et portis semper videmus. -- Cicero (setq reply-to (concatenate 'string "Paul Foley " "")) From pehr at pehr.net Wed Jul 12 01:51:31 2000 From: pehr at pehr.net (pehr anderson) Date: Wed, 12 Jul 2000 05:51:31 GMT Subject: Sound module question References: <396BBA07.E844152@bresnanlink.net> Message-ID: <396BC08E.A3C036A4@pehr.net> I've started mucking around with sound and have seen the os.system command work well for most of my needs. import os os.system("esdplay file.wav") Redhat and Gnome like to use the Enlightenment sound daemon. NOTE: It isn't always started by default. To start the daemon just run "esd" as the user (you don't need to be root). The RPM included with Redhat-6.2 is esound-0.2.17-2.i386.rpm I've upgraded my system with Helix gnome so my esound rpm is esound-0.2.18-1_helix_1 Esound includes the the "esdctl" command to cache wav files for quick playback or looping. If you run these through os.system that should be fast enough for most of your needs. I'm sure there are better ways to talk to the esound daemon, but this was *very* easy. Here is the help for esdctl: [pehr at morseall pehr]$ esdctl esdctl error (1): command line - not enough arguments esdctl [options] [command] options: -s, --server=host:port contact esd server on host at port commands: lock foreign clients may not use the server unlock foreign clients may use the server standby, off suspend sound output for other programs resume, on resume sound output cache sample cache a sample in the server getid name retrieve a sample id from its name free name uncache a sample in the server play name play a cached sample once loop name make a cached sample loop stop name stop the looping sample at end serverinfo get server info from server allinfo get player and sample info from server panstream set panning for a stream pansample set default panning for a sample - left/right pan values scaled to 256. standbymode see if server's on standby, etc. Aaron Berg wrote: > > I started programming python a few months ago and I am still learning. > Does anyone know of a sound module for simple reading and writing of > sound in linux? I know there is a win32 sound module and there is one > for SGI but is there one for linux? oss or alsa... I don't know much > about this issue so it is possible i am just looking in the wrong place. > Thanks, > Aaron From mikeq at my-deja.com Tue Jul 11 08:42:49 2000 From: mikeq at my-deja.com (mikeq at my-deja.com) Date: Tue, 11 Jul 2000 12:42:49 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> Message-ID: <8kf4o5$fao$1@nnrp1.deja.com> Do you know where I can get information on Microsoft's IL? Thanks, In article , "Neil Hodgson" wrote: > Now that Microsoft have revealed their Intermediate Language (IL) virtual > machine, are we going to see a version of Python that compiles directly to > IL? Or will Python byte codes still be interpreted by C code? > > Neil Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Mon Jul 3 10:28:21 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jul 2000 14:28:21 GMT Subject: Memory leaks References: <395F78BF.CBEAA090@synacon.ch> Message-ID: <8F6667253gmcmhypernetcom@199.171.54.154> Ingo Adler wrote: [strange leaks in SWIG'd code] >I have some simple Python-Code which generated memory leaks (ca. 4MB): >(The real code is more complicated, but I could strip it down to this >simple example = the smallest example with the memory leak.) >//--------------------------- >x = X() > >for i in range(100000): > y = x.getY() > y.getNumber() >//--------------------------- Doing things in the "obvious" way from your (snipped) incomplete code, I get no leak when using MSVC 5. - Gordon From richard at cogsci.ed.ac.uk Sun Jul 16 15:35:41 2000 From: richard at cogsci.ed.ac.uk (Richard Tobin) Date: 16 Jul 2000 19:35:41 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> Message-ID: <8kt2qd$22i7$1@pc-news.cogsci.ed.ac.uk> In article <8kq8kc$guk$1 at nnrp1.deja.com>, wrote: > So it's something like the value of infoset.__class__ >changes when you call infoset.validate(schema)? Very like that - it's changing the class of some objects in the infoset, not the infoset itself. >but I really don't see the point >to changing the class of the object instead of just constructing >a new object. None, except to directly model the XML Schema specification which talks in terms of adding properties to info items in an existing infoset. > Like you pass a WellFormedInfoset to something >or call some method of one and get back an instance of a >subclass of ValidInfoset. Some other XML transformations (eg style-sheet application) are defined as infoset->infoset functions in that way, but this one isn't. Sometimes the aim of a program isn't (or isn't just) to calculate a result reliably, but to do it in a particular way to illustrate and explore an algorithm. -- Richard -- Spam filter: to mail me from a .com/.net site, put my surname in the headers. "The Internet is really just a series of bottlenecks joined by high speed networks." - Sam Wilson From aahz at netcom.com Thu Jul 6 12:07:41 2000 From: aahz at netcom.com (Aahz Maruch) Date: 6 Jul 2000 16:07:41 GMT Subject: job offer References: <8k2a7p$mi71@imsp212.netvigator.com> Message-ID: <8k2asd$gin$1@slb0.atl.mindspring.net> In article <8k2a7p$mi71 at imsp212.netvigator.com>, Netvigator wrote: > >First of all, sorry for posting something not related to the Python >language. However, I've got a good news for those living in Hong Kong or >wish to come to Hong Kong. Cos, my company is now recruiting Python >programmers. It's not easy to find Python people in Hong Kong. My company is >developing some WAP applications based on ZOPE. I'm sure you will find the >challange in my company. If you want to know more or want to arrange an >interview, please contact me thru nicklo at computer.org . This is actually related; having jobs available boosts acceptance of Python! However, you might try getting your posting up at http://www.python.org/Jobs.html Unfortunately, I've heard that the updater of the above URL hasn't been responsive lately. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "do you want my self-identities alphabetically, chronologically, or in random order?" -- Misha From hzhu at knowledgetrack.com.bbs Wed Jul 12 15:30:10 2000 From: hzhu at knowledgetrack.com.bbs (hzhu at knowledgetrack.com.bbs) Date: 12 Jul 2000 19:30:10 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bNRMX$lns@openbazaar.net> We are at a crucial juncture concerning introduction of new operators into Python for matrix computation, 1. Experiences with Matlab show that different operators for matrix and elementwise operators are very important 2. It is difficult to add .* and ./ as . is already a valid token. It seems that next candidate on the standard keyboard is @. 3. Gregory Lielens has just implemented a patch that could parse additional operators containing @ a at b is equivalent to a*b, overloaded using __mmul__ and __rmmul__ a@/b a/b __mrdiv__ and __rmrdiv__ a/@b b/a __mldiv__ and __rmldiv__ a@@b a**b __mpow__ and __rmpow__ He indicates similar constructions can be added easily. We intend to add these operators together with Thomas Wouters's augmented assignment operators (+=,*=, etc) to MatPy, but before that several decisions need to be made. First, the main choices: 1. Use a*b as matrix mul, and a@*b as elementwise mul. Pros: - Consistent with Matlab. - Consistent with current MatPy. - Convenient for matrix computations. Cons: - Inconsistent with NumPy - How to differentiate left and right div (matlab a\b and a/b)? 2. Use a@*b as matrix mul, and a*b as elementwise mul. Pros: - Consistent with NumPy - Can use a@/b and a/@b as matlab a/b and a\b. - Can use a at b as inner product so that a at b works irrespective of whether a and b are row or col operators. Cons: - Inconsistent with current MatPy. Need great effort to switch. - Using two symbol operator for matrix mul is cumbersome for long formulas. - It kind of looks ugly. 3. Use a at b as matrix mul, and a*b as elementwise mul. This has most of the pros and cons of choice 2, except Pros: - Single symbol operators for matrix mul and element mul. Cons: - Can't use a at b as inner product. Just to add to the agony, here are a few contrary views: 1. Consistency with Matlab is not necessarily good. In Matlab operators default to matrix (cf * and .*) but functions default to elementwise (cf exp and expm). In Python ** is defined by __pow__. Should it be consistent with pow the function or ** the operator? 2. Consistency with NumPy is not necessarily good. Currently one can use MatPy and NumPy at the same time. a*b will be matrixwise for MatPy and elementwise for NumPy. This is convenient when each usage is dominant in some part of a program. Removing this difference and MatPy will lose a lot of appeal when it is needed. 3. Although it is relatively difficult to switch the usage in MatPy, it is still a good time if we deem this to be A Good Thing. When the status is changed to beta from alpha it would be next to impossible to switch. To throw you completely off the track, here is one additional feature request that would great please mathematicians and greatly annoy computer scientists: Use ^ and @^ for matrix power. Currently ^ is defined as xor which is of sufficiently low level that is unlikely to occur with matrix computations. Note that this is not in our plan right now. One other thing that will be of great efficiency value (whenver somebody comes forward to do it) is to parse := as assignment. This way we can let a=b be simple reference assignment without creating a new Matrix object. The implementors of both previous patches have cautioned that Guido is unlikely to adopt the patch for the .* or @* operators. But I'm quite confident that he can be persuaded. There is a large number of users of Matlab and Octave (maybe even more than users of Python), and there is no fundamental reason they cannot use Python for doing the same thing, provided that we are allowed to add this little additional operator. :-) What other incentives are needed to persuade Guido? Here's a quote from Gregory, > they make a huge difference in readability of code dealing with linear > algebra, in particular when using small matrices. Such operators explain > partly the popularity of Matlab-like tools, imho. I can argue that linear algebra is very important for Python, perhaps even more important than complex numbers, but this is off topic. So all your comments, suggestions and flames a invited. I just have a small request: As this is getting too long, please reply separately to different parts of this article, so that the discussion threads remain manageable. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From ben at co.and.co Sat Jul 8 13:12:13 2000 From: ben at co.and.co (ben at co.and.co) Date: Sat, 08 Jul 2000 17:12:13 GMT Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> Message-ID: Danny Yee wrote: > I need to convert text with ISO Latin characters to HTML, e.g. > I want to map ? to é and so forth. > > I can do this by reading in a wopping big file > ('?', 'À'), > ('?', 'Á'), > ('?', 'Â'), > ('?', 'Ã'), > . > . > > and then going > for pair in fix_list: > line = re.sub(pair[0], pair[1], line) > as I read each line... but there has to be something quicker than that, > surely. Is there a fast way to do this? Just reverse the dictionnary, to be found in htmlentitydefs. Greeetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From cut_me_out at hotmail.com Sat Jul 29 13:55:49 2000 From: cut_me_out at hotmail.com (Alex) Date: 29 Jul 2000 13:55:49 -0400 Subject: cStringIO & write error? References: <8F80A1458seed7@212.120.66.218> Message-ID: > When I do: > > from StringIO import StringIO > f=open('file.dat', 'r+b') > ff=StringIO(f.read(-1)) > ff.seek(0,0) > ff.write(chr(123)) > > all is ok. But when I import from cStringIO I get an error: > [snip] > AttributeError: write > > What am I doing wrong? Probably nothing -- I ran into a similar incompatibility between cStringIO and StringIO a little while back. I think I got around it by doing stuff like this: >>> from cStringIO import StringIO >>> t = StringIO() >>> t.write('stuff') >>> t.seek(0) >>> t.read() 'stuff' Alex. From matthias.huening at univie.ac.at Wed Jul 5 04:21:56 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Wed, 5 Jul 2000 10:21:56 +0200 Subject: Undocumented regex behaviour in re module References: Message-ID: <8jur8r$3eqe$1@www.univie.ac.at> What about a simple regex and the use of string.split()? -------------- tags = re.compile(r"<\?(.+)\?>", re.I | re.M) match = tags.search(text) while match: print text[match.start():match.end()], \ '=>', string.split(match.group(1)) match = tags.search(text, match.end()) -------------- Matthias - - - - - matthias.huening at univie.ac.at http://www.ned.univie.ac.at/ From olivierS.dagenaisP at canadaA.comM Sun Jul 16 15:59:42 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sun, 16 Jul 2000 19:59:42 GMT Subject: Why make a language case sensitive? References: <000801bfeda1$fcd99a20$6cb745c6@timaratz> <%%Rb5.109206$HK2.1930096@news20.bellglobal.com> Message-ID: > It is a typical god side of an MS product, total integration with total > benfit, a pitty thought that the interface is less good than Borland's... I can't say I have used anything of Borland since BC 4.5, I think. I have seen cool features in some GUI builders and IDEs that aren't in VB6, so I have an idea of what you are talking about. "Boa Constructor" http://boa-constructor.sourceforge.net/ ), an IDE for Python seems to make a good effort to implement features typical of recent technologies, although it is still in "Pre-Alpha" but very promising. > Another solution is to be really smart and figure the flow of the > program and determine when a variable is first used and color that > color1 and the next time it is used it is colored color2... I think this [figure the flow of the program] is what VC6 attemps to do with C/C++ code (and that's a pretty expensive calculation) and it's a pity the compiler will [most likely] just end up re-doing the work when you hit "Build", as opposed to something totally integrated like VB... > > Where the variables are declared in the form of a comment that starts with > > the letters "var" which, I think, is how JavaScript declares variables, > > isn't it? > it is said the man who knew the language inside out :-) I'm sorry, I don't follow... > > So, by having a line at the beginning of a function (right after > > the description line, which I hope I didn't screw up) indicating the names > > of the variables we intend to use, any name that isn't in that list and > > isn't in anything we imported would be highlighted as a mistake, and if only > > the case differs, the editor would make the case match the declaration... > The only problem is that it turns Python ugly... Does it? Wouldn't it help whoever was reading your code to better understand where the scope of the variables are, and what you intend to do? I'm reminded of assembler, where it is good practice to comment which registers you will be "destroying" and which you will be using. It saves someone from looking at each line of code to figure it out.... > I know it is a problem, I will however try to enforce it in our > concern, and one might design a devoloping tool that enforced a > naming convention, that could be dfined by the user. ...or a variable declaration convention defined by the user??? : ) You wouldn't HAVE to use the "# var", maybe you're like me and you come from a VB background and you'd rather use "# dim"? > Once you get used to it it really isn't much of a worry I realized today my version of PythonWin (125) wasn't recommended as being the one to use for auto-completion and other nice features, so maybe it already does everything I want it to and my whole rant is moot?? I didn't think PythonWin was as nice as SciTe, in terms of syntax highlighting, so I switched, but now that I look at PythonWin 132, I'm impressed! Maybe I *do* have everything I want. > there is only one thing in this world that makes me wonder: why are all > the beautiful languages run time parsed? (i here think primarily on > Python and Java) Only ONE thing? Wow. You must know the answer to life, the universe and everything, then? And the question, too? If it were up to me, this language would have been called "42"... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From alex at magenta.com Thu Jul 6 07:32:39 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 6 Jul 2000 13:32:39 +0200 Subject: function arguments References: Message-ID: <8k1qvf07rm@news1.newsguy.com> Johannes Zellner wrote in message news:Pine.LNX.4.21.0007061257160.17492-100000 at krispc6.physik.uni-karlsruhe.d e... > > Hello, > > is there a way to get a functions argument list ? > > e.g. > > def fun(fred, lola): > ... > > something like `arglist(fun)' should return [ 'fred', 'lola' ] >>> def fun(fred, lola): ... pass ... >>> def arglist(fun): ... return fun.func_code.co_varnames ... >>> arglist(fun) ('fred', 'lola') >>> It returns a tuple rather than a list, but that's easy to remedy in the unlikely case it matters to you, of course. Alex From ovyxqf at hotmail.com Mon Jul 10 13:29:01 2000 From: ovyxqf at hotmail.com (ovyxqf at hotmail.com) Date: 10 Jul 2000 17:29:01 GMT Subject: I Didnt Know Id Been Date-Raped til the Check She Gave Me Bounced! 6167 Message-ID: <963250141.887982@eagle.marka.net.ua> http://www.mazepath.com/underground/hankins "What a sad commentary on Mensa and Mensans that ... a crude, insensitive, boorish, untalented brute like Bailey Hankins can get his ... garbage printed in so many of our publications. What on earth are our editors thinking?" Norma MCGovern Phoenix, Arizona uujgmysyerqh From zo at angband.org.bbs Mon Jul 17 17:30:03 2000 From: zo at angband.org.bbs (zo at angband.org.bbs) Date: 17 Jul 2000 21:30:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRQ4R$mrn@openbazaar.net> Charles Boncelet writes: > Let's get some facts (yes, I know we are not supposed to let facts > interfere with our arguments on usenet): [Relative popularity measurements deleted.] These metrics are meaningless. You're comparing the popularity of Matlab, the most popular tool for its problem domain (numerical computing), to Python, which (unfortunately) isn't even close to the most popular tool for its problem domain (general-purpose scripting and programming). I'd imagine that establishing that there is a high level of interest in this domain would be a prerequisite for convincing anyone to add the desired features. But your metrics don't tell us anything at all about the relative level of interest in the numerical computing domain, and are thus useless for your apparent purpose. Compare Python+Perl+Tcl+Java+C+C++ to Matlab+(Any other languages targeted towards the numerical computing problem domain. Mathematica?), and you might have something half-worthwhile. Eric From pauljolly at my-deja.com Mon Jul 31 04:47:02 2000 From: pauljolly at my-deja.com (pauljolly at my-deja.com) Date: Mon, 31 Jul 2000 08:47:02 GMT Subject: Extracting search criteria using re Message-ID: <8m3ee5$fh5$1@nnrp1.deja.com> Dear All, I am using the re module to search for a particular string in an html file (not within the tags but within the page material). This question is more about regular expression technique more that anything. I have read the manual on regular expression but cannot seem to find anything that answers my question: when using the (recompiledobject).split() method, I want to return a list of all the occurences of my search criteria and not what remains when my search criteria is stripped from the string. For example, searching using the following search string: \d?\d\s*'°' in the following: "This is an example of two temperatures 56 ° F and 36 ° F." Applying the split function on the above, I would want to return as a list ('56 °', '36 °'). I am sure this is possible but cannot for the life of me find the answer. Any help much appreciated. Regards, Paul Jolly Sent via Deja.com http://www.deja.com/ Before you buy. From cjensen at bioeng.ucsd.edu Sat Jul 1 20:11:59 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Sat, 01 Jul 2000 17:11:59 -0700 Subject: Python MP3 Player References: <395CE50A.3BA16777@bioeng.ucsd.edu> <20000630232210.A1287@novara.avenue> Message-ID: <395E88CF.47236484@bioeng.ucsd.edu> Michael Hudson wrote: > > > Righty ho; find it here: > > http://starship.python.net/crew/mwh/hacks/ > > no docs, no guarantees, no restrictions. Comments appreciated. > > Cheers, > M. > > -- > The use of COBOL cripples the mind; its teaching should, therefore, > be regarded as a criminal offence. > -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5 Thanks very much. Though, I was asking, because xmms isn't vary stable on our systems (SGI IRIX 6.5). I figured that if there was a Python MP3 Player, then it'd probably work on our systems. Your module is interesting, though it doesn't fix my problem. :( -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From walter111 at structurex.net Thu Jul 6 03:45:57 2000 From: walter111 at structurex.net (walter hanagriff) Date: Thu, 06 Jul 2000 02:45:57 -0500 Subject: tkinter frames problem Message-ID: <39643935.3DF3FF3C@structurex.net> it has been over a week since i posted this message with no response while i see most others get an answer the same or next day, so i reposted, i hope thats acceptable, or should i wait longer? am i missing something to this letter that makes the problem unanswerable? because i sent it in once without source and one person finally told me to provicde the source with my problem so i did and i got no responses to it, any advice for getting more help will be greatly appreciated this is just a framework i am using as a simplified test case for adding tkinter to my main program The first class makes the first frame of the program giving the user 3 options, whichever option he chooses opens up a second frame from the second class, but they just keep piling up i want it so that if an options frame is there when they pick another frame, the first options frame will disappear. i can easily delete the main frame from the Main class, but dont know how to call the frames from the defs in the second class, whether i try to call them from Main or Step2, so how do i make what i want happen i think that best explains what i want, any help would be appreciated from Tkinter import * # this class makes the main frame and which frames are opened class Main: # this function makes the first frame for the program def __init__(self, root): Label(root, text = "this program figures the area, perimeter, and power of n \n" "____________________________________________").pack() self.v = IntVar() self.v.set("1") Radiobutton(root, text = "1 = Find the power of a number", variable = self.v, value = 1).pack(anchor = W) Radiobutton(root, text = "2 = Find the area of a shape", variable = self.v, value = 2).pack(anchor = W) Radiobutton(root, text = "3 = Find the perimeter of a shape", variable = self.v, value = 3).pack(anchor = W) next = Button(root, text = "Next", padx = 10, command = self.func.frame2) next.pack(side = LEFT, padx = 5) close = Button(root, text = "Close", padx = 10, command = root.destroy) close.pack(side = LEFT, padx = 5) # this says which frame to open depending on which radiobutton above is picked by user def ifpick(self): if self.v.get() == 1: self.func.frame2() if self.v.get() == 2: self.func.frame3() if self.v.get() == 3: self.func.frame4() # This class makes the frames for each function class Functions: # this frame is for the power of a number, radiobutton option v == 1 def frame2(self): Label(root, text = "this frame is where you put information to get power of n \n" "______________________________________________").pack(side = TOP) # this frame is for the area of a shape, radiobutton option v == 2 def frame3(self): Label(root, text = "this frame is where you put information to get the area of a shape \n" "______________________________________________").pack(side = BOTTOM) # this frame is for the perimeter of a shape, radiobutton option v == 3 def frame4(self): Label(root, text = "this frame is where you put information to get the perimeter of a shape \n" "______________________________________________").pack(side = BOTTOM) if __name__== '__main__': root = Tk() root.title(title) start = Main(Toplevel) root.mainloop() From lull at acm.org Thu Jul 20 01:22:06 2000 From: lull at acm.org (John Lull) Date: 20 Jul 2000 00:22:06 -0500 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> Message-ID: Huaiyu Zhu wrote (with possible deletions): > I really like this kind of ideas. Anyone able to implement it? It should be near-trivial to implement as part of the core. If I thought we reach some sort of consensus it was the "right" way to do it, I'd love to try. So far, I don't see such a consensus developing. > What it > takes to change a patch of grammar to an importable module? This, I suspect, is pretty difficult. > Maybe the way to do it is to change the python implementation of operator > into an object oriented approach? Similar to PyObject we'll have a > PyOperator which defines the symbol, name, scoping and precedence rules. > This way handling operators within python would be similar to hadling > ordinary objects, by import NewOperator. To discourage abuses there may be > restrictions on what is allowed as symbols and what precedence rules are > allowed and so forth, and perhaps prohibit dynamic changes within an > importing module. (Note -- I haven't looked at the Python internals. The following is based on my experience using the language, & reading about it. If I've misunderstood something here, please feel free to correct me.) The problem I see with it is as follows: The Python compiler can tell just by lexical analysis what is a function, what is a standard operator, what is a keyword, what is a constant, etc. It doesn't need an import statement to know that a.bizarremethodname(b) is supposed to be translated to a call to bizarremethodname() on object a. If you require an import statement for the compiler to distinguish operators from other language elements, you've just made a truly fundamental change in the way Python works -- because import statements get compiled into bytecode, but don't get *executed* until runtime. By that time the compilation is done, but you want the import statement to change something that already happened. That clearly doesn't work. You could, of course, define a completely different import-like mechanism, which would be handled at compile time, to deal with these issues -- but your resulting NewOperator wouldn't be terribly like a standard Python object. (In the following, '..newOp..' etc. are just a sample of what *might* be done. I'm not married to the notation, nor am I suggesting it as in any way optimum.) To add operators to the language at run time, you would need to define them in such a way that the compiler could recognize them as operators without knowing anything it won't know until runtime. The compiler would also have to be modified to handle them appropriately. You could, at least in theory, do something like: a..newOp..(b..otherOp..c) and have the compiler translate it into: a.__newOp__(b.__otherOp__(c)) simply because it could recognize [.][.][a-zA-Z][a-zA-Z0-9]*[.][.] as the standard definition of a user-defined binary operator. It could compile the statement correctly without knowing whether object 'a' even implemented the operator. With a bit of extra work, you could probably even make the run-time execute the above as b.__otherOp__(c).__rnewOp__(a) if it turned out __newOp__() was not defined for object a, but __rnewOp__() was defined for the result of b.__otherOp__(c). What you would lose this way is: 1. Any notion of precedence or associativity for these operators. Changing the definition to give the compiler this information would likely leave you with something pretty error prone. You're likely going to have to provide parentheses in your code anywhere simple left-to-right evaluation is not appropriate. 2. It's not obvious to me how you could make such operators handle short-cut evaluation as the standard boolean operators do. Whether this is important or not, I don't know. Probably not terribly. 3. Frankly, expressions written this way just don't look right to me. Once you know what .* means, 'a .* b' is just easier to read than 'a ..eMul.. b'. What you would gain is: 1. An unlimited supply of domain-specific binary operators. 2. Operators can make sense to someone who knows little or nothing about the domain. He doesn't need a reference to find out what '.*' means. 3. Operator notation anywhere it's clearer than functional notation. 4. Functional notation anywhere it's clearer than operator notation, *without* having to write separate operator handlers and functions. Regards, John From tim_one at email.msn.com Fri Jul 28 21:48:29 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 28 Jul 2000 21:48:29 -0400 Subject: Perl is worse! In-Reply-To: Message-ID: [Grant Edwards] > ... > I guess I never looked into the details in Python (haven't done much > numerical stuff yet). I had sort of assumed that floating point > values were 32 bit, but if they're 64, then as you say, the problem is > postponed until long ints are involved. A Python float is a C double, which on all Python platforms I know of is a 64-bit format, and on almost all conforms to IEEE-754 so has 53 bits of precision (so all integers i with abs(i) <= 2.**53 are exactly representable, and note that "<=" instead of "<" is not a typo despite your first impression ). A Python int is a C long, and that varies more widely. On most platforms that's 4 bytes, so conversion to (Python) float cannot lose info. On some platforms it's 8 bytes, though, and conversion to (Python) float *can* lose info on those. There wasn't a lot of thought given to numeric endcases in Python at first, simply because its initial audience did not have many number-crunchers, and building robust portable semantics on top of C is a PITA since K&R C itself was sloppy about its numerics. it's-pretty-accurate-to-call-python's-numeric-policies-"benign-neglect"-ly y'rs - tim From do.not.email at hotmail.com Mon Jul 17 18:25:18 2000 From: do.not.email at hotmail.com (JJ) Date: Mon, 17 Jul 2000 22:25:18 GMT Subject: problems trying wxPython in Win 95 References: <000701bfef98$9f658040$6401a8c0@home> Message-ID: Thanks for the tip. I have Win98 and the wxdemo didn't work. Now I tried again, and in a console window appeared following message: "Can't create window of class wxCanvasClass! Possible Windows 3.x compatibility problem?" In the MS Windows standard error message was "WX21_15.DLL" mentioned. I searched on my hard disk and there were both Wx21_15.dll and Wx21_16.dll. I removed and reinstalled wxPython, and now the demo didn't crash. And the Wx21_15.dll had disappeared. So the problem may be in it. Thanks. "Darrell Gallion" wrote in message news:000701bfef98$9f658040$6401a8c0 at home... > My experience with this isn't recent. > But last I checked wxPython didn't work with 1.6, don't know about 2.0. The > demo will work with 1.5.2. I'd suggest uninstalling wxPython, rebooting and > reinstalling it. I had a problem like this when upgrading from the last > version of wxPython. > From phd at phd.russ.ru Tue Jul 11 11:25:28 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 11 Jul 2000 15:25:28 +0000 (GMT) Subject: POOP / Python (Object Oriented Persistence) ? In-Reply-To: <8kfd7o$2tf$1@desig-bs01-s04.adtranzsig.de> Message-ID: On Tue, 11 Jul 2000, Dirk-Ulrich Heise wrote: > That's my principal problem with all this > persistency stuff - interoperability between > versions of a program. Or is ZODB the first > thing to overcome this, and i missed > something? You missed __setstate__. ZODB is not the first thing that uses this... Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From lull at acm.org Fri Jul 21 08:24:31 2000 From: lull at acm.org (John Lull) Date: 21 Jul 2000 07:24:31 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> Message-ID: <50ggnss2rhdf2uh3pe6m4o1slib9d6fvko@4ax.com> "Rainer Deyke" wrote (with possible deletions): > "John Lull" wrote in message > news:ueefns037mjarv63dqpbh52mmr1k6vvaop at 4ax.com... > > This shouldn't be hard to parse. In fact, it might be a reasonable > > foundation for class-specific operators: > > A(.opName)B > > would get executed as either > > A.__opName__(B) > > or > > B.__ropName__(A) > > or raise an exception as appropriate. > > This would allow constructs such as: > > A(.init)B > > In other words, it would turn all existing __magic__ functions into > operators. Not a good idea IMO. One could easily prevent that by having A(.opName)B invoke A.___opName__(B) instead of A.__opName__(B) or some such. Clearly there's nothing to force use of the same naming convention for these operator methods. Regards, John From me at you.com Thu Jul 6 12:20:05 2000 From: me at you.com (teroc) Date: Thu, 06 Jul 2000 16:20:05 GMT Subject: accessing WAB Message-ID: <3964af8e.15594046@news.earthlink.net> Is it possible to access the Windows Address Book (WAB) via python? I've looked through the various classes/methods of the win32* extensions, along with the various activex(right term?) extensions via the Pythonwin class browser. Running makepy on wab.exe produces nothing (of course user error is possible). What I wish to do is use Python to 'automate' address entry imports into the WAB. Even better if I could pull them from an LDAP server and import them..... but one thing at a time. If anyone has any clues please chare them. Ken From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 16:00:12 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 20:00:12 GMT Subject: Why make a language case sensitive? Message-ID: <3bQYCC$i5z@openbazaar.net> > It is a typical god side of an MS product, total integration with total > benfit, a pitty thought that the interface is less good than Borland's... I can't say I have used anything of Borland since BC 4.5, I think. I have seen cool features in some GUI builders and IDEs that aren't in VB6, so I have an idea of what you are talking about. "Boa Constructor" http://boa-constructor.sourceforge.net/ ), an IDE for Python seems to make a good effort to implement features typical of recent technologies, although it is still in "Pre-Alpha" but very promising. > Another solution is to be really smart and figure the flow of the > program and determine when a variable is first used and color that > color1 and the next time it is used it is colored color2... I think this [figure the flow of the program] is what VC6 attemps to do with C/C++ code (and that's a pretty expensive calculation) and it's a pity the compiler will [most likely] just end up re-doing the work when you hit "Build", as opposed to something totally integrated like VB... > > Where the variables are declared in the form of a comment that starts with > > the letters "var" which, I think, is how JavaScript declares variables, > > isn't it? > it is said the man who knew the language inside out :-) I'm sorry, I don't follow... > > So, by having a line at the beginning of a function (right after > > the description line, which I hope I didn't screw up) indicating the names > > of the variables we intend to use, any name that isn't in that list and > > isn't in anything we imported would be highlighted as a mistake, and if only > > the case differs, the editor would make the case match the declaration... > The only problem is that it turns Python ugly... Does it? Wouldn't it help whoever was reading your code to better understand where the scope of the variables are, and what you intend to do? I'm reminded of assembler, where it is good practice to comment which registers you will be "destroying" and which you will be using. It saves someone from looking at each line of code to figure it out.... > I know it is a problem, I will however try to enforce it in our > concern, and one might design a devoloping tool that enforced a > naming convention, that could be dfined by the user. ...or a variable declaration convention defined by the user??? : ) You wouldn't HAVE to use the "# var", maybe you're like me and you come from a VB background and you'd rather use "# dim"? > Once you get used to it it really isn't much of a worry I realized today my version of PythonWin (125) wasn't recommended as being the one to use for auto-completion and other nice features, so maybe it already does everything I want it to and my whole rant is moot?? I didn't think PythonWin was as nice as SciTe, in terms of syntax highlighting, so I switched, but now that I look at PythonWin 132, I'm impressed! Maybe I *do* have everything I want. > there is only one thing in this world that makes me wonder: why are all > the beautiful languages run time parsed? (i here think primarily on > Python and Java) Only ONE thing? Wow. You must know the answer to life, the universe and everything, then? And the question, too? If it were up to me, this language would have been called "42"... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From m.faassen at vet.uu.nl Mon Jul 31 03:56:40 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 07:56:40 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> <8lvu6d$8pa$2@news.dtc.hp.com> <8m23tv$pqc$1@newshost.accu.uu.nl> <8m2976$p9g$1@news.dtc.hp.com> Message-ID: <8m3bfo$hn2$1@newshost.accu.uu.nl> (Greg Weeks) wrote: > Martijn Faassen (m.faassen at vet.uu.nl) wrote: > : Perhaps there is some other semantics for 'value' and 'reference' stemming > : from another programming tradition that I'm not aware about, though. > There is, but it may wither away as time goes on. I guess I'm trying to > keep it alive. Consider the following snippet of Python code: > def f(x): > x = > a = > f(a) > > At this point in the program, a is still . > On the other hand, in the analogous Perl code, things are different. [snip] > At this point, $a is . The function f did not just receive the > pattern of bits that were written into $a. f received the *address* of the > variable $a, dereferenced it, and called the result $_[0]. So assigning to > $_[0] is the same as assigning to $a. Hm, I didn't work Perl worked like that without explicit dereferencing, but what do I know about Perl. :) I *do* know that Python's behavior is almost exactly the same; what is passed in Python is also the address of object a. But since Python uses addresses all the time, there is no way to change what a points expect explicit assignment, as long as it points to an immutable. The difference seems to be that $a in Perl is in fact *not* a reference but a name for a value directly. So perhaps this is a more subtle and more clear distinction: In Perl, variables are (by default) names for values. But when you pass a variable to a function, the *reference* of this value will be passed, and you can change the *value* to something else. (do I get Perl's semantics right this time?) In Python, variables are names for references. When you pass a reference to a function the only thing that can be changed in the function is the state of the object through that reference; there's no way to change the nature of that object itself (the value). So I'd still say in Python you're passing references around. In Perl the situation is now trickier; what is passed to functions are references to values, but what you manipulate (by default) is the value, not the reference. Assignment in Perl is not name-rebinding; it's value manipulation. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From thomas at xs4all.net Sat Jul 8 13:45:36 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 8 Jul 2000 19:45:36 +0200 Subject: What about try:except:finally In-Reply-To: <39675729.C9E01442@nipltd.com>; from chrisw@nipltd.com on Sat, Jul 08, 2000 at 05:30:33PM +0100 References: <3967d908.363887342@news.online.no> <39675729.C9E01442@nipltd.com> Message-ID: <20000708194536.O26534@xs4all.nl> On Sat, Jul 08, 2000 at 05:30:33PM +0100, Chris Withers wrote: > Alan Daniels wrote: > > >Does python support, or if not, would it be cool to have support for > > >try/except/finally? > > > > No, but just use try/except/else instead. Why it's "else" instead of > > "finally", I have no idea, but this works just fine. Example: > Actually, yes it does ;-) > ...but it does something different. I read the discription on page 50 of > David Beazely's Python Essential Reference, but it didn't make much > sense to me :S The 'else' is called 'else' because it's similar to the 'else' in 'if' clauses and 'for' and 'while' loops: the 'else' clause of a 'try/except' only gets executed when *no* exception occurs. 'finally', however, will alway be called on the 'way out' of the try-block, wether something went wrong or not. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From paul at prescod.net Thu Jul 13 03:41:48 2000 From: paul at prescod.net (Paul Prescod) Date: Thu, 13 Jul 2000 02:41:48 -0500 Subject: Discussion: Introducing new operators for matrix computation References: Message-ID: <396D72BC.A6BA53BF@prescod.net> Huaiyu Zhu wrote: > > We are at a crucial juncture concerning introduction of new operators into > Python for matrix computation, Andrew Kuchling reminded me that there is work under way to make it possible in some post Python 2 timeframe to load custom grammars, compilers and other weird bits into the Python interpreter. That may be your best bet. Guido is pretty allergic to domain-specific syntax. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html From cjc26 at nospam.cornell.edu Fri Jul 21 18:07:25 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Fri, 21 Jul 2000 22:07:25 GMT Subject: Dot-comma, anyone? (Re: zip or marry etc) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <397517C6.93911CF0@prescod.net> <397684EB.3E0C5D88@my.signature> <3977C029.2C1DC8AC@my.signature> Message-ID: * Greg Ewing menulis: | | For one thing, it would make it easier to implement | parallel iteration efficiently. When I write | | for x,y in zip(a,b): | | I'm just trying to express the way the iteration is | to be carried out. I don't really mean that I want the | zip of the two lists to be computed first and then | iterated over. Maybe we could specify that zip() is lazy, like in Haskell, or else define another function called xzip() (parallel to xrange()) which is the lazy version of zip(). -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From donn at u.washington.edu Mon Jul 31 13:07:13 2000 From: donn at u.washington.edu (Donn Cave) Date: 31 Jul 2000 17:07:13 GMT Subject: How does Python compare to ? References: <3FF3ED6EC164DBD2.77C81740D77CD9FA.D247DC7D74D3B365@lp.airnews.net> Message-ID: <8m4bo1$3le2$1@nntp6.u.washington.edu> Quoth claird at starbase.neosoft.com (Cameron Laird): | In article , | Moshe Zadka wrote: | . |> Of course -- heck, even I use CGI for most of my web solutions. The thing |> is, I'm not (currently) a web developer -- so when I have a problem to |> solve, the most important thing for me is how long it takes to set up |> the solution. For that, CGI rocks. However, as soon as you care about |> either performance or about program scalability (IOW, once it's beyond |> a form-to-send-mail and its ilk) (and if you don't, then the only |> difference between Java servlets, PHP-plugin and Python CGI is the |> syntax), the CGI is the most horrible solution available. |> |> CGI requires always a process startup and usually interpreter (be it |> Tcl, Guile, Perl or Python) startup. That makes it unacceptable if there |> are more then 2 hits/second. | . | . | . | I'm stuck. It's going to be hard replying without | invocation of the canard about democracy being "the | most horrible solution available"--except for all | the rest. | | Moshe and I are in agreement on all points, except | that I have customers receiving 20 hits per second | which they're contentedly satisfying with CGI-based | service. Years ago, I thought it was ugly. Now, I | just think I have bigger problems, and let CGI toil | on. The platform could make a difference here, if two web sites were running the same kind of CGI service on different platforms, for example a UNIX host versus some other platform that by reputation has a lot more overhead starting new processes. But it has to be partly the interpreter too. A casual test on FreeBSD 4.0 with Python 1.5.2 against the system shell and various interpreters says Python takes 10 times as long to get started and print out "hello". (This is elapsed time, on an unloaded host where elapsed ~ user+system.) Bash and awk take 2 or 3 times as long, perl is somewhere in between. On my computer here (Intel PII 450mhz), I would guess 20 real Python programs per second, plus httpd, would be past the limit of what we could do. Donn Cave, donn at u.washington.edu From paul at prescod.net.bbs Sun Jul 16 23:30:06 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 03:30:06 GMT Subject: Wishlist sumbission form? Message-ID: <3bQjkU$mP_@openbazaar.net> Matthew Cline wrote: > > Is there any way of submitting feature requests for Python, > other than by filing a bug report? I don't think so. If it is a very targeted request, you could try the but report route. If it is large and arguable, you should probably post it here and get some people to support it. If its good, someone will implement it. In open source software, only the features that developers are interested in get implemented so a wish list might well get ignored anyhow. It's not that nobody cares what you think it's that there's an infinite list of wishes so people tend to attack them in the order in order of personal interest or widespread demand. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From see at message.body Fri Jul 28 01:24:53 2000 From: see at message.body (Sam Penrose) Date: Thu, 27 Jul 2000 22:24:53 -0700 Subject: best apache+python module? References: <20000728113918.B12152@inkontact.com.au> Message-ID: In article <20000728113918.B12152 at inkontact.com.au>, Steve Purcell wrote: > Jason Ives wrote: > > > > I've been looking for an apache module that will run python .cgi's > > without > > having to instantiate a new interpreter for each request. [snip] They > > all > > seem rather sparsely supported.. > > Check out PCGI: > http://www.digicool.com/releases/pcgi > > There's a HOWTO here: > http://starship.python.net/crew/jbauer/persistcgi/howto/index.html > > -Steve After having a Bad Experience with one of these (memory leak in PyApache), I must ask why they are so popular. My company writes pure-Python sites whose CGIs handle tens of thousands of hits a day on unremarkable Intel hardware running vanilla Linux. Two of our CGIs have started to bog down recently, and in both cases the cause is the same: have to generate HTML pages roughly a meg in size; one containing so many images that the number of Apache processes goes through the roof. In neither case would faster Python performance help. Linking your interpreter to Apache forces you into dependence on a chunk of code that has orders of magnitude less testing than either Apache or Python does, probably wouldn't remove any bottlenecks if they existed, and may well break the next time either Python or Apache is updated. Unless, of course, you know differently. But my sense is that most of the people interested in these modules merely know they want their sites to run fast and have read the mod_perl marketing materials. Anyone who can afford 256 megs of RAM and a SCSI hard drive can serve thousands of people a day with sites that execute thousands of lines of Python, without working particularly hard to optimize their software (CGIs or Python or the OS). And if they find they can't, they should not assume that a persistent Python executable will help without having good reason to do so. -- spenrose at well dot com From kmp at atrium.fsnet.co.uk Mon Jul 3 18:08:17 2000 From: kmp at atrium.fsnet.co.uk (Kenneth Payne) Date: Mon, 03 Jul 2000 22:08:17 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> <20000703.19444100@linux.local> <8jqnsu$m79$1@news1.xs4all.nl> Message-ID: <20000703.22081700@linux.local> Boudewijn - Thanks for your interest in my sip problem. I've installed autoconf and automake. This gets rid of all errors except the message about X (if that is an error) but I still get the same probelm on installing pyQT. My configure output for sip now looks like this : loading cache ./config.cache checking for a BSD compatible install... (cached) /usr/bin/ginstall -c checking whether build environment is sane... yes checking whether make sets ${MAKE}... (cached) 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 for a BSD compatible install... /usr/bin/ginstall -c checking for gcc... (cached) 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... (cached) yes checking whether gcc accepts -g... (cached) yes checking for c++... (cached) c++ checking whether the C++ compiler (c++ ) works... yes checking whether the C++ compiler (c++ ) is a cross-compiler... no checking whether we are using GNU C++... (cached) yes checking whether c++ accepts -g... (cached) yes checking for bison... (cached) bison -y checking how to run the C preprocessor... (cached) gcc -E checking for flex... (cached) flex checking for flex... (cached) flex checking for yywrap in -lfl... (cached) yes checking lex output file root... (cached) lex.yy checking whether yytext is a pointer... (cached) yes checking host system type... i686-pc-linux-gnu checking build system type... i686-pc-linux-gnu checking for ranlib... (cached) ranlib checking for ld used by GCC... (cached) /usr/i486-linux/bin/ld checking if the linker (/usr/i486-linux/bin/ld) is GNU ld... (cached) yes checking for BSD-compatible nm... (cached) /usr/bin/nm -B checking whether ln -s works... (cached) yes loading cache ./config.cache within ltconfig checking whether ln -s works... (cached) yes checking for ranlib... (cached) ranlib checking for strip... (cached) strip checking for objdir... .libs checking for object suffix... (cached) o checking for executable suffix... (cached) no checking for gcc option to produce PIC... (cached) -fPIC checking if gcc PIC flag -fPIC works... (cached) yes checking if gcc static flag -static works... (cached) 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 the linker (/usr/i486-linux/bin/ld) is GNU ld... yes checking whether the linker (/usr/i486-linux/bin/ld) supports shared libraries... yes checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking for /usr/i486-linux/bin/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking command to parse /usr/bin/nm -B output... ok checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes creating libtool loading cache ./config.cache checking for the Qt meta object compiler... /usr/lib/qt/bin/moc checking for the Qt include files... /usr/lib/qt/include checking for the Qt library files... /usr/lib/qt/lib checking for X... no checking for -fno-exceptions... yes checking for Python 1.5 include files... /usr/include/python1.5 creating ./config.status creating Makefile creating sip/Makefile creating siplib/Makefile creating sip.spec creating config.h config.h is unchanged If all this seems correct, perhaps the error is in the configure for the PyQT sources. Should I concentrate on that? By the way, I tried installing the rpm for sip, but it requires a later version of libstdc than mine. I get the error : failed dependencies: libstdc++-libc6.1-2.so.3 is needed by sip-0.12-1 It's at least comforting to know that it is possible to run these python / KDE bindings on SUSE 6.3 Thanks again for your interest. Best wishes -- Ken >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 03/07/00, 19:00:46, boud at rempt.xs4all.nl (Boudewijn Rempt) wrote regarding Re: Problem Installing PyQt-012: > Kenneth Payne wrote: > > This looks suspicious in the sip configure output: > > . > > . > > checking for working aclocal... missing > > checking for working autoconf... missing > > checking for working automake... missing > > checking for working autoheader... missing > > checking for working makeinfo... found > > . > > . > > . > > checking for x... no > > . > > . > > Should I be looking to install aclocal, autoconf and automake? Would > > it be easier to install from rpms? > Well, I runs Suse 6.3, too (but compiled both KDE and Qt myself), > and I have no problems compiling PyQt 0.12 either with Qt 1.44 or Qt > 2.1.1, with Python 1.52 or Python 1.6alpha2, and when I compare my > config.log with yours, I notice that I _do_ have aclocal, autoconf, > automake and autoheader - I'd try installing them, they should be in > your distribution. Otherwise, you're the second person I've seen with > those errors - maybe it's something for Phil to look at. > -- > Boudewijn Rempt | http://www.valdyas.org From nobody at nowhere.nohow Wed Jul 26 23:10:17 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Thu, 27 Jul 2000 03:10:17 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: On Thu, 27 Jul 2000 00:32:37 GMT, Steve Lamb wrote: >On Wed, 26 Jul 2000 19:38:55 -0500, Guido van Rossum wrote: >>The announcement is waiting for final negotiations about GPL >>compatibility of the new license; BeOpen's CTO, Bob Weiner, is >>confident that the issue will be resolved one way or another by >>Friday. > > Stupid question: Why is it everyone and their mother is coming out with a >new open source license for their project instead of sticking with the >established ones? The same reasons people keep coming out with new programming languages instead of sticking with the established ones: 1) They can't find an established one that does what they want. 2) It's an interesting intelectual exercise resulting in endless Usenet arguments where there's no chance of the involved parties ever agreeing. 3) It's fun. You probably think I'm kidding about #3, but Joe Public would think that people who like inventing programming languages are at least as weird as people who like to write legal stuff -- and we've got to assume that at least some of the lawyers who practice IP law think it's fun and interesting. -- Grant Edwards grante Yow! Look into my eyes and at try to forget that you have visi.com a Macy's charge card! From mjackson at wc.eso.mc.xerox.com Thu Jul 27 15:41:48 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 27 Jul 2000 19:41:48 GMT Subject: The State of Python References: <8lq20g$kt1$1@nntp9.atl.mindspring.net> Message-ID: <8lq39s$np6$1@news.wrc.xerox.com> aahz at netcom.com (Aahz Maruch) writes: > [posted & e-mailed] > > In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, > Guido van Rossum wrote: > > > >I've placed the slides of my talk at the O'Reilly Open Source > >Convention on-line at our BeOpen PythonLabs website: > > > > http://www.pythonlabs.com/talks.html > > It appears that the HTML version requires JavaScript. That's a Bad Idea. Seconded. And where are these alleged T-shirts? :-) -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson A doctor can bury his mistakes, but an architect can only advise his client to plant vines. - Frank Lloyd Wright From jerome.quelin at insalien.org Mon Jul 3 11:28:30 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Mon, 3 Jul 2000 17:28:30 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> <3960A4D3.F45133B4@muc.das-werk.de> Message-ID: <962638110.1459980735@news.libertysurf.fr> Thomas Thiele wrote: >No I think this is not sooo nice. Becouse I want to replace the widget >with others. What about the pack_forget method ? -- File pack_forget.py #!/usr/bin/python from Tkinter import * class F(Frame): def __init__(self): Frame.__init__(self) Button(self,text='change', command=self.change).pack() self.f1 = Frame(self) self.f2 = Frame(self) Label(self.f1, text='eggs', bg='red').pack(side=LEFT) Label(self.f1, text='spam', bg='green').pack(side=LEFT) Label(self.f2, text='spam', bg='blue').pack(side=LEFT) Label(self.f2, text='eggs', bg='yellow').pack(side=LEFT) self.f1.pack() self.visible = 1 self.pack() def change(self): if self.visible == 1: self.f1.pack_forget() self.f2.pack() self.visible = 2 else: self.f2.pack_forget() self.f1.pack() self.visible = 1 F().mainloop() -- End of file The beauty of pack_forget is that it just unmaps the specified widget, and keeps the internal layout of the widget. Regards, Jerome -- jerome.quelin at insalien.org From loewis at informatik.hu-berlin.de Tue Jul 11 09:10:07 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Jul 2000 15:10:07 +0200 Subject: off-topic, "Compiler" technology References: <396ABBD7.8715465D@t-online.de> <8kf2jf$sqc$1@desig-bs01-s04.adtranzsig.de> Message-ID: "Dirk-Ulrich Heise" writes: > So why doesn't it work for all the > other languages as well? :-) My understanding is that Andreas Otto is still in search for somebody who will fund a Python or Perl compiler; so far, apparently nobody was interested enough, or trusted that Mr. Otto would indeed be able to deliver a compiler offering significant speedup. Regards, Martin From g2 at seebelow.org Sun Jul 30 13:02:11 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 30 Jul 2000 18:02:11 +0100 Subject: Python license (was RE: Python plug-ins for Adobe Products available) References: Message-ID: <39845F93.43AD@seebelow.org> Tim Peters wrote: > > The wrangling itself is a good sign: it means that we (BeOpen PythonLabs) > have been opposing more restrictions. CNRI already changed their license to > the extent that the board of the Open Source Initiative voted to certify it > as Open Source compliant (see definition at > > http://www.opensource.org/osd.html > > ). We also want Python to remain GPL-*compatible*, and CNRI has changed > some of the language in response to Richard Stallman's objections. The following pointed question is directed at CNRI, not you, Tim, but... _Who died and left *Stallman* in charge_? where-i-come-from-'rms'-means-'root-mean-square'---which-ain't-a -bad-discription-of-Stallman,-come-to-think-of-it--ly y'rs, =g2 p.s. Sorry to "discriminate against any person or group of persons" ;-) p.p.s. BTW, as an old-timer, "OSI" means "Ohio Scientific Incorporated" to me -- they made my beloved first computer, the Superboard II. -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From david_ullrich at my-deja.com Mon Jul 24 11:58:18 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Mon, 24 Jul 2000 15:58:18 GMT Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> <8l9qfp$gc6$1@nnrp1.deja.com> <6%_d5.1964$6E.417529@ptah.visi.com> <8lclbq$f6o$1@nnrp1.deja.com> <397BD3E7.38BF914F@my.signature> Message-ID: <8lhp2o$r91$1@nnrp1.deja.com> In article <397BD3E7.38BF914F at my.signature>, Greg Ewing wrote: > You may know already, but I just thought I'd mention > that you can use this trick to make the implementation > of your 2-index __getitem__ function look nice: > > class MyClass: > def __getitem__(self, (x,y)): > ... Thanks. Actually in the one situation where I've actually used these however-many-indicies-it-is things this wouldn't work because I sometimes pass only one index. (M[row] is a row of a matrix, while M[row, col] is an entry. (No, I never heard of NumPy...)) DU > -- > 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 > Sent via Deja.com http://www.deja.com/ Before you buy. From cookedm at physics.mcmaster.ca.bbs Mon Jul 17 22:00:02 2000 From: cookedm at physics.mcmaster.ca.bbs (cookedm at physics.mcmaster.ca.bbs) Date: 18 Jul 2000 02:00:02 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRX62$ja5@openbazaar.net> At some point, hzhu at localhost.localdomain (Huaiyu Zhu) wrote: > On 17 Jul 2000 17:39:33 -0400, David M. Cooke > wrote: > >> Consider the proposal of having two classes, Matrixwise and Elementwise, > >> with methods to cast to each other. I don't know why > >> > >> (a.E()*b.E()).M()*(c.E()*d.E()).M() > >> > >> would be more preferable to > >> > >> (a.*b)*(c.*d) > > > >Well, it doesn't have to be as complicated as your first example. Assume > >the default is Matrixwise, and we get rid of some ()'s by overriding > >__getattr__, so that we can right > > > >(a.E*b.E)*(c.E*d.E) > > > That's a good point. Can __getattr__ be made to work only on a selected > number of attributes? We could use it on T, H, I, C for transpose, > Hermitian transpose, inverse and conjugate. But if it works on all the > undefind members the error message may be too obscure. Any examples? Yep. See code below. > BTW, you meant > > (a.E*b.E).M*(c.E*d.E).M > > for otherwise it is equivalent to (a.*b).*(c.*d). Actually, I was thinking that elementwise multiplication would return an object that does matrixwise multiplication (the idea being that elementwise is a special case, just as .* is used for it instead of * in Matlab). > >But what if we assume that if one operand has .E, the other does also! > >Then we can write > > > >(a.E*b)*(c.E*d) > > This won't work. It would introduce many hard-to-trace bugs. Looking at > > (a*b)*(c*d) > > and you have to trace the program all the way down to figure out the > identities of a,b,c,d. Note that in concept the identities of the objects > do not change. We are changing their identities only as labels to help > picking different operators. I can foresee great confusion in practice with > this approach. I realize this. Note that you have to trace the program to tell that a,b,c,d are matrices anyway :-). A lot of this is removed by always having an operation return a Matrixwise object. Anyways, here's some code that implements what I was talking about. It uses the UserArray and Matrix classes included with NumPy: # matclass.py from UserArray import UserArray from Matrix import Matrix class Matrixwise(Matrix): def __init__(self, data, typecode=None): if isinstance(data, UserArray): UserArray.__init__(self, data.array, typecode=typecode) else: UserArray.__init__(self, data, typecode) def __getattr__(self, name): if name == 'E': return Elementwise(self) else: try: return self.__dict__[name] except KeyError: raise AttributeError, name def __mul__(self, other): if isinstance(other, Elementwise): return Elementwise.__rmul__(self, other) else: return Matrix.__mul__(self, other) class Elementwise(UserArray): def __init__(self, data, typecode=None): if isinstance(data, UserArray): UserArray.__init__(self, data.array, typecode) else: UserArray.__init__(self, data, typecode) def __mul__(self, other): return Matrixwise(UserArray.__mul__(self, other).array) Here's a session: >>> import matclass >>> a = matclass.Matrixwise([[2,3],[4,5]]) >>> b = matclass.Matrixwise([[1,2],[3,4]]) >>> a*b matclass.Matrixwise([[11, 16], [19, 28]]) >>> a.E*b.E matclass.Matrixwise([[ 2, 6], [12, 20]]) >>> a.E*b matclass.Matrixwise([[ 2, 6], [12, 20]]) >>> a*b.E matclass.Matrixwise([[ 2, 6], [12, 20]]) Obviously, this can be extended to include transpose, etc. -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From sill at localhost.kitenet.net Thu Jul 27 20:14:35 2000 From: sill at localhost.kitenet.net (Oldayz) Date: Fri, 28 Jul 2000 00:14:35 GMT Subject: ttyio.py Message-ID: Hello, Anybody knows where I can get ttyio.py? I searched python.org but all results it returned were broken links. -- Andrei From dale at out-think.NOSPAM.co.uk Sun Jul 9 07:38:08 2000 From: dale at out-think.NOSPAM.co.uk (News.tele2.co.uk) Date: Sun, 9 Jul 2000 12:38:08 +0100 Subject: How to use makepy? Message-ID: <8k9o91$7b1$1@supernews.com> Well I've run it and it seemed to work but I'm not really sure what to do next. In fact, I'm not entirely sure what it's supposed to do for me but I'm hoping it will at least give me access to some COM object constants. Where is it documented? Thanks Dale Strickland-Clark From thomas at cintra.no Mon Jul 24 09:05:30 2000 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 24 Jul 2000 13:05:30 GMT Subject: multi-dimensional array ?? Message-ID: <397d3cc8.33972780@news.online.no> Hi, I need to hold x,y,z coordinates in a multi-level grid. How can this be done in Python? From dworkin at ccs.neu.edu Mon Jul 17 21:17:30 2000 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 17 Jul 2000 21:17:30 -0400 Subject: Does Python support interfaces? In-Reply-To: Randall Parker's message of "Tue, 18 Jul 2000 01:08:03 GMT" References: Message-ID: Randall Parker writes: > I'm quite new to Python. For those who are familiar with Java interfaces: > Does Python have a similar facility? > > Can one declare interfaces, then declare that a class implements some > interface, instantiate an object of that class type, and then cast it to > an interface that it is declared to support and then pass it around as a > reference to that interface type and make calls to methods of that > interface type? Better yet, Python doesn't make you do all of that work. Just define the class, and make sure that it provides the proper interface. Note that I'm not using "interface" with any special language-dependent meaning here. If it behaves properly, it behaves properly, and that is all that matters. In any case, it sounds like you should read a little more about Python. There generally isn't any explicit type-declaration, and by extension, casting. "Casting" a Python object is not a very meaningful statement. -Justin From ldw at us.ibm.com Tue Jul 25 16:50:33 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Tue, 25 Jul 2000 15:50:33 -0500 Subject: Memory management References: <8lkdh5$qpm$1@news.rchland.ibm.com> Message-ID: <8lkuiq$qt0$1@news.rchland.ibm.com> Reading through Quick Python. For those who want to get explicit about memory management, it looks like the authors advise saying "object = None" rather than "del object". Is that the correct interpretation? Presumably Python will then call object.__del__() when the garbage collector runs. Larry "Michael Hudson" wrote in message news:m3zon6asl3.fsf at atrus.jesus.cam.ac.uk... > "Larry Whitley" writes: > > > I'm running out of virtual memory on my NT 4.0 system running a longish > > python script. Python says "memory error" and quits. NT shows the > > application using 130+ megabytes. I have 192 megabytes on the system so it > > seems like a rational number. I suspect that this means that I have a > > memory leak in my code. > > > > In the outer loop of my code, I create a object of a class I have defined. > > The outer loop reads records from a trace file and hands them to the object > > created for execution. This first level object creates a number of second > > level objects of a different class while processing the trace file. When > > the trace file is complete, the outer loop deletes the first level object. > > I am expecting that to cause all of the references held by that object, and > > those of the second level objects is created to go to zero. > > > > Here's a programmtic description: > [schnipp] > > My question: How do I get rid of the memory used by o1 and by o1a, o1b, etc > > within o1 when each trace file is processed? > > I'm guessing that you have reference cycles; these can be fun to find, > and even more fun to eliminate. However the code you posted didn't > create any cycles, so either post some more, or go and stare at your > code some (ask Gordon about the "hypnotising bricks" approach...). > > It's also possible that Python 2.0 will have a better garbage > collector. > > Cheers, > M. > > -- > Very rough; like estimating the productivity of a welder by the > amount of acetylene used. -- Paul Svensson, comp.lang.python > [on the subject of the measuring programmer productivity by LOC] From tom-main at REMOVEME.home.com Mon Jul 10 20:22:10 2000 From: tom-main at REMOVEME.home.com (Tom) Date: Tue, 11 Jul 2000 00:22:10 GMT Subject: Looking for a tree widget with control of text color Message-ID: Is there a tree widget for wxPython or TKinter that support setting the text color (foreground or background) for each node? Ideally it could also be updated dynamically. I heard that there is a good tree widget in IDLE, called TreeWidget, but I can't find it. Do I have the name right? I found the IDLE source code in with the Python 1.5.2 source code but there was nothing called TreeWidget there. Thanks, Tom. From andymac at bullseye.apana.org.au Wed Jul 5 18:48:30 2000 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Thu, 6 Jul 2000 08:48:30 +1000 (EST) Subject: Telnetlib In-Reply-To: <8jvnjs$f2l$1@nnrp1.deja.com> Message-ID: [mailed to originator & python-list] On Wed, 5 Jul 2000 vxgvxg at my-deja.com wrote: > When using any of the telnetlib read functions (such as read_all(), > read_until(), etc.), the 0x00's seem to be dropped from the data > stream. Any ideas? I know nothing of telnetlib, but seem to recall that by default the telnet protocol negotiates 7-bit ascii with remapping/filtering of control codes (the NUL character is quite likely to be affected). It is possible to negotiate 8-bit ascii, and minimise the remapping/filtering with many telnet daemons. Whether telnetlib supports this will require perusal of the docs. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From stephen at cerebralmaelstrom.com.bbs Tue Jul 18 04:40:10 2000 From: stephen at cerebralmaelstrom.com.bbs (stephen at cerebralmaelstrom.com.bbs) Date: 18 Jul 2000 08:40:10 GMT Subject: Getting local IP address... Message-ID: <3bRhQA$kSN@openbazaar.net> Um, jeez. I'm rather surprised by these responses -- I assumed it was some simple little function somewhere I was missing.. I'm also even more surprised at the differences between the three approaches -- #1 -- socket.gethostbyname(socket.gethostname()) -- #2 -- Some complicated stuff dealing with asking Linux (which, incidentely, is bad since i'm primarily on a Windows machine for the time being -- and in the future will be on a *BSD, and hope to have my program working on all three :)) what the address is on the given ethernet card.. -- #3 -- Just go all out and connect, since in the process you have to be telilng the other side where you are, so you can get it that way. #2 and #3 just seem .. convoluted .. as heck. But because so many people sugguested them, I have to assume that they beileve there is some central problem with #1... What is it? :) David Bolen wrote in message news:uitu45ihv.fsf at ctwd0143.fitlinxx.com... > Mike Fletcher writes: > > > import socket > > def getLocalHostIP( remote = ("www.python.org", 80)): > > '''Get the "public" address of the local machine, i.e. > > that address which is connected to the general internet. > > Code by Donn Cave, posted to comp.lang.python''' > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > s.connect( remote ) > > ip, localport = s.getsockname() > > s.close() > > return ip > > > > That is actually from a Deja posting, seems to be fairly portable, doesn't > > rely on parsing obscure Unix command responses, is readable, and is > > generally quite reliable. > > But has a pretty large (IMHO) negative that you are making a wasted > network connection to an external server that has to spend time > setting up and tearing down TCP with you for no reason. That seems a > pretty high overhead to pay just to determine what is essentially a > locally configured piece of information. If you are in charge of your > own server that you are using I suppose that's one thing, but it seems > a big waste if you're connecting to someone else's. > > Unfortunately, really determining a local configured address just > isn't that portable a thing from my experience. Probably the closest > would be the SIOCGIFCONF IOCtl (for Unix systems) as previously > posted. There is an Windows socket IOCtl that is similar > (SIO_ADDRESS_LIST_QUERY), but I'm not sure how best to get to it from > Python, aside from something like a CallDLL approach. > > While without an alternative that is portable as the above example > makes it hard to come out too strong against it, I did want to point > out that while it may be portable and readable, it has negatives on > the network side in terms of wasted connections. I built backbones in > a prior life, and I sort of cringe to think of tons of user code > suddenly starting to do stuff like the above :-) > > -- > -- David > -- > /-----------------------------------------------------------------------\ > \ David Bolen \ E-mail: db3l at fitlinxx.com / > | FitLinxx, Inc. \ Phone: (203) 708-5192 | > / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ > \-----------------------------------------------------------------------/ -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From olipt at mayo.edu Thu Jul 20 19:18:10 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 20 Jul 2000 18:18:10 -0500 Subject: Discussion: new operators for numerical computation In-Reply-To: <39777941.1A85F3CA@STScI.Edu> References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> <39777941.1A85F3CA@STScI.Edu> Message-ID: > I would also suggest just using solve(A,B) for matrix solve. It's not that > long and its descriptive. I tend to agree here. The A\B syntax in Matlab is not especially intuitive. > > The one issue that concerns me about this discussion is the continued narrow > focus to emulate Matlab syntax to the exclusion of more general N-dimensional > operations. I can see the need for some more general operators, but I'm not > for any of this, if all we're doing is defining 2-D Matlab syntax. I > suggest the Matlab people take a look at APL or J to get a broader > perspective of array languages. These are my sentiments too. Huaiyu, it's obvious you've spent a lot of time in Matlab but not so obvious that you've considered the design of NumPy very much. There was A LOT of discussion that wen't in to NumPy to make it more generic than 2-D Matlab (I wouldn't be using it if it weren't). That's why you meet resistance when you seem to want to change syntax to make just 2-D Matrix notation easier. I think that 6+5 operators will never fly. I think we'll be lucky if we get four into Python itself. I suppose if you want to maintain a separate patched-interpreter than you can do whatever you feel best about, though.. ;-) -Travis From david_ullrich at my-deja.com Sun Jul 2 13:55:38 2000 From: david_ullrich at my-deja.com (david_ullrich at my-deja.com) Date: Sun, 02 Jul 2000 17:55:38 GMT Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> Message-ID: <8jnvml$2at$1@nnrp1.deja.com> In article <395E2425.8F6F8757 at uniserve.com>, Bob van der Poel wrote: > > I see sample code for python/tkinter which looks like this: > > class main: > def __init__(self): > ...do a bunch of init stuff > > a=main() > root.mainloop() > > What I'm wonder is why the use of a class for this. You say it's "sample code". One possibility is that sample code is not supposed to do what it does in the best possible way, it's supposed to do what it does in the most _illustrative_ possible way - it's supposed to be a sample of how to do things in other situations where the class will have more interesting methods. (Another possibility is that you overlooked the fact that the class in question derives from another class, so it actually does include more than just __init__, you just don't see it on that page.) DU > Wouldn't it be > just > as clear and perhaps more efficient to do > > ...do init stuff > root.mainloop() > > Is this just a good habit being developed by those who think that > classes are better than functions, or god forbid, inline code? > > While I'd asking, are there any penalties in the speed/memory usage > departments on using classes vrs. functions? > > In case this isn't obvious I'm an old programmer who figured that C was > a really nice, almost-cross-platform assembly language.... > > -- > __ > / ) / Bob van der Poel > /--< ____/__ bvdpoel at uniserve.com > /___/_(_) /_) http://users.uniserve.com/~bvdpoel > > Sent via Deja.com http://www.deja.com/ Before you buy. From neilh at scintilla.org Thu Jul 27 19:00:33 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 27 Jul 2000 23:00:33 GMT Subject: The State of Python References: Message-ID: > If Python had the GPL-license we would never have gotten into this mess. My > main argument for *not* using Python at first was that it didn't > have the GPL attached to it... Yes, the GPL is more restricive but you can't > have both ways. If earlier versions of Python had been GPLed, the copyright owner could still have changed the license for 1.6. No different from the current situation. Neil From fiona at sitegnome.com Wed Jul 12 23:48:48 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: Thu, 13 Jul 2000 13:48:48 +1000 Subject: checking the existence of a fiel References: Message-ID: <396D3C20.F062F265@sitegnome.com> Hi, This question also made it into the FAQTs knowledge base last month. Maybe you should check that site out. http://python.faqts.com Specifically, How do I check to see if a file exists? http://www.faqts.com/knowledge-base/view.phtml/aid/2782/fid/245 cheers, Fiona "Fernando Rodr?guez" wrote: > > Hi! > > How can I check if a file exists? O:-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez -- Site Gnome - site maintenance, documentation and proof reading http://www.sitegnome.com From johannes at zellner.org Thu Jul 6 06:57:49 2000 From: johannes at zellner.org (Johannes Zellner) Date: Thu, 6 Jul 2000 12:57:49 +0200 (CEST) Subject: function arguments Message-ID: Hello, is there a way to get a functions argument list ? e.g. def fun(fred, lola): ... something like `arglist(fun)' should return [ 'fred', 'lola' ] -- Johannes From jtoy at tcgfinancial.com Wed Jul 19 17:37:46 2000 From: jtoy at tcgfinancial.com (jtoy) Date: Wed, 19 Jul 2000 17:37:46 -0400 Subject: critique my 1st program ever Message-ID: <39761FAA.70E65704@tcgfinancial.com> Hi, this is my first program I have ever written. Please tell e what I need to do to clean it up or make any other suggestions. Thanks. Also, could you answer a couple of question I have below. # Written by Jason Toy(toyboy at toy.eyep.net)http://toy.eyep.net on 02:07 July 16, 2000 EST #This program is an eyep client for any OS that has Python installed import urllib, os, string def parser(host, userdata): if userdata['ip'] =="": eyep = 'http://eyep.net/update.php/'+userdata['username']+'/'+userdata['password']+'/'+host else: eyep = 'http://eyep.net/update.php/'+userdata['username']+'/'+userdata['password']+'/'+host+'/'+userdata['ip'] parsereturn = urllib.urlopen(eyep) if parsereturn.read() == "RETURN4": print host, "has been updated successfully" elif parsereturn.read() == "RETURN1": print "You are missing fields, request is probably misconfigured for", host elif parsereturn.read() == "RETURN2": print "Bad username/password for", host elif parsereturn.read() == "RETURN3": print host, "isn't owned by you" elif parsereturn.read() == "RETURN5": print "Invalid IP address for", host elif parsereturn.read() == "RETURN6": print "Service is temporarily unavailable" else: print "Error message on", host, ":", parsereturn.read() ,"--Please report to http://www.eyep.net for further information." def readuserdata(aFileName): userdata = {} myfile = open(aFileName) for line in myfile.readlines(): (item, value) = string.split(line, ':', 1) userdata[item] = string.strip(value) return userdata def writeuserdata(aFileName, userdata): myfile = open(aFileName, 'w') for item in userdata.keys(): myfile.write("%s:%s\n"% (item, userdata[item])) myfile.close() userdata = {} if os.access('userdata.dat', os.R_OK) == 0: userdata['username'] = raw_input("Enter your user name: ") userdata['password'] = raw_input("Enter your password: ") userdata['host1'] = raw_input("Enter you first hostname: ") userdata['host2'] = raw_input("Enter your second host(if you have only 1, press enter): ") if userdata['host2'] != "": userdata['host3'] = raw_input("Enter your third host(If you have only 2, press enter): ") userdata['ip'] = raw_input("Enter your ip(press enter for autodetection): ") else: userdata = readuserdata('userdata.dat') parser(userdata['host1'], userdata) if userdata['host2'] !="": parser(userdata['host2'], userdata) if userdata['host3'] !="": parser(userdata['host3'], userdata) else: print "Thank You" if os.access('userdata.dat', os.R_OK) == 0: print "Saving your configuration........." writeuserdata('userdata.dat', userdata) Can you tell me how I can make a python program find the IP address of the local machine? If possible, I would like to make this not matter what OS its on( i want it to work on windows and Unix/Linux/BSD). Second, can you tell me how I could run this program as a dameon, again not OS dependent, because while I know you can put a Python script in cron, how can you do the same with windows? Third, how can I make Python recognize what OS its on, that wat if I can't do the above 2 questions withouot being OS dependent, then I will do somethin like: if OS == x then do else OS == z do Thanks for your time. Jason Toy toyboy at toy.eyep.net http://toy.eyep.net From jerry_spicklemire at my-deja.com Mon Jul 24 11:14:26 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Mon, 24 Jul 2000 15:14:26 GMT Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> <8lhij5$278$1@slb2.atl.mindspring.net> Message-ID: <8lhmgd$p92$1@nnrp1.deja.com> "Arthur Siegel" wrote: > > Perhaps your shop, which sounds: > a) substantial > b) for profit > > consider doing what has traditionally been done when a technical > solution requiring an impled or express warranty of fitness is > necessary - arrange to engage an appopriate shop in that business > to provide it. > This suggestion makes perfect sense, in cases where Python has already been adopted by the substantial, for profit shop in question. One could then assume that Python is recognized for it's merits, and that the "customer" realizes that, as with any Open Source tools, it is easy and effective to contribute by scratching your own itch, and returning the resulting solution to the community. However, I have no problem relating to the original "letter", since I, like many Python fans, have faced resistance when attempting to use Python and it's progeny (Zope), and to have them accepted in a for profit setting. Lack of clarity in the process of creating and evolving Open Source is a grave cause of misunderstanding and an easy target for FUD mongers. It may not be easy, or even likely , but it would certainly help to move toward a development model that values coordination of effort, and strives to foster cooperation wherever possible. There is some good news, in the form of recently arisen examples such as SourceForge, CoSource, etc. To me these represent one more step in the many "new things under the sun" that have been sparked by the IntraNet, and GNU. The need for straightforward mechanisms that support Open Source, and make it easy for non-developers to see benefits from participation, has begun to be filled. Later, Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From dale at out-think.NOSPAMco.uk Mon Jul 3 18:02:59 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 3 Jul 2000 23:02:59 +0100 Subject: Definative Documentation on Objects References: <8jqui2$9na$1@supernews.com> Message-ID: <8jr2iv$cn2$1@supernews.com> Now why didn't I find that! I've been looking all over the place and it was right under my nose. Thanks for the reply! -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Alex wrote in message news:etdu2e7j58c.fsf at w20-575-34.mit.edu... > > Perhaps the tutorial? > > http://www.python.org/doc/tut/node11.html > > It all depends on what a definitive statement would be, I guess. > > Alex. From paul at prescod.net Sun Jul 2 17:08:06 2000 From: paul at prescod.net (Paul Prescod) Date: Sun, 02 Jul 2000 16:08:06 -0500 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> <395EAF62.4A628573@uniserve.com> Message-ID: <395FAF36.5EE57FBC@prescod.net> Bob van der Poel wrote: > >... > > Yes, that I understand. In some of the example code I've seen there is > only the __init__ function and no data. That's why it doesn't make sense > to me. Maybe I'm just having a bad day..... Is this code public? It doesn't seem particularly useful for all of us to just guess why they MIGHT have done it that way. -- Paul Prescod - Not encumbered by corporate consensus The calculus and the rich body of mathematical analysis to which it gave rise made modern science possible, but it was the algorithm that made the modern world possible. - The Advent of the Algorithm (pending), by David Berlinski From mwh21 at cam.ac.uk Thu Jul 27 03:24:06 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 27 Jul 2000 08:24:06 +0100 Subject: Operators for everything (was Re: Operators for matrix) References: <397CB3EA.15F5514F@prescod.net> <200007250053.RAA03842@rocket.knowledgetrack.com> <397CFDAC.38A22DAF@prescod.net> <397FAE70.67357E5C@see.my.signature> Message-ID: Greg Ewing writes: [snip smalltalk inspired ideas] > However, I don't think that any of this sort of thing > is going to satisfy the mathematicians. Infix operators > work not only because they are infix, but because they > are extremely compact, allowing very complicated > formulas to be expressed concisely yet readably. But this is the problem! (as I see it) If I see A @mmul B (or "A mmul: B" or "A :mmul B" (which I think is my favourite yet)) then I can have an informed guess at what is going on, but if I see A %*!? B I've got no f**king clue! [schnipp] > I think we're just going to have to wait for Unicode > before we can solve this in a really satisfactory way, > folks. Nah, not even then, I suspect. Cheers, M. (who really really doesn't want to go to work today!) -- If I had wanted your website to make noise I would have licked my finger and rubbed it across the monitor. -- signature of "istartedi" on slashdot.org From moshez at math.huji.ac.il Mon Jul 31 03:58:25 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 31 Jul 2000 10:58:25 +0300 (IDT) Subject: How does Python compare to ? In-Reply-To: <2BC506F412001015.A448199B4E14D358.B1243148487C59CB@lp.airnews.net> Message-ID: [Moshe] > Why use CGI? Its time is long past. [Cameron Laird] > CGI isn't modern, but it's going to be in use for a looooong > time, I claim. Of course -- heck, even I use CGI for most of my web solutions. The thing is, I'm not (currently) a web developer -- so when I have a problem to solve, the most important thing for me is how long it takes to set up the solution. For that, CGI rocks. However, as soon as you care about either performance or about program scalability (IOW, once it's beyond a form-to-send-mail and its ilk) (and if you don't, then the only difference between Java servlets, PHP-plugin and Python CGI is the syntax), the CGI is the most horrible solution available. CGI requires always a process startup and usually interpreter (be it Tcl, Guile, Perl or Python) startup. That makes it unacceptable if there are more then 2 hits/second. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From billtut at microsoft.com Wed Jul 5 18:13:46 2000 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 5 Jul 2000 15:13:46 -0700 Subject: MAPI/COM: where is the server? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD26F@RED-MSG-50> Its talking to the local MAPI COM object that talks to the Exchange MAPI provider which uses whatever method it wants to communicate with the Exchange server. I believe it uses Win32 RPC. Cute diagram: +---------------------+ | MAPI.Session | | COM Object | +---------------------+ | Core MAPI | | Code | +---------------------+ | Exchange MAPI | | Provider | +---------------------+ | Win32/DCE RPC | +---------------------+ | Network | +---------------------+ | Exchange Server | +---------------------+ Bill -----Original Message----- From: ge at nowhere.none [mailto:ge at nowhere.none] Sent: Wednesday, July 05, 2000 3:05 PM To: python-list at python.org Subject: MAPI/COM: where is the server? My MAPI/COM e-mail fetcher (running under win95) does this: self.session = win32com.client.Dispatch("MAPI.Session") self.session.Logon("MS Eschange Settings") [message fetching code left as an exercise for the reader] This was all developed without any basic understanding of DCOM or MAPI by copying other people's examples and semi-random trial-and-error. Question: Is it talking to Exchange server (which runs on a remote machine), or is it talking to a local copy of MS Outlook which is then acting as an intermediary? If it's talking directly to Exchange server, then there's a possibility I could do the same thing from Linux using either Software AG's product or GCOM. If my program is just talking to the local copy of MS Outlook, then running the program under Linux isn't very useful, since I still have to run that win95 machine that's sitting over in the corner. -- Grant Edwards grante Yow! I have the power at to HALT PRODUCTION on all visi.com TEENAGE SEX COMEDIES!! -- http://www.python.org/mailman/listinfo/python-list From dgoodger at bigfoot.com Tue Jul 11 00:12:20 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Tue, 11 Jul 2000 00:12:20 -0400 Subject: Language Challenge -- Results In-Reply-To: <396A493A.DE1DF77B@sdynamix.com> References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: on 2000-07-10 18:07, bv (bvoh at sdynamix.com) wrote: > Language Challenge 2000 -- Results On viewing the results table, we note that there was exactly one entry under Assembler, and five under Fortran (including -- hold onto your hats -- the winner!). None in any other language (including Python). A wry quip precedes the table: We didn't think it was possible to silence the language warriors, however, the emptiness in the table suggests just that. What can be inferred from this deafening silence...? ... is the necessary know-how confined only to those who practice the language perceived by some as pass?? This was an opportunity to show your prowess, not with rhetoric but with deeds -- code solving a real life problem -- yet you came up empty. Let's look at the prizes: Compaq Visual Fortran V6.1 Professional Edition - Provided courtesy of Compaq SDX Modeling and Simulation Software V3.0 The SDX offering may be a wonderful product; I don't know. But the Visual Fortran would be a waste of shelf space to most Pythonistas, I believe. > We'd like to particularly encourage a visit by the younger generation > which probably never even saw a code without trailing semicolons I know of a language that does very well without a lot more line noise than just trailing semicolons. Anyone care to hazard a guess? ;-} > To view the contest summary please click on the "Language Challenge > 2000" on http://sdynamix.com But seriously (my comments above were in good fun, I assure you, no harm intended), I read this newsgroup regularly and I never saw mention of the Language Challenge 2000. Did I miss it? Perhaps the audience determined the outcome? Ah, fond memories of my college Fortran course... Thank Guido for Python! -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From fig at oreilly.com.bbs Mon Jul 17 15:50:04 2000 From: fig at oreilly.com.bbs (fig at oreilly.com.bbs) Date: 17 Jul 2000 19:50:04 GMT Subject: Newbie question: PyOpenGL installation Message-ID: <3bRNNT$lvY@openbazaar.net> Installing PyOpenGL on Linux is not easy right now. I managed to do it, but had to alter some of the source. I was about to write up how I did it when I found Robin Humble had done the same thing, and posted it to the PyOpenGL egroup: http://wxwindows.org/pipermail/wxpython-users/2000-April/001922.html Here is the text of his post: ===================================================================== Hi, First post... These are the steps I went through to get pyOpenGL from CVS (May30) working with RedHat 6.2. I think it'd be similar for RH6.1. Some of these changes should probably go into CVS... * install python-numpy-15.3-1.i386.rpm from http://download.sourceforge.net/numpy/python-numpy-15.3-1.i386.rpm * grab pyOpenGL from CVS using the instructions on http://www.pythonpros.com/cvs.html * edit Setup.in to be all -lGL -lGLU (not MesaGL) and to be link paths of -L/usr/X11R6/bin - this'd be fine as a spec file patch... don't worry about CVS * edit src/Togl-1.5/togl.c at ~line 127 to add a 8.0.5 version choice which is the same as the 8.0.4 version - probably should be in CVS as it appears to work with tk/tcl 8.0.5 * run python BUILD.py * run python install.py -v * edit /usr/lib/tk8.0/Togl/pkgIndex.tcl to be .so not .dll - there should be an OS dependant 'pkgIndex.tcl' in the support/ directory that 'install.py' chooses depending upon whether you're running Unix or Windows. Obviously .dll makes no sense under Unix/Linux. * move /usr/lib/tk8.0/Togl/togl.so to be Togl.so - maybe if I knew what the syntax of the 'pkgIndex.tcl' file was then this wouldn't be necessary as 'togl.so' should be ok? Not sure... I also have most of the demos from www.python.de working if anyone is interested. The RawOpengl one being the exception. I couldn't find any sensible demos from the cvs version of pyOpenGL. Maybe I don't know the right place to look? Please let me know if you'd like patches for any of these things and I'll do my best to help. If the CVS gets updated then I'm happy to contribute a .spec file and create a source and binary i386 rpm (and a download site) if anyone is interested. Possibly also an Alpha/Linux binary rpm. I'm impressed by the speed and simplicity of pyOpenGL so far! About 100k+ points per frame animating smoothly and happily (software only Mesa with Athlon700/K7V/G400Max)... Well done!! :) cheers, robin -- Robin Humble / http://www.cita.utoronto.ca/~rjh/ ===================================================================== Since reading this, I found another person who says they solved some of the MesaGL library problems by installing the Mesa 3.0 RPM from Robin Dunn's wxPython site: http://alldunn.com/wxPython/dist/others/ Best of luck! Stephen From m.faassen at vet.uu.nl Thu Jul 27 16:24:38 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Jul 2000 20:24:38 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> Message-ID: <8lq5q6$fn4$1@newshost.accu.uu.nl> Steve Lamb wrote: > On 27 Jul 2000 17:56:55 GMT, Martijn Faassen wrote: >>Hmm. You seem to expect that strings and other things will be automatically >>coerced to integers whenever a function expects an integer. I think that's >>pretty scary; when I pass in the wrong thing to a function I *want* it to >>complain, as it's very likely I did it by accident. > The problem there is you're thinking in terms of separate data types. I > prefer the freedom of thinking in /DATA/. Not types, just data. 1. Is that > a string? Is it an integer? Is it a floating point number? Yes, it is all > three. In the end if you want to add your data together, you need to know what the result will be. If you want to substract your data, you also need to know. What if your data is "foo" and you add them together? What if the user gave some input and you don't *know* what the user entered? I think in your case you usually need to remember what type your data is *anyway*, and what's worse you need to know what will happen to your data for various cases: "1" + "2" (3 or "3") "2" + 2 # 4 I presume (or "4") "foo" + "bar" # ? (I tried; it gives you 0) "foo" + "3" # ? (gives you 3..) This may become quite unobvious in various cases, and may happen by accident, right? Though I understand the case for genericity, I don't really see it here. [snip] >>I don't want things to work by accident. Perhaps you're missing that this >>'problem' is also a 'feature'; you get less 'weird' bugs due to the fact that >>your program keeps running long after your data got coerce-mangled to death. >>Python would tend to throw exceptions as soon as it went wrong. > I've never gotten 'weird' bugs from Perl taking the data type from the > context of the operation at hand. Not even in my early days of Perl. I won't > say there weren't got'chas that got me, but it was quite liberating not having > to worry about thinking in terms of how the computer sees the data and, > instead, having the computer see the data as /I/ see it. But what if that makes no sense? What if I entered 'foo' in the config file where I needed to enter a number? Won't you get a weird bug now? > Furthermore, I have already gotten my first 'wierd' Python bug and it is > wierder, by far, than anything I hit in Perl. Even when I was debugging the > code (love the debugger!) I couldn't understand what was going on. What's > more, in the context of the script, it shouldn't have happened. > def foo(): > print "foo" > foo This script won't do anything. >>>> def foo(): > ... print "foo" > ... >>>> foo >>>> > Sure, works nice in interactive mode. You'd think when I left that in my > script that Python would have tossed it's cookies. I can see where this could be confusing, but your 'foo' there is just like saying: 2 or "foo" That won't do anything either. 'foo' is a function object. I imagine the reason Python doesn't complain here is that it can treat expressions as statements, and that sometimes this makes sense, such as when there's a function call: foo() # is an expression too > No. All I saw was a > statement the parser took and the debugger was showing no call being made even > when stepping through the code. That's because nothing's being called, right? The expression is being evaluated. Interactive mode gives you the string representation of the result of the expression, but running a script won't. > Newbie mistake, sure, but certainly one of > those that if we want to be strict about what goes where should have been > caught. I'm not claiming we want to be strict about things at all times. If I thought that I wouldn't be using Python. I was claiming that 'guessing' what a line of code is supposed to mean can be bad. I mean, really: "foo1" + 1 # 1 "1foo" + 1 # 2 "1" + 1 # 2 " 1" + 1 # 2 "\n1" + 1 # 2 "1*2" + 1 # 2 Are you sure this never gives you any odd output? >>So perhaps you're missing the important tradeoff here. > What, strict checking versus TMTOWTDI? No, giving up in the face of ambiguity versus guessing. Ambiguity tends to arise when I'm doing something wrong; if I did it right it wouldn't be ambiguous code. Besides, I wouldn't want to read such code even if it did the right thing; confusing. In Python there are tons of ways to do it too. :) > If we're going to have the strict > checking why, then, don't we have typing up front instead of the half-typing > we have now? Because I wasn't arguing for 'strict checking'; I was arguing not checking until the *last moment*, and if that makes no sense, give up. (unless you catch the exception, of course) > Python gets the initial type from context but won't switch types > based on context? Might as well force people back into declaring variables > in certain types since that is implicitly what we have now. Not in OO code: class Foo: def doit(self): print "foo" class Bar: def doit(self): print "bar" foo = Foo(); bar = Bar() foo.doit() bar.doit() That works, as the check at the last moment could figure it out; there was such a method, so it executes it. Now if 'doit()' was absent and the system started guessing, we'd be in trouble, right? Also not in generic code: def add(a, b): return a + b Works for integers as well as for strings. Unless you pass in a string and an integer. If you wanted to support that, you need to tell it explicitly: def add(a, b): return int(a) + int(b) Though this does something else in case two strings are passed in. I'd make the conversion to integers the responsibility of the caller, myself. Also not even between numbers: 1 + 1.0 1L + 1 1.0 + 1L >>All right, for this particular case I suppose one could get used to >>this kind of coercing. But in general? I'd need to *remember* it all, >>right? > Nope. You stuff a number into a scaler it is a number but can be used as > a string. So I don't need to know about what happens when I do "1foo" + 1? Or "foo1" + 1? Or "foo1" - 1? Presumably I'd need to check my user input *anyway*, right? > Not that hard to remember. Much easier, in fact, that having to > remember to declare everything from the onset or declare it each time you > need to use it in a particular context much less having to put in checks > in case you're trying to declare something into something which it cannot > be morphed into. But in Python you don't need to declare at all. You just need to explicitly say sometimes you want something changed into something else. If you want an integer, change your string into an integer. Do it early on if you don't want to do it everywhere and work with integers from then on. > Simply stated, main reason I don't do C, don't do Java, and dropped Pascal > so long ago, the frustration of not being able to take data of one "type" and > use it in a different context without jumping through 20 different loops > depending on the particular case. To me it isn't char, int, longint, unsigned > or signed, strings or whatever, it is data. Lists and hashes (and in Python, > tuples) are just structures of data. What "type" that data is is completely > subjective and based on the context of the operation. To me, a language that > understands that has the feature, not the language that refuses to. The funny thing is that in Python this happens, and I'd agree with you, but it tends to happen more often for class instances, not so much for built-in primitives. Instances don't have a type, and they continue working as long as they support the operations called on them. The thing is, they don't by default support all operations, and if an operation is not supported, Python stops. For built-in types such as integers and strings, Python does not support the operation of adding them together (but it could, you could make a class for this; though it'd be a pain and overkill in this case). We aren't so far apart in that sense; we just disagree about how many operations the basic datatypes should support. I personally never had trouble with having to call int() excessively, for instance. If you find you're doing that a lot in your code, something may be odd about the design of your code. Note that Python does do this type of automatic conversion in some cases. 'print' can for instance print just about anything. Note also that in your case, the only thing you're complaining about is that Python treats numbers and strings differently; Python doesn't care much whether your number is an integer or a float or a long integer, for instance. It doesn't distinguish between characters and strings either. The only addition to your type pantheon would seem to be the string/number dichotomy and the list/tuple dichotomy, nothing else. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul at prescod.net Tue Jul 18 00:15:23 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 23:15:23 -0500 Subject: Wherefore art thou, 1.6? References: <3973D0A1.5E1289D9@concentric.net> Message-ID: <3973D9DB.9E141287@prescod.net> Manus Hand wrote: > > ... > > Can someone please post a status on 1.6? Here's part of the story: http://www.pythonlabs.com/news_sitelaunch.html And the next part: http://www.pythonlabs.com/tech/python2.html And some more: http://www.python.org/pipermail/python-dev/2000-July/011960.html http://www.python.org/pipermail/python-dev/2000-July/012574.html No news since. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From thomas_s at ebox.tninet.se Sun Jul 9 15:52:55 2000 From: thomas_s at ebox.tninet.se (Thomas Svensson) Date: Sun, 09 Jul 2000 20:52:55 +0100 Subject: Static member variables Message-ID: <8kahdq$5e2$1@zingo.tninet.se> Hello, Is there a way of declaring static (and constant) member variables in classes? I have a member variable that should be unique for each class type and thus should not waste memory for each instance of the class I create. Something like the __doc__ string I guess. Can this be done? Thanks, Thomas From bjrubble at shell16.ba.best.com Fri Jul 7 20:03:42 2000 From: bjrubble at shell16.ba.best.com (Adam Clark) Date: 8 Jul 2000 00:03:42 GMT Subject: Help! Indenting craziness! References: <8k5pev$182l$1@nntp1.ba.best.com> Message-ID: <8k5r4u$182l$2@nntp1.ba.best.com> Let me retract the "blank, unindented lines" part before somebody flames me. I realize now that this is a python-mode issue, probably due to a space/tab mixup. Problem is, everything appears to be tabs. There is no detectable difference either visually or by cursor navigation between correct code and SyntaxError-generating code. So, that said, help!! Adam Adam Clark wrote: > Hi all, > Does anybody have a technique for avoiding syntax errors due to blank, > unindented lines? I'm getting these on a regular basis, and I haven't > figured out any reliable way to fix them. Sometimes if I take every line > in the vicinity, backspace it to the end of the previous line, and > reposition it, the errors go away. But often they don't, and I end up > just deleting chunks and rewriting them until Python stops complaining. > This is with Emacs and python-mode. > Thanks > Adam From db3l at fitlinxx.com Tue Jul 18 19:46:23 2000 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jul 2000 19:46:23 -0400 Subject: Python 2.0 - win32pipe routines inclusion for Windows Message-ID: I've noticed that the latest sources for Python 2.0 in CVS have included the win32pipe code from the PythonWin extensions as a replacement for the prior os.pipe() routine in Python 1.5.2. One consequence of this is that you no longer receive process exit codes on the pipe.close() operation. Since I need the result codes in my work, and work under Windows NT primarily, I figured I'd try to do something about it. I've created a small patch to the latest posixmodule.c in CVS that uses an internal dictionary to maintain a mapping between created pipes and child processes so it can retrieve the exit code, and was wondering if this is something that should just be submitted to the SourceForge patch manager or if there is any other process for Python 2.0 (this is my first non-R/O poke at the sources). While munging around in the source it also appears that there seems to be a mismatch between the ordering of file handles returned by the higher order popen# routines in the internal posixmodule (the win32pipe routines) versus the current popen2.py library module. I think I saw a discussion about this in the python-dev archives, but it wasn't clear if the two should be consistent at this point in the repository. Thanks. -- -- 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 neilh at scintilla.org.bbs Mon Jul 17 05:40:05 2000 From: neilh at scintilla.org.bbs (neilh at scintilla.org.bbs) Date: 17 Jul 2000 09:40:05 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bR7T5$kCB@openbazaar.net> > working with the new Build 132 of Pythonwin we have a minor problem. > German Umlauts are not handled properly in the editor windows. > They are shown as boxes, some of them seem to be dead keys. > > The problem did not exist in previous builds. > Does anyone have a hint ? 132 defaults to using Unicode for editing Python source code and the interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, find the OnInitialUpdate method and comment out the two lines under "# Enable Unicode if we can". Save the file, shut down Pythonwin and restart it and see if this fixes the problem. Yes, there should be an option to control this. Neil From mpetroni at my-deja.com Sat Jul 22 18:23:16 2000 From: mpetroni at my-deja.com (mpetroni at my-deja.com) Date: Sat, 22 Jul 2000 22:23:16 GMT Subject: Cannot create objects in Zope 2.2.0 Message-ID: <8ld6sb$qg5$1@nnrp1.deja.com> I've just downloaded Zope 2.2.0 for win32 and installed it. Ir runs with administrator privileges, but when I try to create any objects I get the following message: ----------------- Zope Error Zope has encountered an error while publishing this resource. Error Type: SuperCannotOwn Error Value: Objects cannot be owned by the superuser Troubleshooting Suggestions The URL may be incorrect. The parameters passed to this resource may be incorrect. A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. Traceback (innermost last): File C:\Servers\Zope\lib\python\ZPublisher\Publish.py, line 222, in publish_module File C:\Servers\Zope\lib\python\ZPublisher\Publish.py, line 187, in publish File C:\Servers\Zope\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook File C:\Servers\Zope\lib\python\ZPublisher\Publish.py, line 171, in publish File C:\Servers\Zope\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: manage_addFolder) File C:\Servers\Zope\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: manage_addFolder) File C:\Servers\Zope\lib\python\OFS\Folder.py, line 116, in manage_addFolder File C:\Servers\Zope\lib\python\OFS\ObjectManager.py, line 249, in _setObject (Object: ApplicationDefaultPermissions) File C:\Servers\Zope\lib\python\AccessControl\Owned.py, line 271, in manage_fixupOwnershipAfterAdd (Object: ElementWithAttributes) SuperCannotOwn: (see above) ------------------ Any Ideas? Thanx! Sent via Deja.com http://www.deja.com/ Before you buy. From db3l at fitlinxx.com Thu Jul 20 19:35:18 2000 From: db3l at fitlinxx.com (David Bolen) Date: 20 Jul 2000 19:35:18 -0400 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> <8l7vlm$r63$1@news6.svr.pol.co.uk> Message-ID: "Duncan Smith" writes: > I am using PythonWin. I do try to close the file with outputfile.close() > after the second 'if'. I don't understand why it apparently doesn't work. > ie. I want to open a file and write to it on the first iteration (which it > does), write to it on subsequent iterations (which it does), and close it > after a certain number of iterations (which it doesn't). Thanks for your > help, but I'm afraid I'm still stuck. It might help to see a little more of the application, because I'm not sure the excerpt you included can even execute your close operation without raising a NameError. So if you aren't getting the exception, then perhaps that portion of the code isn't even running when you think it is? If you look at your function definition (I'm assuming it's a method of some class you didn't include in your post), you have the following: def acceptsim(self, cost, n): t = 10000.0 / n if self.cost == 0: outputfile = open('simresults.txt', 'w') sys.stdout = outputfile self.cost = DJT.totalcost(self) self.low_cost = self.cost self.low_ordering = self.ordering[:] if n > 900000: outputfile.close() return 'stop' (...) Now, here's one problem - your use of outputfile makes it a local variable to the acceptsim method. It's not an instance variable, so it won't be preserved from method invocation to method invocation. So unless you execute this function where both self.cost==0 and n>900000, your use of outputfile.close() will refer to outputfile when it doesn't exist (never having been assigned to reference anything). That doesn't affect the other output of the function since you also assign the reference to the file to sys.stdout which is preserved across calls to your method. As to why the file still appears to be opened/locked from other applications, the prior response about sys.stdout still referencing the file is a good possibility, especially given that it doesn't appear likely that your outputfile.close() is executing and/or even if it did, it would be trying to close something different since it won't still reference the same file. So one thought would be to just make outputfile an instance variable (self.outputfile) which will preserve its value. I would also verify that your n>90000 clause is actually triggering. You might use sys.stderr.write() to write any debugging output to the console since sys.stdout is redirected. But I'd also look at how you are handling your file reference. If you're going to use outputfile to close the file, you want to be careful not to leave sys.stdout pointed to it after the close. If you need it to work as sys.stdout (e.g., rather than just using outputfile.write in the other portions of your method), then I'd save the old sys.stdout in an instance variable, and restore it to sys.stdout after you close the file. There's also a small chance that once you have assigned to sys.stdout that Pythonwin is saving a reference to that somewhere which also contributes a reference to the open file. But closing the file explicitly should still take care of the Windows sharing issues, although I suppose that might affect Pythonwin's ability to restore things. I would worry too much about that until you work out the actual handling of the outputfile file reference though. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From felipe at spin.ch Thu Jul 20 20:45:24 2000 From: felipe at spin.ch (felipe wettstein) Date: 21 Jul 2000 01:45:24 +0100 Subject: Python Module for sequence alignments. References: Message-ID: <39776ECD.2D121D6@spin.ch> hi alex you wrote: > Hi. I made a python module that does simple sequence alignments. If > there is enough interest, I may make it a little more elaborate. You > can get it from > > http://puffin.lcs.mit.edu:8080/align.tgz > > To use it on linux > > tar zxf align.tgz > cd align > make > i tried this (and you will see in my question that i am a blody beginner, but nevertheless, i ask you:) bla: /align # make gcc _alignmodule.c -c -o _alignmodule.o \ I /usr/include/python1.5/ -I /user/include/python1.5/Numeric _alignmodule.c:2 arrayobject.h: No such file or directory make: *** [all] Error 1 what did i wrong? is my python not installed well? when it makes sense to answer please do, whenn you would have to write me a whole manual, forget it. thanks felipe and then also my linux does not seem to understand what setenv means (i thought it is kernel 2.2.14, suse6.4), and me i nether do understend. have a good day felipe From piet at cs.uu.nl Wed Jul 5 09:12:49 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 05 Jul 2000 15:12:49 +0200 Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> <87og4eugz7.fsf@cartman.azz.net> Message-ID: Note that the trick via a .bat file may cause problems with parameters containing = signs, and with I/O redirections. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From alex at magenta.com Wed Jul 26 04:30:10 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 26 Jul 2000 10:30:10 +0200 Subject: Two COM Questions: QueryInterface, and Callback Inheritance References: <3pnf5.50267$DH3.1583089@news-east.usenetserver.com> Message-ID: <8lm7r402fmm@news1.newsguy.com> "Christopher Paulicka" wrote in message news:Bosf5.51489$DH3.1693859 at news-east.usenetserver.com... [snip] > > How to QueryInterface for a new dispatch interface? [snip] > Well, that seems straightforward. But, I get the following error message: > >>> other_s = s._oleobj_.QueryInterface("{new_iid}") > TypeError: There is no interface object registered that supports this IID So the IID you're trying to QI for appears not to be registered as an IID. _IS_ it, in fact, an *INTERFACE* id? It seems not, from the following snippet: > # If I get the type of s, and try to use it's CLSID, that doesn't work. ...right: a CLSID is a class-id, it identifies a coclass, not an interface. You cannot QI for a CLSID, but only for an IID. Both CLSID's and IID's are GUID's, but they are registered and used differently. You can't QI for a class-id, just as you can't CoCreateInstance *without* specifiying a class-id. > if ret is not None: ret = win32com.client.Dispatch(ret, 'Duration', > '{EB5093C7-56F9-11D2-88CE-00C04FA35859}', UnicodeToString=1) > return ret > > # Now it works fine! Yep, but the third argument to Dispatch is a class-id, not an IID. So maybe I've not understood what is it that you're trying to do. If you want to access another interface of an object you already have a reference to, then QI is correct, but you have to specify the interface identification -- the IID, not the CLSID. If you want to instantiate a brand-new object, then the CLSID is correct. But that is a substantially different task. Alex From see at my.signature Thu Jul 20 22:03:10 2000 From: see at my.signature (Greg Ewing) Date: Fri, 21 Jul 2000 14:03:10 +1200 Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: <3977AF5E.552F4F42@my.signature> John Lull wrote: > > That problem extends far beyond linear algebra, & an ideal solution > would be applicable to any problem domain in which infix notation is > greatly preferable. I second this. The matrix people are being accused of being selfish by requesting core language extensions for their particular domain. But that's not what they're asking for at all. Python with its overloadable operators can be thought of as a meta-language for creating domain-specific languages. But the number of operators is too restricted for it to be really good in this role. Operator overloading feels like something tacked on as an afterthought rather than a serious feature. I don't think it's unreasonable to consider whether this situation could be improved. Personally, I think that language that's serious about user-defined operators and mathematical domains should allow the use of every operator character in the Symbol font. If those characters are useful enough to be included in a standard font, I think they deserve to be available in a programming language, too! In fact, I may just make this my next Python enhancement project. Anyone know where I can get a Unicode-aware editor for Mac or Unix? -- 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 pehr at pehr.net Thu Jul 6 22:29:34 2000 From: pehr at pehr.net (pehr anderson) Date: Fri, 07 Jul 2000 02:29:34 GMT Subject: How to print to stdout in binary References: <8k1kn5$mkt$1@nnrp1.deja.com> Message-ID: <3965408E.DDD4A2@pehr.net> What platform are you developing on? under linux I did the following in a file "t.py": import sys x = open("python.prc", "rb").read() sys.stdout.write(x) [pehr at morseall python]$ python t.py > t [pehr at morseall python]$ diff python.prc t I didn't get any differences when I did this. Would you try it and see how it goes? -pehr brianbird at my-deja.com wrote: > > I've seen similar questions to this posted in other language forums, > but I've not seen anything for Python: > > Does anyone know how to tell python to print the sys.stdout in binary > rather than plain text. It's mode is set as 'w' and I can't seem to > change it. > > I'm experimenting with a cgi script which I want to output an image to > the browser so that the HTML file can have: > > and the resulting output of the script is an image. > I've currently got: > > f = open("test.jpg","rb") > bytes = f.read() > f.close() > sys.stdout.print(bytes) > > but I want the output to print in binary mode so that the image can be > displayed correctly. If I was printing to another file I could open it > with: > > f2 = open("test2.jpg","wb") > f2.write(bytes) > f2.close() > > so is there any way to do this with stdout? > > Thanks > > Sent via Deja.com http://www.deja.com/ > Before you buy. From solodov at bigfoot.com Tue Jul 11 12:00:40 2000 From: solodov at bigfoot.com (Peter Solodov) Date: Tue, 11 Jul 2000 12:00:40 -0400 Subject: checking the existence of a fiel In-Reply-To: ; from frr@mindless.com on Tue, Jul 11, 2000 at 03:37:26PM +0000 References: Message-ID: <20000711120040.A2677@sympatico.ca> Here's the code: try: file = open("some_file") except IOError: print 'Error: Couldn\'t create temp file.' sys.exit(0) Fernando Rodr?guez [frr at mindless.com] wrote: > Hi! > > How can I check if a file exists? O:-) > > TIA > > -- > > > --------------------------------------- > Fernando Rodr?guez > > > -- > http://www.python.org/mailman/listinfo/python-list From mhammond at my-deja.com.bbs Sun Jul 16 22:30:05 2000 From: mhammond at my-deja.com.bbs (mhammond at my-deja.com.bbs) Date: 17 Jul 2000 02:30:05 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bQiJT$m5x@openbazaar.net> In article <396f9d89.25704394 at news.btx.dtag.de>, spamfranke at bigfoot.de (Stefan Franke) wrote, regarding Python .NET [FWIW, the ActiveState page for this stuff is at http://www.activestate.com/.NET ] > How will that all impact the future of the CPython / Win32 > integration? It is just yet another demand on my time. It certainly does not sound the death knell for Pythonwin, win32com, or the win32 extensions. But-sometimes-I-wish-it-did-ly, Mark. Sent via Deja.com http://www.deja.com/ Before you buy. From gwachob at my-deja.com Wed Jul 26 23:44:22 2000 From: gwachob at my-deja.com (gwachob at my-deja.com) Date: Thu, 27 Jul 2000 03:44:22 GMT Subject: BXXP Python project Message-ID: <8lob6m$ntl$1@nnrp1.deja.com> Hi Pythoners- I've started a project on http://www.bxxp.org to build a library in Python implementing the BXXP protocol. We need help in getting this project moving forward. If you have an interest in Python network programming and in insuring that Python remains a viable language for networked applications in the future, please take a look at: http://www.bxxp.org/bxxp/projectPage.jsp?prID=5 BXXP is a new peer-to-peer protocol framework for use in designing new applications. The idea is that an application designer can focus on the application and not on the details of network programming. -Gabe (gwachob at wachob.com) Sent via Deja.com http://www.deja.com/ Before you buy. From Ed_Stauff at avid.com Mon Jul 31 10:42:21 2000 From: Ed_Stauff at avid.com (Ed Stauff) Date: Mon, 31 Jul 2000 14:42:21 -0000 Subject: Why won't Python connect to C++ socket on NT? In-Reply-To: <8m2hrb+g395@eGroups.com> Message-ID: <8m438d+opvn@eGroups.com> Oops. Never mind. Byte-ordering problem. *SMACK*. -- Ed From arhodes at psionic.com.bbs Mon Jul 17 12:30:04 2000 From: arhodes at psionic.com.bbs (arhodes at psionic.com.bbs) Date: 17 Jul 2000 16:30:04 GMT Subject: Getting local IP address... Message-ID: <3bRIDS$jG8@openbazaar.net> Here's a tremendously non-portable way to do it for Linux by reading it straight off the ethernet card... import string,socket,fcntl SIOCGIFADDR = 0x8915 ifname = 'eth0' s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) ifr = ifname+'\0'*(16-len(ifname))+chr(socket.AF_INET)+15*'\0' r= fcntl.ioctl(s.fileno(),SIOCGIFADDR,ifr) addr = string.join(map(str,map(ord,r[20:24])),'.') print addr Aaron arhodes at psionic.com Stephen Hansen wrote: > > Nevermind. > > I've discovered i'm intelligent enough to actually chcek Deja and get > an answer so that i doin't have to spam ya'll with stupid questions :) > > Heh. :) > > --S > > Stephen Hansen wrote in message > news:8ko8qr$7cd$1 at nnrp1.deja.com... > > How do I go about getting my dynamic IP address? I want to make a > > little program to check periodically (daily or so) and log the results > > so I can determine how often my IP is getting shuffled. :) > > > > Thanks :) > > > > --Stephen > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. From gjohnson at gs.verio.net.bbs Mon Jul 17 12:50:01 2000 From: gjohnson at gs.verio.net.bbs (gjohnson at gs.verio.net.bbs) Date: 17 Jul 2000 16:50:01 GMT Subject: Getting local IP address... Message-ID: <3bRIcQ$kWM@openbazaar.net> Why not just do an addr = os.system(ifconfig eth0 | grep inet) This should return the ip addy of the nic... Since the way OS's store IP addys is so implementaion dependant, I don't see how it could be portable unless people start making a posix way of storing an ip addy on top of the os dependant way On Monday, July 17, 2000 11:33 AM, Aaron Rhodes [SMTP:arhodes at psionic.com] wrote: > Here's a tremendously non-portable way to do it for > Linux by reading it straight off the ethernet card... > > import string,socket,fcntl > SIOCGIFADDR = 0x8915 > ifname = 'eth0' > s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) > ifr = ifname+'\0'*(16-len(ifname))+chr(socket.AF_INET)+15*'\0' > r= fcntl.ioctl(s.fileno(),SIOCGIFADDR,ifr) > addr = string.join(map(str,map(ord,r[20:24])),'.') > print addr > > > Aaron > arhodes at psionic.com > > > Stephen Hansen wrote: > > > > Nevermind. > > > > I've discovered i'm intelligent enough to actually chcek Deja and get > > an answer so that i doin't have to spam ya'll with stupid questions :) > > > > Heh. :) > > > > --S > > > > Stephen Hansen wrote in message > > news:8ko8qr$7cd$1 at nnrp1.deja.com... > > > How do I go about getting my dynamic IP address? I want to make a > > > little program to check periodically (daily or so) and log the results > > > so I can determine how often my IP is getting shuffled. :) > > > > > > Thanks :) > > > > > > --Stephen > > > > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list From loris at caren.demon.co.uk Tue Jul 25 09:13:24 2000 From: loris at caren.demon.co.uk (Loris Caren) Date: Tue, 25 Jul 2000 14:13:24 +0100 Subject: Saving PNG files using Win32 PIL Message-ID: <397D9274.FEB1132D@caren.demon.co.uk> I've writen a script to generate PNG images using PIL. It works a treat under Linux, but when I try to port it to MSWindows, the PIL/PngImagePlugin spits saying that I don't have a zip encoder. I already have a copy of pkzip, but I got hold of a copy of gzip.exe and stuck it in C:\Windows\zip.exe but to no avail. Can anyone confirm that I need a zip executable, or is the PIL wanting a DLL, etc? From huaiyu_zhu at yahoo.com Mon Jul 17 20:42:44 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Mon, 17 Jul 2000 17:42:44 -0700 (PDT) Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) In-Reply-To: <39739EEE.D53D9601@roguewave.com> Message-ID: On Mon, 17 Jul 2000, Bjorn Pettersen wrote: > I think you hit the crux of the problem. You want to add syntax that is > only useful in one domain, and that is too extreme. I don't buy this dichotomy here: either it is every domain, or it is only one (meaning limited) domain. I don't even know if there is a general meaninful rule to count application domains in integers. I haven't yet heard much comment about either a = ["Alice", "Bob"] b = " is " c = ["a girl", "a boy"] d = a .+ b .+ c or ESR's comment about using .& and .| for lattice algebra, which I suppose include union and intersection of sets, among other things. What about the example of plotting graphics of server statistics on the web? Which domain is it: numerical processing or text processing or visual arts? I don't see such arguments as any different from the claim that string literals are sintactic sugar for the single domain of text processing only (web and re and so on being subdomains). Since by such definition text processing is a very large domain I do want string literals even just for this only domain, even if it does not include everything. A more reasonable threshold along these lines would be "sufficiently wide", but I don't see we are going to get clear consensus on that point so I won't continue on this topic. > Why don't you create a preprocessor that converts > > a .* b > > into > > elementWiseMultiply(a,b) > > and create an appropriate suffix for your matlab/python files (mpy?) > It's a pretty easy thing to do, and sounds much more appropriate in this > situation. This could work if there is a hook so that import mymodule would automatically run preprocessor < mymodule.mpy > mymodule.py anywhere in the path. It should do this after examining the timestamp just like current import does. Otherwise after a few surprises people would keep .py instead of .mpy so it is just a helper for writing, but not useful for extending or maintaining code, On the other hand, if there is an introspective module that affects how the parser reads the rest of the file it would be eminently useful. Huaiyu From alex at magenta.com Mon Jul 10 05:59:39 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 10 Jul 2000 11:59:39 +0200 Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> <8k9tot$5o$1@supernews.com> Message-ID: <8kc71a0tf6@news2.newsguy.com> "Dale Strickland-Clark" wrote in message news:8k9tot$5o$1 at supernews.com... > Well, all this seemed to do was break an existing working program. I've had > to delete the \gen_py folder to get things working again. > > I am confused now. > > Anyone got any idea how to use makepy? I see you're received good and helpful replies, just wanted to add one thing: in my limited experience, when makepy breaks working code it's most of the time because of case-sensitivity issues. I.e.: with late-bound Automation, which is what you're using absent makepy, the name of methods and properties are matched without regard to case; once you early-bind (with makepy), case does become significant, though. So, if the real name of a method is Method, and you were calling it like this: anobject.method() that will break; you'll have to change the call to anobject.Method() This seems unfortunate to me, but I don't see what could easily be done about it. I believe case-insensitivity is in the Automation specs (by Microsoft), maybe because Visual Basic (for which language so much of Automation was thought of) is also case-insensitive; but once you early-bind, if you're using a case sensitive language (not just Python, but also, for example, C++), then the language's rules will prevail. Maybe a __getattr__ override on makepy-built objects would work, but it feels kludgey and perhaps slow, too. Alex From arnold at dstc.monash.edu.au Wed Jul 5 18:18:44 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Thu, 06 Jul 2000 08:18:44 +1000 Subject: MAPI/COM: where is the server? In-Reply-To: Your message of "Wed, 05 Jul 2000 22:04:57 GMT." Message-ID: <200007052218.IAA26977@xevious.dstc.monash.edu.au> -->"Grant" == Grant Edwards writes: Grant> If it's talking directly to Exchange server, then there's a Grant> possibility I could do the same thing from Linux using either Grant> Software AG's product or GCOM. what's GCOM? (sorry, google reveals nothing useful ...) d From grey at despair.rpglink.com Fri Jul 28 04:11:18 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 08:11:18 GMT Subject: Perl is worse! References: Message-ID: On Fri, 28 Jul 2000 01:24:08 -0400, Tim Peters wrote: >Steve, in case it isn't clear yet, Python programmers *want* to be blown out >of the water when doing something as senseless as > 1 + "foo" It isn't senseless. That is the whole point. It is only senseless because of typing. Clearly you cannot add a word to a number, granted. But what of 1 + "1"? That isn't senseless, those are two numbers. I can see they are two numbers, it is only because of typing that it fails. So I ask you this /VERY/ simple question. Why can't Python do both? Hm? What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it together? If it is a string that cannot be converted to an integer, throw an exception, otherwise, do it. Then that preserves the 1 + "foo" exception and also does the sane thing of getting rid of types when it makes sense to do so. Hell, why do an exception at all? Why not do what is already done with integers, reals and floats? 1 + 1 = math 1 + "1" = math 1 + "foo" = string ("1foo") "foo" + "foo" = string ("foofoo") You already accept: 1 + 1 = integer 1 + 1.2 = float 1 + 1j = complex So please don't tell me you don't want "automagic" type changing when it is already there and, I'd wager, you use it extensively. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From Gareth.McCaughan at pobox.com Fri Jul 28 14:50:27 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 28 Jul 2000 19:50:27 +0100 Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: Steve Lamb wrote: > a = None > list(a) > a = 1 > list(a) > a = 123 > list(a) > a = "abc" > list(a) > > To me all of those could be converted into lists yet only the last one is. > Why do I say that? Because you'd like not to distinguish between a single object and a list containing only that object. I think that's a mistake. If you want to turn 1 into a single-element list, you can do it in the simplest way imaginable: [1]. That's *building* a list, not *converting* to one, though; and the distinction matters. But, I hear you cry, it doesn't matter. We shouldn't distinguish. 1 is 1 and all alone and ever more shall be so, and it's the same thing as "1" and (1,) and "one" and "I" and "un" and {{}} and ... er, sorry, I got a little carried away. Anyway, I don't agree with you. What's "foo" + "bar"? What's "1" + "2"? What's 1 + 2? I claim there are Obviously Right answers to the first and third of those questions, and there's no way to answer the question in the middle that will be consistent with both. Perl says that "foo"+"bar" isn't legal; you have to use a completely different operation for string concatenation. I don't like that. Still less do I like the fact that in Perl "foo" == "bar". When you're comparing objects, you need to know when you write the comparison code whether they're numbers or strings. And how do you compare arrays? Um. Implicit coercions save you some keystrokes. You don't have to say "int()" or "float()" or whatever. Perhaps that would matter to me if my coding speed were limited by my typing speed: but it isn't. Especially not for non-trivial programs in Perl. It's limited by my ability to keep stuff in my head. Python is much easier to read fluently than Perl is, and that means I don't have to remember so much or think so hard just to understand what a fragment of code does; and that means I code much faster in Python than I do in Perl. (And, before you ask: I knew Perl before I knew Python. I've used it a lot. I'm not basing my arguments on having known Python for years, tried out Perl once, and found it hard. And I still use Perl in preference to Python for some text-manipulation tasks.) Let's go back to those examples for a minute. What do you want list("123") to be? ["123"] or ["1", "2", "3"]? If the former, then you're losing sight of the fact that a string is *obviously* a string of characters. If the latter, then you're saying that you want 123 <-> "123" but [123] <-> ["1", "2", "3"]. Ouch. > None could be converted into an empty list. None is nothing. I fail to > see how you can't populate a list with a single nothing. So do you want [None] or []? Heck, 0 is nothing too; why not say that 123+None = 123, too? I suppose list(0) should yield [] rather than [0], since 0 is nothing and nothing is an empty list. And a ham sandwich is better than eternal happiness, because nothing is better than eternal happiness and a ham sandwich is better than nothing. I prefer my programming languages *not* to encourage puns like this. > 1 is a single value. I fail to see why that cannot be converted to [1] > which is allowed, btw. > a = [1] > a That isn't a conversion. It's building a list. There are important differences; for instance, [x] is always a 1-element list containing only x. There's no way to make that true of list(x), since e.g. we obviously must have list(x) == x when x is already a list. (If you think that list(x) should always be a 1-element list containing x, then I conclude that you've just misunderstood the name; the function you want is already available, and it's written [x].) > "abc" could either be a single value or a sequence. It is converted > as ["a", "b", "c"]. Of course, the same /could/ be said for the above. > However, let's play around with this one since it is the only one that > works somewhat as expected in conversion. On the contrary, the others all work *exactly* as I expect, and strings are the ones that are a little counterintuitive. > a = "abc" > a > a = list(a) > a = str(a) > a > > a is now "['a', 'b', 'c']". Which means we split a string up when > converting to list but don't concatinate on the way back. list() and str() were never meant to be inverses. list() is for converting arbitrary sequences into lists. str() is for producing string representations of arbitrary objects. > How did I run across this? Because I wanted to create an empty name each > time a class instance is created. Since I was building the class I didn't > know if I was going to use a list or a str. I figure I could just set it > to None and then manipulate it later. Nope. Couldn't even convert it even > though the conversion seems quite straightforward to me. None into any > structure should yield and empty of that structure. We can have empty > strings, tuples, lists and directories. None doesn't mean "empty object". It means "no object". There's a big difference, whether or not you care to recognise it. As big as the difference between "no bottles" and "an empty bottle", which is insignificant only if all you care about is the beer. :-) > Funny thing, though. I can do this > and it works just fine: > > a = None > a = "" > > Amazing, that. Automagical conversion from None to an emptry string on > the assignment operator. Actually, we both know, and correct me as I may be > wrong, that it is really reassigning the data space a is pointing to. Seems like a very strange way of putting it, but yes. I don't see any reason why you should think it's "amazing" or "automagical", still less "conversion". > However, if we want to create the namespace with nothing we cannot > because we cannot convert it for later use. Thus, we are back to > declaring variables except this time we're doing it with automagical > (implicit) means instead of explicit. What on earth do you mean? The following isn't illegal at all. class Foo: def __init__(self): self.name = None def rename(self, name): self.name = name def __str__(self): return "" % self.name a = Foo() a.rename("wombat") print a b = Foo() b.rename([1,2,3]) print b This will print What's your problem? > I just don't understand how people can advocate for types and the > restrictions they impose while, on the other hand, embracing a language that > is free enough to shoot yourself in the foot by reassigning None. It's pretty hard to reassign None by accident. It's pretty easy to say "print 'yes!' if ($a == $b);" and forget that $a and $b might be strings. I shoot myself in the foot a *lot* less with Python than I ever have with Perl. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From mwh21 at cam.ac.uk Mon Jul 24 16:35:34 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Jul 2000 21:35:34 +0100 Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: digitig at cix.co.uk (Tim Rowe) writes: > In article , mwh21 at cam.ac.uk > (Michael Hudson) wrote: > > > Sorry, but eh? I fail to understand you, I think. > > > > Example usage of what I'm talking about: > > > > def add(x,y): > > return x + y > > > > 1 @add 1 > > ==> 2 > > My problem is that identifiers that refer to overloaded infix operators > must begin with a @ (and presumably any identifier beginning with @ must > be an overloaded infix operator). Hey, why not force integers to begin > with a %, strings with a $... > > I don't like it because it makes programs harder to read. One of the > reasons I don't like Perl is that it tends to look as if the whole program > is obscene and has been censored with $@**!& special symbols! One of the > advantages of Python is that there is little of this nonsense, and I would > hate to see it added to. I don't think extensible infix is worth it. Oh, fair enough. That's not what I read in your first post, though! (I just re-read it, and it still makes very little sense to me...) > By the way, /I'd/ expect x add y to set x to x + y, leave y alone and > return None (or x + y if this were comp.lang.c). I'd expect x plus y to > have the behaviour you expect of add. I'm undecided whether that's a > problem with infix or the perennial problem of choosing good identifiers! Crikey, are you an assembly programmer? I took the name from the __add__ special method name... (to me, plus is the symbol, addition is the operation; would you prefer __star__ to __mul__). pointless-ly y'rs M. -- Arrrrgh, the braindamage! It's not unlike the massively non-brilliant decision to use the period in abbreviations as well as a sentence terminator. Had these people no imagination at _all_? -- Erik Naggum, comp.lang.lisp From hzhu at localhost.localdomain Fri Jul 21 02:44:21 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Fri, 21 Jul 2000 06:44:21 GMT Subject: [long and fussy] But what do these operators _mean_? References: <8l899g$6f5$1@agate.berkeley.edu> Message-ID: On 21 Jul 2000 01:33:36 GMT, Edward Jason Riedy wrote: >Quick summary: Maybe there needs to be a numerics-sig before any >of these changes are adopted... Yes. >And Huaiyu Zhu writes: > - > - (4) Similarity with Matlab (but not really compatibility). > >Take care here. Matlab has made many arbitrary choices that kill >consistency. Their treatment of 1x1 `matrices' has been discussed >to death in the NA-digest. And the lack of algorithm specification >for matrix /, \, etc. has caused more than a few surprises. This is a good one. In MatPy 1x1 matrix is different from a scalar. > > - Notation: To avoid confusion, I'll adopt matlab notation and invent > - a set of unique names in the following discussions: > >I'll trade all the fuss over notation for fuss over _definitions_. >I'm accustomed to using xGEMM, xGESVX, etc. in any language. Why >those rather than whatever the language throws at me? They're >well-defined. I know their error bounds and behavior in the face >of floating-point oddities. Give me those definitions, and I'll >take almost any notation. Hell, I've been putting up with the >BLAS and LAPACK naming scheme. Concerning the semantics of these operators, I think we only need a general agreement, leaving out algorithmic specifications to various packages. The advantage of Python over Matlab really shows here: Only the association between .* and __dotmul__ would be built into the language. The association between __dotmul__ and the actual implementation is handled by the classes that define __dotmul__. Whichever package you import you'll know its complete specification. The advantage is that this allows natural migration towards better algorithms without breaking any existing code. (Cf the migration from regex to re.) >Before anyone adds new notations for operations, you need to be >sure you have definitions for those operations. And good definitions >will exacerbate some of the numeric issues in Python. For example, Imho, the only possible resolution on this is to only provide pure math definition of these operators in the core language, leaving numerical specification to the packages that implement them. No one could prove that any of the numerical algorithms used today would be optimal forever, anyway. >Python doesn't provide reasonable ways to test for Inf or NaN. These >are needed in new eigenvalue routines (the only known optimal ones). >Yes, I know, there are some non-IEEE architectures left, but they >shouldn't be encouraged. (Keep in mind that I'm at Berkeley; expect >a strong IEEE-754 bias.) Agreed. Although this is not the topic here, it is really a big drag. How do Octave handle this on all platforms? I support the idea that Python should use IEEE whenever possible, as I don't buy Java's philosophy of using the common minimum of every platform. Would a NonIEEEError be possible? That might help users on those platforms to invoke their own error handling routines by catching this exception. [snip. Good links to various specifications. ] > - - How to deal with left division? > >How to compute it? Iterative or direct? With what pivoting >strategy if direct, or preconditioning if iterative? For which >matrix sizes? What about symmetric matrices? Treating them as >unsymmetric adds a _lot_ of error. I suppose that for any matrix class there could be many subclasses, such as symmetric matrix, triangular matrix, sparse, symmetric sparse, etc. For each of them the methods could be overridden to use the optimal algorithm for that specific type. Once the general framework is settled, users needing special cases would be able to contribute implementations without fearing collisions with others. Unlike matlab that is not object oriented, in python such selections of implementation can be dealt with by special classes instead of special methods. For really precision or efficiency critical applications, I think nothing beats special subclass where the user can fine tune the definition of every methods. >There's the possibility of Python being _better_ than Matlab, Octave, >SciLab, etc. and not just being equal to them. Complete agreement here. Huaiyu From matthias.huening at univie.ac.at Mon Jul 24 06:58:06 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Mon, 24 Jul 2000 12:58:06 +0200 Subject: Variables in strings.. References: <81324605608.20000724121203@buz.ch> <397C393F.E4AFEBB4@schneider-kamp.de> Message-ID: <8lh7gf$6702$1@www.univie.ac.at> Peter Schneider-Kamp schrieb in im Newsbeitrag: 397C393F.E4AFEBB4 at schneider-kamp.de... > Gabriel Ambuehl wrote: > > > > print "Hello $name" > > would do the job. Now the only solution I could find in Python was > > this awful > > print "Hello %(name)s" % var() > > There is of course: > > print "Hello", name > print "Hello", name[1] > ... and this: print "hello %s" % name print "hello %s" % name[1] Matthias -- matthias.huening at univie.ac.at http://www.ned.univie.ac.at/dt/ From urner at alumni.princeton.edu Thu Jul 27 19:01:35 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Thu, 27 Jul 2000 16:01:35 -0700 Subject: PY to HTML References: Message-ID: <3jd1osceobrf161hp83fhsdlnvi7o6dvpp@4ax.com> "Colin Meeks" wrote: >Does anybody know anything that will enable me to convert a Python script to >HTML, so I can display it on a webpage nicely formatted with syntax colour >coding. Manually coding is a pain in the posterior :-) > >Colin > Yes, some folks have put out the components you need, one of them by Guido's bro, Just van Rossum. You need py2html and PyFontify. I've made them downloadable for you at ftp://ftp.teleport.com/pub/users/pdx4d/python/ along with html.py -- a few lines I wrote to glue these together and make conversion easier. You just go: >>> import html >>> html.convert("turtles") # no file extension (assumes .py) OK and you'll have turtles.html (or whatever). Note: I changed py2html slightly to make its colors match the ones used by Windows IDLE. I've used this colorizing capability a lot at: http://www.inetarena.com/~pdx4d/ocn/numeracy0.html (my 'Numeracy + Computer Literacy' series, featuring Python as teaching language -- see the Python edu-sig for more ramblings and background about it). Also: the above utilities do not, so far as I know, color code cut 'n paste transcripts from the command window itself, just .py files. I still to quite a bit of manual colorizing of cut 'n paste sessions. Kirby From erno at iki.fi Tue Jul 18 10:07:33 2000 From: erno at iki.fi (Erno Kuusela) Date: 18 Jul 2000 17:07:33 +0300 Subject: Reading asynchronous data from a serial device References: <8kuvg0$kg2$1@nnrp1.deja.com> <1zIc5.1394$6E.263441@ptah.visi.com> Message-ID: >>>>> "Eric" == Eric Hopper writes: Eric> I'm not sure how to start it as a daemon thread. try Thread.setDaemon(). -- erno From level2junkie at my-deja.com Wed Jul 26 11:02:41 2000 From: level2junkie at my-deja.com (level2junkie at my-deja.com) Date: Wed, 26 Jul 2000 15:02:41 GMT Subject: SetupTK.py Message-ID: <8lmuif$lnd$1@nnrp1.deja.com> I am trying to run the SetupTK.py file that comes in with Gordon Mcmillan's software. Has anyone successfully run this script? I have tried and I keep getting this: D:\ICE DEV\Frame138b>python SetupTK.py Finding TK installation... Analyzing python dependencies of Tkinter D:\Program Files\Python\Lib\lib-tk\Tk ter.py analyzing win32api found KERNEL32.dll found USER32.dll found ADVAPI32.dll found SHELL32.dll found OLEAUT32.dll found PyWinTypes15.dll found python15.dll found MSVCRT.dll analyzing PyWinTypes15.dll found KERNEL32.dll found USER32.dll found ADVAPI32.dll found ole32.dll found OLEAUT32.dll found python15.dll found MSVCRT.dll analyzing python15.dll found KERNEL32.dll found USER32.dll found ADVAPI32.dll found WSOCK32.dll found WINMM.dll found MSVCRT.dll analyzing _tkinter found tcl80.dll lib not found: tcl80.dll dependency of found tk80.dll lib not found: tk80.dll dependency of found python15.dll found MSVCRT.dll found KERNEL32.dll Could not find tcl binaries! Operation aborted. I have been running tcl/tk on my machine for months, and I haven't had a problem with it before. All of my tcl/tk stuff still runs fine. I am at a complete loss as to why or how this couldn't work. I thought I had installed Tkinter correctly, all of my scripts that use Tkinter work great. Help. -Chris Sent via Deja.com http://www.deja.com/ Before you buy. From jerome.quelin at insalien.org Thu Jul 6 07:53:50 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Thu, 6 Jul 2000 13:53:50 +0200 Subject: tkinter frames problem References: <39643935.3DF3FF3C@structurex.net> Message-ID: <962884430.572613412@news.libertysurf.fr> walter hanagriff wrote: >this is just a framework i am using as a simplified test case for adding [snip] >i think that best explains what i want, any help would be appreciated I don't know if this is what you want, but check the code below (run it as a standalone app, it should work): -- File test.py #!/usr/bin/python from Tkinter import * class Main: def __init__(self, root): # The top label. text = 'this program figures the area, perimeter, and power of n' text = text + '\n' + '_'*len(text) Label(root, text=text).pack(side=TOP, fill=X) # The 'main' panel to command the option frame to show. self.var = StringVar() self.var.set('power') main = Frame(root, bd=2, relief=SUNKEN) Radiobutton(main, text="1 = Find the power of a number", value='power', command=self.update_frame, variable=self.var).pack(anchor=W) Radiobutton(main, text="2 = Find the area of a shape", value='area', command=self.update_frame, variable=self.var).pack(anchor=W) Radiobutton(main, text="3 = Find the perimeter of a shape", value='perim', command=self.update_frame, variable=self.var).pack(anchor=W) Button(main, text="Close", command=root.destroy).pack(padx=10, pady=10) main.pack(side=LEFT, padx=5, pady=5) # Create 3 frames, one for each option. self.frames = { 'power': Frame(root), 'area': Frame(root), 'perim': Frame(root) } # Populate the option frames at your convenience. prefix = 'this frame is where you put information to get ' list = (('power', 'power of n'), ('area', 'the area of a shape'), ('perim', 'the perimeter of a shape')) for (frame_name, text) in list: frame = self.frames[frame_name] text = prefix + text text = text + '\n' + '_'*len(text) Label(frame, text=text).pack(expand=YES, fill=BOTH) # We start with one frame. self.update_frame() def update_frame(self): # Unpack every option frame. for n in self.frames.keys(): self.frames[n].pack_forget() # Pack the current option frame. self.frames[self.var.get()].pack(side=RIGHT) if __name__== '__main__': root = Tk() root.title('test') start = Main(root) root.mainloop() -- End of file I throw up your class Func and swept a little your code. Hope this helps ? Regards, Jerome -- jerome.quelin at insalien.org From eq3pvl at eq.uc.pt.bbs Mon Jul 17 12:20:02 2000 From: eq3pvl at eq.uc.pt.bbs (eq3pvl at eq.uc.pt.bbs) Date: 17 Jul 2000 16:20:02 GMT Subject: Zope newbie Message-ID: <3bRI12$krv@openbazaar.net> coughlan at gothaminteractive.com wrote: > I've just installed Zope on Linux, and the documentation that comes > with it refers almost exclusively to NT!? There is very little on Zope > with Apace. > > Does anyone know of a URL or forum to get a decent tour of Zope on > Linux? zope.com is also *very* dissappointing. The website is www.zope.org > It's unclear to me how to even create a hello world program to make > sure it's installed and running. Any advice, would be appreciated. check in the /doc directory for install information. You don't need to use apache to check if Zope works, use Zope internal server instead. There are serveral ways to use Zope with Apache. For fastcgi, my favourite, in zope.org check for the fastcgi howto (under documentation-howtos). regards pedro From nobody at nowhere.nohow Sun Jul 16 12:14:23 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 16 Jul 2000 16:14:23 GMT Subject: help with tkinter coding References: <396FDD54.E2DD84FF@structurex.net> <8kpqee$7jn$1@nnrp1.deja.com> Message-ID: On Sat, 15 Jul 2000 13:54:28 GMT, John Grayson wrote: > >It just happens that one of the sample chapters for Python >and Tkinter Programming is on geometry managers. It might >help you understand how the Packer works... > > http://www.manning.com/Grayson/chapt05.pdf > I highly recommend John's book for somebody new to Tk. It's a well-written book, the examples are complete enough to be useful, and the editting job is first-rate: there are very few mistakes (especailly for a first edition). -- Grant Edwards grante Yow! HAIR TONICS, please!! at visi.com From fichou at katamail.com Mon Jul 24 16:01:00 2000 From: fichou at katamail.com (Patrick Fichou) Date: Mon, 24 Jul 2000 22:01:00 +0200 Subject: Python 3000 Message-ID: <8li7ah$ign$1@serv1.albacom.net> Anyone knows more about what will be Python 3000 ? It seems that it will be the next evolution of this language, after the 1.7 version. The big issue is that Python 3000 would not be compatible withe the actual 1.n language !? How it is possible and what it means ? Patrick From kpmurphy at my-deja.com Mon Jul 10 14:54:03 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 10 Jul 2000 18:54:03 GMT Subject: Tkinter Option (Radio) Buttons References: Message-ID: <8kd642$2qk$1@nnrp1.deja.com> In article , "dsavitsk" wrote: > If i have 3 option buttons created like in Interface() below I am able to > use Value() to determine which button is selected, Is there a bit of code > that i could add to Value() to disable certain buttons (i don't need the > if...elif's, just how to disable an option of my choosing.) or a better way > to do this. > > >>> def Value(): > ... global CnType > ... print CnType.get() > > >>> def Interface(): > ... CnType = IntVar() > ... CnType.set(0) > ... fm = Frame() > ... optTp = Radiobutton(fm5, text='Button 0', variable=CnType, value=0) > ... optTp.grid(row=0, column=0, sticky=W) > ... optTp = Radiobutton(fm5, text='Button 1', variable=CnType, value=1) > ... optTp.grid(row=0, column=1, sticky=W) > ... optTp = Radiobutton(fm5, text='Button 2', variable=CnType, value=2) > ... optTp.grid(row=0, column=2, sticky=W) > ... fm5.pack(side=TOP) > > thanks > doug > > i know that the attribute 'state' can be NORMAL or DISABLED. try giving each item a unique name, and then use the following command: button_1.apply(state=DISABLED) hope this helps :) -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From ciminna at operamail.com Mon Jul 31 07:45:38 2000 From: ciminna at operamail.com (Dr. V. Ciminna) Date: Mon, 31 Jul 2000 07:45:38 -0400 Subject: subscription to newsgroup Message-ID: <398566E2.C1FA02E2@operamail.com> please add the following email to your subscription list: ciminna at address.com From g2 at seebelow.org Mon Jul 31 14:01:43 2000 From: g2 at seebelow.org (Grant Griffin) Date: 31 Jul 2000 11:01:43 -0700 Subject: Python license (was RE: Python plug-ins for Adobe Products available) References: Message-ID: <8m4eu7$1tj1@drn.newsguy.com> In article , "Tim says... > >[Tim] >> ... >> We also want Python to remain GPL-*compatible*, and CNRI has changed >> some of the language in response to Richard Stallman's objections. > >[Grant Griffin] >> The following pointed question is directed at CNRI, not >> you, Tim, but... >> >> _Who died and left *Stallman* in charge_? > >I don't think CNRI reads comp.lang.python, so I guess I'll have to take a >crack at it myself: we did . >AFAIK, asking RMS to get involved was our idea, not CNRI's. So don't blame >them for this one! Many dozens of Python projects rely on GPL compatibility >today, and we don't want to see them get screwed. Sorry if I already missed it, but what in the heck is "GPL compatibility"? We in the Peanut Gallery aren't privy to the details of the license being considered, but AFAICT, Python's old (beloved) license was not what one might call "GPL compatible" in that it had virtually no restrictions. (The GPL preserves freedom mainly by restricting. That Richard Stallman is a genius!) So how was the _old_ one "GPL compatible"? (I'm confused...) >While I'm not directly >involved in the negotiations, I've seen much of the email traffic about it, >and RMS has been extremely helpful in explaining his concerns and even >suggesting specific changes to CNRI's language that he would accept. If GPL >compatibility is something you want to assure, can you think of anyone >better to ask than RMS? I sure can't. Whether you like him or not, Don't get me wrong, I like _him_ just fine: it's mainly his ideas and methods that I disapprove of. >he's >the most competent enitity in the universe to address GPL issues. Sorry but I'm confused again...if a qualified lawyer can't become a greater authority on a license after studying it for a bit (at $200 an hour ) than a genius-level Computer Scientist (at $200 an hour ), said contract probably isn't worth the bits it's written on--at least not to The Party of the First Part and The Party of the Second Part. Isn't the law run mainly by lawyers? (BTW, does anybody know if the GPL ever been tested in court?) >And he's >been a good friend to Python despite that it wasn't released under a GNU >license. Now _that's_ what I like about him: he's flexible. (i-guess-stallman-isn't-the-root-of-all-square-meanness-after-all -)-ly y'rs, =g2 p.s. I think one day, Richard Stallman will be remembered for helping create a great movement he never intended: "free software" in the Python, not GPL sense. _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From Norbert.Klamann at pobox.com.bbs Mon Jul 17 09:00:02 2000 From: Norbert.Klamann at pobox.com.bbs (Norbert.Klamann at pobox.com.bbs) Date: 17 Jul 2000 13:00:02 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems Message-ID: <3bRCd2$kCJ@openbazaar.net> In article , "Neil Hodgson" wrote: > 132 defaults to using Unicode for editing Python source code and the > interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, > find the OnInitialUpdate method and comment out the two lines under "# > Enable Unicode if we can". Save the file, shut down Pythonwin and restart it > and see if this fixes the problem. > > Yes, there should be an option to control this. > > Neil > > Thanks a lot, Neil, that fixes the problem Norbert -- Norbert Klamann Klamann Software & Beratung GmbH Erftstadt Germany Klamann.Software at pobox.com Sent via Deja.com http://www.deja.com/ Before you buy. From setok at fishpool.com Fri Jul 28 13:06:34 2000 From: setok at fishpool.com (Kristoffer Lawson) Date: 28 Jul 2000 17:06:34 GMT Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> Message-ID: <8lseiq$1trq$1@news.bbnetworks.net> In comp.lang.tcl Dan Kuchler wrote: : http://www.perl.org/perl6/pr/initial_meeting.html : Lots if interesting little tidbits in here. Of which the most interesting seems to be that they want Perl to be everything for everyone. Somehow I have this image of a star exploding. It'll probably still be popular, though... -- - ---------- = = ---------//--+ | / Kristoffer Lawson | www.fishpool.fi|.com +-> | setok at fishpool.com | - - --+------ |-- Fishpool Creations Ltd - / | +-------- = - - - = --------- /~setok/ From lars.lundstedt at telia.com Mon Jul 10 13:17:38 2000 From: lars.lundstedt at telia.com (Lars Lundstedt) Date: Mon, 10 Jul 2000 17:17:38 GMT Subject: Enumerating drives Message-ID: Anyone know how to enumerate drives (local and network) in Python? /LasseLu From paul at prescod.net Mon Jul 24 02:00:02 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 24 Jul 2000 01:00:02 -0500 Subject: Attributes PEP Enhancement Message-ID: <397BDB62.9BA93128@prescod.net> Okay, the strong preference of people on the list is for separate method handlers for __set_XXX__ and __get_XXX___. I propose the following algorithm to try and keep performance reasonable (though probably not as good as with the single-method proposal). When Python sees a class like this: class Foo: def __set_XXX__( self ): pass It would add two things to the class's dict. __set_XXX__ = XXX = Now let's say you see this code: Foo().XXX This will find the attribute handler object. It will discard that object immediately and *restart* its search at the beginning, now looking for __get_XXX__. In other words, it detects that XXX is a "special attribute" because of an entry in the dictionary but it uses full Python inheritance rules to find the appropriate method. In essence the attribute handler object is *just a flag* not a useful piece of information. The flag is important because how else would we know when to look for a __get_XXX__ function? When we are looking up attributes that do NOT have handlers, the performance should be identical to today. If you do this: foo=Foo() foo.__dict__["XXX"]=5 ...you will blow away all three attribute handlers for that attribute. You can get them back by reassigning the attribute handler flag object to foo.XXX. If there is no getattr defined then it looks for a generic __getattr__ (as per usual) and otherwise raises AttributeError. Setattr works like this: First it does a getattr to see if there is an attribute handler object. This first getattr can be optimized away for objects that have no attribute handlers at all. If there is no attribute handler flag for XXX, the code continues as with today's Python. If there is a handler flag, Python looks for a setter function. If it finds one, it calls it. If it can't find it then we have somewhat of a problem. We can either just allow the write using traditional Python rules or raise an AttributeError. I think that the latter is appropriate because remember what the former will do. It will *overwrite your handler*. That isn't a good default action. Another possible default action is to write to __XXX instead of XXX. It would be nice if foo.__dict__["XXX"] were "available" for use rather than reserved by the mechanism but I don't see how to work that and still get decent performance for property gets -- especially property gets that are NOT related to the feature. Anyhow, hacking your dictionary is ugly. Just use foo.__xxx . -- Paul Prescod - Not encumbered by corporate consensus New from Computer Associates: "Software that can 'think', sold by marketers who choose not to." From KatMouse at gmx.de Tue Jul 25 16:33:18 2000 From: KatMouse at gmx.de (Eduard Hiti) Date: Tue, 25 Jul 2000 22:33:18 +0200 Subject: Type inference for JScript.NET Message-ID: <8lktiq$rgv$14$1@news.t-online.com> There is an article on MSDN (http://msdn.microsoft.com/voices/scripting07142000.asp) about .NET enhancements of JScript, the Microsoft dialect of Javascript. Among the known things like compilation to IL bytecode there is mentioning of optional typing of variables to boost performance and even - type inference! (although rudimentary). Nice features - leaving the question: will there be something similar for python# | python.NET ? From jeremy at beopen.com Mon Jul 10 09:47:36 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 10 Jul 2000 09:47:36 EDT Subject: Feature Request: IPv6 support built into 1.6/2.0 References: Message-ID: Olmy writes: > Has there been any consideration of rolling the KAME IPv6 patches > to Python into the official release? No once considered it before your message arrived. > It would be quite interesting to start using python to code > some small ipv6 utilities here and there. > > Any thoughts? Are there more appropriate methods to submit feature > requests? Two thoughts: - I don't know of any developers running on an IPv6-enabled machine. It's hard to test patches if we can't run the code. - If we can find someone who can test the IPv6 pathces, that person can submit them using the SourceForge patch manager. http://sourceforge.net/patch/?group_id=5470 -- Jeremy Hylton From hsl at tcp.co.uk Tue Jul 11 00:55:29 2000 From: hsl at tcp.co.uk (Martin Rand) Date: Tue, 11 Jul 2000 05:55:29 +0100 Subject: Language Challenge -- Results References: <396A493A.DE1DF77B@sdynamix.com> Message-ID: On Mon, 10 Jul 2000 15:07:54 -0700, bv wrote: > >Language Challenge 2000 -- Results > >Contest entries have been tabulated and you're invited to find out how >different languages fared. View the effortless solution of this >technical problem embodying a central theme of modern engineering and >scientific practice -- computer aided optimal design. > >We'd like to particularly encourage a visit by the younger generation >which probably never even saw a code without trailing semicolons, and to >those who are curious how to "roll your own" before purchasing expensive >optimization toolboxes. > >To view the contest summary please click on the "Language Challenge >2000" on http://sdynamix.com > Er.... where was this "language challenge " publicized *before* it was closed to all further entires? -- Martin Rand Highfield Software Ltd mwr at highfield-software.co.uk Phone: +44 (0)23 8025 2445 Fax: +44 (0)23 8025 2445 From alex at magenta.com Mon Jul 3 05:07:43 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 3 Jul 2000 11:07:43 +0200 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> <962367319.379353174@news.libertysurf.fr> <395D79FE.4E4FDBCE@colconsulting.com> Message-ID: <8jplbd0l5c@news2.newsguy.com> Frank V. Castellucci wrote in message news:395D79FE.4E4FDBCE at colconsulting.com... > Jerome Quelin wrote: > > > > "Alex Martelli" wrote: > > >By calling the accessors, rather than accessing the data > > >directly, you ensure that if somebody overrides the > > >accessor functions in a derived class you'll be calling > > >the derived-class versions of those functions. If that is > > >what you want (one direction along which you want to let > > >inheritors of your class extend or tweak behaviour), then > > >it's probably worth the overhead you mention. > > The class isn't to be derived any further. It's a class that I use in an > > application, and that may be imported in some other applications, but not to be > > inherited. Then, "do the simplest thing that could possibly work" applies. > > Then, is it better/cleaner to access private members with accessors or not? > > Is it a matter of style? Or are there hidden caveheats using (or not using) > > accessors? It _seems_ cleaner to use accessors, but man, it's quite awkward. I would not use accessors that feel awkward to you, without specific purpose. > As you really have no way to "prohibit" further derivation (unless I > missed the "final" keyword in the reference), using your accessors and > praying that anyone over-riding the accessor/mutator methods does the > proper thing would be my direction. Such "prohibition" is not hard at all: class dontderive: def __init__(self): if self.__class__ != dontderive: raise "told you not to!" class foo(dontderive): pass However, I wouldn't normally do it, again under the "simplest thing" principle. Just documenting "this class is not meant to be derived from, so, just don't do it, or results will be unpredictable" is likely to be "the simplest thing that could possibly work" in this case. Alex From jwbnews at scandaroon.com Sat Jul 1 23:52:33 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sat, 01 Jul 2000 20:52:33 -0700 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> <395EAF62.4A628573@uniserve.com> Message-ID: In article <395EAF62.4A628573 at uniserve.com>, Bob van der Poel wrote: > Paul Prescod wrote: > > > > Bob van der Poel wrote: > > > > > > ... > > > > > > Is this just a good habit being developed by those who think that > > > classes are better than functions, or god forbid, inline code? > > > > Given what you've said, that one-function class looks pretty bizarre. Is > > there maybe something else useful about it that you haven't noticed? > > Classes are not better than functions. They are just different. In most > > cases, you use classes when you need to combine data and instructions. > > Yes, that I understand. In some of the example code I've seen there is > only the __init__ function and no data. That's why it doesn't make sense > to me. Maybe I'm just having a bad day..... Is there anything about those classes such that deriving from them would make sense? If not, it's probably just a style issue (someone coming from SmallTalk--to pick one example--where there isn't any code outside some class might well do that). Also, if the module is going to be imported, the code is handier if it isn't at the top level of the module: import time may well not be the right time for the code to be run. That wouldn't explain class vs function, though. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From rlytleNOrlSPAM at tqs.com.invalid Mon Jul 17 18:26:18 2000 From: rlytleNOrlSPAM at tqs.com.invalid (Rob) Date: Mon, 17 Jul 2000 15:26:18 -0700 Subject: problems trying wxPython in Win 95 References: Message-ID: <0d24a28c.ebd70b08@usw-ex0110-076.remarq.com> I got wxPython to work, mostly. I installed the update for WinSock for win95. I was able to try the demo, but did get the "blue screen of death" upon exiting. rob * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful From neilh at scintilla.org Sun Jul 30 08:47:23 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 30 Jul 2000 12:47:23 GMT Subject: Calling C Function Pointers from Python References: <8ltqvn$pbl$1@nnrp1.deja.com> <39840d9b_1@news.newsfeeds.com> <39841e3a_1@news.newsfeeds.com> Message-ID: > > Here is a sequence of calls: > > > > import calldll > > kernel32 = calldll.load_library('kernel32.dll') > > Beep = calldll.get_proc_address(kernel32, "Beep") > > ret = calldll.call_foreign_function(Beep,'ll','l',(1000,500)) > > > > Neil > > Thx. Can you (additionally) explain the meaning of 'll' and 'l' and give an > example where I receive a return value (a double for example)? The second argument, "ll" in this case is the shape of the arguments (two long ints in the example) and is defined in the "Extending and Embedding..." document. The third argument is the shape of the return value, a long int here. The last argument is a tuple contining the arguments to the called function. The example code is already receiving a return value indicating whether the Beep succeeded. The readme.txt says "calldll.call_foreign_function does not yet support returning 64-bit quantities (like C doubles)". Neil From donn at u.washington.edu Fri Jul 14 12:11:15 2000 From: donn at u.washington.edu (Donn Cave) Date: 14 Jul 2000 16:11:15 GMT Subject: getpid Usage References: <8kksms+n5h5@eGroups.com> Message-ID: <8kne33$4qmq$1@nntp6.u.washington.edu> In article <8kksms+n5h5 at eGroups.com>, david at tumbleweed.com wrote: | Is there some convenient way of getting os.getpid to return the PID of | a given executable? What I want to do is start a process and know it's | PID. When I do the following I get the PID of the python executable. | | os.system("path") | os.getpid() Give me a break, in that example the "path" process should have exited when control returns from the system() function, so there is no PID left to report. So the first question we have to ask is, what are you really doing here? Do you append an & to the command to get the shell to run it in the background and exit? Or does your particular command do this on its own? In the first case, there are a couple of things you can do. You can exec the command directly as the shell would do, rather than using system() to invoke a shell. The popen2 module does that, for an example, and you can ignore the pipe, dup and close stuff there. The parent fork will get the child's PID value from fork(). The other option would be something like os.popen('cmd &\necho $!', 'r'). You will get back the PID as a text string in the pipe. In the second case, there's nothing you can do without control over the application, since that's where the fork you're interested in occurs. As already suggested in another followup, in such a case the application ought to write out its PID to a file, in the standard location for your platform - /var/run, /etc, whatever. Donn Cave, donn at u.washington.edu From swun at eSec.com.au Mon Jul 17 02:33:02 2000 From: swun at eSec.com.au (Sam Wun) Date: Mon, 17 Jul 2000 16:33:02 +1000 Subject: example on how to use configparser in python? Message-ID: <3972A89E.DC9CFD19@eSec.com.au> Does anyone have that? Thanks Sam. From hopper at omnifarious.mn.org Tue Jul 18 12:14:57 2000 From: hopper at omnifarious.mn.org (Eric Hopper) Date: Tue, 18 Jul 2000 10:14:57 -0600 Subject: Does Python support interfaces? References: Message-ID: In article , Justin Sheehy wrote: > > Just define the class, and make sure that it provides the proper > interface. Note that I'm not using "interface" with any special > language-dependent meaning here. If it behaves properly, it behaves > properly, and that is all that matters. Whee! Inheritance by mysteriously coinciding method names is so much fun! -- Eric Hopper (hopper at omnifarious.mn.org) (http://www.omnifarious.org/~hopper) From mfletch at tpresence.com Sun Jul 23 01:00:21 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 23 Jul 2000 01:00:21 -0400 Subject: bit manipulation frustration Message-ID: list( string) is one of the other ways :) . Enjoy, Mike -----Original Message----- From: David Goodger [mailto:dgoodger at bigfoot.com] Sent: Sunday, July 23, 2000 12:41 AM To: python-list at python.org Cc: jkraska1 at san.rr.com Subject: Re: bit manipulation frustration ... >>> s="abcd" >>> map(None, s) ['a', 'b', 'c', 'd'] ... From Norbert.Klamann at pobox.com Mon Jul 17 08:46:10 2000 From: Norbert.Klamann at pobox.com (Norbert.Klamann at pobox.com) Date: Mon, 17 Jul 2000 12:46:10 GMT Subject: Pythonwin 132: Letters with Umlaut cause problems References: <8kuhnd$bh3$1@nnrp1.deja.com> Message-ID: <8kuv6f$kcg$1@nnrp1.deja.com> In article , "Neil Hodgson" wrote: > 132 defaults to using Unicode for editing Python source code and the > interactive window. To stop this, open Pythonwin\pywin\scintilla\view.py, > find the OnInitialUpdate method and comment out the two lines under "# > Enable Unicode if we can". Save the file, shut down Pythonwin and restart it > and see if this fixes the problem. > > Yes, there should be an option to control this. > > Neil > > Thanks a lot, Neil, that fixes the problem Norbert -- Norbert Klamann Klamann Software & Beratung GmbH Erftstadt Germany Klamann.Software at pobox.com Sent via Deja.com http://www.deja.com/ Before you buy. From stadt at cs.utwente.nl Wed Jul 12 10:15:29 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Wed, 12 Jul 2000 16:15:29 +0200 Subject: CyberChair available Message-ID: <396C7D81.DFC479BE@cs.utwente.nl> It didn't work for comp.lang.python.announce: ===================== Hi. This is the qmail-send program at starship.beopen.com. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. : Sorry, no mailbox here by that name. (#5.1.1) ===================== So, here is the announcement: CyberChair, an online paper submission and reviewing system (for conferences and workshops), which has been used for the European Conference on Object-Oriented Programming (ECOOP) since its 1997 edition, and by some other conferences as well, is now available under the GNU General Public License. CyberChair was written in Python (http://www.python.org). At least version 1.5.1 is needed. Until recently I had not read anything else than the Python tutorial and this newsgroup, so CyberChair may contain "silly" Python code which could be improved. My colleague Fred Gansevles (who pointed me at Python 4 years ago - thanks:-) helped me out with some problems. To get CyberChair, visit http://www.cyberchair.org/requestUse.html, fill in the details of your webserver and conference or workshop, and download the generated customized version. Before downloading, you may want to try the demo system, which has been installed at the CyberChair homepage (http://www.cyberchair.org). Cheers, Richard van de Stadt From steedman at quake.cs.fsu.edu Sun Jul 23 05:09:46 2000 From: steedman at quake.cs.fsu.edu (Ronald Steedman) Date: 23 Jul 2000 09:09:46 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l7kkl$2bv$2@gxsn.com> Message-ID: <8lecoq$o7l$4@news.fsu.edu> Michael Abrash wrote an article on creating micro-languages in assembly to create extremely fast programs that perfectly fit the problem domain. He believed with good reason that they could outperform both C/C++ and general purpose scripting language while allowing easier coding. He also didn't believe that they were very difficult to program. Tradeoffs would include resources allocated to develop the language as well as training time to teach new employees how to use it effectively. You would also need a programmer with a thorough knowledge of assembly. -- Ron Steedman In comp.games.development.programming.misc Sean Wilson wrote: : Before I started trying to write my own scripted language I tried to find : some tutorials and articles on them but couldn't get them anywhere. Someone : directed me towards python but I couldn't find anything about the virtual : machine it uses. How does it work and why is it so slow? : My system is extremely simple and only allows assembly style instructions : but I cannot really see how it can be made faster. Using the 'Move : ' command, the following list of : integers are produced for Move Up 3 (where capitals are constant values): : CMD_MOVE : CONSTANT : DIR_UP : CONSTANT : 3 : I just have a big 'switch' statement which the first integer is sent to, : with each command having matching 'case' statement. The relevant command : code then reads in one parameter at a time, moving the current integer : pointer in the script forward after each. The parameters are then send to : the C++ Move function to be executed. : I found a tutorial on Flipcode which used a stack machine but this seems : very slow compared to this approach. One big disadvantage though of my : approach is that I'm allowing no compound statements (e.g. Move Up (1 + 2)), : but this isn't a problem since the game is based on a 2d tile map. : What other methods are there? How do professional games such as Unreal do : it? : Regards, : Sean Wilson : http://www.users.globalnet.co.uk/~neutron/programming From smigowsky at dspace.de.bbs Mon Jul 17 06:50:03 2000 From: smigowsky at dspace.de.bbs (smigowsky at dspace.de.bbs) Date: 17 Jul 2000 10:50:03 GMT Subject: Memory leak problems with python and COM Message-ID: <3bR9KR$l0C@openbazaar.net> Hi, you didn't miss the 131 build. This build was purely to test against the developer version von Python 1.6. So the release numbers would be ... 128, 129, 132 Stefan >-----Original Message----- >From: Etienne Labuschagne [mailto:etiennel at geospace.co.za] >Sent: Monday, July 17, 2000 9:17 AM >To: python-list at python.org >Subject: Re: Memory leak problems with python and COM > > >Hi there > >To my embarrasment I found that I am still using Python build >129 and that I >(somehow) missed the release of build 131! > >Anyway, build 131 solved the problem! > >Thanks for your help. > >Regards >Etienne > >"Mark Hammond" wrote in message >news:8klbu9$38u$1 at nnrp1.deja.com... >> In article <963474833.835936 at proxy.lia.net>, >> "Etienne Labuschagne" wrote: >> > Deleted a and b on the python side and then destroying the COM >> server - that >> > doesn't clear up the memory. I am using SafeArrayAccessData and >> > SafeArrayUnlock on the server side to make sure that it >releases the >> data on >> > the server side. >> > >> > Is there something else that I must do? >> >> I suggest you get the latest CVS version (I realize this may be a >> PITA :-( Since build 132, a number of leaks have been >fixed. There is >> a very good chance that this particular leak was plugged previously. >> >> If not, I will definately look into this and plug it! >> >> Mark. >> >> >> Sent via Deja.com http://www.deja.com/ >> Before you buy. > > >-- >http://www.python.org/mailman/listinfo/python-list > From ktwyzq at money=$$$.com Sat Jul 1 13:22:15 2000 From: ktwyzq at money=$$$.com (ktwyzq at money=$$$.com) Date: 1 Jul 2000 17:22:15 GMT Subject: Online = $$$ ; Offline = $$$ too !! Message-ID: <8jl9c7$jgl@elod.vein.hu> pfsedwkhqymliwdmpbvcmjhtrmdugzgulwghwhdnrqgucunrmswtgyxkdzycxhephvbuqzznsnqozppgrteznfxfkgxjvfmpsezbmqmblppyfuswudncmpswfguydhnomwbhqsxvlzy begin 644 d:\Advertisement\cyberking\1st name.html M/"%D;V-T>7!E(&AT;6P@<'5B;&EC("(M+R]W,V,O+V1T9"!H=&UL(#0N,"!T M Message-ID: On Mon, 31 Jul 2000 pauljolly at my-deja.com wrote: > Dear All, > > Firstly, apologies for all the questions! However, extensive searching > and reading of manuals has not helped me here. How does one remove > whitespace characters from a string (using the re module)? I don't understand what you're doing here: trim whitespace off the ends? string.strip(s) Take out all whitespace? string.join(string.split(s), '') Or string.replace(s, ' ', '') (Which is the same thing) -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From richard_chamberlain at ntlworld.com Sat Jul 8 01:42:09 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Sat, 8 Jul 2000 06:42:09 +0100 Subject: Newbie: Development plaform References: <20000707190803.4740.qmail@web210.mail.yahoo.com> Message-ID: Hi Demos, Tkinter is the de facto gui standard for Python because of its maturity and it's cross platform ability, it's very much a matter of opinion though. wxPython has a lot more widgets than Tk but I found Tk more intuitive to use. Grayson's Python and Tkinter programming may be worth picking up as it has excellent coverage of Tkinter and has a chapter on distributing applications. Richard Demos Economacos wrote in message news:20000707190803.4740.qmail at web210.mail.yahoo.com... > Hello, > > I am comtemplating development of a system that will > have to run on Linux, Win and Mac. > > My questions are: > What GUI tool and Database (< 100,000 recs) would you > recommend? > How to distribute programs to us > > Thanks > > Demos > > > > > __________________________________________________ > Do You Yahoo!? > Send instant messages & get email alerts with Yahoo! Messenger. > http://im.yahoo.com/ > From cg at gaia.cdg.acriter.nl Mon Jul 24 14:59:58 2000 From: cg at gaia.cdg.acriter.nl (Cees de Groot) Date: 24 Jul 2000 20:59:58 +0200 Subject: Python in game development? References: <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: <8li3ne$80p$1@gaia.cdg.acriter.nl> Gerry Quinn said: >Changing things at random and hoping the problem goes away is not the >way to fix bugs. > No, but it is certainly a venerable development style: try stuff interactively and then cut'n'paste code from a scratch pad to the actual code base. (and I don't think the original comment mentioned doing stuff "at random". The idea is that you can debug incrementally while the system is running, by making partial fixes with instant feedback. Plus, poking around to see where the buggy stuff is becomes much easier) -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/ From thomas at xs4all.net Thu Jul 6 07:19:18 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 13:19:18 +0200 Subject: function arguments In-Reply-To: ; from johannes@zellner.org on Thu, Jul 06, 2000 at 12:57:49PM +0200 References: Message-ID: <20000706131917.J13478@xs4all.nl> On Thu, Jul 06, 2000 at 12:57:49PM +0200, Johannes Zellner wrote: > is there a way to get a functions argument list ? > def fun(fred, lola): > ... > something like `arglist(fun)' should return [ 'fred', 'lola' ] If I'm not mistaken, that would be: fun.func_code.co_varnames[:fun.func_code.co_argcount] Except that it returns a tuple, not a list. dir() is your friend ;) Also, you might want to look at the IDLE source for that kind of information. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From hzhu at localhost.localdomain Mon Jul 17 21:20:16 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 01:20:16 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735A82.8B4D0489@prescod.net> <3973A347.3ABCB12F@prescod.net> Message-ID: On Mon, 17 Jul 2000 19:22:31 -0500, Paul Prescod wrote: >I don't think you need __getattr__ > >class Matrix: > def __init__( self, ....): > self.T=Transpose( self ) > self.H=Hermitian( self ) > self.I=Inverse( self ) > self.C=Conjugate( self ) > self.E=Elementwise( self ) > self.M=self # matrixwise is default > ... other matrix-like methods ... > >class Transpose: > def __init__( self, mymatrix ): > self.mymatrix=mymatrix > ... other matrix-like methods, but transposed ... > >Notice that no computation (e.g. actual transposition) needs to be done >until you actually need to calculate a value. Maybe you can find >optimizations that allow only tiny parts of matrices to be computed. This is interesting. I suppose the computational cost is minimum. What about implementation? Do I have to write everything five times? Right now I'm even using .T() to avoid writing both left and right computations. It cost some computation but saves a lot of implementation and maintainence. Note that even one liners are relatively big cost because most of the current functions are just one liners. Huaiyu From thomas at xs4all.net Wed Jul 5 18:13:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 6 Jul 2000 00:13:48 +0200 Subject: __getattr__ and pickle In-Reply-To: ; from embed@NOSPAM.geocities.com on Wed, Jul 05, 2000 at 02:58:43PM -0400 References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <20000706001348.E13478@xs4all.nl> On Wed, Jul 05, 2000 at 02:58:43PM -0400, Warren Postma wrote: > "Gordon McMillan" wrote in message > news:8F655BA3Egmcmhypernetcom at 199.171.54.154... > > C'mon Sean! You've been around a while. You know when __getattr__ hacks go > > bad it's because they go recursive. (And the stack size on Windows is off > > by some tiny amount, so it GPFs instead of traps.) > That kinda says (a) Windows Sucketh, and (b) surely there must be a > workaround for the Infinite-Recursion-Crash bug? Well, there is. There's this little counter that keeps track, but the recursion counter is set too high for Windows, apparently, so it chooses to crash before Python stops itself. > Oh yeah, there is, .... It's called Christian Tismer's Stackless Python. > Hope that stackless makes it into the official python, by 1.7, or if not, > there's always 3000. Here's hoping. There is no 1.7, the next release is going to be 2.0, not 1.6 ;) At least, that's what the CVS tree is calling itself. As for Stackless, I agree it's a thing of coolness, but it won't help you out in infinite recursion; it's stackless, not limitless. You'll run out of memory eventually. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From karl_python at sub.ulbrich.org Thu Jul 20 19:58:21 2000 From: karl_python at sub.ulbrich.org (Karl Ulbrich) Date: Thu, 20 Jul 2000 19:58:21 -0400 Subject: Uploading forms+files via Python script -- no luck Message-ID: <20000720195821.K11463@exeter.exeter.org> I've written a script that's supposed to perform an http POST in order to upload a mix of fields and files to a webserver, based on examples referred to in previous posts on this topic here. To test this script, I wrote a simple python cgi script that receives a form POST then prints out everything that showed up in FieldStorage. The test-script shows the form values if I make a simple form and post fields and/or files from Internet Explorer (or Netscape). When I use my upload script to attempt to post, however, I never see any cgi form contents. :-( Using netcat to catch the raw HTTP traffic, I captured both the http upload output of IE and my script, but didn't see any differences in formatting/MIME stuff that looked detrimental. But, something's gotta be wrong, because Python (and presumably other webservers -- the real point) doesn't think I've sent a form. :( Many thanks to anyone who spots the problem!! Thanks, Karl Ulbrich p.s. It would be great if urllib did this... I'd offer to do it, but, well, it doesn't work! ............... THE RECEIVE SCRIPT (install as a CGI) ............... #!/usr/bin/python # This script simply echos out FieldStorage contents for-debugging # (this script works just fine) import sys,os,cgi,glob,string sys.stderr = sys.stdout data = cgi.FieldStorage() print "content-type: text/html\n" print "

Echo Form Contents

" print str(len(data.keys())) + " Keys found in data.keys(): " for key in data.keys(): print key, '\t' print "" for item in dir(data): print "", "", print "", "" print "
", item, "", getattr( data, item), "
" .............. THE (broken) UPLOAD SCRIPT ......................... #!/usr/bin/python #!/usr/local/bin/python # # Summary: First stab at a general web form-and-file POST uploader # Author: Karl Ulbrich # # Liberally borrows and addapts from: # FileTransfer.py - CGI file transfer, may require Python 1.5 or higher # Prior Author/Version: # JeffBauer at bigfoot.com http://starship.python.net/crew/jbauer/cgiupload/ # Prior art: Aaron Watters, Jim Fulton import os, sys, traceback import httplib #import tempfile from whrandom import randint from string import join from time import time class FileUploadRequest: """Client-side CGI form/file POST upload.""" def __init__(self, uri, host, port): self.uri = uri self.host = host self.port = port self.queryString = None self.boundary= '%s%s_%s_%s' % \ ('-------', int(time()), os.getpid(), randint(1,10000)) self.parts = [] ## collect each multipart as a single list-entry def loadfile(self, filename, fieldname, headerDict=None): """Add a file to the multipart upload.""" f = open(filename, 'rb') data = f.read() f.close() hdr = [] hdr.append( '%s' % self.boundary ) hdr.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (fieldname,filename)) hdr.append('Content-Type: application/octet-stream') # hdr.append('Content-Length: %d' % len(data)) # Add user-defined header values here, if provided. if type(headerDict) == type({}): for k in headerDict.keys(): hdr.append("%s: %s", (k, headerDict[k])) part='%s\n\n%s' % ( join(hdr,'\n') , data ) self.parts.extend( [part] ) def loadfield(self, fieldname, data, headerDict=None, ): """Add a field to the multipart upload.""" hdr = [] hdr.append( '%s' % self.boundary ) hdr.append('Content-Disposition: form-data; name="%s"' % fieldname ) #hdr.append('Content-Length: %d' % len(data)) # Add user-defined header values here, if provided. if type(headerDict) == type({}): for k in headerDict.keys(): hdr.append("%s: %s", (k, headerDict[k])) part='%s\n\n%s' % ( join(hdr,'\n') , data ) self.parts.extend( [part] ) def request(self): query = '%s\n%s' % ( join(self.parts,'\n'), self.boundary ) print "=====BODY DATA BEGIN (DEBUG)=====" print query print "=====BODY DATA END (DEBUG)======" contentType = 'multipart/form-data; boundary=%s' % self.boundary contentLength = str(len(query)) h = httplib.HTTP() h.connect(self.host, self.port) h.putrequest('POST', self.uri) h.putheader('Accept', '*/*') h.putheader('Proxy-Connection', 'Keep-Alive') h.putheader('User-Agent', 'PyFormsPoster/0.1') h.putheader('Content-Type', contentType) h.putheader('Content-Length', contentLength) h.endheaders() h.send(query) rcode, rmsg, headers = h.getreply() response = h.getfile().read() print "Return Code: %s\n" % rcode #if rcode != 200: # msg = "error: %s, %s\n%s %s" % (rcode, self.uri, rmsg, response) # #raise FileUploadRequestException(msg) # raise "FileUploadRequestException", msg return response def testecho(): usage = 'usage: cgiupload filename' if len(sys.argv) < 2: print usage sys.exit(1) filename = sys.argv[1] uri = '/cgi-bin/echoform.py' host = '10.10.10.2' port = 80 #port = 8888 F = FileUploadRequest(uri, host, port) F.loadfile(filename,'file1') #F.loadfile(filename,'file2') F.loadfield( "yourname" , "Arthur, of Camelot" ) F.loadfield( "summary" , "Perhaps if we built a large wooden Badger..." ) F.loadfield( "details" , "Run Away!" ) F.loadfield( "submit" , "submit the page" ) response = F.request() print response if __name__ == '__main__': if os.environ.has_key('SERVER_PROTOCOL'): FileUploadAcquisition(os.environ) else: #test() testecho() ........... A SIMPLE HTML FORM ................................

Sends to echoform.py on 80


Your Name 
Summary   
File #1   
Details   
          
From ralf.claus at teleatlas.com Wed Jul 5 01:07:13 2000 From: ralf.claus at teleatlas.com (Ralf Claus) Date: Wed, 05 Jul 2000 07:07:13 +0200 Subject: WinNT User Name References: Message-ID: <3962C281.405FB34E@teleatlas.com> michael montagne wrote: > > First off, I'm a newbie at Python. > I'm trying to return the user who is logged on at a PC. What I really need > is the login name. How do I do that? Seems like it otta be quite simple > but I'm having trouble. > > -mjm ..and finally import getpass username = getpass.getuser() works on both systems (NT,UNIX), if you need. From fsanchezpr at teleline.es Sat Jul 29 21:10:59 2000 From: fsanchezpr at teleline.es (Paco) Date: Sun, 30 Jul 2000 01:10:59 GMT Subject: visita mi web Message-ID: http://www.terra.es/personal2/fsanchezpr/navega.htm From cjc26 at nospam.cornell.edu Tue Jul 25 19:47:05 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 25 Jul 2000 23:47:05 GMT Subject: Memory management References: <8lkdh5$qpm$1@news.rchland.ibm.com> Message-ID: * Larry Whitley menulis: | I'm running out of virtual memory on my NT 4.0 system running a longish | python script. Python says "memory error" and quits. NT shows the | application using 130+ megabytes. I have 192 megabytes on the system so it | seems like a rational number. I suspect that this means that I have a | memory leak in my code. There have been some modules written to detect cycles in your data structures (which are the usual cause of memory leaks), for example Cyclops at -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From spamfranke at bigfoot.de Mon Jul 3 20:22:37 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 04 Jul 2000 00:22:37 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <8jabvo014tv@news2.newsguy.com> <8jqbru017gf@news2.newsguy.com> <2f985.6708$Tb7.40527@news-server.bigpond.net.au> Message-ID: <39642dc0.16230059@news.btx.dtag.de> On Mon, 03 Jul 2000 23:22:38 GMT, "Mark Hammond" wrote: >A framework for calling arbitary vtable interfaces is also in place. I would *really* appreciate such a thing. Any pointers? Stefan From digitig at cix.co.uk.bbs Sun Jul 16 16:20:19 2000 From: digitig at cix.co.uk.bbs (digitig at cix.co.uk.bbs) Date: 16 Jul 2000 20:20:19 GMT Subject: Top 10 Language Constructs (Phyton) Message-ID: <3bQYbJ$hW4@openbazaar.net> In article <8kmtab$4or$1 at pollux.ip-plus.net>, GustavsB at ch.sibt.com (Bruno Gustavs) wrote: > "Dinu C. Gherman" wrote in message > news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... > > What do you mean by "language constructs", Python keywords > > like "for" or "class"? Are you expecting some statistics of > > used keywords over one's own code? > > > > I doubt this will be very useful, like the answer to the > > question: "Which are the ten most used words in English?". > > But maybe I'm not understanding well how you think you'll > > benefit from such an answer... > > Lets assume you're going to design Phyton2. What would this > language contain? What should Phyton2 support? What would you > like to solve with Phyton2? People's "top 10 constructs" would be a disastrous basis for such a language. I'm trying to remember the name of a language I used many years ago that was designed by government committee. It had about 10 ways of doing some obscure things (because everybody on the committee had contributed their favourite solution) but no ways of doing quite ordinary things (because everyone on the committee used those things but none of them noticed them). The result was like a car with three different air-conditioning units and no engine. /Much/ better IMHO is to see what application domains Python is particularly strong in, and to try to find out what distinguishes Python in those domains. Then look for ways it can be improved in those specific domains and expanded into closely related domains. At the moment there are things I use Python for and things I use Ada for. If the next version of Python tried to muscle in on the mainstream Ada territory it would almost certainly find that Ada still did those things better but the attempted shift had broken it's advantage in those things it was good at before. From herzog at online.de Mon Jul 31 12:56:44 2000 From: herzog at online.de (Bernhard Herzog) Date: 31 Jul 2000 18:56:44 +0200 Subject: formatting (was Re: Perl is worse!) References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> <8luhso41ce8@news2.newsguy.com> <8m1f0462n4o@news2.newsguy.com> <8m3ri602ej2@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > Python isn't beyond criticism here, by the way. As an > alternative to the % _operator_, a named-function (to > be provided as a built-in) could perfectly well have been > chosen by our BDFL: > > format(formatstring, a, b, c) > > or > > format(formatstring, vars()) > > isn't (IMHO) any less readable than the current > > formatstring % (a,b,c) > > or > > formatstring % vars() > > just _slightly_ more verbose, but, again IMHO, that slight > extra verbosity would be in a good cause. A function also has the advantage that it could be extended more easily. The % operator has only two arguments which doesn't leave much room for new features. In Sketch, for example, I've implemented a format function that supports user defined conversions: format(template, dict, converters) The template string can contain conversions of the form %(key)[converter] which is replaced by the value of converters["converter"](dict["key"]) The graphics objects in Sketch which don't know anything about user preferences for units supply both the template and dict and the UI code provides the converters for lenghts and positions so that e.g. the template "%(width)[length]" and the dict {'width': 72} are displayed as "72 pt" or "2.54 cm" depending on user preferences. This setup coventiently puts all knowledge about the preferred units in one place. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From tim_one at email.msn.com Thu Jul 27 02:24:25 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 27 Jul 2000 02:24:25 -0400 Subject: "always passes by reference" In-Reply-To: <397FCF58.9F254AA2@see.my.signature> Message-ID: [Tim, quoted out of context] > Anyone thinking about references under the covers is just confusing > their mental picture -- only the implementers have to worry about > that, and even then rarely. [Greg Ewing] > How can you have a correct mental picture of the Python > data model that doesn't contain anything corresponding > to a reference? In context, the paragraph was talking about Python's parameter-passing mechanism, which is not (as you agreed in your own reply!) what "call by reference" suggests to people, and particularly not to the person who brought it up. That's the sense and the context in which thinking about references under the covers is just confusing. You called Python's mechanism "call by spanish inquistion"; I called it "call by object". > Whether you call it that or not, there has to be something > in the model that is not-the-object but somehow identifies- > the-object, so that the object can appear in more than one > place at a time without having multiple copies of it. Oh, Greg -- that's so either/or. Didn't you know that Python is the first truly post-modern quantum language ? an-object-is-in-all-places-simultaneously-ly y'rs - tim From paul at prescod.net.bbs Mon Jul 17 14:10:02 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 17 Jul 2000 18:10:02 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up Message-ID: <3bRKgQ$mbr@openbazaar.net> "G. David Kuhlman" wrote: > > ... > > Now, I ask you, what other scripting language would enable me to > support that breadth of users? Incredible. IMHO, the ability to crawl into niches is the feature that makes Python's ascendency inevitable. Any particular "killer app" could die and the others will carry it forward. Any particular operating system could die and Python would thrive on the remaining ones. (in fact the (unlikely) death of Windows would drive VB programmers into Python's arms and the (equally unlikely) death of Unix would drive Perl users to Python) I think Python is a very safe bet, even compared to more established languages. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From alex at magenta.com Wed Jul 26 15:04:06 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 26 Jul 2000 21:04:06 +0200 Subject: Deleting files with wildcards References: <397f046d.193858654@news.atnet.at> Message-ID: <8lncs70240i@news2.newsguy.com> "Manfred Pisecky" wrote in message news:397f046d.193858654 at news.atnet.at... > Hello everyone! > > I have to delete a bundle of files, e.g. *.txt in a portable way (it > must work for Linux and NT). > > I use Python 1.5.2. and have not found a way to either delete files > with wildcards or to read the directory content (and do it file by > file). > > Is there a portable way in 1.5.2 ? os.listdir(path) will portably return the list of all files in the path, and os.unlink can be used to delete one or more of them (or, os.remove, too). os.path.walk is also handy if you need to iterate on a whole subdirectory tree. Alex From ajm at enteract.com Fri Jul 14 18:46:21 2000 From: ajm at enteract.com (Alan Miller) Date: Fri, 14 Jul 2000 17:46:21 -0500 Subject: Enumerating drives in Python or wxPython References: <8aKa5.485$652.11285@newsc.telia.net> Message-ID: David Bolen (db3l at fitlinxx.com) wrote: >Alan Miller writes: >> for driveletter in string.uppercase: >> if os.path.isdir(driveletter + ":\\"): >> drivelist.append(driveletter) > >The only rub with this is that for things like floppies, you can get >errors running isdir() if there is no diskette present. Interesting, I tried it out before I posted and didn't have any problems. My biggest concern was that it might not report a removable drive if it didn't have media in it, but I didn't have problems with either the floppy or IDE Zip drives in my system. It did take a moment while it checked the empty drives, but I don't know that there's any way around that since Explorer does the same. It seems that isdir() doesn't die if there's no media, but I can only assume that the implementation is buried in the code for python itself (os.path.isdir is really ntpath.isdir, which calls os.stat, which is really nt.stat, and nt is one of the builtins) which I haven't downloaded. Note that the root directory does seem to be handled as a special case, since it's always going to exist on any drive under DOS/Windows. Anyway, even if isdir() did return an error that should be trappable; I'd expect the error returned to be different for media not available than for no such device. ajm From rvollmert at gmx.net Tue Jul 18 04:52:04 2000 From: rvollmert at gmx.net (Robert Vollmert) Date: Tue, 18 Jul 2000 10:52:04 +0200 Subject: event handler advice In-Reply-To: <8l033n$pr2$1@la-mail4.digilink.net>; from pete@visionart.com on Mon, Jul 17, 2000 at 03:49:02PM -0700 References: <8l033n$pr2$1@la-mail4.digilink.net> Message-ID: <20000718105204.A1009@krikkit> On Mon, Jul 17, 2000 at 03:49:02PM -0700, Pete Shinners wrote: > my guess is i need some dictionary that defines the > messages and their routine name (no shortcut way to do > this unless python had #define like macros :]) > > messages = {msg.INIT:"INIT", msg.PLAY:"PLAY", ...etc} You could try to generate this dictionary automatically. Something like messages = {} for name in dir(msg): val = getattr(msg, name) if type(val) == type(0): messages[val] = name maybe with some additional testing of the format of name, so you don't by accident define a signal to call __doc__ or the like. -- Robert Vollmert rvollmert at gmx.net From rloisel at helicon.net Sat Jul 22 20:40:11 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Sat, 22 Jul 2000 20:40:11 -0400 Subject: IDLE window disappears on startup Message-ID: <397A3EEA.792BDDEB@helicon.net> New to Python but not script programming. W98 Python 1.5.2b First tried clicking on the idle.pw and idle.pwc icons and a window pops up and immediately disappears. Then tried: start->run-> python idle.py and idle.pyw and the same thing happened. Appreciate any suggestions. Also if there are any Amiga users of python out there. I also can't get IDLE going on that platform either but at least I have the shell. rloisel at helicon.net (Rod Loisel Enfield NH) From test at online.com Thu Jul 6 18:03:25 2000 From: test at online.com (Harry Testmeier) Date: Thu, 06 Jul 2000 22:03:25 GMT Subject: Uploading binary files References: Message-ID: <3964fda9.6059914@news.btx.dtag.de> On Fri, 30 Jun 2000 16:46:49 GMT, "Chris Biegay" wrote: >I'm trying to upload files through an HTML form, but it only works >for text files. When I try to send a jpeg or something the process just >hangs, and I can't even change the script afterward since the webserver >won't release the file! Any ideas? This is basically how I'm doing it now: > >form = cgi.FieldStorage() >formItem = form[inputName] > >if formItem.file: > print "Received file [" + formItem.filename + "]" > data = formItem.file.read() > ... Hi Chris, your Python code seems to be OK, but did you specify an "enctype" in your HTML-code (e. g.
)? Hope this helps Arnold From kelley at bioreason.com Fri Jul 14 06:29:51 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 14 Jul 2000 11:29:51 +0100 Subject: Is pickle buggy? References: <396B069A.9EBDD68B@muc.das-werk.de> <396EE83D.FB60B033@bioreason.com> Message-ID: <396EEB9F.20FBC9A4@bioreason.com> I goofed, I actually do get this behavior in windows. I started a new thread "string issues or questions about intern" basically if you eval('"AAAAA"') it appears "AAAAA" is not garbage collected. But if you eval('a="AAAAA"') a is garbage collected. Interesting eh? -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From kpmurphy at my-deja.com Mon Jul 10 13:59:28 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 10 Jul 2000 17:59:28 GMT Subject: tkinter menus References: <8kcmeb$m5r$1@nnrp1.deja.com> <5vujmsg8hdf54luae6e2c0jivv93qheu9h@4ax.com> Message-ID: <8kd2tk$3l$1@nnrp1.deja.com> In article <5vujmsg8hdf54luae6e2c0jivv93qheu9h at 4ax.com>, mwr at hsl.tcp.co.uk wrote: > On Mon, 10 Jul 2000 14:26:40 GMT, Keith Murphy > wrote: > > >menu, menu... anyone, anyone? > > > > How do you configure top-level menu entries? I'd like to put a 'help' > >menu (and possibly others) on the right end of the menu bar. I've seen > >examples where you make your own frame... but there has to be a way > >built in... doesn't there? :) > > > In Tkinter, when you use the appropriate geometry manager to put the > button in the menu bar. E.g: > helpButton = Menubutton(myMenuBar, ...) > helpButton.Pack(side=RIGHT, ...) > > Or if you're using Pmw, then you can do something like: > myMenuBar = Pmw.MenuBar(...) > myMenuBar.addmenu(side=RIGHT,...) > > -- > Martin Rand > Highfield Software Ltd > mwr at highfield-software.co.uk > Phone: +44 (0)23 8025 2445 > Fax: +44 (0)23 8025 2445 > well i am using a system menubar, not one i've created. i'm using fredrik lundh's 'an introduction to tkinter' (http://www.pythonware.com/library/tkinter/introduction/index.htm) as my guide. here is an example he uses: # File: menu-example-2.py from Tkinter import * root = Tk() def hello(): print "hello!" # create a toplevel menu menubar = Menu(root) menubar.add_command(label="Hello!", command=hello) menubar.add_command(label="Quit!", command=root.quit) # display the menu root.config(menu=menubar) mainloop() ...if you try and pack or anything, you will get the following message: TclError: can't pack ".1977984.1980464": it's a top-level window ... any more help? thanks :) -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From thiele at muc.das-werk.de Mon Jul 3 12:28:55 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 18:28:55 +0200 Subject: making widgets invisible References: <3960794E.6E2B36E6@muc.das-werk.de> <8jq5bf$h45$1@nnrp1.deja.com> <3960A4D3.F45133B4@muc.das-werk.de> <962638110.1459980735@news.libertysurf.fr> Message-ID: <3960BF47.AF251B0B@muc.das-werk.de> > I think this pack_forget methode is what I was looking for. I'll try it. Thanks Thomas From dale at out-think.NOSPAMco.uk Wed Jul 19 11:36:49 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 19 Jul 2000 16:36:49 +0100 Subject: ADO 2.5 connection problem References: Message-ID: I've just knocked up a JavaScript equivalent of this as a Windows Scripting Component and it works a treat. Is it me or is Python Win32Com doing something stupid? -- Dale Strickland-Clark Out-Think Ltd, UK Business Technology Consultants Dale Strickland-Clark wrote in message news:snbbe8hl1nk87 at news.supernews.com... > Sorry about the length of this post but I've run out of ideas. > > The following error is produced by a short extract of the program I'm > working on. > > The program opens a database connection (ADO) object which it stores in the > object it returns on creation. > > That connection is then used on subsequent calls to access record sets. The > test() method shows that the connection is still open. > > This used to work with MDAC 2.1 but I had to upgrade to MDAC 2.5. That's > when it stopped working. This error is reproducible on NT 4.0 and Windows > 2000. > > HELP! Why can't I use this connection? > > > >>> import thstest > >>> x = thstest.ths() > Create ths... > >>> x.logon('fred', 'pw') > Traceback (innermost last): > File "", line 1, in ? > File "S:\JOBS\THS\Code\thstest.py", line 52, in logon > rs.open(qry, self.dbcon, adOpenStatic, adLockOptimistic, adCmdText) > File "d:\Program Files\Python\win32com\client\dynamic.py", line 428, in > __getattr__ > raise pythoncom.com_error, details > com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', > 'Operation is not allowed on an object referencing a closed or invalid > connection.', 'C:\\WINNT\\HELP\\ADO210.CHM', 0, -2146824579), None) > >>> x.test() > Connection state: 1 > >>> > > > from win32com.client import Dispatch > > # Constants > > # ---- CursorTypeEnum Values ---- > adOpenStatic = 3 > # ---- LockTypeEnum Values ---- > adLockOptimistic = 3 > # ---- CommandTypeEnum Values ---- > adCmdText = 0X0001 > > # ---- ObjectStateEnum Values ---- > adStateClosed = 0X00000000 > adStateOpen = 0X00000001 > adStateConnecting = 0X00000002 > adStateExecuting = 0X00000004 > adStateFetching = 0X00000008 > > sourcedb = "s:\\data\\merlin.mdb" > > class ths: > def __init__(self): > self.dbcon = Dispatch("ADODB.Connection") > self.dbcon.Open("Driver={Microsoft Access Driver (*.MDB)}; DBQ=" + > sourcedb) > print "Create ths..." > > def test(self): > print "Connection state:", self.dbcon.state > > def __del__(self): > print "Deleting ths..." > self.dbcon.Close() > self.dbcon = None > > def logon(self, email, password): > rs = Dispatch("ADODB.Recordset") > qry = "select * from user where email = '%s' and password = '%s'" % > (email, password) > rs.open(qry, self.dbcon, adOpenStatic, adLockOptimistic, adCmdText) > return not rs.EOF > > > > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants > > > From robin at jessikat.demon.co.uk Mon Jul 3 19:23:07 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 4 Jul 2000 00:23:07 +0100 Subject: tkinter hanging References: Message-ID: <+fF0kLAbBSY5Ewaz@jessikat.demon.co.uk> In article , Robin Becker writes >In article , Thomas Wouters > writes >>On Sun, 2 Jul 2000 15:25:21 +0100, Robin Becker >>wrote: >>>I'm having problems with zombie processes under win32 with a tkinter >>>linked against Tk 8.3. I seem to be exiting the mainloop ok and have >>>destroyed all subwindows and then the gui object itself, but >>>occasionally I still generate a zombie. I have checked that my after's >>>are cancelled and debug prints seem to show me exiting the script. >> ... Under Win95 + Python 1.6a2 this code hangs about 1 in 10 times when the gui is killed using the window manager. The output indicates that the mainloop is terminated, afters are cancelled and all the widgets are destroyed. Even so it seems to hang after printing 'sys.exit'. It is using the common Tk idiom of delayed polling with after, but the exit code makes strenuous efforts to remove any pending calls. Can anyone see what I'm doing wrong? #################### from Tkinter import * import string, sys, os, regex, telnetlib import traceback, time class CommandEntry(Entry): def __init__(self, master, partk, **kw): apply(Entry.__init__, (self, master), kw) class Gui: def __init__(self): self.tk = Tk() try: self._build() self._alive = 1 except: traceback.print_exc() self.destroy() def _build(self): self.tk.geometry("800x600") self.tk.title("Client") self.tk.protocol("WM_DELETE_WINDOW", self.close) self.after_id = [] tA = {'fg':'white','bg':'black','state':'disabled','height':20} tC = {'fg':'white','bg':'black','insertbackground':'yellow','insertwidth':2} if os.name != 'posix': # need tcl/tk 8.0 on windows fnt = ("Fixedsys", 12) tA['font'] = fnt tC['font'] = fnt self.txt = Text(self.tk,tA) self.entry = apply(CommandEntry,(self.tk, self), tC) # set up the scrollbar for the txt widget self.scrollVertical = Scrollbar(self.tk,orient=VERTICAL) self.txt.configure(yscrollcommand=self.scrollVertical.set) self.scrollVertical.config(command=self.txt.yview) self.scrollVertical.pack(side=RIGHT, anchor=E, fill=Y) self.entry.pack({'side': 'bottom', 'fill': 'both'}) self.entry.focus_set() self.txt.pack({'side': 'bottom', 'fill': 'both', 'expand': 1}) def mainloop(self): self.after_id.append(self.tk.after(100, self.iterate)) self.tk.mainloop() print 'mainloop end' def destroy(self): self._alive = 0 self.after_cancel() for w in ('scrollVertical','txt','entry','tk'): try: getattr(self,w).destroy() delattr(self,w) print '%s destroyed' % w except: traceback.print_exc() def iterate(self): if self.loop(): self.after_id.append(self.tk.after(50, self.iterate)) else: self.tk.quit() def after_cancel(self): while self.after_id!=[]: id = self.after_id[0] del self.after_id[0] try: self.tk.after_cancel(id) except: traceback.print_exc() def close(self,event=None): self._alive = 0 def loop(self): if not self._alive: return 0 try: pass except: traceback.print_exc() self._alive = 0 return self._alive if __name__ == '__main__': gui = Gui() gui.mainloop() print 'Exiting' gui.destroy() del gui while 1: time.sleep(1) print 'sys.exit' sys.exit() -- Robin Becker From alex at magenta.com Fri Jul 14 10:01:51 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 14 Jul 2000 16:01:51 +0200 Subject: Local CGI programming References: <396F0F28.7C8B8B83@ieee.org> Message-ID: <8kn6mh02n5c@news2.newsguy.com> "Didier WILLAME" wrote in message news:396F0F28.7C8B8B83 at ieee.org... > Hello all, > > I need to call a CGI python script with my web browser, on my WIN NT > station (local hard drive). > > To test this, I have written the following script. But the new page > (built by the python script) is not diplayed by the web browser! > > Is a http service needed to perform this test? Yes, you need a HTTP server that supports CGI to test out CGI. > If yes, what minimal product propose you? Python comes with a CGI-capable HTTP server but I have not managed to make it run under NT (it uses fork and several other Unix-only constructs). The easiest solution for me was to install Xitami, a free lightweight HTTP server, www.xitami.com; it was a no-brainer to set up and use. I'd much rather have a usable Python CGI-capable server on my NT box, but that port would have taken more effort and was not my focus at the time. It also seems to me your script has one excess blank line between headers and content, but I don't think this is your problem. Alex From thiele at muc.das-werk.de Mon Jul 3 12:32:17 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 03 Jul 2000 18:32:17 +0200 Subject: From UNIX to Win NT References: <39606DAC.49A502DB@muc.das-werk.de> <8F665C79Agmcmhypernetcom@199.171.54.154> <39608FE0.35950741@muc.das-werk.de> <8F666C0AEgmcmhypernetcom@199.171.54.154> Message-ID: <3960C011.84B3D888@muc.das-werk.de> The program is the front-end of a job - management system. The program has to receive a user - command (via pickling over a tcp-socket connection) and execute a special program and evaluate the output. And this program runs on NT too. And so the starting server has to run on NT too. From nobody at nowhere.nohow Fri Jul 28 01:22:56 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Fri, 28 Jul 2000 05:22:56 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: In article , Ben Wolfson wrote: >list() (and tuple()) only work on objects that actually have a sequence >mapping makes a lot of sense and, to me, resolves the ambiguity in >precisely the way I would expect. Is 'sequence mapping' for list() an tuple() defined the same as for the 'for' statement: it has a get_item(i) method that returns either a value or raises an exception? -- Grant Edwards grante Yow! While I'm in at LEVITTOWN I thought I'd visi.com like to see the NUCLEAR FAMILY!! From johannes at zellner.org Fri Jul 7 12:07:08 2000 From: johannes at zellner.org (Johannes Zellner) Date: Fri, 7 Jul 2000 18:07:08 +0200 (CEST) Subject: how to mimic interactive Message-ID: Hello, how do I design an interactive input loop so that it feels like called python interactively ? (e.g. prints results of math operations) e.g. in a script while 1: exec raw_input(prompt) if I run this script and type 2*3 at the input prompt it does not print the result as in the interactive python interp. Short: where do I find the input loop implementation for interactive python `shells' ? -- Johannes From sabren at manifestation.com Sat Jul 29 14:11:33 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 29 Jul 2000 14:11:33 -0400 (EDT) Subject: Python 3000 ? In-Reply-To: <8luuin$ags$4@newshost.accu.uu.nl> Message-ID: On 29 Jul 2000, Martijn Faassen wrote: > It's amazing how often this question is asked. What is causing all these > people to ask this question? Some web page being extremely mysterious > about Python 3000 somewhere? http://www.python.org/1.5/ "... after that, we'll be working on "Python 3000" (the new code name for the grand Python redesign; the language will be incompatible)..." I think someone wrote it just to scare people. :) Not to point fingers, but it's Guido's email address on that page... Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From neilh at scintilla.org Sun Jul 9 19:39:48 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 09 Jul 2000 23:39:48 GMT Subject: Pythonwin 1.5.2 References: <8kaij5$c9s$1@supernews.com> <8kaolt$flc$1@supernews.com> Message-ID: <838a5.12069$Tb7.82109@news-server.bigpond.net.au> > Oh for standards in keyboard shortcuts. What's wrong with ctrl-enter like > Visual Studio? Visual Studio uses Tab. I had no idea it also allowed Ctrl+Enter. Neil From ge at nowhere.none Wed Jul 19 14:41:36 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 19 Jul 2000 18:41:36 GMT Subject: Advice sought: text-mode (but not CLI) apps in Windows console ? References: <8F7682C13PaCmAnRDLM@195.25.12.37> Message-ID: In article , Cliff Crawford wrote: >| Since then I have been through what I believe to be a reasonably thorough >| Web search (from Parnassus outwards) to find something to get me started, >| and have turned up precious little. Various Python bindings of curses or >| ncurses exist, but can one run curses itself under Win 9x ? Or are there >| other, well-hidden libraries or modules that do more or less the same thing >| on that platform ? (I'm not asking for something as high-level and >| extensive as the Borland OWL of old :-) > >You may be able to compile curses using cygwin/djgpp. Also, there >is another library called S-Lang which you could use, and I believe >there is a port for it for Windows. There is a nice widget set called newt (with a Python binding called snack) that uses slang. If slang is available under Win32, then it should be possible to use newt/snack. -- Grant Edwards grante Yow! Wait... is this a FUN at THING or the END of LIFE in visi.com Petticoat Junction?? From bill at dehora.fsnet.co.uk Fri Jul 28 17:54:07 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Fri, 28 Jul 2000 22:54:07 +0100 Subject: Python is Zen (was Python is wierd) References: <39806045.F67EBD04@wag.caltech.edu> Message-ID: <8lt0ap$69q$2@newsg4.svr.pol.co.uk> Does this imply a "Thinking in Python"? -Bill de h?ra From tim at pnorthover.freeserve.co.uk Tue Jul 25 15:27:42 2000 From: tim at pnorthover.freeserve.co.uk (Tim Northover) Date: 25 Jul 2000 20:27:42 +0100 Subject: Reading a file Message-ID: I'm attempting to read a file line by line with readline(), but it seems to return and empty string when EOF is encountered. Is there a way of discerning the difference between the end of the file and a blank line in the file? I'm very new to this so I don't know the methods used but I couldn't find anything relevant when grepping the html docs. Tim N. From peter at schneider-kamp.de.bbs Mon Jul 17 10:50:02 2000 From: peter at schneider-kamp.de.bbs (peter at schneider-kamp.de.bbs) Date: 17 Jul 2000 14:50:02 GMT Subject: [Patch] {l,r}just with optional pad character parameter Message-ID: <3bRFWP$jXa@openbazaar.net> Thomas Wouters wrote: > > As for the patch itself, it looks okay, though I'd say the restriction on > padchar being a single character is a bit strange. Why not allow multiple > characters as padding ? string.join() allows strings instead of single > characters, too. Two reasons why not: - it would have been harder to implement - undetermined semantics: "GvR".ljust(6,"12") =?= "GvR121" or "GvR".ljust(6,"12") =?= "GvR12" or "GvR".ljust(6,"12") =?= "GvR1212" I would vote for the first, but I am not sure it is obvious. Also I don't see any danger in the version implemented now. If you supply a string of length != 1, you get a very nice (helpful) TypeError. Two reasons why: - you could use "" to switch off padding, "N/A " to fill a line with "N/A N/A N/A N/A " or " ." if you don't like """ 1.2.7. On the verge of sending........ 1.2.8. Really about to send now.......""" - it would be more general. Python likes that. If we can work out the semantics, I volunteer to implement it. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From grey at despair.rpglink.com Sun Jul 30 20:37:48 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 00:37:48 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8ltgpt$31a$1@newshost.accu.uu.nl> <8lvslc0mn8@news2.newsguy.com> <8m1evp22n4o@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 14:52:12 +0200, Alex Martelli wrote: >One is presumably processing existing logs to extract data upon >which business decisions will be based (if there is no interest >whatsoever in the data extracted, why is it being extracted?!). Security? >the one originally considered). So, try again, giving any example of >the 'tons of conversions' and/or the 'type it dozens of times', and >once again we'll presumably show how _it just isn't so_... No, I trust you. If I were to do so the conversation would never die. Chalk it up to difference of opinion and my ignorance and let's move on. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From shindich at my-deja.com Mon Jul 10 21:23:45 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Tue, 11 Jul 2000 01:23:45 GMT Subject: reference counter and __del__ References: <3969CB5C.A860D124@muc.das-werk.de> Message-ID: <8kdsuj$k9c$1@nnrp1.deja.com> In article <3969CB5C.A860D124 at muc.das-werk.de>, thiele at muc.das-werk.de wrote: > 1. I have the problem that not all of my objects are destroyed and I > don't know where and why, so I wonder if there a way to check out from > where and how many references to a special object exists? > You can use sys.getrefcount (). Thomas Thiele posted a similar question today, you might want to look at the answers to that posting too. For all we know, there could be a reference leak in pickle. > 2. When __del__ is called the object will be detroyed, correct? Yep. In fact, __del__ is called as the object being destroyed. > 3. Why is __init__ not called when I unpickle an object? > I don't know the exact answer to this question, but my guess is that it doesn't need to call the constructor. I assume that pickle.loads () simple creates an object and sets up the properties on that object to be the same as those of the object that got serialized using pickle.dumps(). But read the docs on it. I am no authority on pickle inetrnals. > Thomas > Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From michels at linmpi.mpg.de Thu Jul 13 05:33:25 2000 From: michels at linmpi.mpg.de (Helmut Michels) Date: Thu, 13 Jul 2000 11:33:25 +0200 Subject: python/win9x and contour plots References: <396CDB9E.6F6AA3@oreilly.com> Message-ID: <396D8CE5.A39FB656@linmpi.mpg.de> "Stephen R. Figgins" wrote: > Eric Haageman has given some examples of using DISLIN with Python on the > O'Reilly Network. It works okay on my Win98 system. You can find > articles in his column at: > > http://www.oreillynet.com/pub/q/numerically_python > > I don't know how well DISLIN can handle an irregular grid, if it can at > all. But it does seem pretty easy to use with Python. > > Stephen DISLIN cannot handle directly irregular grids for contour plots, but there is a routine with the name getmat for calculating a regulat matrix from randomly distributed data points. This calculated matrix can then be passed to the contour and surface plotting routines in DISLIN. ------------------- Helmut Michels Max-Planck-Institut fuer Aeronomie Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at linmpi.mpg.de DISLIN Home Page: http://www.linmpi.mpg.de/dislin From bjorn at roguewave.com Sat Jul 22 00:19:27 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 21 Jul 2000 22:19:27 -0600 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <397920CF.AD6F30BD@roguewave.com> Tim Hochberg wrote: [snip] > ------------------------------------------------------------------------ > Proposal one, which for lack of a better name I'll call Huaiyu's proposal: [snip] > Advantages: Similarity to MatLab syntax. > Disadvantages: Reversed syntax. > Essentially precludes eventual unification of NumPy and MatPy. > 5.+A probably won't confuse the parser, but it may confuse me. No, it will not confuse the parser, however it will be parsed as "5.0 + A" which might not have been intended... In any case, I find Konrad's proposal more aestethically pleasing (but then I don't care about Matlab users ) -- bjorn From rhymes at tiscalinet.it Tue Jul 25 10:58:31 2000 From: rhymes at tiscalinet.it (rhymes) Date: Tue, 25 Jul 2000 16:58:31 +0200 Subject: Python & AI Message-ID: Do u know something on the net related to Artificial Intelligence and Python Language?? Thanx in advance. Lawrence Oluyede rhymes at tiscalinet.it "Per cambiare, per diventare un' altra cosa dobbiamo prima sapere cosa siamo" Bruce Lee From gherman at darwin.in-berlin.de Thu Jul 13 10:42:30 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Thu, 13 Jul 2000 16:42:30 +0200 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <396CB0D3.8F7BC8E5@prescod.net> <396D9EF5.D4B0EE10@prescod.net> Message-ID: <396DD556.65D80A8@darwin.in-berlin.de> Paul Prescod wrote: > > Huaiyu Zhu wrote: > > > > ... > > > > I also find I need to do this a lot of time. For example, when you read > > something from a file, you want to return an object of a specific class > > based on the content. The easiest way to do it appears to be > > > > class General: > > __init__(self, data): > > self.data = data > > if data is something: > > self.__class__ = Special1 > > else: > > self.__class__ = Special2 > > > > class Special1(General): pass > > > > class Special2(General): pass > > YOur code would work just as well if Special1 and Special2 were not > related to General. In fact, it would work if you separated out that > init function into something that reads the data and creates an > appropriate class instance based on the data. This is a typical case for using one of the following design patterns: Abstract Factory, Builder, Factory Method (see "Design Patterns" by Gamma et al. for de- tails). There is really no need for turning OO concepts upside- down only because the specification of a particular language allows for doing it (unless there is no other proper way to do it...). Regards, Dinu -- Dinu C. Gherman ................................................................ "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 loewis at informatik.hu-berlin.de Sun Jul 9 06:19:20 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Jul 2000 12:19:20 +0200 Subject: ISO Latin -> HTML conversion References: <8k4r6p$p1v$1@thrud.anatomy.usyd.edu.au> <8k8q17$rov$1@thrud.anatomy.usyd.edu.au> Message-ID: danny at thrud.anatomy.usyd.edu.au (Danny Yee) writes: > wrote: > >Just reverse the dictionnary, to be found in htmlentitydefs. > > Where do I find this? >>> import htmlentitydefs >>> dir(htmlentitydefs) ['__builtins__', '__doc__', '__file__', '__name__', 'entitydefs'] >>> print htmlentitydefs.entitydefs Regards, Martin From richard_chamberlain at ntlworld.com Fri Jul 21 13:03:39 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Fri, 21 Jul 2000 18:03:39 +0100 Subject: Where to install Python 1.5.2 ? and pmw ? References: Message-ID: Hi Randy, My python is actually installed in c:\program files\python but it's probably best to put it in c:\python to avoid any issues with the directory name 'program files'. Having said that I've never had a problem. My Pmw is just inside the python directory with no issues. Richard Randolph MacKenzie wrote in message news:sngqqrb46tt22 at corp.supernews.com... > Where is the best place to install Python 1.5.2 in the Windows platform ? Is > C:\Program Files\Python really the best location? > I also want to install pmw so that I can import pmw without generating an > error message. How do I do that ? > > -TIA, Randy > > > > From see at below Sat Jul 29 04:09:46 2000 From: see at below (Paul Foley) Date: 29 Jul 2000 20:09:46 +1200 Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: On Fri, 28 Jul 2000 21:06:37 GMT, Steve Lamb wrote: > On 28 Jul 2000 16:16:12 -0400, mmillikan at vfa.com wrote: >> Are you saying that data is naturally untyped and that >> operations/functions are naturally typed (and that this typing >> of o/f's is unambiguous)? > Mmmm, in as far as I can read that, yes. It is the operation that > determines the type of the data, not the data in and of itself. Not in the world I live in! If I put a slice of pizza in my coffee cup, it doesn't magically turn into coffee...just makes a mess. -- Nomina stultorum in parietibus et portis semper videmus. -- Cicero (setq reply-to (concatenate 'string "Paul Foley " "")) From ajs at ix.netcom.com Mon Jul 24 09:52:22 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 24 Jul 2000 09:52:22 -0400 Subject: Open letter to Guido van Rossum References: <200007240401.AAA07578@mail3.mia.bellsouth.net> Message-ID: <8lhij5$278$1@slb2.atl.mindspring.net> Dan Grassi wrote in message > > Then there is the mod-python/mod_pyapache mess, two competing versions > both with major problems ranging from re not working in the module > version of mod_python to memory leaks in both versions. Memory leaks are > a major problem in a shop that is serving over 1 million pages a day. Perhaps your shop, which sounds: a) substantial b) for profit consider doing what has traditionally been done when a technical solution requiring an impled or express warranty of fitness is necessary - arrange to engage an appopriate shop in that business to provide it. Perhaps Guido is not in a postion to worry about whether dot.coms serving 1 million pages a day decide to do the Python world a favor and use a Python based solution. I would hope he doesn't loose sleep over your problem. From gmcm at hypernet.com Fri Jul 21 13:23:24 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jul 2000 17:23:24 GMT Subject: Intercept methods/raise exception References: <3978f242.25036009@news.online.no> <8F77C5E93gmcmhypernetcom@199.171.54.155> <397912ac.71497477@news.online.no> Message-ID: <8F7880DBBgmcmhypernetcom@199.171.54.155> Thomas Weholt wrote: >On 20 Jul 2000 23:55:14 GMT, gmcm at hypernet.com (Gordon McMillan) >wrote: [proxy class] >Ok, it seems to work, allthough only if I access methods. Accessing >simple values like ints and strings directly only traps that value, >not the attribute name. Sure it does. Both __getattr__ and __setattr__ have the name of the attribute - it's an argument. >And, most importantly, how can I make my objects behave like the ones >used thru a proxy, *without* putting them into one? is it possible? I >mean, I just want to avoid have to declare one instance, and then >stuff it into another new instance. Can it be done in one big swoop? Two ways. The sane way: (I'll assume your class is class Fiddle. Now rename it to _Fiddle.) def Fiddle(*args, **kwargs): obj = apply(_Fiddle, args, kwargs) return Proxy(obj) Your users will never know what hit them. The insane way is to take Demo/metaclasses/Trace.py (from the source distribution) and modify it to suit your needs. You might know what hit you, but that's about all you'll know. >Anyway, where can I read up on stuff like this? Proxy, nifty object >handling. Any hints? The docs (the very early sections of the library reference, and scattered thru the language ref) actually explain pretty well how this stuff works. They just never give much of a hint what you can do with it. For that, you need a madman (Mark Hammond, Tim Peters, Don Beaudry, Aaron Watters, Jim Fulton, me). The single most elegant example of utter depravity is Aaron Watters' FreeTerm.py. Clipped from a posting: #courtesy of Aaron Watters (a posting dated 1997/05/01) class freeterm: def __init__(self, name): self.__myname__ = name def __getattr__(self, name): return attrterm(self, name) def __repr__(self): return str(self.__myname__) def __str__(self): return `self` def __call__(self, *args, **kargs): return callterm(self, args, kargs) def __coerce__(a,b): return (a,b) def __cmp__(a,b): return id(a) - id(b) class attrterm(freeterm): def __init__(self, thing, attname): #print thing, ".", attname self.__attname__ = attname freeterm.__init__(self, thing) def __repr__(self): #return "(%s).%s" % (str(self.__myname__), self.__attname__) return "%s.%s" % (str(self.__myname__), self.__attname__) import string class callterm(freeterm): def __init__(self, fn, args, kargs): self.__myargs__ = args self.__kargs__ = kargs self.__fn__ = fn freeterm.__init__(self, fn) def __repr__(self): strargs = map(str, self.__myargs__) for (key, value) in self.__kargs__.items(): item = key + "=" + `value` strargs.append(item) arglist = string.joinfields(strargs, ", ") args = "(%s)" % arglist return `self.__fn__` + args def test(): [a,b,c,d,e] = map(freeterm, "abcde") print a+b*c print a*b+c print a.open(d)+e print a.this(c).that(e.x)+d print (a<>c print a(d**e, key=b-c) that'll-teach-ya--ly y'rs From lkcho at my-deja.com Mon Jul 31 14:06:43 2000 From: lkcho at my-deja.com (lkcho at my-deja.com) Date: Mon, 31 Jul 2000 18:06:43 GMT Subject: CGI downloading References: <8m1lc5$89p$1@nnrp1.deja.com> <19ad.398464e2.b28f1@yetix.sz-sb.de> Message-ID: <8m4f7e$7t7$1@nnrp1.deja.com> What is the different between residing inside document root and outside document root. If it is inside document root, how to get it? Thank you. LKCho In article <19ad.398464e2.b28f1 at yetix.sz-sb.de>, ajung at suxers.de wrote: > lkcho at my-deja.com wrote: > 2qy > 2qyIs there any possible way to download the whole cgi script, instead of > 2qyletting it response with html pages? > > On a well administrated web server this should not be possible. > Usually CGI scripts reside outside the web servers document root. > However I have seen lots of insecure systems where CGI reside > inside the document root. > > Cheers, > Andreas > > Sent via Deja.com http://www.deja.com/ Before you buy. From adams_s at lab.eng.usyd.edu.au Sun Jul 9 17:59:44 2000 From: adams_s at lab.eng.usyd.edu.au (Steven Adams) Date: Mon, 10 Jul 2000 07:59:44 +1000 Subject: Getting ip address and browser info References: <3967B9F8.1694E2F3@bioeng.ucsd.edu> Message-ID: <8kasde$er2$1@news1.wire.net.au> heres a snippet I've found that prints out server details: import os for x,y in os.environ.items(): print x, y ------------------ os.environ['HTTP_USER_AGENT'] gives browser type os.environ['REMOTE_ADDR'] gives the IP address of the requesting party ----------- hope that helps, Steven Curtis Jensen wrote in message news:3967B9F8.1694E2F3 at bioeng.ucsd.edu... > Using python CGI how can I get the ip address and browser info of the > requestion party? Thanks. > > -- > Curtis Jensen > cjensen at bioeng.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 From phil at geog.ubc.ca Fri Jul 21 14:41:28 2000 From: phil at geog.ubc.ca (Phil Austin) Date: 21 Jul 2000 11:41:28 -0700 Subject: [long and fussy] But what do these operators _mean_? References: <8l899g$6f5$1@agate.berkeley.edu> <8la3bo$b55$1@agate.berkeley.edu> Message-ID: there was a matrix-sig but it has been replaced by: http://lists.sourceforge.net/mailman/listinfo/numpy-discussion Any topic related to numerical methods and Python would be within the domain of that list. Phil From digitig at cix.co.uk Mon Jul 24 17:25:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Mon, 24 Jul 2000 22:25 +0100 (BST) Subject: Operators for everything (was Re: Operators for matrix) References: <397B6319.27A6438A@nceas.ucsb.edu> Message-ID: In article <397B6319.27A6438A at nceas.ucsb.edu>, keitt at nceas.ucsb.edu (Timothy H. Keitt) wrote: > R (www.r-project.org) uses '%' as in A %*% B. Might be nice to > standardize. Um, only if there's a benefit -- otherwise we'll standardise on semicolons to divide statements and curly braces to delimit blocks. I find A %*% B very hard to read, and I don't like so much use of arcane symbols. The only tidy way of handling infix operators in Python than I can see is to make operators first class objects. From jvickroy at sec.noaa.gov.bbs Mon Jul 17 14:30:07 2000 From: jvickroy at sec.noaa.gov.bbs (jvickroy at sec.noaa.gov.bbs) Date: 17 Jul 2000 18:30:07 GMT Subject: Event set/clear/wait Message-ID: <3bRLJV$jy3@openbazaar.net> How can software be written to determine when it is "safe" to *clear* a threading.Event that has previously been *set*? Do I even need to consider this? Thanks for your interest. -- jv P.S. "safe" is intended to convey the notion that all threads issuing a *wait* on the event are no-longer blocking because of it. From horst at proceryon.at Thu Jul 27 09:21:35 2000 From: horst at proceryon.at (Horst Gassner) Date: Thu, 27 Jul 2000 15:21:35 +0200 Subject: Pmw dialogs - very slow Message-ID: <3980375F.4D366654@proceryon.at> Hi all! Am I doing something wrong or are Pmw dialogs really so slow? Here are the lines of code: s.notYetImplemetentedDlg = Pmw.MessageDialog(s.parent, defaultbutton=0, title = notYetImplementedHdrTxt, message_text = notYetImplementedTxt) s.notYetImplemetentedDlg.activate(geometry = 'centerscreenalways') The dialog frame appears very fast but it takes between 1 and 2 seconds to display the contents! When I use the simple tk-Dialog then everything is okay (dialog including contents appears suddenly). tkMessageBox.showinfo(notYetImplementedHdrTxt, notYetImplementedTxt) I like Pmw very much and I also want to use the Pmw dialogs because of there extended features (e.g. centering the dialog on screen, using the same font as for all other Pmw-Megawidgets) Is there a possibilty to speed this up? Thank you in advance Horst From digitig at cix.co.uk.bbs Sun Jul 16 14:50:12 2000 From: digitig at cix.co.uk.bbs (digitig at cix.co.uk.bbs) Date: 16 Jul 2000 18:50:12 GMT Subject: ODMG? Message-ID: <3bQWKb$j9g@openbazaar.net> Is there any ODMG-style Object-Oriented Database system for Python? From frr at mindless.com Mon Jul 10 13:16:53 2000 From: frr at mindless.com (Fernando Rodríguez) Date: Mon, 10 Jul 2000 17:16:53 GMT Subject: including files Message-ID: <9yna5.229$iT2.4602@m2newsread.uni2.es> Hi! What's teh Python's equivalent for C's #include "myfile.h"? O:-) TIA -- --------------------------------------- Fernando Rodr?guez From neo_brave at my-deja.com Mon Jul 3 21:45:38 2000 From: neo_brave at my-deja.com (Neo Brave) Date: Tue, 04 Jul 2000 01:45:38 GMT Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: <8jrfjv$geg$1@nnrp1.deja.com> In article , "Olivier Dagenais" wrote: > How about a batch file called p.bat ? (with optional status messages) > > -----start p.bat-------- > @echo off > echo Starting script '%1.py' .... > c:\progra~1\Python\python "%1.py" %2 %3 %4 %5 %6 %7 %8 %9 > echo Execution complete! > ----end p.bat----------- > > Given you have a script called "spam.py": > > -----start spam.py------ > print "Spam spam spam spam" > -----end spam.py-------- > > Then, you would type: > > c:\work\python\stuff>p spam > Starting script 'spam.py' ... > Spam spam spam spam > Execution complete! > > Is that what you wanted?? Thanks. Thats an improvement on what I have been doing till now but its not quite as neat as the WinNT solution (which I've tried on WinNT and it works :-)). Maybe its time I bit the bullet and upgraded to NT. Neo -- Neo Brave Sent via Deja.com http://www.deja.com/ Before you buy. From weeks at golden.dtc.hp.com Sun Jul 30 12:24:54 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 30 Jul 2000 16:24:54 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> Message-ID: <8m1ksm$kr9$1@news.dtc.hp.com> [I should have mentioned this in my previous response, but I missed it:] Martijn Faassen (m.faassen at vet.uu.nl) wrote: : This seems to be where the confusion comes in. When people claim Python : passes by value, because the *references* are being passed by value, : that seems to be just stating that the only thing the computer can pass : in the end is numbers. If you say that, everything is by value Not really. The question is *which* number do you pass to the function: the number written in the argument variable or the address of the argument variable (which is then implicitly dereferenced). Perl passes the latter (call by reference), Python passes the former (call by value). So, in Perl you can have: $x = 0; f($x); print "$x\n"; # PRINTS 42 Greg From nobody at nowhere.nohow Fri Jul 28 21:13:52 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sat, 29 Jul 2000 01:13:52 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <8lrt2h013fp@news2.newsguy.com> <8lsa9901fm9@news2.newsguy.com> Message-ID: In article <8lsa9901fm9 at news2.newsguy.com>, Alex Martelli wrote: > >> I would assert that although 1 + "foo" is meaningful to the C >> _compiler_, it is still meaningless to almost "everyone" (as in >> people) except Perl coders, and probably meaningless to most of >> them as well. > >I think you underestimate the amount of "Obfuscated C" participants >who have not been Perl coders. 1+"foo" and 1["foo"] are very >meaningful kinds of constructs to obfuscators!-) Probably true. However, I've been writing C code for a living for 15 years, and I can count on my thumbs the number of people I've met to whom 1 + "foo" would not be confusing. (I am not among them -- and I've written a C compiler!) A few more could figure it out if they were told it was a valid C expression. Once it was pointed it it was valid, I could see what the value would be, but most of us would have initially reacted by thinking that that's not a valid expression. >What I don't understand is, rather...: > > $foo = ++$bar; > >versus > > $foo = 1 + $bar; I wrote one Perl program about 9 years ago and never did it again. -- Grant Edwards grante Yow! BELA LUGOSI is my at co-pilot... visi.com From nobody at nowhere.nohow Sun Jul 30 12:22:07 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 30 Jul 2000 16:22:07 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Sun, 30 Jul 2000 02:45:58 GMT, Steve Lamb wrote: >On Sun, 30 Jul 2000 01:48:32 GMT, Grant Edwards wrote: >>I concur. In non-programming, life is strictly typed. Allowed >>operations are determined by the type of the object. You can't >>make a phone call on a waffle-iron. Were I to _try_ to make a >>phone call on a waffle-iron, it doesn't "automagically" convert >>istelf into a telephone. Instead, I get a rather interesting >>burn pattern on the side of my head. > > You're making the mistake of trying to associate >programming concepts to real world objects. But in many, many programs (at least in the embedded and process control areas where I do most of my work) program objects _do_ correspond to real world objects. > I'm sorry, but that is why I said data is data is data. That's a bit of a tautology. ;) > To give you a counter example when I write my pen doesn't >toss up an exception when I write out, "11 people are insane!" >because it contains an integer in a string context! I don't understand the analogy. Pens are not responsible for parsing English sentances and proofreading them. They're responsible for leaving a visible trail when they're dragged across a paper surface. -- Grant Edwards grante Yow! Are you still an at ALCOHOLIC? visi.com From stephen_purcell at yahoo.com Wed Jul 26 20:44:08 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 27 Jul 2000 10:44:08 +1000 Subject: Python luddites (was Re: Type inference now simplicity) In-Reply-To: <397F5410.6D9D317A@uab.edu>; from shapr@uab.edu on Wed, Jul 26, 2000 at 09:14:34PM +0000 References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> Message-ID: <20000727104408.A10021@inkontact.com.au> Shae Erisson wrote: > And I'm opposed to it because it seems like sugar to me. I've always > loved Python's simplicity, and I hope it stays that way. > Adding new operators and new syntax will make Python harder to read, and > harder to learn. I don't want that. Yay! Python luddites unite! It also seems to me that Python is popular and effective exactly because of its simplicity. I love the fact that Perl folks rant about features 'missing' in Python only to find that the exact same functionality is available in a nicely packaged form in a standard module (e.g., 're'). This is the Python aesthetic, and I love it. -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From mallor at 3DProgrammer.com Thu Jul 20 06:37:29 2000 From: mallor at 3DProgrammer.com (Mallor) Date: Thu, 20 Jul 2000 10:37:29 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l52hs$i05$1@kopp.stud.ntnu.no> <39765839.ADB85077@san.rr.com> Message-ID: "Courageous" wrote in message news:39765839.ADB85077 at san.rr.com... > > > > http://www.stackless.com/ > > > > What exactly *are* these advantages? (Very curious...) > > Stacklessness allows certain specific optimizations for > threading that wouldn't be possible otherwise. For example, > it's quite possible to run 10,000 threads simultaneously > in stackless Python, which is especially useful if you have > lots of small simulation entities which are doing various > and sundry routine and small tasks. If I had 10,000 of anything to process, why wouldn't I try to batch that up? Only answer I can think of is if you had 10,000 fairly unique things going on. Like 10,000 players on a MUD server and nobody shares any turn-phase actions at all. I'm not sure that's how I'd design a MUD to begin with, sounds pretty bloated. I don't think I'd need 10,000 asynchronous Active Server Page transactions for an e-commerce website, I think I could queue 'em. So, 10,000 sounds like a pretty theoretical advantage. I'd be more interested if there's some big payoff for, say, a dozen heterogeneous processes? > One of the things that stacklessness enables is the "first > class continuation" which is really a generalized primitive > for doing flow control. If Python came coupled with any > kind of metalinguistic/macro environment, it would be possible > to any number of flow control and looping constructs, > practically without limit. I guess my suspicion about primitives for doing flow control, is I've spent most of my computer career learning how to pipeline the flow control tighter and tighter by regularizing the units of computation. Sure, some problems aren't amenable to that, but most problems are, and I'm not sure I want to pay maintenance overhead to have the conceptual elegance. After all, main memory access in a flat address space is pretty elegant until you have to deal with a cache hierarchy. > "first class" continuations expose the various pieces > of functionality in 1-4 to the ordinary programmer. It > is no longer a matter strictly controlled by the > interpreter/compiler. The programmer can then make > meta-level decisions that would have otherwise not been > doable without the continuation construct. Fair 'nuff, I'd use it to blow off all returns. Once the packets have been shipped to some hardware interface - 3d, network, whatever - what do I care about gratuitously returning from subroutines? The pedantic answer is exception handling. Well, screw exception handling! :-) Of course, the design level method for coping with this problem is using big arrays of stuff that you can repetitively chug through, to minimize or even eliminate function call overheads. > The idea of "stacklessness" per se is doing away with > the push/pop operations altogether in order to facilitate > the continuation itself. Without having to constantly > push/pop stack elements, context switching between threads > or regions of memory becomes very cheap. Only if the consumption of resources by the threads themselves is cheap. If they're all a bunch of memory hogs, you've just invented a great way to thrash. > There's a cost involved here, but if you're doing lots > of context switching, you very often don't care. I hate context switching. All efficiency comes from hardwiring the context. > This kind of environment is particularly of interest to high > performance computiationalists who use massively parallel > machines. And of no interest whatsoever to those of us using serial machines on mainstream PC industry CPUs. But your point is taken. -- Cheers, Infernal Troublemaker Troll Mallor "By simple mistake, mortals themselves amuse." From lull at acm.org Thu Jul 13 22:36:02 2000 From: lull at acm.org (John Lull) Date: 13 Jul 2000 21:36:02 -0500 Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> Message-ID: At the dawn of the third millenium (by the common reckoning), hzhu at localhost.localdomain (Huaiyu Zhu) wrote (with possible deletions): > I think cleanness is one of the main virtue of python, but it is lacking in > numerical computation. To give an example of the difference it makes, I'll > quote from my original post asking for matrix in python (with corrections) > > [in octave we write] > > b = X\y # LMS solution of a linear equation y = X*b > > b = (X'*X)\(X'*y) # or written out in more details > > b = inv(X'*X)*(X'*y) # or in a less efficient form. > > > > but the corresponding Python notation is horrendous: > > > > b = matrixmultiply(inverse(matrixmultiply(transpose(X), X)), > > (matrixmultiply(transpose(X), y[:,NewAxis]))) I'm don't think this is quite fair. You could just as easily write: b = rDiv(X, y) if you simply had an appropriate rDiv() function. It's not nearly as pretty as octave's notation, but it doesn't have to be nearly as hideous as your example. Regards, John From m.faassen at vet.uu.nl Thu Jul 27 15:10:40 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Jul 2000 19:10:40 GMT Subject: Python 3000 References: Message-ID: <8lq1fg$hg2$1@newshost.accu.uu.nl> Tim Peters wrote: [Martijn:] >> Once all of this becomes a bit more clear for the parties >> involved, that is. >> >> It keeps changing and it makes people worried. At least it makes me >> worried. > What can we do about that? In the short term it *is* a mess. [snip] Oh, you're right; see my response to Guido elsewhere on the newsgroup. Just uselessly venting some frustration, I suppose. :) Perhaps we should write somekind of 'request for clarification' letter to CNRI to indicate what's up with the community. Anyone up to write such a thing? Not me, my poor neurons. But I'll gladly add comments if someone proposes a letter to the newsgroup. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From db3l at fitlinxx.com Fri Jul 7 20:36:51 2000 From: db3l at fitlinxx.com (David Bolen) Date: 07 Jul 2000 20:36:51 -0400 Subject: EOF References: <75F7304BB41CD411B06600A0C98414FC0A41CB@ORSMSX54> Message-ID: "Daley, MarkX" writes: > A better way is this: > > f = open("file") > line = f.readline > while line: > > line = f.readline Well, better is debatable I suppose :-) I personally dislike code like this a lot since it places the executing code on which the loop depends on two places. For a single readline() (don't forget the ()) maybe it isn't terrible, but it's still a maintenance headache waiting to happen - you'll always have two spots that need to be kept exactly the same. > This way, you're not testing truth against a known true. The pattern of an infinite loop being broken upon an exit condition is a fairly standard approach for a number of situations, and I think it's pretty clear. At least for the case of file I/O in Python, the while 1: with a break on EOF loop is pretty much an idiom - argued at times as one of the rougher idioms, but an idiom nonetheless :-) -- -- 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 Fri Jul 21 02:22:51 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 21 Jul 2000 06:22:51 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> Message-ID: <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> "John Lull" wrote in message news:ueefns037mjarv63dqpbh52mmr1k6vvaop at 4ax.com... > This shouldn't be hard to parse. In fact, it might be a reasonable > foundation for class-specific operators: > A(.opName)B > would get executed as either > A.__opName__(B) > or > B.__ropName__(A) > or raise an exception as appropriate. This would allow constructs such as: A(.init)B In other words, it would turn all existing __magic__ functions into operators. Not a good idea IMO. -- Rainer Deyke (root at rainerdeyke.com) Shareware action/role-playing games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From db3l at fitlinxx.com Mon Jul 3 20:59:27 2000 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jul 2000 20:59:27 -0400 Subject: Traping output from os.system References: <8jn34q$kpn$1@news.lth.se> Message-ID: "Mark Hammond" writes: > > Any chance that a future update to the extensions will be able to > > return the result code of the child process on a close(), as > > os.popen() does? > > Unlikely that Bill or I will look into this. The problem is that the file > object doesnt know anything about the popen child process. Hmm, yeah, but couldn't the win32popen module just pass a different close routine (to PyFile_FromFile()) and then keep track of which file handles were for which pipe? True, it would have to manage that mapping, but could probably just use an internal dictionary for it :-) (Note I haven't actually tried this myself yet - just guessing from a few glances at the source) Ah, well - unfortunately exit codes are key for me, since the gate decisions. So I'll just keep valid consoles around for the moment :-) > Personally, I would prefer to _remove_ win32pipe.popen's implementation, > and re-write it in pure-python using the raw win32pipe functions - just to > prove we can :-) And also so it would be easier to hack to do this sort of > stuff, or cloned for "custom" requirements, etc. Makes sense - I may try that at the point where I need to get rid of thge consoles, although I'm definitely targeted at NT, so I get to avoid all the Win95/98 ugliness I keep hearing about :-) Doing it this way would probably make it easier to return an object that looked like a file object (although it wouldn't really be the actual type) but knew enough about how to access the child process during the close() operation. Thanks. -- -- 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 dsavitsk at e-coli.net Fri Jul 28 02:22:02 2000 From: dsavitsk at e-coli.net (d. savitsky) Date: Fri, 28 Jul 2000 06:22:02 GMT Subject: com makepy problems References: Message-ID: well, thanks. i am afraid i don't know how to use the registry editor, but i'll look it up and see what i can do. also, i'll check what the error codes are from the win2k and win98 machines and see how similar they are. in all cases late binding seems to work, that is, i code on a machine where makepy is fine and the programs run on the other machines without any complaints (mostly ADODB/ADOX/DAO stuff with Access). doug "Mark Hammond" wrote in message news:XM3g5.13980$4p3.108502 at news-server.bigpond.net.au... > > key2 = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "Typelib\\%s" > % > > (iid)) > > api_error: (5, 'RegOpenKeyEx', 'Access is denied.') > > Sheesh. This is very strange. I have no idea why reading the registry > would throw an "Acces Denied" error. Can you see this key and subkeys > using the registry editor. > > Im afraid I have never had this reported, and this makepy code is getting > a number of years old. So NFI, I'm afraid. > > Mark. > > > From bill at dehora.fsnet.co.uk Fri Jul 28 19:58:02 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Sat, 29 Jul 2000 00:58:02 +0100 Subject: Perl is worse! (was: Python is Wierd!) References: <8losor$4bk$1@nnrp1.deja.com> Message-ID: <8lt6nh$fsr$1@newsg4.svr.pol.co.uk> > But the irony now is that ZOPE will be 'opened' to PERL too. I have > read through the 'debates' going on in the zope mailing list, but it > still doesn't make sense - why allow Zope to be polluted by something > that is clearly deficient? How is it deficient? > It's like allowing people to use sand instead of cement to build a house. I've built houses. You need both. And more. From jhe at webde-ag.de Mon Jul 3 12:40:25 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Mon, 3 Jul 2000 18:40:25 +0200 Subject: Random number generation, simple question. References: Message-ID: <8jqfis$eak$1@pollux.ip-plus.net> "Kalle Svensson" schrieb im Newsbeitrag news:Pine.GSO.4.21.0007031546410.25965-100000 at luna.dsv.su.se... > * Suppose I do a loop where I get a byte at a time and then re-seed the > generator either with random numbers from the generator or with values > from time. Will that improve the randomness? Certainly not. Seeding is done ONCE, always. What you should do is to call random() 80 times, and use the MSB only, i.e. "bit = random() < 0.5". Ciao, J?rgen -- J?rgen Hermann (jhewebde-ag.de) WEB.DE AG, Amalienbadstr.41, D-76227 Karlsruhe Tel.: 0721/94329-0, Fax: 0721/94329-22 From thomas at xs4all.net Tue Jul 18 12:02:37 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 18 Jul 2000 18:02:37 +0200 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) In-Reply-To: ; from lull@acm.org on Tue, Jul 18, 2000 at 08:09:12AM -0500 References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39736213.15848862@eecis.udel.edu> <39739291.4155A128@prescod.net> Message-ID: <20000718180237.C4283@xs4all.nl> On Tue, Jul 18, 2000 at 08:09:12AM -0500, John Lull wrote: > At the dawn of the third millenium (by the common reckoning), Paul > Prescod wrote (with possible deletions): > > Look, if you took a poll of all programmers in the world, only a small > > fraction use matrices very often. Therefore it is a niche. Most > > programmers use numbers and strings every day, however. > By that reasoning, cryptography ought not be part of the standard > distribution, either. Nor should complex numbers. Nono, the question is not whether it's part of the standard library or not. The question is whether it should get special syntax ! Complex numbers have special syntax, but it's very restricted, low-impact: the 'j' to create a complex number. Cryptography does not have special syntax. > A very large part of the *reason* it's not used more is that linear > algebra is simply *not* natively available in any common language > other than Matlab. There are plenty of other possibilities. Not everything has to be killed with special syntax. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From thomas at cintra.no Wed Jul 12 07:04:52 2000 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 12 Jul 2000 11:04:52 GMT Subject: Extending PythonWin Message-ID: <396c4f8a.787419228@news.online.no> Ok, a wishlist for PythonWin : 1. Integrate the Installer-module, with shortcuts etc. 2. Make some system so that users could make small scripts/modules appear in the menues etc. I`d like to have a code revision system for instance, and if there were a simple way of making modules available from inside PythonWin, this could be done in a snap. ( For experienced programmers that is. ;-> ) Thomas From xiarcexml at yahoo.com Fri Jul 14 11:38:18 2000 From: xiarcexml at yahoo.com (Dave Williams) Date: Fri, 14 Jul 2000 08:38:18 -0700 (PDT) Subject: Does Python code >.require<< a run-time environment?? (New to Python) Message-ID: <20000714153818.28906.qmail@web5302.mail.yahoo.com> I am new to Python... and I was wondering... Does Python code compile to any form of .exe file, or do you require a run-time interpreter? If the second is the case, how do you distribute applications?? Is it a light-weight run-time (small space, easy to include)... and do the end-users have to go through alot of steps to get to run it?? I like the language... but one reason why I'm looking at something -other- than Java is that I am kinda needing an .exe -type capability... ~Dave __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From nowonder at nowonder.de Mon Jul 31 19:53:13 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Mon, 31 Jul 2000 23:53:13 +0000 Subject: [4th Draft] Open Letter to CNRI: Request for clarification References: <3985969C.48222D21@nowonder.de> Message-ID: <39861169.3A2A5102@nowonder.de> Hi Will! Thanks for the suggestions. I guess you'll like the 6th draft. Will Ware wrote: > > 1. CNRI legally owns Python, up to version 1.6. You and I don't have > any legal rights of any kind in this matter. The user community does > not collectively have any legal rights in this matter. We are extremely > dependent upon CNRI's good will. I doubt that. As far as I understood the matter Python 1.5.2 was released under the old CWI license. Am I missing something? Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From tsmets at altern.org Thu Jul 27 19:36:39 2000 From: tsmets at altern.org (Thomas SMETS) Date: Thu, 27 Jul 2000 23:36:39 GMT Subject: inserting integer in Table References: <397CEEA4.7683A17@altern.org> <397CF583.603BC6B9@attglobal.net> Message-ID: <3980E10A.205B6361@altern.org> Well Roland, didn't work at my place ... I reCREATED a similar table with a column defined as int4 & bearing the name pk. tsmets=> create table TESTPYTHON tsmets-> ( pk integer, filename varchar(99), file bytea ); I couldn't insert a simple integer with you command : i = 0 conn.query("insert into TESTPYTHON pk values ( %s );" % i) Exception thrown is : Traceback (innermost last): File "insertBlobs.py", line 15, in ? conn.query("insert into TESTPYTHON (pk) values ( %s );" % i) pg.error: ERROR: Relation 'testpython' does not have attribute 'pk' Shouldn't I use %i or something like that instead of %s ? Tx, Thomas, =============== Roland Schlenker wrote: > > Thomas SMETS wrote: > > > In PostgreSQL table is : > > > > test=> \d test_blob_s; > > Table = test_blob_s > > +----------------------------------+----------------------------------+-------+ > > | Field | Type | > > Length| > > +----------------------------------+----------------------------------+-------+ > > | filenumber | int4 > > | 4 | > > | filename | varchar() > > | 100 | > > | filecontent | oid > > | 4 | > > +----------------------------------+----------------------------------+-------+ > > test=> > > > > > > Now I'm willing to insert in that table rows like this one : > > , , . > > > > Here's is the (not-so-running) code : > > > > > > # > > # > > # ############################################ > > import os, glob > > from pg import DB > > > > conn=DB('test') > > conn.query("BEGIN WORK;") > > > > i = 0 > > for name in glob.glob("*.jpg"): > > print "Name is ", name, > > try: > > conn.query("insert into test_blob_s filenumber values (" + i + > > ")") > > conn.query("insert into test_blob_s values (%s);" % i) > > > > > print " inserted" > > except TypeError,e: > > print '\nerror ', e, 'undefined' > > # conn.query( "update test_blob_s set filename = '" + name + "')") > > # conn,query("update test_blob_s set filename = '%s';" % name) > > > > > # conn.query( "update test_blob_s set filecontent = '" + > > lo_import(name) + "')") > > # conn.query("update test_blob_s set filecontent = %s;" % > lo_import(name)) > > > > > > > i = i + 1 > > > > conn.query(" COMMIT WORK;"); > > > > > > > > of course I can't have it passing the insert of "i" > > Could some one help ? > > > > Thomas, > > > > -- > > > > Thomas SMETS Phone : +32 (0)2 742. 05. 94. > > Av. de la Braban?onne 133 / 3 e-mail : tsmets @altern.org > > 1030 Bruxelles > > > > ==== Quote of the day ========= > > You shouldn't wallow in self-pity. But it's OK to put your feet in it > > and swish them around a little. > > -- Guindon > > ======= End of Quote ========= > > Roland Schlenker -- Thomas SMETS Phone : +32 (0)2 742. 05. 94. Av. de la Braban?onne 133 / 3 e-mail : tsmets @altern.org 1030 Bruxelles ==== Quote of the day ========= Your true value depends entirely on what you are compared with. ======= End of Quote ========= From fdrake at beopen.com Mon Jul 3 09:28:02 2000 From: fdrake at beopen.com (Fred L. Drake, Jr.) Date: Mon, 3 Jul 2000 09:28:02 -0400 (EDT) Subject: Bug in math.frexp? In-Reply-To: <200007031118.NAA22787@centurion.xs4all.nl> References: <20000630221759.A1965@xyz.donetsk.ua> <14688.12945.528521.351944@cj42289-a.reston1.va.home.com> <200007031118.NAA22787@centurion.xs4all.nl> Message-ID: <14688.38114.543936.743938@cj42289-a.reston1.va.home.com> Thomas Wouters writes: > Not sure which version of the Linux manpges you read, but the frexp manpage > that came with RedHat 6.1 more or less exactly mirrors Tim's description: I must have looked at something older when last I updated the frexp() description; my Mandrake 7.0 install agrees with your RedHat manpage. > Solaris 2.5 manpage I have access to is indeed a bit confusing, but does > state the same: 'x' is in the range of [0.5, 1), or 0. That means the > exponent has to be able to be negative, when the original number was > negative. And it's certainly possible I was just confused... numerics are not my area of expertise, and I'll bow to Tim on this stuff regardless. -Fred -- Fred L. Drake, Jr. BeOpen PythonLabs Team Member From db3l at fitlinxx.com Tue Jul 18 15:22:57 2000 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jul 2000 15:22:57 -0400 Subject: Pipes, Sockets and Threads References: <8l17sr$bpa$1@nnrp1.deja.com> Message-ID: rpevans at my-deja.com writes: > I have extended Python with some purpose built functions, written in C > which communicate with a server process, via named pipes. Initially I > called one of these functions (mylib.fred ) from main to initiate > communications with the server. Once stablished I then started a thread, > again a mylib function, to monitor the pipe connection set up > previously. This is does but locks out the rest of the system. Only > when the thread receives data from the server does the rest of the > system run momentarily before again hanging. My first line of attack was > to put the function which initiated the comms in a separate thread so > divorcing the comms from main completely (I hoped). Now I have the > problem of communicating data ( pipe/socket fds) from my first thread > back to main and then to the second thread which inplements the select . I think you're going to have to be clearer here just what sort of threads (Python or native) you're talking about in each portion of the above paragraph, because the answers are different in either case. If, for example, your mylib module creates an internal native thread to handle I/O to the named pipe, buffering it up until the Python process wants to query it, you shouldn't have any problem at all. Once the native thread is begun, it runs independently of Python. You will, of course, have to provide some sort of protection mechanism (semaphores, critical sections, etc..) over common resources such as shared buffers. However, if the threads you are talking about are Python threads, then it sounds like you aren't relinquishing the global interpreter lock around blocking I/O in your extension module. Python, although it supports threading, can only really have one interpreter native thread running at one time. So even if you create multiple Python threads, if one of them calls into an extension module that then blocks (such as on I/O to a named pipe), it will block the Python interpreter in general. There are macros that you can use within your extension module to relinquish the global interpreter lock around such blocking I/O or other long-running native tasks (regaining it after the process is completed), which will permit the other Python "threads" to continue running in the interpreter. The use of these macros and the issue of the global interpreter lock is covered in the Python/C API documentation (see seciton 8.1, although I agree it's not unbelievably detailed). > (...) > Secondly how do I transfer variables from the C extension library to and > from the Python module. I asume I can't return a value from a thread in > the argument list. I have tried declaring a variable as global in python > and external in C without much (ie any succcess ). Extension functions accept arguments as Python objects (which can be parsed with PyArg_ParseTuple() for example) and returns results also as Python objects (often built with Py_BuildValue() or returned from some other Python C-API function). This is covered in the extending and embedding Python documentation. > Could anyone tell me how I can implement complete asynchronicity between > my mian module and the communication threads. Is there a site with some > example Python threaded code. The library reference is quite sparse in > this area. The books I have bought (O Reilly) do not mention threaded > architecture. Is there a book which covers this? Have you read the Python/C API documentation? It should answer some of these questions. As mentioned above, there are probably two main approaches that you might take. You could either build internal threads into your extension module that have nothing to do with Python directly, but simply ensure your application remains responsive while the Python threads are doing their thing. The other approach is to actually depend on the Python threads for the shared operations and just support the interpreter lock within your extension functions to ensure that you don't block other Python threads out. Which is more appropriate depends on your application - the builtin Python modules pretty much all do the latter (I believe), but I often find the former useful in extension modules - particularly when the reason for the extra threads is just to overlap I/O and remain responsive to some external device or network connection. -- -- 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 grey at despair.rpglink.com Thu Jul 27 14:44:42 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 18:44:42 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> Message-ID: On 27 Jul 2000 17:56:55 GMT, Martijn Faassen wrote: >Hmm. You seem to expect that strings and other things will be automatically >coerced to integers whenever a function expects an integer. I think that's >pretty scary; when I pass in the wrong thing to a function I *want* it to >complain, as it's very likely I did it by accident. The problem there is you're thinking in terms of separate data types. I prefer the freedom of thinking in /DATA/. Not types, just data. 1. Is that a string? Is it an integer? Is it a floating point number? Yes, it is all three. 1.21 / 1 1 + 1 "My keycode is simple, 1." >I don't want things to work by accident. Perhaps you're missing that this >'problem' is also a 'feature'; you get less 'weird' bugs due to the fact that >your program keeps running long after your data got coerce-mangled to death. >Python would tend to throw exceptions as soon as it went wrong. I've never gotten 'weird' bugs from Perl taking the data type from the context of the operation at hand. Not even in my early days of Perl. I won't say there weren't got'chas that got me, but it was quite liberating not having to worry about thinking in terms of how the computer sees the data and, instead, having the computer see the data as /I/ see it. Furthermore, I have already gotten my first 'wierd' Python bug and it is wierder, by far, than anything I hit in Perl. Even when I was debugging the code (love the debugger!) I couldn't understand what was going on. What's more, in the context of the script, it shouldn't have happened. def foo(): print "foo" foo >>> def foo(): ... print "foo" ... >>> foo >>> Sure, works nice in interactive mode. You'd think when I left that in my script that Python would have tossed it's cookies. No. All I saw was a statement the parser took and the debugger was showing no call being made even when stepping through the code. Newbie mistake, sure, but certainly one of those that if we want to be strict about what goes where should have been caught. >So perhaps you're missing the important tradeoff here. What, strict checking versus TMTOWTDI? If we're going to have the strict checking why, then, don't we have typing up front instead of the half-typing we have now? Python gets the initial type from context but won't switch types based on context? Might as well force people back into declaring variables in certain types since that is implicitly what we have now. >All right, for this particular case I suppose one could get used to >this kind of coercing. But in general? I'd need to *remember* it all, >right? Nope. You stuff a number into a scaler it is a number but can be used as a string. Not that hard to remember. Much easier, in fact, that having to remember to declare everything from the onset or declare it each time you need to use it in a particular context much less having to put in checks in case you're trying to declare something into something which it cannot be morphed into. Simply stated, main reason I don't do C, don't do Java, and dropped Pascal so long ago, the frustration of not being able to take data of one "type" and use it in a different context without jumping through 20 different loops depending on the particular case. To me it isn't char, int, longint, unsigned or signed, strings or whatever, it is data. Lists and hashes (and in Python, tuples) are just structures of data. What "type" that data is is completely subjective and based on the context of the operation. To me, a language that understands that has the feature, not the language that refuses to. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From m.faassen at vet.uu.nl Fri Jul 28 23:24:45 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jul 2000 03:24:45 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: <8ltipt$31a$2@newshost.accu.uu.nl> Alex Martelli wrote: [snip] > Making members into a dictionary _of lists_ seems another quite plausible > organization, changing the loop's body to: > if members.has_key(name): > members[name].append(occ) > else: > members[name]=[occ] > or (a matter of style): > try: > members[name].append(occ) > except KeyError: > members[name]=[occ] I prefer (1.5.2 and later): l = members.get(name, []) l.append(occ) members[name] = l Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cjensen at bioeng.ucsd.edu Wed Jul 26 12:04:47 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 26 Jul 2000 09:04:47 -0700 Subject: print format References: <397E3530.E821018C@bioeng.ucsd.edu> Message-ID: <397F0C1F.48F761AF@bioeng.ucsd.edu> William Tanksley wrote: > > On Tue, 25 Jul 2000 17:47:44 -0700, Curtis Jensen wrote: > >I don't know if this is possible in python but, Is there a way to repeat > >a format command a spceified number of times? For example, in Fortran > >there is the format code "20I5" Which is the same as "I5" twenty > >times. I want something like: > >print '20(%i5) ' % [list of 20 intgers] > > Perhaps > > print (20*"%5i ") % [list of 20 integers] > > will work for you. The multiplier on the string repeats it 20 times. > This lets you do things like: > > list = [list of 'n' integers] > print (len(list)*"%5i ") % list This only works with tuples, not lists. The % operator with strings requires tuples. I'm not sure why the chose to make this limitation. The following code gives this error. a = [1,2,3,4,5] print (5*"%5i ") % a Traceback (innermost last): File "", line 1, in ? TypeError: illegal argument type for built-in operation However, it works fine if a is a tuple. Thanks. > > >Also, how do I print without a new line other than using > >sys.stdout.write? > > Why? Is there something in specific you're trying to avoid? (Yes, it's > possible, but it's not pretty.) I want to print something, and then latter, print something else on the same line. I don't want to append to a string and then print the string. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From alex at magenta.com Sat Jul 15 05:15:46 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 15 Jul 2000 11:15:46 +0200 Subject: "archive" bits (was FAQTS) References: <20000713214019.24273.qmail@synop.com> Message-ID: <8kpavo14id@news1.newsguy.com> "Fiona Czuczman" wrote in message news:20000713214019.24273.qmail at synop.com... [snip] > ## Unanswered Questions ######################################## > ------------------------------------------------------------- > How can you check on the status of a file's "archive" bit, on DOS-type platforms > http://www.faqts.com/knowledge-base/view.phtml/aid/4706 > ------------------------------------------------------------- > Barry Pederson I had missed the original request. On Win32, with Hammond's extensions: PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au) >>> from win32file import GetFileAttributes >>> GetFileAttributes("C:/witha.txt") 32 >>> GetFileAttributes("C:/withouta.txt") 128 >>> where witha.txt does have the A attribute and withouta.txt lacks it. You can also use symbolic names for the constants: >>> import win32file >>> win32file.FILE_ATTRIBUTE_ARCHIVE 32 >>> win32file.FILE_ATTRIBUTE_NORMAL 128 >>> Note that the 'normal' bits seems to be set if and only if no other bits are set. Other attributes in the bitmask behave more normally, i.e., they are bitwise-or'ed to give all attributes of the file. For example, after making witha.txt read-only (still _with_ the A attribute as well), we have: >>> GetFileAttributes("C:/witha.txt") 33 >>> win32file.FILE_ATTRIBUTE_READONLY 1 >>> I.e., the attributes of the file are the bitwise-or of archive and readonly. So, if you only want to test for archive, and don't care about the others, you'll bitwise-and GetFileAttributes' result with FILE_ATTRIBUTE_ARCHIVE, rather than testing for equality! Alex From alex at magenta.com Fri Jul 7 04:52:17 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 7 Jul 2000 10:52:17 +0200 Subject: os.system References: <8k23tg$38me$1@www.univie.ac.at> <39653D15.E4DE6131@pehr.net> Message-ID: <8k45ut0190a@news2.newsguy.com> pehr anderson wrote in message news:39653D15.E4DE6131 at pehr.net... > Dear Matthias, > > In general, calling os.system causes the system to start a shell > which then processes the command string. [snip] > All I can offer is an explanation, not a speedup. > Perhaps you could find a way to talk to a browser that > may already be started? Not all that difficult: >>> import win32api >>> win32api.ShellExecute(0,"open","c:\\pippo.htm",None,"",0) 33 >>> This opens the given URL, in an existing and suitable browser window if possible, else in a newly generated one, and I find it to be very fast. (The returned "33" doesn't mean much of anything -- just check that it's not 32 or less, those would be errors -- just the N+1-th annoying Win32 API quirk:-). > I'd recommend browsing "Python for Win32" if you are serious > about surviving under windows. Yes, and I'm not even sure that would suffice (is ShellExecute documented there? I'm familiar with it, because I routinely program under Win32 with other languages, so that's the first thing I looked for when trying to do something equivalent to a "start" from commandline, but I'm not sure how a Win32 newbie would learn about it...). Hammond's book is excellent, and so are his win32* extensions, but there might still be lots of difficulty for programmers that are not familiar at all with Win32 and its API's. Alex From alex_c at mit.edu Tue Jul 11 08:46:02 2000 From: alex_c at mit.edu (Alex Coventry) Date: 11 Jul 2000 08:46:02 -0400 Subject: Python and SSH References: <8kf4gl$fqm$1@saltmine.radix.net> Message-ID: > I'd like to have a running python process ACCEPT an incoming SSH > connection. Any ideas on how I could do this? > > -- cary Not really, but you might be able to get what you want using the Monitor in Zope over a ssl connection, depending on what you want the accepting python process to do. Alex. From robin at jessikat.fsnet.co.uk Sat Jul 15 21:02:08 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 16 Jul 2000 02:02:08 +0100 Subject: Neil Schemenauer's GC patch in python1.6? References: <396F28A1.A181BF39@email.sps.mot.com> <3dn1jkljwy.fsf@kronos.cnri.reston.va.us> <20000716012003.L7340@xs4all.nl> Message-ID: <0k1sOJAQmQc5Ew5z@jessikat.fsnet.co.uk> In article <20000716012003.L7340 at xs4all.nl>, Thomas Wouters writes >On Sat, Jul 15, 2000 at 06:30:19PM +0100, Robin Becker wrote: >> In article <3dn1jkljwy.fsf at kronos.cnri.reston.va.us>, Andrew Kuchling > >[ amk explains cycle-GC will be in 2.0, though possibly optionally ] > >> If GC has finally/nearly made it, what about Chris Tismer's stackless? > >A different story altogether. I'm sure Christian can give a better >explanation that I can, but I believe the main showstopper is the fact it's >impossible to implement (currently) in JPython, not to mention future Python >compilers. There may be a lot more behind it, though. > bit strange that features/defects in java should determine where python goes. I would certainly like generator style programming to be easier. -- Robin Becker From thomas at cintra.no Thu Jul 13 02:31:42 2000 From: thomas at cintra.no (Thomas Weholt) Date: Thu, 13 Jul 2000 06:31:42 GMT Subject: Switching to Linux...... converting files and databases.... References: <8kj4i2+2fuo@eGroups.com> Message-ID: <396d6214.857701549@news.online.no> On Thu, 13 Jul 2000 01:04:02 -0000, "Steve Purcell" wrote: >ge at n... (Grant Edwards) wrote: >> >> FYI, there are alread some projects like that: catdoc, >> mswordview, (other things for excel and ppt files). One of the >> projects (can't remember the name) is a library of routines to >> read/parse MS Office output. > >You're probably thinking of the WV library: http://www.wvware.com/ > >-Steve Hm .. could someone with C/C++ experience/knowhow make Python-bindings to that library ?? Please. Thomas From hzhu at knowledgetrack.com Fri Jul 14 20:22:41 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Sat, 15 Jul 2000 00:22:41 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> <396E444D.496234AC@roguewave.com> <396F502B.45225ED9@roguewave.com> <396FABF3.B82E0C2@roguewave.com> Message-ID: On Fri, 14 Jul 2000 18:10:27 -0600, Bjorn Pettersen wrote: >Huaiyu Zhu wrote: >> >> On Fri, 14 Jul 2000 11:38:51 -0600, Bjorn Pettersen >> wrote: >> > >> >Well, this could actually be generally useful, but not with the .+ >> >syntax (since the dot would interfer with methods on the sequence >> >object). > >You're quoting me out of context here. What I could find generally >useful is a way to spell component-wise operations... That's what I meant to quote. Sorry if that's not clear. >As you might have guessed, I don't really care what is done in the >matrix case -- I don't use matrices. If a component-wise "operator" >were to be added to Python however, I would expect it to work with e.g. >list and in that case a dot is ambigous: > > mylist.foo() # are you calling the foo method on the list or the >elements? This is a method call, because f is not an operator and .f is not, either. Or are you thinking about something else? >I have a feeling that what you really want these operators to do is >paralell component-wise operations on more than one collection object >though, which is exactly what list comprehensions do (in a general way). How would you write this in list compresension (in less than 10 lines)? B*(sin(A*x+b).*(A*y)/3)/C Note that * is matrix multiplication and .* is elementwise. Note that C is a matrix so the / is matrixwise. If you want to write everything as for loops it takes at least 30 lines, without any decent error analysis. The main attraction of OO programming for numerical computation is finally being able to not write out the indices, as mathematicians have always be able to do on paper. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From aahz at netcom.com Tue Jul 18 22:48:28 2000 From: aahz at netcom.com (Aahz Maruch) Date: 19 Jul 2000 02:48:28 GMT Subject: Getting method from within method? References: Message-ID: <8l34ts$49f$1@slb6.atl.mindspring.net> In article , David M. Cooke wrote: >I want to do recursion, like this: > >def factorial(n): > if n <= 1: return 1 > else return n * factorial(n-1) > >However, this depends on the name of the method staying the same. For >instance, if I did this: > >fact = factorial >factorial = None > >fact(5) would give me an error since factorial isn't a method anymore. >It would be nice if there was some way of referring to the method >inside of the method. While there are ways of getting to what you claim you want, IMO the most appropriate answer is to remind you of the old joke: "Doctor, it hurts when I whack my knee with a hammer." "Well, don't do that!" -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From m.faassen at vet.uu.nl Thu Jul 20 11:04:11 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jul 2000 15:04:11 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> Message-ID: <8l74db$hs6$1@newshost.accu.uu.nl> In comp.lang.python Moritz Voss wrote: > "Martijn Faassen" schrieb im Newsbeitrag > news:8l6pgt$fmc$1 at newshost.accu.uu.nl... >> In comp.lang.python Moritz Voss wrote: >> > HOW FAST ARE THESE? >> >> Python's not amazingly fast by itself. >> >> Note that the speed of the compiler doesn't matter much; it's near >> instantaneous, but since it outputs bytecodes and you can use those, >> the speed of the interpreter is what really matters, and the interpreter >> isn't too fast. > Of course! That'S the problem. I was pointing out that it is often *not* a problem. Premature optimization, even in game programming, is not a good idea. While Python is slow compared to C code, if the same algorithm is used, you can: * use smarter algorithms much more easily in Python. Especially since Python allows rapid prototyping. * offload the time critical bits to C. > So there is not a JIT compiler style thingy > for Pyhon? There's no JIT for Python. >> From a game programming perspective, you can probably consider Python to >> be dirt-slow, though. The trade-off is a lot of power for speed, but >> that power can help you gain back speed because you can be a lot smarter. > Well...my python use would be for animation scriipts, micro AI scripts, and > map event scripts...maybe a little more, even. It should be fine for map event scripts and for AI scripts, though this of course depends on your exact implementation. Animation scripts could be more tricky. Animation overal control can be done in Python, though individual frame updates I'd do with C. (that said, I made a simple animation system once in Python built on top of SDL with PySDL and it seemed fast enough. no intensive testing, though) > Thanks :) So designing my own scripting language is easier. That's of course not true; designing your own scripting language will most likely result in an ad-hoc broken design. Look at all the various application specific scripting languages for examples. It's even possible your own design will be slower in many cases than the equivalent code in Python, as you don't have as much time to polish it. Of course you can do it right too, but it'll cost lots of time and is definitely not easier. > Or: Isn't it feasibble to pull of a stunt like ID software did with their VM > files? These contain compiled C code that is loaded dynamically - and of > course is fast as hell. We currently do a lot like this with DLLs for the > Engine and Contoller modules, but maybe this is even an idea at unit level? If you want to script your game in C there isn't any problem. :) The idea of using a higher level language however is that you can use higher level constructs. Which, believe me, is often a lot easier than using C or C++. > I'll open a thread on this... Compiled Scripts. > Thanks for the hints, though, I was jus getting started in Python :) It's > neat, but if it's slow, then it's worthless. I think this focus on speed is even for a game programmer the wrong approach. It's only too slow when you find it's too slow. You haven't found out Python's too slow for your purposes yet. That said, there are various other scripting languages which can be faster and which are embeddable as well. I suggest you look at Lua: http://www.tecgraf.puc-rio.br/lua/ Pike: http://pike.idonex.com/ And I'm sure there are more. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nospam at buzzoff.com Thu Jul 20 14:09:46 2000 From: nospam at buzzoff.com (Moritz Voss) Date: Thu, 20 Jul 2000 20:09:46 +0200 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> Message-ID: <8l7f69$bon$1@fermi.tro.net> "Martijn Faassen" schrieb im Newsbeitrag news:8l74db$hs6$1 at newshost.accu.uu.nl... > In comp.lang.python Moritz Voss wrote: > > I was pointing out that it is often *not* a problem. Premature optimization, > even in game programming, is not a good idea. While Python is slow > compared to C code, if the same algorithm is used, you can: > > * use smarter algorithms much more easily in Python. Especially since > Python allows rapid prototyping. > > * offload the time critical bits to C. Maybe I don't get the python concept. Do you link it statically? Or is the interpreter *.exe invoked every time? We came from dos, counting every clock we spent using 90% assembly in our software. Until we were struck that our texturing algorithm sucked (and anyway, 3d accelerators were coming up and I already had one...)... > >> From a game programming perspective, you can probably consider Python to > >> be dirt-slow, though. The trade-off is a lot of power for speed, but > >> that power can help you gain back speed because you can be a lot smarter. Yes and no. Just because I have encapsulation and overloaded operators, that does not mean my program is going to be faster than a program that performs the same task in assembly or C. > > Thanks :) So designing my own scripting language is easier. > > That's of course not true; designing your own scripting language will > most likely result in an ad-hoc broken design. Look at all the various Now, my own language would be an assembler-style thing. The concept is as follows - every instruction corresponds to an index. Each of these indices, after compilation, are then translated, during runtime, into direct function addresses. So what I have is my program that consists of a huge bunch pointers to C functions (which can have any level of complexity). These would just be loaded, and called, loaded, and called. I'm not going into the depths of this here but passing parameters and references is not a problem. > application specific scripting languages for examples. It's even possible > your own design will be slower in many cases than the equivalent code > in Python, as you don't have as much time to polish it. That is the problem - python is oblect-oriented. Most AI scripts are tiny, though, just 15 lines or so with my assembler code. Something for a missile would be "CheckTarget--Steer-IfCloserThanX-Detonate". The script knows how toget closer to what it wants - but does so not my reall playing god and moving the missile, but just setting off a command "Steer" that tells the physics engine "ThrustvectorAngleChange (angles)"... This is unlike the scripts in the Quake engines that allow to do unrealistic things - in my project, each script can only do what is physically possible - otherwise, the missile will crash or the tank will tip over in a curve. A caveat here: The unit scripts will be lengthy, having units check engine and gun temperature (and move into the shade or cease fire), check whether they can go down that hill after it has started rainign, have them communicate targetting info or even orders to other units, calculate the lead for their next shots, return to a repair base via the safest way.... And it MUST all be user definable for the player, that point is muission critical for the project. Otherwise, we'd hardcode it. So what my C program would do is call a python function "main" or so that runs and makes all these decisions, even calling subroutines and so on - and modifes the unit state that it shares with the C program. (Which, then, will run the atomar part of the physics engine, the one that does things like accelerate and so on over time, according to the unit's desired speed states.) So that kinda requires a language that is not absolutely basic, like my ASM concept. :) I'll play around with python, but I found the way to embed it totally confusing. (That is, of course, because I have never worked with embedded languages yet). Also, I find no tutorial that clearly tells me how to change my C variable "X" from within my Python program "Y" that is invoked by the C Program. > Of course you can do it right too, but it'll cost lots of time and is > definitely not easier. I agree. I don't want to reinvent the wheel. > > > Or: Isn't it feasibble to pull of a stunt like ID software did with their VM > > files? These contain compiled C code that is loaded dynamically - and of > If you want to script your game in C there isn't any problem. :) > > The idea of using a higher level language however is that you can use > higher level constructs. Which, believe me, is often a lot easier than > using C or C++. Yes. Like [[ SELECT * FROM CoWorkers WHERE SEX="F" ]] is easier than finding your possible future spouse in C or Assembler. > I think this focus on speed is even for a game programmer the wrong > approach. It's only too slow when you find it's too slow. You haven't > found out Python's too slow for your purposes yet. Hey! We coded a long time to get the engine to run at 300 fps with some graphics load. We don't want the micro-AI scripting part to slow it down. That is the AI clients's job. :-) I think I'll go with Python, and if the performance problems become dominant, I'll check that ASM concept of mine. Thank you for the links! I'll have a closer look at them. > Regards, > > Martijn -- -- Moritz "Thygrrr" Voss Client-Server & OpenGL Coder spirit.link.studios - http://o2.ods.org From mikael at isy.liu.se Mon Jul 31 08:12:38 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 31 Jul 2000 14:12:38 +0200 (MET DST) Subject: Python is wierd! In-Reply-To: <8lku8v$nf8$1@gaia.cdg.acriter.nl> Message-ID: On 25-Jul-00 Cees de Groot wrote: > Intercal is weird (profoundly wierd, I'd say). Mostly everything else > is a serious attempt to make programmer's lifes easier. At best it is > perceived weirdness caused by where you come from (if you come from > Fortran, Perl is /really/ weird). If you are looking for the weird, take a look at brainf***. Yes, that's an obscene word. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 31-Jul-00 Time: 14:02:30 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From paul at prescod.net Fri Jul 14 16:38:02 2000 From: paul at prescod.net (Paul Prescod) Date: Fri, 14 Jul 2000 15:38:02 -0500 Subject: proposal: accessor methods References: Message-ID: <396F7A2A.ABE184@prescod.net> Michal Wallace wrote: > > Hey all, > > I was just wondering if anyone else would find this useful: Yes, accessor methods have been proposed many times and many people would find them useful.Python very recently got a formal proposal mechanism for ideas like this which come up over and over and over again. That way pros and cons can be collected once and for all rather than over and over. If you (or anyone out there) want to do a formal Python Enhancement Proposal for accessor methods, contact me and I'll point you to the right format. Either an implementing patch or at least a suggestion of a good way to implement it would also improve the likelihood of adoption. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From mad at sympatico.ca Wed Jul 5 23:09:32 2000 From: mad at sympatico.ca (Duke) Date: Thu, 06 Jul 2000 03:09:32 GMT Subject: socket error Message-ID: I'm using Python 1.5.2 for Windows 98, and am trying to do some socket stuff. Copying an example right out of the manual (section 7.2.2), I get the following error: Traceback (innermost last): File "C:\Programming\Python\Tools\idle\ScriptBinding.py", line 131, in run_module_event execfile(filename, mod.__dict__) File "C:/Programming/Python/socket.py", line 5, in ? s = socket (AF_INET, SOCK_STREAM) NameError: socket Here are the first 5 lines in the script: # Test server script from socket import * HOST = '' PORT = 50007 s = socket (AF_INET, SOCK_STREAM) The example I'm using works fine on my Linux box Python interpreter, version 1.5.2. Any ideas? If you need more info on hardware or software, let me know. Thanks, -- Duke. From swekbw at barcelona.com Wed Jul 26 08:31:01 2000 From: swekbw at barcelona.com (swekbw at barcelona.com) Date: Wed, 26 Jul 2000 12:31:01 GMT Subject: Ya tengo mi correo @barcelona.com 226 Message-ID: <9SAf5.365$yl5.159@telenews.teleline.es> Por fin y tras varios traspies ya damos correo electronico gratuito tu nombre at barcelona.com. en www.barcelona.com Ademas va incluida tambien la conexion gratuita para rtb, rdsi y rdsi128 Que las disfrutes!!! xzwlprgnjnenlmzfxmwcdzoqwomioqemqyspfrrwgcczkpuzwvgsuwxilftubgijutlkcewere From db3l at fitlinxx.com Mon Jul 31 18:05:35 2000 From: db3l at fitlinxx.com (David Bolen) Date: 31 Jul 2000 18:05:35 -0400 Subject: ftp and lowercase? References: <39832544.2E05FCFB@online.no> Message-ID: Stein Surland writes: > The host did not take the LIST command so I changed it to LS and ls. It > seems that the ftplib sends the list command in uppercase. How to change > this to lowercase? I have ftp'ed to the host and it does not recognize > LIST or LS only ls. (I know that you resolved your issue later, but just an FYI) Note that neither "LS" nor "ls" are valid FTP commands for use with a server. The commands for retrieving directory information are "LIST" (name plus server-specific information) or "NLST" (name only). The commands - although often transmitted in uppercase - are case insensitive (as long as the server conforms to the protocol). What you were probably running into is that when you use "ls" in FTP clients that support that command, they internally translate that into a remote "LIST" command. And often such clients (particularly those modified from a Unix base) are case sensitive in parsing their command lines. In some clients you can enable debugging (e.g., "debug" or something similar) and see the underlying commands being transmitted in response to your entered commands. ftplib exposes a reasonably raw interface to the FTP client/server stream, so you need to work in terms of the real FTP protocol commands, and not some of the command aliases that ftp clients may implement. You can get more information about the commands and how they work if interested by reading the protocol specification (RFC959, or STD9), available in any RFC repository (http://www.rfc-editor.org for one). Section 4 covers the commands. In your example, the reason you had problems is that placing a space after the LIST command indicated that you were going to supply a directory path that you wanted a listing of (see section 5.3.1 of the spec). So you were in violation of the spec for ending the command at that point. While I expect some (many?) servers would treat that as no directory a bit more gracefully, rejecting the command is also valid. -- -- 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 cknight at mail.arc.nasa.gov Tue Jul 18 15:49:58 2000 From: cknight at mail.arc.nasa.gov (Chris Knight) Date: Tue, 18 Jul 2000 12:49:58 -0700 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <8l2ce1$de2$1@sun500.nas.nasa.gov> "Andrew Kuchling" wrote: > This is a first experiment in whether I can make a useful, > interesting, somewhat coherent summary of python-dev activity. > If reaction is favorable, and time permits, it may become a biweekly > posting. It's very much appreciated, any possibility of (cross-)posting it to c.l.p.announce? From rumjuggler at cryptarchy.org Fri Jul 28 04:58:56 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 28 Jul 2000 08:58:56 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 07:57:12 GMT, grey at despair.rpglink.com (Steve Lamb) wrote: > >>No, it took a sequence containing a single element and turned it into a list >>containing a single element. list() only works on sequences. 'a' is a >>sequence of length 1. > > That is what I said. It took a single element and made it a list with a >single element. No. The single element is the string "a". It took the *sequence* "a" and made it a list. >>> string = "a" >>> result = [] >>> for character in string: result.append(character) >>> result ['a'] That works because "a" is a single-element sequence. Ditto ['a'] and ('a',). If list() really took a single element and returned a list with that element, as I've said previously, the result of list( ('a',) ) would be [('a',)]. -- Barnabas T. Rumjuggler Further-more, I have long since put the finishing touches on my own official obituary, a 350-page tale of heart-rending loss which details, among other things: my meteoric rise from Onion stringer to editor to publisher; my assassination at the hands of lady-actress Ethel Barrymore's jealous suitors; the thousand days of mourning which followed my death, during which a cold rain fell constantly, no bird sang, and children were born antlered and hooved; ... -- T. Herman Zweibel From rloisel at helicon.net Mon Jul 24 08:24:07 2000 From: rloisel at helicon.net (Rodney Loisel) Date: Mon, 24 Jul 2000 08:24:07 -0400 Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> <8lfq6o$g07$1@nnrp1.deja.com> <397B96EE.9C62A45F@helicon.net> Message-ID: <397C3567.18E4546B@helicon.net> If I have to type the following in a dos prompt with no history or mouse support every time I want to run a python program perhaps I'm asking the wrong questions... "C:\Your\Dir\Here>python C:\Your\Dir\Here>python hello.py" I may have in my ignorance downloaded PY5.2 which may be a beta version that assumes that tk is already on my computer. What is the latest full distribution and where might I get that, and do I just need to delete the whole python directory before installing the version I download? Someone please enlighten me - I've been using computers for 14+ years and am about to give up on this project if the basic setup information isn't available. rloisel Olivier Dagenais wrote: > In order to avoid having a window flash like that, you will have to use a > DOS prompt and invoke your scripts from the command line like so: > > C:\Your\Dir\Here>python hello.py > > ...then, if there is something totally wrong that prevents programs from > running, you'll know about it. > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Rodney Loisel" wrote in message > news:397B96EE.9C62A45F at helicon.net... > > There is a _tkinter.pyd in the Python\dll\ but there is no Tk directory. > Why > > > > would there be no Tk directory if Python seems to depend on it so much? > > All I can do with this program is 'run Python' or select it from the start > > menu > > and I get a generic dos shell with a >>> prompt an no shell features. > > Clicking > > on any *.py icon just opens and quickly closes a window before I can read > > what's in it. I downloaded the program thru the Python web site and > > installed > > it by their instructions. Looks like I've wasted 25.00 on my new "Teach > > yourself Python" book... > > rloisel > > > > Sam Schulenburg wrote: > > > > > Usually the problem is IDLE can not find the Tk dll's. My solution has > > > been to copy the Dll's from the Tk\bin directory to the Python\DLL > > > directory. > > > > > > Sam Schulenburg > > > > > > In article , > > > "Olivier Dagenais" wrote: > > > > The Python binary might be in your path, but maybe the libraries > > > aren't? > > > > > > > > -- > > > > ---------------------------------------------------------------------- > > > > Olivier A. Dagenais - Carleton University - Computer Science III > > > > > > > > "Rodney Loisel" wrote in message > > > > news:397B0D93.6A5EE7CB at helicon.net... > > > > > Changed the DOS properties not to close on exit > > > > > the following is the result of > > > > > import Tkinter > > > > > several levels of error > > > > > last: > > > > > DLL load failed: one of the library files > > > > > needed to run this application cannot be > > > > > found. > > > > > rloisel > > > > > > > > > > > > > > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > > From aek at aek.dk Fri Jul 14 16:49:56 2000 From: aek at aek.dk (Anders Eggers-Krag) Date: Fri, 14 Jul 2000 22:49:56 +0200 Subject: Downside to using Python in ASP/MS IIS server side? References: <3973b7ce.945183441@news.online.no> Message-ID: <41Lb5.996$bb.24557@news101.telia.com> Well there are other alternatives - I never understood why people use VBScript, rather than JScript, which would allow them to use the same scripting language both client side and server side allowing for more code reuse and a higher degree of learning and understanding the behaviour of the language Admited be it that I am considdering Python, I also did about 6 months ago but at that time no one on this list could/would tell me how to handle Collections and I gave up Personally I will be looking deep into python for my next project and by that time odds are that you people have solved all the small issues that has made me stay away from it till now :-) anyway the point is that I think you should take a look at JScript too Anders Eggers-Krag "Thomas Weholt" wrote in message news:3973b7ce.945183441 at news.online.no... > Hi, > > We`re trying to use Python as script-language instead of VBScript in a > MS IIS/MS Site Server solution. We have to access a MS SQL 7.0 > database too. Does anybody have any experience in something like this? > All we want is to get rid of VBScript. ( At least, for now ;->) > > Are there any obvios downsides to this? Will we get into trouble cuz > Python cannot access the same stuff as VBScript etc. ?? > > Any hints, advice or possible case-studies would be great. > > Thomas From paul at prescod.net Tue Jul 18 10:35:21 2000 From: paul at prescod.net (Paul Prescod) Date: Tue, 18 Jul 2000 09:35:21 -0500 Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395D7E14.B18EC77D@san.rr.com> <3968fadf.299209218@nntp.interaccess.com> <396A1436.3B6BD73B@sage.att.com> <8kld9h$489$1@nnrp1.deja.com> <8kvdon$tit$1@slb3.atl.mindspring.net> <39734BB4.8C24B6E@prescod.net> <3973ef17.387124584@news.nikoma.de> Message-ID: <39746B29.F5FE5FBB@prescod.net> "Philip 'Yes, that's my address' Newton" wrote: > > ... > > Why would ex-Perl-on-Unix-users have to switch to Python if their > platform disappeared? What makes you think (nearly) no-one on Mac OS or > Win32 uses Perl? I think Perl users on non-Unix platforms use Perl to be compatible with Unix. Python's native support for those platforms is much more solid, sophisticated and easy to use. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From moshez at math.huji.ac.il Fri Jul 28 02:05:29 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 28 Jul 2000 09:05:29 +0300 (IDT) Subject: Local user modules? In-Reply-To: Message-ID: On Thu, 27 Jul 2000, Steve Juranich wrote: > Without further ado, here's my question: Is it possible for a user to write > a module in C/C++ and make that available to the Python interpreter > *without* needing to edit systemfiles like > ${PYTHON_HOME}/Modules/Setup.local? This question is OS dependant, but for all OS's that matter, the answer is yes. I'm sure about this answer about Linux, AIX, Solaris and all Windows OSs. If you have a question about a specific OS, please bring it up... > Is is possible for me to add NumPy to my Python path without actually > sticking it in the main Python system path? Yes. > FYI, I know all about how to alter sys.path to add a directory like > ~/Python/MyModules that would add modules implemented in Python, but how do > I do the same thing for objects implemented in C/C++? The same way: Python uses the same search path for both kinds of modules. it-worked-for-me-ly y'rs, Z. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From jepler.lnk at lnk.ispi.net Wed Jul 12 08:34:35 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Wed, 12 Jul 2000 12:34:35 GMT Subject: Is pickle buggy? References: <396B069A.9EBDD68B@muc.das-werk.de> Message-ID: On Tue, 11 Jul 2000 13:35:54 +0200, Thomas Thiele wrote: >Hallo! I try it again, becouse it is important: > >Why does this programm (pickle) eats memory? >Why does pickle (marshal in it) not freeing the whole memory? > >And not cPickle eats more memory! Augmenting the test program with: class X: def __init__(self, s): self.s=s I can also observe this behavior. RedHat 6.2/python 1.5.2-13 I suspect, but haven't read the source well enough to know, that this has to do with the interning of strings. The following code will produce the memory leak without invoking pickle: def uniquestring(): # the code to generate those unique 5-letter strings while 1: eval(`uniquestring()`) If you think this sucks, you're probably right. Jeff From jkraska1 at san.rr.com Sun Jul 30 16:25:53 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 30 Jul 2000 20:25:53 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> <39838BAC.C855EDCB@san.rr.com> <39846ECC.DF5FE175@san.rr.com> Message-ID: <39848FFE.948BF635@san.rr.com> > >> >This is a conceptualization issue, and I suspect to a degree, > >> >false. If "x" is merely a label, one can imagine x labeling > >> >3 or x labelling red quite easily. Your analogy works because > >> >you carefully framed it, but there's nothing at all to say that > >> >your framing of it was right. > >> > > >> >To the contrary; while I can't prove it, I do believe it's wrong. > >> > >> Nobody expects a proof, but a just-as-carefully-framed > >> counter-analogy would be a good start... > > > >I don't know why I'd need a carefully framed analogy at all. > >The labelling concept speaks for itself, and in fact is the > >way that some people teach python. It seems to be quite > >intuitive. > > I'm sorry, but I have no idea if you're agreeing or disagreeing with me. > Are you claiming that in real life the operations you can perform on/with a > physical object are not determined by the type of the object? Not at all. I'm claiming that using real life operations was itself a framing of the problem which isn't at all correct. I'd argue that referring to a python variable as an arbitrary label to any object is something which is quite intuitive to the novice programmer. These same novices will also intuitively understand that, in the situation where the label is currently labelling an object of a particular type, certain operations are inappropriate for that object. Which is exactly how python behaves. C/ From embed at NOSPAM.geocities.com Tue Jul 4 14:42:18 2000 From: embed at NOSPAM.geocities.com (Warren Postma) Date: Tue, 4 Jul 2000 14:42:18 -0400 Subject: visual C++ giving runtime heap-check error in Py_Finalize(x) Message-ID: I have managed to get a repeatable (on my machine) version of either a reference count or other related kind of nasty bug in my embedded C++ application when I call Py_Finalize. The error I get is when trying to malloc some memory for a new object, the malloc call senses corruption of a previously freed block of memory, after the time it was last freed. here is the trace message that is printed out to the visual C++ output window: I get the following call stack: NTDLL! 77f9f9df() NTDLL! 77fcc8a1() NTDLL! 77f87aa3() NTDLL! 77fb3c33() NTDLL! 77fa7131() NTDLL! 77fca4cb() _free_base(void * 0x005d8a40) line 96 _free_dbg_lk(void * 0x005d8a60, int 0x00000001) line 1116 + 9 bytes _free_dbg(void * 0x005d8a60, int 0x00000001) line 1001 + 13 bytes free(void * 0x005d8a60) line 956 + 11 bytes string_dealloc() line 175 + 9 bytes PyString_Fini() line 1112 + 88 bytes Py_Finalize() line 242 What is happening is this: In PyString_Fini it is freeing the set of characters 0 to 255. When freeing character[17] I trace in, and it is calling the standard C method "free()" to release PyObject characters[17] which is the PyObject (string) memory at 0x5d8a90. As you can see above, some pointer mangling ends up happening. The reference count for the PyObject is 1 already, and the object itself does not appear to be corrupt. I added the line char *c = PyString_FromString( characters[i] ); just to see if I could still get the character values out of the strings, and they are all still there, and this string does not appear corrupt in any way but the heap debug code prints this warning and throws a debug exception: HEAP[myprogram.exe]: HEAP: Free Heap block 5d8a90 modified at 5d8ab8 after it was freed The funny thing is that there are no other threads in there, so if anything is modifying anything, then it's the malloc() code itself doing it. Has anybody else had a problem like this ever? Trick is, it does this both with my custom (statically linked) Python 1.5.2 and with the python15.dll also, so it's either (a) a bug in my code somewhere, probably one of my C extensions somewhere or (b) something weird in Python itself, which my code is causing to happen, but which is definitely a bug in 1.5.2. I am leaning towards (A) because it is 99.9999% of the time always my fault! :-) Warren Postma From hinsen at cnrs-orleans.fr Thu Jul 20 12:13:43 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 20 Jul 2000 18:13:43 +0200 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: Tim Hochberg writes: > Although, there's a fair amount of "symbol" space in this kind of operator > scheme, but there's still an issue in that for dimensions greater than > two, there's no way to specify which axis to apply the inner products > on. I'm not sure there's any good way to do that with infix notation though. Again APL comes to the rescue: add indices to operators. For example, (+.*)[0,2] would be an inner product along axis 0 of the left operand and axis 2 of the right one. On the other hand, I am not convinced that such things are really that useful - you can always transpose your arrays prior to applying complex operators. I would leave such sophistications out of the discussion for now; one can always add them later if there is really a need. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From edream at tds.net Sat Jul 8 21:57:05 2000 From: edream at tds.net (Edward K. Ream) Date: Sun, 09 Jul 2000 01:57:05 GMT Subject: Borland C++ Builder make files for Python? Message-ID: <3967DBDB.7FBDD3E5@tds.net> I would like to build the Python interpreter and library using Borland C++ Builder 4 so that I can embed Python in an app. Does anyone have such a makefile that works? Thanks, Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From paul at prescod.net.bbs Tue Jul 18 00:20:06 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 18 Jul 2000 04:20:06 GMT Subject: Wherefore art thou, 1.6? Message-ID: <3bRab5$m5r@openbazaar.net> Manus Hand wrote: > > ... > > Can someone please post a status on 1.6? Here's part of the story: http://www.pythonlabs.com/news_sitelaunch.html And the next part: http://www.pythonlabs.com/tech/python2.html And some more: http://www.python.org/pipermail/python-dev/2000-July/011960.html http://www.python.org/pipermail/python-dev/2000-July/012574.html No news since. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From laurent8 at sxb.bsf.alcatel.fr Tue Jul 11 12:39:10 2000 From: laurent8 at sxb.bsf.alcatel.fr (Frederic Laurent) Date: Tue, 11 Jul 2000 18:39:10 +0200 Subject: simple (?) re question Message-ID: <396B4DAE.3FEF0B0E@sxb.bsf.alcatel.fr> Hi, I try to have a regular expression that doesn't match if a filename is composed of "SCCS", so I have >>> r=re.compile(".*(?!SCCS.*$).*[.]java$") and then >>> r.match("/foo/bar/SCCS/s.file.java") But it's wrong for me ! I was expected this file will not match. I've got the same problem with an expression wich mustn't match something that's ending with a java extension >>> r=re.compile(".*[.](?!java$).*$") with 2 dot, it doesn't work, >>> r.match("/foo/bar/SCCS/s.file.java") but with only one, it's ok >>> r.match("/foo/bar/SCCS/file.java") so, what's the problem ? thanks in advance, -- Fr?d?ric LAURENT mailto:frederic.laurent at sxb.bsf.alcatel.fr T?l : (33) 03 88 55 70 00 poste 57228 From grey at despair.rpglink.com Thu Jul 27 18:28:25 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 22:28:25 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> Message-ID: On 27 Jul 2000 20:24:38 GMT, Martijn Faassen wrote: >In the end if you want to add your data together, you need to know what >the result will be. If you want to substract your data, you also need >to know. That all depends. In python, yes, you need to know. Why? Because 1 + "foo" doesn't work. Sure, in perl you get 1, but you don't get blown out of the water because of it. OTOH, in Perl, if you meant to do a string addition there is a different.syntax.for.that. Because of this you know that "foo" doesn't equal anything, IE, 0. >What if your data is "foo" and you add them together? What if >the user gave some input and you don't *know* what the user entered? Then that would be a user error, wouldn't it? You can check for those things. If you're relying upon user input you don't need type checking to do it. python: try: b = b + 1 except TypeError: print "Numbers, stupid, not letters." perl: unless (int($a)){ print("Numbers, stupid, not letters.\n") } $a++ The difference comes when you do something like this: (/^(\d{1,2})[Dd](\d{1,3})$/ || /^(\d{1,2})[Dd](\d{1,3})([\+\-])(\d{1,2})$/) Perl or Python, doesn't matter, you should be able to read it. Simple regular expression to take die codes from RPGs (3D6+3, for example) and break it down into the component parts regardless of their being a modifier to the actual dice rolled. What does this sample show? Same thing that the previous one did. (/^(\d{1,2})[Dd](\d{1,3})$/ || /^(\d{1,2})[Dd](\d{1,3})([\+\-])(\d{1,2})$/) $1 $2 $1 $2 $3 $4 I already /know/ that the user supplied data are numbers! The regular expression has taken care of that for me. That, right there, is my checking. You pass fooDfoo+foo through that filter then we'll have something to talk about. I don't need range telling me that I'm supplying an invalid data type because, unless the re module is seriously broken, it isn't going to happen. To think that the only way to catch such errors is at the same level, when something is called, is absurd. Especially, as I said, when we are taking the data type from context! I mean, I know those are numbers, the regex prohibits numbers in 1,2 and 4. I know 3 is going to be + or -. That is all it can be. But because regex is considered a string operation it assumes that all returns are strings. Because of this any assignments you make from those returns are going to be strings unless you force them into another type. This even though I not once told it what type the data is! If it is giving a type from the first operation performed on that variable then why can it not also change types based on subsequent operations? >I think in your case you usually need to remember what type your data >is *anyway*, and what's worse you need to know what will happen to your >data for various cases: Assumption: that data checking cannot be performed by the programmer. False assumption, I've given two examples where the data will be what I want because I have made the appropriate checks. One comes right from the program that I am porting to Python to learn Python. In fact, that program relies on user input every step of the way yet I've not had any problems performing the operations I want to perform on the data. >This may become quite unobvious in various cases, and may happen by >accident, right? Doesn't mean the programming language should barf on it. I am of the opinion that a /lot/ more operations are performed where a lack of type checking is a virtue than a bane. I really dislike having to explicitely declare data as a certain type just for an operation, especially after having programmed in a language where such is not required and especially if I have control of the dataflow throughout the entire course of its life. Not only does this cause problems for simple operations like extracting numbers with regex to be manipulated with mathematics, but also internal data structures where the author is defining things on the fly and needs to perform both string and numerical operations on, say, the keys of a hash/directory. >Though I understand the case for genericity, I don't really see it here. I see it the other way. Though I understand the case for typing, I rarely see a case where it is actually useful and, in fact, many cases where it is a bane. I'd much rather have to deal with the few cases when they arise than the many cases when they arise. For example, mathematics which require roll-over at a certain number (unsigned int, for example). This is more so in a language which does have certain cases when types can change (int versus float, for example) and the initial type is implicitly stated but requires an explicit declaration to change that implicit type. Either have all types be immutable regardless of context unless explicitly stated or have all types mutable as best as possible based on context with the option of explicit typing. The half-and-half is just as confusing as a lot of what a lot of Python pundants dislike about Perl. Just like lists and directories (does that include tuples? I forget) being referenced but the "single" data types (integer, character, I believe string, not sure) being copied. That is no less magical and confusing than, say, using an implicit $_ in a foreach loop or constructing a data loop from @lines into %lines using $line to do it. $lines{$line} = $line[$line] is always fun to bedazzle newbies, isn't it? No different than implicit typing, IMHO, except here I do have cues as to what is a scalar, a hash and an array. >But what if that makes no sense? What if I entered 'foo' in the config >file where I needed to enter a number? Won't you get a weird bug now? OK, go ahead and do it in Python, what do you get? An exception. Do it in Perl, what do you get? The /possibility/ of odd behavior. The language doesn't know! /I/ am the human. /I/ am the smart one. I don't need a language to tell me that adding numbermatch.group(1) and numbermatch.group(2) is invalid when they came from (\d*) constructs in a regular expression. They're numbers! I made sure they are numbers! Right there, \d. And that is the whole point. In both cases you have to do error checking. The difference is that with the implicit types enforced it gets in the way. I'd much rather the language assume I am smart enough do to my own checking and assured that the data is valid than to assume I'm too stupid to do it and crap the program out when something doesn't match what it /thinks/ is invalid even though I have taken pains to ensure it is. >This script won't do anything. Thank you for so stating the obvious, especially when I provided the interactive mode right after it. >I imagine the reason Python doesn't complain here is that it can treat >expressions as statements, and that sometimes this makes sense, such >as when there's a function call: The problem is, outside the context of interactive mode what good does it do? Nothing that I can think if. Have you made calls for Python to check for such things just as it checks implicit types? If not, why not? In both cases the assumption is that the programmer does dumb things and should be babysat. >I'm not claiming we want to be strict about things at all times. If >I thought that I wouldn't be using Python. I was claiming that 'guessing' >what a line of code is supposed to mean can be bad. I mean, really: >"foo1" + 1 # 1 >"1foo" + 1 # 2 >"1" + 1 # 2 >" 1" + 1 # 2 >"\n1" + 1 # 2 >"1*2" + 1 # 2 >Are you sure this never gives you any odd output? Positive. Because you have made the base assumption that the only way to check data is for the language to do it instead of the programmer. I know what data I am passing, I don't need type checking in an implicit system to provide annoyances all over the place for the off chance that I /might/ goof up. Quite a Libertarian view, innit? In a sentence. LET ME MAKE MISTAKES! >No, giving up in the face of ambiguity versus guessing. Ambiguity tends >to arise when I'm doing something wrong; if I did it right it wouldn't >be ambiguous code. Besides, I wouldn't want to read such code even >if it did the right thing; confusing. What ambiguity? Data is data. I don't find it confusing when you unlearn the concept of types. I mean, how many people out there who program in other languages consider Python confusing because whitespace is used for block declaration instead of {} or BEGIN/END or whatever other block declaration is out there. If your mind can wrap itself around the concept of a lack of braces for block declaration then there should be no problem unlearning the concept of data "types". >In Python there are tons of ways to do it too. :) So long as you tell it explicitly what you want even though its ambuigity on the implicit typing is what cause the problem in the first place? I'm sorry, but I do not consider data confusing unless it is typed. I see 1 and I am confused why I can't add it to 2. I don't /care/ if it is a char, string, integer or floating. It is 1 to me. >Because I wasn't arguing for 'strict checking'; I was arguing not checking >until the *last moment*, and if that makes no sense, give up. >(unless you catch the exception, of course) Which makes no sense without declarations up front since you are allowing ambiguity, to use your term, from the onset. Python: You need to know what data type it spews out for each operation. Perl: You need to know what the data contains. Either way, you got ambiguity. As for catching the exception I'd much rather check the data first, thank you. >Not in OO code: Funny, we have implicit typing in OO code that causes problems later in the code. So yes in OO code. >That works, as the check at the last moment could figure it out; there was >such a method, so it executes it. Now if 'doit()' was absent and the system >started guessing, we'd be in trouble, right? This is not, however, data. Methods are functions, if there is nothing to call, there is nothing to call. 1 is data, be it integer, float, char, string or any other name you want to give it. >So I don't need to know about what happens when I do "1foo" + 1? >Or "foo1" + 1? Or "foo1" - 1? Presumably I'd need to check my user >input *anyway*, right? Yup, that is exactly what you should be doing and if you were doing it properly then you'd not have to rely upon the language to do it for you. As I said, you're trading knowing what a certaion operation does with certain data versus having to know what type of data a certaion operation spits out at you. 6, half dozen. Ring a bell? >> Not that hard to remember. Much easier, in fact, that having to >> remember to declare everything from the onset or declare it each time you >> need to use it in a particular context much less having to put in checks >> in case you're trying to declare something into something which it cannot >> be morphed into. >But in Python you don't need to declare at all. You just need to explicitly >say sometimes you want something changed into something else. If you >want an integer, change your string into an integer. Do it early on if >you don't want to do it everywhere and work with integers from then on. Thank you for ignoring what I said. First off, in Perl I don't have to declare at all as a rule and only need to worry about the exceptions. In Python it is the reverse, I need to declare as a rule except for the exceptions. Furthermore if I need to change my string into an integer I need first check to make sure it is a string /THEN/ I can convert it to an integer. >>> int(None) Traceback (innermost last): File "", line 1, in ? TypeError: object can't be converted to int {grey at teleute:~} perl print int(null)."\n" This causes problems when using a regex that has an or that can match different numbers of groups based on which or hits because any conversions on any group that didn't hit now needs to be encapsulated in either a try/except|finally block or an if. You might like littering your code with try/except and ifs which are only needed because the type checking isn't allowing you to do things you should be able to do but personally I don't. I find it foolish that I need to check a variable to make sure it exists so I can type it to integer when I know an integer is going into it in the first place! In short a regex which returns a number turns into... $modifider = $4; ...has become... if diematch.group(4): modifier = diematch.group(4) ...or... try: modifier = int(diematch.group(4)) except TypeError: pass All because I don't want to have to int() the darn thing every time I use it elsewhere. That may seem like a small thing but in my mind, since I consider everything just data, I move between string and numerical operations seamlessly because data is /both/. >The funny thing is that in Python this happens, and I'd agree with you, >but it tends to happen more often for class instances Except I don't consider instances data. They are structure or commands, not data. >We aren't so far apart in that sense; we just disagree about how many >operations the basic datatypes should support. I personally never had >trouble with having to call int() excessively, for instance. If you >find you're doing that a lot in your code, something may be odd about the >design of your code. I seriously doubt that. All I'm doing is a basic regex match and assignment of the matched data. I haven't gotten into making complex data structures yet in Python but I have a feeling the typing will get in the way since a lot of the times that I manipulate keys in a hash/directory I move in and out of numerical and string processing to get the job done. >Note also that in your case, the only thing you're complaining about is >that Python treats numbers and strings differently; Python doesn't care much >whether your number is an integer or a float or a long integer, for instance. >It doesn't distinguish between characters and strings either. The only >addition to your type pantheon would seem to be the string/number >dichotomy and the list/tuple dichotomy, nothing else. :) Hmmm, but you forget, lists, tuples and hashes are not data, they are structure. Hashes and arrays are not data, they are structure. Classes that hold only data are not data, they are structure. Classes, in fact, to me, are just structures that hold either functions (renamed to methods) or data. You have different types of data. I have, conceptually, data, commands and structure. What /form/ those take and what semantics assigned to them vary from language to language but the concepts to me are quite clear. data = the information. commands = the operations tha manipulate the data structure = orgainzation of either data or, in the case of OO, commands as well. 1 is data. Not integer, not string, not any other type that any other language has cast upon it to help it out. It is data. That is how my mind works and, in fact, that is how the minds of nearly every human being works. 1 is data. What to do with that data depends on context. There is no "conversion" as that is purely a machine concept since to it, everything is either on or off. The difference between your position and mind is that you're closer to the machine where the machine is closer to me. Lists, arrays, hashed, directories, classes, structs, etc, etc, etc are all organizational in nature. OO has the distinction of having the ability to apply those organizing constructs to commands and not just data. Operations, functions, prodecures, methods. All manipulate the data. The do something. In OO they can be organized. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From stephen at cerebralmaelstrom.com Sun Jul 9 12:44:52 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sun, 09 Jul 2000 16:44:52 GMT Subject: Borland C++ Builder make files for Python? References: <3967DBDB.7FBDD3E5@tds.net> <3968581B.C9571894@dittmar.net> Message-ID: <8_1a5.124522$WS3.1076728@typhoon.we.rr.com> Hinthint. Don't forget to run coff2omf on the VC lib if you just link it to your borland project :) --S Daniel Dittmar wrote in message news:3968581B.C9571894 at dittmar.net... > I think Borland supplies a tool to convert Visual C++ workspaces to C++ > Builder projects, at least they mention VCTOBPR.EXE in their help files > for the free command line tools. > > Unfortunately, this tool is not part of the free tools, so please submit > your converted makefiles to the Python team. > > BTW, I don't think it is really necessary to rebuild Python, just try > linking against the import lib created from the python15.dll. > > Daniel > > "Edward K. Ream" wrote: > > > > I would like to build the Python interpreter and library using Borland > > C++ Builder 4 so that I can embed Python in an app. Does anyone have > > such a makefile that works? > > From nils.otto.johansen at nrk.no Wed Jul 19 12:02:15 2000 From: nils.otto.johansen at nrk.no (Nils Otto Johansen) Date: Wed, 19 Jul 2000 18:02:15 +0200 Subject: Exception when creating com-object in thread Message-ID: Hi! When I am running a threaded python script, and in one of the threads want to creata a instance of a com class, an exception is raised saying : CoInitialize is not called (freely transleted from norwegian :"CoInitialize er ikke kalt.") any suggestions ?? What is CoInitialize, and how and why do I call it Nils From stephen at cerebralmaelstrom.com Fri Jul 14 20:29:29 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sat, 15 Jul 2000 00:29:29 GMT Subject: Getting local IP address... References: <8ko8qr$7cd$1@nnrp1.deja.com> Message-ID: Nevermind. I've discovered i'm intelligent enough to actually chcek Deja and get an answer so that i doin't have to spam ya'll with stupid questions :) Heh. :) --S Stephen Hansen wrote in message news:8ko8qr$7cd$1 at nnrp1.deja.com... > How do I go about getting my dynamic IP address? I want to make a > little program to check periodically (daily or so) and log the results > so I can determine how often my IP is getting shuffled. :) > > Thanks :) > > --Stephen > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From db3l at fitlinxx.com Fri Jul 21 18:53:27 2000 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jul 2000 18:53:27 -0400 Subject: Closing a file References: <8l7lm7$kkb$1@news6.svr.pol.co.uk> <39785934.FD37DFD8@sec.noaa.gov> <8la5ae$cck$1@news8.svr.pol.co.uk> Message-ID: "Duncan Smith" writes: > The following seems to do exactly what I want. It was suggested by a > computer scientist who knows no Python (but I presume C). Is 'sys.stdout = > 0' a safe way of handling this? Not if you want sys.stdout to continue functioning the way it normally does (e.g., this might generate errors in other code that uses 'print') :-) But yes, assigning sys.stdout to _anything_ else will remove the reference to your open file (which sys.stdout is holding, but loses when you point sys.stdout to reference something else - the integer 0 in this case) and the file object will then get closed and deleted. That's basically the same suggestion that the first responder to your original note mentioned. If I might suggest, it would be cleaner to save the old contents of sys.stdout when your function first reroutes it (just save it off in self.old_stdout or whatever), and then restore to that value when done. You also mentioned along the thread that this was one of your first programs. I'm not sure if rerouting sys.stdout and then using 'print' is a requirement of your application or if it's just the first way you tried to get file output. If you really just want to control output to the file, you could ignore sys.stdout altogether, just keep your file reference in an instance variable (say self.outputfile.write()) and then use normal file routines to do your output. Now in some cases they will differ a bit because 'print' assumes it should convert everything to a string before printing. If you want that format in the file with a direct write() you can convert the value into a string before calling write() in various ways (calling str(), using "%s" % value, etc..) -- -- 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 boncelet at eecis.udel.edu Wed Jul 19 10:53:46 2000 From: boncelet at eecis.udel.edu (Charles Boncelet) Date: Wed, 19 Jul 2000 10:53:46 -0400 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <3hitu4wiq9.fsf@angband.org> Message-ID: <3975C0FA.3A45B105@eecis.udel.edu> Eric Lorenzo wrote: > > Charles Boncelet writes: > > Let's get some facts (yes, I know we are not supposed to let facts > > interfere with our arguments on usenet): > > [Relative popularity measurements deleted.] > > These metrics are meaningless. You're comparing the popularity of > Matlab, the most popular tool for its problem domain (numerical > computing), to Python, which (unfortunately) isn't even close to the > most popular tool for its problem domain (general-purpose scripting > and programming). I'd imagine that establishing that there is a high > level of interest in this domain would be a prerequisite for > convincing anyone to add the desired features. But your metrics don't > tell us anything at all about the relative level of interest in the > numerical computing domain, and are thus useless for your apparent > purpose. Compare Python+Perl+Tcl+Java+C+C++ to Matlab+(Any other > languages targeted towards the numerical computing problem domain. > Mathematica?), and you might have something half-worthwhile. > > Eric I think you miss my point (which probably means that I didn't phrase it well). Matlab has many more users than Python. I don't care whether there are more script writers than numerical workers. I just wanted to clearly establish that Matlab is more popular than Python (which I think I have). Why did/do I want to establish this? It is my opinion that there are many numerical people out there who would be more than willing to switch to Python if Python was a little more appropriate for their needs (and perhaps if it was advertised a little more aggressively). Pros of Python for numerical users: Numpy is fast and well written (and getting better, thanks to the efforts of its developers). Python has access to lots of interesting libraries, e.g., databases, web, graphics, cryptography, etc. (I do things that combine numerical work with web and cryptographic tools and use database thingys to store the results. Python is great at these things.) Cons of Python for numerical users: Numpy does not have the simple syntax that mathematicians/engineers/etc love. It does not have the plethora of toolboxes Matlab does. (I expect Python to improve in this area.) Writing C numerical extensions is difficult for newcomers (and some not-so-newcomers :-) Python does not come setup for numerical work (with numpy, PIL, graphics builtin). Its help facilities are almost nonexistent. Reasons why Python is a better alternative than Octave, Perl, TCL, etc: Octave doesn't have easy access to the other things that Python has; it is only a free version of Matlab without all the toolboxes. Perl and TCL are far too ugly to seriously attract the numerical crowd (who are generally not professional programmers). On my soapbox: As you say, Python "isn't even close to the most popular tool for its problem domain". And yet, the Python community refuses to sully the language by adding things that might make it more popular (not just more operators for numerical work, but stackless for palm pilots, +=, ++, support for reloadable operators, typechecking, list comprehensions, more elaborate iterators, to name a few.) There might be arguments against each of these, but taken together it indicates an unwillingness to change. Python is perfect as is, and we certainly don't need to adopt the methods of the unwashed. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From jeremy at beopen.com Tue Jul 11 09:45:11 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 11 Jul 2000 09:45:11 EDT Subject: RADIUS authentication poll References: <14698.5654.645828.624122@bitdiddle.concentric.net> <20000710210546.N26534@xs4all.nl> Message-ID: Thomas Wouters writes: > On Mon, Jul 10, 2000 at 02:29:42PM -0400, Jeremy Hylton wrote: > > > We recently received a module submission for the Python standard > > library that implements very basic RADIUS authentication. It's not > > clear how widely useful this module would be. > > Not really something to put in the std. lib, in my humble opinion. This looks like the consensus conclusion. If someone need the radius module, she can find it using the Vaults of Parnassus. http://www.vex.net/parnassus/apyllo.py?i=37689935 Jeremy From srs25 at cornell.edu Tue Jul 25 11:06:11 2000 From: srs25 at cornell.edu (Samuel Scarano) Date: Tue, 25 Jul 2000 11:06:11 -0400 Subject: Searching a binary file References: Message-ID: <397DACE3.515F71A9@cornell.edu> Interesting problem. I'd like to propose a generalized one which I may be facing soon: Suppose you want to search with an *arbitrary* regular expression. In this case, you don't know how long the matching string may be, so you don't know how much overlap you need between buffers. Is it necessary, perhaps, to use a constant buffer-overlap size, thus placing a bound on the length of a matched string? Just to make it harder, suppose the buffers are numerous and arbitrarily small -- sometimes smaller than the matched-string length bound. Is there a way to get the regular expression engine to save its state at the end of one buffer and pick up where it left off on the next? I'm almost certain that this is possible (at least with the sort of naive DFA-based regex implementation that I have in mind), but has such functionality been made available in python? luthi at vaw.baug.ethz.NOSPAM.ch wrote: > > What is the fastest way to search a binary file for a certain byte pattern > (**** in my case)? > > I came up with this solution, but I guess there is a better way to do > it. Thanks for all suggestions. > > Martin Luethi > > ===== > > # constants > MaxFileSizeInMemory = 10*1000*1000 > > file = open('my_binary_file', 'b') > > file.seek(0,2) # set the pointer to the end of the file > filesize = file.tell() # get the size of the file > file.seek(0) # reset the file pointer > rex = re.compile(r'[\*]{4}') # the bytes to search for > starpointer = [] # position of the '****' in the file > oldpos = 0 > for i in range(filesize/MaxFileSizeInMemory + 1): > data = self.file.read(MaxFileSizeInMemory) # read a chunk of bytes > m = rex.search(data) > while m: # find all '****' in this chunk > pos = m.start() - 4 # corrected for the length of '****' > incpointer.append(pos + i*MaxFileSizeInMemory) > m = rex.search(data, pos + 10) > oldpos = pos > file.close() # close the file > > -- > ============================================================ > Martin Luethi Tel. +41 1 632 40 92 > VAW ETH Zuerich > CH-8092 Zuerich mail luthi at vaw.baum.ethz.ch > Switzerland > ============================================================ -- Samuel R. Scarano "Due to circumstances beyond my undergraduate, Cornell University control, I am master of my fate and captain of my soul." http://people.cornell.edu/pages/srs25/ -- Ashleigh Brilliant From claird at starbase.neosoft.com Tue Jul 18 09:12:53 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Jul 2000 08:12:53 -0500 Subject: newb question References: <3973EE1B.15B0B32E@mediaone.net> <8l0tfe$3th$1@nnrp1.deja.com> Message-ID: <163D6955A2007F47.FFD962D0598C8347.D4930FC2360D6694@lp.airnews.net> In article <8l0tfe$3th$1 at nnrp1.deja.com>, wrote: >In article <3973EE1B.15B0B32E at mediaone.net>, > Toy wrote: >> what is a simple way I can save variables that people enter in from >> 'raw_input' ? That way, someone enters the variables they want, then >> when the script is booted up everytime the machine starts, it will >grab >> the variables from somewhere. Thanks. >> Jason Toy >> toyboy at toy.eyep.net >> >> >The tutorial at Python's >website tells a simple and easy way to do exactly what you're >saying. If you can get the variables into a class (read section 9, in >particular 9.3) then it is easy to read and write a big set of vars all >together in one operation by using the 'pickle' command (read about >this and easy file creation/opening in section 7.2). I just read over . . . Pickling's good. In many situations, it can be handy simply to write out Python source text. I don't understand Tony's question well enough to know whether he's a candidate; however, gives a few examples that might be helpful. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From porter at et.byu.edu Tue Jul 11 13:50:09 2000 From: porter at et.byu.edu (C. Porter Bassett) Date: Tue, 11 Jul 2000 11:50:09 -0600 (MDT) Subject: Solaris Binaries Message-ID: I need to find python binaries for solaris7 and solaris8. I have found some on the net, but they don't have curses or even threads. I am not experienced enough to compile the thing by myself. Can anybody point me in the right direction? -------------------------------------------------------------------------- C. Porter Bassett porter at et.byu.edu http://www.et.byu.edu/~porter -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- From to_get_my_address at see.my.signature Thu Jul 27 02:29:19 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 19:29:19 +1300 Subject: Is the "Be" significant? (Re: The State of Python) References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: <397FD6B9.5017B952@see.my.signature> By the way, does BeOpen have anything to do with the BeOS people? If not, it would seem to be a rather confusing choice of name. -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From mblatch at orci.com Thu Jul 6 12:03:44 2000 From: mblatch at orci.com (m) Date: Thu, 06 Jul 2000 10:03:44 -0600 Subject: Having problems with Exceptions Message-ID: <3964ADE0.E8051736@orci.com> I'm new at Python coding and am trying to catch errors returned by os.open with exception handling. All errors with os.open are returned with an OSError exception. So, how do I split out the individual errors with something as simple as: try: file=os.open("test",os.O_RDWR | os.O_CREAT | os.O_EXCL, 0444) except OSError: {want to do different things here for errno EEXIST (file exists) or EACCES (Permission denied), etc.} I have looked at the tuple returned by sys.exc_info() and can extract the *text* of the Python error message (i.e. "[Errno 17] File exists"), but not the numeric error number. I certianly don't want to have to rely on parsing the text to get the actual error. I'm sure there is an easy answer to this if someone would be kind enough to help me. Thanks, Mike mblatch at orci.com From paul at svensson.org Mon Jul 24 14:34:35 2000 From: paul at svensson.org (Paul Svensson) Date: 24 Jul 2000 18:34:35 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: <8li27r$6sg$1@newsy.ifm.liu.se> Tim Hochberg wrote: (summarized) >At this point there seems to be main proposals. There are variations >on these basic themes, but these two capture the main points: proposal 1: >New Operators: .+, .-, ./, .* proposal 2: >New Operators: (+), (-), (/), (*)[outer], (.)[dot], (|)[solve], (^)[power] Unfortunarely, neither of these seem very esthetically pleasing to me, and I don't mean the graphics. May I instead suggest that we add no new operators at all, just a modicum of new syntax. Logically, elementwise operators are defined in terms of operations on the elements, and thus should need no new __foobar__ methods, only some way (i.e. syntax) to indicate that the operators are operating on the elements (with the usual NumPy broadcasting applied) instead of on the whole. Matrix operators on the other hand, operate on the whole objects, which is the natural way for operators to be defined in Python, so it would make more sense to use the usual (+, -, *, /, **, ...) symbols for these. This is doable only as long as we don't usurp them for elementwise operations. As for what syntax to use for elementwise operations, X [+] Y (etc) immediately evokes the right image to me; naturally combining + and []. The extension from matrices to any and all Python containers comes naturally. (This should also mesh well with (augmented) assignment, for example, X [=] Y making a (shallow) copy into the existing object; however, I haven't quite thought thru the implications of this...) The up side: + clean, easy to understand syntax, with no surprises + the natural object-orientedness of python operators is preserved + no new operators or __foobar__ methods needed The down side: - no new operator for left division; use solve(x, y) - no new operators for various different multiplications - the NumPy people are not likely to be pleased /Paul From owen at astroNOJNK.washington.edu.invalid Mon Jul 17 13:43:33 2000 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Mon, 17 Jul 2000 10:43:33 -0700 Subject: Tkinter canvas resize question Message-ID: <8kvgk5$6m4q$1@nntp6.u.washington.edu> I have a Tkinter canvas (along with a few other widgets) in a window. I want the canvas widget to resize whenever the window resizes (the other widgets are fields with fixed height). Not a problem, so far. But...I'd also like to resize the contents of the canvas whenever the user resizes the window. I have been catching the event, but this is not very satisfactory because I see it before the canvas does. I've been manually configuring canvas to a new size, but this is potentially unstable -- if I don't set exactly the size the frame wants, the frame will generate a new event, leading to many cycles of size changing. What I'd really like is for the canvas to resize itself (i.e. perform all the standard negotiations with its master) and then tell me it has been resized, so I can redo its contents. Is there some easy way to do this? Saving this, is there some easy way to catch , pass it to canvas (as if I'd never intercepted it) and then ask canvas what size it has become and redo its contents accordingly? I do have John Grayson's book "Python and Tkinter Programming"; the info is likely in there, but I haven't found it. I suspect I should also have a complete Tk reference, and would welcome suggestions. -- Russell P.S. another useful thing would be to have a window that contained a canvas of a particular aspect ratio (say 1:1, square). When the user resized the window, the window would retain the newly requested height, but the width would change as needed to give the canvas its desired aspect ratio. Is this sort of thing possible, and what is involved? Writing a new layout manager? From jack at tornado.sh.cvut.cz.bbs Fri Jul 14 19:30:03 2000 From: jack at tornado.sh.cvut.cz.bbs (jack at tornado.sh.cvut.cz.bbs) Date: 14 Jul 2000 23:30:03 GMT Subject: wxNotebook in a wxWindow doesn't stretch Message-ID: <3bPCYR$mnu@openbazaar.net> hi. I am lost. After few hours of trying to solve it, I give up... I have following piece of code (modified, shortened...): class MainWindow(wxFrame): def __init__(self, parent, id, title): wxFrame.__init__(self, parent, id, title, size = (800, 600), style=wxDEFAULT_FRAME_STYLE| wxNO_FULL_REPAINT_ON_RESIZE) self.CreateStatusBar(1, wxST_SIZEGRIP) # is ksSPLIT is set, we split main window horizontally into two # subwindows if ksSPLIT: self.splitter = wxSplitterWindow(self, -1, style=wxNO_3D|wxSP_3D) self.leftWin = self.splitter self.desktopFrame = wxWindow(self.splitter, -1) self.desktopFrame.SetBackgroundColour(wxNamedColour("Pink")) else: self.splitter = None self.leftWin = None self.desktopFrame = self # the following code won't reside in constructor later! # I need the desktopWin placed IN desktopFrame so that it occupies the # whole area of it # desktopWin may look differently depending on the application, # when no desktopWin is set up, desktopFrame should be visible self.desktopWin = wxNotebook(self.desktopFrame, -1) txt = wxTextCtrl(self.desktopWin, -1, style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL) self.desktopWin.AddPage(txt, "Overview") sizer = wxBoxSizer(wxHORIZONTAL) sizer.Add(self.desktopWin, 1, wxEXPAND | wxALIGN_CENTER, 5) self.desktopFrame.SetAutoLayout(true); self.desktopFrame.SetSizer(sizer); #sizer.Fit(self.desktopFrame) self.Show(true) if ksSPLIT: self.splitter.SplitVertically(self.leftWin, self.desktopFrame) self.splitter.SetSashPosition(180, true) self.splitter.SetMinimumPaneSize(20) # a jeste pocatecni formular a jeho pracovni podminky self.aktivniFormular = None self.desktopWin = None now, when I set ksSPLIT = 0, everything works just fine. the desktopWin occupies the whole area of desktopFrame (== self). but as soon as I change ksSPLIT = 1, desktopWin takes only a very small area of desktopFrame (about 10x10 pixels) and it won't scale with the desktopFrame. thanks for your help. Jan -- Jan Fedak talk:jack at tornado.sh.cvut.cz mailto:J.Fedak at sh.cvut.cz mailto:jack at mobil.cz Linux - the ultimate NT Service Pack. From un4e at rzstud1.rz.uni-karlsruhe.de Wed Jul 19 08:44:30 2000 From: un4e at rzstud1.rz.uni-karlsruhe.de (Bjoern Giesler) Date: 19 Jul 2000 12:44:30 GMT Subject: Newbie question: PyOpenGL installation References: <3bRNNT$lvY@openbazaar.net> <8l2emv$583$13$1@news.t-online.com> Message-ID: <8l47re$313$1@news.rz.uni-karlsruhe.de> Hi, Thomas Malik <340083143317-0001 at t-online.de> wrote: :> :> * install python-numpy-15.3-1.i386.rpm from :> http://download.sourceforge.net/numpy/python-numpy-15.3-1.i386.rpm :> :> * grab pyOpenGL from CVS using the instructions on :> http://www.pythonpros.com/cvs.html :> : That's quite old, the actual PyOpenGL is now on : http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/?cvsroot=PyOpenGL I just got the CVS source from there, installed it (modifying it according to the rules posted in this thread), and it doesn't work :-( Just saying the two lines >>> from OpenGL.Tk import * >>> from OpenGL.GL import * results in a segmentation fault. The abbreviated backtrace is #0 0x8126fa7 in ?? () #1 0x8064211 in import_submodule (mod=0x8124288, subname=0xbfffe973 "GL", fullname=0xbfffe96c "OpenGL.GL") at import.c:1737 #2 0x8063e94 in load_next (mod=0x8124288, altmod=0x8124288, p_name=0xbfffed78, buf=0xbfffe96c "OpenGL.GL", p_buflen=0xbfffe968) at import.c:1603 #3 0x8063b31 in import_module_ex (name=0x0, globals=0x8130778, locals=0x8130778, fromlist=0x8120978) at import.c:1452 #4 0x8063c30 in PyImport_ImportModuleEx (name=0x81434ec "OpenGL.GL", globals=0x8130778, locals=0x8130778, fromlist=0x8120978) at import.c:1489 #5 0x8080065 in builtin___import__ (self=0x0, args=0x8127c88) at bltinmodule.c:65 The line in #1 is #1 0x8064211 in import_submodule (mod=0x8124288, subname=0xbfffe973 "GL", fullname=0xbfffe96c "OpenGL.GL") at import.c:1737 1737 path = PyObject_GetAttrString(mod, "__path__"); My system is a SuSE 6.3 (glibc 2.0), relatively pristine, on ix86. I'm at a loss here. Anyone have an idea why this happens, or even have a binary package you might tar up and send to me? Thanks a lot in advance. Regards, --Bj?rn From cmfinlay at SPAMmagnet.com.au Wed Jul 5 09:21:03 2000 From: cmfinlay at SPAMmagnet.com.au (cmfinlay at SPAMmagnet.com.au) Date: Wed, 05 Jul 2000 23:21:03 +1000 Subject: "Write to a file" question please? Message-ID: number = 100 print "Number =", number OUT = open("TT.txt","w") OUT.write("Number =", number) # Error OUT.close() The code above gives the error. Traceback (innermost last): File "ttest.py", line 5, in ? OUT.write("Number =", number) TypeError: read-only buffer, tuple OUT.write("Hello World") Works but a number or variable of a number does not. I have been reading documents on Python to no avail this time. I am using Win98 with the latest python for this OS. Any help would be much appreciated E-mail me at cmfinlaySPAM at magnet.com.au or reply here. From slinkp23 at yahoo.com Wed Jul 26 20:01:57 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 26 Jul 2000 20:01:57 -0400 Subject: Find where you left off... Message-ID: <397F7BF5.F4A0138D@yahoo.com> A little trick I discovered today: when writing python in emacs, you can mark the spot where you stopped just by writing some arbitrary text like "start from here" or whatever. Next time you open this file in emacs, just do C-c C-c ; python throws an exception and emacs jumps to the offending line. Cool. -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.slinkp.com A member of ARMS: http://www.reacharms.com From cg at schlund.de Thu Jul 13 11:15:39 2000 From: cg at schlund.de (Carsten Gaebler) Date: Thu, 13 Jul 2000 17:15:39 +0200 Subject: Sybase module crashes (segfault) References: <396B2DEA.2FAEA72B@schlund.de> <396B3885.F612FD76@schlund.de> Message-ID: <396DDD1B.1A64A561@schlund.de> Hi! Actually there are three cases in which Sybase.connect makes a segfault: - missing interfaces file - $SYBASE not set - $LANG set to anything else than "" or "C" and no internationalazation installed with Sybase Carsten. From nowonder at pool.informatik.rwth-aachen.de Tue Jul 25 01:40:57 2000 From: nowonder at pool.informatik.rwth-aachen.de (Peter Schneider-Kamp) Date: Tue, 25 Jul 2000 05:40:57 +0000 Subject: mapping the read() fonction References: <8lhsu5$huv$1@reda.worldonline.fr> Message-ID: <397D2869.2473D923@pool.informatik.rwth-aachen.de> Benjamin wrote: > > I would like to map the read() function of a file object Just use a lambda like this: map(lambda f:open(f,"r").read(), list_of_filenames) Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From bos at hack.org Mon Jul 31 17:57:05 2000 From: bos at hack.org (Rikard Bosnjakovic) Date: Mon, 31 Jul 2000 23:57:05 +0200 Subject: Profiler Message-ID: <3985F631.2814FE9A@hack.org> I'm using the profiler-module and it works okay. But now I'm interested in checking how many bytes memory different parts of my script allocates, especially my deep-nested and huge dictionaries. Is there a way/tool/whatever for this purpose? -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se Anyone sending unwanted advertising e-mail to my address will be charged $25 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From pauldubois at home.com Sun Jul 2 22:40:03 2000 From: pauldubois at home.com (Paul F. Dubois) Date: Mon, 03 Jul 2000 02:40:03 GMT Subject: Getting double* from NumPy array? References: Message-ID: <72T75.24010$i5.229971@news1.frmt1.sfba.home.com> Please see the appropriate chapter in the Numerical Documentation (Chapter 12, I believe). There is quite a bit to know and just telling you to access x->data would not be doing you any favors. Please read the entire chapter before proceeding. The process is not very complicated but it must be done correctly. Don't overlook the import_array statement. Ted Drain wrote in message news:ted.drain-2606001323500001 at mjordan.jpl.nasa.gov... > I have some existing C/C++ code that can accept a double array ( int len, > and double* ptr) to do some processing. I want to allow users to create > arrays in python using NumPy and then provide an interface to pass these > arrays to my C/C++ code. > > Assuming a 1-dimensional NumPy array, is there an easy way to extract a > pointer to a double and length from the python object? The C/C++ isn't > going to change the object so I'd prefer not to make a copy of it. > > Thanks > Ted > > -- > Ted Drain Jet Propulsion Laboratory Ted.Drain at jpl.nasa.gov From lull at acm.org Wed Jul 5 23:07:00 2000 From: lull at acm.org (John Lull) Date: 5 Jul 2000 22:07:00 -0500 Subject: Singleton COM local/remote server? References: <7bd5msssk48km280t9bvds4i3v6hs7r8or@4ax.com> <8jvad40s00@news1.newsguy.com> Message-ID: At the dawn of the third millenium (by the common reckoning), "Alex Martelli" wrote (with possible deletions): > Now, there remains the issue of, how to control the flags > used on CoRegisterClassObject by pythonw.exe...? I can't > find it in the docs (which doesn't mean it isn't there... > it just says I can't find it). Maybe we need to look at > the sources...? It seems to be passed as the third command line argument to LocalServer.py, which calls RegisterClassFactories(), which in turn calls CoRegisterClassObject(). LocalServer.py is apparently run anytime you start a Python local server. Now I just need to figure out how to set up the command line arguments -- I suspect it's something set in the registry during installation. Thanks much. Regards, John From hzhu at knowledgetrack.com Wed Jul 12 15:32:32 2000 From: hzhu at knowledgetrack.com (Huaiyu Zhu) Date: Wed, 12 Jul 2000 19:32:32 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: We are at a crucial juncture concerning introduction of new operators into Python for matrix computation, 1. Experiences with Matlab show that different operators for matrix and elementwise operators are very important 2. It is difficult to add .* and ./ as . is already a valid token. It seems that next candidate on the standard keyboard is @. 3. Gregory Lielens has just implemented a patch that could parse additional operators containing @ a at b is equivalent to a*b, overloaded using __mmul__ and __rmmul__ a@/b a/b __mrdiv__ and __rmrdiv__ a/@b b/a __mldiv__ and __rmldiv__ a@@b a**b __mpow__ and __rmpow__ He indicates similar constructions can be added easily. We intend to add these operators together with Thomas Wouters's augmented assignment operators (+=,*=, etc) to MatPy, but before that several decisions need to be made. First, the main choices: 1. Use a*b as matrix mul, and a@*b as elementwise mul. Pros: - Consistent with Matlab. - Consistent with current MatPy. - Convenient for matrix computations. Cons: - Inconsistent with NumPy - How to differentiate left and right div (matlab a\b and a/b)? 2. Use a@*b as matrix mul, and a*b as elementwise mul. Pros: - Consistent with NumPy - Can use a@/b and a/@b as matlab a/b and a\b. - Can use a at b as inner product so that a at b works irrespective of whether a and b are row or col operators. Cons: - Inconsistent with current MatPy. Need great effort to switch. - Using two symbol operator for matrix mul is cumbersome for long formulas. - It kind of looks ugly. 3. Use a at b as matrix mul, and a*b as elementwise mul. This has most of the pros and cons of choice 2, except Pros: - Single symbol operators for matrix mul and element mul. Cons: - Can't use a at b as inner product. Just to add to the agony, here are a few contrary views: 1. Consistency with Matlab is not necessarily good. In Matlab operators default to matrix (cf * and .*) but functions default to elementwise (cf exp and expm). In Python ** is defined by __pow__. Should it be consistent with pow the function or ** the operator? 2. Consistency with NumPy is not necessarily good. Currently one can use MatPy and NumPy at the same time. a*b will be matrixwise for MatPy and elementwise for NumPy. This is convenient when each usage is dominant in some part of a program. Removing this difference and MatPy will lose a lot of appeal when it is needed. 3. Although it is relatively difficult to switch the usage in MatPy, it is still a good time if we deem this to be A Good Thing. When the status is changed to beta from alpha it would be next to impossible to switch. To throw you completely off the track, here is one additional feature request that would great please mathematicians and greatly annoy computer scientists: Use ^ and @^ for matrix power. Currently ^ is defined as xor which is of sufficiently low level that is unlikely to occur with matrix computations. Note that this is not in our plan right now. One other thing that will be of great efficiency value (whenver somebody comes forward to do it) is to parse := as assignment. This way we can let a=b be simple reference assignment without creating a new Matrix object. The implementors of both previous patches have cautioned that Guido is unlikely to adopt the patch for the .* or @* operators. But I'm quite confident that he can be persuaded. There is a large number of users of Matlab and Octave (maybe even more than users of Python), and there is no fundamental reason they cannot use Python for doing the same thing, provided that we are allowed to add this little additional operator. :-) What other incentives are needed to persuade Guido? Here's a quote from Gregory, > they make a huge difference in readability of code dealing with linear > algebra, in particular when using small matrices. Such operators explain > partly the popularity of Matlab-like tools, imho. I can argue that linear algebra is very important for Python, perhaps even more important than complex numbers, but this is off topic. So all your comments, suggestions and flames a invited. I just have a small request: As this is getting too long, please reply separately to different parts of this article, so that the discussion threads remain manageable. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From stephen_purcell at yahoo.com Thu Jul 20 09:51:33 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 20 Jul 2000 13:51:33 -0000 Subject: Intercept methods/raise exception In-Reply-To: <3979f896.26656309@news.online.no> Message-ID: <8l7055+uhdi@eGroups.com> thomas at c... (Thomas Weholt) wrote: > >Is there a way to define a method in a class that is called each time > >every other method is called in that class, and based on a attribute, > >raise an exception or let the method-class go thru? Check out the Bastion standard library module. Even if you can't use it directly, the source code will certainly help you. http://www.python.org/doc/lib/module-Bastion.html -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From jepler.lnk at lnk.ispi.net Wed Jul 12 18:59:09 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Wed, 12 Jul 2000 22:59:09 GMT Subject: Glade References: <396B9784.191A513D@tcomhp43.epfl.ch> Message-ID: On Tue, 11 Jul 2000 23:54:13 +0200, Cedric Lefeuvre wrote: >1...Is there a good documentation because i didn't succeed in finding >one in the official site. I haven't found any. Instead, I learned Glade by trial and error. >2...What is the capacity of Glade..I mean it seems to be easy to create >static windows but is there the possibility (in the way to show results >of some applications) for example to change the size of a tree or a a >table.... Once you've created your application using a statement like wtree = libglade.GladeXML(gladefile) you can refer to individual widgets by widget = wtree.get_widget("widget_name") and then manipulate that widget: widget.set_usize(new_width,new_height) Of course, you can also add a scrollbar within glade and/or set the widget to expand when the user resizes the window. Personally, I don't care for applications that spontaneously move/resize their own windows. Jeff From mksql at my-deja.com Thu Jul 6 16:27:05 2000 From: mksql at my-deja.com (mksql at my-deja.com) Date: Thu, 06 Jul 2000 20:27:05 GMT Subject: Win32com curiousity #2: PythonWin code completion Message-ID: <8k2q2c$fg2$1@nnrp1.deja.com> When I first start PythonWin, the code completion feature seems to only partially function, until I save the source file at least once. This is when opening an existing source file, and after I have run makepy on the ADO libraries. For example, in a program with a recordset defines with: rs = win32com.client.Dispatch('ADODB.Recordset') typing 'rs.' brings up a partial list of methods/properties - Fields, MoveNext, Open After saving the program, 'rs.' brings up the entire expected list. Interestingly, the 3 keywords above are method/properties that already exist in preceeding code. Am I missing a configuration step? Sent via Deja.com http://www.deja.com/ Before you buy. From scorder at incigna.com Thu Jul 13 12:24:38 2000 From: scorder at incigna.com (Sam) Date: Thu, 13 Jul 2000 12:24:38 -0400 Subject: ASP Questions References: <8kk616$5ck$1@plutonium.compulink.co.uk> Message-ID: On 13 Jul 2000 10:35:18 GMT, gbreed at cix.compulink.co.uk wrote: >Here are some outstanding problems I have with ASP files written in >Python. Hopefully, some of you will have solutions. > >I can't write to session or application variables. In VBScript, this is >done like Session("key")="value". In Python, for writing to a new key, >that translates to assignment to None. I found some documentation for >fixing this in P*rlScr*pt, but still can't get it to work in Python. > Session("key") = value is a VBScript specific thing. Its bypassing the default method of Session which in this case is probably Item. I'm not sure off hand. >Response.Redirect doesn't terminate execution of the script. I'm getting >round this by throwing an exception, but is there a command that can do >the same job more cleanly? Have you tried a return statement? I'm guessing here but the asp page is probably being executed in some kind of invisible function. >I ran a script with an infinite loop once. How should I have terminated >it (other than by proof reading my code better)? Not sure. The same has happened to us in vbscript and we ended up shutting down the server. He forgot the recordset.movenext while in a loop processing a recordset. Typically if you can get to the box fast enough before the ram is swallowed up you can shutdown iis. Otherwise I think it was the power button because the box was totally unresponsive. There may be a page execution timeout that can be specified in iis. I don't remember off hand. >I'm finding the, when Append-ing parameters to a stored procedure, the >parameter names are ignored. Is this right? This isn't a Python problem, >but I thought I'd throw it in anyway. > Now something that I definately know about. I ran into this problem last week. Here is the relavant code. import win32com.client constants = win32com.client.constants # I just do it this way instead of a from so that its easy to reimport in asp. rs = win32com.client.Dispatch('ADODB.Recordset') cmd = win32com.client.Dispatch('ADODB.Command') cmd.ActiveConnection = ("big long connection string") cmd.CommandText = "ExpConfig_Get" #Name of stored proc #a tuple of parameters params = ("ExpJobID", constants.adInteger, 4, 11), #Here is the line you are probably missing. cmd.CommandType = constants.adCmdStoredProc #Now I append the parameters... for parm in params: cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1], constants.adParamInput, parm[2], parm[3])) #set cursor location and run. rs.CursorLocation = constants.adUseClient rs.Open(cmd, CursorType = constants.adOpenForwardOnly, LockType = constants.adLockReadOnly) The reason that ado is ignoring your parameters is that the default command type is adCmdText. I guess when it is text it doesn't bother to look for any parameters associated with the command object. Though it might if your sql looked like "select * from whatever where id = ?" IIRC ? is used in the data environment designer in VB to denote a parameter in an sql call. > >Right, that'll do. Thank you for you time and any replies. > > Graham Your welcome hope it helped, -Sam From weeks at golden.dtc.hp.com Sun Jul 30 18:20:48 2000 From: weeks at golden.dtc.hp.com (Greg Weeks) Date: 30 Jul 2000 22:20:48 GMT Subject: experts disagree on "call-by-reference" Message-ID: <8m29o0$p9g$2@news.dtc.hp.com> Lisp, CLU, Java, and Python implement objects, assign objects, and pass objects to functions similarly. [Although Jave differs regarding its "primitive" types.] So I was curious about how various Lisp, CLU, and Java texts dealt with the issue of "references" and "call-by-whatever". I examined my bookshelf. Some texts used phasing I like; others didn't: "Lisp" (by Winston and Horn): The text makes no distinction between objects and references to objects, and it states that Lisp is call-by-value. "Common Lisp" (by Steele): The text makes no distinction between objects and references to objects. The text implies that objects are addresses: "(eq x y) is true iff x and y are the same identical object. (Implementationally, x and y are usually eq iff they address the same identical memory location.)" No mention is made of call-by-whatever. Structure and Interpretation of Computer Programs (by Abelson and Sussman): The text implies that objects are addresses: "In this representation, which is called box-and-pointer notation, each object is shown as a pointer to a box". The text then partially reverses itself with: "The box for a pair is actually a double box, the left part containing (a pointer to) the CAR of the pair and the right part containing the CDR." For consistency, "(a pointer to)" should have been omitted. The text states that Lisp is call-by-value. CLU Reference Manual (by Liskov and others): The text doesn't say quite what an object is, but it seems to say that an object is not an address. It also states that CLU argument passing is not call-by-value or call-by-reference. but is instead "call-by-sharing". The Java Language Specification (by Gosling, Joy, and Steele): The text distinguishes between objects and references. No mention is made of call-by-whatever. All of the passages mentioned above could just as well apply to Python. The experts are in explicit disagreement. Regards, Greg From hamish_lawson at yahoo.co.uk Tue Jul 25 16:58:49 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 25 Jul 2000 13:58:49 -0700 Subject: ZORB for Mac? References: <397DFAD2.6354B460@spacenet.tn.cornell.edu> Message-ID: <16f52c28.854faa9c@usw-ex0106-046.remarq.com> Here's what the Zope FAQ says about building Zope on the Mac. I don't know whether the same issues would apply to building just ZODB. > Is there a version of Zope that runs on the Macintosh OS? > > Due to some C code that is embedded in Zope, it cannot run > on "straight" Python code, and therefore does not currently > run on a Mac. This does not mean that Zope could not be > ported. Michel Pelletier of Digital Creations has > commented, "Certainly, there is an issue about the C code that > comes with Zope. There is no reason why someone with enough > development studios and third party libraries couldn't compile > them however, they are written in ANSI C." The good news is > that Michel feels that Zope should compile cleanly on OS X, > although he has not yet given it a try. > > Can I run Zope on a Mac using the LinuxPPC operating system? > > Yes, several people are successfully running Zope on LinuxPPC > Macs. Hope this helps, Hamish Lawson ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From jerome.quelin at insalien.org Sat Jul 1 03:51:14 2000 From: jerome.quelin at insalien.org (Jerome Quelin) Date: Sat, 1 Jul 2000 09:51:14 +0200 Subject: Passing variable-length keyworded arguments list to base class constructor? References: <962352947.103057778@news.libertysurf.fr> <8F635367Cgmcmhypernetcom@199.171.54.154> <962379073.1230449645@news.libertysurf.fr> <8F63C1ABDgmcmhypernetcom@199.171.54.154> Message-ID: <962437874.1408268869@news.libertysurf.fr> gmcm at hypernet.com (Gordon McMillan) wrote: >>That is exactly what I want to know: what this mucking consists of? >Depends on what args the base class expects. If the base class expects >**kwargs, then you can have anything in there. >But maybe you've been playing with the interpreter, and have discovered all >this by now... Yep, this works fine by now. Thanks all for your replies. Regards, Jerome -- jerome.quelin at insalien.org From m.faassen at vet.uu.nl Sun Jul 30 16:45:22 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jul 2000 20:45:22 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> <397FCE9C.F22BB6B4@see.my.signature> <8luu0m$ags$2@newshost.accu.uu.nl> <8m1ksm$kr9$1@news.dtc.hp.com> Message-ID: <8m2452$pqc$2@newshost.accu.uu.nl> (Greg Weeks) wrote: > [I should have mentioned this in my previous response, but I missed it:] > Martijn Faassen (m.faassen at vet.uu.nl) wrote: > : This seems to be where the confusion comes in. When people claim Python > : passes by value, because the *references* are being passed by value, > : that seems to be just stating that the only thing the computer can pass > : in the end is numbers. If you say that, everything is by value > Not really. The question is *which* number do you pass to the function: > the number written in the argument variable or the address of the argument > variable (which is then implicitly dereferenced). Perl passes the latter > (call by reference), Python passes the former (call by value). So, in Perl > you can have: > $x = 0; > f($x); > print "$x\n"; # PRINTS 42 Are you sure it works like that in Perl? I am not that familiar with Perl, but I thought it had an explicit way to do dereferencing. I thought Perl by default passes things *by value*, though you *can* pass the reference to a value if you want to (allowing this trick). In Python you can have the same thing, in fact, as Python passes references around. Except that in the case of integers, the integer object is immutable. But take a list, for instance, and you can do it: x = [0] def f(x): x[0] = 42 f(x) print x # prints [42] That's because in Python everything's a reference (and thus references are passed as well). It's just that some references point to mutable objects, and some don't (and in the latter case the semantics is equivalent to value semantics). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ioadler at my-deja.com.bbs Thu Jul 13 18:30:03 2000 From: ioadler at my-deja.com.bbs (ioadler at my-deja.com.bbs) Date: 13 Jul 2000 22:30:03 GMT Subject: Memory leaks Message-ID: <3bOLVR$mmM@openbazaar.net> In article <8F6667253gmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > Ingo Adler wrote: > > [strange leaks in SWIG'd code] > > >I have some simple Python-Code which generated memory leaks (ca. 4MB): > >(The real code is more complicated, but I could strip it down to this > >simple example = the smallest example with the memory leak.) > >//--------------------------- > >x = X() > > > >for i in range(100000): > > y = x.getY() > > y.getNumber() > >//--------------------------- > > Doing things in the "obvious" way from your (snipped) incomplete code, I > get no leak when using MSVC 5. > > - Gordon Hi Gordon, Finally, I reproduced the leaks under the control of "Code Guard", which can list them. For every call in the loop there is an entry like this (I translated it to English): Error 00175. 0x300010 (Thread 0xFFE455D5): Ressource-Leak: memory block (0x2732848) has never been released memory block (0x02732848) [Size: 40 Byte] was allocated with malloc call stack: 0x004AECDD(=FORTUNA.EXE:0x01:0ADCDD) \Python\Objects\stringobject.c#145 0x0044BE99(=FORTUNA.EXE:0x01:04AE99) \src\fortuna_wrap.c#769 0x0044F969(=FORTUNA.EXE:0x01:04E969) \src\fortuna_wrap.c#1824 0x0046B9F9(=FORTUNA.EXE:0x01:06A9F9) \Python\Python\ceval.c#2359 0x0046B892(=FORTUNA.EXE:0x01:06A892) \Python\Python\ceval.c#2324 0x0045EDBE(=FORTUNA.EXE:0x01:05DDBE) \Python\bltinmodule.c#126 That makes 40*100000 = 4 MB as I measured roughly before. fortuna_wrap.c is the code generated by swig: ... SWIGSTATICRUNTIME(PyObject *) SWIG_NewPointerObj(void *ptr, _swig_type_info *type) { char result[512]; PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, type->name, NULL); #else SWIG_MakePtr(result,ptr,type); // line 769 robj = PyString_FromString(result); #endif return robj; } ... #define Y_getX(_swigobj) (_swigobj->getX()) static PyObject *_wrap_Y_getX(PyObject *self, PyObject *args) { Y *_arg0; PyObject *_resultobj,*_argo0=0; X *_result; self = self; if(!PyArg_ParseTuple(args,"O:Y_getX",&_argo0)) return NULL; if ((SWIG_ConvertPtr(_argo0,(void **) &_arg0,SWIGTYPE_Y_p,1)) == -1) return NULL; _result = (X *)Y_getX(_arg0); // line 1824 _resultobj = SWIG_NewPointerObj((void *) _result, SWIGTYPE_X_p); return _resultobj; } ... So it happens in PyString_FromString - but only with this loop (= both functions in the loop). Any suggestions? Ingo Sent via Deja.com http://www.deja.com/ Before you buy. From hsl at tcp.co.uk Thu Jul 6 13:04:14 2000 From: hsl at tcp.co.uk (Martin Rand) Date: Thu, 06 Jul 2000 18:04:14 +0100 Subject: tkinter frames References: <8k26af$1nq$1@nnrp1.deja.com> Message-ID: On Thu, 06 Jul 2000 14:49:56 GMT, Keith Murphy wrote: >can anyone tell me why this doesn't work? > >from Tkinter import * > >root = Tk() >myFrame = Frame(root, width=200, height=200, bg='red') >myFrame2 = Frame(root, width=200, height=200, bg='orange') > >label1 = Label(myFrame, text='hi') > >myFrame.grid(row=0, column=0) >myFrame2.grid(row=0, column=2) > >root.mainloop() > > >...(in my mind)it should display two colored frames, one containing a >label. > You need to apply the appropriate geometry manager to label1 to get it displayed within the frame. -- Martin (off-duty) Chandlers Ford, Hampshire From thomas at xs4all.net Sun Jul 16 11:24:47 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 16 Jul 2000 17:24:47 +0200 Subject: Imports in classes?? In-Reply-To: ; from mskott@image.dk on Sun, Jul 16, 2000 at 03:11:03PM +0000 References: Message-ID: <20000716172447.X7340@xs4all.nl> On Sun, Jul 16, 2000 at 03:11:03PM +0000, Martin Sk?tt wrote: > Im currently writing a database applikation using Python and > PostgreSQL. Because I need both a GUI and a web interface i have > chosen to divide the program in three classes (and files): one containing my > database queryes and one for each interface type. But where would be > the right place to import my database connection module (pygresql)? In > each interface file or in the query file? > I guess both solutions would would work, but what would be the "right > thing"? The right thing would be to do it when you need it. If you need the pygresql module in each interface file (that is, you actually reference it), you will have to put it in there. If you don't, well, don't :-) Don't import modules you aren't going to use. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From digitig at cix.co.uk Sat Jul 22 16:28:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Sat, 22 Jul 2000 21:28 +0100 (BST) Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: In article , mwh21 at cam.ac.uk (Michael Hudson) wrote: > W.Whiten at mailbox.uq.edu.au (Bill Whiten) writes: > > > I would prefer the normal oprerators plus an escape character > > followed by > > additional characters to define new operators eg @+ @div etc. > > I quite like this idea (unlike most of the others that have been > mentioned...); it reminds me of Haskell. Ouch -- I don't. The type of an identifier determined by the characters in the identifier, rather than being assigned? That's one of the things I loathe about Perl. And what would a Python identifier be doing, constrained to refer only to one type? From jhe at webde-ag.de Thu Jul 20 04:07:32 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Thu, 20 Jul 2000 10:07:32 +0200 Subject: Get the name of the superlcass? References: <39779f54.3806062@news.online.no> Message-ID: <8l6bt3$euc$1@pollux.ip-plus.net> "Thomas Weholt" schrieb im Newsbeitrag news:39779f54.3806062 at news.online.no... > Ex. I got a class Structure, and a sublcass Building. I want to check > in a list for structures, then see if any of them are buildings. if isinstance(UncleTomsHut, Building): ... From OneDay at ATime.net Sat Jul 22 06:42:24 2000 From: OneDay at ATime.net (OneDay at ATime.net) Date: Sat, 22 Jul 2000 06:42:24 EDT Subject: Newbie question, Getting Started? Message-ID: <8lbtqg$2drj$1@earth.superlink.net> Hello all, I've done some programming with MS Access and Excell Visual Basic, but am new to Python. I've been reading the tutorial for several days now and am having difficulty figuring out where to start. For example, where do I write a simple MessageBox program? Can I write Python 1.5.2 or Tcl executable programs that can be run on a PC that does not have python installed? Thanks for your time, Al (The only stupid question is the one not asked.) From regenkind at gmx.de Mon Jul 10 14:01:32 2000 From: regenkind at gmx.de (Frank Timmermann) Date: Mon, 10 Jul 2000 20:01:32 +0200 Subject: including files References: <9yna5.229$iT2.4602@m2newsread.uni2.es> Message-ID: <396A0F7C.43F5CBE8@gmx.de> Hi, import modulname that is all to do to use a module. you don't need something like a '.h' file to include a module. cu regenkind "Fernando Rodr?guez" wrote: > Hi! > > What's teh Python's equivalent for C's #include "myfile.h"? O:-) > > TIA > > -- > > --------------------------------------- > Fernando Rodr?guez From urner at alumni.princeton.edu Fri Jul 28 13:18:00 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 28 Jul 2000 10:18:00 -0700 Subject: Python in politics (sssssssssnake!) Message-ID: Something from another newsgroup but mentions Python, so I elected to cross-post (to the CIA group as well, because of the InQTel thing)[1]. For more context re the below, check: http://www.egroups.com/message/synergeo/1319 http://www.egroups.com/message/synergeo/1321 Also my "Math Makeover" homepage at: http://www.teleport.com/~pdx4d/makeover0.html The basic idea is to remix education topics to come up with more robust synergies (blah blah) i.e. get more kids doing Python programming around polyhedra, while watching TV shows which show how life in a Fly's Eye dome might be exciting, and useful to others (ala 'ER'). Kirby 4D Solutions .projects: videogrammatron, synergetics, philosophers network [1] http://www.in-q-tel.com/ Note: changed "Malthusian" to "Malthusian-minded" for a better read. ========================================================================= Newsgroups: bit.listserv.geodesic Date: Fri, 28 Jul 2000 09:37:43 -0700 Reply-To: List for the discussion of Buckminster Fuller's works Sender: List for the discussion of Buckminster Fuller's works From: Kirby Urner Subject: Re: more late night synergetics Comments: cc: synergeo at egroups.com To: GEODESIC at LISTSERV.ACSU.BUFFALO.EDU At 08:55 AM 07/28/2000 -0700, Dick Fischbeck wrote: >Kirby-This is getting close to language I can really >grab onto. Would you rewrite this piece, say so that >an average sixth-grade could get it? >Thanks, >Dick I think for TV-immersed 6th graders these ideas would work best if presented as video with computer graphics. What we need is a databank of short videoclips, averaging under a minute in length, and retrievable by key word. You string these together or call them up in response to student questions. Hypertext interface. Distribution is by CDROM or DVD. In the USA, the Department of Education and DARPA should be pumping bucks into some prototypes, in consortium with the private sector (the corporations need not always be USA-based e.g. Sony), to catalyze a renaissance in education. A presidential candidate who doesn't speak in definite, clear terms about how she or he plans to revamp education is just blowing smoke, trying to get elected without doing the requisite homework. DARPA previously funded a "Computer Programming for Everybody" initiative (CP4E) designed to get more programming into the schools, with the Python language spearheading the effort.[1] That grant has long since run out, and is small change next to what's needed to spark imaginations around design science concepts more generally. Hollywood needs to get into the act, casting stars against a backdrop of futuristic artifacts that exists as working prototypes, not simply as phoney props or stage magician special effects. The game of brand placement (embedding logos in the actual programs, vs. separating out into separate advertising segments) will make a lot of sense in this context, as corporations vie with one another to prove their sponsorship of the "sexiest future" (e.g. Fly's Eye air-liftable utility pods, wired to cyberspace and staffed by youngsters with heavy duty real world responsibilities, ala ER -- real time camera access via webcam and TV segments (this is not a new theme for me -- shows like 'Survivor' bring us closer)). We're in dire need of a realistic futurism, an attainable positive tomorrow. Because a self-indulgent and Malthusian-minded academia has fallen down on the job (by and large), Federation pseudo-Science ala Star Trek has been allowed to fill the cultural void, holding out the prospect of a high tech future, but using mumbo jumbo concepts instead of hard science-math, leaving kids to fantasize helplessly about some 24th century, while Spaceship Earth meanwhile remains in the grip of obsolete power structures, desparate to hang on to power (the Napster fracas being just the tip of the iceberg vis-a-vis that juggernaut).[2] A lot of intellectuals overseas are well-aware of how USA politicos are consistently and concertedly ignoring their leadership responsibilities, which include inspiring positive future visions, vs. simply serving as the puppets and task masters of those who see humans as little more than exploitable consumers. This has the effect or eroding the credibility and even the comprehensibility of the political leadership. Why don't they make any sense? Education is from the inside out, but the inner world has been left in the hands of media manipulators who fill heads with cheap googoo-brained claptrap, whatever it takes to create a new generation of mall rats and fast food junkies. The USA, such as it still exists, is working to counter that diet, with healthful content -- design science based positive future imagery, backed up with real math and science, being chief among the vitamins and minerals we need to firm up our jello-brained culture. We should start a race to see which presidential candidate we can get to say "Buckminster Fuller" on TV first. The Republicans have an edge, because President Reagan awarded Bucky the Medal of Freedom. But Gore is into the internet, and that's a relevant segue to design science as well. Nader is highly critical of corporations ala 'Grunch of Giants' and so has plenty of hooks. There's nothing stopping any of these campaigns from jumping on the design science bandwagon and demonstrating some ability to point towards a positive future for all humanity. Any candidate who fails to lead the way to a better tomorrow ipso facto fails the minimum test for leadership ability, in my book. Kirby [1] CP4E: http://www.python.org/doc/essays/cp4e.html [2] http://www.salon.com/tech/col/rose/2000/07/27/napster_shutdown/index.html From fiona at sitegnome.com Fri Jul 14 00:14:48 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 14 Jul 2000 04:14:48 -0000 Subject: [FAQTS] Python Knowledge Base Update -- July 14th, 2000 Message-ID: <20000714041448.27471.qmail@synop.com> Hello! Once again another collection of entries into http://python.faqts.com Cheers, Fiona ## New Entries ################################################# ------------------------------------------------------------- How do I import a file that isn't in the pythonpath? http://www.faqts.com/knowledge-base/view.phtml/aid/4719 ------------------------------------------------------------- Fiona Czuczman Mike 'Cat' Perkonigg The easiest way is to put '.' in your PYTHONPATH. But you can extend your path with any directory in your python code with: >>>import sys >>>sys.path.append (path-to-load-modules-from) ------------------------------------------------------------- Is there a Python module that would allow me to easily parse and format vCards? http://www.faqts.com/knowledge-base/view.phtml/aid/4720 ------------------------------------------------------------- Fiona Czuczman Henning Schroeder The new WorldPilot 1.1alpha contains such a module (file vCard.py) ftp://demo.worldpilot.com/pub wppocket-1.1.0alpha2.tgz (see wppocket-1.1.0alpha2.tgz) ------------------------------------------------------------- Is there anybody who has worked on wbmp converter image from any other format in Python? If yes, where can I find it? http://www.faqts.com/knowledge-base/view.phtml/aid/4721 ------------------------------------------------------------- Fiona Czuczman Duncan Booth Try http://www.rcp.co.uk/distributed/Downloads The file wbmpconv.zip (1192k) is a command line convertor to/from wbmp format (Win32 binary). Alternatively, wbmpconvsrc.zip (8k) contains the python sources. The source version requires that you have Python and PIL installed on your machine, the binary is completely self contained but a bit large as it needs to include the Python and Tk dlls. Obviously the source version lets you convert to/from any image formats supported by PIL, the win32 binary supports: ARG BMP* CUR DCX EPS* FLI FPX GBR GIF* ICO IM* IMT IPTC JPEG* MCIDAS MIC MPEG MSP* PCD PCX* PIXAR PNG* PPM* PSD SGI SUN TGA TIFF* WBMP* WMF XBM* XPM XVTHUMB (the ones with a * may be read or written, the other formats may only be read). ------------------------------------------------------------- What is UnboundLocalError for? http://www.faqts.com/knowledge-base/view.phtml/aid/4722 ------------------------------------------------------------- Fiona Czuczman Tim Peters When a local name is referenced but has not been bound to a value. In other words, it's an unbound local error . Note that UnboundLocalError is a subclass of NameError, because it's a more specific form of NameError, so old code expecting to catch NameError exceptions will still catch UnboundLocalError exceptions. In 1.5.2 and before, NameError was thrown regardless of whether the offending name was local or global. So UnboundLocalError gives more information. > I encountered it when I made a mistake like this: > > >>> f() > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1, in f > UnboundLocalError: l > >>> So your function f (which you have not shown us) refers to a local name "l" which you didn't give a value before referencing it. It's impossible for us to guess what you put in the body of f; here's one possibility: >>> def f(): ... l = l + 1 # local "l" referenced on the right before definition ... return l ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in f UnboundLocalError: l >>> ## Edited Entries ############################################## ------------------------------------------------------------- What is wxPython? How does it compare with Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/3565 ------------------------------------------------------------- Fiona Czuczman, Olivier Dagenais Shae Erisson,http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpother wxPython [ http://www.wxpython.org ] is a set of Python bindings for the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was written as a C++ library to provide a platform-independant way of implementing rich and fast user interfaces. ----------------------------------------------------- I chose wxPython over Tkinter (for my projects) because: - wxWindows seems to have more widgets than Tk - special widgets (like the TreeView) are implemented using the operating system's native implementations, not complete re-writes - it's more than a "lowest common denominator" among platforms, wxWindows seeks to provide the same, advanced functionality on all platforms, even if it means they have to write a lot of code to complement a platform's native component - wxWindows seems to cover more ground, in terms of functionality (it's more than a GUI toolkit, it also seeks to provide functions/classes for files, threads, printing, clipboard, networking, ODBC, etc...) - I was *really* impressed with the wxPython demo ----------------------------------------------------- The wxWindows documentation emphasizes the "less good" points of other GUI toolkits (namely Tkinter) to motivate wxPython: http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin465.htm#wxpothe r ------------------------------------------------------------- Should __getattr__ increment the reference count before it returns the appropriate attribute, or not? writing a Python module in C http://www.faqts.com/knowledge-base/view.phtml/aid/2907 ------------------------------------------------------------- Fiona Czuczman Gordon McMillan It should incref the attribute and leave the owner alone. Imagine a sequence like this: newref = a.b # here's your __getattr__ a = None Now a's refcount drops. If it drops to 0, it gets deallocated, which will decref b. Without an incref in __getattr__, the user would have an invalid reference. ------------------------------------------------------------- How do I check to see if a file exists? http://www.faqts.com/knowledge-base/view.phtml/aid/2782 ------------------------------------------------------------- Fiona Czuczman Fredrik Lundh,Peter Schneider-Kamp To check if a file exists use: >>> import os.path >>> os.path.exists("python/") 1 >>> os.path.exists("spam/") 0 >>> os.path.exists("python/patches/submitted/array.pop-extend.patch") 1 If you only want a true for regular files have a look at isfile(): >>> os.path.isfile("python/") 0 >>> os.path.isfile("spam/") 0 >>> os.path.isfile("python/patches/submitted/array.pop-extend.patch") for more info or other function look at: http://python.org/doc/current/lib/module-os.path.html From walter111 at structurex.net Sun Jul 30 04:14:59 2000 From: walter111 at structurex.net (walter hanagriff) Date: Sun, 30 Jul 2000 03:14:59 -0500 Subject: not stopping til it works Message-ID: <3983E403.36183DF8@structurex.net> before i go on, one thing to say, i do not have the money to buy a book right now, otherwise i would, it would be great to actually be able to read a good tutorial on tkinter at almost any price, just saying since i did get that suggestion once i have tried so many ways to get what i want to work, and getting nowhere, its definitely not from lack of trying and patience that keeps me asking the same questions, though if i ever get these 2 answered it will be all for awhile i am sure i wont give up though so i have simplified the problem as much as possible, the only problems so far that i know of i have these 2 entry fields, how do i get any info that a person puts into them i tried using textvariable but i cant get it to work, and i tried using the get method with entry widget, but neither of these 2 things work next, how do i get that info to work with the pow() function, ex. the user inputs 3 in box 1 and 2 in box 2, i get those numbers and show on the screen this: first entry, " to the power of ", second entry, " = ", first entry**second entry actually it should look like this, "3 to the power of 2 = 9" i next want it so that when pressed, button will make this info appear in the frame or any better ideas for showing the answer? unfortunately i can do very little testing to see how to make the button work since i have a hard enough time getting there because of the first problem, but in test i have given predefined numbers to print out and tried using the button to show them and i tried not packing the label til i pressed button, or tried calling a def when i press button but no matter what the label prints out along with entry fields, before i even press the button and pressing button does nothing, when i dont even get an error from something def power(self, frame): Entry(frame, width = 10).pack() Entry(frame, width = 10).pack() Button(frame, text = 'Get answer').pack(side = LEFT) From dcalvelo at pharion.univ-lille2.fr Tue Jul 25 15:36:25 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 25 Jul 2000 19:36:25 GMT Subject: Reading a file References: Message-ID: <8lkq7p$1gj$1@netserv.univ-lille1.fr> Tim Northover wrote: : I'm attempting to read a file line by line with readline(), but it : seems to return and empty string when EOF is encountered. Is there a : way of discerning the difference between the end of the file and a : blank line in the file? An empty line is never empty: it has \n or \r or both. : I'm very new to this so I don't know the methods used but I couldn't : find anything relevant when grepping the html docs. http://www.python.org/doc/FAQ.html Entry 6.30 HTH -- DCA -- Daniel Calvelo Aros calvelo at lifl.fr From peter at schneider-kamp.de Tue Jul 11 18:51:16 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Tue, 11 Jul 2000 22:51:16 +0000 Subject: kjbuckets References: <8kflcs$8qv$1@einstein.ebicom.net> Message-ID: <396BA4E4.2C221BD7@schneider-kamp.de> gene at ozob.net wrote: > > I am trying to install a program call routeplanner which requires > kjbuckets which appears to be an extension of python. Kjbuckets docs say > to read the python extension manual to learn how to compile kjbuckets into > pythons. However I can seem to locate this document. > > I would appreciate if someone would give me a clue. It should be part of the documentation that comes with python. In any case you can find it at the Python website (http://www.python.org) under "Documentation" and "Extending and Embedding" (http://www.python.org/current/ext/ext.html). Hope that helps, Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From fplancke at my-deja.com Wed Jul 19 13:46:21 2000 From: fplancke at my-deja.com (Frédéric van der Plancke) Date: Wed, 19 Jul 2000 17:46:21 GMT Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> Message-ID: <8l4ph6$vj$1@nnrp1.deja.com> In article <3974E8CD.55215FD9 at inrialpes.fr>, Vladimir.Marangozov at inrialpes.fr wrote: > [...] the python-dev members are looking for feedback. For instance, > read the PEP documents -- they summarize recent and past proposals for Sorry I'm dense, but where can I find that ? Where can I find PEP documents ? It's bad it's so hard, hard, hard to find current information about Python on the web starting from would-be obvious points. (Exercise: starting from www.python.org/, find anything "mainstream" about Python 2, or "Python-dev" ... :-( ) (By "mainstream" I mean something like "What's new in Python 2.0" - yes I eventally was lucky enough to get a hand on that one -- or "table of PEP documents/proposals/..." -- these items are still wanted, if they exist.) Web links on the www.python.org main page (or equivalent) would be fine. -- Frederic van der Plancke e-mail address: reverse and add dot-at-dot to: (I don't read regularly.) Sent via Deja.com http://www.deja.com/ Before you buy. From milenko at moonshine.co.uk Sat Jul 22 08:47:20 2000 From: milenko at moonshine.co.uk (Jack) Date: 22 Jul 2000 12:47:20 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> Message-ID: <8F7985804milenkomoonshinecouk@194.73.73.116> >5 gets you 7 that you have added a > >from os import * > >to your script. > >Don't do that. > Thats exactly right, and is there any way i can access the os library then without everything going mad-whack. Cheers, Jack From anamax at earthlink.net Sun Jul 16 16:10:36 2000 From: anamax at earthlink.net (Andy Freeman) Date: Sun, 16 Jul 2000 20:10:36 GMT Subject: Funding vs Python Message-ID: <8kt4rj$d4n$1@nnrp1.deja.com> I was tired of hearing a friend talk about how wonderful Python is, so I decided to learn Python by using it to implement a product that the official implementation team thought would take experts 1-2 man years using numerous Java buzz-words. A month later, I'm still a Python newbie, but I'm close enough to done that I'm looking at the rev 2 feature list. (The experts are still trying to hire but are going to start any day because other folks like running code more than they like plans.) No good deed goes unpunished, so now I'm getting push back along the lines of "we can't get funded if it's in Python". (Somehow, I don't think that using Perl would have produced the same reaction.) I've seen the list of web projects at python.org, so I'm wondering if there are others or if there really are examples of companies that didn't get funded because they used Python. -andy Sent via Deja.com http://www.deja.com/ Before you buy. From johngrayson at home.com.bbs Sat Jul 15 14:30:04 2000 From: johngrayson at home.com.bbs (johngrayson at home.com.bbs) Date: 15 Jul 2000 18:30:04 GMT Subject: Tkinter? Message-ID: <3bPgJS$jrv@openbazaar.net> In article , "David L. Heald Jr." wrote: > I'm writing a script that will act as a GUI interface to another script, and > I want to have file browsing ability. How do I call this in Tkinter? I have > looked through 2 different books, and a couple of help files and have yet to > find anything. > > This is not really a Tkinter issue, since you can fire up a file browser window from a simple Python program. However, it may introduce some special problems if you're doing it from a GUI. Therefore, here is some sample code to illustrate how to do this for Windows and Solaris platforms. You would have to adjust for other platforms. Note that if you're doing this just for Unix, that you don't need to thread: you can just fire off the command in the background... from Tkinter import * from tkSimpleDialog import * import sys, os, thread class App: def __init__(self, master): self.master = master Label(master, text='Browsing:').pack(side=LEFT, padx=4, pady=15) self.entry = StringVar() Entry(master, width=50, bg='gray', textvariable=self.entry, state=DISABLED).pack(side=LEFT, padx=15, pady=15) Button(master, text='Browse...', command=self.browse).pack(side=BOTTOM) def browse(self): path = askstring("Browse", "Enter directory") self.entry.set(path) browser = Browse(folder=path) class Browse: def __init__(self, folder='.'): if sys.platform == 'win32': cmd = 'Explorer %s' % folder else: cmd = 'dtfile -folder %s' % folder thread.start_new_thread(self.doIt, (cmd,)) def doIt(self, where): os.system(where) root = Tk() display = App(root) root.mainloop() Hope this helps to get you started. BTW: Chapter 18 of Python and Tkinter Programming covers handling asynchronous events and things that block the mainloop... John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From bjorn at roguewave.com Mon Jul 17 20:03:58 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 17 Jul 2000 18:03:58 -0600 Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735013.1AE68176@roguewave.com> <39735D6E.8E3349D9@roguewave.com> Message-ID: <39739EEE.D53D9601@roguewave.com> Huaiyu Zhu wrote: [snip] > The morale of the arguement is: requiring every syntax to be useful in every > domain is too extreme and not quite useful. But considering exactly what > the domain is and exactly how it might be used may help. I think you hit the crux of the problem. You want to add syntax that is only useful in one domain, and that is too extreme. Why don't you create a preprocessor that converts a .* b into elementWiseMultiply(a,b) and create an appropriate suffix for your matlab/python files (mpy?) It's a pretty easy thing to do, and sounds much more appropriate in this situation. -- bjorn From blinocac1 at home.com.bbs Thu Jul 13 14:10:03 2000 From: blinocac1 at home.com.bbs (blinocac1 at home.com.bbs) Date: 13 Jul 2000 18:10:03 GMT Subject: Compiling Python Message-ID: <3bOEgR$lvu@openbazaar.net> Well I found a P2C translator, but I've yet to test it. If it works I'll post the url. "Nicholas Cloy" wrote in message news:Bj4b5.889$O47.17397 at news6-win.server.ntlworld.com... > I downloaded the installer at > http://www.faqts.com/knowledge-base/view.phtml/aid/3111/fid/244/lang/ but > the program executes in a msdos window, is there anyway to compile a python > script into an file ythat will run in a windows 98 gui? > > -- > _________ > > Nick at ex-inferis.freeserve.co.uk > Icq no 69088298 > _________________________ > "Ahmed Ahmed" wrote in message > news:20000711054522.28720.qmail at web3406.mail.yahoo.com... > > Look here > > http://www.faqts.com/knowledge-base/view.phtml/aid/3111/fid/244/lang/ > > > > --- "David L. Heald Jr." wrote: > > > Yeah, the latter. I like Python, but I'm interested > > > in taking my programs > > > with me to other computers that don't have python. > > > "Dennis Lee Bieber" wrote in > > > message > > > news:9m5lms0bt9fhiir6c2vju9ti4hvvv473kb at 4ax.com... > > > > On Mon, 10 Jul 2000 21:29:09 GMT, "David L. Heald > > > Jr." > > > > declaimed the following in > > > comp.lang.python: > > > > > > > > > Does anyone know if there is a compiler > > > available anywhere for python > > > for > > > > > win32? > > > > > > > > > Pardon? > > > > > > > > A compiler with which to build Python from source, > > > or > > > > > > > > A compiler which builds native executables from > > > Python programs? > > > > > > > > > > > > For the latter, I don't think one exists on any > > > platform -- > > > > freeze may be the closest equivalent (as I recall, > > > not having used it, > > > > it embeds Python byte-code into a binary with the > > > Python interpreter). > > > > > > > > For the former... I think folks are working on > > > getting the > > > > downloadable Borland C to compile it, the M$ VC > > > should handle it with no > > > > problems, and gcc probably can manage it. > > > From johngrayson at home.com Thu Jul 20 08:35:42 2000 From: johngrayson at home.com (John Grayson) Date: Thu, 20 Jul 2000 12:35:42 GMT Subject: 2 tkinter questions References: <3976B061.617CACB0@structurex.net> Message-ID: <8l6rmt$h1a$1@nnrp1.deja.com> In article <3976B061.617CACB0 at structurex.net>, walter hanagriff wrote: One answer: You *are* using Tkinter variables, aren't you? def power(self, frame): self.ivar1 = StringVar() self.ivar2 = StringVar() entry1 = Entry(frame, width = 10, textvariable = self.ivar1) entry1.pack() entry2 = Entry(frame, width = 10, textvariable = self.ivar2) entry2.pack() iv1 = ivar1.get() ; iv2 = ivar2.get() Sent via Deja.com http://www.deja.com/ Before you buy. From akuchlin at mems-exchange.org Mon Jul 31 13:27:12 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 31 Jul 2000 13:27:12 -0400 Subject: [3rd Draft] Open Letter to CNRI: Request for clarification References: <39816303.C808D05A@nowonder.de> <39852224.FE658DC5@nowonder.de> <398763f2.270509351@news.online.no> Message-ID: <3du2d6gqhb.fsf@kronos.cnri.reston.va.us> thomas at cintra.no (Thomas Weholt) writes: > slows down the development-cycle of Python. The longer it takes for a > beta to get into users hands the longer it takes before bugs are found > and removed. Longer time to wait for a stable release of Python 2.0. > And I cannot get my hands on that sweet baby quick enough!! :-> Note that you can still grab a copy of the current CVS tree and try it out, if you're that enthusiastic about it. Playing with the CVS version is valuable because any errors you find can be corrected without hundreds of people finding them in an official beta, which causes a certain proportion of duplicated or unhelpfully vague reports. --amk From jlecomte at ifrance.com Wed Jul 19 09:12:21 2000 From: jlecomte at ifrance.com (=?iso-8859-1?Q?J=E9r=F4me_Lecomte?=) Date: Wed, 19 Jul 2000 14:12:21 +0100 Subject: Python et Question sur Linux References: <8l43gh$j3u$1@broadway.news.is-europe.net> Message-ID: <8l4671$n5t$1@broadway.news.is-europe.net> I am confused. The message ended up in the wrong box by mistake. Boy, I'm glad there was nothing personal or bad (or both) there ! Accept my appologies :-) J?r?me. "J?r?me Lecomte" wrote in message news:8l43gh$j3u$1 at broadway.news.is-europe.net... > Salut, > > J'ai commenc? ? regarder Python. Ca a l'air vraiment bien (plus facile > et plus clair que Perl et mieux int?gr? avec le reste du monde que > tout ce que j'ai vu jusqu'a pr?sent). Tu connais ? > > Mon fr?re envisage d'installer Linux sur son PC (266Mhz) pour > programmer. Il faut compter combien de DD pour ?tre confortable. 500Mo > peut faire l'affaire, ou il faut 1Go min. > > J?r?me. > From m.faassen at vet.uu.nl Mon Jul 10 11:43:12 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 10 Jul 2000 15:43:12 GMT Subject: POOP / Python (Object Oriented Persistence) ? References: <002001bfea62$21eabdf0$f0c809c0@lslp7o.lsl.co.uk> Message-ID: <8kcqug$p32$1@newshost.accu.uu.nl> "Tony J Ibbs (Tibs)" wrote: > Martijn Faassen explained that Zope does indeed do most of the things I'd > mentioned, and then: >> > persistence over LARGE networks, etc. >> >> What would this mean? > One of the interests of the people in Glasgow is how one copes with data > that may be distributed over many computers. This includes issues such as > how do you fallback to another copy of the data, how do you decide > whether/when to cache locally, and if so when to update, etc. Zope's ZEO is going into this area. I haven't looked at it myself, but basically you can cluster several copies of the ZODB together. In the case of ZEO there's the case of a single point of failure (the central front-end machine), however. But ZEO is definitely very cool. Not a lot of code either from what I've seen. > Since they > also store the program code in the store, this also means sharing software > over the network as well. Right, I don't think ZEO has looked into this yet. You'd have to have your Zope products (or in case of raw use of the ZODB, python classes) installed on all servers for it to work. Since Zope is fairly componentized and part of a Zope Web App tends to be in DTML and is in the ZODB already (with more Python moving into the ZODB too), this doesn't seem to be a large project just yet. > In todays emphasis on shared services over the > net, a lot of this begins to sound remarkably prescient. Definitely! When did this research take place? > It's often regarded as one of those "we'll worry about that later" problems, > since people expect to be working on a local store, but thinking about it > earlier can have interesting insights into what one should be *doing* > locally (and as soon as one has two users on two systems sharing stuff, the > slippery slope has started). But it did seem to be a *difficult* problem, > conceptually as well as practically. Agreed that it's important, agreed that it's difficult. Luckily Zope has Jim Fulton. :) Again, ZEO is a remarkably small amount of code. > But I *know* I don't understand the field, so I'll shut up straight away > about it... I don't understand the field either, so let's babble on. Perhaps we'll learn something. :) >> Do you still think what the ZODB does is much >> different from what you're describing? > Erm, no, it sounds like I need to find some excuse to find out more about > Zope, instead! (damn, another worthwhile thing to learn about). This article by Andrew Kuchling may be interesting, if you're just interested in the ZODB and ZEO by itself: http://starship.python.net/crew/amk/python/writing/zodb-zeo.html Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From hzhu at localhost.localdomain Thu Jul 13 17:23:28 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 13 Jul 2000 21:23:28 GMT Subject: Discussion: Introducing new operators for matrix computation References: <396E160D.272C0C34@roguewave.com> Message-ID: On Thu, 13 Jul 2000 13:18:37 -0600, Bjorn Pettersen wrote: >It seems like you're trying to create a special purpose language here. >Ie. I don't see it as general enough to be worth putting into the core >unless you can come up with other use cases... Personally, I would much >prefer the ability to overload the relational operators (individually, >not through __cmp__). This is not a call for a special language for matrix only. But we do need enough binary operators to override with. The additional operators might be useful at other places as well. In matlab the following operations are all different from each other a+b a.+b a-b a.-b a*b a.*b a/b a./b a\b a.\b a^b a.^b What python operators can we override for them all? Just one additional symbol for so many new binary operators is a good bargain, IMO. I think cleanness is one of the main virtue of python, but it is lacking in numerical computation. To give an example of the difference it makes, I'll quote from my original post asking for matrix in python (with corrections) [in octave we write] > b = X\y # LMS solution of a linear equation y = X*b > b = (X'*X)\(X'*y) # or written out in more details > b = inv(X'*X)*(X'*y) # or in a less efficient form. > > but the corresponding Python notation is horrendous: > > b = matrixmultiply(inverse(matrixmultiply(transpose(X), X)), > (matrixmultiply(transpose(X), y[:,NewAxis]))) Doesn't this look like the other p language or lisp? Well, my original post missed two parentheses and two matrixmultiply's and nobody even noticed it. If one cannot even write X\y in one line, think about how to write a typical formula like B = inv(A) - A\U/(C+V/A*U)*V/A Huaiyu From wizard at eznet.net.bbs Mon Jul 17 21:10:01 2000 From: wizard at eznet.net.bbs (wizard at eznet.net.bbs) Date: 18 Jul 2000 01:10:01 GMT Subject: OT: RedHat 6.1 (was Re: newbie unimpressed...) Message-ID: <3bRVdR$kXm@openbazaar.net> In article <8l047h$6ag$1 at slb6.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article , Grant Edwards > wrote: >>In article <8kvqqb$8e5$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >>>In article <8kvp81$9q1$1 at nnrp1.deja.com>, >>>wrote: >>>> >>>>(I'm using python 1.5.1 on Redhat 5.2) >>> >>>I strongly recommend upgrading to Python 1.5.2. The documentation is >>>much better, for starters. >> >>FWIW, RH 5.2 is getting a bit old also. I couldn't recommand >>6.[01], but 6.2 seems to be decent. > > What's wrong with 6.1? (We upgraded a few months back, mainly to get > 1.5.2, and I'd like to know if there's a serious reason we should move > to 6.2.) I don't know if you would consider this serious or not; but 6.2 as a whole is a vast improvement over 6.1. Well maybe not vast but it certainly is the best bug fix release that I've seen. The only unfortunate thing is that you have to be careful with the Kernel Updates. > -- > --- Aahz (Copyright 2000 by aahz at netcom.com) > > Androgynous poly kinky vanilla queer het <*> > http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 > > Q: In a lesbian relationship, who decides who gets to be the man? A: > It's two women. There is no man. That's the point. From thantos at chancel.org Mon Jul 24 22:55:59 2000 From: thantos at chancel.org (Alexander Williams) Date: Tue, 25 Jul 2000 02:55:59 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: Well, if I'm feeling Haskellish (and I am), I might suggest `op` as a generalized method of converting a function from prefix op(x,y) to "x `op` y". This begs the question of what to do with multi-argument functions since Python doesn't support currying to the degree Haskell does. Still, for binary functions (/any/ binary functions), it works as well as any of the current proposals and is easily generalizable. That is: Assuming you have instance x of class X, possessing method mult, you can do "x2 `x.mult` y" and it converts logically to "x.mult(x2,y)". Yes, its syntactic sugar, but it's keen anyway. (Am I the only one that thinks the question of how to impliment Matrix stuff is, at heart, goofy, and stems from some mathematicians being too lazy to do it the OO way, which would be to give the Matrix class an eMult method to do element-wise multiplication and which checks the type its given to make sure its sensical before returning an instance of Matrix with the proper values? Yes, the syntax looks like: >>> mRes = m1.eMult(m2) ... but its syntactically clean, doesn't require any jibber-jabber with the core interpreter, and works. Could Python make use of type dispatch mechanisms? Probably, bjut get the Types-SIG to produce a typeful proposal for Python before you leap on it. I'd rather have real function currying supported internally than type dispatch. Could I make use of the ability to make any sequence of characters into an infix operator? Probably, but its a lot less important than other things to me.) -- Alexander Williams (thantos at gw.total-web.net) | In the End, "I think sex is better than logic, | Oblivion but I can't prove it." | Always http://www.chancel.org | Wins From olczyk at interaccess.com Mon Jul 10 13:49:41 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Mon, 10 Jul 2000 17:49:41 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395E05CD.E38F642C@webamused.com> <396b3f42.316716812@nntp.interaccess.com> Message-ID: <396c0bf6.369120718@nntp.interaccess.com> On Mon, 10 Jul 2000 05:22:56 GMT, "Stephen Hansen" wrote: >BTW, i'm sorry if i'm oversnipping, but i'm only commenting to a certain >portion of this... > >Your example is invalid because they still kept the same script and just >redesigned it a bit... Uhm. No. The original was a serious story about the difficulties a robot cop had integrating into a human police force. The rewritten was a comdey. Charaters were renamed some were added some were changed. Descriptions were changed. Plot elements were removed others were added. In other words the two were as similar as "Romeo and Juliet" and "West Side Story". > >If Microsoft took Java code, named it Mocha, and altered the API's and a few >other ways that it worked, Sun would win a suit. If Microsoft took the >CONCEPT of the Language, and made their /entire own language/ around the >/idea/ of it, then they havn't /copied/ anything. You can't copyright a >'concept' or an 'idea'. You can copyright your perticular application of >said idea or concept. Class A moron. Read some verdicts and get a clue. Yes you can. From Norman_Shelley-RRDN60 at email.sps.mot.com Fri Jul 14 10:50:09 2000 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Fri, 14 Jul 2000 07:50:09 -0700 Subject: Forum: comp.lang.python >> Thread: Memory leak: assigning function object to instance variable >> Message 1 of 18 Save this thread back to search results Subject: Re: Memory leak: assigning function ?Neil Schemenauer's GC patch in python1.6? Message-ID: <396F28A1.A181BF39@email.sps.mot.com> Is Neil Schemenauer's GC patch scheduled to be in python1.6? I'm currently getting hit with huge memory leaks probably due to circular references. Even after going through and removing the most obvious ones it has helped only a little. Having to design programs and algorithms with reference counting in mind is just as bad as having to remember to remember to use free() when in C or C++. Python must be better than it currently is in order to sell it to others who have not yet seen the light. From medved55 at greenbay.usa.com Wed Jul 26 23:30:32 2000 From: medved55 at greenbay.usa.com (Alex) Date: Thu, 27 Jul 2000 03:30:32 GMT Subject: Beginning Message-ID: <8loacq$n81$1@nnrp1.deja.com> hi everybody! I just begin to study programming and one friend of mine advised to me to start with the Python language. I find it interesting. If anybody know good Internet links to Python sources, please send it here. Also any good advice for beginner will be appreciated. If you a beginner and would like to exchange ideas and experience about programming on Python e-mail me medved55 at greenbay.usa.com. Profy welcome too. Thank you. Alex Sent via Deja.com http://www.deja.com/ Before you buy. From tsmets at altern.org Thu Jul 27 19:39:34 2000 From: tsmets at altern.org (Thomas SMETS) Date: Thu, 27 Jul 2000 23:39:34 GMT Subject: inserting integer in Table References: <397CEEA4.7683A17@altern.org> Message-ID: <3980E1B9.30D49461@altern.org> Well Roland, didn't work at my place ... I reCREATED a similar table with a column defined as int4 & bearing the name pk. tsmets=> create table TESTPYTHON tsmets-> ( pk integer, filename varchar(99), file bytea ); I couldn't insert a simple integer with you command : i = 0 conn.query("insert into TESTPYTHON pk values ( %s );" % i) Exception thrown is : Traceback (innermost last): File "insertBlobs.py", line 15, in ? conn.query("insert into TESTPYTHON (pk) values ( %s );" % i) pg.error: ERROR: Relation 'testpython' does not have attribute 'pk' Shouldn't I use %i or something like that instead of %s ? Tx, Thomas, ================================ Thomas SMETS wrote: > > In PostgreSQL table is : > > test=> \d test_blob_s; > Table = test_blob_s > +----------------------------------+----------------------------------+-------+ > | Field | Type | > Length| > +----------------------------------+----------------------------------+-------+ > | filenumber | int4 > | 4 | > | filename | varchar() > | 100 | > | filecontent | oid > | 4 | > +----------------------------------+----------------------------------+-------+ > test=> > > > Now I'm willing to insert in that table rows like this one : > , , . > > Here's is the (not-so-running) code : > > > # > # > # ############################################ > import os, glob > from pg import DB > > conn=DB('test') > conn.query("BEGIN WORK;") > > i = 0 > for name in glob.glob("*.jpg"): > print "Name is ", name, > try: > conn.query("insert into test_blob_s filenumber values (" + i + > ")") > print " inserted" > except TypeError,e: > print '\nerror ', e, 'undefined' > # conn.query( "update test_blob_s set filename = '" + name + "')") > # conn.query( "update test_blob_s set filecontent = '" + > lo_import(name) + "')") > > i = i + 1 > > conn.query(" COMMIT WORK;"); > > > > of course I can't have it passing the insert of "i" > Could some one help ? > > Thomas, > > -- > > Thomas SMETS Phone : +32 (0)2 742. 05. 94. > Av. de la Braban?onne 133 / 3 e-mail : tsmets @altern.org > 1030 Bruxelles > > ==== Quote of the day ========= > You shouldn't wallow in self-pity. But it's OK to put your feet in it > and swish them around a little. > -- Guindon > ======= End of Quote ========= -- Thomas SMETS Phone : +32 (0)2 742. 05. 94. Av. de la Braban?onne 133 / 3 e-mail : tsmets @altern.org 1030 Bruxelles ==== Quote of the day ========= Your true value depends entirely on what you are compared with. ======= End of Quote ========= From see at my.signature Tue Jul 25 01:00:49 2000 From: see at my.signature (Greg Ewing) Date: Tue, 25 Jul 2000 17:00:49 +1200 Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> <3L%e5.9930$r4.5151@news.indigo.ie> Message-ID: <397D1F01.214C4F52@my.signature> Gerry Quinn wrote: > > Even 10 iterations would be only 5 minutes. A bug that took that many > iterations to kill would require much more than 5 minutes thought. You're completely missing the point. It's not the number of iterations required to *fix* the bug, it's the number of iterations required to *find* the bug. The ability to watch your program execute is an extremely powerful way to track down the causes of bugs. You know what the program is supposed to do; the program is actually doing something different. If you can watch the program execute step by step, it becomes instantly obvious where they diverge. Usually it's also instantly obvious what has to be done to fix it, since often it's just some simple oversight. So, with most bugs, the actual amount of thought required to diagnose and fix it is very small, provided you have access to all the required information. In a system which has a 30 second turnaround, getting hold of that information can be a very drawn-out and frustrating experience. Some bugs, of course, are much more subtle, and require a lot more thought. But even then, the more information you have about what is going on inside your program, and the easier it is to get that information, the better. -- 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.husmann at teleatlas.com Mon Jul 3 10:17:35 2000 From: michael.husmann at teleatlas.com (Michael Husmann) Date: Mon, 03 Jul 2000 16:17:35 +0200 Subject: extracting tuples from a list Message-ID: <3960A07F.7240F23B@teleatlas.com> Is there a simple way to extract two elements from a list that has a size of 2n? I going this way: while list: i, k = list.pop(0), list.pop(0) Is there a better solution? Thanks Michael -- Michael Husmann p.A. Tele Atlas Deutschland GmbH, Postfach 77 77 77, D-31132 Hildesheim PHONE: +(49) 5121 49 4876, FAX: +(49) 5121 49 2866 e-mail: Michael.Husmann at teleatlas.com From ingo.adler at synacon.ch.bbs Sat Jul 15 19:30:03 2000 From: ingo.adler at synacon.ch.bbs (ingo.adler at synacon.ch.bbs) Date: 15 Jul 2000 23:30:03 GMT Subject: Memory leaks Message-ID: <3bQ2AR$mzh@openbazaar.net> This is a multi-part message in MIME format. --------------551E50A81E22A2D9D6B82AD8 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Gordon, I can provide the sample project for MSDev, if I may. I would send it directly to you. Ingo. Gordon McMillan wrote: > ioadler at my-deja.com wrote in <8klffg$ql5$1 at nnrp2.deja.com>: > > >In article <8F6667253gmcmhypernetcom at 199.171.54.154>, > > gmcm at hypernet.com (Gordon McMillan) wrote: > >> Ingo Adler wrote: > >> > >> [strange leaks in SWIG'd code] > [snip] > >> Doing things in the "obvious" way from your (snipped) incomplete code, > >> I get no leak when using MSVC 5. > > >Finally, I reproduced the leaks under the control of "Code Guard", which > >can list them. > > [snip trace and code snippets] > > Not only did my experiment not leak, but I can't match up your SWIG > snippets with anything in my SWIG generated code. I'm running SWIG1.1p5 (as > of a few weeks ago, the latest stable release). > > So maybe you're running a buggy SWIG. Or maybe I could ship you what I > tried, and you can look for differences. I can't debug from your > description (nor have I the time to do so), but I can assure you that what > you're trying to do doesn't have to leak. > > - Gordon --------------551E50A81E22A2D9D6B82AD8 Content-Type: text/x-vcard; charset=us-ascii; name="ingo.adler.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Ingo Adler Content-Disposition: attachment; filename="ingo.adler.vcf" begin:vcard n:Adler;Ingo tel;cell:+41-79-3786792 tel;fax:+41-41-7103244 tel;home:+41-41-7103268 tel;work:+41-41-8111500 x-mozilla-html:FALSE url:www.synacon.ch org:Synacon GmbH adr:;;Rubiswilstrasse 7;Ibach;SZ;6438;Schwitzerland version:2.1 email;internet:ingo.adler at synacon.ch fn:Ingo Adler end:vcard --------------551E50A81E22A2D9D6B82AD8-- From grey at despair.rpglink.com Thu Jul 27 12:03:53 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 16:03:53 GMT Subject: Python luddites (was Re: Type inference now simplicity) References: <8lktiq$rgv$14$1@news.t-online.com> <397F5410.6D9D317A@uab.edu> <20000727104408.A10021@inkontact.com.au> Message-ID: On Thu, 27 Jul 2000 10:44:08 +1000, Steve Purcell wrote: >I love the fact that Perl folks rant about features 'missing' in Python only >to find that the exact same functionality is available in a nicely packaged >form in a standard module (e.g., 're'). This is the Python aesthetic, and I >love it. Exactly? Are you sure that is the right word esp. with the example given? ;) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From hei at adtranzsig.de.bbs Mon Jul 17 05:40:05 2000 From: hei at adtranzsig.de.bbs (hei at adtranzsig.de.bbs) Date: 17 Jul 2000 09:40:05 GMT Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME Message-ID: <3bR7T6$kGA@openbazaar.net> There's also some thing called Visual or Visual Python by David Scherer. See the edu-sig archives for details. Call it "optisches Python", that's german and surely not trademarked. (When we germans seek a product name, we always come up with an english one because that's modern so we wouldn't ever trademark anything that contains a word in our native language. So you're secured.) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Paul Prescod" schrieb im Newsbeitrag news:3971F055.68CD6897 at prescod.net... > Phil Thompson wrote: > > > > ... > > > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. > > Be careful. When I worked at Watcom we tried to make "Visual REXX" to > hear that some other company (not Microsoft, but obviously related to > Microsoft) had a trademark on Visual X where X is a programming > language. Microsoft licenses the name and other people are supposed to > also. From robin at jessikat.fsnet.co.uk Thu Jul 27 14:32:39 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 27 Jul 2000 19:32:39 +0100 Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> <39807595.D6F543E9@netscape.net.remove> Message-ID: In article <39807595.D6F543E9 at netscape.net.remove>, Brian Steele writes >Steve Lamb wrote: >> >[snip] >> *mutters something about lawyers, marketing people and a tank full of >> sharks.* >[snip] > >What good would that do? Sharks, snakes, etc. won't bite lawyers out of >professional courtesy, and since marketers are really of no substance >anyway, it would be like feeding the sharks tofu. The difference between eels and lawyers is that one is a slimy creature you wouldn't want your sister to marry; I forget what you're supposed to say about the fish. -Expecting a barrage of torts-ly yrs- Robin Becker From dsavitsk at e-coli.net Sun Jul 30 22:48:41 2000 From: dsavitsk at e-coli.net (d. savitsky) Date: Mon, 31 Jul 2000 02:48:41 GMT Subject: Windows DDE Server via Python References: Message-ID: thanks. i think a fair amount of reading and bugging the maker of the server is in my future. doug "Penfold" wrote in message news:Fd3h5.3600$_8.423190 at nnrp3.clara.net... > This is fairly easy using the dde module that comes with Mark Hammonds ever > invaluable win32all distribution. > [http://starship.python.net/crew/mhammond/]. > > Once you've grabbed it look at files in the win32/demos/dde subdirectory of > your Python directory. You'll see connecting > as a DDE client is a piece of cake. > > I'm not sure how warm/hot DDE links can be implementing using it but static > requests and Execs are no problem. > > Des. > [cosi@*REMOVESPAM*operamail.com] > > d. savitsky wrote in message > news:V5Qg5.89374$dF.3137888 at news1.rdc1.il.home.com... > > has anybody ever connected to a Windows DDE Server via Python? is it > > something i should do or not? > > > > i have a .dll that does it for me and i just use windll (god bless Sam > > Rushing), but the dll is written badly (i.e. it crashes often from python, > > vb, c++, anything really, and doesn't give much in the way of error > > messages) so i thought i might skip the middle man - although it could be > > the server itself that sucks ... > > > > thanks for any suggestions, > > > > doug > > > > > > From thiele at muc.das-werk.de Tue Jul 11 13:58:22 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Tue, 11 Jul 2000 19:58:22 +0200 Subject: checking the existence of a fiel References: <8kfl5m$skq$1@nnrp1.deja.com> Message-ID: <396B603E.EE48DC85@muc.das-werk.de> > > > os.path.isfile() > > os.path.isfile() and not os.path.isdir() or not? From mikael.lyngvig at toolwood.dk Sun Jul 23 21:11:23 2000 From: mikael.lyngvig at toolwood.dk (Mikael Lyngvig) Date: Mon, 24 Jul 2000 03:11:23 +0200 Subject: Win32 : Making script.py executable in DOS box - PythonLauncher.exe (1/1) References: <8jmjfe$64o$1@nnrp1.deja.com> Message-ID: begin 644 PythonLauncher.exe M35J0``,````$````__\``+@`````````0``````````````````````````` M````````````````````T`````X?N at X`M`G-(;@!3,TA5&AIP1``````` M````X``/`0L!!@``,````!````!0```0C````&````"0`````$```!`````" M```$``````````0``````````*`````$`````````P``````$```$``````0 M```0````````$````````````````)```'0````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M````````55!8,```````4````!``````````!```````````````````@``` MX%506#$``````#````!@````+@````0``````````````````$```.!54%@R M```````0````D`````(````R``````````````````!```#````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M````````````````````````````````"@`D26YF;SH at 5&AI"YT7)I9VAT("A#*2`Q M.3DV+3(P,#`@=&AE(%506"!496%M+B!!;&P at 4FEG:'1S(%)EXM\)!0B=%!0 M_W0D'#/V>7[[AYG)=SM,)!!V`V=>B\9?7KO!NM8Q(B@,`Q at N"1?76OMO*0R% MP'4%OND#U"0CX?^_M5U367T(X(;K#)O_`K()>W]J`5O&`")WP at RS#:S]]H7;M70KOTA112:3LYW[)(O1 M$>7*3^+*!K=]MUXD6UV,46,4D%??+OS=BS"!/L=9B_B+31Y]_"&-'+&*VW?M M_P\Z30R(30MT#(3)E\DAB\?K'0=T]NVS_QD[^'85@"<`4#2)`XHD1H/#!#7> M[;;;1REUR$_\&`J(75E?B3"[^_WY;LFX2!$`Z0L\=&@D4O8L%[X="K=S at V7\ M`.7 at _;Z^\-L]_U#Z5O^1`+I"$(/+_YTMN]]S#X4#`@`DV/I0*U9\=@>W?LD& M9![D`<#WF\&Z at 4"('L6^ [B'5R5G-I&PK$M;]P"_I-_&_\B82-X/L\UQ8V MFV@:&`E?>9;=NPE0:CM780%K%&-[]VVA at 3F`!0`/@XH,(47X.2W]C1=[#X9% MF3)W\,=%]#!@A'S\K87A\(O+C97HG3CCX`C"^MEGK,'W1HQGZ,MQ+H0-YPZU M]KY[#[X-%,H[P70NOP@>+7B%29A,_/K[-(`=6DCZ32`N%CLV&Q\TOQ!B*S:+ MM13173$ND('LM<]?686VFPUM4"N+!SAU9X-%!"BXRQ<]]#Q at 0(S>('+=AK?6 MB@(6\`0[1(+$$KAVZOBFZD<[PP^$R at H]5`J.?"//N.JF%>LU`=:T&6GLGKCD M'.EK0SX,X0;Y3@"X]LLEA!M_\`!\G8%++K1&DZ"]Z@`#2D::^#SX"H25;';T M8OD<&60N2#G_\(.A.8)C!(MB'_^X*9Q+]@#(^)OD9)RPTM!R/N[JR/A"&+;L M)R02LXGD1DVT4@A+9L,C at _@!JHZ&K`R'8&W[@\$$2(D&B1QK M7@<75LBX[B[0^27:LV*O=W=[WEE_[<`Z^!A9;,M!@R;6[2&$!*3_30@^=8Y8GBT$ MVNW!)T<(:AK6F_L-G$E1JFKU_Q4$4#$&8/8?;#`#7UU]5U96:@,"_6?KX`%6 M?B0;$/@[_G065W"V_[,,#/!73O?>&_9&#@B9;KM[M&:#[%1EK$P@:\W!NPGP M4`WX`$H#\('I7&\:',B#L]V:*-H::L5U\!08;43&-@@,"Q2=-8CR6&WP!_=4XM="/-3Y!$,K0W^]K]9P$Z=1N+0(7V=!!J`A'XTF8# MK1!S@&:Q0T/K"MNW=V",:@.`(`!`#`"`.['#O_0&P[[_X==T98H(3='V@@%H MY>V_;6X$(T#K&H#Y+W0/!%QT"A)W_.TN=0LD_.L&C4@!!T"`.$^EA<[$SPTX MA1LJV*UM+/P0`'0?*_L:1QUZ[6]@+9!8,)NM1Q]0>A4*'%M,,/DNJN+#=FB@[%7(9R`@7!U<;GK.1 MJ5DS(AWI'3G/N"5KPQLS)%"@$J)"KHM-"^L1!0U,CO\NEG at 1ASI?3LS,C4+_ M6\.-[5O;W*0D1'!D!BJ*1"0(M\W`;>'8P>`05`GWPI"W^%D7_Q.*"D(XV731 M4U$2=>T+V/_ZM]_MP\'C$%8(BPJ___[^?D`SRP/P^ANMI0-M\0Q.,\\SQH/" MS^^7V+_A<`&!=1PE!G33`;^U'VZ&@>83=<1>B'3#BT+\..G^O_#8=#:$/^\X MW'0GA.1TY\'H$!(5GK6;IMP&U.N6+;%"_MK/2>S$+A-;QF%!HL#X,]P$;#K>$-Y38U*$=7H.QV;[0[ MW#DU,`QT638 at .32ZFS554!U61HM<.\-#DR[-=#X1=@;OO]UB;"]0#CN-=A<0 M@#PX/75IY!>-#V'''_IT at G"TOWW&!.O3&XU$.`'K`NP=UM!X9GD`43T_>4RX MQWXW\'(4@<,;3BT0A0$7<^RCM?#V*\B+Q`R+X8N-0$!3W.[@TLEH,(!H##D$ M9*$-;;T_MU!DB24'%1"CB;C2-]MEZ.$T,]**U(GQO`TB%0K'@H7#73C;=PW! MX0@#R at H08J,,NLQ#P0<:,7^J'-ON5;K]#`$))F--,&,_0C>C"&GZ)3&C\&,) M(J\?;K[D!"L3":$CHRQDX6:#V=PU(`8%'`0!VNJ6ODO%Y%`G-B+LR0E7*!M> MX>!049@@I_JP%;J%;W7@'D>2^%L",>W=+-P-*>#_R00J&6B\AM at 0YLI08"\D M6263.@$W.*PC&"9:PY=V'0XLK%D[-=3OB1!LERJ7CFH!SCOS"5:Z_=_]TKA@ M6CDP='*#P#!"/5!A#'SQ`Y?97G[H4%9.//P(7>'";B0I:D"]6;][$GUA^&.M MZ*=0\ZNJB1T$'*8$JHV><)&W=OL//\MT+(I1`49T)3Z% MMOKV[?X;9W<4BU7\BI)8(`B01D`34HZ6_G;U04&`.934]-/;4%G#EQLYTA1T:$( MV2SVPT`]57+Q5CDL5*R]5F"N^@O"36_#6VVK`&0Y'?R>=`XP`@ZZOJD$TGX# MA12KX;TUBUT$@R4A5?Z/&^&36TO\8_\E1&K]%*6ED0M`_%.AG[N.#7MZ&4DM MI(IT(K#5ML&#Z$\7!`WS2,[6[BI^3+@$!!8%$@.%Y]D+"!%7;`LC!!L$;*JT M%Z/\@-][Q=S#7\/5%`7`>(X/@^Q6T2(*4.'W8Q8TP+Z'B(0,7=]_P7*"QG+T MBD7RQH4-(+,WT7;C!AN-56"V"@+`=H]=NC5W' MNZI"0HJK4NO6U31UT,6*QHO9:V;L=(UZEM@&$Y\Y5MU0+;LCS2;[SOT=5AY6 M--0K&=DC*VS\:``-+07,6R>=7&J-G]#B?W)FBQ'VP@%[^A"*E/+6Q;\%9(B0 M`&?Q'!H"=!`TWKMS(%OKXX"@'($-$VYH/`"_ZTD5)4%_6&,'J_A:JDO(@,$@ MB).7M[&(21\=87(3>G<.BV[8FR#I(.O at 3$J^AOSZLX"?Q'42:OV1DUFS'8)L M=\2@'NR.P>VA<8D"=1'<#%<;E#:[W4>BH\+UJ13HBT'\*S+1A&$'Y"2IGW&IV?Y:__YT`NO-C3E5*\'#"?Y` MD$DF_?PP'('7"0@#S!&:`PX.&<['"#'*NG7AV=524UD2:QE-!&0"OC0QU(;L2L6AH?P.K4/(Y=@,6W<@4(/*'('X/$*R[+,_I MP,I9&=Q7?B-`355"JC M$,.!^;P'$K/-)&P'RC$(=@HQ&_BQGQ:AT&9]`O_0:!!B:`CR%3YP!-CQ'@X` M-!>%&"".`>19/D=X$%@,`>!PWR97#U\Y/4A=W?LZVBM,[P;JJ7@^X$#/G^*P M:!B4%&TL^2YB:"`0'#);G42L,U5ZB89<7T6RW0EH.ZIS#5>>@1O-XE&#-82E M,;IO)Q[I':VG!.!W(A($E1S]>$E[%CEC:V8&GH,3,/S>MU<]NY>%I&)W"U8: M&$\<4F\+#9<#"UYC#X/F=*U%+J''6#@19.,/?5!H,0^4P%`%`"Z^1F^C)4!V MN]GJ<.:P#S9<;1W#TRW,T0^F4#>X=K;7;74!NB6P80:T+F:6"^ZCK`?NI&80 M/6#L4M^A&(W[H;@'B.Z;EECGX/B\Z^%`W\BWK\:&9 M#?0J\(L,$_;!+\#_!17X=7_!^01J/TE?(3O/=JU6N+4#*$%,$]`#__2+;X)( M1/D@LD!W/!MF_@'BTAO+!"[M.Y MQ!(D!GD$4:$W,F/;?%6)"@0N7?BV]M]M#0B,B_O!_P1/@_\_>X9?W1+=UB^] MX9?L$:!"*_>/N1:5$:&)5?A)6CO*II_;6G=V!8GSRD$;^T`^.ZEV:\'Z=HN_ M=&LN0AD9L&U1OE&]NNI at D4L>TB%4$1YK"?FPO=(AE$Q2+&?;%K])ODH+!`@7 M%FJM$9$4[-4).?B"A0HSD8ET\+GN#5NR^2D+)HDO_;*5K0X%")=*8XI,!P1" MN]^@[[I-#_[!B`MS)>"RW;_;#T8.NXB+S]/K=@D9#3[VK53BL0D8ZRDD$(U/ MX(?@GL49)5D$#YV$$G_#8[<).(M41?")&HE<$U!;I,W""$CZH;#"IM]/O5DR MQJB+/610N0_[*]?M`T@,4H``2[I1_]S]X4,3 at V`$_MJFMXX1 at WAD=6Q3$'`,6B,A0/<2"1`X]`HE M8AR+%?(BDOY=Q!;+R"C at 3!'L48U(%%&WR\`'YC$X*Q0[FAARYP=U>8O:.]C=-A/R)A4%Z^89=5EV M;@G>)',1 at WN$"!,WZ^US]@YY)@T;+^X6YO8I!!M8>X7;$/9;XXE]'`=;$(D! MBT.H:H#6PCAL!QOU4]2V[I5'I12+%OK'[-+AK4HMBXR0MH"01(BULIT]-XL2 M+D80<]>_"N0$<68O^(SD+UW3IUJR%H&TK=*52LA"^LQ%^T6H\4KE:$R(1DI40A6<#:8+(5>ETW.(@K`>@3X`)6> MVUR;KWH(D(24-*E(K6TEP4(,I2+"=+,L`V0&_ at M]*3:W1:G$F3>($6*_NV27 MQK#.C`D["H\)?$-ZP&ZNZR\H#8U.MH]TL>\)>P2QO*T6ONX)-RU](UQJ=0N) M"HD#_.&WO77P`]$B`1(R_)_T^.VVBPXAC7D//G4:.QWRH!&I:]A+.Z0& MI%MTP6L1B=%"!`CA62)2`L:D5\`RW;I!774P7XE07;`8S*.P? MQW2(G,#4\!DN<0`@"!(=*L]VZ-1[[A<'GWWD, MBQ"I?,7D@`#%""=MOT6_'/^-EP!P3_IW/(U'=TAW-T1$*\GN.*1D-WE6JTG`N:>HA.0P7&^!:&"7@$NBS+:+): M`0=^:MBTB>?HQ-SE_YG=A8F_UXUP%RM1#.NUP>H/,'U**H2"3_Q).UQW5PU(^-&O`_2Q,7-HUV!DY9B3Y?7V*2 MGC`['U/X+#+)1S[3(5R0&2$-!A*GG)`^H9VEUVV1"%*)"&1_9JCV`D\KS@%[ M6ILG3+33JG`)?\END"QN1#'\#,B-'%J+;2;BRUL_"`5E698E3DM92UEED$F6 M65P3(;.MD9(3Y;BZ$;$KB=CK)2!*A+E&Z#!P%O407/RWLV3:.S)"A@$1C4:P M8VM+<4(0%/@^'_+)_?`C;1_U#XTZ45T,*5FCJS73K4LV7#.DLQ+HT'BZW!#K M=O8JA6'OUXJ%]W7\&Q at AL]BU;-)/1UIS'@"??`B;SG0&>0YU*"&-3B60A2%V M!I>1Y:%V>7=Q=W$(E;"V=8X##I?M>UAJ2^U989)E64M+7`]A85EF MY`8/XF%9Y[FD.4Z611=VVXD#2QC\\2$,L(F9=01D)A:#3C"& M:2:TQ<.":#11"QPMM2W8R`>XDG\L]/ZYR@*]!%%357PPWG?NNUI)P4Z+'7!0 M#@!J_U"@!_R[5T#3B^@[[W0^53FBV]969'XDL2\>55"N=A7;TC8A at 1Y73%U7 M6YL4-LZ/!(Q9*G6W7&V at N&M=6X0]Z_74L<)$CPXAZ%L)/C;:A"`#6!<*%:)0 MVP6T^P6X"@MM75>_W>DDY1`!@_:-,G4C3*.)W*$UM!EZ"SID^:[("[@OCATX M8ZH\!?)6=7N!6U]]%6!)*]$$M<@5:-UVR8,F`L8,X0(ST;:Y(S5$/8XSP/$, M&;`[X(/^<#V0$H&0GP'Y73V1A$H]DY\!^1F%-SV- at B0]Y/D9D(^&$3V2"H*# M]^**(X at 1.[GO8X5/"EE>ZPCZ41'`\/`.DN,T",7ZM/KP,`,&00Y$'7UH7T-WG9)7 at .-%;@2=,$;P0;YPR4Y'<1" M0Q6*T"4[5Q/1_Q?,\/Z*!CK#=!(\/70!1U9W at YLB7TH!Z^BTO02Q:`/%`CG% M\XE;1W2^4(K[5MC, M$BVF>">AHCB`5]W^)/XX&/6+^%A:]:.V at E,N(WU.M:5AOZ@$B-0:&-9_,&S2 MH0 at OI02&4+8MX+!6-?RT2%H at 33+19IRC7X*@ZT>P3!@3 at R&C$%NG&OM[Q[6+ M.R(W]/^WUH/'(12`.")U1(I0`4"`^B)T*84 at U1A1TH[E9.S?H@'B!HH0B!9& M0`O5M]$B=NO.##G%1D#;(F.W'.M#'@4$0$3N_BUYVO:#&1B('D9E('0)L41Y M:PD("77,.TBU6W6L8TIF_QT8`$[>]\02*.!D$"L%)V!F;*L5\1?(O-=N46#* MBP+'T-?B,W^+5H`X7'4$0)(L]A=N;"QU)4$Y?6T-@'@!(HWCT(H"MQV+PO\7 M#;;?V`PSTA at 8#Y3"B071/6__+L732_D.0XC&!EQ&L4MU\[YEJVN`ITK)&`J* M/[!N4VUT.FMT+B at 9X@@G3!@&'QL/0,*NS0T#%0%`."1I,+9R7QL/#C?'^"?O M:@8:CA0T^_=1H51E0HT%5]>[+0/<;!MJ-=NNX,-U!-6B9]IH#@MTOB$8`]AX M8RA8A!?[(\6961?J&P(G)JSC]:`.DC1###^W0C?;)\)F.1Z6ZT!`@=)G;P at 8 M=?D&\BO&+V)HC;;QT?B.0`)=`YR\@1M2-/_79^MT,E7#G`,HGR-34YHE at M0U MT"&^#@P0)[,U5:D-$5:>@',%X/;#ZU.)`G5OA;'V`DLG=#Q at B]<*0#A[25NA MW_L$]BND:E7./I7N8#SVZPNZ]3D'4L1$G0F:E0G7%E&F"[3461'RYN,5[J7#,` M_A+PU at 2!M&KV6"+#2/?8&\`H%*';C?58!*B35YUL`]979 at PE+F\;]<,^T`:` M3J]7F@!`2VS?2CF_U0(Z\-DCZUPCA.&9HPZOA9?@V30#X'O:'5MQ$TUT;!2 M##F2!:S at X.Z;BE&[4`\U"+8>,A0<=D.4:_7?V at U"6\)G[U9#,C!80S`PMPY] M8P,(^OS0K/=`"TZ48N2=F8FU9N!0/],(/FV)[[(A00L6\+H7B#-X/"53P.C"+6/=!!U6#%((-K:-R=:IWH\.CU4, MJ_&=ZSL(,!J+-(_KH;I`6:%W[!S)ZQ5<-#^A#2$V71:4O#N2W6ZUBRFM'%`# M&%`D-9$!Z.&A;U`-@'O7=P$J at SU48)EU(6C\/LZ at C@]ZH5AK6?C_'\:BPQ59 M?J2$50A$TU;W,\FX8$8[5`L&0?L+-8JSR/[QP>8#.Y8:2\/2< MQ!TCZR(@\IFM("P;F)<(\MQG(@%\6A1^*!M,4]844"V0;NWKW<<4H1TA'1;N M=1B#V4C-'_P(2)Z`-C:R+/S31"`82[.V'<4\(',N$B365O!8B^`(0+<@CVE[ M*:.A]!1LS`R3\"\5M]X;>B\1!W(/AZ\;::Z(3Q(OP)A&+ MFS7UUCAGW'1FZ=QA(8NY+EE7]$WL&J4-_H$XG&.)==@[]_N);5OB]D4-QT`^ M''BR3F)DL]O5?Q[:,H-^JHXZCR^-9<@\Q0'.0G\-$_Q"MK.D_+,VW(E=X&(% MDHP2I;+NE'7O?=]TM%9DY&=TG(_6H)5HLR0#)XRQ,<-M*&@@E-5POU#"T12/ M<58R3(`IB'&W'6!HZRWH5HU*7PU0U36QM.Q`:4DQ\PQ>9#`VM]LK'H/"3E`T MPY,C&*&`M*QN%()=GSZ-R5%>5IHXV496I:0$K1T&6<[X&U9)4Z#.PL>[*UP" M6*-#+23R.S#`=MQ7S!P\W`NA at Z$A at WB#I&=DGM>0,H?QTI]\;K+37\/W MQYY9>!]5$CI5BA%HFSOI.NYL&"[Z*K"YN)U,+HD78F.O]0S@!VZ+!G"+%CL: M`W#U!_!&J1[WPG`,!YV!WQJ0QCGK&('B_\<)#IX!B#0`0%-^+=K6 M_54*!.1?=?@3U(;ML'6%H_^"X`QB"69J48N1DX`/N5<0#Q-)0)`["R-+DXPL M&@YY/PT[+"]O!/[K"/WK`_QP7Q[LW0<9BA%!U&2(%T=B[NL%V2$GQ+,$`1%K M,TC3,.$$-"<29R>TL6K'.$AF",;!MF2E1W,,"(@'!JX:Z:&(90`/S/V,PN.C M!@1;(!(<#1S%$^2R0M]5*>2-P8O1`\:@,`FM_G8(._@/@JK#%-/_%MS!@^(# M4W(I\Z7_))5H0MAMT/AOQ[H<@^D$<@SKD,AVS:V\%X6`01Z->)`'_$$:FZYK MD`2\`^`CT3S6W/8W"(I&`8A'`04"5 at A9["1CR\;'7,R-22L\RS*V)0$"`J;R M=6>3D"-&(4<_C$W3=0=?!DP#1#PTU5_3-"PD'+]$CN1IFJ:[1H_D!^CH[.RF M:9JF\/#T]/AX-&":^/SNC3S[#F&+1_@)__"``S5*O*:,H!$P;YL-["UVD)T+ M^1$,"<$%HPT*(!SHPRN-=#%Q?\]N>\DD#?WC_'<`1/?)))RWV>^-L$./^>M^ MD<\K"$,LD!@+.`-W*VRF8&T#.F\#3EB&O25?3U:V2Q\@W^T2H^X"[P(IC$O" M6S:0)R2K+1G8>&4#KD5:^--TW85;M'^\`\3,1M at T3=3XLD4A?I!05V3 at K+AD>QX]C",<+*@IR'.P MX0`"C*)9;-%@%`/C5N$O-OAB%A1^'/@8Y$F6'!@RCA=RA_.X&_<]3K3=!-=B at DZ.@0ZRG:M0&/?C9IF MYL#KI;TQ,*4CR\D at G988".S&'"\/AGA!-.)^-4F*)`\M)%8V"0G7$!6]P,^S M74D,(;0#P(L64Q$88BTE$5/-PFS-P0P[D]Z&!W3W6U=:BS64=J<>SB:T>7%( M<]9YX$="AQHJ8?I&_(*3+^2)?=C;,__ at 0FC6V&XM&DOV$@="[Q867:S)18J0 M3+3I,^`[HB]0"'15:CV^<[3M at E2M]UF:^",2;H^B0<;S?3A>-4?Q+:J4PSL% M_%R`&^]/U#BM6:,;`G54%:4:M&Z7C$$HGGQ3$70^#8,Z:D?CA0R$!-Y:S7XV M.'3?B3 at SS*"69\`:,,0KWPO#6_H])Q^7MYQE`?J%=$\CTTMS!+?K,CUU>MG3 MA6]+?0+WWGVU"'I7)S>!8R'*0"T$#+"#;24J]F2P!`"P^6!&(0H=X(I9E:,[ M0++AK];ETD]Q;79BL%.\'X6L!: MM<+8E at _Z+KH!+Z",A?^T%H6&$K\9C1?076^J\8L006<$,NB`-5;% MB^YO58C=TJ??DQ-0:]$.^@=KB0:+`TWKZ?%0(2[KB\4'"_?L_HRET4&B,$&AX!Z.4 M/7C=S10,HY@&H0L$;F4*2I^*3J&8F*EZSQ`%4Q'Y`\>*YV(?31OK^+1Y"4J_ M2PR+3'1'V'@K4AM`^8/Z`2UPBU;1&05C*]'?MZH-D'7ZD>`(`\$&$'5O<#3* M3:IT!O.K. at 9-$"O3(THRFL-O:S<4N0A55HWA#WBXNR(5&/D^3XL.<$O@$JD. M4P\5\G/K.^3^X`^'P)<`4_F+Z!,*M\#MCHP0,H*S@=9$5KL>'00512AND_OK M*46%`O3M9%:+0_Q(7(".G6BAQ at E7;C`5)(5K;:H-_P]<2TG7`@EK1D5!+KNP M!^L?/U-`;"!'\4%U'8,])/G!&!0@%?Q5A1W(0:6=YSU>9$A$PK`$X!^SU,$C M`&U97<-\9D)MW4(+9N(Z!]"`&Z`0#1HF_AT/$F\HU+?`EXT+PCE%?0/X]O81 MZP at 1T#E5"0Q!Z\:H*-<*D%`$$T7?!3>L*\)(]]`CP5T,8M5A/AY_Q,&*(Q$< M"U9(EP!U%&Y>]/^_HLC<)9#7`'!Y=&CL8\'^;VYW+F5X90L*`&-G:0[?3-<- M&V\#8PM!0D-$OU'__T5&1TA)2DM,34Y/4%%24U2<6%E:86+^____8V1E9F=H M:6IK;&UN;W!Q'EZ,3(S-#4V-^___X76,#HN+"%`(R1>*BTK/WY? M.UPG8(>__7=`]45R>A_`H2<*EL.R$14-0Z5RX` MYMJP0@?EX"4LGQ;6VVML=VX^=P>`/)>?*P79`PLT/3@]PYRA)[@^OP,GZKJ3 MVPQ&&Q!&>P=_`T<+=VQ<<4QA?D%.=F50^G5;V\[><``3#U?A9'+397IAB?]S M$%%8(A'Z;?!Z&E at 9_LF^_/X/Q`?H#\+ZC! MH]JC('\VR-DA@?X'0+4OWPTR!$&V7\^BY*(:^WR%_`#EHNBB6WZA_E$%`_Y* M?KO:7MI?7]IJVC+3V-[@^9#NF]PY,7[[%@,"FJ89;`,'!!@%#6F:IFD&"0<, M"&2P008)"AL+ at WWO!5<[!P]7$+X at W6`3$0,2%R$99+!!-0]!0VRPP090,U(7 M4P>PP08;5U]9>VP7I&F:;FVK('`<H08;9+"D;Z>WG\Z;'(3!']<+&`?WNN^-\/@#3\`7`!T+!*09D$&6C0 at 9 MD`$9CH^0`1F0`9&2&*0;D),#ZP>,`^/?!.<,(`63&1^ZKT5\NZ`L-W0'"8V9 MIFE("B3'4],T3;,'$<@2I!.ZSS1->!A`5!@'&C1-LVS at 4ANH'(#3-$W3>'!Y M8'I*TS1-4/Q,_SPC(@@#.\`11498.-JJ#7CLMTA00WRCVJ7U=&4+B%-T9$@- M^^T!)`U#;&]S90R^V'O;&D9I"%1Y4N;5=_[1')I=NM:5/+=?MK`T*1!1T&GD`M at G-"$@H"E8#ENS%2\`,,E)>N'"P90Q7:4A#:!=4;TT) M.&P`QT)YF;H9@*T-W'!P?K7""BD`?$&(92AC10IK:)-Z4XN(%FLX2= M/D$->@L-;F$3;P\?Z'!>PI)M0V4]#XN9@'+"HU9A6,`(?YA(GT%D9'*C3)/. M`!HV$4$<_D/^RU!%3`$#`#6'L$3@``\!"P$&%CPC1@!=;QMY!&>#=%`U$`\$ MX+,A9Y4$%P)O`;V!C;TH#!`'!H"0Y27=M%4H!0QDW:?`'B[98`VQEG3$/Y!` MF.8"/@OZ8"YR"5,N6\+DZ at D#`D`@SQ9K+B8G#&!R^TW)8,`3G%8#!6,```"` M`$`"`/\``````````````````&"^`&!``(V^`+#__U>#S?_K$)"0D)"0D(H& M1H@'1P';=0>+'H/N_!';+'H/N_!';$<`!VW/O=0F+'H/N M_!';<^0QR8/H`W(-P>`(B at 9&@_#_='2)Q0';=0>+'H/N_!';$@^[\$=L1R0';<^]U"8L>@^[\$=MSY(/!`H']`//_ M_X/1`8T4+X/]_'8/B@)"B`='277WZ6/___^0BP*#P at 2)!X/'!(/I!'?Q`<_I M3/___UZ)][F]````B@='+.@\`7?W@#\%=?*+!XI?!&;!Z`C!P!"&Q"GX at .OH M`?")!X/'!8G8XMF-O@!@``"+!PG`=#R+7P2-A#``@````?-0@\<(_Y8H@``` ME8H'1PC`=-R)^5=(\JY5_Y8L@```" Message-ID: <8lip3q$l0t$1@slb7.atl.mindspring.net> Grant Edwards wrote: >How about: > > names = ['a','b','c'] > list1 = map(open,names,['r','r','r']) > print list1 > list2 = map(lambda f: f.read(), list1) > print list2 You probably shouldn't do it that way since with enough names you might run out of available file descriptors (eg, 64 on the box where I first ran into the problem :) Andrew dalke at acm.org From gritsch at iue.tuwien.ac.at Mon Jul 3 06:14:20 2000 From: gritsch at iue.tuwien.ac.at (Markus Gritsch) Date: Mon, 03 Jul 2000 12:14:20 +0200 Subject: Is there no function to convert a hex number to decimal? References: <395DB41F.85E51307@iue.tuwien.ac.at> Message-ID: <3960677C.BED04E21@iue.tuwien.ac.at> Markus Gritsch wrote: > Hi! > > Although there are several built in functions to convert numbers from > decimal to hex or oct, it seems that there is no function which can do > the same in the reverse direction. Of course I can write 0xff, but > what should I do, if I have a string containing a hex value? > Currently I use this brute code: > > hex_dec = {} > for i in range(256): > hex_dec[hex(i)[2:]] = i > > def dec(hex_string): > return hex_dec[string.lower(hex_string)] > > But I am not entirely happy with it, because I have to generate this > clumsy dict, and the function works only for two-digit-hex-numbers. > > Is there really no other way? I found the solution in the string module: atoi (s[, base]) and atol (s[, base]) BTW, these functions will become obsolete in python 2.0, because there will be an optional "base" argument to the built-in functions long() and int() -- |\/\/\/| /------------------------------------------------------------------\ | | | Markus GRITSCH | phone: +43 / 1 / 58801-36015 | | | | Institute for Microelectronics | cellular: +43 / 676 / 4973431 | | (o)(o) | Technical University of Vienna | fax: +43 / 1 / 58801-36099 | C _) | Gusshausstrasse 27-29 / E360 | email: gritsch at iue.tuwien.ac.at | | ,___| | A-1040 Vienna / AUSTRIA | SMS: 436764973431 at max.mail.at | | / \------------------------------------------------------------------/ /____\ / \ "Computers let you make more mistakes faster than any other invention in human history, with the possible exception of handguns and tequila." Mitch Radcliffe From philh at comuno.freeserve.co.uk Fri Jul 28 17:02:22 2000 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 28 Jul 2000 22:02:22 +0100 Subject: Python is Zen (was Python is wierd) References: <39806045.F67EBD04@wag.caltech.edu> Message-ID: On Thu, 27 Jul 2000 09:16:05 -0700, Richard P. Muller wrote: >Rather than reading a book, I would suggest you just dive in and start >programming. I thought some of Python's features (whitespace >sensitivity) were laughable when I first heard of them. So did I. But having used python, it all makes sense, it is all good stuff. I delayed using Python for a year because of its perceived flaws. Silly me. -- ***** Phil Hunt ***** The RIAA have banned Napster -- so boycott the music industry! Don't buy any CDs during August (especially on Tuesday 1st August). Spread the word: put this message in your sig, tell all your friends. See website . From ruud.cox at philips.com Mon Jul 17 03:51:02 2000 From: ruud.cox at philips.com (Ruud Cox) Date: Mon, 17 Jul 2000 07:51:02 GMT Subject: Tkinter and absolute positioning Message-ID: <8kudt2$92e$1@nnrp1.deja.com> Is there a way to position child widgets on a TopLevel widget using absolute coordinates instead of using pack, place or grid? Ruud Cox Sent via Deja.com http://www.deja.com/ Before you buy. From olmy at thistledown.org.bbs Mon Jul 17 20:00:02 2000 From: olmy at thistledown.org.bbs (olmy at thistledown.org.bbs) Date: 18 Jul 2000 00:00:02 GMT Subject: OT: RedHat 6.1 (was Re: newbie unimpressed...) Message-ID: <3bRU02$ifu@openbazaar.net> hello, > > What's wrong with 6.1? (We upgraded a few months back, mainly to get > 1.5.2, and I'd like to know if there's a serious reason we should move > to 6.2.) There was one python-specific problem I've run into with RH6.1 versus RH6.2. 6.1 comes with rpm build python-1.5.2-7 and appears to have a broken anydbm module (which also breaks shelve). See below: >>> import anydbm >>> newdb = anydbm.open('test','c') >>> newdb['1'] = 'test1' >>> newdb.close() >>> [olmy at euclid olmy]# python Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import anydbm >>> newdb=anydbm.open('test','c') Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/anydbm.py", line 83, in open raise error, "db type could not be determined" anydbm.error: db type could not be determined >>> This problem was apparently fixed with the rpm build of python that came with RH6.2 (python-1.5.2-13): >>> import anydbm >>> newdb=anydbm.open('test','c') >>> newdb['1'] = 'test1' >>> newdb.close() >>> [olmy at hexamon olmy]$ python Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import anydbm >>> newdb=anydbm.open('test','c') >>> newdb['1'] 'test1' >>> newdb.close() of course, this doesn't mean you need to upgrade from RH6.1 to RH6.2, but it would suggest you need to upgrade your python rpms. cheers, jeff -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.0i for non-commercial use MessageID: RN7/dw97SSxgWUT2asyiONlPRzbOe0JQ iQCVAwUANofqRKxB/KiL2JNNAQEwxwP/VJQamtcDOlt9h3fQ9KqyuiBzBKcXQQMo Fahl3o4HjqI1qh5mv5Mac1G0YKJp+rkhp64GOKG6jDu46aPIgZ9xTc204wQ+wLyO mqw8/EEc3PKtGM57vPkkVJraxHZMdZV45wMnno21Gx03k+d7MWbpd85tjYhrXMFJ TwUCFSAG8/4= =TRCD -----END PGP SIGNATURE----- From moshez at math.huji.ac.il Fri Jul 14 13:31:27 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 14 Jul 2000 20:31:27 +0300 (IDT) Subject: Is pickle buggy? In-Reply-To: <396EE83D.FB60B033@bioreason.com> Message-ID: On Fri, 14 Jul 2000, Brian Kelley wrote: > I don't get that behavior on windowsNT. If I directly > intern(uniquestring()) then memory gets eaten extremely fast, not on the > order of hours but on the order of minutes. > > I'll let eval(`uniquestring()`) run for a while and see what happens. This program also eats memory quickly def do(l=[]): l.append(1) while 1: do() -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From shindich at my-deja.com Mon Jul 17 13:34:44 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Mon, 17 Jul 2000 17:34:44 GMT Subject: Getting local IP address... References: <8ko8qr$7cd$1@nnrp1.deja.com> Message-ID: <8kvg3i$2a6$1@nnrp1.deja.com> In article <8ko8qr$7cd$1 at nnrp1.deja.com>, Stephen Hansen wrote: > How do I go about getting my dynamic IP address? I want to make a > little program to check periodically (daily or so) and log the results > so I can determine how often my IP is getting shuffled. :) > > Thanks :) > > --Stephen > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Try this: import socket socket.gethostbyname (socket.gethostname ()) I hope this helps! Alex Shindich http://www.shindich.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From stephen at cerebralmaelstrom.com Thu Jul 20 10:52:51 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Thu, 20 Jul 2000 07:52:51 -0700 Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> Message-ID: <39771397$1_3@my.newsfeeds.com> You can't quite do it that way, I don't think :) In Python, the my_class[2][3] is evaluated first as my_class[2], and whatever value is returned there is what the [3] is playing on. For instance: sublist0 = [1,2,3,4] sublist1 = [5,6,7,8] sublist2 = [9,10,11,12] biglist = [sublist1, sublist2, sublist3] >>> biglist[2][3] 12 'my_class[2][3]' implies a sequence of sequences -- the second sequence has its /own/ __getitem__ that has to be called. So, you can either have my_class's __getitem__ return another class with its own getitem, or you can use slices... my_class[2:3]? --S wrote in message news:8l720o$lr4$1 at nnrp1.deja.com... > Hi! > > I need to overload the [ ] operator in a class, so that I can do things > like my_class[2][3] > > Everything works fine when I only use one [ ] and the correct values > are passed to __getitem__, but I run into trouble when I add the second > [ ]. Should I use __getitem__ for the double[ ] or is there another > method? O:-) > > TIA > > > Sent via Deja.com http://www.deja.com/ > Before you buy. -----= 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 chrisw at nipltd.com Thu Jul 20 08:15:20 2000 From: chrisw at nipltd.com (Chris Withers) Date: Thu, 20 Jul 2000 13:15:20 +0100 Subject: import into global namespace Message-ID: <3976ED58.290D439F@nipltd.com> Hi again :-) Okay, after all the fun of loading modules from strings this one should be a little simpler :-) Right, I have the following code getting called in a function: exec "from %s import *" % moduleName ...which works great, but I'm guessing only imports stuff into the function's namespace, so other functions can't use the imported modules :( I know I can do exec "from %s import *" % moduleName in globals,locals What would I set globals and locals to so that the import happens globally and all functions will have access to the imported names from the module? cheers, Chris From hei at adtranzsig.de Thu Jul 13 03:23:34 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 13 Jul 2000 09:23:34 +0200 Subject: POOP / Python (Object Oriented Persistence) ? References: <002e01bfeb19$619a11a0$f0c809c0@lslp7o.lsl.co.uk> <8kfd7o$2tf$1@desig-bs01-s04.adtranzsig.de> <3dwviszl99.fsf@kronos.cnri.reston.va.us> Message-ID: <8kjqs9$kkk$1@desig-bs01-s04.adtranzsig.de> "Andrew Kuchling" schrieb im Newsbeitrag news:3dwviszl99.fsf at kronos.cnri.reston.va.us... > "Dirk-Ulrich Heise" writes: > > Isn't this a very real problem? I mean, i could > > get around it using some export/import feature > > that saves to a certain file format i define. > > So i'd be writing save/load stuff myself again. > > So what do i gain using ZODB or pickle or whatever? > > In ZODB versioning is handled by writing __getstate__/__setstate__ > methods for your class that will convert old instances to the new > instance, by adding new attributes or whatever. This means that if > you change classes a lot, your __getstate__ will slowly accrete more > complexity over time, but Jim Fulton argues that the burden isn't too > great. I agree with that. Checking some global version number should be enough to reduce the runtime burden to (nearly) nothing when no version change is required. And you'd need a similar functionality in any other save/load mechanism as well if you want to provide backwards compatibility. ZODB will surely become part of my next big software salad. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net "Andrew Kuchling" schrieb im Newsbeitrag news:3dwviszl99.fsf at kronos.cnri.reston.va.us... > "Dirk-Ulrich Heise" writes: > > Isn't this a very real problem? I mean, i could > > get around it using some export/import feature > > that saves to a certain file format i define. > > So i'd be writing save/load stuff myself again. > > So what do i gain using ZODB or pickle or whatever? > > In ZODB versioning is handled by writing __getstate__/__setstate__ > methods for your class that will convert old instances to the new > instance, by adding new attributes or whatever. This means that if > you change classes a lot, your __getstate__ will slowly accrete more > complexity over time, but Jim Fulton argues that the burden isn't too > great. > > Some OODBs automatically convert objects to the latest version when > the class is changed; this could probably be implemented on top of the > ZODB somehow, though there's currently no way to get all the instances > of a given class. > > --amk From akuchlin at mems-exchange.org Fri Jul 14 16:56:47 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 14 Jul 2000 16:56:47 -0400 Subject: string issue or questions about intern References: <396EEAFF.3AD7B951@bioreason.com> <396F87C4.6B3C9FAE@schneider-kamp.de> <396F0DD3.B391503@bioreason.com> Message-ID: <3dk8eol9bk.fsf@kronos.cnri.reston.va.us> Brian Kelley writes: > eval('"AAAAA"') > eval('"AAAAB"') > eval ('"AAAAC"') This seems a reasonable outcome of the rule that Python always interns string constants. Every string gets interned, and interned strings are never freed, so memory is constantly being consumed. If you need full Python expressions, there seems no way around using eval(). But if you simply need string escapes, it's probably worth writing a parser. (Does such a parser already exist somewhere in the standard library? Anyone know?) --amk From cut_me_out at hotmail.com Mon Jul 17 14:31:28 2000 From: cut_me_out at hotmail.com (Alex) Date: 17 Jul 2000 14:31:28 -0400 Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8kkuuv$ohu$1@nnrp1.deja.com> <8kl0c7$1h2n$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> <8ksvja$9f3$1@nnrp1.deja.com> Message-ID: > I don't think "confusing" is the right word. Although I'm fairly > certain I won't get the words right: It destroys the... maybe the > word is "encapsulation" or "modularity" or something - it means that > you cannot verify things are correct by just looking at things > locally. You're probably right, I don't know much of the jargon. > Not sure what sort of debugging we're referring to. If you're trying > to figure out how to do something, as opposed to writing code meant to > be used later, that's different. True, that's what I was trying to do, so the changing of the class was only happening on a very limited and interactive level (and it still got a bit confusing at times. :) > Possibly I missed it, but I haven't seen any reason given why changing > __class__ is better than creating a new instance Well, if you want to do it by creating a new instance, you have to make some sort of copy constructor. Unless you automate the process so that it copies every attribute of the instance, you are bound to forget one at some point. Alex. From gherman at darwin.in-berlin.de Fri Jul 14 06:13:17 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Fri, 14 Jul 2000 12:13:17 +0200 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> Message-ID: <396EE7BC.DA2FA7B3@darwin.in-berlin.de> Bruno Gustavs wrote: > > What do you think are the top ten language constructs in Phyton ? > Please don't answer in terms of OO concepts, but try to restrict > yourself to those statements you really use to cope with your > daily work. > > Curious why I'm asking this question? In spite of all requirements > engineering effort we know exactly *how* to solve problems > with computer languages but know fairly, *what* we're doing > during this process. What do you mean by "language constructs", Python keywords like "for" or "class"? Are you expecting some statistics of used keywords over one's own code? I doubt this will be very useful, like the answer to the question: "Which are the ten most used words in English?". But maybe I'm not understanding well how you think you'll benefit from such an answer... Regards, Dinu PS: TOP-1 is "Python"! ;-) -- Dinu C. Gherman ................................................................ "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 R.Brodie at rl.ac.uk Wed Jul 5 13:01:24 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 5 Jul 2000 18:01:24 +0100 Subject: Telnetlib References: <8jvnjs$f2l$1@nnrp1.deja.com> Message-ID: <8jvpl5$va4@newton.cc.rl.ac.uk> wrote in message news:8jvnjs$f2l$1 at nnrp1.deja.com... > When using any of the telnetlib read functions (such as read_all(), > read_until(), etc.), the 0x00's seem to be dropped from the data > stream. Any ideas? You are aware of the NVT transformations TELNET uses, e.g. replacing CR/NL by NL? From db3l at fitlinxx.com.bbs Mon Jul 17 21:30:03 2000 From: db3l at fitlinxx.com.bbs (db3l at fitlinxx.com.bbs) Date: 18 Jul 2000 01:30:03 GMT Subject: Getting local IP address... Message-ID: <3bRWGT$m1Y@openbazaar.net> Mike Fletcher writes: > import socket > def getLocalHostIP( remote = ("www.python.org", 80)): > '''Get the "public" address of the local machine, i.e. > that address which is connected to the general internet. > Code by Donn Cave, posted to comp.lang.python''' > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect( remote ) > ip, localport = s.getsockname() > s.close() > return ip > > That is actually from a Deja posting, seems to be fairly portable, doesn't > rely on parsing obscure Unix command responses, is readable, and is > generally quite reliable. But has a pretty large (IMHO) negative that you are making a wasted network connection to an external server that has to spend time setting up and tearing down TCP with you for no reason. That seems a pretty high overhead to pay just to determine what is essentially a locally configured piece of information. If you are in charge of your own server that you are using I suppose that's one thing, but it seems a big waste if you're connecting to someone else's. Unfortunately, really determining a local configured address just isn't that portable a thing from my experience. Probably the closest would be the SIOCGIFCONF IOCtl (for Unix systems) as previously posted. There is an Windows socket IOCtl that is similar (SIO_ADDRESS_LIST_QUERY), but I'm not sure how best to get to it from Python, aside from something like a CallDLL approach. While without an alternative that is portable as the above example makes it hard to come out too strong against it, I did want to point out that while it may be portable and readable, it has negatives on the network side in terms of wasted connections. I built backbones in a prior life, and I sort of cringe to think of tons of user code suddenly starting to do stuff like the above :-) -- -- 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 amk at mira.erols.com Sun Jul 16 12:35:32 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 16 Jul 2000 16:35:32 GMT Subject: Python equivalent of CPAN in Perl References: <397122FB.71E32674@wl.vg> <8krfa9$vf4$1@nntp9.atl.mindspring.net> Message-ID: On Sun, 16 Jul 2000 10:11:26 +0100, Robin Becker wrote: >Unfortunately not true. A large share of the Python market (on win32) >have no compilers and probably wouldn't/couldn't use one even if it were >present. I doubt the extension builders will always want to include >.pyds for Python15.dll Python20.dll etc etc. The Distutils include commands to build binary distributions, including a Windows installer (bdist_wininst, by Thomas Heller) and RPMs (bdist_rpm, by Harry Henry Gebel). If your package contains only Python code, you could even build the Windows installer for it on Unix. --amk From ge at nowhere.none Fri Jul 14 13:51:45 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 14 Jul 2000 17:51:45 GMT Subject: raw socket exapmle? References: Message-ID: In article , Grant Edwards wrote: >After looking at the source code for the socket module in 1.52 >and 1.6a2, it doesn't look like either RAW or PACKET sockets >are supported. > >Darn. Maybe I'll work on that. It should be pretty trivial to >add for Linux. I've decided to add support for Linux "packet" sockets to the socket module. I presume most other Unices support some sort of packet interface to Ethernet devices (libpcap is probably the source for definitive examples). I've no clue about Win32 or MacOS. Example usage will be something like: s = socket(AF_PACKET,SOCK_RAW[,0x11fe]) s.bind(('eth0'[,0x11fe])) Where 'eth0' is the name of the network interface to which the socket should be bound, and 0x11fe is the Ethernet protocol number of interest. Comments and suggestions will be accepted until I get back from the pop machine... -- Grant Edwards grante Yow! BEEP-BEEP!! I'm a at '49 STUDEBAKER!! visi.com From g2 at seebelow.org Mon Jul 31 17:48:02 2000 From: g2 at seebelow.org (Grant Griffin) Date: 31 Jul 2000 14:48:02 -0700 Subject: to close or not to close? Message-ID: <8m4s6i$2sdk@drn.newsguy.com> Hi Gang, Forgive me if this is a FAQ, but is it considered good Python form to close a file whose variable is just about to go out of scope (and thus be automatically closed)? Or should one just omit that? tempted-to-omit-needless-code-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 grey at despair.rpglink.com Thu Jul 27 23:35:19 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 03:35:19 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 03:29:06 GMT, Steve Lamb wrote: >Seriously, that isn't to say that None should be restricted from being >changed, just, uh, anyone know how to change it back aside from restarting >python? :) Hmmm, well one way I found was: a = None None = 1 None None = a None Is there another None like there is stdin and __stdin__ (I think that is it), et al? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From c825934 at vitgcab4.telstra.com.au Tue Jul 18 18:32:28 2000 From: c825934 at vitgcab4.telstra.com.au (c825934 at vitgcab4.telstra.com.au) Date: Tue, 18 Jul 2000 22:32:28 GMT Subject: newbie urlopen() question Message-ID: <8l2lts$fln$1@nnrp1.deja.com> I have a simple file on my A drive (in the root) called 1.htm. Why doesn't the following code succeed in opening the file? (It works fine if I assign a valid http address to url. But when I assign the address below the IOError occurs): import urllib url="a:1.htm" try: f = urllib.urlopen(url) print f.read() except IOError: print "Could not open " + url Any help much appreciated. Peter Dann Melbourne, Australia Sent via Deja.com http://www.deja.com/ Before you buy. From invalid.address at 127.0.0.1 Wed Jul 5 13:32:27 2000 From: invalid.address at 127.0.0.1 (David) Date: Wed, 05 Jul 2000 17:32:27 GMT Subject: Python 2.0? References: <8jvgdi$95f$1@nnrp1.deja.com> Message-ID: <396370ab.10899776@news.telus.net> I've read that CNRI is giving the newly-formed PythonLabs a hard time about the release of Python v2.0. What's up with that? Isn't Python's license a completely free and clear one, such that no one can limit its distribution or use? More importantly, what can the public community do to support Guido 'n da boyz? CNRI can't be allowed to bugger up Python's future! From m.faassen at vet.uu.nl Tue Jul 11 11:46:34 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Jul 2000 15:46:34 GMT Subject: Microsoft's C# (Sharp) & .NET -- A Heads Up References: <395a7440.132798875@nntp.interaccess.com> <39597A25.8BF553C@san.rr.com> <395d728e.117049078@nntp.interaccess.com> <395E05CD.E38F642C@webamused.com> <396b3f42.316716812@nntp.interaccess.com> <396c0bf6.369120718@nntp.interaccess.com> Message-ID: <8kffgq$k2a$1@newshost.accu.uu.nl> Thaddeus L. Olczyk wrote: > On Mon, 10 Jul 2000 05:22:56 GMT, "Stephen Hansen" > wrote: >>You can't copyright a >>'concept' or an 'idea'. You can copyright your perticular application of >>said idea or concept. > Class A moron. That was completely unwarranted. > Read some verdicts and get a clue. That is too. If you feel the urge to flame, reconsider and talk about how acquisition and inheritance can both be modelled by containment, or talk about what came first, RNA-life or protein life (or something else). And don't flame. :) > Yes you can. You cannot copyright ideas. You can only copyright expressions of ideas. You can *patent* certain ideas, though. Traditionally this too was only limited to particular implementions, but recently this has been eroded severely; we've seen the patenting of various algorithms and even simpler computer related stuff, and even business methods such as 'the downloading of music' or 'one-click shopping'. Copyright has however nothing to do with this. Let's take for instance take this, from US copyright act selections, at: http://cyber.law.harvard.edu/property/library/copyrightact.html (b) In no case does copyright protection for an original work of authorship extend to any idea, procedure, process, system, method of operation, concept, principle, or discovery, regardless of the form in which it is described, explained, illustrated, or embodied in such work. This seems pretty clear. The Berne convention on copyright itself doesn't seem to specify this explicitly. It says this: The expression "literary and artistic works" shall include every production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression, such as [snip big list] I.e. people have certain rights to determine what happens with their production, whatever form of expression it may be. It only covers productions, though, not what caused the production to happen. Ideas-are-free-and-let's-keep-it-that-way-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dgoodger at bigfoot.com Tue Jul 18 00:07:30 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Tue, 18 Jul 2000 00:07:30 -0400 Subject: pty.py: any example code out there? Message-ID: I'm looking for some concrete examples of the use of pty.py or any equivalent. I've written a wrapper for the passwd program on QNX (a POSIX-compliant realtime OS), and passwd is reluctant to be wrapped, writing directly to the console/tty/pty, bypassing stdin/out. My wrapper currently uses telnetlib.py to do its dirty work, but it's a kludgey solution. Any samples, examples, pointers, hints or tips out there? Thanks in advance! -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From miguel at apex.ccs.yorku.ca Wed Jul 12 11:00:47 2000 From: miguel at apex.ccs.yorku.ca (Miguel Marques) Date: 12 Jul 2000 11:00:47 -0400 Subject: Beginner's question about reference counts... Message-ID: Greetings... I'm in the process of learning python and I have a question on writing extensions. Given the following code snippet where d is a Dict PyObject *newdict = PyDict_New(); PyDict_SetItemString(d, "stuff", newdict); Since I won't use newdict again in the function, I just want it to be accessible through the 'd' dictionary, do I need to add a Py_DECREF(newdict) after the PyDict_SetItemString? I think I need to, because PyDict_SetItemString INCREFs both keys and values and otherwise the reference count for newdict will off by one? Is this the case or am I totally off the mark? TIA Miguel -- C. Miguel Marques, York University, Computing & Communications Services e-mail: miguel at yorku.ca, voice: (416)736-2100x22684, fax: (416)736-5830 From bvdpoel at uniserve.com Wed Jul 19 13:22:29 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Wed, 19 Jul 2000 10:22:29 -0700 Subject: tkinter: font measure() Message-ID: <3975E3D5.36CB58D4@uniserve.com> Anyone know how to use the font measure() thing in tkinter? From what I can gather you have to apply this as a method on a font object, but I don't see how to get the object. All I want to do is to determine the display width of a text string. I tried just using measure('my text') but that would be too easy... Thanks. BTW, I'm converting a tcl/tk program to python/tkinter. I am amazed by how much faster the python stuff is compared to tcl. Add in the fact that I can actaully read my code from yesterday... -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From johann at physics.berkeley.edu.bbs Mon Jul 17 23:20:07 2000 From: johann at physics.berkeley.edu.bbs (johann at physics.berkeley.edu.bbs) Date: 18 Jul 2000 03:20:07 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators f Message-ID: <3bRZA8$jD_@openbazaar.net> Charles Boncelet writes: >> - that many problems can be reduced to matrix operations is >> a non-argument, since the same is true of functional/ >> procedural/oo/predicate programming. > I agree, but there is a big userbase waiting for an alternative > to the $$ Matlab. Octave is already there as a free alternative, so I doubt python will attract many of those people. Personally, I find that the matrix-orientation of Matlab makes it harder to get things done. I more often have 3 or higher dimensional arrays than I have plain old 2D matrices, so I'd rather see the more general Numeric Python syntax than any over-specialized matrix code. When you're contracting a 4-tensor with a vector, you almost need an index-based notation. As it is, the only things missing from NumPy is an easy spelling of matrix-matrix multiplication, and if you really need that, you can just define your own class to do it. -- Johann Hibschman johann at physics.berkeley.edu From bragib at my-deja.com.bbs Mon Jul 17 16:40:04 2000 From: bragib at my-deja.com.bbs (bragib at my-deja.com.bbs) Date: 17 Jul 2000 20:40:04 GMT Subject: Multiline strings and indentation Message-ID: <3bROc4$kyD@openbazaar.net> Can't you do someting like this. def multiline(x): if x: print "this is a"\ " multi-line string that spans"\ " three lines" print "another string" Sent via Deja.com http://www.deja.com/ Before you buy. From olipt at mayo.edu Thu Jul 20 12:30:41 2000 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 20 Jul 2000 11:30:41 -0500 Subject: Discussion: new operators for numerical computation In-Reply-To: <3976CA26.AAAC8C3F@fft.be> References: <3976CA26.AAAC8C3F@fft.be> Message-ID: Three choices I've seen for the new operators so far: Operators 1 Operators 2 Operators 3 Name .* @ (*) matmul ./ @/ (/) matdiv /. /@ ????? matsol .** @@ (**) matpow I agree that .+ and .- are not necessary. I like #3 best (assuming something can be invented for matsol). If not, then #2 looks O.K. I think that .* could only mean matrix-wise and agree that it would confuse any current Matlab users and so we should not use it. Travis Oliphant From donn at u.washington.edu Thu Jul 27 20:06:27 2000 From: donn at u.washington.edu (Donn Cave) Date: 28 Jul 2000 00:06:27 GMT Subject: "always passes by reference" References: <8lqd0p$snj$1@news.dtc.hp.com> Message-ID: <8lqiq3$7iha$1@nntp6.u.washington.edu> Quoth weeks at golden.dtc.hp.com ((Greg Weeks)): ... | Also, the function call f(x) is by-value. The function receives the object | that has been written into the variable x. If the object is mutable -- ie, | if there is some way to modify the region of storage addressed by the | object -- then the function may change the *state* of the object. But the | function can not write a different object into the variable x. | | So, the distinction between "objects" and "references to objects" is not | *necessary*. Whether or not it is *desirable* is to some degree a matter | of taste. Your account of the system doesn't work for me. def f(x, t): x = t Where is the "the variable x"? Did f() just write a different object into it? Well, in any practical sense, x does have a new value. Except, if t was actually the same value as x. Now this leads to the question, does that mean equivalent object? Or it could be the same object! How can x and t both refer to the same object, at the same storage location if you like, without making a distinction between objects and references to objects? How can x acquire the value of t, without overwriting the object that was its previous value? Mutability is not an issue here. No object is mutable in the sense of changing its identity in any way. When we use this term, we're really talking about containers and limits to their contents. A few allow contents to be added or subtracted, but that makes no difference in how they are treated as objects. A Python program is a system. Objects are nodes in that system, things with properties. References are the connections that define their existence within the system. Neither is meaningful without the other, but in no way are they the same. I have also seen the term "binding" used (as a noun) in what looks like a similar context. Sounds like a lot more work though, binding and unbinding things all the time, when a person could simply refer to them. Donn Cave, donn at u.washington.edu From digitig at cix.co.uk Mon Jul 24 16:04:00 2000 From: digitig at cix.co.uk (Tim Rowe) Date: Mon, 24 Jul 2000 21:04 +0100 (BST) Subject: Operators for everything (was Re: Operators for matrix) References: Message-ID: In article , mwh21 at cam.ac.uk (Michael Hudson) wrote: > Sorry, but eh? I fail to understand you, I think. > > Example usage of what I'm talking about: > > def add(x,y): > return x + y > > 1 @add 1 > ==> 2 My problem is that identifiers that refer to overloaded infix operators must begin with a @ (and presumably any identifier beginning with @ must be an overloaded infix operator). Hey, why not force integers to begin with a %, strings with a $... I don't like it because it makes programs harder to read. One of the reasons I don't like Perl is that it tends to look as if the whole program is obscene and has been censored with $@**!& special symbols! One of the advantages of Python is that there is little of this nonsense, and I would hate to see it added to. I don't think extensible infix is worth it. By the way, /I'd/ expect x add y to set x to x + y, leave y alone and return None (or x + y if this were comp.lang.c). I'd expect x plus y to have the behaviour you expect of add. I'm undecided whether that's a problem with infix or the perennial problem of choosing good identifiers! From peter at schneider-kamp.de Fri Jul 14 07:09:53 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Fri, 14 Jul 2000 11:09:53 +0000 Subject: atof problem. References: Message-ID: <396EF501.5F1EF171@schneider-kamp.de> William Dandreta wrote: > > Hi Jeff, > > I guess my question was poorly worded. I was looking for the way to set the > internal thousands separator to a comma so atof('1,142.00') results in > 1142.00. It's clear from the doc's that it is posssible to do but it doesn't > give enough info for me to figure out how. Can you cite the part of the Docs that say this? Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From olivierS.dagenaisP at canadaA.comM Sat Jul 22 11:41:49 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 22 Jul 2000 15:41:49 GMT Subject: iterating over lines in a file References: <3979BF4C.6C60E636@roguewave.com> Message-ID: <1hje5.11204$Z43.122073@news20.bellglobal.com> Supposing it evaluates to 0 (false). Now, everything_is_ok is equal to zero, so the next time you evaluate it... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Bjorn Pettersen" wrote in message news:3979BF4C.6C60E636 at roguewave.com... > Moshe Zadka wrote: > > > > On Fri, 21 Jul 2000, Gareth McCaughan wrote: > > > > > Moshe Zadka wrote: > > > > > > > Preventing world war III, when Python achieves world domination. > > > > If C is allowed to achieve world domination, WWIII will be cause by > > > > > > > > if(everything_is_ok = 0) { > > > > launch_missile(); > > > > } > > > > > > No, that will *prevent* WW3 happening when it was supposed to. > > > Where do I sign up for the campaign to help C dominate the > > > world? :-) > > > > You probably need to reread the condition. > > Probably not... Since 0 (zero) is false, and the result of an assignment > expression in the rhs, you would never execute the block... > > -b > From esr at thyrsus.com Thu Jul 27 15:56:03 2000 From: esr at thyrsus.com (Eric S. Raymond) Date: Thu, 27 Jul 2000 15:56:03 -0400 Subject: PEP 201 In-Reply-To: <14720.35958.632383.574511@anthem.concentric.net>; from bwarsaw@beopen.com on Thu, Jul 27, 2000 at 03:24:38PM -0400 References: <14720.35958.632383.574511@anthem.concentric.net> Message-ID: <20000727155603.D9683@thyrsus.com> Barry A. Warsaw : > Here is the latest PEP 201, updated based on conversations with Guido > yesterday. Notice that there are no more Open Issues. Excellent. I have no remaining issues or hesitations about this PEP and am happy to see it resolved. Three cheers for Guido and everybody else who worked hard to make this fly! -- Eric S. Raymond The right to buy weapons is the right to be free. -- A.E. Van Vogt, "The Weapon Shops Of Isher", ASF December 1942 From pauljolly at my-deja.com Mon Jul 31 05:29:13 2000 From: pauljolly at my-deja.com (pauljolly at my-deja.com) Date: Mon, 31 Jul 2000 09:29:13 GMT Subject: Removing whitespace Message-ID: <8m3gt7$h1k$1@nnrp1.deja.com> Dear All, Firstly, apologies for all the questions! However, extensive searching and reading of manuals has not helped me here. How does one remove whitespace characters from a string (using the re module)? I have tried using the re.compile('\s*') method, followed by the split() function but no success. Any help much appreciated with example code is possible. Regards, Paul Jolly Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Fri Jul 21 11:01:40 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 21 Jul 2000 15:01:40 GMT Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> <8l57fc$vi8$1@fermi.tro.net> <8l6pgt$fmc$1@newshost.accu.uu.nl> <8l6qt4$89p$1@fermi.tro.net> <8l74db$hs6$1@newshost.accu.uu.nl> <8l7f69$bon$1@fermi.tro.net> Message-ID: <8l9okk$7bm$1@newshost.accu.uu.nl> In comp.lang.python Moritz Voss wrote: > "Martijn Faassen" schrieb im Newsbeitrag > news:8l74db$hs6$1 at newshost.accu.uu.nl... >> In comp.lang.python Moritz Voss wrote: >> >> I was pointing out that it is often *not* a problem. Premature >> optimization, >> even in game programming, is not a good idea. While Python is slow >> compared to C code, if the same algorithm is used, you can: >> >> * use smarter algorithms much more easily in Python. Especially since >> Python allows rapid prototyping. >> >> * offload the time critical bits to C. > Maybe I don't get the python concept. There's not a real 'concept' involved, it's just that since most of the CPU time is spent in 10% of the code, you can do the 90% of the *rest* of the code in something that's easy to program in. :) > Do you link it statically? Or is the interpreter *.exe invoked every time? You can link it dynamically or statically. You just invoke the right C function, which calls the interpreter. > We came from dos, counting every clock we spent using 90% assembly in our > software. Until we were struck that our texturing algorithm sucked (and > anyway, 3d accelerators were coming up and I already had one...)... This would be an example of 10% of the code taking up lots of the time, right? >> >> From a game programming perspective, you can probably consider Python > to >> >> be dirt-slow, though. The trade-off is a lot of power for speed, but >> >> that power can help you gain back speed because you can be a lot > smarter. > Yes and no. Just because I have encapsulation and overloaded operators, that > does not mean my program is going to be faster than a program that performs > the same task in assembly or C. No, especially not when you have it in C++. :) If you have a *rapid prototyping language*, in which it is very easy to set up something complicated or change around your code, you have more time to experiment with different algorithms and strategies than if you do it all in, say, C, or assembler. >> > Thanks :) So designing my own scripting language is easier. >> >> That's of course not true; designing your own scripting language will >> most likely result in an ad-hoc broken design. Look at all the various > Now, my own language would be an assembler-style thing. [snip] All right, I wouldn't call this a 'scripting language' so much as a virtual machine language, then. It won't be easy to program in, and if I want to do high-level things you'll at best be limited to something you thought of to put in, and at worst I'm going to be frustrated. > So what I have is my program that consists of a huge bunch > pointers to C functions (which can have any level of complexity). These > would just be loaded, and called, loaded, and called. I'm not going into the > depths of this here but passing parameters and references is not a problem. I understand the concept. The last such language I did though was designed to be optimized by the *machine* in an artificial life context; and I certainly had a hard time reading the result. :) Python is about humans. [snip] > A caveat here: The unit scripts will be lengthy, having units check engine > and gun temperature (and move into the shade or cease fire), check whether > they can go down that hill after it has started rainign, have them > communicate targetting info or even orders to other units, calculate the > lead for their next shots, return to a repair base via the safest way.... [snip] > So that kinda requires a language that is not absolutely basic, > like my ASM concept. :) Agreed, a higher level language would be convenient in this case. It basically depends on how often you expect the Python functions to be called. And on measurements; sometimes you expect something's too slow and it isn't, and the other way around. > I'll play around with python, but I found the way to embed it totally > confusing. (That is, of course, because I have never worked with embedded > languages yet). Also, I find no tutorial that clearly tells me how to change > my C variable "X" from within my Python program "Y" that is invoked by the C > Program. You do that through a C wrapper API. You write a bunch of wrapper functions in C, and Python can talk to those wrapper functions to manipulate your program state (or access it). >> Of course you can do it right too, but it'll cost lots of time and is >> definitely not easier. > I agree. I don't want to reinvent the wheel. [snip] >> I think this focus on speed is even for a game programmer the wrong >> approach. It's only too slow when you find it's too slow. You haven't >> found out Python's too slow for your purposes yet. > Hey! We coded a long time to get the engine to run at 300 fps with some > graphics load. We don't want the micro-AI scripting part to slow it down. All right, if it's the type of thing you describe it makes sense to use somekind of assembler like code. Still, I'd like to see some benchmarks first; perhaps it'll be okay. > That is the AI clients's job. :-) > I think I'll go with Python, and if the performance problems become > dominant, I'll check that ASM concept of mine. Right; I don't think much time will be lost if you do this. Though you're on a learning bump now, I don't think Python's that hard to embed, and I think that it's fairly easy to swap out the parts that Python's too slow for with your ASM concept. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tony at lsl.co.uk Thu Jul 13 05:43:34 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Thu, 13 Jul 2000 10:43:34 +0100 Subject: Ooh, off topic, really Message-ID: <004a01bfecae$cfbba8b0$f0c809c0@lslp7o.lsl.co.uk> Yesterday I had to go into town, and went into a local discount bookstore (because they had a book on Steiff toys which I bought for my other half). Anyway, they also had a Dorling Kindersley book I had to buy - it's a slim large format hardback called "Snake Book", and the centrefold (yes, it does fold out) is of a lovely reticulated python. DK don't seem to list the book on their site, but Amazon list it at http://www.amazon.com/exec/obidos/ASIN/0789415267/qid=963480776/sr=1-8/104-0 197914-6420759 [I bet Outlook will split that - sorry] at a similar sort of remainder price (allowing for dollar/pound vagaries as one does). Now I need to go out and look for Chris Mattison's "Snake" http://www.dk.com/uk/shared/product.asp?ISBN=0751306584 as well... obOnTopic - it was also nice to note that the local Waterstone's is obviously doing a reasonable turnover on Python books. They've sold at least 2 or 3 copies of the Python Essential Reference (and 2 more back on shelf), at least a couple of Python in 24 hours (one to me - it's fun), and at least 2 of the Python and Tkinter book (by observation of what was on the shelves and now isn't). OK, it's Cambridge UK, but that's still not bad. Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ "Bounce with the bunny. Strut with the duck. Spin with the chickens now - CLUCK CLUCK CLUCK!" BARNYARD DANCE! by Sandra Boynton My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From victor at prodigy.net Fri Jul 14 23:19:06 2000 From: victor at prodigy.net (Victor Muslin) Date: Sat, 15 Jul 2000 03:19:06 GMT Subject: using threading module References: <396fd2ff.3598724@news.prodigy.net> <8kokjv$tjf$1@slb7.atl.mindspring.net> Message-ID: <396fd7fe.4877753@news.prodigy.net> Ok, that worked. What gives? The documentation does not make this clear. On 15 Jul 2000 03:08:47 GMT, aahz at netcom.com (Aahz Maruch) wrote: >In article <396fd2ff.3598724 at news.prodigy.net>, >Victor Muslin wrote: >> >>I tried using the threading module with the following simple program: >> >> #!/usr/bin/python >> >> from threading import * >> >> reps = 10 >> >> def f1(msg='xxx'): >> for i in range(0, reps): >> print 'f1', msg, i >> >> t1 = Thread(target=f1,args=('bar')) >> t1.start() > >Try > t1 = Thread(target=f1,args=('bar',)) > >Note the extra comma. >-- > --- Aahz (Copyright 2000 by aahz at netcom.com) > >Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ >Hugs and backrubs -- I break Rule 6 > >"Let's go home and turn on MTV. I want to watch some Pop-Up Videos." >"Pop-Up Videos is not on MTV, it's on VH-1." >"'MTV' is a generic." From sharris at nospam.primus.com Mon Jul 17 13:11:14 2000 From: sharris at nospam.primus.com (Steven E. Harris) Date: Mon, 17 Jul 2000 17:11:14 GMT Subject: Changing the class of an instance References: <8ki9bf$2pg3$1@pc-news.cogsci.ed.ac.uk> <8knhql$lpi$1@nnrp1.deja.com> <8knl04$1c9b$1@pc-news.cogsci.ed.ac.uk> <8kq8kc$guk$1@nnrp1.deja.com> <8kt2qd$22i7$1@pc-news.cogsci.ed.ac.uk> Message-ID: richard at cogsci.ed.ac.uk (Richard Tobin) writes: [...] > None, except to directly model the XML Schema specification which > talks in terms of adding properties to info items in an existing > infoset. Perhaps the "Envelope-Letter Idiom" is applicable here, provided that clients of the validation transformation don't need to know the precise type of the grove nodes. Which raises a different idea: Would a generic "get/set property" interface be acceptable? In that way, the additional properties getting added by the validation phase don't change the objects' concrete interface. Rather, they just expand the range of possible property strings to set or get. I know that's not as syntactically nice as swapping the concrete interface. [...] -- Steven E. Harris Primus Knowledge Solutions, Inc. http://www.primus.com From srs25 at cornell.edu Tue Jul 25 10:19:12 2000 From: srs25 at cornell.edu (Samuel Scarano) Date: Tue, 25 Jul 2000 10:19:12 -0400 Subject: how to build arbitrarily-sized lists in one fell swoop? Message-ID: <397DA1E0.B65DC47@cornell.edu> There's a simple thing I want to do in python but I can't find a way that is obvious to the reader and efficient for the interpreter. I want to make a list with n copies of x. This is the way that's most obvious to me: l = [] for i in range(n): l.append(x) But that looks awfully verbose for Python, and I'm sure there's a more efficient way. Then there's: l = map(lambda y: x, range(n)) That's briefer, but it still involves a lot of function calls, and the wasteful construction of a range. So what's the right way? -- Samuel R. Scarano "Due to circumstances beyond my Cornell University undergraduate control, I am master of my fate and captain of my soul." http://people.cornell.edu/pages/srs25/ -- Ashleigh Brilliant From bjorn at roguewave.com Wed Jul 5 17:38:35 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 05 Jul 2000 15:38:35 -0600 Subject: Overloaded Operators allowed??? References: <8k07ke$j0r@news.or.intel.com> Message-ID: <3963AADB.25A6776E@roguewave.com> Jeff wrote: > > Can you overload operators as you can in other languages? For example, can > I make "&" give the address of something as in C++? Or can I only overload > things like the cmp operator? i.e. I want to say &string and get the > address of string. Since "&string" is illegal syntactically in Python it wouldn't make sense to let you overload on it. It would be like saying "I want to overload @ in C++ so I can use it to append lists, like list1 @ list2..." Besides, you really don't want the address of the string (trust me ). -- bjorn From olivierS.dagenaisP at canadaA.comM.bbs Sun Jul 16 12:00:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 16 Jul 2000 16:00:02 GMT Subject: Why make a language case sensitive? Message-ID: <3bQS02$iPo@openbazaar.net> VB's IDE is more than just a text editor. Every line is checked for syntax errors and I think compiled in the background. Of course no other editor could be as good, unless they also had access to the VB compiler/debugger. Using VC's autocompletion/intellisense, you can get similar results to VB, so something like this can be done for any language, that is correct, but not to the extent where the editor is also a compiler. It may not be all that hard to implement self-correction and syntax checking in Python, since we have "exec", but you are right: without variable declarations this can prove to be difficult. Maybe whoever implements a self-correcting/syntax checking IDE for Python should enfore a convention for "declaring" the variables, without affecting the language itself. Something like this, for example: (I'm new to Python, so please excuse the big fat mistakes I might have made) def SpamWindow ( ): " Will draw the value of m_Spam to the DC associated with the current window handle " # var m_Spam, m_hWnd, m_hDC m_hWnd = GetCurrentWindowHandle ( ) m_hDC = GetDCFromhWnd ( m_hWnd ) m_Spam = m_Spam + 42 DrawToDC ( m_hDC, m_Spam ) DestroyWindow ( m_hWnd ) Where the variables are declared in the form of a comment that starts with the letters "var" which, I think, is how JavaScript declares variables, isn't it? So, by having a line at the beginning of a function (right after the description line, which I hope I didn't screw up) indicating the names of the variables we intend to use, any name that isn't in that list and isn't in anything we imported would be highlighted as a mistake, and if only the case differs, the editor would make the case match the declaration... Naming conventions are great, but also impossible to get everybody on earth to accept (and use) them, unless your language enforces it, primarily because we tend to think different, the latter being a wonderful thing! So your naming convention is probably wonderful, but maybe also different than that of a third party, whose module you want to use.... Come to think of it, I don't think I have a problem with the language being case-sensitive. I have a problem with the editor making me think about a detail that I have come to not have to worry about by using VB. VB may or may not be case sensitive, I wouldn't really know, but what's great is that I don't have to worry about it. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Anders Eggers-Krag" wrote in message news:o8kc5.203$rg.9815 at news101.telia.com... > I know that the VB IDE does this, but that is exactly because Microsoft > realised > that case sensitivity has advantages, and then they enforced case > sensitivity in a > way that is, agreed, in many ways smart. The real problem in Python does not > occur because of case sensitivity it occurs because you do not need to > declare > your variables. Case sensitivity is a good way way to keep the same case > across > different development platforms - the VB concept only works because if you > write > VB you use Microsofts VB IDE, not Ultra Edit, Emacs, notepad, Borland, you > name it. > Mircosofts system enforces IDE monopoly, which is anoying since I do not > like the Visual > studio IDE, I strongly prefer Borlands, or even better Ultra Edit. > > And the VB IDE concept could easily be implementet in a case sensitive > language as well. > > And one more thing, you do not need to remeber the case of any single > variable if you keep > a strict definition of how case should be used: in my case all new words > start with capital, > except the first word of a property, method or simple type - that way I am > never in doubt > as to 1: what type I am dealing with, 2: never in doubt as to what the case > is suposed to be used... > > -- > Anders Eggers - Krag > From bdupire at seatech.fau.edu Sat Jul 8 18:24:04 2000 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Sat, 08 Jul 2000 18:24:04 -0400 Subject: PyArg_NoArgs / PyArg_Parse API Message-ID: <3967AA04.6E5073BB@seatech.fau.edu> PyArgs_NoArg(args) is an API function, used in timemodule.c and not referenced in the documentation.. Actually, it's defined as a macro in Python.h and is equivalent to PyArg_Parse(args,"") I didn't see Py_ArgParse in the doc either! It 's not too difficult too imagine what is the role of PyArg_NoArgs ;-) But when I want to use it in the same way and when I link the C module statically: static PyObject * test_getstruct(PyObject * self, PyObject * args) { if (!PyArg_NoArgs(args)) return NULL; return PyString_FromString(example); /* example=global variable*/ } and when i type >>> import test_API >>> test_API.getstruct() Traceback (innermost last): File "", line 1, in ? TypeError: function requires no arguments (I work on Python 1.5.2 on QNX). Someone can explain me this error? It would be nice to add a little something about that in the online doc. Thanks a lot! Benoit From steffen.ries at sympatico.ca Sat Jul 29 10:16:47 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Sat, 29 Jul 2000 14:16:47 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <8lst4r02grr@news2.newsguy.com> Message-ID: grey at despair.rpglink.com (Steve Lamb) writes: > Nono, you misunderstand me. I prefer the Pascal notion of variables in > place in the string with formatting attached to it instead of placeholder > formatting strings with the variables hanging off the end of the string. > Pseudo code from no language, bear with me. > > "Here is a string with ",$a:d:0:0," variable in it." > > "Here is a string with %d:0:0 variable in it.",$a > > In the former I read and I see, "Oh, $a goes here with this formatting" > whereas in the latter it is "Oh, here is the formatting for... uhm.. $a." > > Again, simplistic and not in any language, but taken to the extreme you > can see the problem. > > "%d:0:0 %c:U %s %s %s %s %d %s %s %s \ > %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k > > What variable goes with what again? In this case I would use the dictionary variant of the format string: "%(a)0d %(b)c:U %(c)s %(d)s %(e)s %(f)s %(g)s %(h)s %(i)s %(j)s %(k)s"\ % vars() /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From popx at pop3.ifs.org.uk Tue Jul 11 13:41:42 2000 From: popx at pop3.ifs.org.uk (Jocelyn Paine) Date: Tue, 11 Jul 2000 18:41:42 +0100 Subject: INPUT TYPE=file in HTML Message-ID: Hi, I've been trying to read files uploaded from an HTML field using the CGI module. Are there known problems with this? The documentation says that if we take the value attribute of the form fields structure, it returns the entire contents of the file as a string. The file attribute returns a pointer to the file. But when I try this, I seem to get the filename as the value attribute, and nothing as the file attribute. The field is inside a form whose HTML arguments are just ACTION and METHOD, nothing else. The field has a TYPE argument whose value is "file", and a NAME attribute. And this combination of field and form works OK if I use it to pload a file to a Perl CGI. Thanks, Jocelyn Paine http://www.ifs.org.uk/~popx/ +44 (0)468 534 091 From donn at oz.net Wed Jul 26 01:22:58 2000 From: donn at oz.net (Donn Cave) Date: 26 Jul 2000 05:22:58 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com> Message-ID: <8llsji$60v$0@216.39.151.169> Quoth weeks at golden.dtc.hp.com ((Greg Weeks)): | Once upon a time, "pass by reference" meant that a function call f(x) could | modify the binding of the variable x. With this definition, "pass by | reference" effectively passes the address of the variable x to the | function. "pass by value", by contrast, passes only the value of the | variable x, not its address. | | With these definitions, Python is uniformly "pass by value". So are Lisp, | Java, and C, but not C++ and Perl. I don't know about that. But I see enough objections and amendments have been contributed already to send this one far out to sea, so I'll just add the observation that in Python usage, everything is by "reference". Any time an object is engaged in the program, it's through what we call a reference. The fact that a function call creates and passes these references is really a red herring, because it doesn't matter how they get there, by function or by import or whatever. What you see is always a reference, and operations on that reference have the same implications in every case. Donn Cave, donn at oz.net From dnotspam-jen at personic.com Sun Jul 2 18:22:33 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:22:33 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> <8jlmj0$r1q$1@supernews.com> Message-ID: <395fc264$0$5621@wodc7nh0.news.uu.net> Yes, I think for the first version I will do this (no need to deal with multi-threading or the network this way). But after the initial version works (hopefully later today), I'll try to move on to one of the other methods described above, probably starting with XML-RPC if I can find more info on it. Thanks, all! Jen "Dale Strickland-Clark" wrote in message news:8jlmj0$r1q$1 at supernews.com... > Start simple. > > Unless this is particularly time critical, I'd create a folder on the Build > server and share it with suitably limited access. > > Give the Web server write access to the folder. > > The Web server writes a batch file or Python script to the shared directory. > > Every few minutes the Build server checks this folder for a file and > executes it. > > If you need some feedback, it could change the name of the file or move it > to a subdirectory while it's running so the Web server can see it's active. > > -- > Dale Strickland-Clark > Out-Think Ltd, UK > Business Technology Consultants > > donotspam-jen at personic.com wrote in message > news:395d48b3$0$21842 at wodc7nh0.news.uu.net... > > FYI, I'm doing all of this on Windows NT, in case that makes a difference > > ... > > > > Is there a good way to get a script on one computer to talk to a script on > > another computer? The process I'm thinking of is pretty simple ... I want > a > > script on a Web server to be able to send a command to a build server to > > start a build process. I'd also like the Web server to be able to query > the > > build servers to find out their status (so that two builds do not run at > > once on the same machine, for example). > > > > I've read a little about SOAP, but I think that my needs are probably a > lot > > simpler than that. The easiest way to accomplish this is to setup a Web > > server on each of the build machines, too, I guess ... but I was hoping > that > > I could just have the scripts that run on the build servers run as NT > > services. > > > > Thanks! > > > > Jen > > > > > > > > > > From dale at out-think.NOSPAM.co.uk Sun Jul 9 09:11:51 2000 From: dale at out-think.NOSPAM.co.uk (Dale Strickland-Clark) Date: Sun, 9 Jul 2000 14:11:51 +0100 Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> Message-ID: <8k9tot$5o$1@supernews.com> Well, all this seemed to do was break an existing working program. I've had to delete the \gen_py folder to get things working again. I am confused now. Anyone got any idea how to use makepy? Thanks Dale Strickland-Clark "News.tele2.co.uk" wrote in message news:8k9o91$7b1$1 at supernews.com... > Well I've run it and it seemed to work but I'm not really sure what to do > next. > > In fact, I'm not entirely sure what it's supposed to do for me but I'm > hoping it will at least give me access to some COM object constants. > > Where is it documented? > > Thanks > > Dale Strickland-Clark > > > > From pisecky at tttech.com Wed Jul 26 11:36:10 2000 From: pisecky at tttech.com (Manfred Pisecky) Date: Wed, 26 Jul 2000 15:36:10 GMT Subject: Deleting files with wildcards Message-ID: <397f046d.193858654@news.atnet.at> Hello everyone! I have to delete a bundle of files, e.g. *.txt in a portable way (it must work for Linux and NT). I use Python 1.5.2. and have not found a way to either delete files with wildcards or to read the directory content (and do it file by file). Is there a portable way in 1.5.2 ? Thanks, Manfred Pisecky From to_get_my_address at see.my.signature Thu Jul 27 00:15:43 2000 From: to_get_my_address at see.my.signature (Greg Ewing) Date: Thu, 27 Jul 2000 17:15:43 +1300 Subject: Don't be too hard on those who want class methods (Re: Python is wierd!) References: Message-ID: <397FB76D.C05BD86B@see.my.signature> Christian Tanzer wrote: > > If you write code using classes as first-class objects, class > variables and methods can be very useful. This is a good point. Usually when people say that class methods are not needed, they're talking about C++ or Java style static methods. But Smalltalk-style class methods are a different species altogether. In Smalltalk, a class is also an instance (of class Class or some subclass thereof), so aClass frobulate: aBlivet is dynamically dispatched on the runtime class of aClass, just like any other message. There is no direct equivalent of this in Python, because classes are not instances, they're a different kind of object. The suggestion by Moshe Zadka: > > class Function: > > > > def __init__(self, func): > > self.func = func > > > > def __call__(self, *args, **kw): > > return apply(self.func, args, kw) > > > > class SomeClass: > > > > def class_method(a, b, c): > > return a+b+c > > > > class_method = Function(class_method) isn't quite the same thing, because there is no 'self' in scope in the method which is bound to the receiving class object (which might be a subclass of SomeClass, so you can't just assume that it's SomeClass). There are no doubt even more convoluted hacks that could be used to fix that, but in 999,999,999 cases out of a billion it's probably better to revise your design so that you don't need class methods in the first place. -- Greg Ewing, Computer Science Department, University of Canterbury, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From hylton at grundriss.freeserve.co.uk Sat Jul 29 05:47:23 2000 From: hylton at grundriss.freeserve.co.uk (hylton) Date: Sat, 29 Jul 2000 10:47:23 +0100 Subject: help with Distutils install please? Message-ID: <3982A82B.B1C2DAA@grundriss.freeserve.co.uk> hi, I want to install numpy and apparently I need to use Distutils to do this. [hylton at localhost Distutils-0.1.3]$ python setup.py install running install Traceback (innermost last): File "setup.py", line 13, in ? setup (name = "Distutils", File "distutils/core.py", line 102, in setup raise SystemExit, "error: %s: %s" % (exc.filename, exc.strerror) AttributeError: filename This is from a user dir on RH6.0 box. is this maybe a path problem? Hylton From slinkp23 at yahoo.com Sun Jul 9 21:04:24 2000 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sun, 09 Jul 2000 21:04:24 -0400 Subject: Namespace weirdness References: <3968E1B0.B6E6F3E9@yahoo.com> <8F6CECA93gmcmhypernetcom@199.171.54.194> Message-ID: <39692118.9D6EAFAA@yahoo.com> Gordon McMillan wrote: > > Paul Winkler wrote: > >class Food: > > def __init__(self, attr1): > > self.attr1 = attr1 > > class BodyPart: > > def do_it(self): > > # This next line is a stand-in for what I want... > > print my_parent_namespace.attr1 > > Python doesn't nest class definitions (or function defs) in a way that is > particularly interesting. Your code creates a class object which is > accsessible as Food.BodyPart, but BodyPart has no idea it was defined > inside Food. As far as it's concerned, it is toplevel. That's what I was afraid of. It does have the useful quality that it's unrelated to any BodyPart in other namespaces, which is why I put it in there. Oh well. > But there is absolutely no cannibalism in Python. None at all. "Cannibalism" = classes eating classes? not sure what you mean, sorry. Thanks for the comments. -- ................. paul winkler .................. slinkP arts: music, sound, illustration, design, etc. web page: http://www.ulster.net/~abigoo A member of ARMS: http://www.reacharms.com or http://www.mp3.com/arms From mlh at idi.ntnu.no Wed Jul 19 16:19:28 2000 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 19 Jul 2000 22:19:28 +0200 Subject: Python in game development? References: <963990339.783645@marvin> <8l4h60$jnk$2@gxsn.com> <8l4isr$l58$2@newshost.accu.uu.nl> Message-ID: <8l52hs$i05$1@kopp.stud.ntnu.no> > > Be sure to check out stackless Python, which has some advantages for > game scripting: > > http://www.stackless.com/ What exactly *are* these advantages? (Very curious...) > Regards, > > Martijn > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? From Vladimir.Marangozov at inrialpes.fr Tue Jul 18 19:31:25 2000 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Wed, 19 Jul 2000 01:31:25 +0200 Subject: Python-dev summary: July 1-15 References: <20000718100813.C21354@newcnri.cnri.reston.va.us> Message-ID: <3974E8CD.55215FD9@inrialpes.fr> David Bolen wrote: > > Andrew Kuchling writes: > > > This is a first experiment in whether I can make a useful, > > interesting, somewhat coherent summary of python-dev activity. > > If reaction is favorable, and time permits, it may become a biweekly > > posting. > > This seems quite useful - is there any "proper" way to send feedback > on mail on python-dev without actually being on the list? > Yes. It's the comp.lang.python newsgroup. Pick up an issue, give it a meaningful subject line (eg. Subject: Re: PEP 201 - Parallel iteration) and discuss it. Most people on python-dev read the newsgroup regularly and forward to the python-dev list some of the issues that have been brought here. So there's feedback from the group to python-dev and there's a natural selection of the topics that need python-dev's attention. This "selection" is a matter of experience -- some topics are recurrent in Python's life and not all posters in c.l.py are aware that they have been discussed extensively in the past. The reverse wasn't true and the python-dev summary documents are intended to inform a broader audience, notably the Python community, on its current activities. The natural place for discussing all topics brought on python-dev is the comp.lang.python newsgroup. This is also the place where the python-dev members are looking for feedback. For instance, read the PEP documents -- they summarize recent and past proposals for various enhancements. All python-dev members are interested in seeing them discussed by the community. So don't hesitate to take a stance on a PEP if you think that you could share an educated opinion. -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From neilh at scintilla.org Mon Jul 10 22:52:53 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 11 Jul 2000 02:52:53 GMT Subject: Can anyone hear me? (was Solution to IDLE and Tkinter proble References: <200007110229.TAA20898@stevie.loop.com> Message-ID: <9_va5.13290$Tb7.89359@news-server.bigpond.net.au> > However, I don't think it is the interpreter itself, because it can > start much quicker when not run through os.system. I read a recent > thread about os.system which said it was slow because it loaded a > shell to run in. If starting up a shell is slow check your path. Too long a path or a path that includes networked volumes or floppy/zip drives can slow things down a lot. Neil From peter at schneider-kamp.de Wed Jul 19 01:24:37 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 05:24:37 +0000 Subject: Python 2.0 - win32pipe routines inclusion for Windows References: Message-ID: <39753B95.B17B988F@schneider-kamp.de> David Bolen wrote: > > I've noticed that the latest sources for Python 2.0 in CVS have > included the win32pipe code from the PythonWin extensions as a > replacement for the prior os.pipe() routine in Python 1.5.2. One > consequence of this is that you no longer receive process exit codes > on the pipe.close() operation. Since I need the result codes in my > work, and work under Windows NT primarily, I figured I'd try to do > something about it. Excellent! That's Open Source at its best. > I've created a small patch to the latest posixmodule.c in CVS that > uses an internal dictionary to maintain a mapping between created > pipes and child processes so it can retrieve the exit code, and was > wondering if this is something that should just be submitted to the > SourceForge patch manager or if there is any other process for Python > 2.0 (this is my first non-R/O poke at the sources). You got three possibilities: - Just follow the guidelines at http://python.org/patches. - Look at the Python at Source Forge FAQ: http://python.sourceforge.net - just submit it, because that's what they tell you > While munging around in the source it also appears that there seems to > be a mismatch between the ordering of file handles returned by the > higher order popen# routines in the internal posixmodule (the > win32pipe routines) versus the current popen2.py library module. I > think I saw a discussion about this in the python-dev archives, but it > wasn't clear if the two should be consistent at this point in the > repository. I can't comment on this one. If no one answers in the next days, maybe you should send this question to python-dev at python.org. Note that at least 120% of python-dev are at OSCON. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From m.faassen at vet.uu.nl Mon Jul 31 04:56:56 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 31 Jul 2000 08:56:56 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <8luhsi01ce8@news2.newsguy.com> <8m26fm$ila$4@newshost.accu.uu.nl> Message-ID: <8m3f0o$hn6$1@newshost.accu.uu.nl> Steve Lamb wrote: > On 30 Jul 2000 21:25:10 GMT, Martijn Faassen wrote: >>Then have your program catch your exceptions! That's one of the main >>reasons for the existence of the exception handling mechanism; to recover >>gracefully from the unexpected. >>It is possible to catch *all* exceptions, if you're worried about that. >>Or whole groups of exceptions, if you like. They're in a hierarchy. > However I find that exceptions come up on the damnedest things, break you > out of loops, cause problems all around and don't let you return to where you > were, esp. when you use general catch all exceptions. As Alex(?) said, you > don't return to where you were so, to me, it seems quite impossible to be able > to catch /all/ exceptions gracefully, ever. Well, I have lots of working Python software still. :) In the presence of bugs in your code, you cannot catch all exceptions *gracefully*. This is because you do not know where all your bugs are. Bugs are not graceful, period. As pointed out to you before, you seem to overestimate the amount of exceptions you need to catch, to handle gracefully or not. Let's try to classify exceptions: 1. A test. You expected this exception and check for it, such as in try: b = int(b) except ValueError: b = 0 2. Unexpected external conditions you didn't think of (file turned out to be locked, etc). 3. an assumption about the structure of input that turns out to be wrong. i.e., a bug. 4. a mistake in your code. You call a nonexistent function, refer to nonexistent variables, your algorithm is just wrong, etc. i.e., a bug. Category 1 exceptions are no problem; you handle them. Category 2 exceptions are the most tricky. They may hint at a bug (you should have checked whether the file was locked). What *is* sure is that you usually cannot continue gracefully; you can't write to the locked file and you need to, or whatever. Ungraceful handling can be implemented with some outer exception handler, or it can be accepted that the program can fail under these circumstances. If it *does* turn out you can continue gracefully, you can only continue gracefully if you catch the exception and handle it, in which case it turns into a variety of category 1. You really fixed a bug in that case. Note that category 1 and category 2 exceptions generally do not happen all over your code. You factored out your code well and these things only happen in specific places. You don't have to place handlers all over the place. Category 3 and 4 are bugs. Bugs cannot be handled gracefully. Again you have two options; have the program stop in the face of a bug, or do a catch-all and try to continue anyway. In the light of that, let's translate what seem to be saying: """ However I find that bugs come up on the damnedest things, break you out of loops, cause problems all around and don't let you return to where you were [in the algorithm], esp. when you use general catch all exceptions. As Alex(?) said, you don't return to where you were so, to me, it seems quite impossible to be able to catch /all/ bugs gracefully, ever. """ The answer to that is easy: No, of course not. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul.magwene at yale.edu Thu Jul 20 13:22:33 2000 From: paul.magwene at yale.edu (Paul Magwene) Date: Thu, 20 Jul 2000 13:22:33 -0400 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> Message-ID: <39773559.77C3D696@yale.edu> Tim Hochberg wrote: > > Gregory Lielens writes: > > > Tim Hochberg wrote: > [...] > > I like the parethese a lot! except for ? which is probably out of > > question, > > this is the prettier way to do it, but (alwas a but :-( ) > > > > - the solve operator indeed...The only thing i can come with is the ugly > > (%) > > or the pretty but out-of-question (\) > > My favorite right now is |. So one would have: > > A[*]B # matouter > A(*)B # matinner > A(/)B # matdiv > A(|)B # matsolve > A(^)B # matpower > > Alternatively, one could use: > > A(*)B # matouter > A(.)B # matinner (AKA dot, get it?) > > That would cut down on the available symbols, but might make parsing > easier? It might also be easier to distinguish between the two > products. > > I've left out other potential outer operators (outer sum, etc) and > alternate inner products (Lie, Kroneker, ?) pending finding a > constituency for them. Kronecker products get used enough (at least in statistics) that I'd hope we'd include 'em (we're already on our way down the slippery slope, so I may as well lobby for operators *I* want ;-). How about: A{*}B # matkron (Paralleling A[*]B for matouter, and A(*)B for matinner) -- Paul Magwene paul.magwene at yale.edu From spam at spam.com Wed Jul 26 20:38:50 2000 From: spam at spam.com (Penfold) Date: Thu, 27 Jul 2000 01:38:50 +0100 Subject: How to create COM Servers with IID_IDTExtensibility2 interface Message-ID: Any win32 COM gurus here ? :-) [eg Mark Hammond ;-) ] What I am trying to do: Create an in-process COM Server capable of being used by Excel as a "COMAddin" According to a very small demo I have downloaded from Microsofts website, for a COM object to be used by excel as a COM Addin it must implement the interface IID_IDTExtensibility2. I know the GUID for this interface and its "defined methods". How can I do this? All of the examples I have read in pythonwin (build 132 on python 1.5.2) imply that you can only create objects with particular interfaces that are defined in the pythoncom module itself eg IID_IDispatch, IID_IConnectionPoint etc Now pythoncom.IID_IDTExtensibility2 is not a defined variable. So is there any way I can go about registering an object as satisfying this specific interface?? Any help appreciated, Des From mrinal at my-deja.com Tue Jul 4 03:41:06 2000 From: mrinal at my-deja.com (mrinal at my-deja.com) Date: Tue, 04 Jul 2000 07:41:06 GMT Subject: Worldpilot Message-ID: <8js4ef$v4n$1@nnrp1.deja.com> Hi, Has anybody tried Worldpilot here? I'm having issues with DateTime.py - it doesn't seem to work with my timezone (IST - +05:30). Has anybody worked around this problem? Any patches available for it? Please cc on replies.. -- Mrinal Kalakrishnan mrinal at india.com http://mrinal.dhs.org/ Sent via Deja.com http://www.deja.com/ Before you buy. From ldw at us.ibm.com Tue Jul 25 11:59:33 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Tue, 25 Jul 2000 10:59:33 -0500 Subject: Memory management Message-ID: <8lkdh5$qpm$1@news.rchland.ibm.com> I'm running out of virtual memory on my NT 4.0 system running a longish python script. Python says "memory error" and quits. NT shows the application using 130+ megabytes. I have 192 megabytes on the system so it seems like a rational number. I suspect that this means that I have a memory leak in my code. In the outer loop of my code, I create a object of a class I have defined. The outer loop reads records from a trace file and hands them to the object created for execution. This first level object creates a number of second level objects of a different class while processing the trace file. When the trace file is complete, the outer loop deletes the first level object. I am expecting that to cause all of the references held by that object, and those of the second level objects is created to go to zero. Here's a programmtic description: def outerloop: # make a list of trace files to process for file in infiles: o1 = FirstLevelClass( some, parameters) # create the object that will process the trace record o1.runTrace( file ) o1.report() del o1 class FirstLevelClass: def __init__( self, some, parameters): aDict = {} # these get filled over time aList = [] def run(file): ... o1a = SecondLevelClass( some, parameters) ... class SecondLevelClass def __init__(self, some, parameters) aDict = {}# these get filled over time aList = [] My question: How do I get rid of the memory used by o1 and by o1a, o1b, etc within o1 when each trace file is processed? Larry From paul at prescod.net Mon Jul 17 01:16:44 2000 From: paul at prescod.net (Paul Prescod) Date: Mon, 17 Jul 2000 00:16:44 -0500 Subject: Type checking in python? References: Message-ID: <397296BC.415C97E1@prescod.net> Matthew Cline wrote: > > def my_func(foo, bar, quux): > if not isinstance(quux, Quux): > raise RuntimeError("param 'quux' must be of class 'Quux'") Let me also point out that in many cases, this style of programming would be frowned upon by serious Python programmers. For instance, if you check that something is a string, your code will complain when it is handed a Unicode string, even though it would probably work fine. If you check that it is an open file, then your code probably will complain about stringIO file-like objects, even though it would probably work fine. If you check that it is an integer, your code will complain about integers, even though ti would probably work fine. In general, the Python philosophy is to "just try it" and see if it works. Sometimes type checks are appropriate but if you do it on the entry to every function, you are probably doing too much work and making your own life (or someone else's) harder later on. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From hzhu at localhost.localdomain Tue Jul 11 15:24:53 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 11 Jul 2000 19:24:53 GMT Subject: off-topic, "Compiler" technology References: <396ABBD7.8715465D@t-online.de> Message-ID: On Tue, 11 Jul 2000 08:16:55 +0200, Andreas Otto wrote: > > The underlying technology "Token-Stream" works for all > scripting languages like *perl* or *python* too. > I think if a compiler is available right now, more than half of the users would be interested, especially if the speed gain is large. OTOH, judging from some prior discussions here, not many developers would put in serious effort until a working prototype is here, as many don't believe it's feasible to achieve much. If you think you can do it all by yourself, but you only lack funding, the best way might be to contact PythonLab. The maintainer's of python might share their hard-earned funding if they judge that a compiler would help to attract more users, esp so-called enterprise users. Maybe there are other ways. I don't know. Just my 2 cents. Huaiyu From jessw at loop.com Mon Jul 10 15:26:35 2000 From: jessw at loop.com (Jesse W) Date: Mon, 10 Jul 2000 19:26:35 +0000 Subject: Can anyone hear me? (was Solution to IDLE and Tkinter proble In-Reply-To: <_Lua5.13223$Tb7.89061@news-server.bigpond.net.au> Message-ID: <200007110229.TAA20898@stevie.loop.com> Dear Neil, First, thank you very much for replying. I was beginning to think I was just screaming into the void. :-) > This may just be the slow python.exe startup because of multimedia > problem. If Python is also slow to start up from the command line However, I don't think it is the interpreter itself, because it can start much quicker when not run through os.system. I read a recent thread about os.system which said it was slow because it loaded a shell to run in. Thank you for replying, Jesse W From kuncej at mail.conservation.state.mo.us Thu Jul 13 10:52:31 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Thu, 13 Jul 2000 09:52:31 -0500 Subject: INPUT TYPE=file in HTML References: Message-ID: > I've been trying to read files uploaded from an HTML > field using the CGI module. Are there known problems with this? I have an example cgi script that both creates a form and accepts an upload. See: uplddemo_cgi.py At: http://starship.python.net/crew/jjkunce/ You will need to rename it to uplddemo.cgi, and adjust the global variables as explaind in the doc string. It's been a while since I actually tried it, but it used to work! --Jeff From ppessi at hut.fi Fri Jul 21 14:35:56 2000 From: ppessi at hut.fi (Pekka Pessi) Date: 21 Jul 2000 21:35:56 +0300 Subject: Getting local IP address... References: <3bRK54$kCF@openbazaar.net> Message-ID: mfletch at tpresence.com.bbs@openbazaar.net (Mike Fletcher) writes: >def getLocalHostIP( remote = ("www.python.org", 80)): > '''Get the "public" address of the local machine, i.e. > that address which is connected to the general internet. > Code by Donn Cave, posted to comp.lang.python''' > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect( remote ) > ip, localport = s.getsockname() > s.close() > return ip >That is actually from a Deja posting, seems to be fairly portable, doesn't >rely on parsing obscure Unix command responses, is readable, and is >generally quite reliable. The more common socket-module-based approach (see >Deja) can be confused if you have multiple network interface cards, but is >still portable (i.e. if you only have a single network interface card, it >should work on all system supporting the socket module). I have been using a piece of code like this: def gethostaddr(dst = '224.0.1.41'): s = socket.socket(AF_INET, SOCK_DGRAM) try: s.connect((dst, 7)) (host, port) = s.getsockname() s.close() if host != '0.0.0.0': return host except error: pass return socket.gethostbyname(socket.gethostname()) As an added bonus, no extra connection - UDP just binds the socket to your local address. If not, like MS Winsock, it tries true and tried gethostbyname(gethostname()) trick. -- Pekka.Pessi at hut.fi From db3l at fitlinxx.com Fri Jul 21 14:46:42 2000 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jul 2000 14:46:42 -0400 Subject: Python on Win32: How to freeze? How to hide the system console? References: <8la2o6$hfu$1@pollux.ip-plus.net> Message-ID: "Franz GEIGER" writes: > New to Python I have 2 q's: > > 1) Does anybody "freeze" his Python scripts dev'ed on and for Windows > machines? How? Is Tkinter code freezed too? What's the result? A single EXE > file? I don't do freezes myself, but if you're just trying to come up with a clean distribution mechanism there are some other alternatives. The one I prefer is using an installer package from Gordon McMillan: http://www.mcmillan-inc.com/install1.html This automatically tracks down the various dependencies of your script and puts it all together (along with some very nice archive formats for the various library routines) into an executable that self-extracts itself when it runs. You generally end up with the exe, a pyz for python library files a few standlone files (like exceptions.pyc) and any external modules (dll/pyd). That collection of files is all you need to run your application. The installer package has a simple installation script (console based - prompts for a directory and unpacks), but you can combine the installer with a Windows installation package (on the free side, for example, Inno Setup: http://www.jrsoftware.org and you end up with your Python application looking just like a native installed Windows application, and being totally self-contained within its installation directory. Users install/uninstall it just like any other Windows application. > 2) How can I hide the system console on a Windows machine running a Python > script using Tkinter? Use pythonw rather than python to start your script. (If using the installer package, it has a configuration file option to use a "runw" module to start the script rather than "run" for the same purpose). -- -- 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 jepler.lnk at lnk.ispi.net.bbs Sun Jul 16 22:00:01 2000 From: jepler.lnk at lnk.ispi.net.bbs (jepler.lnk at lnk.ispi.net.bbs) Date: 17 Jul 2000 02:00:01 GMT Subject: Discussion: Introducing new operators for matrix computation Message-ID: <3bQhU4$j5f@openbazaar.net> On Sat, 15 Jul 2000 04:29:09 GMT, Huaiyu Zhu wrote: >That's the beauty of numerical computation, because all kinds of >applications, from animation on your screen to controlling satallite in >space to analysing molecular structures to calculating consumer preference >could all be expressed in the language of linear algebra. (Mathematicians >study spaces more abstract than linear spaces, but you wouldn't want to hear >about them before appreciating the usefulness of linear algebra.) For >example, all deterministic procedures are functions, and most functions we >see are simply points in an (infinite dimensional) space. That's the beauty of procedural programming, because all kinds of applications, from animation on your screen to controlling a satellite in space to analyzing molecular structures to calculating consumer preference could all be expressed in the language of procedural programming. (Programmers study programming languages more abstract than functional programming, but you wouldn't want to hear about them before appreciating the usefulness of procedural programming.) For example, all deterministic processes are expressible as Turing machines, and most turing machines we see are simply expressible in procedural languages. Jeff From nowonder at pool.informatik.rwth-aachen.de Tue Jul 25 02:23:49 2000 From: nowonder at pool.informatik.rwth-aachen.de (Peter Schneider-Kamp) Date: Tue, 25 Jul 2000 06:23:49 +0000 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> Message-ID: <397D3275.244A48C@pool.informatik.rwth-aachen.de> David Bolen wrote: > > I still occasionally miss the trailing braces at the bottom of heavily > indented blocks, if only as a place to "hang" my comments about what > block they are closing - of course that very construct was because > even in C/C++ it was far from clear in some cases from just looking at the > brace :-) Then just use Tools/scripts/pindent.py BTW: If you ever mess up your indentation, but you still have valid #end directives, you can reindent easily. As a bonus you will be able to reformat your code to different tab/space settings. Quoting from the CVS version: *** usage: pindent (-c|-d|-r) [-s stepsize] [-t tabsize] [-e] [file] ... -c : complete a correctly indented program (add #end directives) -d : delete #end directives -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) -e : expand TABs into spaces (defailt OFF) [file] ... : files are changed in place, with backups in file~ If no files are specified or a single - is given, the program acts as a filter (reads stdin, writes stdout). *** Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From gee308 at mediaone.net Sat Jul 22 02:46:03 2000 From: gee308 at mediaone.net (Toy) Date: Sat, 22 Jul 2000 06:46:03 GMT Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> <210720002132510070%matt@mondoinfo.com> <39794752.D54A50CD@mediaone.net> Message-ID: <39794839.37A04FA2@mediaone.net> I just tried to use os.system, and I couldn't get it to work. import os test = 'eth0' os.system('ifconfig',test) results: Traceback (innermost last): File "", line 1, in ? TypeError: string, tuple How can I do the ifconfig while also passing variables? Thanks. Toy wrote: > Thanks for showing me how to do that. I tried to edit something, but it > didn't work, I'll show you: > > def getMyAddr(): > object = raw_input(Which device is connect to the internet(i.e. ppp0, eth0, > ne3: ") > p=os.popen("/sbin/ifconfig",object) > > Is it possible to do that? Will it work with os.system? What are the > differences bewteen using os.popen and os.system? Thanks for your time. > BTW, I only compared OpenBSD 2.7, Linux 2.2.15, and FreeBSD 4.0, but it seems > if you do the string search on ifconfig with find text on 1 line beginning > with inet and ending with mask, It looks like you can get the IP from those 3 > machines.(of coure I still can't write some code to actually do it). Thanks > again. > Jason Toy > > Matthew Dixon Cowles wrote: > > > In article <3978FD9D.B08460CB at mediaone.net>, Toy > > wrote: > > > > > How can I make python issue the command, "ifconfig -a eth0", and then > > > parse the data to grab the IP? I would think that you could tell Python > > > to look for the word, 'inet addr:"(is it different on different Unixes?) > > > and then tell it to get a number right after 'inet addr' that looks like > > > xx.x.xxx.xxx !! Simple Q, but I'm new, thanks. > > > > Something like this should work for you: > > > > import os > > import string > > import re > > import sys > > > > def getMyAddr(): > > p=os.popen("/sbin/ifconfig ep0") > > l=p.readline() > > while l<>"": > > if string.strip(l)[:5]=="inet ": > > matchObj=re.search("\d+.\d+.\d+.\d+",l) > > p.close() > > return matchObj.group(0) > > l=p.readline() > > p.close() > > return "not found" > > > > def main(): > > print getMyAddr() > > > > if __name__=="__main__": > > main() > > > > You'll also notice that the answer to your second question is yes. The > > format of the output of ifconfig is different from Unix to Unix. The > > above example works on FreeBSD. You will need to fiddle it some to get > > it to work under Linux. > > > > Another way to get the local IP is to use the functions in the socket > > module: > > > > >>> import socket > > >>> socket.gethostbyaddr(socket.gethostname())[2][0] > > > > But how to do that varies from machine to machine too. The code above > > works correctly on my FreeBSD box but on my Linux laptop it returns > > 127.0.0.1. In order to make it work right on that machine, I need to > > ask for the address of the hostname only, not the FQDN: > > > > >>> socket.gethostbyaddr(socket.gethostname() > > >>> [:string.find(socket.gethostname(),".")])[2][0] > > > > If there's a portable way of getting the local IP address, I don't know > > what it is. > > > > Regards, > > Matt From ge at nowhere.none Thu Jul 20 11:18:02 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 20 Jul 2000 15:18:02 GMT Subject: Advice sought: text-mode (but not CLI) apps in Windows console ? References: <8F7682C13PaCmAnRDLM@195.25.12.37> <8F7765F6DPaCmAnRDLM@161.48.76.20> Message-ID: In article <8F7765F6DPaCmAnRDLM at 161.48.76.20>, Fred Pacquier wrote: >ge at nowhere.none (Grant Edwards) said : > >>There is a nice widget set called newt (with a Python binding >>called snack) that uses slang. If slang is available under >>Win32, then it should be possible to use newt/snack. > >Thanks (again). Unfortunately, s-lang looks like it's >cross-platform, but newt does not, unless I'm mistaken. Newt was (AFAIK) written by RedHat for use in their installer and system utils, so I wouldn't be surprised if it's pretty Linux-centric. >This stuff is certainly well-hidden and is hardly stumbled >across of you don't already know of it :-) Too true. Newt and snack are both pretty nifty, but I've never tried to use them on anything except Linux, and you probably won't find them on non-RH-derived systems. >Sadly, all this is much too cryptic for the sort of casual use >I had in mind -- it would actually be faster for me to dig out >the win32 extensions and do regular Windows, which I wanted to >avoid in the first place :-) If you want something easy to use, Tkinter is probably as simple as anything (and certainly simpler than curses). -- Grant Edwards grante Yow! Well, O.K. I'll at compromise with my visi.com principles because of EXISTENTIAL DESPAIR! From matt at mondoinfo.com Sat Jul 22 14:45:34 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 22 Jul 2000 13:45:34 -0500 Subject: newb Q References: <3978FD9D.B08460CB@mediaone.net> <210720002132510070%matt@mondoinfo.com> <39794752.D54A50CD@mediaone.net> Message-ID: <220720001345342915%matt@mondoinfo.com> In article <39794752.D54A50CD at mediaone.net>, Toy wrote: > Thanks for showing me how to do that. I tried to edit something, but it > didn't work, I'll show you: > > > def getMyAddr(): > object = raw_input(Which device is connect to the internet(i.e. ppp0, eth0, > ne3: ") > p=os.popen("/sbin/ifconfig",object) > > Is it possible to do that? It's possible to do something like that. The argument to os.popen (and to os.system) needs to be a character string. So you need to build up the string so that it looks just like what you'd type at the keyboard. The string concatenation operator is +, so you'd do something like: dev=raw_input("Device name? ") p=os.popen("/sbin/ifconfig "+dev) > Will it work with os.system? What are the differences bewteen using > os.popen and os.system? os.system is similar to os.popen in that both execute a command of the sort that you'd ordinarily type at a shell prompt. They're different in that os.system just executes that command and if the command produces any output, it's printed in your shell window, while os.popen (if you accept its default) returns a file-like object that you can use to read the output that the command produces and use it in your program. > BTW, I only compared OpenBSD 2.7, Linux 2.2.15, and FreeBSD 4.0, but it seems > if you do the string search on ifconfig with find text on 1 line beginning > with inet and ending with mask, It looks like you can get the IP from those 3 > machines.(of coure I still can't write some code to actually do it). In situations like this, it's generally possible to find some mechanism that works almost all of the time. It's also almost always the case that eventually something that you were depending on will change and you'll have to fix your code. Regards, Matt From jvickroy at sec.noaa.gov Mon Jul 17 14:14:34 2000 From: jvickroy at sec.noaa.gov (j vickroy) Date: Mon, 17 Jul 2000 12:14:34 -0600 Subject: Event set/clear/wait Message-ID: <39734D0A.C40861A9@sec.noaa.gov> How can software be written to determine when it is "safe" to *clear* a threading.Event that has previously been *set*? Do I even need to consider this? Thanks for your interest. -- jv P.S. "safe" is intended to convey the notion that all threads issuing a *wait* on the event are no-longer blocking because of it. From stephen_purcell at yahoo.com Wed Jul 12 21:04:02 2000 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 13 Jul 2000 01:04:02 -0000 Subject: Switching to Linux...... converting files and databases.... In-Reply-To: Message-ID: <8kj4i2+2fuo@eGroups.com> ge at n... (Grant Edwards) wrote: > > FYI, there are alread some projects like that: catdoc, > mswordview, (other things for excel and ppt files). One of the > projects (can't remember the name) is a library of routines to > read/parse MS Office output. You're probably thinking of the WV library: http://www.wvware.com/ -Steve -- Steve Purcell, Technical Director, Inkontact Get in touch at http://www.inkontact.com/ Get testing at http://pyunit.sourceforge.net/ "Life must be simple if I can do it" -- Me From mfletch at tpresence.com Thu Jul 6 14:46:13 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 6 Jul 2000 14:46:13 -0400 Subject: Undocumented regex behaviour in re module Message-ID: No Chris! Don't you realise this is a setup by the PSU to catch people trying to use unauthorised time machines to slip stackless into the codebase? If someone's going to do this it should be one of us expendable people. I hereby volunteer (now where was that racing form, anyway). *poof* <-- see what happens when you fool with time machines kids -----Original Message----- From: Christian Tismer [mailto:tismer at appliedbiometrics.com] Sent: Thursday, July 06, 2000 2:30 PM To: Darrell Gallion Cc: Dave Cole; python Subject: Re: Undocumented regex behaviour in re module ... Please, share your time machine with us :-) ... From eben at ids.net Fri Jul 21 18:40:17 2000 From: eben at ids.net (Eben Oldmixon) Date: Fri, 21 Jul 2000 18:40:17 -0400 Subject: 5.2.1 fails 5 tests: SGI Indigo-2 IRIX 6.2 gcc -O2 Message-ID: <3978D151.8208C03B@ids.net> Can somebody comment on these failures from the Python 5.2.1 distribution test suite? I found mention of an error from test_re under SunOS in the Deja News archives, nothing from python's test_long, and didn't look further. Are these likely to turn and bite? I installed anyway. I particularly like the non-overflowing of maxint+1, although '+-1' (!) is a close second. #file: error_msgs #errors from build of Python 5.2.1 on SGI Indigo-2 under IRIX 6.2 # using gcc -O2 # errors from: # test_grammar # test_builtin # test_types # test_long # test_re python test_grammar.py 1. Parser 1.1 Tokens 1.1.1 Backslashes 1.1.2 Numeric literals 1.1.2.1 Plain integers Traceback (innermost last): File "test_grammar.py", line 44, in ? elif eval('maxint == 9223372036854775807'): OverflowError: integer literal too large error_msgs Traceback (innermost last): File "test_re.py", line 63, in ? raise TestFailed, "re.sub" test_support -- test failed: re.sub 4. Built-in functions test_b1 __import__ abs apply callable chr cmp coerce compile complex delattr dir divmod eval execfile filter float getattr hasattr hash hex id int Traceback (innermost last): File "test_builtin.py", line 9, in ? impo6. Built-in types 6.1 Truth value testing 6.2 Boolean operations 6.3 Comparisons 6.4 Numeric types (mostly conversions) 6.4.1 32-bit integers 6.4.2 Long integers Traceback (innermost last): File "test_types.py", line 85, in ? else:raise TestFailed, 'long op' test_support -- test failed: long op rt test_b1 File "test_b1.py", line 287, in ? raise TestFailed, "int(%s) raised ValueError: %s" % (`ss`, e) test_support -- test failed: int('+-1') raised ValueError: invalid literal for int(): +-1 6. Built-in types 6.1 Truth value testing 6.2 Boolean operations 6.3 Comparisons 6.4 Numeric types (mostly conversions) 6.4.1 32-bit integers 6.4.2 Long integers Traceback (innermost last): File "test_types.py", line 85, in ? else:raise TestFailed, 'long op' test_support -- test failed: long op python test_long.py long / * % divmod long bit-operation identities long str/hex/oct/atol long miscellaneous operations Traceback (innermost last): File "test_long.py", line 251, in ? test_misc() File "test_long.py", line 235, in test_misc raise TestFailed, "int(long(sys.maxint) + 1) didn't overflow" test_support -- test failed: int(long(sys.maxint) + 1) didn't overflow Running tests on re.search and re.match Running tests on re.sub Traceback (innermost last): File "test_re.py", line 63, in ? raise TestFailed, "re.sub" test_support -- test failed: re.sub From do.not.email at hotmail.com.bbs Mon Jul 17 18:20:03 2000 From: do.not.email at hotmail.com.bbs (do.not.email at hotmail.com.bbs) Date: 17 Jul 2000 22:20:03 GMT Subject: problems trying wxPython in Win 95 Message-ID: <3bRRJ6$kCD@openbazaar.net> Thanks for the tip. I have Win98 and the wxdemo didn't work. Now I tried again, and in a console window appeared following message: "Can't create window of class wxCanvasClass! Possible Windows 3.x compatibility problem?" In the MS Windows standard error message was "WX21_15.DLL" mentioned. I searched on my hard disk and there were both Wx21_15.dll and Wx21_16.dll. I removed and reinstalled wxPython, and now the demo didn't crash. And the Wx21_15.dll had disappeared. So the problem may be in it. Thanks. "Darrell Gallion" wrote in message news:000701bfef98$9f658040$6401a8c0 at home... > My experience with this isn't recent. > But last I checked wxPython didn't work with 1.6, don't know about 2.0. The > demo will work with 1.5.2. I'd suggest uninstalling wxPython, rebooting and > reinstalling it. I had a problem like this when upgrading from the last > version of wxPython. > From tim_one at email.msn.com Sat Jul 22 02:52:13 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 22 Jul 2000 02:52:13 -0400 Subject: compiling Python 1.6a2 using VC++ 6.0 In-Reply-To: <3bRbQR$m5X@openbazaar.net> Message-ID: [falk.lehmann at gmx.net.bbs@openbazaar.net] > I try to compile Python 1.6a2 on a WinNT box using VC++ 6.0. > All packages except bsddbmodule and socketmodule compile without errors. > > When I add the include path of the the db-3.1.14 distribution to > ..\db-3.1.14\build_win32 the following error messages appear. I have > tried to include other header files then db.h but nothing works. > ... The PCbuild\readme.txt file in the current CVS tree is more explicit about this: bsddb Python wrapper for the BSD database 1.85. Requires db.1.85.win32.zip, from the "bsd db" link at http://www.nightmare.com/software.html That's the last version anyone ever bothered porting to Windows for Python. From tim.hochberg at ieee.org Thu Jul 20 11:37:36 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 20 Jul 2000 15:37:36 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> Message-ID: Robin Becker writes: > people keep talking about matrix operations as though there is only one > way to do one kind of matrix multiply; I use at least two (inner, outer) > commonly, but others eg Kronecker or Lie are certainly in use. I don't > think any proposal which doesn't address this is likely to get my vote. Well Konrad mentioned [x] or (x) which gives you a lot more symbolic room. For instance one could use [x] for outer products since you can take an outer "product" with essentially any operation. (*) would be matrix multiply, (/) would be matrix "divide", we'd still be searching for a solve operator though. (.) Could be some other inner product. Although, there's a fair amount of "symbol" space in this kind of operator scheme, but there's still an issue in that for dimensions greater than two, there's no way to specify which axis to apply the inner products on. I'm not sure there's any good way to do that with infix notation though. Why don't you propose something that would fit your needs? Rambling, -tim From Bill.Scherer at VerizonWireless.com Tue Jul 18 09:17:51 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Tue, 18 Jul 2000 09:17:51 -0400 Subject: Duplicates again Message-ID: <397458FF.E5E88361@VerizonWireless.com> It's happening again, duplicates by the dozen. sigh. I'm not the only one, am I? hoping-someone-is-listening-who-can-do-something-about-it-ly yrs, -- William K. Scherer Sr. Member of Applications Staff Verizon Wireless From cjc26 at nospam.cornell.edu Mon Jul 10 20:35:14 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 11 Jul 2000 00:35:14 GMT Subject: Namespace weirdness References: <3968E1B0.B6E6F3E9@yahoo.com> <8F6CECA93gmcmhypernetcom@199.171.54.194> <39692118.9D6EAFAA@yahoo.com> <3969A8B8.FCA803F3@yahoo.com> Message-ID: * Paul Winkler menulis: | | But I overlooked the obvious. Just stuff all those arguments into a | dictionary! | Then my code above looks like: | | class Food: | def __init__(self, args = {}): You could do something even trickier here: def __init__(self, **args): This allows you to call __init__ with keyword arguments, like this: f = Food(color='red', texture='slimey', flavor='salty') args will be passed a dictionary of all the keyword arguments, so this is basically like the solution you came up with, only with a possibly nicer syntax :) | self.args = args | self.thing1 = SomeClass(self.args) | self.thing2 = SomeClass(self.args) | ... | | class SomeClass: | def __init__(self, args) If you choose to use keyword arguments above, you probably should leave SomeClass as it is, because it's not too easy to pass a dictionary to a function expecting keyword arguments. It >can< be done, though, using the apply function. | self.args = args | def do_something_useful: | print self.args['some_key'] | ... | | Ahhh, much better. Now I only have to deal with the entire list of | args (now keys) once, when I create a Food instance, and then just | reference each by key when needed. | | And accessing the parameters as args['key'] is actually a lot easier | than typing self._parentInstance.arg1 or some such weirdness. | | | p.s. there are several common English insults that take the form of | Food.BodyPart, hence my weird choice of names. | | egg.head | meat.head | cheese.head | lard.ass | pizza.face | beer.belly | | I have the feeling there are more... let's-all-hear-it-for-synecdoche-ly y'rs, Cliff -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ Synaesthesia now! icq 68165166 From timr at probo.com Thu Jul 27 01:32:20 2000 From: timr at probo.com (Tim Roberts) Date: Wed, 26 Jul 2000 22:32:20 -0700 Subject: Reading PCI Configuration Space... References: Message-ID: <97ivnsok3v8uije2ka2moqqcsin528omm0@4ax.com> Jerome Chan wrote: >Does anyone know how to read the PCI configuration space with Python >under Win 98 or Linux? Doing this under Windows requires a C extension, and even then it isn't easy. Under Windows 98, you can scan the BIOS for the PCI entry point and call it directly. Under Windows NT, even this doesn't work; you need the help of a kernel driver. Much of the interesting PCI information is buried in the registry, which IS accessible from Python. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From grey at despair.rpglink.com Fri Jul 28 14:18:45 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 18:18:45 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Fri, 28 Jul 2000 18:23:39 +0200, Alex Martelli wrote: >Where Python fits, I don't know, but I suspect it would be an excellent >first-language (except for those who belong to the "bondage-and-discipline" >school of programming, and/or of teaching-to-program, who would surely be >better advised to look at Pascal or some of its successors). Well, if it is any consolation I did tell my roommate of the two languages I currently dabble in, Perl and Python, if she wanted to start to learn to program I recommended Python even though my Path, thus far has been Pascal, C (and subsequent running away screaming like a madman), some DOS based scripting languages (4DOS anyone?), REXX (see C comment), Perl, Python. PHP is next on the list somewhere once I can find a decent reference book. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From matt at mondoinfo.com Wed Jul 19 20:38:15 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 19 Jul 2000 19:38:15 -0500 Subject: tkinter: font measure() References: <3975E3D5.36CB58D4@uniserve.com> Message-ID: <190720001938158576%matt@mondoinfo.com> In article <3975E3D5.36CB58D4 at uniserve.com>, Bob van der Poel wrote: > Anyone know how to use the font measure() thing in tkinter? I had to figure this out just the other day. Here's what works for me: >>> import Tkinter >>> foo=Tkinter.Toplevel() >>> import tkFont >>> f=tkFont.Font(family="7x13") >>> f.measure("wibble") 42 The Toplevel() call wouldn't be necessary in your program since you'd have already called mainloop(). Best regards, Matt From m.faassen at vet.uu.nl Sun Jul 30 17:45:33 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jul 2000 21:45:33 GMT Subject: Perl is worse! References: <3h8zumi4i2.fsf@angband.org> <8lva5q$bga$1@news6.svr.pol.co.uk> Message-ID: <8m27lt$ila$6@newshost.accu.uu.nl> "Bill de h?ra" wrote: [snip] > It's my hope that future languages will not allow in-code comments, the same > way Python has dumped bracketing. Instead replace comments with naming, > abstraction and unit tests. Comments are a story about code; too often that > story is fairy tale. > If you can't clarify your code without inline comments, you're not done. I don't use inline comments that way. I simply write the comments before I write the code, or change it. I say things like 'here I'm doing this'. Inline comments describe the how; docstrings describe the what. I also use inline comments for warnings (hairy code coming up, or 'hack!' or FIXME). I find them quite useful that way. Perhaps it'll be different if there are a lot of people who change my code, but that's currently not the case. Perhaps I've been lucky at not encountering bad comments a lot yet, too. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aek at aek.dk.bbs Sun Jul 16 11:00:02 2000 From: aek at aek.dk.bbs (aek at aek.dk.bbs) Date: 16 Jul 2000 15:00:02 GMT Subject: Why make a language case sensitive? Message-ID: <3bQQL2$kzx@openbazaar.net> I know that the VB IDE does this, but that is exactly because Microsoft realised that case sensitivity has advantages, and then they enforced case sensitivity in a way that is, agreed, in many ways smart. The real problem in Python does not occur because of case sensitivity it occurs because you do not need to declare your variables. Case sensitivity is a good way way to keep the same case across different development platforms - the VB concept only works because if you write VB you use Microsofts VB IDE, not Ultra Edit, Emacs, notepad, Borland, you name it. Mircosofts system enforces IDE monopoly, which is anoying since I do not like the Visual studio IDE, I strongly prefer Borlands, or even better Ultra Edit. And the VB IDE concept could easily be implementet in a case sensitive language as well. And one more thing, you do not need to remeber the case of any single variable if you keep a strict definition of how case should be used: in my case all new words start with capital, except the first word of a property, method or simple type - that way I am never in doubt as to 1: what type I am dealing with, 2: never in doubt as to what the case is suposed to be used... -- Anders Eggers - Krag "Olivier Dagenais" wrote in message news:%%Rb5.109206$HK2.1930096 at news20.bellglobal.com... > As a VB freak (or ex-thereof), I need to point out that the VB IDE will > attempt to make all variables and keywords use the same case. So, for > example, "if" is always 'converted' as "If" and if you declare a variable as > such: > > Dim m_Spam As Long > > (which, BTW, the IDE would have 'fixed' the words 'Dim', 'As' and 'Long') > > and then you need to refer to m_Spam, you can type it without any capitals, > and when you move the cursor to another line, the IDE will look up the > declaration and match the case of the new instance of the variable with that > of the declaration... For example, I type: > > m_spam = M_SPAM + 42 > > and it becomes: > > m_Spam = m_Spam + 42 > > ...which keeps the readability. (doesn't it?) Also, now that I have this > line of code, if I go back to the declaration and change 'm_Spam' to > 'm_SpAm', all the references 'm_Spam' will now read 'm_SpAm'... > > So, I can't say that I agree with you when you say that forcing the user to > type the name correctly will improve readability, especially in the case of > Pyton when a mis-typed variable name results in a new binding being created, > and not a compile-time error, like in C. I once read an "article" (more > like a joke) on how to write really bad (obfuscated) C code, and one of the > "tips" was to mix the cases of the letters making up variable names.... > > If you have a pre-processor or a powerful IDE (more like a compiler built > into an IDE), you can achieve readability that is customized to the person > reading and making a change in the "readability" of a name does not require > doing a [case-sensitive] find/replace. > > Let the user have only to remember the sequence of characters and let the > computer find out (in a previous declaration or usage) how they should be > capitalized. > > I love Python. I hope case sensitivity doesn't stay around for too long. > All it *really* allows you to have is something like a previous post, where > a file requires a close method with a small C and for a DB connection, a > close method with a capital C: > > aFile.close() > aConnection.Close() > > ...which just seems pretty silly to me, especially if you're someone trying > to use code from two different sources, and they have adopt similar > conventions, except the case is different. People just don't think like > computers: 'a' and 'A' are the same letter, and you bring up a good example > in your last paragaph... > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > > "Anders Eggers-Krag" wrote in message > news:jbPb5.1245$bb.28195 at news101.telia.com... > > I would say that it improves syntax consequense, leading to more readable > > code > > for others, you are never in doubt about what to look for when looking for > a > > keyword, > > > > in VB you might look for IF, If or if, and they look very different, and > it > > becomes a lot harder > > to read somebody elses code. > > > > the case insensitivity is nice when I am the only one to read my code as I > > could then choose my > > own obscure notation such as mYmetOd() and keep it consequent writing dEf, > > claSs, If eTc. > > wheras case sensitivity makes it more natural to keep a more sensitive > > manner such as myMethod() > > MyMethod() or my_method() throughout that everyone can agree on, I believe > > that case sensitivity > > leads to more uniform code, that again makes it easier to read your > > collegues code. And i think it should > > seem natural to everyone, after all books are written in case sensitive... > > you can't write: "i Am the wisEst > > One of aLl." and be taken seriously > > > > But it depends on which kind of access is needed to the system ie it would > > be dreadfull if DNS > > or SMTP servers were case sensitive and user enters MicroSoft.com and > gets > > nowhere because > > he should have written microsoft.com. > > > > > > -- > > Anders Eggers - Krag > > > > > > "Peter Timaratz" wrote in message > > news:000801bfeda1$fcd99a20$6cb745c6 at timaratz... > > > I can't think of any advantages to a case sensitive language. Python is > a > > > very well-designed language though, so I imagine there is a good reason > > that > > > it is case sensitive. So what are the advantages of a case sensitive > > > language? > > > > > > > > > > > > From cut_me_out at hotmail.com Mon Jul 31 13:33:39 2000 From: cut_me_out at hotmail.com (Alex) Date: 31 Jul 2000 13:33:39 -0400 Subject: looking for python object debugging hints References: <87og3es4ai.fsf@oak.gitaram.com> Message-ID: > Here are some of the ideas I have: > > 1. Build a statically linked Python executable and completely > avoid the whole problem. I do this, and it works pretty well. I have a script that goes over my development directory, copies across any file matching *module.c into the python Modules/ directory if there isn't already an up-to-date copy there, modifies the Setup file if necessary, does a 'make; make bininstall' in the python directory, and filters the output from that so that only lines matching one of the copied files gets printed. It's as easy to use as make, most of the time, except that you have to go back and look at the entire make output if there's a linking error. Alex. From Barrett at STScI.Edu Thu Jul 20 18:12:18 2000 From: Barrett at STScI.Edu (Paul Barrett) Date: Thu, 20 Jul 2000 18:12:18 -0400 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <8l7c80$mlc$1@tomm.stsci.edu> Message-ID: <39777941.1A85F3CA@STScI.Edu> Perry Greenfield wrote: > We are planning to use Numeric (or its future equivalent) heavily for > our software. One thing we would strongly object to is making > matrix operators the default. The vast majority of our manipulations > (on images and spectra) involve elementwise operations. This would be > consistent with what most astronomers would expect (and how IDL--currently > the most commonly used array-based language in the astronomical community > by far--handles it). > Note that IDL uses * as elementwise multiply and # has matrix multiply. The latter, I find, fairly desciptive, ie. it looks like a matrix. I would also suggest just using solve(A,B) for matrix solve. It's not that long and its descriptive. The one symbol in Python that I would like to see changed is ^ to mean exponentiation, instead of **. The xor operation could be represented by !| or &| . The one issue that concerns me about this discussion is the continued narrow focus to emulate Matlab syntax to the exclusion of more general N-dimensional operations. I can see the need for some more general operators, but I'm not for any of this, if all we're doing is defining 2-D Matlab syntax. I suggest the Matlab people take a look at APL or J to get a broader perspective of array languages. From fran at stat.Berkeley.EDU Sat Jul 15 19:14:11 2000 From: fran at stat.Berkeley.EDU (Fran Rizzardi) Date: 15 Jul 2000 23:14:11 GMT Subject: something like os.link() for NTFS? Message-ID: <8kqr83$qm9$1@agate.berkeley.edu> Hard links exist under NTFS. Does anyone know of a Python function for NT under NTFS that does what os.link() does under UNIX? If not, is there a technical reason why it isn't a good idea? Thanks very much, Fran Rizzardi From sabren at manifestation.com Mon Jul 31 16:09:31 2000 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 31 Jul 2000 16:09:31 -0400 (EDT) Subject: Best way to solve dual call??? In-Reply-To: Message-ID: On Mon, 31 Jul 2000, Arint? wrote: > I have this app that allows python scripts to talk to devices thru a c++ app > and a dll. At certain times the device may need to send a message to the > script like COVER_OPENED/COVER_CLOSED. Currently, it is giving me a error > in the Thread State stuff. It works ok if there is a call to the script and > while that call is being made then send the message. Example I have a > messagebox in my dll that python scripts can pop up, while the script is > waiting for that messagebox to go away Messages from the device can safely > make it in. I could tell the testers to popup a window whenever a message > may be expected, but that is not practical or possible. Any hints on what I > could do? If you want a DLL to send a message back into your program, you're probably talking about having a callback routine to catch it, right? I ran into this situation trying to script a MIDI keyboard. Every time I pressed a note, python would completely crash. I don't know if this is the ONLY way to solve the problem, but I found it works best to have the callback written in C, and compile it as a python module. I'm not a very good C programmer (so I can't tell you much more than that) but I got the code working, and you can see it at http://www.sabren.com/code/python/midi/ Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From gerryq at indigo.ie Mon Jul 24 14:18:22 2000 From: gerryq at indigo.ie (Gerry Quinn) Date: Mon, 24 Jul 2000 18:18:22 GMT Subject: Python in game development? References: <964118210.2281.0.pluto.d4ee0942@news.demon.nl> <397ab732.1184204@news.proxad.net> <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: <3L%e5.9930$r4.5151@news.indigo.ie> In article , David Bolen wrote: >gerryq at indigo.ie (Gerry Quinn) writes: > >> In article <8lh588$oti$3 at news.fsu.edu>, Ronald Steedman > wrote: >> > A full compile of a complex software package can often take 30 seconds or >> > more. That can be frustrating when you're trying to find and remove bugs. >> > You try one thing, wait 30 seconds, try another thing, wait 30 seconds... >> > >> > Imagine how an intepreter would help. Try one thing IMMEDIATELY SEE THE >> > RESULT... try another thing IMMEDIATELY SEE THE RESULT... then you only >> > compile the application when you're finished and want a faster program. >> >> If I were your boss I would make sure you had no access to an >> interpreter! I would even slow down your compilation by giving you an >> older machine ;-) >> Changing things at random and hoping the problem goes away is not the >> way to fix bugs. > >Where in the above did he say "random" and "hope"? Being able to >iteratively and interactively make changes hardly has to impact the >methodology used in arriving at those changes to be made. > >Or are you saying that the use of a compiler would remove the need to >ever iterate more than once on a bug fix? I'm not sure I'd agree :-) > Even 10 iterations would be only 5 minutes. A bug that took that many iterations to kill would require much more than 5 minutes thought. Clearly if compile time is frustrating in such a case, the time devoted to thinking about the bug is insufficient. Furthermore, if it appeared to go away after trying this and trying that, I am not confident that it would be properly fixed. Sometimes, you do find the problem by applying a half thought out change, finding it works, and then realising what the problem was. But a compile time of 30s is neither here nor there, IMO. Gerry Quinn -- http://bindweed.com Puzzle / Strategy Games and Kaleidoscope for Windows Download evaluation versions free, no time limits New: Unique 2-player strategy game "Zen" From arhodes at psionic.com Wed Jul 19 18:23:15 2000 From: arhodes at psionic.com (Aaron Rhodes) Date: Wed, 19 Jul 2000 17:23:15 -0500 Subject: Getting local IP address... References: Message-ID: <39762A53.376B180A@psionic.com> Mike Fletcher wrote: > > The primary problem with #1 is complex network configurations. For instance, > here is what the code gives you on my machine (and my configuration is not > that complex in the grand scheme of things)... > > >>> import socket > >>> socket.gethostbyname( socket.gethostname()) > '192.0.2.201' > > Which seems perfectly reasonable, except that that is actually an address on > our VPN, and is completely un-addressable by the outside world. > (Incidentally, you likely get the same information from the Linux hackery, > since it only accesses "the first" ethernet adapter, is, effectively, doing > exactly the same thing as gethostbyname, just in an obscure way, and you > still are left not knowing what is connected to the Internet). Just to clarify -- the Linux hack does things a tad different than the socket.gethostbyname( socket.gethostname() ) call... The socket.gethostbyname method relies on an entry in /etc/hosts or a valid DNS entry (or whatever nsswitch.conf says to use actually) under hosts: . If these two things are broken or don't exist the call will fail as in: >>> import socket >>> print socket.gethostbyname_ex(socket.gethostname()) Traceback (innermost last): File "", line 1, in ? socket.error: host not found *Note: I only tried this on Linux since that's what I'm on right now. However, the Linux fcntl method will work without valid DNS/hosts file. The other issue here is that if multiple IP addresses are used, there's really not a good way to tell which one was used to send a packet to particular destination unless you use the reflection method as previously described (or sniff the wire in non-promiscuous mode to see what your machine is sending -- fairly tedious). If you need to know which address "will be used" to send a packet somewhere before it is sent -- i.e. to locate the "external" interface before it's used, then you could perhaps look at the default route on the system and compare to the machine you are trying to connect to... or have the user tell you. This is an interesting problem...who would have thought. Aaron arhodes at psionic.com From donn at u.washington.edu Fri Jul 28 17:37:11 2000 From: donn at u.washington.edu (Donn Cave) Date: 28 Jul 2000 21:37:11 GMT Subject: "always passes by reference" References: <8llct3$n34$1@news.dtc.hp.com><397FCE9C.F22BB6B4@see.my.signature> Message-ID: <8lsue7$4qis$1@nntp6.u.washington.edu> Quoth hzhu at users.sourceforge.net (Huaiyu Zhu): ... | IMHO, the name/object dichotomy is much more descriptive for python than the | reference/value dichotomy. What about references that have no name, in lists and tuples? Donn Cave, donn at u.washington.edu From boud at rempt.xs4all.nl Thu Jul 6 04:59:44 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 6 Jul 2000 08:59:44 GMT Subject: Problem Installing PyQt-012 References: <20000702.20095100@linux.local> <20000703.19444100@linux.local> <8jqnsu$m79$1@news1.xs4all.nl> <20000703.22081700@linux.local> Message-ID: <8k1hq0$k0r$1@news1.xs4all.nl> Kenneth Payne wrote: > Boudewijn - > I've installed autoconf and automake. This gets rid of all errors > except the message about X (if that is an error) but I still get the > same probelm on installing pyQT. Sorry for getting back so late - in the meantime I've tried to install PyQt on a few other machines. One problem I had was that on Redhat /usr/local/lib, where sip installs by default, wasn't included in ld.so.conf or the ld_library_path. Sip isn't a Python module, really, so it doesn't reside in /lib/python. > checking for X... no I do think you need X, really. Have you got the development packages installed? If you try again, first remove config.cache, to force autoconf to look again, then run ./configure again. If you still can't get it to work, I'd suggest contacting Phil Thompson - he's far more knowledgeable in compiling matters than I am. Success! -- Boudewijn Rempt | http://www.valdyas.org From garry at sage.att.com Mon Jul 31 08:35:03 2000 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 31 Jul 2000 12:35:03 GMT Subject: Perl is worse! References: <39814767.FFEFE5D0@infercor.no> <3981DB97.E367C81E@alcyone.com> Message-ID: <39857277.FBA95374@sage.att.com> Steve Lamb wrote: > > On 29 Jul 2000 20:09:46 +1200, Paul Foley wrote: > >Not in the world I live in! If I put a slice of pizza in my coffee cup, > >it doesn't magically turn into coffee...just makes a mess. > > Of course not, pizza is not data. Data has this lovely property that > pizza doesn't have, it doesn't really exist. that's ok, Paul doesn't really have a slice of pizza. -- Garry Hodgson Every night garry at sage.att.com a child is born Software Innovation Services is a Holy Night. AT&T Labs - Sophia Lyon Fahs From jacques.bonhomme at advalvas.be Wed Jul 19 20:35:24 2000 From: jacques.bonhomme at advalvas.be (Damien) Date: Thu, 20 Jul 2000 02:35:24 +0200 Subject: Discussion: Introducing new operators for matrix computation - general approach? References: <396E160D.272C0C34@roguewave.com> <396EDE0B.5F9075B6@fft.be> <8koktn$dik$1@news-int.gatech.edu> Message-ID: <3976494C.3A6DE1F7@advalvas.be> Andrew Henshaw wrote: > > ...snip... > I wonder if some of these problems could be approached in a more general > manner. What if Python could support the definition of operators in the > same manner as functions? If that were the case then something like: > > opr rDiv(X, y): > > would define a new operator function that would work like: > > b = X rDiv y > > The big advantage would be that special purpose grammars could be easily > imported. The core language could be kept as simple as possible, but still > be extensible in a way that matters to a lot of people. > > I suspect that whitespace would be required around these new 'operators', > although many people already do that with regular operators. Also, I'm not > sure how you'd specify an operator that wasn't valid as a function name, but > I can think of possibilities. > I agree with a general approach. Operator overloading is present in Python and can create elegant solutions. Extending the number of operators can also make things clearer as there is no obligation to link a new type of operation to an existing operator. A general operator of the type .X could avoid major parsing problem. When treating the dot operator, the X is present as parameter and is the first character following the '.' This avoids the necessity for blanks around the operator. Damien Fontaine From rumjuggler at cryptarchy.org Sat Jul 29 16:05:09 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 29 Jul 2000 20:05:09 GMT Subject: [Python-Dev] PEP 201, zip() builtin References: <200007280428.QAA09796@s454.cosc.canterbury.ac.nz> Message-ID: <4ge6oso7stn8m263dvkabt6foq1tbrqbqc@4ax.com> On Fri, 28 Jul 2000 13:22:37 GMT, Guido van Rossum wrote: >> bwarsaw at beopen.com (Barry A. Warsaw): >> > An earlier version of this PEP proposed that >> > zip() return a built-in object that performed lazy evaluation >> > using __getitem__() protocol. This has been strongly rejected >> > by the BDFL in favor of returning a real Python list. If lazy >> > evaluation is desired in the future, the BDFL suggests an xzip() >> > function be added. > >Greg Ewing replies: >> Well, in that case I think the BDFL has just shot this >> proposal in the foot as far as being a serious solution >> to the parallel for loop problem. >> >> I was willing to live with the idea of using zip() instead >> of having a proper parallel iteration syntax, as long as >> it was implemented lazily. But now it seems I'll have to >> use another ugly x-named function all over the place. > >Who says all over the place? As far as I can tell, lock-step >iteration (let's not call it "parallel") is a fairly uncommon >operation -- but just common enough that people have been arguing for >some kind of support for it. > >The proposed implementation will be blindingly fast -- zip() could >approximate the existing range() function in speed. There are a few >well-known cases where xrange() is to be preferred over range(), but >in *most* cases, I claim, range() performs well enough. Note that I'm >not saying that range() is faster than xrange() -- I am saying that it >is *fast enough* for typical usage. > >I claim the same for zip(). We'll have a C implementation of zip() in >the 2.0b1 release (expect it late August); please hold back your >judgement until then. I take it, then, that lock-step iteration will be done with zip()? That seems too bad, because it the existing Python syntax could be modified to create easily-understood (to me, anyway) ways of expressing both parallel and lock-step iteration: parallel: for x in sequence1, y in sequence2: stuff lock-step: for x, y in sequence1, sequence2: stuff -- Barnabas T. Rumjuggler This is the Great Theatre of Life. Admission is free but the taxation is mortal. You come when you can, and leave when you must. The show is continuous. Good-night. -- Robertson Davies, _The Cunning Man_ From thomas at xs4all.net Fri Jul 21 02:48:48 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 21 Jul 2000 08:48:48 +0200 Subject: [long and fussy] But what do these operators _mean_? In-Reply-To: <8l899g$6f5$1@agate.berkeley.edu>; from ejr@lotus.CS.Berkeley.EDU on Fri, Jul 21, 2000 at 01:33:36AM +0000 References: <8l899g$6f5$1@agate.berkeley.edu> Message-ID: <20000721084848.C9897@xs4all.nl> On Fri, Jul 21, 2000 at 01:33:36AM +0000, Edward Jason Riedy wrote: > Python doesn't provide reasonable ways to test for Inf or NaN. These > are needed in new eigenvalue routines (the only known optimal ones). > Yes, I know, there are some non-IEEE architectures left, but they > shouldn't be encouraged. (Keep in mind that I'm at Berkeley; expect > a strong IEEE-754 bias.) Well, now that the C standard (C99) says *something* about the implementation of floating point numbers, we can expect some change in this. However, given that it took 10 years before Guido decided for an all-out move from K&R C to ANSI C, it's not likely to happen overnight ;) Tim can probably say more about this, though, as usual. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From thamelry at vub.ac.be Mon Jul 10 03:56:25 2000 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 10 Jul 2000 07:56:25 GMT Subject: More math on the O'Reilly Network References: <3964CA9B.CBCD5B03@oreilly.com> <8k41s8$a8i$1@snic.vub.ac.be> <21a69d79.ebd96c80@usw-ex0104-032.remarq.com> Message-ID: <8kbvj9$lde$1@snic.vub.ac.be> fig wrote: : Sounds like the article didn't go where you wanted it to go. There's nothing wrong with it. I just thought the introduction to matrices and vectors was a little bit superfluous. : What aspects of NumPy were you looking for a good tutorial on? There are some gotcha's when working with Numpy, like the automatic upcasting of arrays. Numpy can be used to do large scale vector operations efficiently (eg. multiplying 1000 vectors by a matrix). It would be nice to explain how to do that as well. Explaining how to transfer data from Numpy to C and back would also be interesting. Cheers, --- Thomas Hamelryck Institute of Molecular and Structural Biology Aarhus University Gustav Wieds Vej 10C DK-8000 Aarhus C Denmark http://zombie.imsb.au.dk/~tham : ----------------------------------------------------------- : Got questions? Get answers over the phone at Keen.com. : Up to 100 minutes free! : http://www.keen.com From grey at despair.rpglink.com Fri Jul 28 18:05:24 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 28 Jul 2000 22:05:24 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <3981B034.80FACD08@fft.be> <3981D863.F71AC0AC@alcyone.com> Message-ID: On Fri, 28 Jul 2000 12:00:51 -0700, Erik Max Francis wrote: >Perl doesn't make a distinction between types at the object level, but >it has to at the _operator_ level. Might that be exactly why I say that data is data and that the operation determines the type? :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From nowonder at pool.informatik.rwth-aachen.de Tue Jul 25 03:45:24 2000 From: nowonder at pool.informatik.rwth-aachen.de (Peter Schneider-Kamp) Date: Tue, 25 Jul 2000 07:45:24 +0000 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> Message-ID: <397D4594.B52DE55E@pool.informatik.rwth-aachen.de> Jonathan wrote: > > 1. There are no keywords to declare static or instance variables; it > 2. No *formal* declaration of static class methods, e.g. no 'static' > 3. No keywords to differentiate between passing arguments by reference [...] > it; but i don't think it's suitable to be a first programming language > for non-programmers(i read somewhere about this project going on). > Pascal(for procedural) and Java(for OOP) is still the better choice to > start off, IMHO. I think especially for non-programmers, it is a quite good language. Consider your three points above: A non-programmer is not going to care about static variables/classes/passing conventions. I think it's true that compared to many other languages these things are a bit weird (magic), but in most cases they do what you want them to do. In Python you can write nearly pseudo code, e.g. with for element in list and other constructions. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From Armin at Steinhoff_de.bbs Sun Jul 16 17:50:05 2000 From: Armin at Steinhoff_de.bbs (Armin at Steinhoff_de.bbs) Date: 16 Jul 2000 21:50:05 GMT Subject: Funding vs Python Message-ID: <3bQb5S$kD_@openbazaar.net> In article <8kt4rj$d4n$1 at nnrp1.deja.com>, Andy says... > >I was tired of hearing a friend talk about how wonderful Python is, >so I decided to learn Python by using it to implement a product that >the official implementation team thought would take experts 1-2 man >years using numerous Java buzz-words. A month later, I'm still a >Python newbie, but I'm close enough to done that I'm looking at >the rev 2 feature list. (The experts are still trying to hire >but are going to start any day because other folks like running >code more than they like plans.) > >No good deed goes unpunished, so now I'm getting push back along the >lines of "we can't get funded if it's in Python". (Somehow, I don't >think that using Perl would have produced the same reaction.) Well ... compile your Python sources into C++ or use JPython in order to generate JAVA code :-)) Regards Armin > >I've seen the list of web projects at python.org, so I'm wondering >if there are others or if there really are examples of companies that >didn't get funded because they used Python. > >-andy > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From a.kupries at westend.com Mon Jul 31 14:29:04 2000 From: a.kupries at westend.com (Andreas Kupries) Date: 31 Jul 2000 20:29:04 +0200 Subject: Content of the Perl6 talk References: <16E8935DE8C35BF0.1E652ED229DA405D.479F9E5D07D36E5F@lp.airnews.net> <398126DE.6E2C2627@ajubasolutions.com> <3981EDA1.1CB1CE07@ajubasolutions.com> Message-ID: Dan Kuchler writes: > Andreas Kupries wrote: >> >>> Syntax separation - multiple syntaxes ? Perl6 offers the >>> possibility to ... write Perl programs in multiple syntaxes such >>> as Python, JavaScript, and Perl5 ... >> This reminds me of Guile, which tried to do the same thing, no ? >> Universal lisp engine below, multiple formats for programming it >> above. Here just with the perl engine below. A try to unify >> interpreters ? See also Jean-Claude's Minotaur, using a forth >> engine below and beside interpreters for several scripting >> languages to allow them to use each other (and their extensions) >> hither and fro. With the long-term goal to make each interpreter a >> set of routines above the universal forth engine below. Hm. Looking at my post and this I think that I came across as being opposed to this. I am not. I don't think that I will have time to actively participate in such an effort [*] but I will follow them with interest. [*] Maybe indirectly through working on the tcl core. > I understood this to mean that for perl 6 they might try to > architect it into a front-end/back-end style where the front-end has > a parsing engine (and translator to byte codes or some intermediary > language?) and then the backend provides the code for actually > implementing the various commands. Exactly. This is that guile tries to do too. > If done correctly, only the perl front end would have to be > implemented, but it would give others the opportunity for trying to > write some new syntax (which could be like tcl, python, etc.) that > would work with the existing perl backend. > That was how I envisioned that bullet might be implemented.. -- Sincerely, Andreas Kupries ------------------------------------------------------------------------------- From R.Brodie at rl.ac.uk Mon Jul 24 10:08:18 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Mon, 24 Jul 2000 15:08:18 +0100 Subject: Variables in strings.. References: <81324605608.20000724121203@buz.ch> <8lh72p$173m@newton.cc.rl.ac.uk> <71330494285.20000724135012@buz.ch> Message-ID: <8lhikk$rgg@newton.cc.rl.ac.uk> "Gabriel Ambuehl" wrote in message news:71330494285.20000724135012 at buz.ch... > I really dislike all that HTML generators no matter if they are for > Perl or Python. I've got my very own view about how I want to have my > HTML code looking (imagine strongly idented, ie each element has got > it's own identation level, constructs). Using some modules > for it just won't do the job for me... If you prefer, rolling your own template functions wouldn't be too hard. For example, if you want to interpolate a list into a string: >>> def format(template, *args): for element in args: ... template = re.sub('#', str(element), template, 1) ... return(template) ... >>> format('Value is # and # and #', 2, 3, 4) 'Value is 2 and 3 and 4' No doubt re hackers could optimise the code further. One could even (horrors) write a function that takes a string and does Perl style substitution from the enclosing namespace. From chrisw at nipltd.com Fri Jul 7 09:07:35 2000 From: chrisw at nipltd.com (Chris Withers) Date: Fri, 07 Jul 2000 13:07:35 GMT Subject: imp.load_module from a string Message-ID: <8k4kmh$khb$1@nnrp1.deja.com> Hi, I am trying to a load a .pyc which has been pickled, sent over a TCP/IP connection and then unpickled into a string. imp.load_module seems perfect, however, when I call it with: imp.load_module(moduleName, StringIO.StringIO(modulePYC), moduleName+'', (".pyc","rb",imp.PY_COMPILED)) I get: ValueError: load_module arg#2 should be a file or None Anyone know how I should be doing this? cheers, Chris Sent via Deja.com http://www.deja.com/ Before you buy. From bvdpoel at uniserve.com Sat Jul 1 22:56:34 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sat, 01 Jul 2000 19:56:34 -0700 Subject: Class vrs. function References: <395E2425.8F6F8757@uniserve.com> <395E4281.452C26DE@prescod.net> Message-ID: <395EAF62.4A628573@uniserve.com> Paul Prescod wrote: > > Bob van der Poel wrote: > > > > ... > > > > Is this just a good habit being developed by those who think that > > classes are better than functions, or god forbid, inline code? > > Given what you've said, that one-function class looks pretty bizarre. Is > there maybe something else useful about it that you haven't noticed? > Classes are not better than functions. They are just different. In most > cases, you use classes when you need to combine data and instructions. Yes, that I understand. In some of the example code I've seen there is only the __init__ function and no data. That's why it doesn't make sense to me. Maybe I'm just having a bad day..... -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From richard_chamberlain at ntlworld.com.bbs Mon Jul 17 16:40:03 2000 From: richard_chamberlain at ntlworld.com.bbs (richard_chamberlain at ntlworld.com.bbs) Date: 17 Jul 2000 20:40:03 GMT Subject: Multiline strings and indentation Message-ID: <3bROc3$kuA@openbazaar.net> Hi Jen, How about: def multiline(x): if x: print "this is a" \ "multi-line string that spans" \ "three lines" \ print "another string" Richard donotspam-jen at personic.com wrote in message news:39736250$0$14722 at wodc7nh6.news.uu.net... > I'm just getting started with Python. The indentation feature really does > make things readable ... except when using multi-line strings. This just > doesn't look right: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Is there a way to make the above more readable? It would be nice if it could > be written this way and have Python just figure out what whitespace to > ignore: > > def multiline(x): > if x: > print """this is a > multi-line string that spans > three lines""" > print "another string" > > Thanks for any suggestions! > > Jen > > From gmunsey at punkalunka.org Sun Jul 30 15:32:05 2000 From: gmunsey at punkalunka.org (Grant Munsey) Date: Sun, 30 Jul 2000 12:32:05 -0700 Subject: Python plug-ins for Adobe Products available References: <8m06l3$8s4$1@agate.berkeley.edu> Message-ID: > While I'll grant that this is a good first step for Adobe, these > are simply add-ons for proprietary software. The add-ons are > often available under moderate licenses. Thanks for the compliment ... it wasn't exactly easy to convince Adobe that they should have an open source site. I'm hoping it will grow as time goes on. "simply add-ons", it wasn't exactly simple to do these since the APIs are somewhat Baroque. In fact there is a pretty complete scheme that uses Python code to produce wrapper C++ code for many of the API calls. This might be useful for someone who finds SWIGs allowable parameter types a bit to restrictive. I said the license is liberal because I'm happy it turned out that way ... lot of time with corporate lawyers, etc. I don't really like GPL because IHMO it isn't liberal ... just replaces one set of restrictions with another. Please no flames on this topic it's been beaten to death. > Meanwhile, there are existing free software projects that could > use help. > ... I wrote the plug-ins for the Adobe products because I wanted them. I made them available because some people were interested and I thought that some others might be as well. If you want to help Gimp, Sketch, Broadcast 2000, VTK, whatever then ... go to it! What really worries me is the wrangling over the Python license ... one of the reasons I went for Python in a big way was the non restrictive license. "Edward Jason Riedy" wrote in message news:8m06l3$8s4$1 at agate.berkeley.edu... > And Grant Munsey writes: > - Adobe has opened an open source site at http://opensource.adobe.com. > [...] > - The Adobe Open Source license is reasonably liberal. > > While I'll grant that this is a good first step for Adobe, these > are simply add-ons for proprietary software. The add-ons are > often available under moderate licenses. > > Meanwhile, there are existing free software projects that could > use help. > > The Gimp + Gimp-Python (instead of Photoshop): > http://www.gimp.org/ > http://www.daa.com.au/~james/pygimp/ > > Sketch, which is implemented in Python (instead of Illustrator): > http://sketch.sourceforge.net/ > > I'm not familiar with ``After Effects,'' but the description sounds > like an extension of Broadcast2000: > http://heroinewarrior.com/bcast2000.html > AFAIK, there's no Python associated with that project. Perhaps there > should be. Integration with things like VTk (www.kitware.com) would > be nice. VTk has a Python binding, but not a very nice one. > > Jason > From scorder at incigna.com Fri Jul 7 09:11:39 2000 From: scorder at incigna.com (Sam) Date: Fri, 07 Jul 2000 09:11:39 -0400 Subject: Ado stored procs with parameters References: Message-ID: <43lbmsohe81o718p1db16r4vcceap31ufd@4ax.com> I feel stupid replying to myself but this is something somebody will probably run across and now the answer will be in the archives as well. Apparently ADO is stupid when running statements. The default statement type is adCmdText. It looks like in this mode it doesn't look for any parameters that might have added.. Changing the CommandType to adCmdStoredProc makes it decide to look if any parameters were added. So in this case the line: cmd.CommandType = constants.adCmdStoredProc should be added somewhere before the rs.Open command is executed. So is the DB Api any better? I saw somebody announced a DBAPI for Ado. Right now I don't have the time to check it out. Besides if I want to get Python more accepted where I work I can't expect them to learn another DB object model on top of a new language. At least for now. -Sam On Thu, 06 Jul 2000 08:47:43 -0400, Sam <> wrote: >I'm having a bit of trouble using a stored proc on MSSQL that takes >parameters. I create a command object and then append the parameters >to it. Then I create a recordset object and use the open method >passing the command object and a few other parameters. Unfortunately >I get an error saying that the stored proc requires The same parameter >that I just added. Below is the code I'm using. Any ideas? > >Sam Corder > >import win32com.client >constants = win32com.client.constants > >class dbcon: > def __init__ (self, connect = None): > self.connectstr = connect > def runSQLReturnRS(self, sql, params = None): > if self.connectstr == None: > return None > else: > rs = win32com.client.Dispatch('ADODB.Recordset') > cmd = win32com.client.Dispatch('ADODB.Command') > cmd.ActiveConnection = self.connectstr > cmd.CommandText = sql > if params != None: > for parm in params: > cmd.Parameters.Append(cmd.CreateParameter(parm[0], >parm[1], constants.adParamInput, parm[2], parm[3])) > > rs.Open(cmd, CursorType = constants.adOpenForwardOnly, >LockType = constants.adLockReadOnly) > return rs > > def __AddParams(self, cmd, params): > for parm in params: > cmd.Parameters.Append(cmd.CreateParameter(parm[0], >parm[1], constants.adParamInput, parm[2], parm[3])) > >if __name__ == '__main__': > db = dbcon("Provider=SQLOLEDB;Data Source=s-incigna2k;User >Id=msl_login;Password=***;Connect Timeout=5;network >library=dbmssocn;Initial Catalog=msl;") > params = ("ExpJobID", constants.adInteger, 4, 11), > rs = db.runSQLReturnRS("ExpConfig_Get", params) > print rs.Fields.Count > From tismer at appliedbiometrics.com Wed Jul 5 09:52:00 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 05 Jul 2000 15:52:00 +0200 Subject: Why is Python so slow ?- revisited. References: <394D6579.8B2FF840@appliedbiometrics.com> <8tA35.10459$C44.626417@bgtnsc05-news.ops.worldnet.att.net> Message-ID: <39633D80.27B767E4@appliedbiometrics.com> William Dandreta wrote: > > Hi chris, > > Here is the fastest version of my program. Ok. I was off for a while and did not follow the thread. Some hints may give you a little speedup: Don't work on the global level, but do everything in functions. This gives you a speedup, since local variables are optimized and don't involve dictionary lookups. Further, since you are working on only 6000 lines or so, you can save quite some time by using readlines(),and then iterating over that list. But I don't know if Py1.2 has readlines at all. Here a rough layout, untested of course! ### start of example refactored #corrects Y2K leapyear error and #strips off all the " marks import strop FINNAME = 'lu4.txt' FOUTNAME = 'lu4.new' def process(finn=FINNAME, foutn=FOUTNAME): # caching some funcitons locally: strip = strop.strip splitfields = strop.splitfields atoi = strop.atoi joinfields = strop.joinfields _map = map _tuple = tuple lines = open(finn, 'r').readlines() fout = open(fount, 'wb) write = fout.write for line in lines: fields = splitfields(joinfields(splitfields(line,'"'),''),',') fields[2] = joinfields(splitfields(fields[2],' '),'0') fields = _map(strip,fields) #convert date to YYYYMMDD format if fields[2][-2:] == '00': fields[2] = '2000' + fields[2][-10:-8] + fields[2][-7:-5] else: fields[2] = '19' + fields[2][-2:] + fields[2][-10:-8] + fields[2][-7:-5] #fix date for Y2K leapyear error if fields[2] == '20000301': fields[2] = '20000229' elif fields[2] == '20000401': fields[2] = '20000331' elif '20000301' ---------------------------------------------------------- > #corrects Y2K leapyear error and > #strips off all the " marks > > from strop import strip, splitfields,atoi,joinfields > > lu4 = open('lu4.txt','r') > newlu4 = open('lu4.new','wb') > > while 1: > #for i in range(6000): > line = lu4.readline() > if not line: break > fields = splitfields(joinfields(splitfields(line,'"'),''),',') > fields[2] = joinfields(splitfields(fields[2],' '),'0') > fields = map(strip,fields) > #convert date to YYYYMMDD format > if fields[2][-2:] == '00': > fields[2] = '2000' + fields[2][-10:-8] + fields[2][-7:-5] > else: > fields[2] = '19' + fields[2][-2:] + fields[2][-10:-8] + fields[2][-7:-5] > > #fix date for Y2K leapyear error > if fields[2] == '20000301': > fields[2] = '20000229' > elif fields[2] == '20000401': > fields[2] = '20000331' > elif '20000301' fields[2] = '2000' + fields[2][4:6] + '%02d' % (atoi(fields[2][6:])-1) > > newlu4.write('%-16s,%8s,%8s,%10s,%10s,%-11s,%-11s,%-21s,%-51s\r\n' % > tuple(fields)) > --------------------------------------------------------------------- > Bill > > Christian Tismer wrote in message > <394D6579.8B2FF840 at appliedbiometrics.com>... > >Also feel free to send me your source code for inspection. > > -- > http://www.python.org/mailman/listinfo/python-list -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From brunnsNObrSPAM at beer.com.invalid Thu Jul 6 03:38:31 2000 From: brunnsNObrSPAM at beer.com.invalid (Simon B) Date: Thu, 06 Jul 2000 00:38:31 -0700 Subject: Hi, my name is not Mrs so-called Gumblenose References: <395B2B88.CC3041C1@memo.volvo.se> <1c934748.cd75dee0@usw-ex0106-045.remarq.com> <8jvii30149t@news1.newsguy.com> Message-ID: <0021d40a.e7b821c9@usw-ex0106-045.remarq.com> "Alex Martelli" wrote: >> If someone were to port JPython to the '400, you would be able >> to use the AS/400 Toolbox for Java's native DB access APIs, but >> that would be a pretty major job in itself. > >Why would JPython have to be "ported" at all? Doesn't it >"just run" with any common-or-garden Java Virtual Machine? Pretty much. But I gather that the AS/400 implementation of the JVM has a few, uh, features. Also, you'd have to wrap the AS/400 Toolbox for Java, or it wouldn't be worth doing in the first place. Cheers, Simon B. With Microsoft, failure is not an option. It comes bundled. ----------------------------------------------------------- Got questions? Get answers over the phone at Keen.com. Up to 100 minutes free! http://www.keen.com From dale at out-think.NOSPAM.co.uk Sun Jul 9 11:55:52 2000 From: dale at out-think.NOSPAM.co.uk (Dale Strickland-Clark) Date: Sun, 9 Jul 2000 16:55:52 +0100 Subject: How to use makepy? References: <8k9o91$7b1$1@supernews.com> <4p%95.10247$A06.1298430@pouncer.easynews.com> Message-ID: <8ka7cd$c3$1@supernews.com> Thanks for all replies. I've now read the chapter in Python Programming on Win32 and am somewhat the wiser. However, I am confused as to why it seems to break this very simple program after running Makepy on "Microsoft ActiveX Data Objects 2.5 Library". At the print statemtent, I get this: print DBRec(0).Value TypeError: too many arguments; expected 1, got 2 Where did it get 2 from? ------------------------ import win32com.client DBCon = win32com.client.Dispatch("ADODB.Connection") DBRec = win32com.client.Dispatch("ADODB.Recordset") DBRec.CursorLocation = 3 # adUseClient = 3 sDB = "s:\\ths\\merlin.mdb" DBCon.Open("Driver={Microsoft Access Driver (*.MDB)}; DBQ=" + sDB) #DBRec.open("House", DBCon, adOpenStatic, adLockOptimistic, adCmdTable) DBRec.Open("House", DBCon, 3, 3, 2) DBRec.AddNew() DBRec.Fields("Price").Value = 234000 DBRec.Update() print DBRec(0).Value DBRec = None DBCon = None ---------------------------- Thanks for any help Dale Strickland-Clark "Roger Upole" wrote in message news:4p%95.10247$A06.1298430 at pouncer.easynews.com... > It should speed up your COM calls. Also, you can browse thru the > generated file and see all the properties and methods of the COM > object. > Once the object has been created, the constants will be available as > win32com.client.constants.someconstantname. > There is a Readme.html in the /win32com directory, and more documentation in > /win32com/HTML/QuickStartClientCom.html. > HTH > Roger Upole > > "News.tele2.co.uk" wrote in message > news:8k9o91$7b1$1 at supernews.com... > > Well I've run it and it seemed to work but I'm not really sure what to do > > next. > > > > In fact, I'm not entirely sure what it's supposed to do for me but I'm > > hoping it will at least give me access to some COM object constants. > > > > Where is it documented? > > > > Thanks > > > > Dale Strickland-Clark > > > > > > > > > > From query at mhk.lu.se Fri Jul 7 09:16:35 2000 From: query at mhk.lu.se (Peder Schmidt & Rickard Nordström) Date: Fri, 07 Jul 2000 13:16:35 GMT Subject: OFF TOPIC: Questions about Open Source Development. Message-ID: <398dd828.5186868@news.lu.se> Hello! We are two students writing our master thesis about open source software. First we want to describe what open source development is and how it works. Secondly, we want to compare the open source model of developing software to traditional project groups working in accordance to a life-cycle model. Your help would be greatly appreciated! Our focus lies on business critical systems, so most of the questions will reflect this. Your name and e-mail will remain confidential! Please send your answers to: query at mhk.lu.se Thank you in advance! July 2000 Peder Schmidt and Rickard Nordstr?m ---------------------------------------------------- ---------------------------------------------------- BACKGROUND QUESTIONS -------------------- - Age? - Gender? - What is your profession? - What kind of tasks do you perform at your job? - What is your programming experience (if any)? - How much time do you spend on open source development (if any)? ---------------------------------------------------- ---------------------------------------------------- QUALITY FACTORS, RATED ---------------------------------------- The scale used is 1 to 5. 1 means strong favour to opensource development methodology. 2 means favoring open source. 3 means equally good. 4 means favoring traditional development. 5 means strong favour to traditional project groups working in accordance to a life-cycle model. We would be grateful if you commented upon your choice. - Which development process provides the best environment for uniform design? (For example code consistency and implementation techniques) Rating (1-5): - Which development process provides the best traceability? (For example cross-referencing functions in the software to specific pieces of code) Rating (1-5): - Which development process gives the best support for writing software with the required precision in calculations and software output? (For example efficient or correct algorithms) Rating (1-5): - Which development process support construction of "robust" software best? (Continuity of operation under non-nominal conditions) Rating (1-5): - Which development process support implementation of functions in the most understandable manner best? (For example self-explanatory variable names and comments in the code. Usually avoidance of practices which increase complexity) Rating (1-5): - Which development process best prevents the existence of trapdoors and trojan horses in the software? Rating (1-5): - Which development process provides the best environment for construction of software resistant to Denial of service attacks? Rating (1-5): ---------------------------------------------------- ---------------------------------------------------- QUALITY FACTORS, DESCRIPTIVE ---------------------------------------------- - How is open source software tested, except for peer-reviews? Are there any formal methods? - In case you have experience in professional development of software how do you test the software in that environment? - If you have developed open source software, did you use any existing source code from other projects? - If your answer to the question above was yes, did you feel that the code was usable "as is" and comprehensive or did you have to modify it to suit your needs? - If you have experience in professional development of software, did you use any existing source code from other projects? - If your answer to the question above was yes, did you feel that the code was usable "as is" and comprehensive or did you have to modify it to suit your needs? ---------------------------------------------------- ---------------------------------------------------- THE OPEN SOURCE DEVELOPMENT PROCESS ----------------------------------- - Describe the different phases an open source project passes through. What happens in each specific phase? - What documents are usually generated (if any) during the open source development process? - When do you consider an open source project to be "mature"? (if your answer is never - then please explain this) Thank you for filling out this questionnaire! Please send your answers to query at mhk.lu.se From fiona at sitegnome.com.bbs Thu Jul 13 17:40:02 2000 From: fiona at sitegnome.com.bbs (fiona at sitegnome.com.bbs) Date: 13 Jul 2000 21:40:02 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 13th, 2000 Message-ID: <3bOKH2$n80@openbazaar.net> Hi guys, I'm a little confused :-) yesterday I'm pretty sure I sent out a summary to the list, it doesn't seem to have made it though so this is a second attempt. Apologies if it makes it twice now. So, what's been entered into http://python.faqts.com: - How can you check on the status of a file's "archive" bit, on DOS-type platforms - What Python code can I use to find all the network ports that are in use on a server? - Can I use python to access web (eg.yahoo) email account? - Is there any way to find the mount point of a filesystem given the path to a file within the file system? - How can I create a wxBitmap image from a Python Imaging Library (PIL) image? - How can I compare two strings in a case-insensitive way? - What is wxPython? How does it compare with Tkinter? - Bidirectional communication through pipes: read/write popen() cheers, Fiona ## Unanswered Questions ######################################## ------------------------------------------------------------- How can you check on the status of a file's "archive" bit, on DOS-type platforms http://www.faqts.com/knowledge-base/view.phtml/aid/4706 ------------------------------------------------------------- Barry Pederson ## New Entries ################################################# ------------------------------------------------------------- What Python code can I use to find all the network ports that are in use on a server? http://www.faqts.com/knowledge-base/view.phtml/aid/4684 ------------------------------------------------------------- Fiona Czuczman Aaron Berg to figure out what ports are used on a server you could use netstat -a -n import os popen("netstat -a -n") ------------------------------------------------------------- Can I use python to access web (eg.yahoo) email account? http://www.faqts.com/knowledge-base/view.phtml/aid/4685 ------------------------------------------------------------- Fiona Czuczman Steve Purcell For web mail accounts that have POP access, such as Yahoo, check out the 'poplib' standard library module: http://www.python.org/doc/current/lib/pop3-example.html ------------------------------------------------------------- Is there any way to find the mount point of a filesystem given the path to a file within the file system? http://www.faqts.com/knowledge-base/view.phtml/aid/4686 ------------------------------------------------------------- Fiona Czuczman John Clonts I didn't find anything already extant, so here's this: def mountpoint(s): import os if (os.path.ismount(s) or len(s)==0): return s else: return mountpoint(os.path.split(s)[0]) def testit(): print mountpoint("/home/john/scheme/cmucl") print mountpoint("/usr/local") print mountpoint("/lib/") print mountpoint("lib") ------------------------------------------------------------- How can I create a wxBitmap image from a Python Imaging Library (PIL) image? http://www.faqts.com/knowledge-base/view.phtml/aid/4687 ------------------------------------------------------------- Fiona Czuczman Greg Landrum Here's some sample code: def PilImgToWxBmp(pilImg): wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1]) wxImg.SetData(pilImg.tostring()) bmp = wxImg.ConvertToBitmap() return bmp ------------------------------------------------------------- How can I compare two strings in a case-insensitive way? http://www.faqts.com/knowledge-base/view.phtml/aid/4688 ------------------------------------------------------------- Fiona Czuczman Bjorn Pettersen import string if string.lower("FOO") == string.lower("Foo"): ## Edited Entries ############################################## ------------------------------------------------------------- What is wxPython? How does it compare with Tkinter? http://www.faqts.com/knowledge-base/view.phtml/aid/3565 ------------------------------------------------------------- Fiona Czuczman, Olivier Dagenais Shae Erisson wxPython [ http://www.wxpython.org ] is a set of Python bindings for the GUI toolkit wxWindows [ http://www.wxwindows.org ], that was written as a C++ library to provide a platform-independant way of implementing rich and fast user interfaces. I chose wxPython over Tkinter (for my projects) because: - wxWindows seems to have more widgets than Tk - special widgets (like the TreeView) are implemented using the operating system's native implementations, not complete re-writes - it's more than a "lowest common denominator" among platforms, wxWindows seeks to provide the same, advanced functionality on all platforms, even if it means they have to write a lot of code to complement a platform's native component - wxWindows seems to cover more ground, in terms of functionality (it's more than a GUI toolkit, it also seeks to provide functions/classes for files, threads, printing, clipboard, networking, ODBC, etc...) - I was *really* impressed with the wxPython demo ------------------------------------------------------------- Bidirectional communication through pipes: read/write popen() http://www.faqts.com/knowledge-base/view.phtml/aid/4448 ------------------------------------------------------------- Nathan Wallace, Fiona Czuczman Hans Nowak, Snippet 259, Hrvoje Niksic """ Packages: files;miscellaneous """ ''' In all kinds of circumstances it would be very useful to call an external filter to process some data, and read the results back in. What I needed was something like popen(), only working for both reading and writing. However, such a thing is hard to write in a simple-minded fashion because of deadlocks that occur when handling more than several bytes of data. Deadlocks can either be caused by both programs waiting for not-yet-generated input, or (in my case) by both their writes being blocked waiting for the other to read. The usual choices are to: a) Write a deadlock-free communication protocol and use it on both ends. This is rarely a good solution, because the program that needs to be invoked is in most cases an external filter that knows nothing about our deadlock problems. b) Use PTY's instead of pipes. Many programmers prefer to avoid this path because of the added system resources that the PTY's require, and because of the increased complexity. Given these choices, most people opt to use a temporary file and get it over with. However, discussing this problem with a colleague, he thought of a third solution: break the circularity by using a process only for reading and writing. This can be done whenever reading and writing are independent, i.e. when the data read from the subprocess does not influence future writes to it. The function below implements that idea. Usage is something like: rwpopen("""Some long string here...""", "sed", ["s/long/short/"]) -> 'Some short string here...' I've put the function to good use in a program I'm writing. In addition to getting rid of temporary files, the whole operation timed faster than using a tmpfile (that was on a single-CPU machine). The function will, of course, work only under Unix and its lookalikes. Additional information is embedded in the docstring and the comments. I'd like to hear feedback. Do other people find such a thing useful? Is there a fundamental flaw or a possibility of a deadlock that I'm missing? ''' def rwpopen(input, command, args=[]): """Execute command with args, pipe input into it, and read it back. Return the result read from the command. Normally, when a process tries to write to a child process and read back its output, a deadlock condition can occur easily, either by both processes waiting for not-yet-generated input, or by both their writes() being blocked waiting for the other to read. This function prevents deadlocks by using separate processes for reading and writing, at the expense of an additional fork(). That way the process that writes to an exec'ed command and the process that reads from the command are fully independent, and no deadlock can occur. The child process exits immediately after writing. More precisely: the current process (A) forks off a process B, which in turns forks off a process C. While C does the usual dup,close,exec thing, B merely writes the data to the pipe and exits. Independently of B, A reads C's response. A deadlock cannot occur because A and B are independent of each other -- even if B's write() is stopped because it filled up the pipe buffer, A will happily keep reading C's output, and B's write() will be resumed shortly. """ # XXX Redo this as a class, with overridable methods for reading # and writing. # # XXX Provide error-checking and propagating exceptions from child # to parent. This would require either wait()ing on the child # (which is a bag of worms), or opening another pipe for # transmitting error messages or serialized exception objects. # # XXX This function expects the system to wait for the child upon # receiving SIGCHLD. This should be the case on most systems as # long as SIGCHLD is handled by SIG_DFL. If this is not the case, # zombies will remain. def safe_traceback(): # Child processes catch exceptions so that they can exit using # os._exit() without fanfare. They use this function to print # the traceback to stderr before dying. import traceback sys.stderr.write("Error in child process, pid %d.\n" % os.getpid()) sys.stderr.flush() traceback.print_exc() sys.stderr.flush() # It would be nice if Python provided a way to see if pipes are # bidirectional. In that case, we could open only one pipe # instead of two, with p_readfd == p_writefd and c_readfd == # c_writefd. p_readfd, c_writefd = os.pipe() c_readfd, p_writefd = os.pipe() if os.fork(): # Parent for fd in (c_readfd, c_writefd, p_writefd): os.close(fd) # Convert the pipe fd to a file object, so we can use its # read() method to read all data. fp = os.fdopen(p_readfd, 'r') result = fp.read() fp.close() # Will close p_readfd. return result else: # Child try: if os.fork(): # Still the same child os.write(p_writefd, input) else: # Grandchild try: # Redirect the pipe to stdin. os.close(0) os.dup(c_readfd) # Redirect stdout to the pipe. os.close(1) os.dup(c_writefd) # Now close unneeded descriptors. for fd in (c_readfd, c_writefd, p_readfd, p_writefd): os.close(fd) # Finally, execute the external command. os.execvp(command, [command] + args) except: safe_traceback() os._exit(127) except: safe_traceback() os._exit(127) else: os._exit(0) From nobody at nowhere.nohow Sun Jul 30 12:28:46 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Sun, 30 Jul 2000 16:28:46 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <3981D737.CBA366F@alcyone.com> <8lvovs1dj1@news2.newsguy.com> <8m1evi12n4o@news2.newsguy.com> Message-ID: <2JYg5.2853$6E.754619@ptah.visi.com> On Sun, 30 Jul 2000 11:41:15 +0200, Alex Martelli wrote: >> 1 >> >> What comes next? > >Now THAT is a poser. In Europe at least, for example, if you're looking >for a house you know that what's likely to come next is 3, then 5, etc; >odd-numbered addresses are on one side of the road, even-numbered ones >on the other (two separate sequences). It's the same in most places in the US also. The size of the "jumps" is often larger. In most places numbers go up 100 per "block" (where a block is the distance from one street corner to the next). Since there are maybe 10-20 houses per block, numbers tend to go up by larger increments. -- Grant Edwards grante Yow! Now I understand the at meaning of "THE MOD SQUAD"! visi.com From grey at despair.rpglink.com Thu Jul 27 11:43:09 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 27 Jul 2000 15:43:09 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: On Thu, 27 Jul 2000 01:40:25 GMT, Guido van Rossum wrote: >new license more liberal than I would have been able to negotiate on >my own if I were still a CNRI employee. *mutters something about lawyers, marketing people and a tank full of sharks.* Heh, ok, thanks for the answer. :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From aahz at netcom.com Mon Jul 17 19:18:09 2000 From: aahz at netcom.com (Aahz Maruch) Date: 17 Jul 2000 23:18:09 GMT Subject: OT: RedHat 6.1 (was Re: newbie unimpressed...) References: <8kvp81$9q1$1@nnrp1.deja.com> <8kvqqb$8e5$1@nntp9.atl.mindspring.net> Message-ID: <8l047h$6ag$1@slb6.atl.mindspring.net> In article , Grant Edwards wrote: >In article <8kvqqb$8e5$1 at nntp9.atl.mindspring.net>, Aahz Maruch wrote: >>In article <8kvp81$9q1$1 at nnrp1.deja.com>, wrote: >>> >>>(I'm using python 1.5.1 on Redhat 5.2) >> >>I strongly recommend upgrading to Python 1.5.2. The documentation is >>much better, for starters. > >FWIW, RH 5.2 is getting a bit old also. I couldn't recommand >6.[01], but 6.2 seems to be decent. What's wrong with 6.1? (We upgraded a few months back, mainly to get 1.5.2, and I'd like to know if there's a serious reason we should move to 6.2.) -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Q: In a lesbian relationship, who decides who gets to be the man? A: It's two women. There is no man. That's the point. From quango at watervalley.net Fri Jul 28 00:42:17 2000 From: quango at watervalley.net (Chris Lawrence) Date: Fri, 28 Jul 2000 04:42:17 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> Message-ID: On Fri, 28 Jul 2000 03:29:06 GMT, Steve Lamb wrote: > None could be converted into an empty list. None is nothing. I fail to >see how you can't populate a list with a single nothing. Reasonable enough. Though you're not populating a list with a single nothing; you're making an empty list. OTOH, by the logic below, why not [None] instead of []? > 1 is a single value. I fail to see why that cannot be converted to [1] >which is allowed, btw. >a = [1] >a > > 123 is a single value. I fail to see why that cannot be converted to >[123] which, again, is allowed. See above. Not sure about these. If you want a one-element list, say so. x = [1] is concise. x = list(1) ain't. If [] offends your sensibilities, try x = list(1,). > "abc" could either be a single value or a sequence. It is converted as >["a", "b", "c"]. Of course, the same /could/ be said for the above. However, >let's play around with this one since it is the only one that works somewhat >as expected in conversion. "abc" is a string. Strings are immutable sequences in Python. list((1,2,3)) = [1,2,3]. Same principle. >a = "abc" >a >a = list(a) >a = str(a) >a > > a is now "['a', 'b', 'c']". Which means we split a string up when >converting to list but don't concatinate on the way back. I'd think, then, >that we'd not split the string up in the first place and consider it a single >value for a single entry in a list. IE, ["abc"]. But, of course, dropping >back from a list to a str isn't perfect since you're going from a more complex >structure into a simple data set. How does Python know you want "['a','b','c']" instead of "['abc']"? (And wouldn't you *really* expect "abc"?) It can't. But logic suggests that ['aa', 'b', 'c'] isn't the same thing as ['a', 'a', 'b', 'c'], yet your representation would say they are the same. This strikes me as type-based magic, which Python tries to avoid. > How did I run across this? Because I wanted to create an empty name each >time a class instance is created. Since I was building the class I didn't >know if I was going to use a list or a str. I figure I could just set it >to None and then manipulate it later. Nope. Couldn't even convert it even >though the conversion seems quite straightforward to me. None into any >structure should yield and empty of that structure. We can have empty >strings, tuples, lists and directories. Funny thing, though. I can do this >and it works just fine: Huh? Python is a strongly typed language. None is an instance (the sole instance, natch) of a NoneType variable. Should NoneType things transmute themselves into other types of things at the drop of a hat? This sounds fishily like Perlish automagic conversion. > However, if we want to create the namespace with nothing we cannot because >we cannot convert it for later use. Thus, we are back to declaring variables >except this time we're doing it with automagical (implicit) means instead of >explicit. Sure you can. x = None ... for y in range(10): if x is not None: x = x + y else: x = y Which begs the question: why would you want to declare a variable without knowing what you're going to stick in it? (Incidentally, you're not creating a namespace, you're making an entry in a particular namespace...) > I just don't understand how people can advocate for types and the >restrictions they impose while, on the other hand, embracing a language that >is free enough to shoot yourself in the foot by reassigning None. Hmm, works in JPython too. And Python 2.0b1. Maybe it's a feature ;-) Frankly, I don't know how you'd get None back. And it will play havoc with things: None = 1 if None: print 'Hello' I suspect Guido will tell you, "don't do that." ;-) Chris -- ============================================================================= | Chris Lawrence | Your source for almost nothing of value: | | | http://www.lordsutch.com/ | | | | | Debian Developer | This address has been spam-proofed. | | http://www.debian.org/ | All spam goes to your postmaster. | ============================================================================= From moshez at math.huji.ac.il Tue Jul 18 02:35:34 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 18 Jul 2000 09:35:34 +0300 (IDT) Subject: nis module error In-Reply-To: <39736BCB.626BD669@hpbs1711.boi.hp.com> Message-ID: On Mon, 17 Jul 2000, Jacob Hunt wrote: > I am new to python and want to use the nis module. When I import the > module I get the error: > > Traceback (innermost last): > File "", line 1, in ? > ImportError: /usr/lib/python1.5/lib-dynload/nismodule.so: undefined > symbol: yperr_string > > what does this mean? How can I correct the problem or is there a way > around it. > > I am using python 1.5.2 on x86 SuSE 6.4. It basically means that SuSE has f**ked up the dependancy. Try compiling Python from source and see if the problem goes away (it should) -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From david_ullrich at my-deja.com.bbs Sun Jul 16 14:50:12 2000 From: david_ullrich at my-deja.com.bbs (david_ullrich at my-deja.com.bbs) Date: 16 Jul 2000 18:50:12 GMT Subject: Changing the class of an instance Message-ID: <3bQWKa$j5h@openbazaar.net> In article , Alex wrote: > > > Well it's exactly what I was doing once because I was a lot more > > clever than the guys who said I shouldn't. And then I decided quite > > suddenly that they were right. (At the end of a _long_ stretch trying > > to figure out why the heck something wasn't working - of course the > > answer is the object in question was very different from the object it > > appeared it should be...) > > It can have really confusing consequences, I don't think "confusing" is the right word. Although I'm fairly certain I won't get the words right: It destroys the... maybe the word is "encapsulation" or "modularity" or something - it means that you cannot verify things are correct by just looking at things locally. When you write def AClass: def AMethod(self): you can't know that AMethod is correct just by inspecting , because you have no idea whether is what's executed when AMethod is called. > but it's still too useful for > me to abandon. If you have a class which takes a long time to > instantiate (e.g., you have to load a lot of statistical data into > memory,) then having a script like > > class C: > pass > > if 't' not in dir(): > t = C() > > t.__class__ = C > t.experiment_with_instance() > > can really decrease your turn-around time when you're debugging -- you > can change t's methods around behind its back without changing its data. Not sure what sort of debugging we're referring to. If you're trying to figure out how to do something, as opposed to writing code meant to be used later, that's different. I'm not sure whether you're talking about temporary experimental code or "real" code; the post that started this was evidently talking about real code. In temporary code I suppose changing __class__ could be more convenient simply because it possibly takes a few fewer lines to write - in real code I don't see why changing the value of aninstance.__class__ is better than creating a second instance of the new class. Possibly I missed it, but I haven't seen any reason given why changing __class__ is better than creating a new instance (I don't think that the time it takes to load data counts, there's no reason you have to reload the data instead of referring to the data already loaded.) > Alex. > Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at localhost.localdomain Sun Jul 30 23:14:35 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Mon, 31 Jul 2000 03:14:35 GMT Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <8lla9m$hfd$1@animus.fel.iae.nl> <8luhsp51ce8@news2.newsguy.com> Message-ID: On Sat, 29 Jul 2000 14:07:17 +0200, Alex Martelli wrote: [snip] >> FLAG = bitwise.or(FLAG1, FLAG2, FLAG3, FLAG4, FLAG5, FLAG6, FLAG7, FLAG8) > >What an EXCELLENT idea. shift left/right could also be packaged that >way (or, almost so; 'or' is a reserved words in Python...). > >> quite "unpythonic" to let them occupy four unique ascii characters as > >Agreed, and worse if you consider << and >>. > [snip] > >The 'bitwise' module could supply easily explicit bitfield-extraction >in place of the mask-and-shift idioms, too. > >Oh well -- maybe a hint for Python 3000, when backwards compatibility >can be broken...! Why wait that long! Here's a prototype. If this becomes default, it would be easier to replace the implementation in the future - with much less to break. """ bitwise.py - replaces builtin bitwise operations with named functions """ def bitleft(x, bits): return x << bits def bitright(x, bits): return x >> bits def bitshift(x, bits): "shift left (positive bits) or right (negative bits)." if bits >= 0: return x << bits else: return x >> -bits def bitnot(x): return ~x def bitxor(x1, x2): return x1 ^ x2 def bitor(*args): y = 0 for x in args: y = y | x return y def bitand(*args): y = ~0 for x in args: y = y & x return y if __name__ == "__main__": assert bitleft(16,2) == 64 assert bitright(16,3) == 2 assert bitshift(16,2) == 64 assert bitshift(16,-3) == 2 assert bitnot(7) == -8 assert bitxor(6,7) == 1 assert bitand(6,7) == 6 assert bitor(6,7) == 7 assert bitand(4,5,6) == 4 assert bitor(4,5,6) == 7 print "Tests passed" From cut_me_out at hotmail.com Thu Jul 13 14:58:18 2000 From: cut_me_out at hotmail.com (Alex) Date: 13 Jul 2000 14:58:18 -0400 Subject: Why are some infinite recursion stack overflows hard to deal with? References: Message-ID: Thanks, Martin. That makes a lot of sense of the examples I've seen of this problem. Alex. > If you manage to run into recursion on the C stack, then the Python > stack overflow check won't trigger. Every time a Python function is > invoked, the recursion depth is incremented; you get the exception at > 10000. However, if you have, say, 10 C functions per Python function, > you may hit the stack limit of your operating system before the > recursion depth limit is hit. From python-list at teleo.net Fri Jul 7 21:01:44 2000 From: python-list at teleo.net (Patrick Phalen) Date: Fri, 7 Jul 2000 18:01:44 -0700 Subject: Splitting c.l.py... In-Reply-To: References: Message-ID: <0007071815170C.03526@quadra.teleo.net> [Tim Peters, on Fri, 07 Jul 2000] :: Can't speak for me mates at Luxurious PythonLabs World :: Headquarters, but I'd like to apologize for my own lack of participation on :: c.l.py over the past several months! :: When things settle down, at least I intend to resume harassing c.l.py. And :: there's already a great deal of development discussion on Python-Dev that :: *should* be on c.l.py. Thanks for expressing this, Tim. You've been missed. Then, to compound matters, I read the following Advogato diary entry from the effbot the other day and truly began to wonder if the good old days were gone: """ 5 Jun 2000 Just noticed that the Python version of the eff-bot has been online for five years (give or take a few days). To celebrate this anniversary, I've decided to shut down the comp.lang.python newsgroup eff-bot! (Frankly, it's been a while since c.l.py was the most interesting place in Pythonia, and it's no longer the endless source of positive energy it once was.) But to avoid offending anyone (or everyone ;-), lets just say that five years is a very long time on the net. It's time to find other channels for the eff-bot. Onwards! """ From nobody at nowhere.nohow Mon Jul 31 10:28:53 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Mon, 31 Jul 2000 14:28:53 GMT Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> <3982F04D.74FCF41C@webamused.com> <39834B9F.C6877761@webamused.com> Message-ID: In article , Paul Foley wrote: >> Steve is correct. In my experience it is not only inoffensive >> in some contexts, it has a positive connotation and means >> someting along the lines of what "mate" means in Australia. > >Well, I say you're both wrong. Say it all you want. I've seen the word used that way. -- Grant Edwards grante Yow! I'm having a MID-WEEK at CRISIS! visi.com From robin at alldunn.com Thu Jul 13 23:10:50 2000 From: robin at alldunn.com (Robin Dunn) Date: Thu, 13 Jul 2000 20:10:50 -0700 Subject: Win32 : Making script.py executable in DOS box References: <8jmjfe$64o$1@nnrp1.deja.com> <8jp3pt$q7j$1@nnrp1.deja.com> Message-ID: > > Under Windows NT or Win2k, you can use the PATHEXT environment > > variable. Simply add ".py" to the semi-colon sep'd list of > > extensions, and off you go! > > Great, thats a help for NT, but I also want to do this on Win98 :-). > > > No solution I am aware of for 95, although there are some tricks > > you can pull (Im sure someone else will fill these in for you)! > > Anyone??? > If you use the 4DOS command shell instead of command.com then you can set an environment variable like this: set .py=c:\path\to\python.exe -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxpython.org Java give you jitters? http://wxpros.com Relax with wxPython! From t.harris at robinsons.co.uk Mon Jul 17 12:03:44 2000 From: t.harris at robinsons.co.uk (Toby) Date: Mon, 17 Jul 2000 17:03:44 +0100 Subject: Global & Importing issues.... Newbie Message-ID: <963849878.7647.0.nnrp-13.c3ad12d2@news.demon.co.uk> I have a simple requirement for a second module to access a global variable stored in the first (main) module. I can reproduce my problem with the following 2 modules... Mod1.PY >>> import Mod2 myGlobal = None if __name__ == "__main__": myGlobal = 100 Mod2.DoPrint() #endif #endmodule Mod2.PY >>> import Mod1 def DoPrint(): print Mod1.myGlobal #enddef #endmodule When executing Mod1.PY I expect the answer 100 to be printed out, I get None I also get the same problem if there is a function in Mod1 which prints the value of myGlobal and is called from Mod2 - I think this is the same problem. :o( Any help from Python experts ? TIA Toby From jeremy at beopen.com Thu Jul 6 22:40:19 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 06 Jul 2000 22:40:19 EDT Subject: readline.c & more References: Message-ID: I agree that the system isn't great, but at least it provides us with a mechanism to track patches and assign responsibility for them. The old email approach didn't have either feature, which made it much harder for the people catching the patches. You might suggestion an email interface in the SourceForge feature request forum: https://sourceforge.net/forum/?group_id=1 -- Jeremy Hylton From heiland at ncsa.uiuc.edu Mon Jul 31 16:12:19 2000 From: heiland at ncsa.uiuc.edu (Randy Heiland) Date: Mon, 31 Jul 2000 15:12:19 -0500 Subject: check file exists Message-ID: <3985DDA3.E811F70A@ncsa.uiuc.edu> How does one test for whether or not a (Unix) file exists? thanks, Randy From peter at schneider-kamp.de Wed Jul 19 15:27:37 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Wed, 19 Jul 2000 19:27:37 +0000 Subject: Where to put the PEPs? (was: Re: Python-dev summary: July 1-15) References: <20000718100813.C21354@newcnri.cnri.reston.va.us> <3974E8CD.55215FD9@inrialpes.fr> <3975E180.1AFD30D@roguewave.com> Message-ID: <39760129.9BA42B7E@schneider-kamp.de> Bjorn Pettersen wrote: > > I think the PEPs are a great idea, but it would be even better if they > were more accessible... How about putting them up on the beopen or > python.org site? (That way the faq can refer to them for recurring > discussions with all the arguments archived in the PEP...) How about putting them on sourceforge? python.sourceforge.net/peps/pep-0206.txt and friends What do you think? Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From hzhu at localhost.localdomain Tue Jul 18 16:00:32 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 18 Jul 2000 20:00:32 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) References: <3973415D.5262CD86@eecis.udel.edu> <39735193.C8A6C311@prescod.net> <8kvocr$5mq$1@eeyore.INS.CWRU.Edu> <8F74C4E37gmcmhypernetcom@199.171.54.155> <8l0dqm$lji$1@eeyore.INS.CWRU.Edu> <8l1gm5$kh4$1@eeyore.INS.CWRU.Edu> Message-ID: On 18 Jul 2000 11:56:53 GMT, Kevin Jacobs wrote: >Not really. From what I've seen, the Python expression syntax is >significantly simpler than the full grammar. At least, its much simpler to >parse. So it has to be restricted to expressions. >> One of my biggest gripe about matlab is it forces me to treat strings as >> part of matrix. Now you are asking me to treat matrix as part of string. >> :-) > >Not matrices, just matrix expressions. Maybe this isn't such a big deal >for me since I grew up with LISP and Scheme. Would you allow literal matrix initialization like Matrix([[1,2],[3,4]]) inside the quote? >I have no problem with adding syntax for defining new operators. In fact, I >think that Standard ML allows just that. I know I've seen a proposal >something like this posted already, but lets consider a builtin like: > >add_infix_operator('.*', default_binary_element_multiply_evaluator, > '__relement_multiply__', # Right associative class member > '__lelement_multiply__') # Left associative class member > >where the default evaluator is called if the right or left associative >member evaluators are not specified on the operand classes. Such a scheme >would be sufficient if all the proposed linear-algebra syntax used valid >operators. It should be possible to augment the Python grammar to support >this, though its certainly not trivial. I think this is the best way, but don't know if anybody is able to do it. Huaiyu From swun at eSec.com.au Sun Jul 23 21:09:06 2000 From: swun at eSec.com.au (Sam Wun) Date: Mon, 24 Jul 2000 11:09:06 +1000 Subject: example for inherit the thread class? Message-ID: <397B9732.ACEBBF2A@eSec.com.au> Does anyone have example of how to inherit the thread class? or point to an url for some example? Thanks Sam. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hzhu at localhost.localdomain.bbs Mon Jul 17 21:20:03 2000 From: hzhu at localhost.localdomain.bbs (hzhu at localhost.localdomain.bbs) Date: 18 Jul 2000 01:20:03 GMT Subject: Matlab vs Python (was RE: Discussion: Introducing new operators Message-ID: <3bRW43$iPy@openbazaar.net> On Mon, 17 Jul 2000 19:22:31 -0500, Paul Prescod wrote: >I don't think you need __getattr__ > >class Matrix: > def __init__( self, ....): > self.T=Transpose( self ) > self.H=Hermitian( self ) > self.I=Inverse( self ) > self.C=Conjugate( self ) > self.E=Elementwise( self ) > self.M=self # matrixwise is default > ... other matrix-like methods ... > >class Transpose: > def __init__( self, mymatrix ): > self.mymatrix=mymatrix > ... other matrix-like methods, but transposed ... > >Notice that no computation (e.g. actual transposition) needs to be done >until you actually need to calculate a value. Maybe you can find >optimizations that allow only tiny parts of matrices to be computed. This is interesting. I suppose the computational cost is minimum. What about implementation? Do I have to write everything five times? Right now I'm even using .T() to avoid writing both left and right computations. It cost some computation but saves a lot of implementation and maintainence. Note that even one liners are relatively big cost because most of the current functions are just one liners. Huaiyu From breiter at usf.Uni-Osnabrueck.DE Mon Jul 31 09:13:59 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 31 Jul 2000 13:13:59 GMT Subject: GPL Compatability (was Re: The State of Python) References: <8luufo$ags$3@newshost.accu.uu.nl> Message-ID: <8m3u2n$g48$4@newsserver.rrzn.uni-hannover.de> In article <8luufo$ags$3 at newshost.accu.uu.nl>, m.faassen at vet.uu.nl (Martijn Faassen) writes: > Moshe Zadka wrote: >> On 28 Jul 2000, Martijn Faassen wrote: >>> Moshe Zadka wrote: >>> > On Fri, 28 Jul 2000, Paul Duffin wrote: >>> >>> >> What does GPL compatible mean ? >>> > It means that it can be relicenced as GPL. This is basically correct, but for the resulting whole product. >>> Are you sure? I thought it meant you could legally link it to >>> GPL-ed software. That's what the whole Qt/KDE squabble is about, at least. Yes, this is exactly what it means. The whole product thing was not produced by the GPL nor is the complexity of this license its own fault. AFAIU it is the law, which has strange interpretations of a whole product and code linked to each other is a whole product. To fully secure freedom with a strong copyleft you need to demand that the resulting product containing your code is still under the save copyleft rules. You cannot allow the whole product to be less well protected or you loose a lot and it would be a serious backdoor. All the GPL tries is to protect the freedom securely and that is what it does. Other code is not that well protected and only compatible with the GPL if is allows the resulting product to be well protected. I hope this sheds some light on the issue. :) Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From milenko at moonshine.co.uk Fri Jul 21 19:26:26 2000 From: milenko at moonshine.co.uk (Jack) Date: 21 Jul 2000 23:26:26 GMT Subject: Newbie pythoner, with bizzare problem Message-ID: <8F79257Amilenkomoonshinecouk@194.73.73.116> Hey there, im pretty new to using python, and im just experimenting with file access, a wrote a script that works fine, and then all of a sudden it started throwing up this error: inp = open("c:/autoexec.bat",'r') TypeError: illegal argument type for built-in operation it was working fine before, and i dont see anything unusual in the syntax. Any help would be appreciated, Cheers, Jack Green From tttok_2000 at yahoo.com Wed Jul 12 03:24:36 2000 From: tttok_2000 at yahoo.com (Ahmed Ahmed) Date: Wed, 12 Jul 2000 00:24:36 -0700 (PDT) Subject: Monitoring Network Ports Message-ID: <20000712072436.11470.qmail@web3402.mail.yahoo.com> Can you tell me how to write a Python code to find all the network ports that are in use on a server? __________________________________________________ Do You Yahoo!? Get Yahoo! Mail ? Free email you can access from anywhere! http://mail.yahoo.com/ From jepler.lnk at lnk.ispi.net Sun Jul 16 22:07:03 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Mon, 17 Jul 2000 02:07:03 GMT Subject: Is pickle buggy? References: <396B069A.9EBDD68B@muc.das-werk.de> <396EE83D.FB60B033@bioreason.com> <396EEB9F.20FBC9A4@bioreason.com> Message-ID: On Fri, 14 Jul 2000 11:29:51 +0100, Brian Kelley wrote: >I goofed, I actually do get this behavior in windows. I started a new thread >"string issues or questions about intern" Oh good! So we agree that the problem is while: eval(`uniquestring()`) and presumably because of the implicit intering of the string itself? See you on the other thread, which seems to have gotten more traffic. Jeff From tjreedy at udel.edu Mon Jul 17 12:50:33 2000 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 17 Jul 2000 12:50:33 -0400 Subject: [Patch] {l,r}just with optional pad character parameter References: <8kshd3$l1h$2@bw107zhb.bluewin.ch> <20000716165538.V7340@xs4all.nl> <39733AC7.96CCBF81@schneider-kamp.de> Message-ID: <8kvd70$dn4$1@news.udel.edu> "Peter Schneider-Kamp" wrote in message news:39733AC7.96CCBF81 at schneider-kamp.de... > Thomas Wouters wrote: > > > > As for the patch itself, it looks okay, though I'd say the restriction on > > padchar being a single character is a bit strange. Why not allow multiple > > characters as padding ? string.join() allows strings instead of single > > characters, too. > > Two reasons why not: > - it would have been harder to implement > - undetermined semantics: > "GvR".ljust(6,"12") =?= "GvR121" This is exactly what I would expect -- a 6 char result string > or > "GvR".ljust(6,"12") =?= "GvR12" > or > "GvR".ljust(6,"12") =?= "GvR1212" But these are not the right length -- someone who wanted something like this should examine lengths of input and pad and adjust whatever accordingly. > I would vote for the first, but I am not sure it is obvious. Anything else would surprise me, so I agree. TJR From neilh at scintilla.org Wed Jul 19 09:42:12 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 19 Jul 2000 13:42:12 GMT Subject: Stripping down Python References: Message-ID: > Are there any papers/stories ideas of how to most effectively strip down > Python? Ie. how to trim down the size of Python as much as possible, > removing the parser etc. Just having the basic Python interpreter, with > basic libraries, capable of running .pyc and .pyo files. Deeply embedded Python http://www.abo.fi/~iporres/python/ Neil From phil at river-bank.demon.co.uk.bbs Sun Jul 16 12:20:02 2000 From: phil at river-bank.demon.co.uk.bbs (phil at river-bank.demon.co.uk.bbs) Date: 16 Jul 2000 16:20:02 GMT Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME Message-ID: <3bQSP2$kCD@openbazaar.net> Visual Python is aimed at KDE and GNOME application developers and allows you to easily embed Python as a GUI enabled scripting language in your application. It includes KDE and GNOME APIs to manage Python interpreters, scripts and the communications between running scripts and your application. Users benefit from a common scripting language allowing them to develop scripting skills that are re-usable with all their applications. The same Visual Python script uses KDE widgets when run from a KDE application, and GNOME widgets when run from a GNOME application. When used in conjunction with tools like SWIG and SIP to expose application specific functionality to scripts, developers can provide their users with the ability to extend their application in many ways. The Visual Python home page is at http://www.thekompany.com/projects/vp/. Phil From R.Brodie at rl.ac.uk Mon Jul 31 07:26:09 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Mon, 31 Jul 2000 12:26:09 +0100 Subject: How does Python compare to ? References: Message-ID: <8m3noj$10la@newton.cc.rl.ac.uk> "Moshe Zadka" wrote in message news:Pine.GSO.4.10.10007311048410.10092-100000 at sundial... > CGI requires always a process startup and usually interpreter (be it > Tcl, Guile, Perl or Python) startup. That makes it unacceptable if there > are more then 2 hits/second. Yes, but you can easily use Apache extensions for at least three of those languages. I can't see any particular reason why mod_perl and mod_python shouldn't give comparable performance to mod_php. From vtbl.moorepe at memo.volvo.se Fri Jul 14 09:19:00 2000 From: vtbl.moorepe at memo.volvo.se (PM) Date: Fri, 14 Jul 2000 13:19:00 +0000 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kmtab$4or$1@pollux.ip-plus.net> Message-ID: <396F131C.4AD83C8A@memo.volvo.se> I should like it to kick c#'s butt, perhaps Bruno Gustavs wrote: > > "Dinu C. Gherman" wrote in message > news:396EE7BC.DA2FA7B3 at darwin.in-berlin.de... > > What do you mean by "language constructs", Python keywords > > like "for" or "class"? Are you expecting some statistics of > > used keywords over one's own code? > > > > I doubt this will be very useful, like the answer to the > > question: "Which are the ten most used words in English?". > > But maybe I'm not understanding well how you think you'll > > benefit from such an answer... > > Lets assume you're going to design Phyton2. What would this > language contain? What should Phyton2 support? What would you > like to solve with Phyton2? > > Regards > Bruno Gustavs From bvdpoel at uniserve.com Wed Jul 19 19:56:29 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Wed, 19 Jul 2000 16:56:29 -0700 Subject: CDDB Message-ID: <3976402D.9B957E2F@uniserve.com> Has anyone converted the cddb code which calulates the cddb id and track timing for a cd from C to python? Looks like it should be possible without too much work...I was going to try this myself, but figured I'd ask before I started... Thanks. -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From gee308 at mediaone.net Tue Jul 25 01:01:04 2000 From: gee308 at mediaone.net (Toy) Date: Tue, 25 Jul 2000 05:01:04 GMT Subject: newb Q: security with variables References: <397BE388.349CCA17@mediaone.net> <2kYe5.25991$1h3.418424@news20.bellglobal.com> <8li9dq$8do$1@nnrp1.deja.com> <397CD2C4.8D28FE65@mediaone.net> <397D2423.C06FEB9B@pool.informatik.rwth-aachen.de> Message-ID: <397D243A.FEFA34F4@mediaone.net> Thanks, I just didn't have time to search for it. Peter Schneider-Kamp wrote: > Toy wrote: > > > > The link is broken, could you show me another link? > > > > Jeremy Hylton wrote: > > > > > http://www.cnri.reston.va.us/software/pisces/manual/module- > > > pisces.pwcrypt.html > > http://www.cnri.reston.va.us/software/pisces/manual/module-pisces.pwcrypt.html > > Come on, that is not THAT hard ;-) > Peter > -- > Peter Schneider-Kamp ++47-7388-7331 > Herman Krags veg 51-11 mailto:peter at schneider-kamp.de > N-7050 Trondheim http://schneider-kamp.de From bill at dehora.fsnet.co.uk Sat Jul 29 15:47:15 2000 From: bill at dehora.fsnet.co.uk (Bill de hÓra) Date: Sat, 29 Jul 2000 20:47:15 +0100 Subject: agents References: <8l55hg$6ia$1@newsg1.svr.pol.co.uk> Message-ID: <8lvcgn$f7e$1@news6.svr.pol.co.uk> "Bill de h?ra" wrote in message news:8l55hg$6ia$1 at newsg1.svr.pol.co.uk... > Before I go off and start these myself, is anyone working on Agent > frameworks and or tuple spaces (Linda-alikes) in Python? > > -Bill de h?ra That'll be a no then ;-) All I could find were Lintyn (a retargetable MUD client) and Knowbot (internet agents: http://www.cnri.reston.va.us/home/koe/index.html). Right, I is off codin. -Bill de h?ra From rgparker at west.net Sun Jul 9 20:19:19 2000 From: rgparker at west.net (Randall Parker) Date: Mon, 10 Jul 2000 00:19:19 GMT Subject: Python book suggestions? Message-ID: I would like to learn Python because people I respect think highly of it. I have backgroun in C++, Java, and assorted other languages. I intend to use Python to do web site development. Does anyone have any suggestions as to which books are good for learning the Python language? How about a book about Python and XML? How about a book about Python for web site development? I'm thinking of starting with the v1.6 version that I see from an article has a number of language changes over previous versions. Are any books due out imminently that will cover this newer version? From banderson at boi.hp.com Tue Jul 18 20:10:34 2000 From: banderson at boi.hp.com (Bill Anderson) Date: Tue, 18 Jul 2000 18:10:34 -0600 Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME References: <963764534.1476580377@news.demon.co.uk> Message-ID: <3974F1FA.5D4A9F40@boi.hp.com> Olivier Dagenais wrote: > > You may want to hook up with the guys at ActiveState for your Win32 version > of VisualPython: > > http://www.activestate.com/Products/VisualPython.html > > Unless both of you came up with the name "Visual Python" to mean totally > different things?? Easy: "Visual Python" -and- "Visual python" -- Bill Anderson (ARC) Unix/Linux System Administrator HPSO Engineering Productivity Team Thursday, July 13, 2000 Random Quote: A bug in the hand is better than one as yet undetected. From claird at starbase.neosoft.com Wed Jul 19 17:40:03 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Jul 2000 16:40:03 -0500 Subject: newb question References: <39761E61.1E2191B4@tcgfinancial.com> Message-ID: <1DAEC848DF4B11DE.52EE01F00D60F6E0.982C845CA8423473@lp.airnews.net> In article <39761E61.1E2191B4 at tcgfinancial.com>, jtoy wrote: . . . >Third, how can I make Python recognize what OS its on, that wat if I . . . import os print os.name -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim_one at email.msn.com Wed Jul 19 01:12:11 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 19 Jul 2000 01:12:11 -0400 Subject: Discussion: Introducing new operators for matrix computation In-Reply-To: Message-ID: Sleeping in the same room with Guido for a night did not make it easier to channel him, but it did make it easier to cloud his mind: Guido is not opposed to adding new operator symbols to core Python. As of breakfast Tuesday, anyway, and there are witnesses, so he'll have trouble changing his mind (well, it will be clumsy for him to *admit* it if he changes his mind ...). But but but (you knew it wouldn't be *that* easy!): + Everybody concerned that new operators are "not Pythonic" please swallow it -- it is Pythonic, cuz Guido said it is <0.9 wink -- but see following points too>. Contribute by helping to come up with a complete and Pythonically beautiful implementation instead. + Please keep this off of Python-Dev. Doesn't belong there (at least not yet). Interested parties can form a mailing list, or try to discuss it on comp.lang.python (my personal hope is that you try the latter, and stick to one Subject line). + There *must* be a PEP for this. Guido won't read any more of the debate -- it's too voluminous, repetitive and contentious. He'll eventually read a PEP, though, *after* some sort of consensus is reached. A PEP requires a champion. I hope Huaiyu Zhu volunteers for this, as he's argued his case eloquently and rationally. The champion doesn't need to know how to implement it, but does need to summarize sometimes-opposing positions dispassionately. + There are things Guido will & won't tolerate. Guessing which is an interesting & educational challenge . For example, adding a new operator like .+ is fine, as the maximal-munch rule for lexing can resolve formal ambiguities easily. OTOH, *any* new operator symbol containing a backslash is dead before arrival -- backslash has purely "meta" meanings in Python today. If the goal is to make Python look exactly like some other language, forget it. It's still Python, with some light syntactic sugar to make life in special domains sweeter. + This one is from me, but it's a safe bet you can view at as precognitive channeling if you oppose it: anyone suggesting to, e.g., make ".+" mean something new and exciting for ints or floats or strings or ... will be shot. There are probably no operations on the builtin types used frequently enough to merit new syntactic shorthands (excepting, perhaps, that if P3K changes the meaning of integer division, a new "//" operator for flooring division was looked upon kindly in the past). The new operators are for convenience in special domains (where the case for them is indeed very strong), not an excuse to turn current Python into a cryptic mess. + Also from me: forget about user-defined precedence and associativity. The PEP must define these once & for all, and that's that. + The set of new operator symbols cannot be open-ended (as it is in, e.g., Haskell). There are at least 4 variants of Python tranlators already in existence, and Guido wants the set of operator symbols fixed so that a variety of parsing techniques can be used in their natural forms without trickery. IOW, the full set of operator symbols must-- as it is today --be a fixed finite set known in advance. + If the numerical folk can't reach consensus on the set of operators and what they should mean, my bet is that Guido will let this die rather than get sucked into Pronouncing on each of the points in dispute. After all, he has little personal use for this stuff: if the people who *do* want it can't agree, it's not worth having. how's-that-for-a-mysterious-announcement?-ly y'rs - tim From aahz at netcom.com Thu Jul 27 15:19:44 2000 From: aahz at netcom.com (Aahz Maruch) Date: 27 Jul 2000 19:19:44 GMT Subject: The State of Python References: <200007270038.TAA03951@cj20424-a.reston1.va.home.com> Message-ID: <8lq20g$kt1$1@nntp9.atl.mindspring.net> [posted & e-mailed] In article <200007270038.TAA03951 at cj20424-a.reston1.va.home.com>, Guido van Rossum wrote: > >I've placed the slides of my talk at the O'Reilly Open Source >Convention on-line at our BeOpen PythonLabs website: > > http://www.pythonlabs.com/talks.html It appears that the HTML version requires JavaScript. That's a Bad Idea. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Zie is so far from a clue that it would take a sub-light vessel several years to reach one. --Aahz From collins at rush.aero.org Thu Jul 6 21:39:17 2000 From: collins at rush.aero.org (collins at rush.aero.org) Date: Thu, 6 Jul 2000 18:39:17 -0700 Subject: (no subject) Message-ID: <200007070134.SAA31022@wd264.aero.org> smenard at alis.com, tismer at tismer.com, jcw at equi4.com, tseaver at starbase.neosoft.com,pbl at pbl.cx, m.ring at ndh.net, bwinton at iname.com, benpark at my-deja.com,thomas at xs4all.net, drek at zupa.bigstudios.com, senn at maya.com,burt at dfki.de, ulf.engstrom at b2b-link.com,calcium at altavista.net,tamer at tammura.at, karl at ulbrich.org, ddevilliers at lando.co.za Subject: [ANN] Python port to Palm Pilot Announcing the alpha port of Python-1.5.2+ to the Palm Pilot, available for download after 8AM PDT July7, 2000 at http://www.isr.uci.edu/projects/sensos/python/. This release includes the modified Python source and tools for creating Palm applications from Python modules. As a convenience, we include the gnu toolchain required to support the Python distribution on the Palm Pilot. We emphasize that this is an alpha release and is deficient in many respects. We are releasing it now to stimulate interest in Python on small computing platforms. Enjoy! From alex at magenta.com Thu Jul 27 08:39:10 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 27 Jul 2000 14:39:10 +0200 Subject: Perl is worse! (was: Python is Wierd!) References: <8losor$4bk$1@nnrp1.deja.com> Message-ID: <8lpand0gbg@news1.newsguy.com> "Jonathan" wrote in message news:8losor$4bk$1 at nnrp1.deja.com... [snip] > god - the whole thing now looks like a mess! I don't think i will ever > bother using PERL again (unless it's a 5-10 lines kind of thing). > Python's syntax now seem much 'cleaner' and intuitive. But then i guess [snip] > But the irony now is that ZOPE will be 'opened' to PERL too. I have > read through the 'debates' going on in the zope mailing list, but it > still doesn't make sense - why allow Zope to be polluted by something > that is clearly deficient? It's like allowing people to use sand > instead of cement to build a house. (I haven't mastered Zope yet, so i I may share your opinion of Perl (and, apparently, the rough outline of your history with it -- after using it a lot in the past, I'm never going to go back to it now that I've found out about Python), but I disagree with your assessment of letting people use Perl for Zope as a "pollution" of Zope. People get strongly attached to certain programming languages for all sort of reasons, be they good or bad, and it's not necessarily a framework developer's job to wean them away from them; if a framework can reasonably be made to support language X, and a framework designer's goal is to make the use of his own framework more widespread, then X should be supported if it has a significant "constituency", and can thus add to the framework's user base. And this is clearly the case here. People using Perl for web-related tasks are really legions (no matter that most of them hardly master over 50% of Perl's awesome, intricate complexity -- pragmatically, you CAN get things done, even if once in a while a flying brick [from some part of the language that remains obscure to you] hits you smack in the forehead). Maybe they'd be best advised to switch to Python, maybe not (I think they would, but that's quite another issue); but language-advocacy is not necessarily the framework developers' goal. I will piously hope that the *internals* of Zope remain in bright, clean Python (or C where needed, e.g. for speed purposes), but if that is so, then no "pollution" ensues if, over that Python-base, one is allowed to build superstructure in Perl, Visual Basic, Tcl, JScript, or whatever your least-favourite language happen to be. Think of it as a competitive advantage you will have, using beautiful Python over beautiful Zope, over the unwashed masses misguidedly using whatever other language (and/or web-framework)...:-). Alex From moshez at math.huji.ac.il Thu Jul 27 10:42:11 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 27 Jul 2000 17:42:11 +0300 (IDT) Subject: Will NumPy ever be built into standard Python dist? In-Reply-To: <39804498.B6182B66@wag.caltech.edu> Message-ID: On Thu, 27 Jul 2000, Richard P. Muller wrote: > Does anyone know whether there are plans to make NumPy part of the > standard Python distribution? I'm currently working on PEP 206, "Sumo interpreter", which is a souce distribution with many useful modules. For more information, see http://python.sourceforge.net/peps/ -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From gjohnson at gs.verio.net.bbs Mon Jul 17 20:10:01 2000 From: gjohnson at gs.verio.net.bbs (gjohnson at gs.verio.net.bbs) Date: 18 Jul 2000 00:10:01 GMT Subject: Internet Programming in Python Message-ID: <3bRUCQ$jLX@openbazaar.net> 1996 M&t books.. The Python Annotated Archives is 4 years newer "Stephen R. Figgins" wrote: > > Tony Johnson wrote: > > > > http://www.ora.com shuld carry this one... > > No, we didn't publish that one. I forget who did. > > Stephen R. Figgins > O'Reilly Network > -- > http://www.python.org/mailman/listinfo/python-list From thomas at cintra.no Thu Jul 20 09:06:13 2000 From: thomas at cintra.no (Thomas Weholt) Date: Thu, 20 Jul 2000 13:06:13 GMT Subject: Intercept methods/raise exception References: <3978f242.25036009@news.online.no> Message-ID: <3979f896.26656309@news.online.no> On Thu, 20 Jul 2000 12:41:16 GMT, thomas at cintra.no (Thomas Weholt) wrote: >Hi, > >Is there a way to define a method in a class that is called each time >every other method is called in that class, and based on a attribute, >raise an exception or let the method-class go thru? > >If I could raise some exception each time an object was accessed no >matter what, that would be great too, but I guess that`s stretching it >a bit far. > >I need this to control a huge object that's manipulated in many ways, >not always by it's own methods, sometime by altering attributes >directly. If I could trap any change in an objects properties or use >of its methods, that would be the best thing. > >Thanks. > >Thomas Hi, me again. I tried using __getattr__, like def __getattr__(self, attrname): print 'Trace:', attrname return getattr(self, attrname) But it crashed terribly. The object in question is accessed lots of times. When I ran it, it printed : Trace: __coerce__ Some hundred, thousands times, then collapsed with a bang. Any ideas?? Thomas From rhicks at rma.edu Tue Jul 11 09:57:41 2000 From: rhicks at rma.edu (Robert) Date: Tue, 11 Jul 2000 13:57:41 GMT Subject: [HELP] GNOME-PYTHON Message-ID: Does anyone know how to create a tabbed document interface in GNOME-PYTHON? Robert From thomas at xs4all.net Tue Jul 4 07:55:04 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 4 Jul 2000 13:55:04 +0200 Subject: Equivalent to ppm for Python? In-Reply-To: <3961CD63.553F6D46@dulcesol.es>; from pablo.prieto@dulcesol.es on Tue, Jul 04, 2000 at 12:41:23PM +0100 References: <3961881d$0$20233@wodc7nh6.news.uu.net> <3961CD63.553F6D46@dulcesol.es> Message-ID: <20000704135504.E283@xs4all.nl> On Tue, Jul 04, 2000 at 12:41:23PM +0100, Pablo Prieto wrote: > "donotspam-jen at personic.com" escribi?: > > Is there anything like PPM for Python? For those who don't know, PPM is the > > Perl Package Manager > > (http://www.activestate.com/Support/ActivePerl/PPM.html). PPM is a utility > > that will go out and download and install packages for you from the Internet > > (at least on Win32 -- I assume it works elsewhere, too). > Sorry. This is not a reply. Just a request for this question be answered > since I'm interested in it too. While it's not exactly what you mean (it doesn't (yet) go out and grab packages for you), Distutils, which comes with Python 2.0, is probably what you are looking for. See the Distutils SIG on www.python.org. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From grey at despair.rpglink.com Fri Jul 28 21:47:04 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Sat, 29 Jul 2000 01:47:04 GMT Subject: Perl is worse! References: <8losor$4bk$1@nnrp1.deja.com> <8lpt57$hsu$2@newshost.accu.uu.nl> <8lq5q6$fn4$1@newshost.accu.uu.nl> <8lspdu$m7e$1@newshost.accu.uu.nl> <20000728192952.A32288@exeter.exeter.org> Message-ID: On Sat, 29 Jul 2000 01:20:13 GMT, Huaiyu Zhu wrote: >That's good, because None usually indicates there is nothing (not even a >zero), It is different. Good, to me, is not having to check when I know what is going in there. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From robin at jessikat.fsnet.co.uk Wed Jul 19 06:59:06 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 19 Jul 2000 11:59:06 +0100 Subject: CVS missing xmlparse.h Message-ID: pyexpat.c(18) : fatal error C1083: Cannot open include file: 'xmlparse.h' -- Robin Becker From claird at starbase.neosoft.com Sun Jul 30 21:55:33 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Jul 2000 20:55:33 -0500 Subject: Python license (was RE: Python plug-ins for Adobe Products available) References: Message-ID: <6AF52BA0F6CB5412.B6BD1CBC48E4B721.8A4459A5D553A993@lp.airnews.net> In article , Tim Peters wrote: . . . >the most competent enitity in the universe to address GPL issues. And he's >been a good friend to Python despite that it wasn't released under a GNU >license. . . . ... also despite Python's status as not-LISP, and therefore foreign to him. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From pehr at pehr.net Wed Jul 12 02:15:28 2000 From: pehr at pehr.net (pehr anderson) Date: Wed, 12 Jul 2000 06:15:28 GMT Subject: Python and SSH References: <8kf4gl$fqm$1@saltmine.radix.net> Message-ID: <396BC629.E2706D3D@pehr.net> I'm guessing you want somebody to ssh to your box, and instead of their normal bash shell, they see your python app instead. This is easily doable by creating a new user and setting it's shell to be the name of your python app in /etc/passwd. If you look at /etc/passwd you will notice that most accounts have /bin/bash as the last argument. Just change that to be an absolute path to your python script! You move from this: ssh -- client | BIG BAD INTERNET | sshd -- daemon | bash -- user shell to do general stuff to this: ssh -- client | BIG BAD INTERNET | sshd -- daemon | your app as the user's default shell. Does this help? -pehr Cary O'Brien wrote: > > I'd like to have a running python process ACCEPT an incoming SSH > connection. Any ideas on how I could do this? > > -- cary From cpaulicka at 8cs.com Tue Jul 25 22:55:15 2000 From: cpaulicka at 8cs.com (Christopher Paulicka) Date: Tue, 25 Jul 2000 19:55:15 -0700 Subject: Two COM Questions: QueryInterface, and Callback Inheritance References: <3pnf5.50267$DH3.1583089@news-east.usenetserver.com> Message-ID: > How to QueryInterface for a new dispatch interface? > > You just perform the QI - but on the "_oleobj_" object. ie: > > > >>> import win32com.client > > >>> d = Dispatch("MyCoolThing.App") > > >>> s = d.GetOtherThing() > > You need to do something like: > >>> s = d.GetOtherThing() > >>> other_s = s._oleobj_.QueryInterface("{new_iid}") > >>> s = Dispatch(other_s) # Turn it back into a useful object. > Well, that seems straightforward. But, I get the following error message: >>> other_s = s._oleobj_.QueryInterface("{new_iid}") TypeError: There is no interface object registered that supports this IID # If I get the type of s, and try to use it's CLSID, that doesn't work. >>> print s >>> other_s = s._oleobj_.QueryInterface(DirectAnimationModule.IDAGeometry.CLSID) # Maybe EnsureModule hasn't registered this IID? # I try manually adding the CLSID directly >>> other_s = s._oleobj_.QueryInterface('{EB5093C7-56F9-11D2-88CE-00C04FA35859}') # That doesn't work either. # However, if I change the method (from above) >>> s = d.GetOtherThing() # So I rewrote GetOtherThing() directly in the makepy generated file # and put the ID in place def GetOtherThing(self, Duration=defaultNamedNotOptArg): ret = self._oleobj_.InvokeTypes(0x60020009, LCID, 1, (9, 0), ((5, 1),),Duration) if ret is not None: ret = win32com.client.Dispatch(ret, 'Duration', '{EB5093C7-56F9-11D2-88CE-00C04FA35859}', UnicodeToString=1) return ret # Now it works fine! # So, what can I do? It seems inelegant to have to change all of the automatically generated # methods, and wrong, since I am upcasting in effect. From seanmcgrath at my-deja.com Sun Jul 2 11:45:58 2000 From: seanmcgrath at my-deja.com (seanmcgrath at my-deja.com) Date: Sun, 02 Jul 2000 15:45:58 GMT Subject: __getattr__ and pickle References: <395f26a4.1832855@news.iol.ie> <395f2748.1996610@news.iol.ie> <395f27ab.2095753@news.iol.ie> <8F655BA3Egmcmhypernetcom@199.171.54.154> Message-ID: <8jno3n$p6m$1@nnrp2.deja.com> At 09:07 02/07/00 -0400, Gordon McMillan wrote: > >Do you have a __getinitargs__ or __getstate__ or __setstate__ that might be >triggering a call to __getattr__? > I don't have calls to __getinitargs__, __getstate__ or __setstate__. What I do have is a __getattr__ which I suspect is involved in this:-) The patient is pyxie.py (http://www.digitome.com/pyxie.py). The object I am trying to pickle is a tree structure. A variable CurPos points to a sub-ordinate object which can be of type xElement or xData. The __getattr__ hook achieves a Delphi-like effect in which attributes of these sub-ordinate objects appear as attributes of the top level object. It seemed like a good idea at the time:-) Here is a test program that reproduces the problem:- from pyxie import * try: import cPickle pickle = cPickle except ImportError: import pickle t = xTree() s = pickle.dumps (t) print s t1 = pickle.loads(s) When I try and pickle using the Python implementation of pickle, I get an exception: No attribute '__getstate__' on xTree or current xNode. I don't follow this as I thought __getstate__ was for fine tuning the information to be pickled. Using cPickle I don't get an exception at save time but instead get a GPF at load time. BTW, I have a test version of Pyxie with the __getattr__ stuff taken out and it pickled just fine. Picked versions of parsed XML trees load really quickly with it. What I am implementing is analagous to Pythons .py/.pyc idea. When Pyxie loads a tree it loads the binary version unless the plain text version has been modified more recently. When saving, it saves both binary and plain text XML every time. Works great! >Does an Irishman like to talk? > Only on days that end in a "y":-) regards, Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Fri Jul 28 17:09:56 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 28 Jul 2000 23:09:56 +0200 Subject: Perl is worse! References: <8lse9j01oti@news2.newsguy.com> Message-ID: <8lst4r02grr@news2.newsguy.com> "Steve Lamb" wrote in message news:slrn8o3jap.49c.grey at teleute.rpglink.com... [snip] > >But, back to %members...: > >Why organize it like that, rather than just index it directly with a > >(name,number) pair? Presumably, because Perl cannot use a pair as an index, > >but wants a scalar? But that's no problem in Python, so (guessing at your > >snipped parts): > > Exactly. Actually I normally use something like $name."|".$index for a > later split(). I hope you remember that in Python there's no need for the joining and later re-splitting: just putting the pair (tuple) in there is so much easier and more natural. > >a single string, but the % operator has the advantage of being > >easily tailorable > > I never did like the whole placeholder for actual values in print > statements or other similar constructs. I fail to see why one must do that > instead of putting what you want there. Among other things, it makes it easy to save/load/change a format-string; you are encoding that much information as easily-handled data, rather than as harder-to-handle executable code. It's also easier to ensure that the same, identical format-string is used in various places: just use a variable to identify it. If/when it changes, it's changed in ONE place; this is the kind of thing that's harder to do with code. (You could do it by moving the formatting into a function, but then what's the advantage of myformat(name,index) over myformat%(name,index)...?-). It's a long-running querelle in C++, which suggests a style like std::cout << a << b << c; in place of C's classical printf (format-string-based) approach. A format-string does have the disadvantage of encoding the type information _away_ from the object (which you may not think of as a disadvantage, but most people do:-). However, in Python this may not be a problem, since the % operator is defined to call the string-conversion for the items in the right-hand operand that correspond to a %s on the left; so, the object can get control if it wants to, by overriding the convert-to-string special method. There's nothing stopping a C++ programmer from defining a similar formatting operator, of course, but it doesn't seem to be happening much that I can see. But this is all about occasions in which the formatting really matters -- when it must match an externally imposed standard, or it must be displayed to the end-user. Such formats tend to be subject to frequent, finicky changes, so having them as easily changed strings is particularly nice. When no such constraint obtains, Python generally permits you to just use the tuple -- guaranteeing no data loss, maximum simplicity, directness. You just don't have to put strings together, to split them up again later, as much as is usual in Perl (it was _mandatory_ in Perl 4, which had no rich data structures; it's still _popular_ in Perl 5, for various reasons). [about warts] > I'm not saying it is the same. I am just refuting claims that Python > doesn't have then and that they are, senseless, wretched, horrible or any > other negative description people care to place on it. It is different and as > someone (you, mayhap?) said that even typing isn't good in all cases. I'm not quite sure what you're saying, but there's a well-known URL out there (which I forget, but hope someone else will remind us of:-), of a well-known Pythonista, collecting Python's warts. It's good to keep aware of them, particularly in a language that makes so many of us so enthusiastic, or how will they ever be fixed? The types-vs-classes dychotomy is mentioned there, maybe that is what you are thinking of, but it's really a piece of exoterica which practically strikes very few people. I doubt you'll find much concurrence that automatic conversion of strings to numbers in the context of arithmetic is anything but a . I've already listed several reasons (such as the multiplication of operators and other linenoise this approach implies -- by forcing operators to determine context, you need separate operators for concatenation and replication, versus those for addition and multiplication; by letting type determine context, Python needs far fewer). Many more have been listed by others. You're unconvinced, but I guess that's okay. But I can't think of even one area where Perl, as a language, has any advantage at all over Python (there may be areas not connected to language design, such as the quality of available books, which are harder to call). Why else would I have been so happy, so utterly happy, to leave 8 years of Perl experience behind and start over from scratch with Python? It may have to do with the way my mind (and that of other ardent Pythonistas) clicks, versus the mental processes of equally ardent Perlites. Python never surprises me; when I don't know for a fact how something works, and I guess rather than looking it up, I get it right 90%. Perl, even after many years, kept coming up with surprises for me. I think Python is objectively simpler: fewer keywords, fewer builtins, no weirdly named variables with similarly weird effects, etc, etc. And if you've ever looked at the C sources of Python versus those of Perl, I think you'll find just as much difference in complexity. Very similar absolute-power, very different complexity-levels to achieve that power. But that simplicity be a _virtue_, post-modern redundance a _vice_, is an aesthetic judgment whose practical value will no doubt depend on the way each individual's mental processes work -- and there's a lot of variation in that (thanks be!). Just as I consider C++'s complexity a vice (but still use it a lot, because I've found no other technology _dominating_ it, i.e., better for _all_ purposes; and also, _that_ is a complexity which I managed to absorb at well over 90%, not fully satisfactorily to me, but easily in the top centile, and enough for much effectiveness -- _Perl's_ complexity seems of a different kind...), so I do Perl's. But I acknowlegde that they're two languages with an extremely wide user-base, so, assuming other people have made totally rational and informed judgments and evaluations (perhaps a rash assumption; one year ago, for example, I had never evaluated Python...), there must be many minds for which such complexity works a charm... Alex From MichaelDyck at home.com Sat Jul 22 02:32:33 2000 From: MichaelDyck at home.com (Michael Dyck) Date: Sat, 22 Jul 2000 06:32:33 GMT Subject: Parser project References: <397361C5.1D401DF2@prescod.net> Message-ID: <39793FE7.D2C12A32@home.com> Paul Prescod wrote: > > Here is a project for a parser hacker: > > Write a Python module that can read a grammar in the syntax that Python > uses (see Grammar/Grammar in the source distribution) and generate a > parser object without any special compilation stage: This itself would not be too difficult, but I'm not sure it would be as helpful as you think. > from newparser import Parser > > parser=Parser( grammar="/python/src/Grammar/Grammar" ) > parsetree=parser.parse( sys.argv[1] ) > code=compileast( parsetree ) > eval( code ) > > With this tool, people could easily write Python-like languages in > Python by making changes to the grammar. This would be great for those > who want to experiment with new language features without building (and > distributing) a special version of Python. Let's say you invented a > Python-like language for matrices. You would tell people to install > Python and then invoke your code like this: > > python matrixLang.py helloworld.mtrx So matrixLang.py would look like the above code, but with "/python/src/Grammar/Grammar" replaced with the name of a file containing the MatrixLang grammar, yes? So `parsetree' would be a parse-tree for the content of helloworld.mtrx. The problem is that it would be a parse-tree corresponding to the *MatrixLang* grammar (e.g., it might contain MatrixLiteral nodes, and TransposeOperator nodes). And you can't give such a parse-tree to compileast (or actually, to sequence2ast or tuple2ast, whose result you would then pass to compileast): it wouldn't know anything about such nodes. Instead, you need another step that transforms `parsetree' into a parse-tree that's acceptable to sequence2ast/tuple2ast. In the example, this would have to transform MatrixLiteral and TransposeOperator nodes into the equivalent standard-Python constructs. Well, I guess that wouldn't be too difficult either (and maybe you had this in mind anyway and glossed over it as the "easy" part), but it's something that would have to be written on a per-language-invention basis, as opposed to the run-time parser-constructor, which need only be written once. > ... It's not > that doing this is impossible today, it just isn't as easy as it would > be if there were a module that could parse things at runtime and was > compatible with Python's grammar syntax. Yes, I suppose it would be easier. Now if only I had some time to do some parser hacking... -Michael Dyck MichaelDyck at home.com From vtbl.moorepe at memo.volvo.se Fri Jul 14 11:51:26 2000 From: vtbl.moorepe at memo.volvo.se (PM) Date: Fri, 14 Jul 2000 15:51:26 +0000 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kmtab$4or$1@pollux.ip-plus.net> <396F131C.4AD83C8A@memo.volvo.se> Message-ID: <396F36C4.D7795CEC@memo.volvo.se> Sorry, I believe the 2 are unrelated. I was feeling a little sardonic as usual, I will show more restraint next time :) Albert Hofkamp wrote: > > On Fri, 14 Jul 2000 13:19:00 +0000, PM wrote: > >I should like it to kick c#'s butt, perhaps > > People who fall for that trap don't deserve to be rescued. > > Albert > --- > Look ma, windows without Windows !! From akuchlin at mems-exchange.org Sat Jul 22 09:36:40 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Jul 2000 09:36:40 -0400 Subject: PyPGP? References: <39751C1A.5F476774@mastnet.net> Message-ID: <3dn1jaxp5j.fsf@kronos.cnri.reston.va.us> John Clonts writes: > Is this a current effort? No, it's dead, and was written in the days of PGP 2.6.2. The file format has changed subsequently, so the code would need to be updated to match the latest OpenPGP RFC. > Is there some other or better source for PGP encrypt/decrypt services > for Python? It's probably best to use GnuPG with its --batch flag, which causes it to output lines which can be readily parsed by another program. I have a partially written class for GnuPG that supports verifying, but I still need to finish the other 3 functions. --amk From pngann at hare.demon.co.uk Fri Jul 21 11:32:52 2000 From: pngann at hare.demon.co.uk (Les Smithson) Date: 21 Jul 2000 16:32:52 +0100 Subject: ANN: Pyxal - Python Home Automation X10 driver Message-ID: I'd like to announce pyxal, a new Python language interface for Home Automation X10 controllers. Details are at http://www.hare.demon.co.uk/pyxal.html. Pyxal presents a device independent, OS neutral, extensible API for controlling X10 devices. It is written 100% in Python, and needs no external 'C' extensions. Pyxal allows Python scripts to control home appliances connected using X10 devices & controllers. Pyxal can be used with any supported X10 controller on any supported platform. Pyxal scripts can be used without modification with any supported X10 controller. Pyxal needs volunteers for X10 controller development, & porting/testing. If you would like to help, see http://sourceforge.net/projects/pyxal. From lull at acm.org Sun Jul 23 11:00:26 2000 From: lull at acm.org (John Lull) Date: 23 Jul 2000 10:00:26 -0500 Subject: Discussion: new operators for numerical computation References: <8l6vul$5ig$1@slb3.atl.mindspring.net> <39772612.CE635178@fft.be> <39774EFA.62287E6E@nih.gov> <%_Rd5.36763$6y5.24594893@news2.rdc2.tx.home.com> <50ggnss2rhdf2uh3pe6m4o1slib9d6fvko@4ax.com> Message-ID: (posted & mailed) hzhu at knowledgetrack.com (Huaiyu Zhu) wrote (with possible deletions): > Would someone like to make a brief summary of the thread on (*) type > operators? I did not follow all of them, and can't seem to be able to > figure out what the consensus is now. Whether this goes into the PEP, it > would be nice to have a summary of the discussion so far. Thanks. I think Tim Hochberg's summary in message is pretty good. > John, would you volunteer? If you think something more is needed, I'm willing to try, but I'm not sure what else is needed. Regards, John From tim.hochberg at ieee.org Thu Jul 27 11:07:27 2000 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 27 Jul 2000 15:07:27 GMT Subject: linear algebra in pure Python? References: <397E9CBC.2AD8FA89@crystal.uwa.edu.au> <397F9D1B.F6DA7037@crystal.uwa.edu.au> Message-ID: Douglas du Boulay writes: > Tim Hochberg wrote: > > package. Another option would be to use JNumeric which is a (more or > > less) drop in replacement for Numeric for use with JPython. The > > LinearAlgebra package has not, unfortunately, been ported(1), but if > > Thanks, Yes I have already looked at JNumeric. I actually spent a week > or so > modifying the PyMultiarray to accept Measurement (value,variance) pairs > and propogate them through multiplication addition etc, only to find out > that the matrix vector arithmetic I was doing (predominantly 3x3 or 4x4) > took from 10 to 30 times longer than the original pure-python based > matrix class (exploiting lists of lists) which I was using. > Needless to say I was disapointed. I am sure it would be terrific > as the matrices get larger, but I don't need that at the moment. > > I suspect the big killer was the very repetitious type coercions > involved, > which require construction of many temporary matrices > (and which I don't have any control over). I'd be interested in seeing an example of the code that was running slow for you. It may provide ideas / motivation for speeding up some aspect of JNumeric. > On the topic of JNumeric, are you interested in a wedge/cross > product and Levi-Cevita antisymmetric tensor function add on for > PyMultiarray, or would that blow the equivalence with Numeric? I'd also be interested in seeing this code. I'm not sure if I'd role it in right now since if NumPy2 becomes a reality, I may be changing JNumeric dramatically so that I can take advantage of the Python code that will be written for that. -tim From moshez at math.huji.ac.il Tue Jul 18 03:41:45 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 18 Jul 2000 10:41:45 +0300 (IDT) Subject: Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation) In-Reply-To: Message-ID: On Tue, 18 Jul 2000, Huaiyu Zhu wrote: > On Mon, 17 Jul 2000 18:11:13 -0500, Paul Prescod wrote: > > > There are even techniques for making your > >language work on the interpreter line. We can help with that. > > Where is this? Is it also included in the references you mentioned? I don't > have time or expertise to examine these, but someone else might. No, we really meant that we'll help yo. Have a look at the way IDLE emulates the Python interpreter -- you can easily see how to run your own compile() function rather then the built-in one. About .mpy modules: check out the CVS's imputils. About custom compilation: check out nondist/compiler for a compiler written in Python you can easily change. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. http://advogato.org/person/moshez From ge at nowhere.none Wed Jul 26 14:06:29 2000 From: ge at nowhere.none (Grant Edwards) Date: 26 Jul 2000 13:06:29 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jul 26) Message-ID: Andrew Kuchling launches an experimental biweekly summary of Python-Dev mailing list traffic with a report on the crucial events of July 1-15 http://deja.com/=dnc/getdoc.xp?AN=647837404 Alex Martelli literately summarizes how to make an object act like a sequence http://deja.com/=dnc/getdoc.xp?AN=650880554 Shae Erisson posts a link to gnetstat, a Linux application that accesses low-level network info with Python http://deja.com/=dnc/getdoc.xp?AN=650496918 Paul Prescod recruits for a documentation tool project http://deja.com/=dnc/getdoc.xp?AN=647947358 Discussion of new operators for numerical computations continues http://deja.com/=dnc/getdoc.xp?AN=648382865 Peter Schnieder-Kamp polls sentiment on looping over multiple sequences http://deja.com/=dnc/getdoc.xp?AN=648552485 Python Enhancement Proposals (PEPs) are now available on the Web http://deja.com/=dnc/getdoc.xp?AN=648866455 Robin Becker announces ReportLab 1.00 release http://deja.com/=dnc/getdoc.xp?AN=648636917 Will Ware annouces ELF file analysis tool http://deja.com/=dnc/getdoc.xp?AN=648657536 Merger of Python and Perl is announced (joke) http://deja.com/=dnc/getdoc.xp?AN=648674597 Cooperation between Tcl and Python encouraged (not a joke) http://deja.com/=dnc/viewthread.xp?AN=648818049 Les Smithson releases Pyxal, an X10 device control API http://deja.com/=dnc/getdoc.xp?AN=649149571 Proposal for attribute access handlers http://deja.com/=dnc/getdoc.xp?AN=649357419 PythonLauncher.exe is a python script launcher http://deja.com/=dnc/getdoc.xp?AN=649945564 Henning Schroeder announces BoboMail 0.4 http://deja.com/=dnc/getdoc.xp?AN=650207893 Benyang Tang announces a smart ftp client written in Python http://deja.com/=dnc/getdoc.xp?AN=647977749 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org eff-bot's complements this digest with his daily python url http://hem.passagen.se/eff/url.htm Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From SBrunning at trisystems.co.uk Thu Jul 20 07:19:20 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 20 Jul 2000 12:19:20 +0100 Subject: zip() : how about braid() Message-ID: <31575A892FF6D1118F5800600846864D4C7087@intrepid> >What's the silliest keyword you ever encountered in a programming language? >I vote for "rof". (short for Rolling-On-Floor, i think in ALGOL68.) INTERCAL has 'COME FROM', 'PLEASE DO' and 'GIVE UP'. But then it's *supposed* to be silly. 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 fredp at mygale.org.nospam Mon Jul 24 05:18:40 2000 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 24 Jul 2000 09:18:40 GMT Subject: Auto-follow-up : text-mode (but not CLI) apps in Windows console References: <8F7682C13PaCmAnRDLM@195.25.12.37> Message-ID: <8F7B7276BPaCmAnRDLM@161.48.76.20> A quick note to conclude my search : although the Win32 curses port from Poland submitted by Radovan Garabik definitely works, it is after all, as Grant Edwards pointed out, "still curses" (and probably a simplified one, it doesn't seem to do colors for instance). It turns out that there is (at least) one alternative that was right under my nose (on Parnassus) right from the start. What tripped me is that it was not under the 'Text UI' section, but with the Windows-specific stuff (as it indeed is). It is the 'Windows Console Driver' by the (very) famous Fredrik Lundh (note: URL has changed, is now http://w1.132.telia.com/~u13208596/console.htm ) It is a small windows DLL with a tiny, optional Python wrapper module. It's about as low-level as the curses wrapper, but of course has a very pythonesque feel to it, so is much more natural to use. It also handles colors very simply. Lastly, instead of the traditional getch() method, it uses a simple event system that gives more keyboard control and allows mouse input (it shows that FL is a Tkinter guru :). It does not seem to be maintained (early 1999) but it does work perfectly (at least under Win 9x, FL says there are issued with the NT console, I haven't tried). I don't know if anyone has already built any higher-level widgets on this (there is a reference to a 'uiToolkit/Text' in the readme, but this is another hidden secret :). Anyway, all I really need is a basic listbox manager, that shouldn't be to hard to do. So, to recap : if like me you need a Windows-only, non-GUI console app with some full-screen text interface and a bare minimum of additional baggage to the standard distribution, Dr Lundh's contribution is probably the easiest way in... Thanks to all who have helped me ! FP -- YAFAP : http://www.multimania.com/fredp/ From jhe at webde-ag.de Thu Jul 27 12:38:12 2000 From: jhe at webde-ag.de (Jürgen Hermann) Date: Thu, 27 Jul 2000 18:38:12 +0200 Subject: cgi dectection References: <39804dc7_1@news.chariot.net.au> <39805CC7.DE18566F@rubic.com> Message-ID: <8lpoe8$1jf$1@pollux.ip-plus.net> "Jeff Bauer" schrieb im Newsbeitrag news:39805CC7.DE18566F at rubic.com... > I usually build test cgi scripts by checking for the > SERVER_PROTOCOL environment variable, e.g.: The more obvious and stable check is GATEWAY_INTERFACE = = CGI/1.1 From samschul at pacbell.net Sun Jul 23 18:05:13 2000 From: samschul at pacbell.net (Sam Schulenburg) Date: Sun, 23 Jul 2000 22:05:13 GMT Subject: IDLE window disappears - more info References: <397A3EEA.792BDDEB@helicon.net> <1use5.617$Gh.13635@news20.bellglobal.com> <397AFD92.7F17FFD1@helicon.net> <397B0D93.6A5EE7CB@helicon.net> Message-ID: <8lfq6o$g07$1@nnrp1.deja.com> Usually the problem is IDLE can not find the Tk dll's. My solution has been to copy the Dll's from the Tk\bin directory to the Python\DLL directory. Sam Schulenburg In article , "Olivier Dagenais" wrote: > The Python binary might be in your path, but maybe the libraries aren't? > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Carleton University - Computer Science III > > "Rodney Loisel" wrote in message > news:397B0D93.6A5EE7CB at helicon.net... > > Changed the DOS properties not to close on exit > > the following is the result of > > import Tkinter > > several levels of error > > last: > > DLL load failed: one of the library files > > needed to run this application cannot be > > found. > > rloisel > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From dnotspam-jen at personic.com Sun Jul 2 18:19:29 2000 From: dnotspam-jen at personic.com (donotspam-jen@personic.com) Date: Sun, 2 Jul 2000 15:19:29 -0700 Subject: Communicating between two computers References: <395d48b3$0$21842@wodc7nh0.news.uu.net> Message-ID: <395fbcd8$0$5627@wodc7nh0.news.uu.net> I checked out the link, but from what I read, it sounds like this is a client-side implementation only. Is there more info on this somewhere? Maybe some examples of how to use this? Thanks! Jen "David Bolen" wrote in message news:uem5e38if.fsf at ctwd0143.fitlinxx.com... > Well, there's probably no end to the number of protocols and methods > by which you could get the machines to talk, but given that it's > Python invoking Python, you might take a peek at Fredrik Lundh's > XML-RPC library. XML-RPC was sort of the precursor to SOAP. Similar > in concept, but it's dirt simple to get two Python processes > communicating (calling arbitrary methods with any Python objects and > returning any Python objects). > > See http://www.pythonware.com/products/xmlrpc/index.htm. From moshez at math.huji.ac.il Sat Jul 1 07:12:07 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 1 Jul 2000 14:12:07 +0300 (IDT) Subject: Example how to use cgihttpserver In-Reply-To: <395CBBCA.9A241134@decrc.abb.de> Message-ID: On Fri, 30 Jun 2000, Peter Mueller wrote: > Hi, > > is there an example how to use the cgihttpserver in a way that some cgi > scripts are in /cgi-bin/* (this is simple) and others are coded in the > program itself. A simple example reading the FieldStorage, generating a > page ... would me help very much. The trick is to use (for the hard-coded "cgi" scripts) the cgi module with non-default parameters: instead of os.environ, use a special dictionary, and instead of sys.stdin, use self.rfile. You'll have to hack something up, and I'm not aware of any ready made examples, but this should give you enough to go on. -- Moshe Zadka There is no GOD but Python, and HTTP is its prophet. From paulb at infercor.no Fri Jul 28 04:42:15 2000 From: paulb at infercor.no (Paul Boddie) Date: Fri, 28 Jul 2000 10:42:15 +0200 Subject: Perl is worse! References: Message-ID: <39814767.FFEFE5D0@infercor.no> Steve Lamb wrote: > > On Fri, 28 Jul 2000 01:24:08 -0400, Tim Peters wrote: > >Steve, in case it isn't clear yet, Python programmers *want* to be blown out > >of the water when doing something as senseless as > > > 1 + "foo" > > It isn't senseless. That is the whole point. It is only senseless > because of typing. Clearly you cannot add a word to a number, granted. But > what of 1 + "1"? That isn't senseless, those are two numbers. I can see they > are two numbers, it is only because of typing that it fails. Having seen Perl's behaviour in cases like the one Tim quoted, albeit in the following form... 1 + $variable (trying to remember Perl syntax) where $variable is some text which should have been a number but for various reasons happened to be something like "foo", I would rather my chosen implementation language did raise an exception than pretend nothing was wrong. > So I ask you this /VERY/ simple question. Why can't Python do both? Hm? > What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it > together? If it is a string that cannot be converted to an integer, throw an > exception, otherwise, do it. Then that preserves the 1 + "foo" exception and > also does the sane thing of getting rid of types when it makes sense to do so. What about 1 + "23"? Is "23" a decimal number or a hexadecimal number or what? > Hell, why do an exception at all? Why not do what is already done with > integers, reals and floats? > > 1 + 1 = math > > 1 + "1" = math > > 1 + "foo" = string ("1foo") Doesn't Perl do this last one as well? I refer you to the example I give above - to have such behaviour permeating one's code is "nasty" to say the least. > "foo" + "foo" = string ("foofoo") > > You already accept: > > 1 + 1 = integer > > 1 + 1.2 = float > > 1 + 1j = complex > > So please don't tell me you don't want "automagic" type changing when it > is already there and, I'd wager, you use it extensively. Actually, this kind of thing does irritate some people, but at least one can claim that such behaviour for numbers is more or less accepted in wider circles, whereas 1 + "foo" is meaningless to almost everyone except Perl coders. Regards, Paul From olivierS.dagenaisP at canadaA.comM.bbs Sat Jul 15 18:50:02 2000 From: olivierS.dagenaisP at canadaA.comM.bbs (olivierS.dagenaisP at canadaA.comM.bbs) Date: 15 Jul 2000 22:50:02 GMT Subject: wxDesigner: Commercial dialog editor for wxWindows and wxPython Message-ID: <3bQ18Q$m5t@openbazaar.net> Coming from VB, I decided to give the editor a try. It's nice, but I wouldn't pay 70 american dollars for it. I hope my comments will be useful... Great points: 1 - I love the idea of representing the hiearchy of sizers and widgets in a treeview, especially that you use different icons for the two. Would be even better if you used an icon representing the type of widget, and put the widget name as the node's string value. 2 - Ability to test your dialog. This is great to make sure it resizes correctly. 3 - Ability to output to C++, Pyhthon or XML. Would be even cooler if you exposed the objects so more persisters could be written (by third parties) 4 - Highlighting the current widget and the widget's parent. Excellent to keep track of the relationships. Not so great points: 5 - The toolbars at the top of the editor are overwhelming (at first) and it would be very nice to either re-organize/customize them, to dock/undock sections or to turn them on and off at will. Maybe giving the toolbars names, too, would help disambiguate the actions. 6 - Inability to move controls around (drag and drop) after they are placed on the form (without resorting to cut/paste - which, incidentally, doesn't work with Ctrl+Insert, Shift+Delete and Shift+Insert, respectively Copy, Cut and Paste) 7 - No keyboard support, especially the DELETE key not doing anything in either the treeview or the main editor. 8 - Must use a seperate dialog to change properties of widgets or containers. A property grid would be excellent for this. 9 - Right-clicking on nodes of the treeview does nothing. If suggestion "1" was implemented, it would be nice to have the same context menu as there is when right-clicking on the widget itself. 10 - Single document interface makes it hard to do many things at once. (maybe this is a limitation of wxWindows?) 11 - Unable to select multiple controls (to move them all around, to cut/copy them all, to delete them all, etc..) 12 - There's no "Proportional" button in the toolbar. (???) 13 - "Empty spaces" only show up blank. It would be nice if the editor gave you an indication that you had put an "empty space" on the form, only when you are editing. 14 - New widgets appear in a weird way. I'd like to drag a new widget in the spot I want it to go, instead of deciding ahead of time where it will go before or after the currently selected widget. (So, to add a new widget, I have to first click on an existing one, click either before or after, then click on the new one. I usually think of it backwards: I choose a new widget then find where to put it.) 15 - Closed source, commercial product. I would want to help out if it was open-source. I would also be willing to pay for the product, if it had the features I mention above... It's a promising product. I'll be happy to test out the next version, as I really like the hiearchical representation of the relationships and it could prove very useful in designing large applications. Good luck! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III "Robert Roebling" wrote in message news:39700FD0.3C368827 at ruf.uni-freiburg.de... > > Hello, > > [I am using this list, since the python-announce list is no > longer functional.] > > I would like to announce wxDesigner 1.0, a commercial program > that can be used in connection with the free C++ GUI wxWindows > library and its populare Python bindings called wxPython. > > wxDesigner is a dialog editor that allows its users to visually > create dialogs using a simple point and click interface. The > output produced by wxDesigner can be either of C++ code, Python > code or XML, making co-development with wxWindows and wxPython > much easier than before. > > wxDesigner is available for Windows and Linux (Intel and PowerPC), > more information including pricing is available from: > > http://www.roebling.de > > For more information about wxWindows and wxPython, have a look at: > > http://www.wxwindows.org > http://www.wxpython.org > > Regards, > > Robert Roebling > >

wxDesigner 1.0 - > Commercial dialog editor for wxWindows and wxPython. (13-July-2000) > > From billtut at microsoft.com Thu Jul 6 20:55:40 2000 From: billtut at microsoft.com (Bill Tutt) Date: Thu, 6 Jul 2000 17:55:40 -0700 Subject: Win32com ADO curiosity #1: MoveNext Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BD280@RED-MSG-50> Because this is Python, and not VB or VBScript. It's a language syntax thing. Bill -----Original Message----- From: mksql at my-deja.com [mailto:mksql at my-deja.com] Sent: Thursday, July 06, 2000 1:21 PM To: python-list at python.org Subject: Win32com ADO curiosity #1: MoveNext In the following code (rs refers to an ADO recordset already created): print rs.Fields(1).Value rs.MoveNext print rs.Fields(1).Value prints the same record twice, while: print rs.Fields(1).Value rs.MoveNext() print rs.Fields(1).Value prints 2 records, as expected. Why does MoveNext require the () ? The ADO object model does not specify parameters for MoveNext, MoveFirst, etc. Sent via Deja.com http://www.deja.com/ Before you buy. -- http://www.python.org/mailman/listinfo/python-list From GustavsB at ch.sibt.com Tue Jul 18 02:09:51 2000 From: GustavsB at ch.sibt.com (Bruno Gustavs) Date: Tue, 18 Jul 2000 08:09:51 +0200 Subject: Top 10 Language Constructs (Phyton) References: <8kmkam$m45$1@pollux.ip-plus.net> <396EE7BC.DA2FA7B3@darwin.in-berlin.de> <8kmtab$4or$1@pollux.ip-plus.net> <8kmurf$6rf$1@nnrp1.deja.com> Message-ID: <8l0s89$np4$1@pollux.ip-plus.net> "John Grayson" wrote in message news:8kmurf$6rf$1 at nnrp1.deja.com... > Oh, well now I understand! > You've reached the wrong newsgroup: you want comp.lang.phyton. > You might get a reponse there! (or not...) Shame on me! As an old dyslexic I was able to misspell the name of Python :-( Shame on me! Bruno Gustavs From gmcm at hypernet.com Sat Jul 22 22:16:26 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: 23 Jul 2000 02:16:26 GMT Subject: Newbie pythoner, with bizzare problem References: <8F79257Amilenkomoonshinecouk@194.73.73.116> <66BC56277B82FC67.B3EED2DD79D7AFED.2311A1AB38DBA14A@lp.airnews.net> <8F7974AF5gmcmhypernetcom@199.171.54.194> <3979CE02.D2744B7E@prescod.net> <8F79AAFA3gmcmhypernetcom@199.171.54.154> <397A03A4.68E6CB09@prescod.net> Message-ID: <8F79E7CF6gmcmhypernetcom@199.171.54.194> Paul Prescod wrote: >Gordon McMillan wrote: >> >> Only sometimes. At other times __builtins__ is a dictionary, so >> >> inp = __builtins__.open("...") >> >> would fail, and you'd have to use >> >> inp = __builtins__['open']("....") > >Why is __builtins__ a shape-shifter? Here's a hint: >>> exec('print type(__builtins__)', {},{}) >>> exec('print type(__builtins__)', globals(),locals()) >>> Similarly, __builtins__ is a module in a script, but it's a dict inside a module. Someplace in the docs it says not to use __builtins__ directly since it's basically a contrivance to allow controlling the environment in which code runs. -Gordon From kelley at bioreason.com Fri Jul 14 06:15:25 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 14 Jul 2000 11:15:25 +0100 Subject: Is pickle buggy? References: <396B069A.9EBDD68B@muc.das-werk.de> Message-ID: <396EE83D.FB60B033@bioreason.com> jepler epler wrote: > On Tue, 11 Jul 2000 13:35:54 +0200, Thomas Thiele > wrote: > >Hallo! I try it again, becouse it is important: > > > >Why does this programm (pickle) eats memory? > >Why does pickle (marshal in it) not freeing the whole memory? > > > >And not cPickle eats more memory! > > > > The following code will produce the memory leak without invoking pickle: > > def uniquestring(): # the code to generate those unique 5-letter strings > > while 1: > eval(`uniquestring()`) > I don't get that behavior on windowsNT. If I directly intern(uniquestring()) then memory gets eaten extremely fast, not on the order of hours but on the order of minutes. I'll let eval(`uniquestring()`) run for a while and see what happens. > > If you think this sucks, you're probably right. See how fast memory gets eaten directly with intern() (I'm not saying intern isn't the culprit though...) > > > Jeff -- Brian Kelley Bioreason, Inc 505 995-8188 ext 207 150 Washington St Suite 303 kelley at bioreason.com Santa Fe, NM, 87501 From grey at despair.rpglink.com Mon Jul 31 04:32:49 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 31 Jul 2000 08:32:49 GMT Subject: Perl is worse! (was: Python is Wierd!) References: <200007280137.LAA30715@envy.fulcrum.com.au> <4rj2osseh99vpqos0pvosoh84s5jq7sbs3@4ax.com> <8lsca101hv4@news2.newsguy.com> Message-ID: On Mon, 31 Jul 2000 02:08:14 GMT, Grant Edwards wrote: >Only if "debone" is a valid operation for the object "peach" and if dial is >a valid operation for the object "waffle-iron". You can't state a-priori >that this is the case. >In real-life only certain operations are valid for a particular object. In real-life you can't make them valid for a certain object, in a programming language you can which is exactly why trying to magle real-world limitations upon the constructs of a computer is, well, not exactly the most ideal thing to do. >>>I don't understand the analogy. Pens are not responsible for >>>parsing English sentances and proofreading them. They're >>>responsible for leaving a visible trail when they're dragged >>>across a paper surface. >> Exactly. >Huh? The pen doesn't toss an exception, neither should the language since they are both /tools/. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From loewis at informatik.hu-berlin.de Sun Jul 9 06:12:53 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Jul 2000 12:12:53 +0200 Subject: What about try:except:finally References: <3967d908.363887342@news.online.no> Message-ID: Matthew Schinckel writes: > Yes, but if you want a statement executed regardless of whether there was > an exception or not, you need to use a finally clause. That also shows that having try:except:finally is perhaps not a good idea. Given try: A except: B finally: C is that the same as try: try: A finally: C except: B or as try: try: A except: B finally: C or is it something else? If so, what would it be? And why not one of the others? Regards, Martin From jriehl at lucent.com Tue Jul 25 00:17:30 2000 From: jriehl at lucent.com (Jon Riehl) Date: Mon, 24 Jul 2000 23:17:30 -0500 Subject: Parser project References: <397361C5.1D401DF2@prescod.net> Message-ID: <397D14DA.CCDE8AA0@lucent.com> Paul Prescod wrote: > > Here is a project for a parser hacker: > > Write a Python module that can read a grammar in the syntax that Python > uses (see Grammar/Grammar in the source distribution) and generate a > parser object without any special compilation stage: > Some of this stuff fits under the scope of the Basil project. See the following URL's: http://www.wildideas.org/basil/ http://sourceforge.net/projects/basil/ http://c2.com/cgi/wiki?BasilProject I have every intention of building a pgen integration for building parsers from pgen specs. However, the current CVS code only has a parser for Bison grammars. Parse trees would be dumped in either an AST pickle format or XML (I need to whip my current C++ integration into shape in order to illustrate the utility already hidden in Basil.) A back end would then need to be developed to translate any other language into a Python code object. Via con GRAD, -Jon From pduffin at hursley.ibm.com Fri Jul 28 05:56:29 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Fri, 28 Jul 2000 10:56:29 +0100 Subject: polymorphism (was Re: Type checking in python?) References: <8lmo4i$s28$1@news.kth.se> <8lor06$hof$1@news.kth.se> Message-ID: <398158CD.9ED1D20E@hursley.ibm.com> Oivvio Polite wrote: > > After all this I still don't get the difference between polymorphism and > overloading. I've just ordered a book on OO design. So maybe that > distinction will become clearer to me, then again, maybe it won't :) > An overloaded function is a function whose behaviour is dependent on the type of information you give it. The types of information that the function supports is limited by the implementation of the function. A polymorphic function is a function whose behaviour is independent of the type of information you give it. The types of information that the function supports is limited to those types which support the set of operations that the function requires. From ge at nowhere.none Thu Jul 20 13:24:59 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 20 Jul 2000 17:24:59 GMT Subject: Trouble when overloading operator[ ] References: <8l720o$lr4$1@nnrp1.deja.com> <8l76hm$pm9$1@nnrp1.deja.com> Message-ID: In article <8l76hm$pm9$1 at nnrp1.deja.com>, david_ullrich at my-deja.com wrote: > You can use the notation [2,3] to accomplish the same >thing: it appears that if you use multiple indices they >get passed as a tuple to __getitem__: You're not using multiple indices. You're using a single index whose value is the expression 2,3. The expression 2,3 evaluates to a tuple, which is passed to _getitem__, just as would the value of any other expression used as an index. -- Grant Edwards grante Yow! My Aunt MAUREEN was at a military advisor to IKE & visi.com TINA TURNER!! From sblakey at freei.com Wed Jul 26 14:28:48 2000 From: sblakey at freei.com (Sean Blakey) Date: Wed, 26 Jul 2000 11:28:48 -0700 Subject: polymorphism (was Re: Type checking in python?) In-Reply-To: <8lmo4i$s28$1@news.kth.se>; from oivvio@cajal.mbb.ki.se on Wed, Jul 26, 2000 at 03:14:01PM +0200 References: <8lmo4i$s28$1@news.kth.se> Message-ID: <20000726112848.A1101@freei.com> On Wed, Jul 26, 2000 at 03:14:01PM +0200, Oivvio Polite wrote: > Hi all. > > I'm building a class with a uniform interface and I'm trying to come to > terms with polymorphism in python. > > For instance I want the constructor to take either a filename, a file object > or a database connection object. > In C++ this would be done using three different constructors. (I'm not quite > sure about this, cause I don't know C++ :-) > But how should one do it in python. > > My first idea was something like this: > > class myclass: > def __init__:(self, arg): > if type(arg) == types.StringType: > #check if that's a filename and do the right initialization. > elif type(arg) == types.FileType: > #do the initialization in an other way > # and so on > In my experience, using the type() builtin is more pain than it's worth. I like the scheme proposed by Alex Martelli, except that I would have used def __init__(filename='', fileobject=None, dbconn=None): instead (personal style I guess. I like to keep strings as strings, even if they are "false" strings). The critical point is that in Python, polymorphism depends solely on the interface provided, not on any "is-a" relationships. Instead of insisting that your argument must be a string (for example), your code should work with any object that exposes the interfaces you need (strings, unicode strings, perhaps even a custom class created by somebody to emulate Java's StringBuffer, etc.). Similarly, you don't need to verify that your argument is a file, only that it has a read() method (or whatever method you use). Alternately, to keep closer to the style of your original: class myclass: def __init__(self, arg): try: if os.path.isfile(arg): # Do proper string initialization here except TypeError: #not a string try: data = arg.read() # File intialization except (AttributeError, TypeError): #Not a file # DB Connection initialization -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 Computers are unreliable, but humans are even more unreliable. Any system which depends on human reliability is unreliable. -- Gilb From paul at prescod.net Wed Jul 19 12:07:01 2000 From: paul at prescod.net (Paul Prescod) Date: Wed, 19 Jul 2000 11:07:01 -0500 Subject: Type checking in python? References: <397296BC.415C97E1@prescod.net> <3974C185.E39E082E@prescod.net> Message-ID: <3975D225.DB8FCDFD@prescod.net> Eric Hopper wrote: > >... > > OK, genericity. I call generic programming 'inheritance for the lazy'. But it has nothing to do with inheritance! > Of the modern languages, the one I can think of right offhand is Java. > And that's something I actually like about it. Java does not require inheritance to do genericity either. Java does require you to pre-declare your interfaces, but you "implement" an interface. You do not inherit from it. That's just terminology, though. > So, what class do you need to define a read method for? Where did that > object get passed in? What if the read method is only called in some odd > circumstance that manages to excape anyone's notice for years? If you want to check that the read method is defined, you can do that at method boundaries. You don't need to enforce an inheritance hierarchy. -- Paul Prescod - Not encumbered by corporate consensus Just how compassionate can a Republican get before he has to leave the GOP and join Vegans for Global Justice? ... One moment, George W. Bush is holding a get-to-know-you meeting with a bunch of gay Republicans. The next he is holding forth on education or the environment ... It is enough to make a red-blooded conservative choke on his spotted-owl drumstick. - April 29th, Economist From NoSpam at NoSpam.com Tue Jul 11 12:00:25 2000 From: NoSpam at NoSpam.com (Tom) Date: Tue, 11 Jul 2000 16:00:25 GMT Subject: Looking for a tree widget with control of text color References: Message-ID: Ok, I found TreeWidget. I was looking at the current (v1.5.2) source code, it is in the 1.6 alpha code. Tom. "richard_chamberlain" wrote in message news:XExa5.10600$_O.178276 at news2-win.server.ntlworld.com... > Hi Tom, > > If you look in your python directory under tools you should see idle, in > there is TreeWidget.py. > > It would be no problem getting Tkinter to do what you want but it would take > a bit of effort on your part. > > Richard > Tom wrote in message > news:SMta5.147482$7o1.3697839 at news2.rdc1.on.home.com... > > > > Is there a tree widget for wxPython or TKinter that support setting the > text > > color (foreground or background) for each node? > > > > Ideally it could also be updated dynamically. > > > > I heard that there is a good tree widget in IDLE, called TreeWidget, but I > > can't find it. Do I have the name right? I found the IDLE source code in > > with the Python 1.5.2 source code but there was nothing called TreeWidget > > there. > > > > Thanks, > > > > Tom. > > > > > > > > From fiona at sitegnome.com.bbs Sat Jul 15 21:00:02 2000 From: fiona at sitegnome.com.bbs (fiona at sitegnome.com.bbs) Date: 16 Jul 2000 01:00:02 GMT Subject: [FAQTS] Python Knowledge Base Update -- July 15th, 2000 Message-ID: <3bQ4R3$ib_@openbazaar.net> Hi List, Here are the latest entries into http://python.faqts.com cheers, Fiona ## Unanswered Questions ######################################## ------------------------------------------------------------- Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class http://www.faqts.com/knowledge-base/view.phtml/aid/4734 ------------------------------------------------------------- Nils Otto Johansen ## New Entries ################################################# ------------------------------------------------------------- Where can I find a DB-API connection to Sybase? http://www.faqts.com/knowledge-base/view.phtml/aid/4753 ------------------------------------------------------------- Fiona Czuczman Paul Boddie The 'ctsybasemodule' apparently resides at the following URL: http://starship.python.net/crew/pgodman/ Whilst 'ctsybasemodule' is rather nice, I found it insufficient for my purposes (no "bind variables" in SQL statements) and decided on mxODBC instead: http://starship.python.net/crew/lemburg/mxODBC.html If you decide to pursue that option, I would suggest looking at my ODBC resources page: http://www.crosswinds.net/~pboddie/Python/mxODBC.html I managed to get mxODBC working with Adaptive Server Anywhere and Adaptive Server Enterprise, but with the recent announcement of zxJDBC you could use JPython and Sybase's jConnect software instead: http://www.ziclix.com/zxjdbc/ http://www.jpython.org http://www.sybase.com/products/internet/jconnect/ ------------------------------------------------------------- How can I call an .exe file from inside a .py file? http://www.faqts.com/knowledge-base/view.phtml/aid/4757 ------------------------------------------------------------- Fiona Czuczman Alex Shindich, Gregoire Welraeds Try this: import os os.execl ('foo.exe') For more info read http://www.python.org/doc/current/lib/os-process.html execl is kind of an alias for execv. So using this solution, be aware of the following: execv (path, args) Execute the executable path with argument list args, replacing the current process (i.e., the Python interpreter). The argument list may be a tuple or list of strings. Availability: Unix, Windows. This mean that if you have the following code in a file: import os os.execv("/bin/ls",("ls","/")) print "Done!" The last line will never be executed because the python process is replaced by the /bin/ls command. To avoid this, Unix allows you to use the fork system call : import os i= os.fork() if i != 0: os.waitpid(i,0) # wait for the child to complete. print done! else: # child process os.execv("/bin/ls",("ls","/")) Another and easier solution, which also works under Windows : import os os.system("foo.exe") print 'Done!' ## Edited Entries ############################################## ------------------------------------------------------------- How can you check on the status of a file's "archive" bit, on DOS-type platforms http://www.faqts.com/knowledge-base/view.phtml/aid/4706 ------------------------------------------------------------- Barry Pederson, Fiona Czuczman http://www.python.org/windows/win32all/,Alex Martelli On Win32, with Hammond's extensions: PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au) >>> from win32file import GetFileAttributes >>> GetFileAttributes("C:/witha.txt") 32 >>> GetFileAttributes("C:/withouta.txt") 128 >>> where witha.txt does have the A attribute and withouta.txt lacks it. You can also use symbolic names for the constants: >>> import win32file >>> win32file.FILE_ATTRIBUTE_ARCHIVE 32 >>> win32file.FILE_ATTRIBUTE_NORMAL 128 >>> Note that the 'normal' bits seems to be set if and only if no other bits are set. Other attributes in the bitmask behave more normally, i.e., they are bitwise-or'ed to give all attributes of the file. For example, after making witha.txt read-only (still _with_ the A attribute as well), we have: >>> GetFileAttributes("C:/witha.txt") 33 >>> win32file.FILE_ATTRIBUTE_READONLY 1 >>> I.e., the attributes of the file are the bitwise-or of archive and readonly. So, if you only want to test for archive, and don't care about the others, you'll bitwise-and GetFileAttributes' result with FILE_ATTRIBUTE_ARCHIVE, rather than testing for equality! From paul at prescod.net.bbs Sun Jul 16 13:30:03 2000 From: paul at prescod.net.bbs (paul at prescod.net.bbs) Date: 16 Jul 2000 17:30:03 GMT Subject: ANNOUNCE: Visual Python v0.1 for KDE and GNOME Message-ID: <3bQUGR$lC7@openbazaar.net> Phil Thompson wrote: > > ... > > The Visual Python home page is at http://www.thekompany.com/projects/vp/. Be careful. When I worked at Watcom we tried to make "Visual REXX" to hear that some other company (not Microsoft, but obviously related to Microsoft) had a trademark on Visual X where X is a programming language. Microsoft licenses the name and other people are supposed to also. Of course this was years and years ago so I don't know what the current situation is. -- Paul Prescod - Not encumbered by corporate consensus It's difficult to extract sense from strings, but they're the only communication coin we can count on. - http://www.cs.yale.edu/~perlis-alan/quotes.html From hansup at prolynx.com Fri Jul 7 14:25:34 2000 From: hansup at prolynx.com (Hans F. Updyke) Date: Fri, 7 Jul 2000 12:25:34 -0600 Subject: urllib question References: <394B196F.5ED9E73@fizzylab.com> Message-ID: paul at fizzylab.com wrote in message <394B196F.5ED9E73 at fizzylab.com>... >Why does the first example work, but not the second (actual >URL not supplied, but you get the idea)? [snip] >u = urllib.urlopen(string.join(["http://cnn.com/", >"index.html"])) >print u.read() O.K. I'm also new at Python, but I think I see a problem. Try this: >>> sample = string.join(["http://cnn.com/","index.html"]) >>> print sample You should see that the two list members have been joined with a space in between. I suspect the web server only responded to the first part of your expected URL. You probably got the results you wanted by accident --- "index.html" used as default response when no page name submitted in URL request. In other words, you would see the same output even if you used a different valid page name. You can avoid the included space by specifying an empty string as the delimiter in the string.join method. In my example, it would look like this: >>> sample = string.join(["http://cnn.com/","index.html"], "") I'm not sure if this approach will fix your "montstrousQueryString?withParameters" example. AFAIK, there could be other lingering problems I'm not smart enough to spot. Also-learning-this-stuff-ly y'rs HansUp From mbaker at 0x7a69.net Tue Jul 25 21:44:44 2000 From: mbaker at 0x7a69.net (Mark Baker) Date: Tue, 25 Jul 2000 20:44:44 -0500 Subject: Python is wierd! References: <8lj7kr$ttc$1@nnrp1.deja.com> <8ljrvu09t6@news1.newsguy.com> Message-ID: In article <8ljrvu09t6 at news1.newsguy.com>, "Alex Martelli" wrote: >> 1. There are no keywords to declare static or instance variables; it >> all depends where they are placed(whether it's right after the >> statement, or inside a ). Isn't it harder for other programmers to >> know at one glance what type of attributes the class define? > > I see a "self.something=23", I know "self" is an instance variable; no > muss, no fuss. MUCH clearer than the implicit-this convention of C++ > and Java. Explicit self -> less weirdness, not more. Er....sort of. class A: a = 200 def __init__(self, x, y): self.x = x self.y = y def sum(self): return self.x + self.y + self.a # Scope within class, but accessible via self a = A(10, 20) a.sum() => 230 An instance does a lookup inside of its class if something isn't found within itself. >> 2. No *formal* declaration of static class methods, e.g. no 'static' >> keyword (though i'm not sure how useful static methods are in OOP >> design). I read somewhere in this newsgroup that the workaround way is >> to define the method outside of the class - doesn't it break the >> 'encapsulation' a class suppose to have? > > Encapsulation in Python is a matter of convention (as it actually ends > up being in all languages, but most strive hard to make it appear they > enforce it:-). Static methods are not particularly useful when you can > have free-standing functions in their stead, and grouping by-module is > more productive than by-class (the class is not the natural unit of > encapsulation, an issue that is also acknowledged by the package concept > of Java and the friend keyword in C++). friend is simply an evil way of violating encapsulation. It's not analogous to modules, packages, or anything else. It simply provides a means of violating C++'s encapsulation (usually for speed purposes, since you should be able to use the accessor/mutator pattern to work with object properties) packages and modules are more akin to categories or namespaces than the main unit of encapsulation, in an object sense. Static functions aren't overly useful in Python because of the existance of these categories, and the lack of enforced encapsulation. Mostly the latter, but they're made more practical with the former. >> codes... However, after reading the python book, my head is still >> spinning, trying to catch all the 'intricacies' of this language. No > > But there aren't any. That's why it's so powerful!-) Oh, there're a few. Just 99.9% of the time it probably is irrelevant to the average Joe. Cyclic references, meta-class magic, some other minor stuff. > Python, together with Smalltalk, Scheme, or Rexx, is an outstanding > candidate for the _second_ way to look at the world. Of these, Python > would be my favourite were I to pick such a language today. Many first year CS students are subjected to Scheme, and most of the ones I've been in contact with have considered switching majors because of it. I'd stick with one of the first two, for beginners. Smalltalk with its uniformity and snapshot nature, and Python with its expected mathematical operator precedance and non-class enforced view of programming. > (Other languages such as Perl, C++, Ada, Common Lisp, and so > on, I view for different reasons as too complex and obtrusive to be good > first-programming-languages, and similarly for lower-level languages > such as C, machine language of any ilk, or Forth). This is all especially true if you want to subject children to programming early on, which is probably the best idea. At this point they aren't going to need machine-oriented (C, C++, ...) or bloated languages (Common LISP, Ada, Perl, C++, ...). In the long run any software engineer or computer scientist will need to learn how the machines function, and how to make them do specific things. For everyone else, there're practical languages. =)