From aleaxit at yahoo.com Thu Apr 12 11:07:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Apr 2001 17:07:08 +0200 Subject: #define (was Re: python-list@python.org) References: <01041208054801.01378@tos1.ralphpill.com> <20010412144018.A14948@freedom.puma-ag.com> Message-ID: <9b4gck0cdd@news1.newsguy.com> "Vincent A. Primavera" wrote in message news:mailman.987079936.13897.python-list at python.org... > Hello, > What I am trying to accomplish is to shorten statements such as > stdscr.addstr(10, 10, 'This is a test...', curses.color_pair(1))... ;o} > nothing too complicated. You don't need a #define (i.e., macros) for this; just wrap this statement into a function, with whatever arguments and defaults you desire. Suppose, for example, that (were this C) you would code: #define SAY(text,y) stdscr_addstr(10, y, text, curses_color_pair(1)) The Pythonic equivalent would then be: def SAY(text, y): stdscr.addstr(10, y, text, curses.color_pair(1)) and of course, you can have default-valued arguments: def SAY(text, y, color=None): if color is None: color = curses.color_pair(1) stdscr.addstr(10, y, text, color) Nothing too complicated -- just nice, powerful, simple. I.e., Python. Alex From rdsteph at earthlink.net Fri Apr 13 16:43:11 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Fri, 13 Apr 2001 20:43:11 GMT Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <9b7iaq0dep@news2.newsguy.com> Message-ID: <3AD6161F.16F5AC19@earthlink.net> Alex Martelli wrote: > > OK. Now, is each of these programs in a separate .py file, or > is each a function, each with a different name, inside the same > main .py file? > ...yes, right now they are in separate .py files. I will try this solution. Later, Alex offers this super code.... > > while 1: > input_string = raw_input(prompt) > try: > input_code = int(input_string) > else: > if 1<=input_code<=num_programs: > function = functions[input_code-1] + '.py' > function() > break > > > goto's this would be trivial. Now, I consider a nested set of "if " > > statements that determines which number was chosen, but still how do I > > "jump" to the correct sub-program??? Even if I define the subprograms as > > functions even, how do I jump to them??? > > You don't really "jump" in this approach -- you do _invoke_ your > code (in a file or function), but, when that is done (if without > raising exceptions), you get back to the point from where you > had invoked it. Which is why I have the "break" statement, to > end the 'while 1' loop when the operation of the subprogram > is finished. (If errors were to be expected and caught, the > function-call would be placed inside a try/except statement). > > Alex Thanks Alex!!! I also am looking right now at your Python cookbook web site...wow this is a really great resource, thanks to you from me and from all Python learners and users future and present!!! I guess in the case of the while loop above, I could nest the while loop in a one bigger while loop that ask "do you want to run another program option quit?" Or, alternatively, and perhaps better, I could imbed a statement asking that question after the else code, immediately before the "break" statement, asking the same question. That would be better, I think... Thanks!!!! From nas at python.ca Sun Apr 29 13:54:17 2001 From: nas at python.ca (Neil Schemenauer) Date: Sun, 29 Apr 2001 10:54:17 -0700 Subject: Sockets: Sending/receiving arbitrary amounts of data In-Reply-To: ; from danielk@aracnet.com on Sun, Apr 29, 2001 at 09:20:45AM -0700 References: Message-ID: <20010429105417.B5249@glacier.fnational.com> Daniel Klein wrote: > What if the server doesn't know in advance how much data will > be sent from the client? You need to build this into your protocol. A lot of existing protocols use terminators to signal the end of data like "\r\n" or something similar. I like using Dan Bernstein's netstring protocol: http://cr.yp.to/proto/netstrings.txt Just an example, if you want to send an arbitrary string the sender would use: def write_string(s, sock): sock.send("%lu:" % len(s)) sock.send(s) sock.send(",") data = "Hello World" write_string(data, sock) reciever: def read_string(sock): size = "" while 1: c = sock.recv(1) if c == ":": break elif not c: raise IOError, "short netstring read" size = size + c size = int(size) s = sock.recv(size) if len(s) != size: raise IOError, "short netstring read" if sock.recv(1) != ",": raise IOError, "missing netstring terminator" return s data = read_string(sock) Obviously the global "sock" must be an open socket connecting the two programs. Some advantages of the netstring protocal is that it is efficient, especially for large messages. It makes it much easier to dynamicly manage memory since the reciever knows in advance how much data is coming. It is also 8 bit clean which means you can send arbirary data and do things like embed netstrings inside of other netstrings. Neil From bkline at rksystems.com Tue Apr 3 09:27:08 2001 From: bkline at rksystems.com (Bob Kline) Date: Tue, 3 Apr 2001 09:27:08 -0400 (EDT) Subject: Broken link in documentation Message-ID: One of the instructions in section 3.1 ("A Cookbook Approach") of Guido's "Extending and Embedding the Python Interpreter" says "Get David Ascher's compile.py script from http://starship.python.net/crew/da/compile/." but that link is broken. My original intention was to scout around with Google, find where it had been moved to, and submit a patch for the docs. What I found instead were old copies, old context diffs, and inconclusive threads along these lines: "Does anyone have a copy of David Ascher's compile.py from his starship pages? The links there appear to be broken, and David appearantly hasn't been able to find time to look for a copy, or can't find it (I've sent him another mail about it in case it has turned up), and documentation users are asking about it. (There's a link from the extending & embedding manual.) "If anyone has a copy, perhaps I could find provide a temporary location for it and revise the link in the online documentation to point there, as a stop-gap measure." [1] Is this as much in limbo as it appears to have been last summer? [1] http://mail.python.org/pipermail/python-dev/2000-June/004776.html -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com From jmarshal at mathworks.com Mon Apr 2 15:11:42 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 2 Apr 2001 19:11:42 GMT Subject: Python and Java Compared? References: <3ac6f744_1@news4.newsfeeds.com> <9aagjo$sfk$1@nntp6.u.washington.edu> Message-ID: <9aaite$s1e$1@news.mathworks.com> In addition to this strength of Python: > - Dynamically typed and interpreted. Both of these make code clearer, > much easier to write and much more malleable. Interpreted code is also > easier to test. It is hard to overstate how valuable these factors are > for reliability -- far outweighing, in my mind, the value of strong > typing (though better optional type checking would be nice to have). I'd like to add a strength of Java: - Strong static typing. Many errors are caught at compile-time, rather than runtime (which could be a user's runtime and not your own). Also, code with explicit type information is often more self-documenting. From donn at oz.net Fri Apr 13 01:30:32 2001 From: donn at oz.net (Donn Cave) Date: 13 Apr 2001 05:30:32 GMT Subject: os.system question References: Message-ID: <9b62to$lti$0@216.39.151.169> Quoth Thomas Duterme : | This may sound silly, but I have a question on os.system(). | | Let's say I have a script while calls some program XXX via | os.system(). Will python wait for XXX to finish what its Yes. | ... but what if I wanted | python to just mosey on down while launching a | subprocess...(ie not wait) How would this be done? Where you're invoking another program, you can use the os.spawnv() function or one of its relatives in both cases. >>> print os.spawnv.__doc__ spawnv(mode, file, args) -> integer Execute file with arguments from args in a subprocess. If mode == P_NOWAIT return the pid of the process. If mode == P_WAIT return the process's exit code if it exits normally; otherwise return -SIG, where SIG is the signal that killed it. That's better not only because you can get what you're asking for, but also because the value of args is passed directly to the program instead of having to be interpreted by a shell, as in os.system(). That interpretation step is not so terribly expensive, but it's vulnerable to terrible errors if the data may contain shell metacharacters. Donn Cave, donn at oz.net From kevin_cazabon at hotmail.nospamplease!.com Sat Apr 21 14:47:15 2001 From: kevin_cazabon at hotmail.nospamplease!.com (Kevin Cazabon) Date: Sat, 21 Apr 2001 12:47:15 -0600 Subject: Animation with Tk References: <3AE1915D.E9207C3@internode.on.net> Message-ID: "PoD" wrote in message news:3AE1915D.E9207C3 at internode.on.net... | Nick Perkins wrote: | def after_callback(self): | do_animation_stuff() + # make sure to do an update + self.root.update_idletasks() | self.root.after(100,self.after_callback) From DavidA at ActiveState.com Wed Apr 11 12:56:48 2001 From: DavidA at ActiveState.com (David Ascher) Date: Wed, 11 Apr 2001 09:56:48 -0700 Subject: Komodo in violation of Mozilla Public License? References: <3AD36E75.EE5A5EA7@optushome.com.au> Message-ID: <3AD48CD0.F8B5C2A3@ActiveState.com> phil hunt wrote: > > On Tue, 10 Apr 2001 15:23:08 -0700, David Ascher wrote: > > > > Komodo is not Open Source or Free Software, true. > > If i write some Python programs in Komodo, and then wish to modify > them in a system that doesn't include Komodo, will I have any problems? No! Komodo doesn't "own" the code written with it. It's just an IDE! Even Emacs doesn't spread the GPL to code written with Emacs =). > (For example. many Java IDEs include a window-painting application > that lets you dynamically build GUIs, and generated Java code from > that. If you subsequently want to alter your GUI, you can either > use the same tool to alter it, or edit the generated Java code > directly (which means you can't subsequently use the tool to edit > your modifications)). > > Does Komodo include a GUI painting application, if so, does it have > this caharacteristic? No, and even if it did, we'd make sure that we didn't put any restriction on any generated code. These kinds of restrictions are (IMO) silly to the point of counterproductive -- we want people to be productive programmers and have no fear using our tools, we don't want to own your work! > Avoiding lock-in needn't prevent a software company from gaining > revenue from the sale-value of their software; a time-deleyed oepn > source license allows both criteria to sit comfortably. Have > ActiveState considered that for Komodo, e.g. a license that releases > the current Komodo code as GPL (or some other license) in, say, > 3 years' time? We always consider licensing choices, and are always open to suggestions. However, I think it's important to note a key difference -- Komodo is not necessary for doing anything. It's not like Komodo is a key piece of IT infrastructure which you (the customer) would ever be in a position to rely on to the point of being locked in. This is (again, speaking for myself) the key factor which drives whether what ActiveState does is Open Source or not -- technology which is 'key infrastructure' should be Open Source because it lets people and companies build the systems they want to build with no lock-in. Hence PyXPCOM is Open Source -- we think it's really really cool technology, and we're proud of it, and it cost us a fair bit of money to develop, but we think it belongs in the 'key IT technology' category, so we don't try to extract revenue from it. The same need is not as present for technologies and products which simply make people more productive, make a process more efficient, or otherwise 'enhance' a process or procedure. We think it fair to get some revenue from the latter. It is always up to the customer to decide whether the benefit is worth the cost. Cheers, --David Ascher PS: If people have concerns about corporate licensing policies, they should feel free to express them, of course. Typically, however, such feedback is more likely to be effective if it's directed to the companies directly instead of posted on a newsgroup. Now, I have no problem with having this particular discussion out in the open [*], but I can assure you that companies react more favorably to constructive emails sent to the appropriate people than to what some perceive as 'attacks' out in the public. It's just how companies operate, for better or worse. [*] I do have a very small issue with conversations about ancient theories of cognitive science going under the heading "ActiveState going the wrong way", but that's Usenet and I live with it =). PS: My own take on the recall/storage/reading/lookup/encoding/memory topic is that after getting a PhD in cognitive science and seeing theories come and go and reading through dozens of experimental reports and suffering through my fair share of experiments, I'll stick with Conan Doyle, William James, and the like. They wrote much better than modern scientists typically do, and their intuitions are much more entertaining than most data. =) PPS: Andrew, you should mine James for quotations if you haven't already. My PhD advisor has an collection, although I don't think he's indexed it. See for example "The Principles of Psychology" nicely available at: http://www.emory.edu/EDUCATION/mfp/james.html. The man figured out most of cognitve science and cognitive neuroscience a hundred years ago =). From kens at sightreader.com Mon Apr 9 21:41:43 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 9 Apr 2001 18:41:43 -0700 Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> Message-ID: <001f01c0c15f$65fe4370$04090a0a@upcast.com> Hmm, did you know that Mark works at ActiveState? (They liked PythonWin too). :-) ----- Original Message ----- From: "Costas Menico" Newsgroups: comp.lang.python To: Sent: Monday, April 09, 2001 6:03 PM Subject: ActiveState going the wrong way > I think ActiveState's Komodo tool is very poorly designed. It is real > slow and even harder to use. I dont understand why they didnt take > something like PythonWin (a much better IDE) and enhance it? > > Also the idea of a multiprogramming environment is just a dream. No > one is going to program in Python and Perl at the same time. Most > people choose a language and stay with it. An IDE that tries to > accomodate multiple languages is a poor IDE. Each language has its > strengths and weaknesses and the IDE is supposed to ehnance them. Not > burden with another languages issues. > > Installation took me longer than installing Windows (anyway it felt > like it). I understand the concept of using Mozilla but I think it > stinks. Get rid of it. > > I am sorry I am so critical of this but I am frustrated with poorly > designed tools. > > Someone should look at PythonWin and enhance it. I would be willing to > pay money for that one. Hey Mark how about it? > > And now to the Komodo uninstall icon. > > costas > -- > http://mail.python.org/mailman/listinfo/python-list > From dnew at san.rr.com Wed Apr 4 12:32:28 2001 From: dnew at san.rr.com (Darren New) Date: Wed, 04 Apr 2001 16:32:28 GMT Subject: Booleans (was: Conditional operator in Python?) References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> <9aadjg$ipg$1@nntp6.u.washington.edu> <9acvud$uk6$1@nntp6.u.washington.edu> Message-ID: <3ACB4C9D.A966E8C7@san.rr.com> Bruce Sass wrote: > What do you do when you want boolean data from a remote site, but the > link is down. You could give up and wait for the link to come back, > use a hardcoded default, or defer to something else which returns a > value you can use. All I did was include the definition of what to do > in the boolean class so the three cases could be handled as such: Actually, I found the best mechanism for my needs, when I did something like this, was to have an object with a five-state value (definitely, probably, maybe, probably not, and definitely not), a textual message, and a level above which this would be considered "true" if all you wanted was a boolean. So if, for example, you were checking an email address, you could do something like definitely - email got delivered probably - final machine was down, but email got queued on an MX host maybe - email got queued locally, address is syntactically valid probably not - heuristics fixed the address and it queued OK ("1234,567" -> 1234.567 at compuserve.com) definitely not - Couldn't figure out what the email address was. Then, for this, you'd likely set the "ok" level at "maybe", meaning "maybe or better should be treated as success", but you could still check the details, with the text string available for logging/debugging. Just a class I found myself using all *over* the place when doing failure-prone internet stuff. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. schedule.c:7: warning: assignment makes calendar_week from programmer_week without a cast. From shaleh at valinux.com Wed Apr 4 12:26:12 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 04 Apr 2001 09:26:12 -0700 (PDT) Subject: "not x in" vs. "x not in" In-Reply-To: Message-ID: On 04-Apr-2001 Kristian Ovaska wrote: > list = [1,2,3,4] > not 5 in list > 5 not in list > > Why is there a "not in" operator? For clarity? > > (Not that I oppose "not in" in any way. I like it. I'm just curious.) > works in my 1.5.2 interpreter >>> l = range(0,10) >>> if 2 not in l: ... print '2 is not in l' ... >>> if 11 not in l: ... print '11 is not in l' ... 11 is not in l >>> From Peek at LVCM.comNOSPAM Wed Apr 18 00:23:00 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Tue, 17 Apr 2001 21:23:00 -0700 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: "If you make a product that even a complete idiot can use, then only a complete idiot will want to use it"... I agree with Doug. Think outside of the box-- don't build a box around your limited view of the universe... "Douglas Alan" wrote in message news:lcd7ab6y2s.fsf at gaffa.mit.edu... < snip > > I don't want my language trying to force bad programmers to write good > code. If this is some sort of official design goal of Python, then it > is a misguided and impossible one. < snip > > "Everything should be as simple as possible, but no simpler." < snip > > A macro capability doesn't detract from this. < snip > > A bad programmer has many tools available to him in Python, as it is, > to make hard to understand code. I don't think it would go over well > to remove useful features from the language to prevent this. < snip > From aleaxit at yahoo.com Wed Apr 25 09:48:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Apr 2001 15:48:08 +0200 Subject: None :) References: <3AE6CBC8.B473F622@inenco.no> Message-ID: <9c6km1025go@news2.newsguy.com> "Hans Kristian Ruud" wrote in message news:3AE6CBC8.B473F622 at inenco.no... > When an element in a sequence s is None, > max (s) will return None: > > >>> s = [1.4, 2.5, None, 4354549999L] > >>> max(s) > >>> > >>> min(s) > 1.4 > > I could'nt find anything about this particular case > in "Learning Python" by Lutz and Ascher. Nor in the FAQ. Comparisons among objects of different types return repeatable (within one run) but 'unpredictable' (a priori) results. On your implementation/platform/run, type None seems to have returned 'greater' than numerics... but you can't rely on that "in general"! Alex From cribeiro at mail.inet.com.br Mon Apr 23 21:15:49 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Mon, 23 Apr 2001 22:15:49 -0300 Subject: Python + Borland - msvcrt = grr. In-Reply-To: Message-ID: <5.0.2.1.0.20010423221402.02382aa0@mail.inet.com.br> At 07:06 23/04/01 +0000, Stephen wrote: >Howdy, > > I just sent in the patch to fix up all the Python sources to let it >compile from the Borland free compiler or C++Builder. This leaves two issues >remaining before I put up the projects/makefiles somewhere: When are you planning to release it? If you can give us a pointer, it would be nice. As for the Borland C++ compiler + Python combo, I gave it a try some weeks ago, but stopped pretty soon. I hate to keep makefiles :-) Carlos Ribeiro From aleaxit at yahoo.com Wed Apr 11 12:20:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Apr 2001 18:20:37 +0200 Subject: Redirect stdout References: Message-ID: <9b208q02hqj@news2.newsguy.com> "Fernando Rodr?guez" wrote in message news:ihe8dtcr8eau6to14996pjm789s7lqohna at 4ax.com... > How can I temporarely redirect stdout to a string? import cStringIO, sys astring = cStringIO.StringIO() saveout = sys.stdout sys.stdout = astring try: # whatever code you want to # run with "redirected" stdout print "hello there!" finally: # make sure stdout is restored sys.stdout = saveout # and here is all the output that # was done 'redirected'...: print astring.getvalue() Alex From sebastien.libert at comexis.com Wed Apr 11 05:19:59 2001 From: sebastien.libert at comexis.com (Sébastien Libert) Date: Wed, 11 Apr 2001 11:19:59 +0200 Subject: HTMLgen - CSS CLASS How to... Message-ID: <3ad41ff2$0$189$456d72a3@news.skynet.be> Hello, I use HTMLgen to generate a website. I use 2 classes from HTMLgen : Table and TemplateDocument. How can i specify a class for the tag or .... My HTML template document contains a CSS with specific CLASS Sample : --My CSS-- --My template-- ... {table_here} .. --Generated HTML--

So i want to have Thx ! From news at myNOSPAM.org Tue Apr 24 00:57:47 2001 From: news at myNOSPAM.org (Stephen Hansen) Date: Tue, 24 Apr 2001 04:57:47 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: I submitted the patch to Sourceforge, its #418147. I'm going to upload another file to the patch to fix 'msvcrt' to compile fine, and then the CVS should compile straight out of the box for Borland... it'll give you one HUGE bunch of warnings (200+!) but they are all nuisances and not important. As for the makefiles&projects -- either tonight or tomorrow i'll upload them somewhere. :) --Stephen (replace 'NOSPAM' with 'seraph' to respond in email) "Carlos Ribeiro" wrote in message news:mailman.988074875.4803.python-list at python.org... > At 07:06 23/04/01 +0000, Stephen wrote: > >Howdy, > > > > I just sent in the patch to fix up all the Python sources to let it > >compile from the Borland free compiler or C++Builder. This leaves two issues > >remaining before I put up the projects/makefiles somewhere: > > When are you planning to release it? If you can give us a pointer, it would > be nice. As for the Borland C++ compiler + Python combo, I gave it a try > some weeks ago, but stopped pretty soon. I hate to keep makefiles :-) > > > Carlos Ribeiro > > > From jkraska1 at san.rr.com Mon Apr 23 20:03:27 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 24 Apr 2001 00:03:27 GMT Subject: string->list->string Message-ID: So. I forget how to do this AGAIN. I know how to convert a string to a list: mylist = str ("alpha") but I don't remember the shorthand for converting it back? On another note, is there a module somewhere that knows how to strip an entire set of user-specified characters from a string, ala: "a!b%c^".stripchars("!%^") "abc" ??? C// From jbaker at ummelec.com Tue Apr 24 11:29:26 2001 From: jbaker at ummelec.com (Jake Baker) Date: Tue, 24 Apr 2001 10:29:26 -0500 Subject: Tkinter question: disappearing label using the packer? Message-ID: Hi all. Thanks for answering my last question! Here's another one: I'm using Tkinter (under windows NT, if that's relevant.) I want to carefully place some items on the window, so I decided to use the packer(). Since I want to mix styles in the same window, I want to put my place()d objects in a Frame object. Surprise! When I do this, the objects in the Frame disappear! (Actually, the frame disappears to!) Examples: This works: (using the pack()er) =begin= from Tkinter import * root = Tk() label = Label(root, text='Hello world!') label.pack() root.mainloop() = end = This does not work: (place()ing in a nested Frame object) =begin= from Tkinter import * root = Tk() frame = Frame(root, bg='white') frame.pack() label = Label(frame, text='Hello world!') label.place(x=0) root.mainloop() =end= Can any tk guru tell me why this is happening? I'm so frustrated trying to get Tk to display the way I want it to I'm thinking of creating all my own widgets and gui routines and painting them on a Canvas! Thanks, - Jake From viznogoud at yahoo.com Wed Apr 4 17:53:46 2001 From: viznogoud at yahoo.com (vikas) Date: Wed, 4 Apr 2001 14:53:46 -0700 Subject: CGI script refuses to run python Message-ID: Hi, I am trying to get this python cgi script to work on apache. I made a test script to break down the problem. So now the script is just: #!/usr/local/bin/python I still get the same error in the web server log: Could not find platform independant libraries Could not find platform dependant libraries Consider setting $PYTHONHOME to [:] 'import site' failed; use -v for traceback How do I fix this? Thanx Vikas From scarblac at pino.selwerd.nl Mon Apr 16 13:02:48 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 16 Apr 2001 17:02:48 GMT Subject: do...until wisdom needed... References: <3ADB1C3C.F1AD88ED@noaa.gov> Message-ID: Benjamin.Altman wrote in comp.lang.python: > Any answer does not seem ideal in Python, but what about an indent concluded with an > "until" like: > > # do some stuff > # do some more stuff > until condition == true So how would you put that after another block? while cond(): #bla #bla #bla #do some stuff until cond2() That doesn't work. You need a proper non-indented block start. Besides, it's ugly :). -- Remco Gerlich From cribeiro at mail.inet.com.br Sun Apr 29 10:22:45 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sun, 29 Apr 2001 11:22:45 -0300 Subject: Opening up PEPS a little more. In-Reply-To: Message-ID: <5.0.2.1.0.20010429111824.023a1060@mail.inet.com.br> There is a simple suggestion that could be implemented right now. All email or news post related to a PEP should include the relevant PEP on the subject line. While many people do this, a lot of people don't. This would make a little bit easier to filter automatically the email. On the same vein, whenever a PEP is edited, a post should be made to the Python newsgroup with an appropriate subject line. Again - some PEP editors do this, but many don't. Another simple way to keep in touch with PEPs would be a weekly bulletin, similar to the one made by the Python-Dev guys. Once per week someone just summarizes all the movement on the PEPs and post the summary to the group, reducing traffic. But first someone needs to step up to the task . Carlos Ribeiro From paulp at ActiveState.com Tue Apr 3 20:00:25 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 03 Apr 2001 17:00:25 -0700 Subject: Regular Expression Question References: <3aca5b94_2@news.nwlink.com> Message-ID: <3ACA6419.2B3D6293@ActiveState.com> Wesley Witt wrote: > > This is probably a simple question, but I can't seem to find the answer > anywhere. > > I want a regular expression that will match ALL lines that do NOT contain > the string "skip". I have some backup logs that I need to filter the noise > out of. Why use a regular expression? You can do something like this (untested): for line in fileinput.readlines(): if line.find("skip")==-1: print line For me, regular expressions are a last resort because they are hard to read later and often slower than string methods. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From reuter at Uni-Hohenheim.DE Mon Apr 23 05:37:48 2001 From: reuter at Uni-Hohenheim.DE (Daniel Reuter) Date: Mon, 23 Apr 2001 11:37:48 +0200 (MET DST) Subject: 2 small problems building Python 2.0 on Linux Message-ID: Hello there, Some time ago I compiled python 2.0 from source on a Debian GNU/Linux box. Everything went fine, except for a problem with tkinter: >>> import Tkinter Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 35 in ? import _tkinter # if this fails your Python may not be configured for Tk ImportError: /usr/local/lib/python2.0/lib-dynload/_tkinter.so: undefined symbol: TIFFOpen I have libtk8.0.so.1 and the corresponding static libraries and headers installed. I compiled it from the sources for tkstep8.0.4-2 and tk alone worked fine. As tkstep is said to be a drop-in replacement for tk with the nextstep look'n'feel, I wouldn't expect this to be a problem, however perhaps it is. Does someone know more about this? libtiff is libtiff.so.3.5.4, however, as tk alone worked, I am not sure, if this can be the problem. Just for information, this is from my Setup.in file in the modules directory in the python2.0 source tree (pretty standard, I think): _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT\ -I/usr/local/include\ -I/usr/X11R6/include\ -L/usr/local/lib\ -ltk8.0 -ltcl8.0\ -L/usr/X11R6/lib\ -lX11 And another question: libpython2.0 compiled as static library, and as far as I have seen in the makefiles, there is no rule to build it shared on Linux. Why? and is there a simple way to do it (e.g. a makefile patch) or do I have to do it by hand? Regards, Daniel From gerhard.nospam at bigfoot.de Sun Apr 15 09:31:41 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 15 Apr 2001 15:31:41 +0200 Subject: [ANNOUNCE] pyAda release 2001-04-15 References: Message-ID: On Sun, 15 Apr 2001 13:55:39 GMT, Fred Kopf wrote: [nothing] Did you want to say something? Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From kamikaze at kuoi.asui.uidaho.edu Thu Apr 19 14:18:11 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 19 Apr 2001 18:18:11 GMT Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: <9blulk$dtj$1@panix6.panix.com> Message-ID: 18 Apr 2001 22:56:04 -0700 in <9blulk$dtj$1 at panix6.panix.com>, Aahz Maruch spake: >In article , >Mark 'Kamikaze' Hughes wrote: >> Okay, nailed that down, too. Try >> >> Since I'd been using 2.0 pre-release at home, I guess it's time to >>upgrade... Or maybe not, as it already excludes the 1.5 users. >Maybe you should just use source? There are two reasons not to: the practical, and the philosophical. The practical side is that people would have the urge to start fiddling with the source, and I *really* can't spare the time to even hear about their diffs, let alone use them, especially since I refactor mercilessly so the code base changes rapidly. And they would start fiddling with the source, because the only people who are likely to run it at this point are Python programmers. I'd rather hear high-level suggestions; "stories" in Extreme Programming terms. The philosophical side is that it's my code. Yes, I believe in code ownership. If I *choose* to give people access to my source, then that's fine but if I choose not to, then that's also fine. Now, when it gets to a stable, basically finished state, I do plan to release it as open source and start working on a multiplayer, server-side, browser-client version. That's likely to be a year or so in the future, though. Until then, it's going to be distributed as .pyo files (and I will take a very, VERY dim view of anyone decompiling them and distributing the source, as that is a copyright violation and I can and will take action; think how cranky I normally am, and then multipy that by a factor of 10). That I even have to *state* that indicates that a certain group of people have really done a job of poisoning the well of software development. I loathe and despise the communist types like St*llm*n who want to prevent anyone from owning their own software. Don't go there. Not that I'm suggesting that you had that in mind, but those are the consequences of "just use source". -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From thomas.heller at ion-tof.com Fri Apr 20 11:59:12 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 20 Apr 2001 17:59:12 +0200 Subject: [Python-Dev] Class Methods References: <027401c0c9ab$5e3c88f0$e000a8c0@thomasnotebook> <200104201626.LAA06384@cj20424-a.reston1.va.home.com> Message-ID: <031b01c0c9b2$d79bfda0$e000a8c0@thomasnotebook> > > Is someone willing to join me fighting > > for class methods (I mean 'real' class-methods > > in the Smalltalk style here, _not_ static > > methods like in Java or C++). > > I will fight class methods to the death. :-) Ouch :-) > > Seriously, I think you'll find an ally in Jim Fulton, So there _is_ some hope. > who basically > told me (since he's sort of my boss :-) to get on with this work. This must be the reason that ExtensionClass provides them: You can implement them in C, and override them in python subclasses. Thomas From dalke at acm.org Wed Apr 11 13:51:05 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 11 Apr 2001 11:51:05 -0600 Subject: call of non-function (type string) error References: Message-ID: <9b25oh$qs$1@slb5.atl.mindspring.net> Graham Guttocks: >This doesn't seem to work for me: > >>>> CIPHER = "DES3" >>>> import Crypto.Cipher >>>> cipher = getattr(Crypto.Cipher, CIPHER) >Traceback (most recent call last): > File "", line 1, in ? >AttributeError: DES3 How about CIPHER = "DES3" Crypto = __import__("Crypto.Cipher.%s" % CIPHER) cipher = getattr(Crypto.Cipher, CIPHER) (Sorry, don't have Crypto installed to test it out.) Andrew dalke at acm.org From ron.l.johnson at home.com Mon Apr 23 23:26:22 2001 From: ron.l.johnson at home.com (Ron Johnson) Date: Tue, 24 Apr 2001 03:26:22 GMT Subject: Example of Function References: Message-ID: alki wrote: > Will someone please give me how a function is written and how it's used? > Thx. "Read the documentation, Webmaster!" http://www.python.org/doc/current/tut/node6.html -- +----------------------------------------------------------+ | Ron Johnson, Jr. Home: ron.l.johnson at home.com | | Jefferson, LA USA http://ronandheather.dhs.org | | ... always eager to extend a friendly claw | +----------------------------------------------------------+ From kapblp at bellsouth.nOt Sun Apr 1 20:45:08 2001 From: kapblp at bellsouth.nOt (KEVIN) Date: Sun, 1 Apr 2001 20:45:08 -0400 Subject: I want to learn PYTHON! References: <1iqx6.3744$aD4.234302@news2.atl> <9a7i3i$lk8$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" unfortunately responded with:$1 at tyfon.itea.ntnu.no... > > After a few hundred of these one gets the urge to answer > "take a look on the Internet." > > Oh, well. Forgive me. It is not as if I couln't figure that out. In fact I have looked around. I was asking for an informed opinion about where someone with NO programming experience would start. I guess I should have stated that or did I? Yes I did! Any way thanks to the others who were helpful. From fredrik at pythonware.com Tue Apr 17 13:38:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 17 Apr 2001 17:38:27 GMT Subject: syntax from diveintopython References: Message-ID: > Here's the code i've been working with. I borrowed the code to create my > own HTMLProc class. The difficulties begin with the uknown_starttag > function. I keep getting a syntax error on the strattrs assignment. I > thought I copied the code verbatim but it still generates a syntax > error. what Python version are you using? > def unknown_starttag(self, tag, attrs): > strattrs = "".join([' %(key)s="%(value)s"' % locals() for key, value in attrs]) > self.parts.append("<%(tag)s%(strattrs)s>" % locals()) whoever wrote the original code should have their python license revoked. Cheers /F From greg at cosc.canterbury.ac.nz Sun Apr 8 20:56:37 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 09 Apr 2001 12:56:37 +1200 (NZST) Subject: CGI script to count downloads In-Reply-To: <20010406092304.B21914@freedom.puma-ag.com> Message-ID: <200104090056.MAA12361@s454.cosc.canterbury.ac.nz> Steve Purcell : > The disadvantage of this approach is that you can't accurately count > *completed* downloads, but that may not be an issue for you. It doesn't really matter if the count is not completely accurate. It's just to give us a rough idea of the amount of interest in our software. > You should put the 'Status' header in yourself for the sake of > completeness and portability. Okay, will do. Thanks for the advice. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From footech at get2net.dk Mon Apr 23 05:13:19 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Mon, 23 Apr 2001 11:13:19 +0200 Subject: difflib References: Message-ID: <5mSE6.44$677.2732@news.get2net.dk> Tim Peters wrote in message news:mailman.987979892.8018.python-list at python.org... > [Mikkel Rasmussen] > > Has anybody got any references for the algorithm used in difflib. > > Nope. It's an algorithm I dreamed up in the early 80's, while at Cray > Research, writing a file-differencing tool. I've carried it with me ever > since, reimplementing it in at least a dozen languages along the way. The > basic idea popped up when staring at some incomprehensible "diff" output, and > wondering "hmmmm -- what if diff restricted itself to *contiguous* > subsequences? and then what if it didn't synch up on junk either?". That's > about it. You can find more discussion in the comments in module ndiff.py > (difflib's SequenceMatcher class started its life in ndiff.py years ago; it > simply got split out into its own module for 2.1). > > When Eric Raymond mentioned the Ratcliff-Obershelp algorithm on Python-Dev, > it was news to me, and a Google search quickly turned up a C implementation > of that. It was obviously the same basic algorithm, except without the "skip > junk" gimmick, and at least the implementations I found were much less > efficient than SequenceMatcher (this is one of those happy instances where my > Python code runs *faster* than previous C, Fortran and Pascal > implementations: I had the *idea* of chaining together hash lists to speed > the search a long time ago, but never had the patience to *implement* that > before recoding in Python -- it's easy in Python). > I have now tested the difflib algorithm and my own algorithm. The difflib is about twice as fast as my own (which is not optimised in any way). They return near identical results. It will be interesting to look closer at the difflib algorithm. Mikkel Rasmussen NB: My first impression of IDLE 0.8 isn't good. The nice possibility to delete previously output text has gone, and some of the specified short cuts does not work on a Danish keyboard. The old short cuts work though. From mwh21 at cam.ac.uk Mon Apr 2 10:53:42 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Apr 2001 15:53:42 +0100 Subject: Self descibing scripts References: <3ac84d19$0$15022$ed9e5944@reading.news.pipex.net> <8b%x6.2720$sk3.877558@newsb.telia.net> <3ac88d6e$0$15028$ed9e5944@reading.news.pipex.net> Message-ID: "Neil Benn" writes: > Oooo, thanks Fredrik, that's close - the only problem is > that it doesn't return parameters required for the methods. D'ya > know if it is possible to do that? Depends a bit what you want. Python has default arguments, * and ** style args and no static type information, so it's harder to give a meaningful answer to your question. You could try Ping's "inpect" module, which is part of Python 2.1 but can also be found at http://www.lfw.org/python/inspect.py which has a "getargspec" function (amongst much other stuff!) that gets all the information in a neat form. Cheers, M. -- The gripping hand is really that there are morons everywhere, it's just that the Americon morons are funnier than average. -- Pim van Riezen, alt.sysadmin.recovery From phawkins at spamnotconnact.com Fri Apr 6 04:25:11 2001 From: phawkins at spamnotconnact.com (Patricia Hawkins) Date: 06 Apr 2001 03:25:11 -0500 Subject: OOT: real-world Smalltalk applications? References: Message-ID: >>>>> "SH" == Steven Haryanto writes: SH> AFAIK, Smalltalk is a mature OO language that has inspired SH> many other languages. But I look for a while on the Web SH> and have so far spotted nearly... one. Okay, I haven't SH> been looking that much. (Compare with Python's list of SH> famous users: Google, Infoseek, Yahoo!, eGroups, ...) SH> Is Smalltalk never used much anymore these days? Millennium Pharmeceuticals uses Smalltalk for their massive, complex internal applications. -- Patricia J. Hawkins Hawkins Internet Applications, LLC From kragen at dnaco.net Mon Apr 2 03:25:14 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Mon, 02 Apr 2001 07:25:14 GMT Subject: CGI Unicode issue? References: Message-ID: In article , Tim Roberts wrote: >After a fair amount of web digging, I've learned that these codes are >base64-encoded Unicode-16 characters. AAA is a base64 encoding for a >16-bit null. ACU is base64 encoding for 0024, the Unicode-16 dollar sign. >The RFC on UTF-7 encoding mentions this +XXX- encoding. I haven't seen this, but I wouldn't be surprised if you could make it go away by specifying a charset on your forms, something like "Content-Type: text/html; charset=utf-8" in the HTTP headers. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From erikw at lineo.com Tue Apr 24 14:23:12 2001 From: erikw at lineo.com (Erik Weber) Date: Tue, 24 Apr 2001 11:23:12 -0700 Subject: Python extension to a C++ module... Message-ID: <988136360.54480@db.lineo.com> So I'd like to make an extension to Python so that it can call class library methods, but the Makefile.pre.in script seems to break when I put a file with the ".cc" exception into Setup. Any hints? -- -Erik Weber Lineo Seattle 206.285.2506 x204 From al053162 at anubis.uji.es Fri Apr 6 05:54:00 2001 From: al053162 at anubis.uji.es (LANCELOT) Date: Fri, 6 Apr 2001 11:54:00 +0200 Subject: Python mail-list in Spanish In-Reply-To: References: <3ACD729A.5090401@ActiveState.com> Message-ID: In english..... Hello, I want to announce a new mail list in Spanish about Python. If you want to subscribe to it, send an e-mail like this: To: python-es-request at aditel.org Subject: subscribe Only that and you will be subscribed in the new mail list. Thanks. More information in: http://www.aditel.org/listas_correo (Information in spanish) En espa?ol..... Hola, Quiero anunciar la nueva lista de correo de Python en espa?ol. Si quieres suscribirte, manda un e-mail como este: A: python-es-request at aditel.org Asunto: subscribe Solo esto y estaras inscrito en la nueva lista de correo. Gracias. Mas informacion en: http://www.aditel.org/listas_correo _,. ,` -.) ( _/-\\-._ /,|`--._,-^| , \_| |`-._/|| ,'| /-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\ | `-, / | / / ( LANCELOT, Pedro Floro Garcia ) | || | / / ) ( `r-._||/ __ / / ( 1? ITIG ) __,-<_ )`-/ `./ / ) Universidad de Castellon (UJI) ( ' \ `---' \ / / ( ) | |./ / ) http://elchiringuito.org/ ( / // / ( lancelotss at hotmail.com ) \_/' \ |/ / ) ( | | _,^-'/ / ( ) | , `` (\/ /_ ) "No es perdedor el que pierde, ( \,.->._ \X-=/^ ( sino el que no sabe ganar." ) ( / `-._//^` ) ( `Y-.____(__} ( ) | {__) \_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_/ () From edwardt at trillium.com Fri Apr 20 13:23:20 2001 From: edwardt at trillium.com (EdwardT) Date: Fri, 20 Apr 2001 10:23:20 -0700 Subject: Is there a way to save the state of a class?? Message-ID: <9bpra9$q0l@news.or.intel.com> Hello, I current have a script that do certain processing on files, and requires user to enter certain info such as: 1. inputfile name 2. output file name 3. whether it would like process all files recusively or just one (stored as a Int instance in class, value got from CheckButton widget in runtime ) 4. a string that supplies the protocol stack it is building. (stored as a string instance in class) Instead of writing some code to save all these some sort of text file; and re-read the next time ithe script got invoked. Does python offer the option to save the state of the whole script, as some kind of persistence objects? I am using python1.5.2. Thanks From sholden at holdenweb.com Mon Apr 30 14:21:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: 30 Apr 2001 13:21:21 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 30) Message-ID: <92C3E00D01B4CE3B.99E3D2BE3B196CB7.EF8E71CA81C7794E@lp.airnews.net> Public Relations ... Mike Orr's write up of Python 9 is published in Linux Journal: http://noframes.linuxjournal.com/articles/conversations/0024.html Peter Liljenberg, one of Pointless Window Manager's developers, is interviewed by LinuxPlanet: http://www.linuxplanet.com/linuxplanet/opinions/3267/1/ Announcements ... Chris Gonnerman announces an alternative readline for Windows: http://groups.google.com/groups?ic=1&th=5f3aa9b9ba3bba35 Jason Mastaler announces an OSI-certified Tagged Message Delivery Agent for qmail, to reduce the amount of spam you receive (but remains silent about eggs, chips and beans): http://tmda.sourceforge.net/ Marc-Andr? Lemburg announces version 0.2.0 of mxNumber, with support for rational types: http://groups.google.com/groups?ic=1&th=cf082df25bdad48c as well as a new packaging of mxBASE and mxCommercial for all current Python releases: http://www.lemburg.com/files/python/ Frederic Giacometti announces the beta release of the Java-Python extension: http://groups.google.com/groups?ic=1&th=7aa72d42c08a7dbc Pearu Peterson announces an initial release of PyGiNaC, a Python interface to a symbolic computation package: http://cens.ioc.ee/projects/pyginac/ Discussions ... The group discussed various ways to slice up a matrix represented as a list of tuples: http://groups.google.com/groups?ic=1&th=1b328f23e3a3d40 Fredrik Lundh comes up with a way to apply standard exception handling to all methods of a class: http://groups.google.com/groups?ic=1&th=650d06497eb83884 Brandon J Van Every's innocent question about function pointers triggers a barrage of suggestions about things Python can do with functions that other languages cannot: http://groups.google.com/groups?ic=1&th=31b839b29e76a3fc A talk about SmallScript reveals the prospect that Python might in the far future compile for a more general virtual machine (see message 5 in the thread to finf the original poster's reference): http://groups.google.com/groups?ic=1&th=b121faa695c8b6fa Andrew MacIntyre reminds us of one way to get XML parsers: http://groups.google.com/groups?ic=1&th=26b00b08425b8fe9 Jeff Shipman elicits many responses about how to print everything in a list, mostly without a print statement: http://groups.google.com/groups?ic=1&th=e2cb1c655d3aa7b4 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From michael at stroeder.com Wed Apr 4 01:12:54 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 04 Apr 2001 07:12:54 +0200 Subject: UnpicklingError with cPickle/pickle under 2.0 Message-ID: <3ACAAD56.8FE2936E@stroeder.com> HI! Any known bugs with the cPickle or bsddb module? Sometimes I get random exceptions like these: return loads(self.dict[key]) UnpicklingError: invalid load key, '?'. I'm using my own sub-classed shelve-like class through anydbm. anydbm chooses bsddb on my platform. class Shelf(shelve.Shelf): """Base class for shelf implementations. This is initialized with a dictionary-like object. See the module's __doc__ string for an overview of the interface. """ def __getitem__(self, key): return loads(self.dict[key]) def __setitem__(self, key, value): self.dict[key] = dumps(value,1) I can't imagine what I'm doing wrong. Any suggestions where to look into it? Ciao, Michael. From sholden at cox.rr.com Mon Apr 23 17:55:35 2001 From: sholden at cox.rr.com (Steve Holden) Date: Mon, 23 Apr 2001 21:55:35 GMT Subject: operators and datatypes for sets References: <9c1jdj$phb$1@news.hccnet.nl> Message-ID: "Anton Vredegoor" wrote in message news:9c1jdj$phb$1 at news.hccnet.nl... > > There has been some discussion about sets some time ago, but I could > find no conclusive information. The consensus seemed to be to use a > dictionary as the underlying data type. In order to revive the > discussion (or to make it explicit here, if it was not dead but only > invisible to me) I would like to present some test code I have made. I > would post it here but since it is 142 lines long I will just give a > link: > > http://home.hccnet.nl/a.vredegoor/smallset/smallset.py > > or the html version: > > http://home.hccnet.nl/a.vredegoor/smallset/smallset.html > > The basic idea is to use lists as the underlying datatype and to do > member administration by setting bits to '1' or '0' in a longint. This > has the advantage of doing very fast operations. There are also some > disadvantages, one of them is having to specify a 'universe'. > So you are talking about finite sets, with underlying base sets specifying the universe. Had you thought about mapping the members on to the positions with a dictionary to allow more flexibility? Having to compute the element's position outside the set is inelegant. > There is a also a PEP about this, > > http://python.sourceforge.net/peps/pep-0218.html > > but this PEP is about a language change, which is way out of my league > since I am only talking about a module. > > I have used the 'in' operator for determining if a set is a subset of > another set. This is different from its normal use where it is used > for checking if an element is in a set. This is likely to be VERY confusing. Although "contains" is ambiguous in English for subset and element set membership, "in" is pretty much expected to refer to element membership, so you might want to think about providing an "is_subset" method ... but don't ask me which way around the arguments should go, that could be a three-week thread all on its own! > Further I have used the '/' > operator for 'set1 without the elements in set2'. This is also > unusual. Subtraction would seem the more normal operation. > I have also added a new operator '~' which can be available > because the universe is specified. It gives all elements that are not > in the set. These are just suggestions. > > Please let me know what you think or show me some better code, > improvements would also be very welcome. > > Anton. > There are a couple of things ... Firstly, have you made any provision for different instances to deal with different universes? It seems to me that it would be more flexible if the smallset.__init__() method were to record some information about the universe of that set, so there was a tighter coupling between smallsets and the objects they were dealing with. That way, compress(), toindex() and expand() would be methods of whichever type of object were being stored in the smallset (in your example, point), and they would be called from within the smallset methods through a self.universe instance variable. For example, your __repr__() mthod might then change from def __repr__(self): #delegate printing to objects in the set return '%s' %expand(self.data) to def __repr__(self): #delegate printing to objects in the set return '%s' %self.data.expand() Hope this helps. regards sTeVe From zzizz_ at notmail.com Thu Apr 12 02:06:07 2001 From: zzizz_ at notmail.com (zzzzz) Date: Thu, 12 Apr 2001 16:06:07 +1000 Subject: Python Programming Ettiquette References: Message-ID: On Thu, 12 Apr 2001 15:45:00 +1000, zzzzz wrote: >a) Directly modify the parameter: >x=[1,2,3] >def add4tolist(inputlist): > inputlist.append(4) >add4tolist(x) >x >[1,2,3,4] >a) is simpler, however, it only works on immutable type oops make that mutable!!!!!!! Regards, zzzzz. --------------------- From sanderse at digiquant.com Mon Apr 30 09:57:49 2001 From: sanderse at digiquant.com (=?iso-8859-1?Q?Snebj=F8rn?= Andersen) Date: Mon, 30 Apr 2001 15:57:49 +0200 Subject: Tkinter: documentation References: <7iae506wfi.fsf@enark.csis.hku.hk> Message-ID: <3AED6F5D.771C45A6@digiquant.com> Isaac Kar-Keung To wrote: > I'm thinking about writing complete free documentation for Tkinter. Wonderful! Please mail me a copy when you're done. /Snebj?rn From ron.l.johnson at home.com Sun Apr 22 16:30:32 2001 From: ron.l.johnson at home.com (Ron Johnson, Jr.) Date: Sun, 22 Apr 2001 20:30:32 GMT Subject: building python2-2.1-4.src.rpm on mdk7.2 fails Message-ID: <3AE33F67.EFB6AC31@home.com> Hello, all. After a good 15 minutes of crunching, it fails. Here are the last 12 or so lines (depending on your line wrap) of the output from rpm --rebuild python2-2.1-4.src.rpm {{{ start of output }}} File not found by glob: /var/tmp/python2-2.1-root/usr/lib/python2.1/lib-dynload/_tkinter.so* Requires: python2 = 2.1-4 Processing files: python2-tools-2.1-4 Finding Provides: (using /usr/lib/rpm/find-provides)... Finding Requires: (using /usr/lib/rpm/find-requires)... line 246: Dependency tokens must begin with alpha-numeric, '_' or '/': %defattr(-, root, root) Failed to find Requires: Requires: python2 = 2.1-4 /bin/bash {{{ end of output }}} This makes no sense to me, because /bin/bash exists on my system. Can anyone help me? Sincerely, Ron -- +----------------------------------------------------------+ | Ron Johnson, Jr. Home: ron.l.johnson at home.com | | Jefferson, LA USA http://ronandheather.dhs.org | | ... always eager to extend a friendly claw | +----------------------------------------------------------+ From dbrueck at edgix.com Tue Apr 3 12:50:37 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Tue, 3 Apr 2001 10:50:37 -0600 Subject: Pickle question References: Message-ID: <01bf01c0bc5e$436564c0$450514ac@PRODUT2KDAVE> Hi Noel, I've pickled multi-megabyte files without problems. Did you pickle in binary or ASCII mode? Did you open the file for reading the same way? f = open('foo.foo','wb') # binary mode pickle.dump(obj, f, 1) # binary mode ... f = open('foo.foo','rb') # binary mode obj = pickle.load(f) Binary mode and ASCII mode both work fine, you just have to be consistent. -Dave > I'm trying to use pickle to serialize some of my instances to files. The > pickling operation works fine -- I do not get a pickling error, but when I > try to unpickle the file, I get the following error: > > ==== > Traceback (most recent call last): > > File "C:\perforce\blueprint\test\pickleDataTest.py", line 37, in > testCompleteRun > > x = pickle.load(file) > > File "c:\python20\lib\pickle.py", line 897, in load > > return Unpickler(file).load() > > File "c:\python20\lib\pickle.py", line 517, in load > > dispatch[key](self) > > KeyError: > ==== > > The pickle file in question is 83 KB -- is that the problem? I seem to be > having this problom on all pickle files over about 5 KB. Is there a data > format in my class that could be causing the problem? > > Thanks, > > Noel > > ------------- > Noel Rappin > Openwave > Principal Software Engineer, Internal Development > Noel.Rappin at openwave.com > (781) 274-7000 x305 > > The contents of this email message do not necessarily reflect the opinions > or programming practices of Openwave Systems > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From kmbotha at netinfo.ubc.ca Wed Apr 11 01:50:19 2001 From: kmbotha at netinfo.ubc.ca (Krisss) Date: Wed, 11 Apr 2001 05:50:19 GMT Subject: The Singing Snake ( Distributed Music System in Python ) Message-ID: <3ad3ef27.28614244@news.interchange.ubc.ca> FYI. I'm a student at UBC (University of British Columbia). Please feel free to comment on my group's programming project - a distributed music system. Features include: * Graphical client and server interface through which to browse songs, express preferences, administer users/computers * DJ that selects songs to be aired in accordance with everyone's listeining preferences (and user-supplied parameters) * Ability to set listening permissions among users (cater for fair use issues) * Support for WAV, MP3, AU, AIFF, CSL (via Snack TCL module) * etc. Checkout sample User Documentation for an idea of how it looks / what it does: http://24.112.121.96/kris/UBC/CPSC/319/userdoc/ ~~====----..----====~~ Kris Botha From btang at pacific.jpl.nasa.gov Wed Apr 25 13:49:32 2001 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Wed, 25 Apr 2001 10:49:32 -0700 Subject: building numpy20 on native blas/lapack References: <3AE608A8.755DEEE5@pacific.jpl.nasa.gov> <9c58d7$5ef@gap.cco.caltech.edu> Message-ID: <3AE70E2C.6A038944@pacific.jpl.nasa.gov> Thanks. I added the lapack library to setup.py. It worked. The setup.py now looks like this: # delete all but the first one in this list if using your own LAPACK/BLAS sourcelist = ['Src/lapack_litemodule.c',] # set these to use your own BLAS library_dirs_list = ['/usr/lib','/usr/local/lib','/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66'] libraries_list = ['blas','lapack','g2c','m'] However, numpy does not get any speed gain by linking to the native blas/lapack. Here I tested the multiplication of 2 real*4 matrixes: Multiplication of 100X100 matrixes takes 0.01 Multiplication of 200X200 matrixes takes 0.11 Multiplication of 300X300 matrixes takes 0.41 Multiplication of 400X400 matrixes takes 1.47 Multiplication of 500X500 matrixes takes 3.10 Multiplication of 600X600 matrixes takes 5.51 The timing is roughly the same as that when linking to the compiled blas_lite. Robert Kern wrote: > > dgesvd is a LAPACK function, not a BLAS function. You need a LAPACK library, > and not just a BLAS. If you don't have an optimized version, then go to > http://netlib.org/lapack to get the FORTRAN version. Compile it per the > instructions and link it in before the BLAS library in the library_list. > I don't know where to get convenient RPMs. > > > -- > 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 -- <> Benyang Tang <> 300-323, JPL <> 4800 Oak Grove Drive <> Pasadena, CA 91109, USA From rjohnson at exotic-eo.com Wed Apr 11 08:20:39 2001 From: rjohnson at exotic-eo.com (Robert Johnson) Date: Wed, 11 Apr 2001 05:20:39 -0700 Subject: Class Variable Question References: <9at1ul010vn@news1.newsguy.com> <3ad2a7dd$0$47987$e2e8da3@nntp.cts.com> <9aush501oro@news2.newsguy.com> <3ad411ff$0$47987$e2e8da3@nntp.cts.com> <9b19nh01pud@news2.newsguy.com> Message-ID: <3ad44bce$0$47992$e2e8da3@nntp.cts.com> > mapInstance.newVariable = 5 > boils down to nothing more than > mapInstance.__dict__['newVariable'] = 5 > I think this is what I was not seeing. Thanks, Robert Johnson From nhodgson at bigpond.net.au Mon Apr 23 04:35:52 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 23 Apr 2001 08:35:52 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: Stephen: > #1) BCC is giving off the STRANGEST warnings. They make no sense-at-all, > it seems to me that the compiler doesn't comprehend that a variable that > only gets modified by macros is actually being modified, so it complains a > LOT about 'variable is assigned a value but never used' etc. Anyways, I'm > looking to the C++Builder for a fix on this :) BCC tries hard to find never used value settings, including some that other compilers don't warn about. For example, IIRC, this generates a warning because the 1 is never read: int i = 1; if (c) i = 2; else i = 3; As does the same thing in a switch statement. BCC may also sometimes work out when loops will never be run or be run only once. I can't recall all the cases but BCC has always been accurate when its given me this warning. Neil From volucris at hotmail.com Tue Apr 24 00:27:55 2001 From: volucris at hotmail.com (Volucris) Date: Mon, 23 Apr 2001 23:27:55 -0500 Subject: Example of Function References: Message-ID: <3ae5008b$0$769$6e49188b@news.goldengate.net> >>> def welcome(): ... #a funtion with no return value (a procedure) ... print '***********' ... print 'Hello World' ... print '***********' ... >>> welcome() *********** Hello World *********** >>> def double(num): ... #a function in the traditional sense (has a return value) ... new_num = num * 2 ... return new_num ... >>> my_num = double(6) >>> print my_num 12 "alki" wrote in message news:DV5F6.4485$5t3.336201 at newsread1.prod.itd.earthlink.net... > Will someone please give me how a function is written and how it's used? > Thx. > > From s713221 at student.gu.edu.au Fri Apr 13 06:55:19 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Fri, 13 Apr 2001 20:55:19 +1000 Subject: The Singing Snake ( Distributed Music System in Python ) References: <3ad3ef27.28614244@news.interchange.ubc.ca> Message-ID: <3AD6DB17.ED416A19@student.gu.edu.au> > An interesting application, with high marks for documentation. > > Because of the high graphical content of the docs you may want to think > about making them available as multiple files for those wit lower-bandwidth > network links. > > Well done! > > regards > Steve However, also supply the documents as one file for those with big bandwidths. Multiple Click-unpack-organise cycles can be annoying. Joal Heagney/AncientHart From aleaxit at yahoo.com Fri Apr 6 08:17:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Apr 2001 14:17:51 +0200 Subject: Timezone References: <31575A892FF6D1118F5800600846864D78BAA1@intrepid> Message-ID: <02ab01c0be93$99fae300$102b2bc1@cadlab.it> "Simon Brunning" writes: > > Worst case, you can probably precompile and package Python > > for your clients most easily (unless it's a platform lacking > > an ISO compliant C compiler -- ARE there such platforms still > > around today...?). > > AS/400. :-( > > Well, unless you want to shell out $loads for it. Ah, OK, I didn't mean to imply a FREE compiler, mind you:-). > V5R1 (the new release of the OS, available soon) will have it for free, > though. I, for one, am looking forward to it. Anyway, isn't the Python 2.0 port to AS/400 available from http://home.no.net/pgummeda/ satisfactory...? Alex From tjg at exceptionalminds.com Thu Apr 12 14:39:07 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 12 Apr 2001 11:39:07 -0700 Subject: How do I make PmwTreeBrowse work Message-ID: <20010412113907.S17435@trufflehunter.avalongroup.net> Hi all, I noticed that there is a module shipped in the contrib directory of Pmw that purports to be a Tree Browser. However, I can't make it work. Is there a short tutorial on how to make it work? or does it work at all? Fail that, is there a Tree implementation available anywhere for Tkinter? Thanks. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 15 days 20:48 hours ago<< From tdelaney at avaya.com Mon Apr 23 20:39:04 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 24 Apr 2001 10:39:04 +1000 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) Message-ID: > 38/3 - not ambiguous, but falls into the problem of integer > truncation. > Nevertheless, I would prefer this notation, and deprecate > integer division > notation in favour of 'mod' (since this would be a major incompatible > language change anyway, might as well make a new keyword at > the same time > ;). Of course, I meant 'div' and 'mod', not just mod ... ;) Tim Delaney From sholden at holdenweb.com Fri Apr 13 07:32:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Apr 2001 07:32:55 -0400 Subject: reusing sys.stdin? References: <20010413002832.66379.qmail@web10306.mail.yahoo.com> Message-ID: "Steve Holden" wrote ... [ ... ] > In fact the Message method goes to considerable lengths *not* to consume the when he should have written In fact the Message __init__() method ... From ^NOSPAM^ifi at ifi.it Thu Apr 5 08:45:44 2001 From: ^NOSPAM^ifi at ifi.it (accattatevillo) Date: Thu, 05 Apr 2001 14:45:44 +0200 Subject: OT?? Zope Message-ID: <3ACC68F8.84266A70@ifi.it> I installed Zope and tried to create a folder. I received the message : >>Error Type: EmergencyUserCannotOwn >>Error Value: Objects cannot be owned by the emergency user Then I created 2 other accounts but I coudn't connect with them. Anyone could help me? Best Regards From tebeka at lycosmail.com Thu Apr 12 08:58:06 2001 From: tebeka at lycosmail.com (Miki Tebeka) Date: Thu, 12 Apr 2001 15:58:06 +0300 Subject: Named code blockes Message-ID: <9b48p1$k73@news.or.intel.com> Hello All, Preobebly missed it somewhere. Is there a discussion/sugesstion about enabling named code blockes (like lisp, perl ...) in Python? Thanks. Bye. ---------------------------------------------------------------------------- -- Smile, damn it, smile. lambda msg: 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From nessus at mit.edu Thu Apr 19 08:43:09 2001 From: nessus at mit.edu (Douglas Alan) Date: 19 Apr 2001 08:43:09 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9bjtbr02108@news1.newsguy.com> <9bl6i701e09@news1.newsguy.com> <9bmgid081b@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > No "taunting" involved -- I dived into it right after you seriously > insulted Steve Holden by impugning his honesty, I did no such thing. I said, "Why not be honest: it's a wart on the language." In my dialect of English this means the same thing as, "Let's be honest: it's a wart on the language." Or, "Why kid ourselves: it's a wart on the language." Or, "If we look at the issue without bias, it's a wart on the language." In no way did I mean to imply that Mr. Holden was lying or trying to mislead anyone. In my dialect of English the meaning would be clear and I've already clarified that it was not my intent to impugn the honesty of Mr. Holden. Yet you seem to believe that it was my intent to insult him. Are you accusing me of lying? Perhaps you and Mr. Holden speak some dialect of English with which I am quite unfamiliar, and in which the statement I made could be misinterpreted. If this is the case, then I am very sorry for the misunderstanding. If I had known ahead of time about the rather different language that you two speak, I would have phrased things differently. Contra to what you say, except in cases where I was very clearly insulted first, I have not uttered sentences that as speech acts were insults to anyone here. Such speech acts would require my intention to insult. More (but not on this topic) after I finish giving a talk today on Chambers et. al.'s MultiJava. |>oug From chrisa at ASPATECH.COM.BR Wed Apr 18 13:38:34 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Wed, 18 Apr 2001 14:38:34 -0300 Subject: I need to convert PNG images to JPG..can python help Message-ID: Hi- I've been using ImageMagick on Linux to convert images from PNG to JPG, but now need to include that code in a python script. My options are to somehow figure out how do call imagemagick's 'convert' from a python script or to use a library/module within python. Anyone have an tips/advice? Thanks, Chris From jcopella at cfl.rr.com Mon Apr 9 11:27:53 2001 From: jcopella at cfl.rr.com (John Copella) Date: Mon, 09 Apr 2001 15:27:53 GMT Subject: [Q] Distributing extensions, compilers, and compatibility Message-ID: I read in the SWIG documentation that extensions should be compiled with the same compiler as that used to build Python itself. In my application, I will be distributing an extension (as a shared lib) to customers where I cannot guarantee this to be so -- can anyone verify from experience that this is a necessary restriction? FWIW, I will need to support the HP-UX and AIX environments, using the commercial compilers from HP and IBM. Thanks for any assistance, John Copella From Marc.Poinot at onera.fr Thu Apr 19 09:17:29 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Thu, 19 Apr 2001 15:17:29 +0200 Subject: [ANNOUNCE] European Python Meeting - Yet another speakers Message-ID: <3ADEE569.9A040773@onera.fr> Check http://lsm.abul.org we have now more top level highly experienced gurus with tera-cognitive knowledge of Python and galactic performance for users in the range [-2:] There's also some newbies possibilities, range [:2] Marcvs [alias Martian EBE are welcome] From neal at metaslash.com Tue Apr 17 12:11:02 2001 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 17 Apr 2001 12:11:02 -0400 Subject: PyChecker 0.3 release Message-ID: <3ADC6B16.8F90B777@metaslash.com> I have released PyChecker 0.3 to SourceForge. Web Page: http://pychecker.sourceforge.net/ Project Page: http://sourceforge.net/projects/pychecker/ I'd like to thank everyone for all the feedback so far, it's been great! In particular, Barry Scott has been very helpful. The CHANGELOG and current command line options are included below. The TODO list has gotten longer (see the web page or download). As always, feedback, suggestions, complaints, etc are encouraged. Neal -- Here's the CHANGELOG: Version 0.3 - 17 April 2001 * Fix some checker crashes (oops) * Add warnings for code complexity (lines/branches/returns per func) * Add more configuration options * Don't produce spurious warning for: x(y, { 'a': 'b' }) * Fix warnings that indicate they are from a base class file, rather than real file * Fix warnings for **kwArgs not allowed, but using named args * Add config option for warning when using attribute as a function (off by default, old behaviour was on) Version 0.2.5 - 12 April 2001 * Add back support for Python 1.5.2 (again) (I sure like 2.0 more with the [ for ] and string methods.) * Add new warning for unused local variables * Add command line switches Here's the current list of command line options: Options: Change warning for ... [default value] -s, --doc turn off all warnings for no doc strings -m, --moduledoc no module doc strings [on] -c, --classdoc no class doc strings [on] -f, --funcdoc no function/method doc strings [off] -i, --import unused imports [on] -l, --local unused local variables, except tuples [on] -t, --tuple all unused local variables, including tuples [off] -v, --var all unused module variables [off] -p, --privatevar unused private module variables [on] -n, --namedargs functions called with named arguments (like keywords) [on] -a, --initattr Attributes (members) must be defined in __init__() [off] -I, --initsubclass Subclass.__init__() not defined [off] -A, --callattr Calling data members as functions [off] -b, --blacklist ignore warnings from the list of modules [['Tkinter']] -L, --maxlines maximum lines in a function [200] -B, --maxbranches maximum branches in a function [50] -R, --maxreturns maximum returns in a function [10] -P, --printparse print internal checker parse structures [off] -d, --debug turn on debugging for checker [off] From neal at metaslash.com Fri Apr 13 15:25:20 2001 From: neal at metaslash.com (Neal Norwitz) Date: Fri, 13 Apr 2001 15:25:20 -0400 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> <3AD5C5B1.98ACEFB3@metaslash.com> <9otuNLAXvs16EwcK@jessikat.fsnet.co.uk> Message-ID: <3AD752A0.ECF538A4@metaslash.com> Robin Becker wrote: > class B: > def __init__(self): > self.x=1 > class A(B): > member = 1 > > C:\Python\pyChecker>python checker.py a.py > > b.py:0 No __init__() in subclass (A) Yes, this was by design. Although the error should be in a.py, not b.py. That's been fixed in CVS. In addition, I have made this warning configurable. The code is fine, it is completely legal to inherit __init__ and not override. The idea was that it it is often a mistake to not override. But this is not always a good assumption....so.... -I, --initsubclass Subclass.__init__() not defined [on] That's a new command line option in CVS version. There are many cases where you want to write completely legal code, but checker can't tell if it is a bug (thinko mistake) or what was intended. Ideally, there would be finer grain control on the options. So one could specify for a particular class/method, set option X to some value. In 2.1, this could be done with function attributes. But I don't know how to deal with these cases for modules/classes/functions generically. One option would be to review the actual doc strings and look for hints (similar to lint /*ARGSUSED*/). Perhaps "CHECKER.initsubclass = 1" ? Any ideas or comments? Neal From dinu at reportlab.com Thu Apr 12 07:49:23 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Thu, 12 Apr 2001 11:49:23 GMT Subject: Bug with [] as default value in functions? - bug.py (0/1) Message-ID: <3ad5904d.176672030@news.t-online.de> Hi, I noticed a very strange behaviour: I've got a recursive function like this: foo(spam, eggs=[]): ... return foo(spam, eggs=eggs where the default argument for eggs, the empty list, is *empty* for the top-level call only when it is explicitly provided with the func- tion call like this: bar = foo(mySpam, eggs=[]) I've attached a more lengthy example showing, I hope, rather pre- cisely what I mean. Is this a bug or just a lack of understanding of recursion and name spaces, delicate as they are, in my brain?? Regards, Dinu -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From juergen.erhard at gmx.net Wed Apr 11 21:55:43 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Thu, 12 Apr 2001 03:55:43 +0200 Subject: I come to praise .join, not to bury it... In-Reply-To: (pinard@iro.umontreal.ca) References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <98rmod$c8p$1@animus.fel.iae.nl> <98tacr0q5s@news1.newsguy.com> Message-ID: <12042001.1@wanderer.local.jae.ddns.org> >>>>> "Fran?ois" == =?iso-8859-1?q?Fran=E7ois?= Pinard writes: Fran?ois> [Alex Martelli] >> IF the huge investment of time and energy doesn't faze you >> [...] striving to help others articulate their objections, in >> great detail, by first laying out in just as much details my >> reason for NOT objecting at all to the architecture Guido has >> chosen for .join; Sorry, Alex... but having read the discussions on python-dev, it doesn't seem like your "Guido has chosen" argument would fly. It didn't seem to me like Guido `chose'... more like Barry did a patch which contained .join, and Guido approved the whole kit'n kaboodle... So, for me it looks much more like something like an accident than a well-reasoned decision (not the introduction of string-methods, but making .join a method of strings). Fran?ois> In the case under discussion, here, I suspect that the Fran?ois> community has shown enough reluctance to consider that Fran?ois> there was at least something to ponder. Details may Fran?ois> well have been articulated, but if they are not even Fran?ois> listened at, there is no point in repeating them Fran?ois> endlessly: this is a lost cause. Well, not just c.l.py, even on -dev were quite a number of voices against separator.join. One of the best: Smalltalk does has `join' as a method of *collections*, not strings! One *might* think that the designers of Smalltalk were... well, not the most stupid people on the planet. Bye, J PS: I still hope that someday we will see this separator.join wart disappear again... -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html "Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories?" -- Michael K. Johnson -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From grey at despair.rpglink.com Mon Apr 23 20:48:24 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 24 Apr 2001 00:48:24 -0000 Subject: Dive Into Python: call for comments (long) References: Message-ID: On Mon, 23 Apr 2001 18:50:23 -0400, Mark Pilgrim wrote: >romanNumeralPattern = \ > re.compile('^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$') >Is this more efficient? It is more elegant (as regular expressions go)? >Any regular expression experts care to comment? Well, generally {}'s are less efficient but a little easier to read. OTOH, define "efficiency" as "easier to read" and yes, it is. The only other thing my admittedly limited regex mind can see is changing the ()s to be (?:)s unless you're explcitely matching them for later use. But I'm sure many people will take issue to that for a variety of good reasons. :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From cribeiro at mail.inet.com.br Mon Apr 9 22:23:16 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Mon, 09 Apr 2001 23:23:16 -0300 Subject: Class Variable Question In-Reply-To: References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> Message-ID: <5.0.2.1.0.20010409223510.02291340@mail.inet.com.br> At 19:24 09/04/01 -0400, Douglas Alan wrote: >I'm not arguing against "programmer freedom". I'm arguing for >features that reduce bugs without reducing power. That's the point. Because of the way Python works, it is almost impossible to implement any kind of "attribute checking". My own code is filled with this kind of construct. You can build new classes on the fly, make composite objects, a whole lot of things that are nearly impossible to do using other statically typed languages. If you really think that this is a good idea (and I understand your position for some particular cases), put some checks on the __setattr__ of your class. It will trap all occurrences of new attributes being attached to the class instance. This is a quick example, by no means complete, that shows the concept: --- test-lock-attr.py class NonExtensibleClass: def __setattr__(self, attr, value): if hasattr(self, '_locked') and not (self.__dict__.has_key(attr)): raise AttributeError else: self.__dict__[attr] = value def lock(self): self._locked = 1 class MyClass(NonExtensibleClass): def __init__(self): self.x = 1 self.y = 0 --- testing >>> m = MyClass() >>> m.x, m.y (1, 0) >>> m.a Traceback (innermost last): File "", line 1, in ? AttributeError: 'MyClass' instance has no attribute 'a' >>> m.a = 2 >>> m.a 2 >>> m.lock() >>> m.b = 3 # you can't insert any new attribute Traceback (innermost last): File "", line 1, in ? File "E:\WORK\Python\teste-lock-attr.py", line 7, in __setattr__ raise AttributeError AttributeError: >>> m.a = 4 # you can still change attributes >>> m.a 4 You can put the lock() call inside __init__ to achieve automatic locking. Carlos Ribeiro From danyelf at ics.uci.edu Fri Apr 20 13:59:03 2001 From: danyelf at ics.uci.edu (Danyel Fisher) Date: Fri, 20 Apr 2001 10:59:03 -0700 Subject: rexec, threads, and ugly crashes In-Reply-To: <15072.21930.19829.121396@slothrop.digicool.com> Message-ID: <001601c0c9c3$95815260$c614c380@ics.uci.edu> Thanks for the response. > Is this a regular Python application, started by invoking the > interpreter with a script, or is it an application with an embedded > interpreter? It's a regular python application. > DF> RExec is my tool. > I don't think the problem is related to rexec. It might not be. But that line is the one where it crashes, each time: before it's even had a chance to look at the RExec'd code. > The error message means that a C extension module is being loaded > before Py_Initialize() has been called. Py_Initialize() is called in > Py_Main() pretty much before it does anything else. Odd. I take it that generating a new interpreter--with rexec-- is what creates a new module? [Other possibly-relevant details: I'm doing this within a thread started by a SocketServer with the Threading MixIn, using TCPServer. I'll work on putting together a minimum set of code that hits the crash later.] > What happens if you just type > bash-2.04$ python -v -c "import imp" It seems to work fine, I think: bash-2.04$ python -v -c "import imp" # /usr/local/lib/python2.0/site.pyc matches /usr/local/lib/python2.0/site.py import site # precompiled from /usr/local/lib/python2.0/site.pyc # /usr/local/lib/python2.0/os.pyc matches /usr/local/lib/python2.0/os.py import os # precompiled from /usr/local/lib/python2.0/os.pyc import posix # builtin # /usr/local/lib/python2.0/posixpath.pyc matches /usr/local/lib/python2.0/posixpath.py import posixpath # precompiled from /usr/local/lib/python2.0/posixpath.pyc # /usr/local/lib/python2.0/stat.pyc matches /usr/local/lib/python2.0/stat.py import stat # precompiled from /usr/local/lib/python2.0/stat.pyc # /usr/local/lib/python2.0/UserDict.pyc matches /usr/local/lib/python2.0/UserDict.py import UserDict # precompiled from /usr/local/lib/python2.0/UserDict.pyc Python 2.0 (#4, Apr 11 2001, 12:50:56) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. import imp # builtin # clear __builtin__._ # clear sys.path # clear sys.argv # clear sys.ps1 # clear sys.ps2 # clear sys.exitfunc # clear sys.exc_type # clear sys.exc_value # clear sys.exc_traceback # clear sys.last_type # clear sys.last_value # clear sys.last_traceback # restore sys.stdin # restore sys.stdout # restore sys.stderr # cleanup __main__ # cleanup[1] exceptions # cleanup[1] posix # cleanup[1] imp # cleanup[1] site # cleanup[1] signal # cleanup[2] os.path # cleanup[2] os # cleanup[2] UserDict # cleanup[2] posixpath # cleanup[2] stat # cleanup sys # cleanup __builtin__ # cleanup ints # cleanup floats From roy at panix.com Sat Apr 21 16:02:46 2001 From: roy at panix.com (Roy Smith) Date: Sat, 21 Apr 2001 16:02:46 -0400 Subject: How best to write this if-else? Message-ID: I want to test a line to see if it matches any of a bunch of pre-compile regexes. I also want to capture the match objects. What really want to write is something like this (pseudo-code): e1 = re.compile ('...') e2 = re.compile ('...') e3 = re.compile ('...') line = file.readline() if (m = e1.match (line)): text = m.group(1) elif (m = e2.match (line)): text = m.group(1) elif (m = e3.match (line)): text = m.group(1) but I can't write it that way because python doesn't have assignment operators. Seems like I stuck with something like: m = e1.match(line) if m: text = m.group(1) else: m = e2.match(line) if m: text = m.group(1) else: m = e3.match(line) if m: text = m.group(1) but the best word I can think to describe that style of coding is "silly". Is there really no more straight-forward way to do what I want? From paulp at ActiveState.com Wed Apr 18 09:34:58 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 18 Apr 2001 06:34:58 -0700 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> <9bk0ce026c6@news1.newsguy.com> Message-ID: <3ADD9802.3CC1BEE5@ActiveState.com> Alex Martelli wrote: > > ... > > Possibly. On the other hand, I seem to be slightly more refined > than you at Usenet flamewars, judging for example from the styles > used to insult -- rude, direct name-calling on one side, subtler > indirect venom on the other. I'll leave the meta-flamewar debate to you two. But try to remember that this is comp.lang.python. The joy of the flame probably does not yield long-term rewards for either participant nor for the audience. > ... It appears to me that the crucial design-goal that > Python and Dylan did not share was *SIMPLICITY*. Exactly what > such additions as a macro-system would destroy in Python. I find it hard to believe that the mere existence of the system would destroy Python's simplicity. My impression, after years of use, is that Python's simplicity is skin deep and that's a good thing. In other words: Python makes all easy stuff easy AND syntactically simple (unlike some other languages which claim to make easy stuff easy) but there are depths of complexity in the semantics that few ever plumb. It seems, on the other hand, like syntax is something of a sacred cow. I really don't see how the mere ability for some yahoo to mess up his program with some stupid syntax extension impacts the rest of us at all. Neel K made an important point in passing: that same yahoo can mess us up by writing totally unmaintainable, unreasonable functions. I don't see the big difference. And if some smart people can use hygenic macros to make Python code that is more maintainable or readable, why should they be disallowed? Python doesn't take away the rope -- it tends to hide it so that only people who know what they are doing will find it. A perfect example is func.func_code. Imagine the havoc idiots could wreak if it was widely known that the func_code attribute is writable and func_code objects can be constructed at runtime from raw binary data. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From phlip_cpp at my-deja.com Fri Apr 13 02:16:28 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 13 Apr 2001 06:16:28 GMT Subject: Tkinter Context Menus select their first item even if you don't want them to References: Message-ID: <9b65js$cfg@dispatch.concentric.net> Proclaimed Phlip from the mountaintops: > Hyp Ton: > > Try this code... You can right-click on the canvas to make the menu > pop up. > > http://mail.python.org/pipermail/python-list/1999-November/015485.html > > However, if you make the first menu item call a command that calls > 'sys.exit(0)', merely summoning the menu with croaks the > program. > > Real Context Menus display and then await a further input. This means you > can back out of an action instead of comiting it. Platform is LinuxPpc. > > My current work-around is to make the first item do nothing, but I'd > obviously prefer a real fix. Thanks to someone for the request that I provide the offending source, but I'm on another project right now. I suspect the issue boils down to with my code the geometry math puts the menu such that the mouse is over the first item when the tip appears. Then mouse-up selects the item. The fix is to get the geometry right, putting the menu a pixel southwest of the mouse, and maybe to trigger the context menu on mouse-up instead of mouse-down. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- I don't want to work. I want to surf on de 'net all day. I don't want to play. I just want to surf on de 'net all day. -- From sholden at holdenweb.com Wed Apr 4 11:25:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 4 Apr 2001 11:25:23 -0400 Subject: why does the % string format operator only take tuples? References: <986344880.1233352496@news.silcom.com> Message-ID: "Clarence Gardner" wrote in message news:986344880.1233352496 at news.silcom.com... > On Tue, 03 Apr 2001, Ram Bhamidipaty wrote: > > > > > >Does anyone else think it would be a good idea of the % operator > >were extended to also handle lists? > > > >-Ram > > You want as few types as possible to be treated as containers for the > data to be formatted, because you have a problem formatting an object > of those types. > > For example, if you want to print the tuple (1,2), you can't use > print '%s' % (1,2) > Instead, you have to do something like > print '%s' % `(1,2)` > Making % treat lists as tuples would just mean there were more objects > that can't be formatted. > Or, perhaps, print '%s' % ((1, 2), ) which uses a tuple containing a single tuple. regards Steve From mwh21 at cam.ac.uk Mon Apr 2 19:03:29 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Apr 2001 00:03:29 +0100 Subject: inspect module References: <3ac8ab44$0$12245$ed9e5944@reading.news.pipex.net> Message-ID: "Neil Benn" writes: > However I have a problem in that the dis module isn't available with > Jython (which I am using with IBM's BSF). Does anyone know if there is a > Jython version of dis. I believe Jython compiles Python into Java bytecodes. Is there a disassembler for Jave bytecodes? I guess there must be somewhere, but is it in the standard library? I doubt it somehow. [...] > Once again, thanks for your help - if your ever in Cambridge UK - I'll > buy you a pint!! Well, I'm here most of the time... there are a few of us Cambridge Pythoneers. Maybe we should have a mini-meet again sometime. Cheers, M. -- ... when all the programmes on all the channels actually were made by actors with cleft pallettes speaking lines by dyslexic writers filmed by blind cameramen instead of merely seeming like that, it somehow made the whole thing more worthwhile. -- HHGTG, Episode 11 From dubois at users.sourceforge.net Mon Apr 23 12:51:20 2001 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Mon, 23 Apr 2001 16:51:20 GMT Subject: A list of Python users? References: Message-ID: "Jan Dries" wrote in message news:mailman.987982833.19798.python-list at python.org... > > I am aware that www.python.org has many references to many companies > using Python, but at the company where I work, they don't really care > about "Satz-Rechen-Zentrum Berlin", "Swedish Meteorological and > Hydrological Institute" or even LANL and Google for that matter. But > some good references to IBM would make my case to sell Python to my > management a whole lot easier. Well, of course you don't care if LANL uses it. But LLNL that uses it. Big difference. (:-> Seriously, I think Python is pretty closed to established as *the* steering language for scientific applications. Your management ought to take that seriously -- it means a big base of competent and non-poor users who have a stake in keeping the product going. From astpspd at pea.or.th Fri Apr 27 04:43:15 2001 From: astpspd at pea.or.th (Tawee Laoitichote) Date: Fri, 27 Apr 2001 15:43:15 +0700 Subject: How to store numeric array in disk Message-ID: <003901c0cef6$19e83960$24130180@astpspd> Dear, I'd like to keep my array stuff in my hard disk after a number of experiments. I hear of pickling and unpickling. I have tried but some errors. Like this : py> myfile='h:\\python21\\prob.pik' py> print myfile h:\python21\prob.pik py> p=pickle.Pickler(myfile) Traceback (most recent call last): File "", line 1, in ? p=pickle.Pickler(myfile) File "h:\python21\lib\pickle.py", line 104, in __init__ self.write = file.write AttributeError: write my next statement should be p.dump(mystuff) #which is my array stuff What am I doing wrong? Please suggest... From sdm7g at Virginia.EDU Fri Apr 20 14:04:19 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 20 Apr 2001 14:04:19 -0400 (EDT) Subject: With or Using In-Reply-To: Message-ID: This was discussed and argued in an earlier thread. The problem with 'with' is when it's nested ( think: "with pitcher... with water... with spoon..." ) the implied pronoun is imprecise to a human reader -- you have to go back and look at the structures definitions to see which slots belong to which records. It's not a problem for the compiler, which keeps handy lookup tables, and it may not be a problem for the author who knows what he meant, but for other readers it's a pain. In Pascal programs with 3 nested levels of 'with', I ususally have to resort to annotating the missing parent names back in as comments. It wouldn't be so bad if you weren't allowd to nest it, but than somebody would complain about the no-nesting restriction. Better just to avoid it. BTW: My favorite ambiguous pronoun reference was from the Three Stooges: [ Curly holding a sledge hammer; Moe holding a spike or chisel: ] Moe: "When I nod my head, hit it!" ( You can guess what happens. :-) -- Steve Majewski On Fri, 20 Apr 2001, Gary Walker wrote: > Consider this: > > Recipe for Lemonade > > Add 8 cups water to a large pitcher > Add 1/2 cup lemon juice to a large pitcher > Add 2 cups sugar to a large pitcher > Stir the ingredients that are in the large pitcher > > Now consider: > > To a large pitcher add: > 8 cups water > 1/2 cup lemon juice > 2 cups sugar > and stir. > > Did the second one confuse you? Did you forget the large pitcher?? Of course > not. It's much easier to understand. So it is with with. From aahz at panix.com Fri Apr 13 17:20:58 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Apr 2001 14:20:58 -0700 Subject: still wondering (was Re: Pep 245) References: <3AD2740E.E4B2A023@seebelow.org> <9av88a$4v9$1@panix3.panix.com> Message-ID: <9b7qjq$c6g$1@panix6.panix.com> In article , Thomas Wouters wrote: >On Tue, Apr 10, 2001 at 08:18:34AM -0700, Aahz Maruch wrote: >> In article <3AD2740E.E4B2A023 at seebelow.org>, >> Grant Griffin wrote: >>>Aahz Maruch wrote: >>>> In article <3ACE7FC5.6A72FA4A at seebelow.org>, >>>> Grant Griffin wrote: >>>>> >>>>>In its "Tim Peters" section, the book "Learning Python" says: >>>>> >>>>> Come to think of it, only one person we have talked to claims to >>>>> have _met_ Tim in person, and that's Guido. Makes you wonder... >>>>> >>>>>And I've wondered ever since. But Tim cleared that up recently when he >>>>>said that he had met Aahz. So that gives us two witnesses. >>>> >>>> Note that I have never claimed to have met Tim. >>> >>>Even now that the new millennium has just had its first Python >>>conference? >> >> Why would that make any difference? I still have never claimed to have >> met Tim. > >Well, *I* claim Aahz met Tim, and I met Tim (and Aahz). In fact, we were >sitting at the same table as Tim while he was packing away something that >looked like a hamburger, but 5 times the size and with 10 times as much >green stuff as they normally get. Come to think of it, that can't have been >real.... so what does that make Tim ? I'm still not claiming that I've met Tim. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From tim at worthy.demon.co.uk Fri Apr 20 03:28:29 2001 From: tim at worthy.demon.co.uk (Tim Howarth) Date: Fri, 20 Apr 2001 08:28:29 +0100 Subject: With or Using References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> <2b95c26c4a%tim@worthy.demon.co.uk> Message-ID: <86e9e6e4a%tim@worthy.demon.co.uk> In message Carlos Ribeiro wrote: > At 16:11 18/04/01 +0000, David C. Ullrich wrote: > >It's in Delphi all right. Now find five Delphi experts and ask them > >whether they think it's a good idea. > > > Delphi uses static types. So it is possible to know, in a unambiguous way, > what member is being assigned in a "with" clause. > Python uses dynamic types. It is impossible to know in advance which > attribute will be referenced at runtime. Member attributes may be added or > removed from objects on the fly. This would make it impossible to know, > from a simple reading, what attribute is being read - a local one, a global > one, or a member attribute. Thanks, a sensible reason/explanation for it not be a good idea for Python. -- ___ |im ---- ARM Powered ---- From donn at u.washington.edu Thu Apr 19 11:59:57 2001 From: donn at u.washington.edu (Donn Cave) Date: 19 Apr 2001 15:59:57 GMT Subject: Writing 'intercepted' e-mail message to a mailbox References: Message-ID: <9bn21t$f0c$1@nntp6.u.washington.edu> Quoth Jacobus van der Merwe : | I am redirecting all email sent user1 at myhost.co.za to a python script, | which | extracts certain data from the e-mail and writes it to file. But now I | still want | user1 to receive this e-mail. | | I read the incoming mail using | mailMessage = rfc822.Message(sys.stdin) | | How can I get the message from my variable mailMessage into user1's | mailbox?? I can not find a method that does it. I'm pretty sure there is no such function in the Python library, and it's a hard one to write. Mailbox files can use one of several different data formats, depending on how they do things at your site, and in any case you must carefully interlock against other software that could accidentally try to modify the file at the same time. But in this case I doubt you need to. If you have a ".forward" file that routes the mail into the Python program, then all you need to do is change its contents from "|/that/path/mailread" to \user1, "|/that/path/mailread" , and the mail delivery system will deal with it. Donn Cave, donn at u.washington.edu From paulp at ActiveState.com Sat Apr 21 05:39:55 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 21 Apr 2001 02:39:55 -0700 Subject: ActivePython 2.1 (build 210) References: <000c01c0c958$141f6240$d938a8c0@Hadfield> <5f6rb9.ke1.ln@alltel.net> Message-ID: <3AE1556B.95A5AC2F@ActiveState.com> Maniac wrote: > > Paul Prescod wrote: > > > > BTW, the quotes around the path do not, as far as we know, cause any > > serious problems on any variant of Windows. On the other hand, it may be > > that we were over-conservative in adding them. I'll check with our QA > > and installer guys about that. > > Wow Windows and Quality Assurance in the same paragraph.... what's the > world coming to? > > BTW isn't Windows Quality Assurance an oxymoron? I didn't say we quality assured windows. Just that we do quality assurance ON windows. Quality assurance on unstable, inconsistent platforms consists of figuring out what workarounds are necessary in what circumunstances! We had some doozies getting out ActivePython on e.g. Windows 95...and that was after all of the work the core team put into Win95 compatibility themselves! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jegnet at cadvision.com Fri Apr 27 18:05:09 2001 From: jegnet at cadvision.com (jegnet) Date: Fri, 27 Apr 2001 22:05:09 GMT Subject: Thankyou for all the wonderfull help and suggestions References: <3AE7ADC9.C82A9C18@yahoo.com> Message-ID: <3AE9EE38.414C05BE@cadvision.com> xerox wrote: > I looked at the cook book approach in the documentation > and the link for the compile.py script is broken. > > Does anyone have any complete examples allow with how > to set up MS VC++ 6 > > I have searched everywhere but probably am looking in the > wrong places :) > > Thanx From loeffler at multichannelsystems.com Tue Apr 17 11:16:08 2001 From: loeffler at multichannelsystems.com (Hans Löffler) Date: Tue, 17 Apr 2001 17:16:08 +0200 Subject: a serial port module for the Mac? Message-ID: <9bhmpt$9829g$1@ID-63368.news.dfncis.de> Is there something like the Serial package for Windows for the Mac around? Hans From robin at jessikat.fsnet.co.uk Sat Apr 14 06:13:59 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 14 Apr 2001 11:13:59 +0100 Subject: thread conditional code Message-ID: It seems that using a lock requires the threading overhead; so is there any way to avoid locking when threading hasn't been started? I guess I would like to know if thread.c's initialized variable is true / false. That way I could conditionally lock access to contentious variables and avoid thread overhead when not needed. -- Robin Becker From nas at python.ca Wed Apr 4 10:31:26 2001 From: nas at python.ca (Neil Schemenauer) Date: Wed, 4 Apr 2001 07:31:26 -0700 Subject: how to rebuild Python with static linking (freeze/AIX) ? In-Reply-To: ; from Eugene.Leitl@lrz.uni-muenchen.de on Wed, Apr 04, 2001 at 04:17:43PM +0200 References: Message-ID: <20010404073125.A14489@glacier.fnational.com> Eugene Leitl wrote: > Any idea how to do that? Uncomment the relevant modules in Modules/Setup. Don't uncomment the "*shared*" line. Rebuild. Neil From olaf.zanger at soli-con.com Tue Apr 10 01:59:04 2001 From: olaf.zanger at soli-con.com (Olaf Zanger) Date: Tue, 10 Apr 2001 05:59:04 GMT Subject: modem Message-ID: <3AD2A24B.254B335@soli-con.com> hi there, i'm working on suse linux 7.1 with python 1.54 i couldn't find anything in the documentation about a modem module. we want to call a datalogger and send a 'space' get the responded 'SIC100 #14012040' send a '?' send a 'd' get 100 lines something back where one looks like: '20.03.2001 00:00 0.00E3' thanks for help olaf -- soli-con Engineering Zanger Dipl.-Ing. (FH) Olaf Marc Zanger Lorrainestrasse 23 3013 Bern / Switzerland Fon: +41-31-332 9782 Mob: +41-76-572 9782 mailto:info at soli-con.com mailto:olaf.zanger at soli-con.com http://www.soli-con.com From paulp at ActiveState.com Tue Apr 17 16:25:08 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 17 Apr 2001 13:25:08 -0700 Subject: After Parrot, what next? References: <3ad5c8ae.159009144@news.okstate.edu> <9b8see$71d$1@slb6.atl.mindspring.net> Message-ID: <3ADCA6A4.D58F8B13@ActiveState.com> [news and mail] Mark 'Kamikaze' Hughes wrote: > > ... > > Who lied to you and told you SAX was a good idea? I was involved (in an admiteedly minor way) with the original specification of SAX. I've also been using SAX-like parsers for about eight years now. In the early days it was common to laugh at people who tried DOM-like parsers because who had that much RAM to spare? SAX-like programming languages used to sell for thousands of dollars and people built really complicated multimedia applications with them. i.e. Encarta In 90% of all XML applications a DOM is merely a convenient luxury. They could be done with SAX instead. The only exceptions are applications that do heavy multi-node addressing and you don't need that to define a programming language. In fact I've never seen an XML-based programming language that did addressing into the source documents. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From rcameszREMOVETHIS at dds.removethistoo.nl Fri Apr 13 11:31:24 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Fri, 13 Apr 2001 15:31:24 GMT Subject: tars and zips References: <3AD5F88E.13C645D5@packeteer.com> Message-ID: Bob Purvy wrote: > [Zip] > > Anyway, for zip: I've gotten as far as importing zipfile, creating > the ZipFile object, and listing its contents. But do I need to > write some Python code to iterate through the files, doing read for > each one and then writing it? I haven't found any single 'inflate' > method anywhere, nor the equivalent of 'tar xf'. Use the read() method on the ZipFile-object, where is the full name of any of the files in the archive. The one flaw is that read() stores all of that decompressed file into memory, and returns it as a string, so for very large files that may be a nuisance. Please keep in mind that what seems to be a path specification in actually is just part of the name: a name like 'this/is/my/file.txt' is a good name for an archive member, but may not be a good filename if the subdirectories don't exist already. For compressing files, use write(filename[, arcname[, compress_type]]). You'd expect to see write() working the exact same way as read(), only the other way around, but it doesn't: it appends a file to the archive, not a string. Pretty convenient, if somewhat inconsistent. Although defaults to it is best to clean it up a bit so that it doesn't start with a '/' or something like 'C:/', and you may want to remove (part of) the common prefix when appending a large number of files: if all of the files start with, for instance, /usr/robert/projects/python/zip/ just keeping the prefix zip/ will usually be sufficient. Also, unzipping a file sometimes (it's rare, but it happens) fails unexpectedly, where other archivers (like WinZip and PowerZip) don't complain. (The error seems to come from the zlib-library, not the Zip- module.) However, this has never happened with files I have created myself, either using the zip-module, or some other archiver, so I'm at a loss why that is. It could be that there are some minor incompatibilities between the deflate-methods in zlib and some archivers. It's a minor issue, though: finding a truly corrupted zipfile, where all archivers will report CRC errors, happens at least as often. Robert Amesz From nas at python.ca Wed Apr 25 10:00:28 2001 From: nas at python.ca (Neil Schemenauer) Date: Wed, 25 Apr 2001 07:00:28 -0700 Subject: None :) In-Reply-To: <3AE6CBC8.B473F622@inenco.no>; from hans@inenco.no on Wed, Apr 25, 2001 at 01:06:13PM +0000 References: <3AE6CBC8.B473F622@inenco.no> Message-ID: <20010425070027.B19405@glacier.fnational.com> Hans Kristian Ruud wrote: > When an element in a sequence s is None, > max (s) will return None: > > >>> s = [1.4, 2.5, None, 4354549999L] > >>> max(s) > >>> > >>> min(s) > 1.4 The ordering of different types is arbitrary. In Python < 2.1 all numeric types were smaller than all other types. In 2.1 None is smaller than any type. Neil > > I could'nt find anything about this particular case > in "Learning Python" by Lutz and Ascher. Nor in the FAQ. > > > slightly mystified > - hans kristian - > > -- > http://mail.python.org/mailman/listinfo/python-list From jmarshal at mathworks.com Wed Apr 4 09:54:24 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 4 Apr 2001 13:54:24 GMT Subject: A couple garbage collector questions References: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> Message-ID: <9af92g$mmb$1@news.mathworks.com> Dan Sugalski wrote: ... > There are also a number of other versions of the traditional M&S that are > more responsive and more cache friendly too. (Generational garbage > collectors are rather nice) Or stop-and-copy collectors in general, which don't need to touch every object like mark-sweep collectors do. From sanner at scripps.edu Mon Apr 2 18:38:59 2001 From: sanner at scripps.edu (Michel Sanner) Date: Mon, 2 Apr 2001 15:38:59 -0700 Subject: unsigned short in Python 2.0 Message-ID: <1010402153900.ZM82170@noah.scripps.edu> Hi, I tried my PuOpenGL graphics tools out under Python2.0 and found some differences with Python 1.5.2 it seems that with Python 1.5.2 it was possible to pass an unsigned short value to a function expecting a short. This is used in _openglmodule.c, for instance static PyObject* gl_LineStipple(PyObject* self, PyObject* args) { GLint arg1; GLushort arg2; TRY (PyArg_ParseTuple(args, "ih", &arg1, &arg2)); glLineStipple(arg1, arg2); Py_INCREF(Py_None); return Py_None; } Python 1.5.2 (#0, Apr 14 2000, 10:15:38) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> from OpenGL import GL >>> GL.glLineStipple(1.0, 0xFFFF) No problem under python2.0 passing anything larger than 2**15-1 creates a overflow exception (I think in PyArg_ParseTuple). Python 2.0 (#4, Oct 23 2000, 11:20:17) [C] on irix646 Copyright (c) 2000 BeOpen.com. All Rights Reserved. >>> from OpenGL import GL >>> GL.glLineStipple(1.0, 0xFFFF) Traceback (innermost last): File "", line 1, in ? GL.glLineStipple(1.0, 0xFFFF) OverflowError: signed short integer is greater than maximum >>> I could not see how to specify an unsigned short in the documentation :( .. -Michel -- ----------------------------------------------------------------------- >>>>>>>>>> AREA CODE CHANGE <<<<<<<<< we are now 858 !!!!!!! Michel F. Sanner Ph.D. The Scripps Research Institute Assistant Professor Department of Molecular Biology 10550 North Torrey Pines Road Tel. (858) 784-2341 La Jolla, CA 92037 Fax. (858) 784-2860 sanner at scripps.edu http://www.scripps.edu/sanner ----------------------------------------------------------------------- From dsh8290 at rit.edu Thu Apr 19 13:22:57 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 19 Apr 2001 13:22:57 -0400 Subject: why python annoys me In-Reply-To: <9bn1pi$96c$2@news.sns-felb.debis.de>; from ramagnus@zvw.de on Thu, Apr 19, 2001 at 05:57:28PM +0200 References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> <9bn1pi$96c$2@news.sns-felb.debis.de> Message-ID: <20010419132257.G28582@harmony.cs.rit.edu> On Thu, Apr 19, 2001 at 05:57:28PM +0200, Rolf Magnus wrote: | Jaap Spies wrote: | | > Did you give Jython a try? With Jython you can use the 'nice things of | > Python' with the best of Java. | | With "the best of Java", do you mean the poor memory management? I heard | that's one of the biggest difference between Python and Jython. He meant the extensive libraries that exist and are being made and "sold" (ie convincing management that java & libs are good) rapidly. Yes, Jython and CPython (Jython is Python, you know :-)) have different memory management techniques. CPython is implemented in C, where malloc/free are used to manage memory, and it is the programmers job to do it right. CPython chooses to use reference counting to determine whether or not a Python object needs to/should be freed at any given time. Jython is implemented in Java. As such it runs on top of a JVM. As a result Jython can not do any better than the JVM's garbage collector for freeing memory becuase java does not provide a manual mechanism like free(). A design decision, no doubt influenced by this fact, in Jython is to use the JVM's gc to handle the memory management and not bother with ref counting at all. So yes, Jython does have just as much memory problems as Java because Jython is a Java program. -D From root at rainerdeyke.com Fri Apr 20 13:14:46 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 20 Apr 2001 17:14:46 GMT Subject: dynamic casting in python References: <9bo76f$q82$1@bob.news.rcn.net> Message-ID: "Christian Reyes" wrote in message news:9bo76f$q82$1 at bob.news.rcn.net... > How do I do it? > Is it possible? def dynamic_cast(klass, object): if isinstance(object, klass): return object # Returns 'None' if 'object' is not an instance of 'klass' class C: pass class A(C): pass class B(C): pass def create_C(name): # Factory function if name == 'A': return A() if name == 'B': return B() raise ValueError, 'create_C argument must be "A" or "B"' spam = create_C('A') spam_as_A = dynamic_cast(A, spam) # Sets 'spam_as_A' to 'spam'. spam_as_B = dynamic_cast(B, spam) # Sets 'spam_as_B' to 'None'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aslusarc at pc46.ics.ele.tue.nl Fri Apr 27 09:11:34 2001 From: aslusarc at pc46.ics.ele.tue.nl (Alexander Slusarczyk) Date: 27 Apr 2001 15:11:34 +0200 Subject: Tkinter Toplevel spawned in event handler Message-ID: Hi! I am a Tkinter rookie, so please bear with me if I'm doing something obviously stupid. I am trying to write a simple Tkinter application, which will show modeless windows with some content as the reaction to button press. I am trying to achieve it with the following code: ---- class MyWin(Toplevel): def __init__(self,master,number): Toplevel.__init__(self,master) self.number = number Label( self , text=str(self.number) ).pack() self.bind("", self.cancel) self.wait_window(self) def cancel(self,event=None): print "Canceling",self.number self.destroy() def new_window(): global win_number, root no = win_number win_number = win_number + 1 print "Showing",no t = MyWin(root,no) print "Canceled",no root=Tk() win_number=0 Button(root, text="New Window",command=new_window).pack() root.mainloop() ---- when I run it and create 3 windows (0,1 and 2), and then "" them in the order of their creation I get the following: Showing 0 Showing 1 Showing 2 Canceling 0 Canceling 1 Canceling 2 Canceled 2 Canceled 1 Canceled 0 it seems that MyWin(root,x) for a window only returns, after the MyWin() for all the windows created AFTER x have returned (?!) Am I making any sense? Does anyone have an explanation, or - preferably - a fix ? Thanks in advance, Alex From zeitlin at seth.lpthe.jussieu.fr Fri Apr 20 15:08:39 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 20 Apr 2001 19:08:39 GMT Subject: Tkinter and wxPython References: <20010419150803.Z29182@trufflehunter.avalongroup.net> Message-ID: On Thu, 19 Apr 2001 21:32:35 -0400, D-Man wrote: >On Fri, Apr 20, 2001 at 12:23:58AM +0000, Vadim Zeitlin wrote: >| On Thu, 19 Apr 2001 18:36:53 -0400, D-Man wrote: >| >Personally I like GTK+ the best, and it does work on *nix and Windows. >| >| Sorry to sound exhausted, but could people please understand one day that >| wxPython *is* GTK+ under Unix?? Even Cameron Laird wrote in his small > >No need to apologize Vadim. I know that wx(Python|Windows) is has GTK >as the underlying implementation on Unix systems I know that you know :-) but I think that reading the above may confuse people who don't. >I think the cause is providing the wxWindows API (philosophy on >layout) on top of the GTK+ framework. I think the cause is that some controls (most notable tree and status bar) are not implemented using the GTK widgets. This could be easily changed if someone really wanted it bad enough though. > Maybe Boa Constructor can fill the first part of that gap? Not at all impossible from what I know about it. There is wxWorkshop too, of course. > Also I think I've heard some talk in the wx community >about an XML description thing that seems to resemble libglade. It >will be a big advance/improvement in the wx system. The XML resources already work, the problem is packaging/makefiles. I don't know if they're already supportedb y wxPython but they surely will be in (relatively) near future. Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From javalist at 21cn.com Thu Apr 26 23:29:19 2001 From: javalist at 21cn.com (javalist) Date: Fri, 27 Apr 2001 11:29:19 +0800 Subject: how to explain this memory usage Message-ID: <48567482546.20010427112919@21cn.com> Hello python-list, thanks everyone,I have try it on all the platform I have access,here is a short list: platform/system that free/delete don't return memory to os: *solaris 7/solaris 8/solaris 2.6 for sparc *solaris 7 for x86 *hpux 11.00 on L2000 *irix 6.5 (mips) platform/system that free/delete do return memory to os: *linux on x86 *free bsd 4.2 on x86 *win2000(very strange,win do return memory to os,but not all,about 1/3 is still belong to python interpreter) Best regards, javalist mailto:javalist at 21cn.com From aleaxit at yahoo.com Wed Apr 11 12:17:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Apr 2001 18:17:33 +0200 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> Message-ID: <9b203102hla@news2.newsguy.com> "Robert Johnson" wrote in message news:3ad467f2$0$47994$e2e8da3 at nntp.cts.com... > I am a Python newbie and I am wondering if Python and TKInter will allow me > to write web applications similar to what I can do with ActiveX. Python can run on your server and do lots of wondrous things, but that's pretty different from running an ActiveX on the _client_ machine. Running Tkinter on your server will only make pretty graphics *on your server box* -- they will not be seen by the clients visiting your site! To run a classic-Python application *on the client-side*, the client-side would have to install Python or some packaging thereof -- it's not really a "web application" any more then, is it? Although it may use various means to let the specialized clients talk to Python programs on the server, admittedly. > Apparently, ActiveX is not Netscape-compatible, or so I'm told (what a Or vice versa -- a zillion different application on Windows support ActiveX... it's hardly the fault of the ActiveX architecture if Netscape has decided to stay incompatible with it:-). > surprise!). I am writing an application that will plot an optical thin film > design. It will contain some boxes with entry parameters and will plot a > graph of the reflectance, transmission, tau, or rho for a particular thin > film design over a range of wavelengths (I work for a laser optical > manufacturer that specializes in thin film coatings). This looks like something that might be run on the server-side, using the client just to enter the parameters (a normal HTML form) and then to display the resulting graphs (as images, or, maybe better, as a structured-vector-graphics plot if you can convince your client-users to download and install the appropriate SVG plug-in for their box -- I think Adobe makes free SVG plug-ins available for many browsers and platforms, and it IS, I believe, a W3C recommendation/standard). If you fear that would be too much load on your server, then you need to do a better analysis of the client-side options, depending on what client platforms you want to support. > Another option (WAG)? > I designed the original program with Borland C++ Builder and it works great > as an ActiveX program on the web page (it actually looks like a Windows > program running on the web page). Can I do something with Python that will > allow a Netscape browser to view the ActiveX applet (effectively making the > ActiveX component cross-platform)? I know Python is supposed to be capable > of calling COM objects, though I have not looked into it or if this means I > can run the program in Netscape. Python, with a suitable installation, can use ActiveX (through various means, but the best and most flexible way is through Internet Explorer, a highly-reusable collection of excellent components) *on Windows platforms* -- this doesn't help you if you want your applications to be used on NON-Windows platform. What platforms, exactly, do you want to target? Why does your app need to be a "web" one (DOES it)? Why does it need to be client-side (DOES it)? If the answers are 'all platforms', MUST be web-based e.g to allow it being updated at any time, it must be client-side e.g. to leave the server with a light load, then I think the ONLY answer you can try is the JVM -- as least as a plug-in, it's available for most browsers, and Python can run on reasonably-updated versions of it (see www.jython.org). Tkinter cannot run on the JVM -- it can only run natively on the various different platforms; you will have to use Java-classes for your GUI's -- awt, swing, whatever. > Book recommendation: > Has anyone read the book "Python and TKInter Programming" by John E. > Grayson? What did you think of the book? Did it help? I've only started browsing it, but it seems good. However, it will be of no help at all for the scenario you're outlining, alas. Alex From zzizz_ at notmail.com Wed Apr 11 18:45:06 2001 From: zzizz_ at notmail.com (zzzzz) Date: Thu, 12 Apr 2001 08:45:06 +1000 Subject: Spice, electrical/electronic simulation & Python Message-ID: <8bn9dt8mn6trvnvst9giq9ipqg46uanf0o@4ax.com> Hi all, To those that don't know spice is a simulation program for electronic/electrical circuit. Has anyone thought about controlling spice through Python scripts, I think this would be an excellent idea & increase the power of spice dramatically? If not, I'll have a go myself when I get time away from the hardware, but why reinvent the wheel? z. (alias Paul E) Regards, zzzzz. --------------------- From ben.hutchings at roundpoint.com Sun Apr 1 21:57:36 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 01 Apr 2001 18:57:36 -0700 Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> Message-ID: Carl Banks writes: > I remember seeing a language that had different operators for > reference and copy assignment, but I forget what is was. VB has separate keywords for those, Set and Let; if neither is used it defaults to copy assignment. In most places only one of those is valid so it's not a real choice. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From whisper at oz.nospamnet Sun Apr 22 13:20:13 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 22 Apr 2001 17:20:13 GMT Subject: Python-2.1(Windows) Optional supproject build problems References: Message-ID: <9bv3sd$2he$0@216.39.170.247> Installation tree - how does that differ from the source tree i'm using? My binary distribution tree is not the same tree as my source tree. One is in Python21 (as it chose), and the source tree is in Python-2.1 (likewise, as it chose). (Ok, I chose the drive, but the rest was it's choice.) WRT the preferred path to install Python sources, i'll keep in mind that I'm to somehow magically know that a FAQ on sourceforge gives that info. it's-at-least-unclear-and-was-just-trying-to-help-silly-run-on- sentencedly-yours... Dave LeBlanc P.S. WRT to "Guido's too" - thanks, but if I wanted someone else to do my thinking for me, i'd be a Pearl user. No disrespect meant to Guido. From qrczak at knm.org.pl Sat Apr 21 17:43:56 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Apr 2001 21:43:56 GMT Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> <3ADF54F1.6000409@hccnet.nl> <3AE0F802.3983C9DB@01019freenet.de> <9brd4f0p7u@news1.newsguy.com> <3AE1D1DE.BF3CEA18@Lugoj.Com> Message-ID: Sat, 21 Apr 2001 11:30:54 -0700, James Logajan pisze: > what are (or is?) "list comprehensions"? A syntax which looks for example like this in Python: [x+y for x in l1 if x<0 for y in f(x)] which means: __result = [] for x in l1: if x<0: for y in f(x): __result.append(x+y) # Result is in the variable __result except that it's a single expression (and doesn't create the variable named __result). > definition of "functional programming"? IMHO the most important technical aspects are: 1. working with immutable data, 2. working with functions as values. In the resulting style implicit maintaining of mutable state is avoided, dependencies on inputs and produced outputs are more explicit, recursion is preferred to loops, expressions are more important than statements, values of expressions rarely depend on the moment of evaluation, reading inputs is often separated from processing the data in internal forms and from writing outputs, functions taking functions as arguments often replace control structures, behaviors are expressed as data, examining object values is more important than checking object identities, effect of an operation is expressed as returning appropriately structured data instead of setting variables or raising exceptions, nesting of simple structures is preferred to big flat objects, objects are more often put into structures which define relationships with other objects than maintain relationships themselves... I'm afraid it's hard to explain. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sholden at holdenweb.com Sun Apr 22 16:01:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 22 Apr 2001 16:01:24 -0400 Subject: Nested Scopes in Idle/PythonWin References: Message-ID: "Greg Chapman" wrote in message news:mailman.987963514.5400.python-list at python.org... > On 22 Apr 2001 15:48:51 -0000, Steve Holden wrote: > > Are you saying that IDLE won't correctly handle modules containing > > > > from __future__ import nested_scopes? > > > > No, I'm talking about the interactive interpreter: > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> def make_adder(x): > return lambda y: x+y > SyntaxError: local name 'x' in 'make_adder' shadows use of 'x' as global in > nested scope 'lambda' (, line 1) > >>> > Interesting. One of the problems of IDLE and PythonWin, of course, is that they provide a "preconfigured" module space in which to run itneractive commands. Sounds like this might be a toughie (hence your umpteen-line patch). Really the IDEs should offer a command-line option to switch on this (and other optional features). Did this perhaps get overlooked in the development process, or is it covered in the release notes? glad-I-haven't-yet-switched-ly y'rs - StEvE From spamers at must.die Mon Apr 16 12:26:17 2001 From: spamers at must.die (Fernando Rodríguez) Date: Mon, 16 Apr 2001 18:26:17 +0200 Subject: Strange error with unbound method Message-ID: Hi! I have a class called ParaStyle (see code below). This class has a method called makeBlackAndWhite that returns a new instance of class ParaStyle. I want to transform a list of ParaStyle instances into a list of the result of applying the makeBlackAndWhite method of each instance. If I do: paraStyles = map( ParaStyle.makeBlackAndWhite, paraStyles ) I get the following error: TypeError: unbound method must be called with class instance 1st argument While if I do it with a for loop: l = [] for para in paraStyles: l.append( para.makeBlackAndWhite() ) I dont get any error! =:-O What's going on???? O:-) -----------ParaStyle Class------------------- class ParaStyle(BaseObject): """Contiene toda la info sobre un estilo de p?rrafo: el estilo de sus caracteres (una instancia de un CharStyle), su alineaci?n, el 'leading' o separaci?n entre lineas, el indentado (una instancia de algna de las siguientes clases: NullIndent (sin indentado), NormalIndent, FrenchIndent o FirstLineIndent)y cual es el siguiente.""" # Tipos de alineaci?n alignment = { 'left': '\ql', 'right': '\qr', 'centered': '\qc', 'justified': '\qj', 'none' : ''} # Tipos de separaci?n (leading) leading = { 1:'', 1.5:"\sl360\slmult1", 2:"\sl480\slmult1" } # TODO: debe de comprobar que los par?metros alignment, # y leading son del tipo correcto. Sino, debe de # levantar una excepci?n # Si no es por omisi?n (no contiene la palabra default o # normal) y no tiene basedOn, probablemente sea un # error. Avisar. def __init__( self, names, charStyle = NullCharStyle(), next = NullParaStyle(), basedOn = NullParaStyle(), indent = NullIndent(), alignment = 'none', leading = 1 ): if not alignment in ParaStyle.alignment.keys(): raise UnknownAlignment, str( alignment ) + ' isn`t a valid alignment' if not leading in ParaStyle.leading.keys(): raise UnknownLeading, str( leading ) + ' isn`t a valid leading' if not names[0] == 'default' and basedOn.__class__ == NullParaStyle: raise NoParent, str( names ) + ' has no basedOn. ' + \ 'Since it`s not the default one, it must have a basedOn' self.names = names self.basedOn = basedOn # si no se indica un next, ha de apuntar a s? mismo if next.__class__ == NullParaStyle: self.next = self else: self.next = next # Hacemos la herencia de next, indent, alignment y leading # en el momento de construir la instancia if basedOn.__class__ == NullParaStyle: self.alignment = alignment self.indent = indent self.leading = leading self.charStyle = charStyle else: if charStyle.__class__ == NullCharStyle: self.charStyle = basedOn.charStyle else: self.charStyle = charStyle if alignment == 'none': self.alignment = basedOn.alignment else: self.alignment = alignment if indent.__class__ == NullIndent: self.indent = basedOn.indent else: self.indent = indent if leading == 1: self.leading = basedOn.leading else: self.leading = leading def makeBlackAndWhite( self ): """Versi?n en blanco y negro del formato ??Ojo!! Si el next es self, tenemos un poblema: para construir un BW, necesitamos previamente ese BW para pasarlo al constructor. Esto causar?a un bucle sin fin. Para evitarlo, construimos primero una versi?n parcial sin el next, y luego le a?adimos una ref a s? mismo. """ if self.next == self: partial = ParaStyle( names = self.names, charStyle = self.charStyle.makeBlackAndWhite(), basedOn = self.basedOn.makeBlackAndWhite(), indent = self.indent.makeBlackAndWhite(), leading = self.leading, alignment = self.alignment ) partial.next = partial return partial else: return ParaStyle( names = self.names, charStyle = self.charStyle.makeBlackAndWhite(), basedOn = self.basedOn.makeBlackAndWhite(), next = self.next.makeBlackAndWhite(), indent = self.indent.makeBlackAndWhite(), leading = self.leading, alignment = self.alignment ) //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From a.kupries at westend.com Sat Apr 21 18:12:42 2001 From: a.kupries at westend.com (Andreas Kupries) Date: 22 Apr 2001 00:12:42 +0200 Subject: Animation with Tk References: Message-ID: <874rvhsy05.fsf@bluepeak.westend> "Nick Perkins" writes: > How can I run a timing loop in a Tk app? I would like to use the > Tk.Canvas widget to try some simple animation. It has some cool > features. I need to have an animation loop, but also have working > buttons, etc, which means running the tk mainloop. See also the Tcl'ers Wiki, http://purl.org/thecliff/tcl/wiki/ModelRailroadingWithTcl http://purl.org/thecliff/tcl/wiki/MoreModelRailroading http://purl.org/thecliff/tcl/wiki/PostcardFromSwitzerland -- Sincerely, Andreas Kupries Developer @ Private ------------------------------------------------------------------------------- From just at letterror.com Fri Apr 20 12:32:57 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 20 Apr 2001 18:32:57 +0200 Subject: Error with string.strip References: <3AE05834.93331DA5@comm.mot.com> <3AE05F50.4D6B517F@comm.mot.com> Message-ID: <3AE064B7.A551DE16@letterror.com> Stephen Boulet wrote: > > > >>> import string > > > >>> string.strip("all's well as ends well ") > > > "all's well as ends well" > > > >>> string.strip(" 15157 ? 0:01 ttsession\012") > > > File "", line 1 > > > string.strip(' 15157 ? 0:01 ttsession\012') > > > ^ > > > SyntaxError: invalid syntax > > > > > Hmm. I'm using 1.5.1 for HPUX 10.x. Maybe I need to upgrade... Hm, it works even in Python 1.5: Python 1.5 (#13, Jun 15 1998, 17:37:50) [GCC 2.7.2.1] on bsdos4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.strip(" 15157 ? 0:01 ttsession\012") '15157 ? 0:01 ttsession' >>> Just From tim.one at home.com Wed Apr 25 00:52:36 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Apr 2001 00:52:36 -0400 Subject: [Python-Dev] Class Methods In-Reply-To: <9c1efn$bkiug$1@ID-59885.news.dfncis.de> Message-ID: [Thomas Heller] > ... > There are cases however (although not in the python library), > where class attributes do not only provide _default_ values > for the instance, but are shared among _all_ instances of this class. Sure. > Here is my actual example: > > I want to define C Structure-like classes, which can be used to wrap > memory blocks, and allow access via attribute names. > > Take the following C code: > > struct POINT{ > int x, y; > }; > > which I would like to define in python in this way: > > class POINT(Structure): > _names = "x", "y" > _format = "ii" # specified in the way the struct-module uses > > and use in this way: > > p = POINT(10, 20) > p.x # would return 10 > p.x = 100 > p._getaddr() # would return the address of the memory block containing > # a struct POINT. I think we're in danger of over-specifying the problem here . > POINT.size_in_bytes > or > POINT.size_in_bytes() # would return the same as the C code > sizeof(struct POINT) > > I would like to retrieve the size_in_bytes attribute _before_ > the first instance of POINT is created, so I cannot calculate > this in the first __init__() call, a magic class method, > automatically called just after the class creation, would come > very handy. That's reasonable enough -- but you know there are many ways to accomplish this already, right? I'm afraid I greatly *prefer* an explicit call to some sort of do_magic_stuff_to_class(POINT) after the class definition, to make it clear that you're playing unexpected games with the class definition (e.g., there is nothing in the body of POINT to suggest to anyone other than the original author-- and even then only right after writing it --that instances will grow .x and .y attributes out of thin air; and I don't care if you have to write an extra line of code if in return readers get a *clue* that dynamic trickery may be afoot). In my experience, there are three kinds of metaclass users in Python: those who blissfully ignore the possibilities; those who endured the metaclass essay to the end, tried it once or twice, shrugged their shoulders and moved on; and those who lived to regret taking it seriously. It makes code a godawful obscure mess, and so even the relatively few people who understand it steer clear of it whenever possible (for example, the Python-level hook has been in since 1.5a3, and it *still* hasn't found a use in the std library). I understand that you're not after something as encompassing as the metaclass hook, but if what you want *can* be spelled with an explicit call, I'm inclined to let it rest there. import struct def do_magic_stuff(c): c.size_in_bytes = struct.calcsize(c._format) class Structure: def __init__(self, *args): if len(self._names) != len(args): raise TypeError("wrong # of args") self.__set_attrs_from_values(args) def __set_attrs_from_values(self, values): i = 0 while i < len(values): setattr(self, self._names[i], values[i]) i += 1 def pack(self): values = [getattr(self, attr) for attr in self._names] return struct.pack(self._format, *values) def unpack(self, blob): values = struct.unpack(self._format, blob) self.__set_attrs_from_values(values) class POINT(Structure): _names = "x", "y" _format = "ii" do_magic_stuff(POINT) After that, >>> POINT.size_in_bytes 8 >>> p = POINT(10, 20) >>> p.x 10 >>> p.y 20 >>> p.pack() '\n\x00\x00\x00\x14\x00\x00\x00' >>> p.unpack('\n\x00\x00\x00\x34\x00\x00\x00') >>> p.x 10 >>> p.y 52 >>> What does that look like in *your* ideal world? I doubt it will be substantially simpler, but suspect it will be even more obscure. From sholden at holdenweb.com Sun Apr 8 12:54:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Apr 2001 12:54:02 -0400 Subject: Which happens first? References: Message-ID: "Remco Gerlich" wrote in message news:slrn9d057b.llp.scarblac at pino.selwerd.nl... > Carlos Alberto Reis Ribeiro wrote in comp.lang.python: > > My personal conclusions are as follows. Please feel free to disagree and/or > > clarify: > > > > 1) Avoid any unnecessary calculation, specially inside tight loops. I tend > > to use lots of explicit calculations, in order to make code easier to > > understand. Things like adding/subtracting one, or calculating an offset > > (for a struct, for instance) are common applications of this idiom, for > > example: > > > > >>> p = a[(3*4+2)-1] # get the second byte of the third DWORD > > > > This kind of construct should be avoided. > > Premature optimization is one of the worst programming sins. > This sin is also known as "introducing implementation bias". Imagine how silly you will feel if you spend several days optimizing a large Python suite in this way, then changes in the compiler technology render your code even less efficient than it would have benn if written naturalistically. > You spend programmer time (figuring out which order to type it) and > readability (writing it (3*4+2)-1 is self-documenting) in order to get some > tiny speed plus that probably doesn't matter at all. > If speed matters as much as Carlos seems to feel it does then arguably Python isn't the right language in the first place! Of course, as suggestions for how the compiler might do a better job they are fine, but I'm sure the developers would be happier to see patches than suggestions. > Only when your finished program is too slow, you can start optimizing. First > you use the profiler to find the 2% of your code that does all the slow > work. Then you improve the algorithm. And if that didn't work, usually > rewriting that small bit in C will be much more effective than saving a > bytecode because of the order of the operands... > Yup. First, make it work. THen (if it doesn't work fast enough) make it work faster. the-wrong-answer-in-half-the-time-is-worthless-ly y'rs - steve From ws-news at gmx.at Tue Apr 3 10:40:25 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 3 Apr 2001 16:40:25 +0200 Subject: ANNOUNCE: python-win32 mailing list References: Message-ID: <986309134.792223@newsmaster-04.atnet.at> I would much prefer if such a group was accessible trough usenet. Mailing lists are a pain with Lotus Notes 4.5, the mail program that is used in our company for various reasons. And a web interface is even worse :-( regards werner From phrxy at csv.warwick.ac.uk Fri Apr 20 12:33:18 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 20 Apr 2001 17:33:18 +0100 (BST) Subject: Syntax error [was: Installed modules list?] In-Reply-To: <15072.25256.945605.144371@slothrop.digicool.com> Message-ID: On Fri, 20 Apr 2001, Jeremy Hylton wrote: > Never mind my previous message. It's pretty clear from the grammar. > > stmt: simple_stmt | compound_stmt > simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE > small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt > compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef > > You can only join simple statements with a semicolon. None of the > statements that use colons between parts are simple statements. Is there any way to work around this for the purpose of simple unix scripts using python -c, then? Other than putting the python in a separate file, of course. John From sdm7g at Virginia.EDU Fri Apr 20 11:58:19 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 20 Apr 2001 11:58:19 -0400 (EDT) Subject: Syntax error [was: Installed modules list?] In-Reply-To: Message-ID: On Tue, 17 Apr 2001, John J. Lee wrote: > I was going to suggest a find command, if you're on unix, but then I > discovered I didn't understand python syntax: > > $ echo `python -c 'for d in [1,2]: print d'` > > works, while > > $ echo `python -c 'import sys; for d in [1,2]: print d'` > > doesn't -- it's a SyntaxError. > > Why? > Interesting. Also: >>> print 1; print 2; if [1]: print 3 File "", line 1 print 1; print 2; if [1]: print 3 ^ SyntaxError: invalid syntax I haven't looked at the actual grammar in quite a while, but I'm guessing that there is a bit of an overgeneralization in the rules to prevent compound statements like: >>> for x in [1,0,2]: if x : print x File "", line 1 for x in [1,0,2]: if x : print x ^ SyntaxError: invalid syntax which are definitely disallowed. -- Steve Majewski From aahz at panix.com Mon Apr 9 19:08:01 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Apr 2001 16:08:01 -0700 Subject: still wondering (was Re: Pep 245) References: <3ACE7FC5.6A72FA4A@seebelow.org> Message-ID: <9atfch$dhk$1@panix2.panix.com> In article <3ACE7FC5.6A72FA4A at seebelow.org>, Grant Griffin wrote: > >But maybe his memory used to be better. (Happens to us all. ) In >its "Tim Peters" section, the book "Learning Python" says: > > Come to think of it, only one person we have talked to claims to > have _met_ Tim in person, and that's Guido. Makes you wonder... > >And I've wondered ever since. But Tim cleared that up recently when he >said that he had met Aahz. So that gives us two witnesses. Note that I have never claimed to have met Tim. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From tim.one at home.com Fri Apr 20 17:34:59 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Apr 2001 17:34:59 -0400 Subject: Can't run "Python-2.1.exe" under NT... In-Reply-To: <067001c0c9df$2d6f4210$0100a8c0@Rogue> Message-ID: [Robin Dunn, reports on a Win2K install failure] > Sorry, since it worked after I rebooted I didn't think of it so > much as a bug but perhaps something that was flaky on my system > before. That's *the* crucial bit of info I really needed to know: debugging one-shots on Windows is hopeless, but in one previous report of what sounded like a similar problem a reboot didn't cure it. I'm happy that the problem went away for you. > (I was also kinda surprisead that the installer was a 16-bit app...) Beggars can't be choosers, alas -- this is the 5.0a version of the Wise installer product, current maybe 6 years ago. They wrote it long before Win2K or ME were even ideas . I believe Mark Hammond talked them into letting Python use it for free, but he moved on from this role, and I haven't had the bandwidth to pursue a more modern alternative. > ... > [Win2K] SP1, also with most other updates from Windows Update as > of a few weeks ago. It's the English version, and a Dell OEM > version as well (in case they did anything to it.) In all those respects, your box matches the Windows boxes Guido & I use at the office. > I removed Dell's original install and reinstalled myself > from their media. Aha! We didn't . [... Administrators group, worked after a reboot ...] > Just before the files started copying. I think it froze when I > clicked on the final button before the install but I don't know > if it froze as a result of the click or if it was frozen already. Then this may be related to one report of a Win2K freeze, except they used the French version. [... and a description of the usual dance when the 16-bit subsystem dies ...] > I changed the install directory to c:\Tools\Python21, as I always do. > Everything else was left alone. > > HTH, It did! Thank you very much. From not.this at seebelow.org Fri Apr 6 12:25:42 2001 From: not.this at seebelow.org (Grant Griffin) Date: 6 Apr 2001 09:25:42 -0700 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <3AC680EE.997108AB@northwestern.edu> <3ac69340_2@news4.newsfeeds.com> <3AC8BF11.1501D4E2@seebelow.org> <9aib2g01rch@drn.newsguy.com> Message-ID: <9akqm60n2e@drn.newsguy.com> In article , "Fredrik says... > >John J. Lee wrote: >> > Yes, but are they doing it in "real time"? >> >> You make it sound as if that were the only kind of programming worth >> doing! ;-) Naw, I was just drawing a distinction... >I've used Python in really serious real time systems -- Just curious: were they also "embedded"? The reason I ask is that embedded systems typically have just the bare minimum of resources--things like memory, processor throughput, peripherals, etc. (That helps make 'em cheap enough, for example, to make burger toys talk.) My overall point here (if any ) is that one generally can't afford to use interpreted languages like Python in resource-critical situations. In any event, I can see how our drastically our "real time" applications differ: >they get huge amounts of new data mine typically get just one or two words of data... >every 15 minutes or so, every 15 microseconds or so, >and must get >rid of them before the next batch arrives... and don't necessarily have to get rid of them before the next batch arrive, but have to provide enough buffering and average throughput so that data does not get "dropped" in the worst case of processor loading. >(and if they're not finished by 6 pm, *everyone* will notice ;-) and if the software doesn't succeed at that, maybe nobody will notice. Or maybe the plane will crash (in which case *somebody* will likely notice. ) that-said,-i'm-glad-to-see-interpreted-languages-getting -their-fifteen-minutes-of-real-time-fame--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 scarblac at pino.selwerd.nl Tue Apr 17 17:36:27 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Apr 2001 21:36:27 GMT Subject: With or Using References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> <2b95c26c4a%tim@worthy.demon.co.uk> Message-ID: Tim Howarth wrote in comp.lang.python: > In message <3ADC5AE1.53C3C4FE at alcyone.com> > Erik Max Francis wrote: > > It saves a small amount of typing (and not very much) at the expense of > > a lack of clarity and the addition of ambiguity. > > I thought with Python's block indenting it would be pretty clear what > was being referred to. Consider: a = A() with a: b = c What does c refer to? Is it a.c or some global c? There's no way to tell. It might even change from time to time. I'm assuming that c would refer to a.c iff a has an attribute called c, and to another variable otherwise. But even the fact that I have to make such an assumption shows that this should not be Python... Be explicit as much as possible. -- Remco Gerlich From pdubuc at cas.org Thu Apr 19 18:08:35 2001 From: pdubuc at cas.org (Paul Dubuc) Date: Thu, 19 Apr 2001 18:08:35 -0400 Subject: Python 2.1 test_locale fails Message-ID: <3ADF61E3.6604FAB3@cas.org> I'm building Python 2.1 on Solaris 2.6. When I 'make test', the test_locale module is the only one that fails: test test_locale failed -- Writing: "'%f' % 1024 == '1024.000000' != '1,024.000000'", expected: '' ... The actual stdout doesn't match the expected stdout. This much did match (between asterisk lines): ********************************************************************** test_locale ********************************************************************** Then ... We expected (repr): '' But instead we got: "'%f' % 1024 == '1024.000000' != '1,024.000000'" Anyone know what this means and how I can fix it? Thanks. Paul Dubuc From bkline at rksystems.com Wed Apr 11 12:51:36 2001 From: bkline at rksystems.com (Bob Kline) Date: Wed, 11 Apr 2001 12:51:36 -0400 (EDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: <20010411111615.L55809-100000@open-systems.net> Message-ID: On Wed, 11 Apr 2001, Chris Watson wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > Sorry, no matter how noble the GNU folks might be, they can't change the > > copyright laws without the cooperation of the courts and/or the > > legislature, and it's not likely they'll be able to enlist the aid of > > either to defeat the longstanding tenet that "de minimis" copyright > > claims are not legitimate. You want to be careful not to mix copyright > > law with contract law. > > Also I might add, there is one known case where you are wrong on this. And > that is the BSD or FreeBSD License. These two licenses allow the GPL to be > placed in addition to the BSDL/FBSDL. Nothing in said licenses prevent it. > So while for most cases youre statement is true in the case of GPL'ing BSD > code it is not. Unfortunately :-/ What? How does anything you wrote support the assertion that changing a single letter of a work in the public domain entitles you to a legitimate copyright claim in the derived work? -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com From s713221 at student.gu.edu.au Sun Apr 15 10:53:17 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Mon, 16 Apr 2001 00:53:17 +1000 Subject: Some Tkinter Canvas Objects Message-ID: <3AD9B5DD.32A1EF57@student.gu.edu.au> I've just written a first stab at some code to make moderatly complex tkinter canvas objects for a chemistry program, including: Simple Lines Double Lines Triple Lines Wavy Lines Scripted Text (Eg. I sorted out how to make a mixture of super-scripted, sub-scripted and normal text on the canvas) Solid Wedges and Stippled Wedges. Yes I know about Canvas.py, but it seemed overkill for what I wanted, I couldn't use it directly without doing a lot of hacking on poor innocent CanvasItem, and disagreed with me on how things should be done. Did steal some ideas from it though ;-) Now these files are to small for me to bother with setting up a sourceforge account, but to large (In terms that it might pee people off) for me to include as a message attachment. I can remember that the official method is to post a vanilla shar file to a "sources" newsgroup and post a reference here, but I can't remember what the other newsgroup is. However, I do want other people to read my code so I can get some suggestions, re. optimisations, generalisations, *grins* why-the-hell-did-you-do-it-that-way-isations. And, a little bit of ego here, it would be cool if others found my stuff useful to them as well. Joal Heagney/AncientHart From jason-dated-5c40fd26209c7880 at mastaler.com Mon Apr 23 15:10:33 2001 From: jason-dated-5c40fd26209c7880 at mastaler.com (Jason R. Mastaler) Date: Mon, 23 Apr 2001 13:10:33 -0600 (MDT) Subject: [ANNOUNCE] TMDA 0.01 - A qmail-based anti-SPAM system Message-ID: I'm pleased to announce the first public release of my Tagged Message Delivery Agent (TMDA). TMDA is an OSI certified Python application for qmail systems designed to significantly reduce (or eliminate) the amount of SPAM/UCE you receive by using unique, cryptographically enhanced (called tagged) e-mail addresses. TMDA can both filter your incoming e-mail, and tag your outgoing address. For complete information, visit the TMDA homepage: As a teaser, TMDA has reduced my influx of SPAM from 500+ junk-messages per month down to only 1-3. Enjoy, Jason R. Mastaler (jason at mastaler.com)

TMDA 0.01 - A qmail-based anti-SPAM system. (23-Apr-2001) From hinsen at cnrs-orleans.fr Tue Apr 10 04:51:36 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 10 Apr 2001 10:51:36 +0200 Subject: Chocolate [was Re: Python Books for 2002] References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> <11A279245FF128F8.7A0E8AF314DD0135.E3C0007C3BD57C8C@lp.airnews.net> <9akknn0p3@news2.newsguy.com> Message-ID: "Steve Holden" writes: > One thing I *don't* understand is how come the stuff Hershey and similar > companies sell is even allowed to be called chocolate. One of the nastier > surprises about moving to the USA was the discovery that many items sold Come to France - chocolatewise this is a highly civilized country. No problem to find 85% pure chocolate even in an ordinary supermarket. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From m.1.robinson at herts.ac.uk Mon Apr 30 04:53:12 2001 From: m.1.robinson at herts.ac.uk (Mark blobby Robinson) Date: Mon, 30 Apr 2001 09:53:12 +0100 Subject: How do I update my API? References: <3AEC4783.6050509@herts.ac.uk> Message-ID: <3AED27F8.8080300@herts.ac.uk> Thanks neil, I installed the development rpm file and it works a treat now....:) Blobby Neil Schemenauer wrote: > > This error means that /usr/lib/python2.1/config/Makefile is > missing and it is needed. Did you install Python 2.1 in > /usr/lib? If so, that file should have been installed. If not, > something is wrong with your 2.1 installation. Perhaps you > installed a packaged version that did not include the development > files. > > Neil > From root at [127.0.0.1] Sun Apr 1 16:18:10 2001 From: root at [127.0.0.1] (deadmeat) Date: Sun, 01 Apr 2001 20:18:10 GMT Subject: list vs tuple References: Message-ID: <62Mx6.1152$p5.4531@news1.rivrw1.nsw.optushome.com.au> > There is a dilemma here nobody has solved. Chicken / egg problem... > You could help by writing a "Python for Pascalers" intro blurb. Um.. er.. I think I left um.. something on. Bye. > occur to you to question whether list[i] is constant-time or takes time > proportional to i Well, you've lost me there. I would have thought a paragraph or two introducing the concept of arrays and how to reference each element would pretty much take care of it.. > the-only-objective-truth-is-that-all-other-languages-suck-ly Only Perl sux :) From grante at visi.com Wed Apr 18 09:54:55 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 18 Apr 2001 13:54:55 GMT Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> Message-ID: In article , Douglas Alan wrote: >> Since self is used for every method of every class, isn't it a bit >> redundant? > >Many people find it less confusing to read code that is written this >way. Otherwise, when you see a variable, you have more choices as to >where the variable might be defined: the local scope, the global >scope, the class scope, etc. > >> I don't know of another OO language that makes you manually carry >> around the "this"/"self" pointer/reference... > >Languages with multimethods routinely do, because multimethods are >typically not class-centric. I.e., a generic function in a language >with multimethods dispatches on all the arguments, not just on one of >them, so no particular argument is given special treatment. > >For class-centric OO languages, I agree with you -- I don't personally >know of any others that require explicit use of self. Smalltalk and Modula-3 both do, IIRC. -- Grant Edwards grante Yow! We just joined the at civil hair patrol! visi.com From aleaxit at yahoo.com Tue Apr 17 06:20:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 17 Apr 2001 12:20:37 +0200 Subject: do...until wisdom found... References: Message-ID: <9bh5e502rf3@news1.newsguy.com> "Ken Peek" wrote in message news:tdnn3dfi4h0m98 at corp.supernews.com... [snip] > while(1): Note that these parentheses are totally redundant. > Some people have suggested that "loop:" is a much better keyword than "do:". > Now I am wondering if they are right-- maybe so. I will have to think about > that some more-- maybe "loop:" IS more readable (by a programming newbie) than > "do:"... hmmm.... It's not an issue of "readable" -- any short English word is readable, but does it suggest what's going on when one does read it? "DO" is just about the least informative verb in the English language ("BE" is often DIS-informative, cfr Korzybski, but that's another issue). "LOOP" is very clear and informative. What's that gotta do with newbieness?! > Can anybody think of a good name for a "Python-like" new language for small > embedded processors? > Let's see-- "tinyPython"? nope-- has "Python" in it-- might make Guido mad. It would be silly to add the adjective "tiny" for a language which aims to be fatter (e.g. by adding multiple redundant loop forms). > Hmmm, maybe "Dragon"? Probably used by someone else? Hmmm... maybe ??? http://www.thesaurus.com/roget/IV/513.html: """ [Nouns] oracle; prophet, seer, soothsayer, augur, fortune teller, witch, geomancer, aruspex; aruspice, haruspice; haruspex; Sibyl; Python, Pythoness; Pythia; Pythian oracle, Delphian oracle; Monitor, Sphinx, Tiresias, Cassandra, Sibylline leaves; Zadkiel, Old Moore; sorcerer [more]; interpreter [more]. """ My favourite suggestions out of this list are Soothsayer, Haruspice and Zadkiel. "Prognosticator" is another similar suggestion. If you prefer the reptilian fold rather than the prophethical one, suitably obscure names could be Woma, Chondro, Liasis, Dumeril, Chandoia, Charina, Corallus, Epicrates, Lichanura, Tropidophis (I'm not 100% sure of the spellings -- checking is advised!). If you prefer the British TV Comedy fold (which is the one Python actually happens to come from), "Fawlty Towers" is one possibility. But I'll leave this part to people more familiar than me with recent British TV Comedy. Let's just note that "Mr Bean" should not be used here, since it's such a natural for some Jython Javabean related framework! Alex From jim at publishingresources.com Fri Apr 27 15:12:11 2001 From: jim at publishingresources.com (Jim Abrams) Date: Fri, 27 Apr 2001 19:12:11 GMT Subject: Controlling SaveAs Word 9.0 COM References: Message-ID: Mark Sloboda wrote in : > Hello, > I have to open a Word file which is text, save it as DOS-encoded text > under a different name, and close it. > A similar VB code example is: > myDocname = ActiveDocument.Name > pos = InStr(myDocname, ".") > If pos > 0 Then > myDocname = Left(myDocname, pos -1) > myDocname = myDocname & ".txt" > ActiveDocument.SaveAs FileName:=myDocname, FileFormat:=wdFormatText > End If > > In my Python code I have tried several approaches: > from win32com.client import Dispatch > > Word = Dispatch("Word.Application") > Word.Visible = 1 > > WordDoc = Word.Documents.Open("C:\\test.txt") > WordDoc.SaveAs(FileName='C:\\TextTest2.txt',FileFormat='wdFormatDOSText' > ) WordDoc.Close() > Word.Quit() > > It works fine if I leave the FileFormat argument out. However, when I > add the FileFormat argument as shown above, I get > > Traceback (most recent call last): > File "d:\python20\pythonwin\pywin\framework\scriptutils.py", line 301, > in RunScript > exec codeObject in __main__.__dict__ > File "C:\...\OpenApp.py", line 7, in ? > WordDoc.SaveAs(FileName='C:\\TextTest2.txt',FileFormat='wdFormatDOSText' > ) File > "d:\python20\win32com\gen_py\00020905-0000-0000-C000-000000000046x0x8x1. > py", line 13959, in SaveAs > return self._oleobj_.InvokeTypes(0x66, LCID, 1, (24, 0), ((16396, 17), > (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), > (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, > 17)),FileName, FileFormat, LockComments, Password, AddToRecentFiles, > WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, > SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter) > com_error: (-2147352571, 'Type mismatch.', None, 2) The file format param is an integer. You can get access to all the constants with: >>> import win32com.client >>> w = win32com.client.Dispatch("Word.Application") >>> w >>> win32com.client.constants.wdFormatDOSText 4 >>> Before that will work you need to find the makepy.py script (Python\win32com\client\makepy.py) and run it. From the list choose the Microsoft Word 9 Type library. Then the above code should work and you can use win32com.client.constants.wdFormatDOSText as the parameter you need. Hope this helps, -J From bos at hack.org Thu Apr 19 22:45:17 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 20 Apr 2001 04:45:17 +0200 Subject: beginner needs help! References: Message-ID: <3ADFA2BD.CF183025@hack.org> D Tang wrote: > Please show me how to do Class Suit and Class FaceValue and class Card, then > I can work out how to do class Deck. Thanks! You're kidding, right? -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From jp at NOSPAMdemonseed.net Thu Apr 26 17:45:46 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Thu, 26 Apr 2001 21:45:46 +0000 Subject: Win32 Extenstion modules How To ??? References: <3AE7ADC9.C82A9C18@yahoo.com> Message-ID: xerox wrote: > I looked at the cook book approach in the documentation > and the link for the compile.py script is broken. > Does anyone have any complete examples allow with how > to set up MS VC++ 6 I would suggest using swig(www.swig.org) to write modules. The documentation for swig explains how to compile with VC++. -jason From wolfson at uchicago.edu Wed Apr 11 19:33:14 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Wed, 11 Apr 2001 18:33:14 -0500 Subject: Chocolate [was Re: Python Books for 2002] References: Message-ID: In article , "Tim Peters" wrote: > [Konrad Hinsen] >> Come to France - chocolatewise this is a highly civilized country. > > [Alex Martelli] >> And not _only_ chocolatewise -- in bread AND wine AND cheese, as well >> as in high-quality chocolate, I consider you guys the only ones on a >> par with Italy... > > [Ben Wolfson] >> What? Everyone knows that India is on par with your rather >> Eurocentric, if I may say so, selections, at least in bread. > > On the chance that these selections aren't so much Eurocentric as > Anglophobic, I'd like to remind everyone that America Leads the World in > both Twinkies and Coke. Although I have to admit that Mexican Coke is > better. But *nobody* beats my homeland's Twinkies! > > who-needs-lindt-when-you've-got-hostess-ly y'rs - tim Venezuala, of course, has everyone beat on the ice cream front: http://4icecream.4anything.com/network-frame/0,1855,4190-10885,00.html It is my dream someday to eat there. -- Barnabas T. Rumjuggler The women come and go, Speaking of the Regis Philbin Show -- Joe Frank From neotaku at free.fr Wed Apr 11 10:23:59 2001 From: neotaku at free.fr (Neotaku) Date: Wed, 11 Apr 2001 14:23:59 GMT Subject: Size File Message-ID: <3OZA6.65$Iz.215152@nnrp6.proxad.net> Hello, Does anybody know how to have the file size (in Ko for exemple) ? Thanks a lot See ya From lloeffler at home.com Sat Apr 21 08:35:13 2001 From: lloeffler at home.com (ll) Date: Sat, 21 Apr 2001 07:35:13 -0500 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: Message-ID: <3AE17E81.FAF82AC0@home.com> Cool! Get rid of the "Can't go there" pop up, and just have it silently not let you move. That's my one gripe. Mark 'Kamikaze' Hughes wrote: > Umbra is a computer role-playing game written in Python, similar to > Alternate Reality and Bard's Tale, with influences from roguelike games > and console RPGs, and set in a universe of Lovecraftian elder gods. > > Umbra features random generation of a huge game world, 3-D graphics > (well, sorta; don't laugh unless you can do better! I can do better, so > I can laugh at my own...), and not a lot else yet. > > > > Right now, I mostly just want feedback on performance and the > interface, if it works on your machine, if I'm completely insane to be > writing a game like this in Python, why there are two Arthurian items in > the town for testing (and there may be a Grail somewhere!), or whatever. > > I'll likely go open source with it once it's a bit further along, but > don't expect that for a while. > > -- > Mark Hughes > "I will tell you things that will make you laugh and uncomfortable and really > fucking angry and that no one else is telling you. What I won't do is bullshit > you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From pmartel at ne.mediaone.net Tue Apr 10 20:28:55 2001 From: pmartel at ne.mediaone.net (Phil Martel) Date: Wed, 11 Apr 2001 00:28:55 GMT Subject: Python Books for 2002 References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> <9av8vs$68g$1@panix3.panix.com> <9avhkm0tjh@drn.newsguy.com> Message-ID: Grant Griffin wrote in message news:9avhkm0tjh at drn.newsguy.com... > In article <9av8vs$68g$1 at panix3.panix.com>, aahz at panix.com says... > > > >In article , > >Douglas Alan wrote: > >>Konrad Hinsen writes: > >>> claird at starbase.neosoft.com (Cameron Laird) writes: > >>>> > In that vein, one significant advantage that Python books have over online docs > is that they have much better indices. (Also, you can take 'em into the potty.) > One word: "laptop" > > =g2 > > _____________________________________________________________________ > > Grant R. Griffin g2 at dspguru.com > Publisher of dspGuru http://www.dspguru.com > Iowegian International Corporation http://www.iowegian.com > Best wishes, --Phil Martel From romberg at smaug.fsl.noaa.gov Fri Apr 13 13:51:45 2001 From: romberg at smaug.fsl.noaa.gov (Mike Romberg) Date: 13 Apr 2001 11:51:45 -0600 Subject: embedding python without dynamically lodaed code in References: Message-ID: >>>>> " " == Samuel D Gendler writes: > I am using libpython.a (2.0, if you must know) in order to gain > access to all of the nifty Python data structures. Currently, > we use ONLY the C api. The application gets distributed to > several thousand servers around the planet, none of which have > any version of python installed, let alone 2.0, and we really > have no interest in doing a python install to several thousand > servers. > When I call PyInitialize() on a machine that does not have > python2.0 installed, it complains like so: > Could not find platform independent libraries Could > not find platform dependent libraries Consider > setting $PYTHONHOME to [:] 'import site' > failed; use -v for traceback > I don't really care that the import fails (assuming that the > PyInitialize still succeeds. I haven't checked the source yet), > but it would be really nice to be able to supress these error > messages, especially if they are having a negative impact on > PyInitialize. > Any suggestions would be much appreciated. Please respond to > my email as well as any public forum that this might arrive at. We do something kinda similar. In our case we are packing all of the python runtime library into a pickled file. So, there is no library under the prefix that python expects. I was able to make this "error" go away by doing the following: 1 - PyInitialize() tries to load a module called 'site'. If this fails then you get the above error. I have found no way to get PyInitialize() to not try to load site (short of modifying the code). 2 - So, we simply add our own site.py somewhere on the PYTHONPATH. If you use the site.py which comes with python then you will still get the failure because it attempts to find some kind of text file which has something like the license in it. This is kinda a pain since this thing is not a python module and can not be pickled or frozen in an embeded app. We use a modified version of the standard python site.py which avoids this problem. You can even freeze site.py into your app (which is what we do). Mike Romberg (romberg at fsl.noaa.gov) From Eugene.Leitl at lrz.uni-muenchen.de Sun Apr 1 16:46:48 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene.Leitl at lrz.uni-muenchen.de) Date: Sun, 01 Apr 2001 22:46:48 +0200 Subject: bzip2 extension exist for python? References: Message-ID: <3AC793B8.49F18709@lrz.uni-muenchen.de> Moshe Zadka wrote: > You shouldn't worry about idiotic things like bzip2, when superior > technologies like lzip (http://lzip.sourceforge.net). I am now working > on a reimplementation of lzip in Python, since I feel the current lzip > code base is too messy to use. Expect updates! If ever I need to order a nuclear strike, I now which date I'll do it on. You'll laugh yourself silly all the way before becoming nuclear ash. From root at rainerdeyke.com Fri Apr 13 10:40:57 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 13 Apr 2001 14:40:57 GMT Subject: list comprehensions whats happening here References: Message-ID: "Carlos Ribeiro" wrote in message news:mailman.987166938.10180.python-list at python.org... > I also lost. I did a small change on your example to better illuminate what > is happening: > > >>> [[i,j] for i in range(3), for j in 'abc'] > [[[0, 1, 2], 'a'], [[0, 1, 2], 'b'], [[0, 1, 2], 'c']] > >>> [[i,j] for i in range(3), for j in 'abc',] > [[[0, 1, 2], 'abc']] > >>> [[i,j] for i in range(3) for j in 'abc'] > [[0, 'a'], [0, 'b'], [0, 'c'], [1, 'a'], [1, 'b'], [1, 'c'], [2, 'a'], [2, > 'b'], [2, 'c']] > > And also, a fourth case for completeness: > > >>> [[i,j] for i in range(3) for j in 'abc',] > [[0, 'abc'], [1, 'abc'], [2, 'abc']] > > So it seems that the idiom > > for i in range(x), > > with the comma right after the for clause, "reduces" the iterated list to > the original list again, and then apply it to all further iterations of the > list comprehension. Now, I don't know if this is by design or by accident; > all I know is that this is something that may be exploited as a useful > idiom. For instance, neither map or zip have this behavior, of applying the > same list to all members of the other. Hint: '[1,2,3],' is a tuple of 1. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From cce at clarkevans.com Tue Apr 3 13:02:54 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 3 Apr 2001 12:02:54 -0500 (EST) Subject: standard deployment for wxPython on Windows? (fwd) Message-ID: On Tue, 3 Apr 2001, Robin Dunn wrote: > Use py2exe or Gordon's Installer to gather the DLLs and PYDs that your app > needs as well as a compressed archive of the python code attached to a > launcher EXE. Then use a standard installer builder such as Inno Setup to > make an installer executable. In it's script you can have it do version > checking, etc. for any system DLLs, everything else (wx*.dll, python*.dll, > etc.) can go into the application directory. Thank you, and I'm actually doing this already with wonderful results. My concern is DLL conflicts, however. Perhaps DLL Hell has gone away in Windows land the last few years, but I doubt it. py2exe has built my distribution so that I'm putting the following files in my install directory: python20.dll, pythoncom20.dll, PyWinTypes20.dll, win32api.pyd, win32trace.pyd, win32ui.pyd, wx22_2.dll, wxc.pyd What happens when 10 of us do this? What happens when we distribute files with the same file(module) name with different patch levels? As I remember, the first program loaded wins... thus if both program A and program B have python20.dll in their directories, the file loaded depends upon which program A or B is loaded first... this is a problem with different patch levels. I was just wondering what our strategy for doing this is? Thank you so much! Clark From aahz at panix.com Mon Apr 2 22:56:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Apr 2001 19:56:03 -0700 Subject: email Message-ID: What is a good algorithm to create this? References: Message-ID: <9abe43$oj4$1@panix6.panix.com> In article , Sheila King wrote: > >(2) For those without Sendmail access, it is possible to access a SMTP >host and send it that way. However, in this case, it seems my script >should generate the Message-IDs, as some SMTP servers will fill this in >but others will not. Say what? I've never seen this. >What is a good way for my script to generate Message-IDs? I know >it usually has something to do with random numbers or strings, but >I thought I would get some advice on how to do this, first, before >blindly proceeding. A description of a general algorithm would be >fine. Pointers to online resources describing such are also very >welcome. A Message-ID generally has the form <"random" garbage>[e-mail address]@domain (That is, some algorithms include the e-mail address and some don't.) Probably the simplest solution is to use a combination of random number plus time.time() (appended to each other as strings). -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "One World, One Web, One Program" - Microsoft Promotional Ad "Ein Volk, Ein Reich, Ein Fuehrer" - Adolf Hitler We don't see a similarity. We really don't. From scarblac at pino.selwerd.nl Mon Apr 23 07:18:23 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 23 Apr 2001 11:18:23 GMT Subject: Ann: ActivePython 2.1 (build 210) References: <3ADF7843.42C686AD@yahoo.com> Message-ID: Stephen wrote in comp.lang.python: > BeOpen was the company that sponsored GvR/et-al for the period when they > released 2.0, so "BeOpen Python" is just 'Python 2.0'. For that > 'distribution', ignore 'BeOpen', and just think, 'Python 2.0'. Its all it > is, with a branded name on it. Now we're up to 2.1, and as far as I am > aware, there are only two "distributions" of it. > > The Official one, which is downloadable from www.python.org, and the > ActiveState one. ActivePython is the Official distribution, with a few bells > and whistles added, I believe. Including all of Mark Hammond's cool Windows stuff in the Windows version. Nice. There is also Pythonware's PY20, which hasn't been updated to 2.1 yet. http://www.secretlabs.com/products/python/index.htm It's Python 2.0, plus extra libraries many of which are developed mainly by Pythonware. A cool feature is that on Windows, it installs in one directory, needing nothing more, no registry settings, do .dlls in the windows directory, etc. This should make it ideal for putting a Python installation on a CDROM or so to be able to run your program independent of whatever the user has installed himself. -- Remco Gerlich From sholden at holdenweb.com Sun Apr 29 19:16:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Apr 2001 23:16:23 GMT Subject: Unbound methods of types References: <9cgu460o46@news2.newsguy.com> Message-ID: "Ben Hutchings" wrote in message news:uwv831f2r.fsf_-_ at roundpoint.com... > "Alex Martelli" writes: > > > # 4. special case, as you note, for string. stuff > > L = map(string.capitalize, l) > > > I feel that it ought to be possible to use type("").capitalize here, > as one could do with a class method. Why is it not possible to get > unbound methods from types? Should it be? > type("") is of type type, not type string. You can apply the str() function to it, but this will give you a method with the string instance bound to it: >>> type("") >>> str(type("")) "" >>> x = str(type("")).upper >>> x() "" >>> x("A banana") Traceback (innermost last): File "", line 1, in ? TypeError: upper requires exactly 0 arguments; 1 given regards Steve From aleaxit at yahoo.com Sat Apr 14 03:20:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Apr 2001 09:20:19 +0200 Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <9b7iaq0dep@news2.newsguy.com> <9b814u$39p$1@slb4.atl.mindspring.net> <3AD648BA.60A7E557@earthlink.net> <3AD7A517.4464B83E@artenumerica.com> <3AD67012.8EE5E90C@earthlink.net> Message-ID: <9b8tmk01tl@news1.newsguy.com> "Ron Stephens" wrote in message news:3AD67012.8EE5E90C at earthlink.net... > Hmm, thanks! But now I worry myself, if "GoTo" was good enough for Donald > Knuth...then why isn't it good enough for me??? And, is it therefore possible that Actually, Donald Knuth, in his brilliant and provocatively titled "Structured Programming with Goto Statements", showed exactly the loop-structure a high-level language would need to let goto's be avoided without any cost (he was very worried about performance, of course): it's called the "N and a half times" loop, and in Python you generally get it with a 'break' statement. Python's break is not as general as, say, Java's, so that you will need a slightly less readable try/except in certain nested-loop cases; however, as, in Python, performance is not the main goal, we normally structure programs into small functions and rarely nest things too deeply -- nesting breeds complication, and good Python style targets simplicity. Exceptions are the missing piece of the puzzle, by the way -- the reason we don't need 'goto' any more for error-handling. Exceptions structure error-handling very effectively. > the whole crusade against "goto" is just an irrational fad??/ Are we persecuting Nah, it's about moving our mental model of computation away from the "machine's innards" levels and towards more abstract ones. If you program in machine language, you will of course use conditional and unconditional jump instructions. Modern languages are a long way from that. The so-called "high-level" languages that Djikstra, Knuth &c were discussing in the '60s and '70s were a mid-way stage, whence the debates about appropriateness of various low-level constructs. "If you want machine language, you know where to find it" (e.g., Knuth's beautiful books:-). Python is not machine language and it would be folly for it to try to mimic such low-level approaches. > ourselves for no good reason??? Will future generations of computer users, in the > year 3000 A.D., look back and view our forswearing of the most usefull "goto" > statement, as equivalent to how we view Islamic folks beating themselves with whips > in a religious frenzy??? I suspect you're confusing Islam with Catholicism here -- flagellants are a typical Catholic phenomenon, while I think typical Islamic 'frenzy' practitioners are the Sufi "whirling dervishes" (a form of 'movement meditation' which has interesting aspects indeed). Alex From volucris at hotmail.com Tue Apr 24 00:50:22 2001 From: volucris at hotmail.com (Volucris) Date: Mon, 23 Apr 2001 23:50:22 -0500 Subject: Example of Function References: <3ae5008b$0$769$6e49188b@news.goldengate.net> Message-ID: <3ae505cd$0$768$6e49188b@news.goldengate.net> I'm making this beautiful code public domain. Feel free to distribute it as you see fit. "Volucris" wrote in message news:3ae5008b$0$769$6e49188b at news.goldengate.net... > > >>> def welcome(): > ... #a funtion with no return value (a procedure) > ... print '***********' > ... print 'Hello World' > ... print '***********' > ... > >>> welcome() > *********** > Hello World > *********** > >>> def double(num): > ... #a function in the traditional sense (has a return value) > ... new_num = num * 2 > ... return new_num > ... > >>> my_num = double(6) > >>> print my_num > 12 > > "alki" wrote in message > news:DV5F6.4485$5t3.336201 at newsread1.prod.itd.earthlink.net... > > Will someone please give me how a function is written and how it's used? > > Thx. > > > > > > From not.this at seebelow.org Mon Apr 2 14:04:01 2001 From: not.this at seebelow.org (Grant Griffin) Date: Mon, 02 Apr 2001 13:04:01 -0500 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <3AC680EE.997108AB@northwestern.edu> <3ac69340_2@news4.newsfeeds.com> Message-ID: <3AC8BF11.1501D4E2@seebelow.org> Dry Ice wrote: > > > I'm not sure why the prejudice against using a language to drive C (or > > C++ or Fortran) modules. [...] > > No prejudice implied. Such a use is entirely reasonable. > > I am evaluating, however, Python-as-development-language, > not as glue for modules which offer the bulk of the > functionality in a project. In that case, rest assured that it is equally useful in that regard. However, since it is an intepreted (not compiled) language, I primarily use it for "off-line" tasks--things where speed doesn't matter much. A typical such use is "text processing" (converting a text file from one form to another form.) For example, I have used Python to analyze/summarize log files from the Iowegian web sites. The essential trade in using Python is that you give up some run-time speed to pick up development-time speed--and that's almost always a good trade. In any application where minimizing run-time speed isn't important, Python's your man. > For years many accused Visual Basic of being a "toy" > language (like "real" coders only use C, dude) because > to do FAST stuff one really had to link to something). > > (Then the OO people called it a toy for other reasons. > Now that it does lots of OO stuff, it's a toy because it's > not cross-platform. Truth is, I see some Visual Basic > everywhere I look. Particularly, with considerable > amusement, when I'm accused of prejudice against > RAD languages as glue.) I'm not sure Visual Basic was ever a "toy" as evidenced by the fact that I've seen professional-quality applications built using it. However, my own experience has been that as an application becomes more and more complex, BASIC's syntax becomes increasingly tiresome and difficult to work around. At some point, it becomes more trouble than it's worth. In comparision, Python's syntax only becomes more of a pleasure with use. It's like a comfortable shoe that fits your foot better each time you wear it (yet never wears thin. ) a-day-without-Python-is-like-a-day-_with_-BASIC--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 orcmid at email.com Wed Apr 11 01:20:23 2001 From: orcmid at email.com (Dennis E. Hamilton) Date: Tue, 10 Apr 2001 22:20:23 -0700 Subject: OT - Closing Off An Open-Source Product In-Reply-To: <20010410210735.I45521-100000@open-systems.net> Message-ID: Good point, Chris. This comes up in discussion of public-domain code and also open-source licenses that allow closed-source derivatives. You are absolutely correct. 1. There is no way, under copyright law in the United States, that someone making a closed-source version of a public-domain or open-source software is able to interfere with the public-domain or open-source original or any existing copyright (or public-domain status) on the material. 1.1 As far as I can tell, there is a misunderstanding of what a copyright claim applies to. 1.2 When I put a copyright claim on a literary work (i.e., software), it applies to that portion of the work that is (1) my original expression and (2) copyrightable subject matter. It does not apply to anything in the work that is not that. In addition, if a portion of the work is subject to the copyright of another, I am in violation of that copyright unless I obtain a license from the original copyright holder that permits any of the actions that are the exclusive right of that copyright holder. (The U.S. Copyright Office and web site provides lots of information on what copyrightable subject-matter is and how this all works. There description is pretty understandable.) 1.3 In particular, if I take a public domain work, and the only change I make to it is to add my copyright notice, I have obtained a copyright on absolutely nothing. And if I charge someone with infringement, one thing they can do is simply produce the public-domain work and demonstrate that it pre-existed the earliest demonstrable distribution of my "version." Similarly, if I make a MIDI arrangement of a popular song and publish it as my work, there is certainly an original component contributed by me, and I am also definitely in violation of the copyright on the elements of the original song which I used without permission. (There are special rules for music and phonorecordings, but this aspect is consistent with the copyright on literary works.) 1.4 (Because copyrights are not patents, there are even more interesting cases. -- If I demonstrate that I completely independently created a work, having no knowledge of your work that it resembles, that is not an infringement either. And the ideas in a copyrighted expression are not themselves subject to the copyright.) 2. It has been pointed out to me that there is a way that an open source *developer* might become "tainted." If someone makes an allowable or licensed derivative that has improvements to the original work, and does not elect to use the original license, the developer needs to be extremely careful about learning about those and about incorporating any of them back into the original open-source version. It seems to me you are entirely correct. There is no way to pre-empt the public-domain or open-source status of a work of software by wrapping the covered work in copyright notices and proprietary notices. -- Dennis -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Chris Watson Sent: Tuesday, April 10, 2001 19:17 To: Mitchell Baker Cc: David Ascher; tchur at optushome.com.au; mertz at gnosis.cx; python-list at python.org; DickH at ActiveState.com Subject: Re: Komodo in violation of Mozilla Public License? > This allows us to make sure that MPL code is always open and not > privatized. At the same time, it allows those building products to You know I usually let this slip because I get sick of license wars. But can you explain to me how the MPL or any other public license prevents the closing of source covered with that license? If I release foo.c version 1.0 under a MPL. And company A comes along and takes a copy of the source of foo.c 1.0 and closes it off and refuses to release work they did on it. Can you tell me what magical creature came along and removed foo.c version 1.0 under the MPL off the face of the globe? The same version that company A borrowed/used/stole/whatever. I mean maybe im missing something. Maybe I dont have enough conspiracy theory blood in me. But how can you close a copy of source that is given to the public? Who or what comes along and with divine intervention removes the public version from the planet? ============================================================================ = -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================ = WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================ = irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 -- http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Thu Apr 19 04:15:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Apr 2001 10:15:16 +0200 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9blhdb$619$1@nntp9.atl.mindspring.net> <9bm47r$qo2$1@slb5.atl.mindspring.net> Message-ID: <9bm6qi02ups@news1.newsguy.com> "Andrew Dalke" wrote in message news:9bm47r$qo2$1 at slb5.atl.mindspring.net... [snip] > >(Is there a way in Python of finding local > >variables by name on the Python stack so that a procedure can get and > >set variables in the caller's environment? If so, you could do it, > >but it would be pretty ugly.) > > Yes and no. Python deliberately makes it hard. You need > to raise an exception and look up the stack frames. There In 2.1, sys._getframe (to "be used for internal and specialized purposes only") provides a somewhat handier alternative to the classic raise-and-look-up idiom. But I don't think this has changed what you can actually _do_ once you've got the caller's frame object -- "see, but not touch", more or less. Consider, for example: import sys if hasattr(sys, '_getframe'): def callerlocals(): return sys._getframe(2).f_locals else: def callerlocals(): try: raise 'catch me' except: return sys.exc_traceback.tb_frame.f_back.f_back.f_locals any = 'pass' def f(): x = 23 print x g(x=24) exec any print x g(y=37) exec any print x,y def g(**kws): print callerlocals() callerlocals().update(kws) print callerlocals() f() In both 2.0 and 2.1, this outputs: 23 {'x': 23} {'x': 23} 23 {'x': 23} {'x': 23, 'y': 37} 23 37 I.e., the "exec 'pass'" trick has allowed the addition of a new binding for y, but not the rebinding of x anyway. If you comment out the exec statements, then f's attempt to access y fails: 23 {'x': 23} {'x': 23} 23 {'x': 23} {'x': 23, 'y': 37} 23 Traceback (most recent call last): File "caller.py", line 28, in ? f() File "caller.py", line 20, in f print x,y NameError: global name 'y' is not defined The dictionary object has allowed the update (sort of: it has allowed the addition of y->37, but not the rebinding of x->23 to x->24), but the code is not looking at that dictionary to fetch 'y' -- the optimizer, absent an exec statement, having decided that 'y' is a global, not a local, variable, it has generated bytecode to fetch a global specifically. Alex From costas at meezon.com Tue Apr 10 14:28:16 2001 From: costas at meezon.com (costas at meezon.com) Date: Tue, 10 Apr 2001 18:28:16 GMT Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> Message-ID: <3ad34fb4.1636258213@News.CIS.DFN.DE> On Mon, 9 Apr 2001 22:24:43 -0600, "bowman" wrote: >> An IDE that tries to accomodate multiple languages is a poor IDE. > >In general, my idea of an IDE is gVim. However, to give the devil his due, >the MS IDE can accomodate several languages while providing a common set of >tools. Part of the reason I stick to gVim is the seamless support for just >about any language I choose to work with. True, it is just an editor and not >a IDE, but if I go to the trouble of learning my way around an IDE, I >certainly would want it to support all the languages I customarily use. Can gVim do the following? a) Have autocompletion / intellisense in the editor. b) Have a built in debugger c) A console to execute ad-hoc commands. Where can i check it out? From kens at sightreader.com Tue Apr 17 21:47:25 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 17 Apr 2001 18:47:25 -0700 Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> Message-ID: <002d01c0c7a9$852cf390$04090a0a@upcast.com> From: "Luke" says: > Python is an ugly language... > > Why should you have to name stuff with __*__ to get some pseudo hiding? > Or for any reason for that matter... Actually __*__ is used for special method overloads such as __init__(), __add__, __str__. __* gets you "pseudo hiding". This is an improvement over the 'private' keyword because you know from the name that you are looking at a private rather than referring back to a declaration. Actually the underscore concept exists specifically because python doesn't have declarations (except when it does). Pseudo hiding is an improvement over true hiding since it is equally effective in preventing accidental abuse, but doesn't actually limit the programmers options. It's often extremely useful to be able to break all the rules temporarily while debugging, for example. Java and C++ programmers are encouraged to use naming conventions like pm_blob to indicate that the variable is a private member. Of course every programmer follows different conventions in this regard, so that technique is not reliable. > Why do you always have to access class data members as self.* What a > pain in the ass, and anti-OO. In a Java class, you don't constantly > have to write this.feature = this.feature2 ++; if this.a > this.b etc... > How tedious that would be, and is with Python's self. > Is it procedural or OO? Some of the std lib seems to think it is OO, > and the other half seems to think it is procedural... I mean sometimes > you create a new object with new, other times you just get a reference > by calling a function. Even Java is more object oriented than this--you > *only* write classes, and the standard library is *only* made of > objects. Python gives too many ways of doing it. > > Furthermore, the syntax and features of the language keep changing with > every release. For God's sake! I regret ever buying programming python > and learning python... I feel like they're already out of date. Almost everything in "Programming Python" and "Learning Python" still applies in python 2.2. > There are lots of nice things about python like its built in [] and {} > and I really like the indention, but I'm about to go back to Java, a > language I know very well and feel comfortable in. I'm not slamming it, > it has lots of potential, but there are so many stupid illogical > features in Python that just ruin the whole experience. I think "stupid" and "illogical" are synonyms which can be defined here as "different from something else I am familiar with." From mal at lemburg.com Sun Apr 22 14:08:08 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sun, 22 Apr 2001 20:08:08 +0200 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) References: <190420011747549837%jwbaxter@olympus.net> <200420010824387666%jwbaxter@olympus.net> Message-ID: <3AE31E08.13B57B67@lemburg.com> "John W. Baxter" wrote: > > In article , M.-A. > Lemburg wrote: > > > "John W. Baxter" wrote: > > > > > > In article , M.-A. > > > Lemburg wrote: > > > > > > > I'm sure this proof of > > > > concept will raise a few more questions regarding the > > > > usefulness of switching to rationals for literals like > > > > 1.123. > > > > > > I might be more tempted to create a Rational containing 1.123 by writing > > > Rational(1123, 1000). (Not to mention the opportunities for > > > obfuscation: Rational(2246, 2000) being just a non-obscure one. > > > > > > And Paul makes a good case for Rational("1.123") I think. > > > > Well, Moshe's plan is to have 1.123 result in a Rational(1123, 1000) > > being created (instead of a Python float). The extension should > > make playing with this idea a whole lot easier. > > I was trying to post a (mild) dissent from that plan. It produces a > change in the value produced by an unchanged bit of code, namely 1.123, > since Rational (1123,1000) isn't equal in value to the present meaning > of 1.123. Had Guido started off with Rational as the result of writing > 1.123, I would like that, but that's not where we are [and this > sentence isn't meant to criticize Guido's choice]. True. The usual procedure for these kind of incompabtible changes can be found in PEP 5 PEP 236 (see http://python.sourceforge.net): If this change should go into the core, then you'll have at least 24 months to adapt to it before a Python uses the new feature as default (and then only if you upgrade to the latest version ;-). -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From nomad*** at ***freemail.absa.co.za Mon Apr 2 04:55:59 2001 From: nomad*** at ***freemail.absa.co.za (nomad) Date: Mon, 02 Apr 2001 08:55:59 GMT Subject: Couple of simple questions References: <3ac4854a.1170697@news.is.co.za> Message-ID: <3ac83d9d.888125@news.is.co.za> Thanks for the replies about the type sizes - much appreciated and now fully working. As for the PythonPath question, I have managed to answer it for myself. If anybody is in a similar situation, all I had to do is ad a subkey to the pythonpath registry key (HKLM\software\python\pythoncore\2.0\pythonpath), and add the custom path to the default string value. Cheers. On Fri, 30 Mar 2001 13:15:16 GMT, nomad***@***freemail.absa.co.za (nomad) wrote: >Howzit, > >I have a couple of (hopefully) simple questions: > >Does anybody know what size python variabel types are? >Eg. how many bytes is and integer? What about a long? I have >searched through the docs but I cant find a reference to the byte >sizes. The reason is that I'm battling with struct.py and some >complex C++ structs. Any help here would greatly appreciated > >Also on and win32 platform, how do I persistently add a custom path to >the pythonpath? I have tried adding it to the pytho path in the >registry, but then when I view the class browser in IDLE, only the >default paths are there. I can do a `sys.path.append.....' each time, >but I would prefer to have my custom module path there automatically. > >Cheers and TIA. From kragen at dnaco.net Mon Apr 2 22:27:36 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Tue, 03 Apr 2001 02:27:36 GMT Subject: list tuple vs Re: References: <62Mx6.1152$p5.4531@news1.rivrw1.nsw.optushome.com.au> <3AC93108.356CBFB6@cosc.canterbury.ac.nz> Message-ID: In article <3AC93108.356CBFB6 at cosc.canterbury.ac.nz>, Greg Ewing wrote: >William Tanksley wrote: >> Always doing things backwards, Forth programmers are. > >Ah, that explains it -- Yoda grew up in a household >of Forth programmers! > >Oops, sorry, I mean household programmers Forth of in Yoda >up grew. household programmers Forth of of Yoda up grew in, think I. This silly is but. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From benjamin.geer at btinternet.com Wed Apr 25 21:40:46 2001 From: benjamin.geer at btinternet.com (Benjamin Geer) Date: Thu, 26 Apr 2001 02:40:46 +0100 Subject: Extending Python with C++ singleton pattern using boost python lib References: <3ae3d7f5.3475467@news.t-online.de> <9c0tdd02sa7@news2.newsguy.com> Message-ID: <9c7uic$7vb$1@uranium.btinternet.com> In article <9c0tdd02sa7 at news2.newsguy.com>, "Alex Martelli" wrote: > It's hard to avoid that: in general, it's VERY hard work to > wrap/expose/handle non-canonical C++ objects (ones that can't be > default-constructed, destructed, copied, assigned). Not just in/to > Python or in/to Boost Python specifically: non canonical objects are Bad > News in any substantial C++ system. It seems to me that this might be true if you pass objects by value and/or reference, but where's the difficulty if you only pass pointers? A singleton can surely make itself available exactly as described in Gamma et. al, via a static method that returns a pointer to the instance, with very little effort required, either in the singleton or in its clients. Copying and assigning pointers is considerably easier than writing copy constructors and copy assignment methods... If you want polymorphism, you're forced to use pointers or references, but references have to refer to something that lives either on the heap or on the stack. If it lives on the stack, you have all the problems of copy constructors, etc. If it lives on the heap, you have to use pointers anyway... If you use garbage collection, there's no way to avoid pointers. Finally, if you're using SWIG to wrap your Python extension, providing pointers to your objects is the the most straighforward approach, unless you want to write a lot of glue code by hand. So why not make all your copy constructors private, use pointers for everything, write singleton classes the way the Gang of Four suggest, and make a singleton available in a Python module? -- Benjamin Geer http://www.btinternet.com/~benjamin.geer From max at alcyone.com Wed Apr 18 11:16:46 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 18 Apr 2001 08:16:46 -0700 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9bhriq$b12$1@panix6.panix.com> <3ADCF9D4.CD1500E5@alcyone.com> <9bj9fp$f64$1@panix2.panix.com> Message-ID: <3ADDAFDE.D586F357@alcyone.com> Aahz Maruch wrote: > I don't understand why you're using "except"; that's the whole point > of > the corollary. The corollary is that the thread is done. The _convention_ to the corollary is that self-invocations don't count. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Education is a state-controlled manufactory of echoes. \__/ Norman Douglas Crank Dot Net / http://www.crank.net/ Cranks, crackpots, kooks, & loons on the Net. From sholden at holdenweb.com Wed Apr 11 23:33:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Apr 2001 23:33:08 -0400 Subject: OT - Closing Off An Open-Source Product References: <20010411183525.P754-100000@open-systems.net> <3AD4F4FB.3D13F205@ActiveState.com> Message-ID: <0l9B6.147943$m04.6141182@e420r-atl1.usenetserver.com> "Chris Gonnerman" wrote in message news:mailman.987041357.11249.python-list at python.org... > ----- Original Message ----- > From: "Paul Prescod" > Subject: Re: OT - Closing Off An Open-Source Product > [ ... ] > > Either you believe in IP or you don't. Either you believe in the freedom > > to copy whatever you want, whenever you want, or you don't. So I don't > > see how further argument would resolve anything. > > How about if you both do and don't believe in IP? In principle, the idea > that a programmer (author, artist, etc.) should be given primary > money-making > control over his or her work is quite reasonable (to me anyway). However, > IP (copyright and patent) is *used* as a Big Club by bigger guys to *smack* > little guys, rather than as a protection for the little guys against the > bigger ones. > > For that reason I am very suspicious of anyone who even *mentions* IP to me > (unless I know they are talking about Internet Protocol :-). GPL is a > direct affront to those people specifically. > Well, that's capitalism for you. The recent modifications to US copyright law, and various poorly-thought-out decisions on software patents, are all (IMHO) clearly the result of big business interests lobbying to protect their livelihoods in whatever way they can. Organizations will, of course, tend to do this as a matter of survival. Traditional large commercial organizations tend not to understand the open source rationale, although IBM and H-P are maybe a sign of interesting trends. > The Internet has turned IP on it's ear. How do you "protect" software or > other published works in a world where rapid communication makes your > "enemies" far more powerful than you can ever hope to be? Free software is > protected by various Free Software and/or Open Source licenses; I submit > that the "hacker ethic" is the real protection here anyway, because if > a "big guy" steals a major piece of, oh, say, Apache and incorporates it > in a closed source program, it's darn hard to prove. > Say what you like about Richard Stallman, he has lived to see his ideas lead to a culture (albeit a minority one) in which IP rights in software *are* more open that they were. Whether you like the GPL or not, it was a direct precursor of the general open source movement, and RMS deserves credit. I think it's entirely fair I can't just wrap the whole GNU/Linux bundle up as "Stevix" without making my code public. Although it would be nice if RMS occasionally suggested we use "Linux/GNU" rather than "GNU/Linux", it's a fair point that Linux would likely not exist without the GPL software tools from GNU. > In summary (yes, you can breathe now) I think (fear? hope?) that IP in the > current sense is doomed. Napster may go down in flames, but OpenNap will > likely live forever... I think that says it all. > Of course, the music industry has found itself at the sharp end of this issue. In order to justify its existence it has to try to convince the courts its IP should be paramount. But if music industrialists think that musicians haven't clearly seen much of the industry is technically unnecessary, they are crazy. The bell is tolling, whether Napster's rather dodgy business model survives or not. The music companies only have IP rights because the musicians sign them away to get access to the distribution channels. The traditional channels are slowly becoming redundant. the consumer can deal directly with a band's web site, download and burn their own CDs. Maybe the real music industry will be web sites in twenty years. The industry liked to call its product "software" because of the cool associations with the hipsterish computing milieu. As they slowly catch on to the idea that open source and electronic distribution can apply to their "software" just as much as it can to the traditional kinds, they may wish they had studied the analogy more closely, and prepared better for the coming evolution. just-wishing-this-would-help-feed-the-starving-poor-ly y'rs - steve From timo at alum.mit.edu Tue Apr 24 23:35:06 2001 From: timo at alum.mit.edu (Timothy O'Malley) Date: Tue, 24 Apr 2001 23:35:06 -0400 Subject: timeoutsocket.py problem References: Message-ID: <240420012335065889%timo@alum.mit.edu> hola. In article , Ben Wolfson wrote: > I'm using timeoutsocket.py with SocketServer.py ... > However, in the Handler class' setup() method, when I do: > > print self.request > > the file descriptor is -1 and, of course, I can't use the socket. Hmm... I've been testing with SimpleHTTPServer, which is built on the SocketServer class, and I have not been having problems. Are you sure it's the same socket? How could the file descriptor become -1 if it is the same socket? I guess I'm saying that I don't have any ideas... I'm truly surprised that something would come in and close your socket. From craigf at ilid.com.au Wed Apr 18 00:29:17 2001 From: craigf at ilid.com.au (Craig Findlay) Date: Wed, 18 Apr 2001 14:29:17 +1000 Subject: Problem with asyncore and Python2.0 References: <3ADC1318.A01728AB@stroeder.com> Message-ID: Michael, I just tried your suggestion and after a bit of trial and error (more error than trial :) it works. I believe the problem was related to stderr. When I redirected it to a file in my server script, the server works perfectly when it is detached from the console. Thanks again for your assistance, Craig From news at myNOSPAM.org Wed Apr 18 15:39:01 2001 From: news at myNOSPAM.org (Stephen) Date: Wed, 18 Apr 2001 12:39:01 -0700 Subject: Idiom gone, or did it really ever exist? () is () References: Message-ID: <3addefe1$1_2@goliath.newsfeeds.com> I _really_ just don't get why you're going through all the trouble. IMHO the below looks cleaner, and works, and can't possibly be considered evil. :) def fun(*args): if args == ((),): print 'We passed an empty tuple' elif args == (): print 'We didn't pass any arguments' else: print 'We passed the following arguments:' % args --Stephen (replace 'NOSPAM' with 'seraph' to respond in email) "Mike C. Fletcher" wrote in message news:mailman.987608307.19862.python-list at python.org... > Yup, I mentioned that in the original article ;) (same with the *args, > **namedargs approaches). I actually switched to using this: > > class NULLARGUMENT: pass > > Then I use the class as the default value for is-checking. > Which I'm told is evil :) . > Mike > > -----Original Message----- > From: Alex Martelli [mailto:aleaxit at yahoo.com] > Sent: Wednesday, April 18, 2001 07:01 > To: python-list at python.org > Subject: Re: Idiom gone, or did it really ever exist? () is () > ... > Why not > > _NULL = [] > > and then > def x(y=_NULL): > if y is _NULL: print "no argument" > > i.e., your original trick, but with a _mutable_ object. This > way it should keep working forever, I believe. > ... > > -----= 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 fredrik at pythonware.com Wed Apr 18 02:21:24 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 18 Apr 2001 06:21:24 GMT Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: Douglas Alan wrote: > I'll tell you who I've listened to quite carefully: Guido, who has a lot > of good ideas, and the designers of Lisp (eg, Dave Moon, John McArthy, > Guy Steele, all of whom I've met personally) so when did any of these guys last tell you that they know more about programming languages and programming language design than you do or ever will? Cheers /F From stephen_purcell at yahoo.com Wed Apr 18 02:37:14 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 18 Apr 2001 08:37:14 +0200 Subject: LOOP wisdom found (was: do...until wisdom found)... In-Reply-To: ; from Peek@LVCM.comNOSPAM on Tue, Apr 17, 2001 at 10:45:15PM -0700 References: <3ADC6F1F.DE1A2FB1@mentor.com> <3ADCA101.6059336E@mentor.com> <0c3D6.5161$sk3.1518317@newsb.telia.net> Message-ID: <20010418083714.D727@freedom.puma-ag.com> Ken Peek wrote: > I too, have it on good authority that Python 3000 will address the > eternal (and infernal) "looping controversy" . As to just > what that "somehow" will be, we will just have to wait and see > what Guido will bless. Yep, guess we can suspend this thread until the Py3K release schedule begins, then. (1) > (MY money is on simplicity!) Mine too, but on a simpler simplicity than yours. (see (1) above) -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From alq666 at yahoo.com Tue Apr 17 15:28:32 2001 From: alq666 at yahoo.com (Alexis Lę-Quôc) Date: Tue, 17 Apr 2001 12:28:32 -0700 (PDT) Subject: return values from scripts In-Reply-To: <3ADC8257.CC51FE1B@ornl.gov> Message-ID: <20010417192832.7381.qmail@web4003.mail.yahoo.com> If you do execfile ('second.py', locals ()) and have second.py look like: do_some_stuff () globals ()["x"]= 7 then the enclosing .py will have a local variable named "x", whose value is 7. -- Alexis Le-Quoc --- Mike Burnett wrote: > While running a script in the python interpreter, I need to run a second > script from the first, passing some values to the second. I know I can > do this with: execfile('second.py',locals()). Is there any way to get > back into the original script one value (a return status) from the > second script? Is there any way to get several parameter values back? > > Mike Burnett > burnettmn at ornl.gov > > -- > http://mail.python.org/mailman/listinfo/python-list ===== -- Alexis Le-Quoc New York __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From sholden at holdenweb.com Mon Apr 2 12:53:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 2 Apr 2001 12:53:13 -0400 Subject: list vs tuple References: <62Mx6.1152$p5.4531@news1.rivrw1.nsw.optushome.com.au> Message-ID: "deadmeat" wrote in message news:62Mx6.1152$p5.4531 at news1.rivrw1.nsw.optushome.com.au... [Tim Peters]> > You could help by writing a "Python for Pascalers" intro blurb. > > Um.. er.. I think I left um.. something on. Bye. > and thereby hangs the tale. A troll from beginning to end. there's-none-so-blind-as-those-who-will-not-see-ly y'rs - steve From bbhaydon at bigpond.com Sun Apr 8 10:43:43 2001 From: bbhaydon at bigpond.com (Brett Haydon) Date: Mon, 9 Apr 2001 00:43:43 +1000 Subject: Driving word processors other than MS Message-ID: Hi there, I have YATS (Yet Another Templating System) which I use to build plain text and MS Word reports (and html) and then convert to PDF to view on a web site. I'm seeing lots of action on open source word processors but does anyone know of one scriptable from Python as a replacement for MS word (so I can run it on Linux). I see that staroffice has a C++ api. Perhaps some talented person has written a wrapper. Brett From wtanksle at dolphin.openprojects.net Wed Apr 11 15:10:22 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 11 Apr 2001 19:10:22 GMT Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> <3ad34fb4.1636258213@News.CIS.DFN.DE> Message-ID: On Tue, 10 Apr 2001 18:28:16 GMT, costas at meezon.com wrote: >Can gVim do the following? >a) Have autocompletion / intellisense in the editor. Yes. >b) Have a built in debugger I think someone's done that, but I've never used it or even looked for it. If nobody's done it yet, and you want it, talk for a while and find other people who share your want (it can't be a rare desire), and work together on an extension. vim can be scripted in Python, Perl, and several other languages. >c) A console to execute ad-hoc commands. Yes. >Where can i check it out? http://www.vim.org -- -William "Billy" Tanksley From db3l at fitlinxx.com Mon Apr 9 18:48:46 2001 From: db3l at fitlinxx.com (David Bolen) Date: 09 Apr 2001 18:48:46 -0400 Subject: An Example Python/Windows App with Source? References: <3ad2329b_1@news4.newsfeeds.com> Message-ID: "Dry Ice" writes: > Anybody know of a small-to-moderate app > with source code which might serve as a > learning framework? Try downloading wxPython (http://www.wxpython.org) and checking out its demo - it shows off just about all the various pieces of the UI, and you can snarf any portion of the demo code for use in your own project. It's layered on top of wxWindows, but wxWindows makes use of the native API as much as possible, so it looks just like a true Win32 API application. -- -- 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 rturpin at do.not.use Tue Apr 3 14:29:30 2001 From: rturpin at do.not.use (Russell Turpin) Date: Tue, 03 Apr 2001 13:29:30 -0500 Subject: Didn't I see HTML embedded Python? (Not Zope?) Message-ID: <3ACA168A.13850B09@do.not.use> I seem to remember seeing something recently about support for HTML embedded Python. Not Zope, but something simpler. But I could be confused -- that corner of my cranium seems to have cobwebs. Can anyone give me a pointer? Thanks! Russell From akuchlin at mems-exchange.org Wed Apr 18 12:51:40 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Apr 2001 12:51:40 -0400 Subject: If you want X, you know where to find it References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bk26r029fc@news1.newsguy.com> Message-ID: <3d4rvmf8wz.fsf_-_@ute.cnri.reston.va.us> "Alex Martelli" writes: > "Douglas Alan" wrote in message > > I find the quote from Alex above to be utterly abusive, and he was > > How so? I assert that you give the appearance of not _getting_ > the Python world-view of _simplicity_ (be it for lack of trying > or lack of ability to do so, that's a secondary issue). The unstated For what it's worth, and at the risk of prolonging this uninteresting sub-branch of an otherwise interesting thread, I thought Alex's posting was an erudite and well-written flame. I didn't find it abusive, but was certainly startled at Alex's vehemence (especially with the 'monkeys typing' quote, which is now in the quotation file). The idea of hygenic macros may or may not be a good one, but Mr. Alan's case is certainly better presented than the average new-feature posting, and I'd give him some leeway just for that alone. (Plus we Kate Bush fans stick together.) I agree with Tim that an explicit proposal is worth reams of list messages, and look forward to a PEP. --amk From aleaxit at yahoo.com Thu Apr 26 12:09:24 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Apr 2001 18:09:24 +0200 Subject: Adding optional 'explicit' declaration? References: <9c63ps$i4h$1@upsn21.u-psud.fr> Message-ID: <9c9h7m02enc@news2.newsguy.com> "Remco Gerlich" wrote in message news:slrn9eg5uc.34r.scarblac at pino.selwerd.nl... [snip] > Does anyone have any numbers on this? People make this claim all the time, > but in practice my typos are always caught at compile time or immediate > testing already. I believe bugs like this are really rare. I think the recent reports of PyChecker runs on the Python libraries do offer one data point on that, but I don't recall the numbers. > And similar to Alex's excellent rant, I hope people aren't trying to make > Python the one language to use for everything... Amen (& thanks for the 'excellent'!-). Alex From sholden at holdenweb.com Thu Apr 12 08:57:01 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Apr 2001 08:57:01 -0400 Subject: =?iso-8859-1?Q?Re:_R=E9f._:_Re:_Help_for_urllib_error_:_'no_host_given'?= References: Message-ID: wrote in message news:mailman.987070578.13268.python-list at python.org... > > Hi Steve, > > Thank you for your investigation. It helps me understand that my python code is > correct. I did not forget any character, while the name of the url comes from > regex extract of the page returned by the server itself. But you're right on the > fact that the name has something wrong, when used in this way. > I tested the web site "manually", that is pasting the entire name of the web > site directly into my Netscape. Same result : "Netscape can't locate the server. > No host specified" (this message translated from French) > > Therefore the question is : how does it come that a Javascript function using > 'document.location="http://blablabla"' is able to redirect my browser to the > said web site, and not 'urllib.urlopen("http://blablabla")' ? > > More, I do not understand the error message. Does it come from the server which > denies the request *or* from the dns which cannot translate the name into an > address *or* from Netscape which seems not to receive/understand the host name ? > Essentially it comes from the httplib code, which examines the URL, breaks it up into various components, and does not find a host component. This is why I wondered whether you had missed a slash out: "http/hostname" raises that exact exception. I would suggest you use urllib to read the URLs. The httplib is mostly support code for that library. regards Steve From timothyrandolph at yahoo.com Wed Apr 4 01:29:40 2001 From: timothyrandolph at yahoo.com (Tim Randolph) Date: 04 Apr 2001 05:29:40 GMT Subject: Python Books for 2002 Message-ID: <9aebg4$cf4@dispatch.concentric.net> Now that there are so many Python books out or in the pipeline it is more pleasant than discouraging to do some gap analysis. Here are some books that I am looking forward to looking forward to: *Thinking in Python* by Bruce Eckel. He says it will happen sooner or later. (http://www.mindview.net/Python/ThinkingInPython.html ) *Design Patterns Python Companion* by Alex Martelli. I know he is working on the Nutshell book, but Alex seems to have enough spare letters, words, and sentences for two books. Besides, he has practically volunteered for it: http://groups.yahoo.com/group/python-list/message/128505 *Mastering Algorithms with Python* by Tim Peters. The catch here is that it really should be in epistolatory form. This is of course to give Tim two or three hundred more opportunities to come up with funny closing "ly yr's" lines. dare-to-dream-or-dream-to-dare-ly yr's, Tim From tuttledon at hotmail.com Thu Apr 19 17:19:52 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 19 Apr 2001 21:19:52 GMT Subject: Create/Edit Win32 Shortcuts? References: <3ADDF0DB.B6E7D7A1@bigfoot.de> Message-ID: [Don Tuttle] > > > > I can't believe that Python doesn't have the ability to create/edit Win32 > > shortcuts (.lnk files). But after an hour of searching the archives and my > > books I can't find anything at all. Would someone point me in the right > > direction? >> [Gerhard H?ring] > > http://www.faqts.com/knowledge_base/view.phtml/aid/4475/fid/538 if you > can use the Python COM support > > If you are not able to use Python COM (as might be the case in a > installer written in Python itself), I can send you some code I have > written half a year ago. It's an extension module to create shortcuts, > it's working but unfinished. Sorry for the slow reply. I'd love to see you code! Even better, I'd love to see you polish it and then submit it for inclusion in the core Windows distribution. Shortcuts are so ubiquitous in Windows that a simple way to work with them really should be a part of the OS module. I suspect the lack of demand for this feature is simply the respective lack of NT admins currently using Python. I'm also expecting this to change dramatically over the next few years. (I was doing remote admin work via telnet when I posted my question.) FYI: Your link lead to the example "link.py". I found Mark has an updated version of it in the 2.0 distribution. Thanks, Don From egbert at bork.demon.nl Sun Apr 1 06:51:43 2001 From: egbert at bork.demon.nl (Egbert Bouwman) Date: Sun, 1 Apr 2001 12:51:43 +0200 Subject: list vs tuple In-Reply-To: ; from qrczak@knm.org.pl on Sat, Mar 31, 2001 at 09:48:07PM +0000 References: Message-ID: <20010401125142.A988@bork.demon.nl> Sat, 31 Mar 2001 21:24:33 GMT, deadmeat pisze: > >>> a = 1 > >>> b = a > >>> a = 2 > >>> b > 1 > > >>> a = [1,2,3] > >>> b = a > >>> a[0] = 0 > >>> b > [0, 2, 3] > Coming from Fortran and PL/I, I too have to be careful not to fall in the reference trap. My way of explaining what happens above is as follows, but it may not be correct. In a = 2 you give the instruction to let a refer to something else. In a[0] = 0 you give the instruction to let a[0] refer to something else, but you don't change the reference of a itself: to the list as a whole. The name of a list is a reference to a list of references. With a = ... you change the top-reference, and with a[0] = ... you only change one of the nested references. So with a=2 you let a and b refer to different things, and with a[0]=0 you let a and b still refer to the same but changed thing. It looks all very consistent, once you remember what = means. Changing that meaning may produce a minor culture shock. Something like that happened to me when for the first time in my life I saw the statement a = a + 1 egbert From moshez at zadka.site.co.il Thu Apr 12 02:47:02 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Thu, 12 Apr 2001 09:47:02 +0300 Subject: Komodo in violation of Mozilla Public License? In-Reply-To: References: , Message-ID: On Wed, 11 Apr 2001, "Fredrik Lundh" wrote: > David Ascher wrote > > Likable, probably -- but also, very possibly, out of business. We > > (ActiveState) are in the fairly unusual position of trying to be both > > valued community members and a successful business at the same > > time. > > not that unusual in the python universe, though -- cannot think of > any Python tools provider that doesn't also do open source stuff... > > Secret Labs, the WingIDE guys, theKompany, eGenix... (etc) Completely agreeing with /F, and just adding Digital Creations to the list. Of course, that doesn't detract from what David was saying -- sadly, it is still not considered the standard way to do business; most companies seem to find it redundant to contribute anything back, and I am certainly happy that Active State goes against the flow.... Now, if only the .deb's were as proffessional looking as the windows installer ;-) -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From jsight at pair.com Sun Apr 15 15:12:10 2001 From: jsight at pair.com (Jesse D. Sightler) Date: Sun, 15 Apr 2001 15:12:10 -0400 Subject: Python & Web Hosting References: <2C4F06C72B8A1DF9.BDA53FE36BC8569E.EA36F170478BB36E@lp.airnews.net> Message-ID: <3AD9F28A.6090600@pair.com> http://www.pair.com/ Their rates are quite reasonable, the service is very reliable, and they offer full Python 2.0 support. The only thing lacking is Zope. :( -------- Jess http://www.biddin.com/ Martin de Vore wrote: > Hi: > > Does anyone know of a list or Web site that covers commercial Web hosting > companies support of Python? > I am thinking about switching hosts and I have seen a few that support > Python 1.5 but I'd be more interested in one that could handle 2 or 2.1 > (after Tuesday). > > Thanks > > Martin L. de Vore > mddevore at neosoft.com From mda at idatar.com Mon Apr 2 23:14:30 2001 From: mda at idatar.com (David Allen) Date: Tue, 03 Apr 2001 03:14:30 GMT Subject: Simple looping question... References: Message-ID: In article , "Ken Seehof" wrote: >>>> f = open(r'd:\qp\var\publish\index.html') z = f.readlines() >>>> type(z) > > > It would appear that readlines() returns a list. Therefore the entire file > is read in to create that list before returning. On the other hand, I have > written a generator class that does what you are saying. In order for > readlines() to be smart, it would have to return a generator instead of a > list. I didn't mean in that case. It's clear that foo = file.readlines() creates an array and puts it in foo. I was talking about in the case of: for line in file.readlines(): print line There, python has two choices. It could either create an entire array holding the entire file, and loop through assigning each member of the array to line each go through. Or, it could not allocate an array at all, and just treat that statement as the equivalent of a long series of file.readline() statements. What I meant was that I think this is the way python handles it when file.readlines() is the set of things you're talking about in a for loop. I don't have code proof for that - it's just that I've run a program that uses that type of a construct: for line in file.readlines(): # Do something with line in several programs that get fed 80MB data files, and I've never noticed python's memory usage encompassing 80 MB, which is what you would expect if the interpreter actually allocated an array to keep the whole file in memory. -- David Allen http://opop.nols.com/ ---------------------------------------- Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard From db3l at fitlinxx.com Mon Apr 23 10:08:44 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Apr 2001 10:08:44 -0400 Subject: Can't run "Python-2.1.exe" under NT... References: Message-ID: "Tim Peters" writes: > [Robin Dunn, reports on a Win2K install failure] (...) > > (I was also kinda surprisead that the installer was a 16-bit app...) > > Beggars can't be choosers, alas -- this is the 5.0a version of the Wise > installer product, current maybe 6 years ago. They wrote it long before > Win2K or ME were even ideas . I believe Mark Hammond talked them into > letting Python use it for free, but he moved on from this role, and I haven't > had the bandwidth to pursue a more modern alternative. With past releases (I haven't tried the 2.1 pre-compiled installer yet) I've had the installer generate an error (on my NT4sp4) system about the 16-bit subsystem on startup, but skipping past it let things run fine. I've seen similar problems in other older 16-bit installation packages, so at least for me it isn't specific to Python. If anyone does look at an alternate installer (is the current Wise configuration in the CVS tree?), I'd suggest going for InnoSetup. Easy to configure, actively maintained, works nicely, and free. -- -- 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 jgriffith at hbs.edu Thu Apr 5 10:43:31 2001 From: jgriffith at hbs.edu (Jeff Griffith) Date: Thu, 05 Apr 2001 10:43:31 -0400 Subject: Python objects in an SQL Database Message-ID: <4.3.2.7.2.20010405103153.01abad70@pop.hbs.edu> While scanning Freshmeat I came across this http://freshmeat.net/projects/myobject.pm/ ---- description ---- MyObject is a PERL module that stores objects in a MySQL database. It should be inherited by a class wishing to persist its objects in the database. --- / description ---- After scanning the python newsgroup archive I came up with no previous discussion about this, a Google search also turned up no public code. I'm familiar with the ZODB and I've heard rumors about a tighter integration of Zope (python) with the Berkeley DB but am curious why something like this isn't more popular? Mapping instance attributes to a database sounds somewhat useful... any ideas? -Jeff Griffith From wiener at rap.ucar.edu Wed Apr 18 23:20:50 2001 From: wiener at rap.ucar.edu (Gerry Wiener) Date: 18 Apr 2001 21:20:50 -0600 Subject: Problem building 2.1 on Debian Linux 2.2.13/2.2.17 In-Reply-To: Harry George's message of 18 Apr 2001 16:56:28 -0700 Message-ID: <651yqpy3ql.fsf@virga.rap.ucar.edu> make test was successful on my build where PYTHONHOME was unset prior to doing ./configure and make. --Gerry From aleaxit at yahoo.com Sun Apr 8 15:47:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Apr 2001 21:47:20 +0200 Subject: Driving word processors other than MS References: Message-ID: <9aqf8b013i1@news1.newsguy.com> "Brett Haydon" wrote in message news:Pz_z6.11825$45.67392 at newsfeeds.bigpond.com... > Hi there, > > I have YATS (Yet Another Templating System) which I use to build > plain text and MS Word reports (and html) and then convert to PDF > to view on a web site. > > I'm seeing lots of action on open source word processors but does > anyone know of one scriptable from Python as a replacement for > MS word (so I can run it on Linux). > > I see that staroffice has a C++ api. Perhaps some talented person has > written a wrapper. I've thought about it, but done nothing about it, yet -- maybe I will once I get my new machine, which will be a Linux box. However, I noticed StarOffice also has a _Java_ api -- I suspect that using Jython to drive *that* might be simpler than writing a wrapper to allow using CPython, even with Boost... since any Java api IS already its own 'wrapper' for Jython's purposes...!-) Alex From nailed at videotron.ca Fri Apr 13 12:08:59 2001 From: nailed at videotron.ca (Alain Toussaint) Date: Fri, 13 Apr 2001 12:08:59 -0400 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> <3ad47a9b$0$47989$e2e8da3@nntp.cts.com> <3AD5C5BA.4365643F@bt.com> <3AD6EF5F.C1CAEC5F@bt.com> Message-ID: >> or documentation. Its likely the support is still in IE >> for Mac as Microsoft builds almost everything on top of COM. > > You learn something every day :-) > I didn';t know that but it then raises the question of how MS > managed the Solaris port of IE? dunno how they did it but you might be interrested with the dcom port to linux: http://www.softwareag.com/entirex/download/free_download.htm Alain From news at myNOSPAM.org Sun Apr 22 12:51:14 2001 From: news at myNOSPAM.org (Stephen) Date: Sun, 22 Apr 2001 16:51:14 GMT Subject: Submitting Bugs at Sourceforge References: Message-ID: <6_DE6.191762$LO3.30348403@typhoon.we.rr.com> Ack! No! *runs, really fast* I'm not familar enough with the Python sources for that. :) --S :) (replace 'NOSPAM' with 'seraph' to respond in email) "Courageous" wrote in message news:ukr5etk97qeapvroammh676nq3i4kdnifv at 4ax.com... > > > Now, my question: I submitted 4 bug-reports on the various minor fixes > >that needed to be done, and have 4 left that I havn't sent in yet. Just in > >general, would it be better for me to send in a batch of those little fixes, > >or submit each one as a seperate bug report? For the most part, they're > >changing various #defines which at the moment assume Win32 = Visual C++. > > The *correct* thing would be for the Gods of Python to give you some kind > of CVS access, although I don't know who they trust with this these days. :) > > C// > From john at everfile.com Wed Apr 25 07:56:03 2001 From: john at everfile.com (John S. Yates, Jr) Date: Wed, 25 Apr 2001 11:56:03 GMT Subject: Integer micro-benchmarks [Smalltalk Multi-Precision Numerics vis-a-vis Highly Optimized Fixed Size Integer C++ Numerics] References: <9c4sjf$qo$1@serv1.iunet.it> Message-ID: On Tue, 24 Apr 2001 19:32:32 -0400 (EDT), Daniel Berlin wrote: >Errr, this is pretty basic PRE and loop hoisting. > >In other words, it's done by anyone taking a college compiler optimization >course. >--Dan Two cents from an erstwhile professional compiler-writer. Loop hoisting is indeed well known and widely practiced (especially if all that is being hoisted is side-effect free expression evaluation operations). PRE (Partial Redundancy Elimination) is much less widely known or implemented. In fact I would be VERY suprised if MS has implemented it since on average it has relatively little payoff and tends to increase code size. My guess is that most what you are seeing is synergistic interaction between function inlining and symbolic evalu- ation (a generalization of constant propagation). But the most important thing that I believe Dan overlooked is the core message from Fred Brook's "Mythical Man-Month" namely the difference between a demonstration of working code (enough to get an A in the course) and a QA-ed product. In a mature compiler with an enormous customer-base one is VERY careful about introducing new optimizations. They MUST be correct and robust. The number of corner cases that have to be verified can be enormous. I personally am reasonably impressed by MS's optimizer. /john -- John Yates, CTO EverFile 119 Braintree St Allston, MA 02134 617 782-2833 x102 From aleaxit at yahoo.com Sat Apr 14 15:14:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Apr 2001 21:14:49 +0200 Subject: How to effectively use exception References: Message-ID: <9ba7gi01n5b@news1.newsguy.com> "Steven Haryanto" wrote in message news:mailman.987246861.25847.python-list at python.org... [snip] > First, should we use exceptions whenever possible? For example, No. You can build many other control structures out of exeptions, but just because you can it is not a good reason to do so. break, return, etc, are better when suitable, *because* they're less general and more specific. > should a smallish function that do some testing return 1/0 to > indicate success/failure or should it raise ValueError if the > test fails? Is the try-except-else style more Pythonic/ > recommended than the if-else-then style? If not, what are the > considerations to balance the two? If it is an error for the check to fail, and you want to make sure client-code won't accidentally forget to check a return value, then THAT is a good reason to have the function raise an exception if needed. If the ONLY purpose of the function is the 'testing', such forgetfulness is not to be feared -- for example, see builtin functions such as isinstance, callable, hasattr: they all return 1 or 0, since they are called for the sole purpose of checking -- their boolean results make for more natural conjunction, e.g. with operators such as or, and, not, within an if or elif. > Second, when do we create our own specific Exception classes, > and when do we just use the existing standard Exception (I use > ValueError in a lot of my methods & functions, accompanied by > the specific message string. So far I haven't faced with the > need to create a custom Exception class). except clauses have an easy time catching specific exception classes; if you raise your own specific class (which may derive from ValueError, or whatever), you may ease life for authors of client code (including yourself:-). You _need_ to have your own classes if they must carry special data fields, but that is a pretty rare issue. > Lastly, can someone recommend some readings on this matter? On the MSDN, last year, there was an excellent series on error handling in C and C++ (on the "Exceptional C++" column); I think you can still find them. They're *NOT* fully applicable to Python, alas, but at least they give you good grounding (if you have a strong C/C++ background) in a different language's style of exception use -- reasoning by difference from it may be easier than trying to reason things out in a vacuum. Alex From barry at digicool.com Wed Apr 11 02:55:55 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 11 Apr 2001 02:55:55 -0400 Subject: Komodo in violation of Mozilla Public License? (fwd) References: <15059.61850.892872.479032@anthem.wooz.org> Message-ID: <15059.65531.321024.49877@anthem.wooz.org> >>>>> "DB" == Daniel Berlin writes: DB> Also, before someone tries to use gcc, libgcc, glibc, DB> libstdc++, etc as an example of something about the GPL, that DB> these programs and libraries have special exceptions included DB> to make things like linking/compiling software with gcc, etc, DB> not require that program to be GPL'd. Good point, thanks. -Barry From ykingma at accessforall.nl Fri Apr 13 05:36:50 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Fri, 13 Apr 2001 10:36:50 +0100 Subject: A sorted map type. References: <3AD5CB10.FDBF9AF4@hack.org> Message-ID: <3AD6C8AD.22CEECE3@accessforall.nl> Antoon, Rikard, Rikard Bosnjakovic wrote: > > apardon at trout.vub.ac.be wrote: > > > What I need is a map type that allow you to visit > > all members in key order. Also the possibility > > to look for the next in line after a search > > would be nice. Is there a module that already > > implements such a maptype or do I have to do > > it myself? > > We had this discussion 2-3 weeks ago. Check some digests. I missed this discussion. But as a jython user I tried to subclass java.lang.TreeMap, which is a sorted map. In Jython this worked like a charm: (of the top of my head, the real version is a reboot away) import java class pythonComparator(java.util.Comparator): def compare(self, k1, k2): return cmp(k1, k2) def equals(self, comp): return self is comp class TreeMap(java.util.TreeMap): def __init__(self): java.util.TreeMap.__init__(pythonComparator) # replace java object ordering by jython cmp(). def __getitem__(self, k): return self.get(k) def __setitem__(self, k, v): self.put(k, v) def __delitem__(self, k): self.remove(k) def keys(self): return self.keySet() # no need to override values() tm = TreeMap() tm[4] = 'four' tm[1] = 'one' tm[3] = 'three' tm[2] = 'two' print tm.values() Output is: ['one', 'two', 'three', 'four'] I wish I knew why the java Set returned by tm.values() behaves like a python list, but that doesn't really matter: it works. (I would be faster to implement the pythonComparator directly in java.) Adding a print statement to the compare() method easily verifies the tree like behaviour at insertions and deletions. So, you can have a sorted map in Jython, provided that your Java has Collections (java 1.2 and later iirc.) For CPython this means that you might implement a C treemap as a native module, I don't know whether this has been done. Kind regards, Ype Kingma (cross posted to comp.lang.python and jython-users at lists.sourceforge.net) -- email at xs4all.nl From fdrake at acm.org Fri Apr 20 11:34:41 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 20 Apr 2001 11:34:41 -0400 (EDT) Subject: [Python-Dev] Class Methods In-Reply-To: <200104201626.LAA06384@cj20424-a.reston1.va.home.com> References: <027401c0c9ab$5e3c88f0$e000a8c0@thomasnotebook> <200104201626.LAA06384@cj20424-a.reston1.va.home.com> Message-ID: <15072.22289.218618.462955@cj42289-a.reston1.va.home.com> Guido van Rossum writes: > __getattr__?), and I have no idea how to do this without dropping the > idea that x.spam(...) is C.spam(x, ...). So maybe that's the > solution? Can that be dropped and still allow subclasses to extend a method offered by the base class? I think making the two different would break an enormous amount of code. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From fig at monitor.net Wed Apr 18 19:18:03 2001 From: fig at monitor.net (Stephen R. Figgins) Date: Wed, 18 Apr 2001 16:18:03 -0700 Subject: Confused about nested scoping Message-ID: <3ADE20AB.9CAD6932@monitor.net> I seem to be misunderstanding what nested scopes do. >From AMK's summary of 2.1 changes: Put simply, when a given variable name is not assigned a value within a function (by an assignment, or the def, class, or import statements), references to the variable will be looked up in the local namespace of the enclosing scope. Here is what I tried: from __future__ import nested_scopes def printspam(): print "spam has value %s" % (spam) def scopetest(): spam = 'bacon' printspam() spam = 'eggs' printspam() scopetest() I figured without nested scopes I would get spam has value eggs spam has value eggs But I thought with nested scopes I would get spam has value eggs spam has value bacon Because the second printspam's enclosing scope would be that of scopetest in which I had reassigned spam. But I still get eggs with my spam. What am I misunderstanding? -Stephen From jacobus at geo.co.za Thu Apr 19 04:12:21 2001 From: jacobus at geo.co.za (Jacobus van der Merwe) Date: Thu, 19 Apr 2001 10:12:21 +0200 Subject: Writing 'intercepted' e-mail message to a mailbox Message-ID: <3ADE9DE5.871DC6E9@geo.co.za> Hi, I am redirecting all email sent user1 at myhost.co.za to a python script, which extracts certain data from the e-mail and writes it to file. But now I still want user1 to receive this e-mail. I read the incoming mail using mailMessage = rfc822.Message(sys.stdin) How can I get the message from my variable mailMessage into user1's mailbox?? I can not find a method that does it. Thanks in advance, Jacobus From emile at fenx.com Wed Apr 25 08:33:25 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 25 Apr 2001 05:33:25 -0700 Subject: big text strings References: Message-ID: <9c6gdl$c35p9$1@ID-11957.news.dfncis.de> Sure. One way is to pass your big string to a text formatting function that breaks the line up as it outputs it. -- Emile van Sebille emile at fenx.com --------- "Brandon J. Van Every" wrote in message news:TyxF6.3796$G04.437886 at newsread2.prod.itd.earthlink.net... > I want to have big text strings in my python scripts, whole paragraphs in > length. I do not want to have to insert \ characters at every line. Is > this possible? > > The application is a text adventure game. I want the big paragraph text > descriptions to be close to the program logic that governs them, I don't > want to stick them off in some special file or database somewhere. That > might be a good idea for localization, but we don't know that the game will > ever be translated into another language, and it'll be a pain in the ass for > development to have the text separate. > > -- > Cheers, www.3DProgrammer.com > Brandon Van Every Seattle, WA > > For plot and pace, writers use words; game designers use numbers. > Anything understood over time has plot and pace. > > > From rdsteph at earthlink.net Sun Apr 15 23:23:19 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 16 Apr 2001 03:23:19 GMT Subject: .py to HTML: indentation problems Message-ID: <3AD916E0.EB9C748F@earthlink.net> A stupid little problem, irritating nonetheless. I have polished my program and now am attempting to load it on my website as an HTML file. Using Netscape Composer, I cut the code from pythonWin, paste it into Netscape Composer, and then upload the HTML file from Composer to my website. Problem is that the lines sometimes wrap in a wierd way that destroys the indentation of the code. Has anyone else found a simple way to avoid this mess? I am finding it difficult to re-indent properly over an internet connection without the advantage of an IDE. It would sure be nice to avoid the problem up front. Ron Stephens From cce at clarkevans.com Sun Apr 29 21:16:34 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Sun, 29 Apr 2001 20:16:34 -0500 Subject: Revised Python job survey Message-ID: <20010429201634.B21972@doublegemini.com> | I'm not even interested in statistically accurate info. All | I want to be able to say is "I got 10 apparently well-qualified | people on comp.lang.python say they would consider moving to LA | for the right money." I'd also put in your survey: (a) How long did it take you to learn Python, i.e. to become relatively proficient. (b) What language they came from (Visual Basic, Java, etc) (c) If they like Python better or not. (d) If they think they are more productive with Python (e) If they think their software is more reliable with Python. This way you can tell your management, well I only got 20 respondants who said they'd move to LA to code in Python. HOWEVER, on average, they said it took them 2 months to get up-to-speed and, on average, they said they feel more productive and are producing more reliable software! THEREFORE, even if we have to hire Visual Basic/Java programmers, it won't be all that much effort to have them learn Python. Just some thoughts, Clark ----- End forwarded message ----- From craigf at ilid.com.au Tue Apr 17 02:07:25 2001 From: craigf at ilid.com.au (Craig Findlay) Date: Tue, 17 Apr 2001 16:07:25 +1000 Subject: Problem with asyncore and Python2.0 Message-ID: I have just installed Python2.0 on a box running OpenBSD2.8 Now a simple asyncore based server that was running happily on the box under Python 1.6, dies whenever a client tries to connect. (The server runs a proprietary protocol which is probably not important here) Now for the strange part. If I start the server from the console or from a remote SSH session, while I am logged on the server runs fine and clients can connect to it successfully. However, If I then log off the console or the SSH session, the next time a client tries to connect, the process dies silently. The same thing happens if I start the server from the rc.local script when the box boots. I have tried putting in lots of print and syslog statements in the script to try to find the point at which this happens but I can't which leads me to suspect that it is the underlying sockets layer. The script does not seem to be throwing an exception. I cannot understand why the script works while I am logged on to the console or via SSH. Any ideas? Craig From nessus at mit.edu Wed Apr 4 20:00:01 2001 From: nessus at mit.edu (Douglas Alan) Date: 04 Apr 2001 20:00:01 -0400 Subject: A couple garbage collector questions References: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> <9ac030$h95$1@news1.wdf.sap-ag.de> <3dd7asv6he.fsf@ute.cnri.reston.va.us> Message-ID: Dan Sugalski writes: > No. On many processors it's a load, increment, store operation, and > very much not atomic. Ah. The last time I programmed in assembly was on a PDP-10. And before that it was a PDP-11. It's all the fault of these pesky new-fangle RISC CPU's they use these days! Thanks for the info. |>oug From zzizz_ at notmail.com Wed Apr 25 22:46:00 2001 From: zzizz_ at notmail.com (zzzzz) Date: Thu, 26 Apr 2001 12:46:00 +1000 Subject: win32com_garbage collection, another QTN References: <91p6et4qisil67p7sue7topfolhlp356v2@4ax.com> <3AE38FE5.8000100@ActiveState.com> Message-ID: On Mon, 23 Apr 2001 02:12:56 GMT, Mark Hammond wrote: >zzzzz wrote: >... > >> My problem is excel, and getting it to close properly: >> >> >> state=win32com.client.Dispatch("Excel.application") The following command returns a Workbooks object that I don't assign to anything: >> state.Workbooks.Open("G:\\MH_State_Flow_7.xls") If I do: wbook=state.Workbooks.Open("G:\\MH_State_Flow_7.xls") and then: state,wbook=None,None then this works & I don't need to call the Quit() command. > > There is a good chance you still have a COM reference left alive. >Check what pythoncom._GetInterfaceCount() returns, and if non-zero you >have another reference - probably the document or worksheet object. > >Mark. Regards, zzzzz. --------------------- From aleaxit at yahoo.com Wed Apr 25 12:59:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Apr 2001 18:59:42 +0200 Subject: Floating point (in)accuracy? References: <3ae6eb73.802364759@news.vr.in-berlin.de> Message-ID: <9c6vmq02kec@news2.newsguy.com> "Dinu Gherman" wrote in message news:3ae6eb73.802364759 at news.vr.in-berlin.de... > Apparently the python mailiing lists on python.org are blocked, so let > me ask here. Is there any good reason for the following behaviour to > be different on Python 1.5.2 and 2.0? [snip] > >>> 3.14 > 3.14 [snip] > >>> 3.14 > 3.1400000000000001 Yes: repr(x) where x is a float used to HIDE some digits (trying to provide a 'prettier' look), but that violates the mission of repr, which is to give you as much info as it can. Now, repr(x) "tells the truth"; use str(x) to get prettier (false:-) output. The interpreter uses repr. You can change that in Python 2.1, by setting sys.displayhook to your favourite "display this result to sys.stdout" function, but that was not in 2.0 yet. Alex From alwagner at tcac.net Tue Apr 24 22:48:31 2001 From: alwagner at tcac.net (Albert Wagner) Date: Tue, 24 Apr 2001 21:48:31 -0500 Subject: MySQSLdb: just guessing Message-ID: I can find no docs for MySQLdb, so I am just guessing how to get going. I got this far by trial and error: >>> import _mysql >>> from _mysql import * >>> connection = connect('myhostname', 'mypassword') >>> It apparently makes some kind of connection 'cause it gave no error, but it gives an attribute error on >>> connection.cursor() I need to know the args to connect(). The above is all it will accept without error, but there is no dsn. It didn't like dsn and password as keywords, per the db2-api. Anything at all will be really helpful. Thanks ahead for any advice. From gfoltz at gsf.com Sat Apr 7 20:44:05 2001 From: gfoltz at gsf.com (Greg Foltz) Date: 08 Apr 2001 00:44:05 GMT Subject: adding text to jpeg images using Python/PIL/??? Message-ID: <9aoc8l$cf5@dispatch.concentric.net> I'm trying to add a name and copyright to jpeg's before publishing on the web. Seems I remember seeing this question and answer sometime in the past but cannot find the answer now without deja.news. Any and all suggestions solicited, perhaps with a code snippet. I've googled and searched most of the usual Python sites without coming up with a good approach. Thanks beforehand, Greg From kragen at dnaco.net Tue Apr 3 03:11:14 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Tue, 03 Apr 2001 07:11:14 GMT Subject: CGI script to count downloads References: <3AC95ECE.B8F5E93E@cosc.canterbury.ac.nz> Message-ID: In article <3AC95ECE.B8F5E93E at cosc.canterbury.ac.nz>, Greg Ewing wrote: >So, my question is, can I put anything in the >headers of the response to give the browser a >hint as to what name the file should be saved >under? > >Or is there a better way of going about this >whole counting business? Perhaps you could make the URL end with download.py/foo/bar/baz.tar.gz instead of using a query; then just use PATH_INFO instead of a form value. Is that possible? > #!/usr/local/cosc/bin/python > print "Content-Type: compressed/gzip" I don't think that's correct ;) > form = cgi.FieldStorage() > path = form["file"].value > f = open(path) Yow. file=/etc/passwd, anyone? At least this isn't Perl, where file=|sh would work :) Doesn't appear you're actually counting yet. Be sure to flock when you do :) -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From aleaxit at yahoo.com Thu Apr 5 06:03:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Apr 2001 12:03:52 +0200 Subject: PEP 245 References: Message-ID: <9ahfu902d1o@news2.newsguy.com> "Remco Gerlich" wrote in message news:slrn9co78i.70t.scarblac at pino.selwerd.nl... [snip] > Common practice in Python is to do not even that, but just use the object as > given. If it doesn't have the methods then there will be an exception. > Heavy unit testing is necessary anyway. Sure. But interfaces happen a lot BETWEEN units -- thus, they yield less readily than one might hope for to the (excellent, indispensable, splendid) practice of heavy unit-testing. "Just go ahead and try to use it, possibly catch resulting exceptions" is good in many cases, but it causes problems when state is being modified by certain methods... and then another method is missing, so the exception leaves state in some in-between, inconsistent state. "rolling back" such partial, incomplete state alterations is generally not an easy task. Being able to ask the object about conformance to the *whole* protocol you need BEFORE you start altering state sure helps! It's no complete solution, because the object itself may be buggy -- it may BELIEVE it is conformant to protocol XYZ, but be wrong about it -- but THAT is what unit-testing on the object should be catching... that it IS correctly implementing those protocols (contracts, interfaces, concepts) it says it's implementing. There is an unfortunately-large body of experience on this problem, which is due to the frequent violation, by the designers of COM interfaces, of the important "interface segregation principle" (see, for example, http://www.objectmentor.com/publications/isp.pdf). When an interface is too fat, an object that purports to 'implement' it may, in fact, often implement just a _subset_; client-code attempts to call methods that ARE in the interface, but that the object does not fully implement, will raise some kind of exception. An interface with 20 methods has over a million possible subsets -- even considering each method as only "entirely implemented" or "not implemented at all". It's not really sensible to expect client code to cope with every subset, or even be tested for all of them; checking may well not be feasible, as it's often the case that there is no idempotent way to verify that a method is in fact, not just 'present', but implemented in a way that can be tried without undesired state-altering side effects. Having +slim+, usable interfaces _and a way to query for conformance to them (without, of course, altering state if conformance is not present)_ is a far better situation. "One method at a time" is just very rarely the optimal "granularity" (just as having methods come in chunks of 20 or so is quite rarely what one actually _wants_!). This can be worked around (as evidenced by the huge amount of working COM client-code that manages to more-or-less survive a world full of fat, partially implemented interfaces:-), but it's a real waste of programming effort to have to do it again and again and again and... Alex From grey at despair.rpglink.com Tue Apr 17 03:35:53 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 17 Apr 2001 07:35:53 -0000 Subject: do...until wisdom found... References: Message-ID: On Mon, 16 Apr 2001 23:02:21 -0700, Ken Peek wrote: >This is roughly equivalent to the code: Then why not just not do the do and make the language simpler? >Can anybody think of a good name for a "Python-like" new language for small >embedded processors? >Let's see-- "tinyPython"? nope-- has "Python" in it-- might make Guido mad. >Hmmm, maybe "Dragon"? Probably used by someone else? Hmmm... maybe ??? >Any ideas? IDon'tKnowWhatPythonIsAndJustMadeItMoreComplexForNoGoodReason? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From kothari.m at lycos.com Thu Apr 19 14:58:42 2001 From: kothari.m at lycos.com (Manoj B Kothari) Date: Thu, 19 Apr 2001 11:58:42 -0700 Subject: Connection to Database through python program Message-ID: Hello, I am a new bee to python.I want to make database connection from a python program.I am using gadfly database.Can anyone help me out with connection to gadfly. Thanks in advance. regards Manoj B Kothari 602-426-1205/602-426-0807(off) 9.30am-5.00pm.(MST) 602-323-9914/602-323-9527(Res) after 8.00pm.(MST) Get 250 color business cards for FREE! http://businesscards.lycos.com/vp/fastpath/ From aleaxit at yahoo.com Thu Apr 19 04:19:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Apr 2001 10:19:18 +0200 Subject: Jython, IBM's Java, and Red Hat 7.1 References: <7toftt7l9j.fsf@localhost.localdomain> Message-ID: <9bm72502v2l@news1.newsguy.com> "Paul F. Kunz" wrote in message news:7toftt7l9j.fsf at localhost.localdomain... > I have a problem with the combination of Jython 2.0,IBM's Java 1.3 > and Red Hat Linux 7.1. I run Jython with option `-i' that invokes > a Python script which imports Java package classes as Python > modules. All that happens is that two Java processes consume all the > CPU time (50% each). The same scripts with Sun's JDK1.3, same > Jython, and Red Hat 6.x or Windows NT/2000 works fine. > > Does anybody have a clue? Any known problems with Jython and > IBM's Java? Might it be a Red Hat 7.x problem? http://www.jython.org/platform.html specifically mentions IBM Java as being Jython compatible for Linux, so this problem would not appear to be a known one... Alex From XQ.Xia at ccsr.cam.ac.uk Thu Apr 19 07:36:34 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Thu, 19 Apr 2001 12:36:34 +0100 Subject: Where to install BLT on window NT? Message-ID: <3ADECDC2.E5B06353@ccsr.cam.ac.uk> I have a python20 on my window NT. I downloaded a BLT for window and Pmw. I install the BLT in c:\python20\ and c:\python20\tcl. But when I try Pmw I find the BLT doesn't work at all. Who can show me where to install the BLT? Thanks a lot Xia XQ From footech at get2net.dk Fri Apr 20 05:55:19 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 20 Apr 2001 11:55:19 +0200 Subject: Any Neural Net code in Python? I want to filter out spam email References: <9bm3pv02qq6@news1.newsguy.com> Message-ID: > > The thesis is available at: > http://agents.www.media.mit.edu/groups/agents/publications/sheth-thesis.pdf > > There about the author here (but not much): > http://www.dfki.de/~allen/People/Stu/Sheth/ > > > Mikkel Rasmussen > Damn that Outlook! It can't even do proper grammar ;-) Mikkel From Pieter_Claerhout at CreoScitex.com Sun Apr 22 05:20:09 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Sun, 22 Apr 2001 11:20:09 +0200 Subject: A list of Python users? Message-ID: <2B1262E83448D211AE4B00A0C9D61B0301DDDD78@msgeuro1.177.115.149.IN-ADDR.ARPA> I would like to add CreoScitex to the list of Python users... A lot of our prepress workflow product Prinergy is written in Python. Also the Dutch companies Oratrix and LettError should be on the list. Oratrix wrote GRiNS, a SMIL authoring system, for a big part in Python. LettError, use Python all the time to automate their work... Take a look at: http://www.creoscitex.com/ http://www.oratrix.com/ http://www.letterror.com/ Cheers, Pieter Pieter Claerhout - Application Support CreoScitex Europe - www.creoscitex.com -----Original Message----- From: Ron Stephens [mailto:rdsteph at earthlink.net] Sent: Sunday, April 22, 2001 5:56 AM To: python-list at python.org Subject: Re: A list of Python users? A very partial list: Yahoo, Google, Disney, Industrial Light and Magic, Red Hat, Microsoft, Infoseek, NASA, Lawrence Livermore Labs, many game software houses (primarily for scripting games), etc etc etc etc etc (just from memory) oh, and most important af all, Digital Creations for Zope!!!! Daniel Klein wrote: > Is there a published list of Python users? People ask me all the time 'Who uses > it?". > > I've search Google Groups and found a few names mentioned but I'm looking for > more. > > Thanks, > Daniel Klein > Portland OR -- http://mail.python.org/mailman/listinfo/python-list From tim at worthy.demon.co.uk Mon Apr 23 04:40:33 2001 From: tim at worthy.demon.co.uk (Tim Howarth) Date: Mon, 23 Apr 2001 09:40:33 +0100 Subject: NTFS permissions References: <1e232f6f4a%tim@worthy.demon.co.uk> <3AE360DA.5030806@ActiveState.com> Message-ID: <8b4a16f4a%tim@worthy.demon.co.uk> In message <3AE360DA.5030806 at ActiveState.com> Mark Hammond wrote: > Tim Howarth wrote: > > results in an error message "the data area passed to a system call is > > too small" but the permissions are copied. > sigh*. This is a trivial bug in win32security. The C++ code is > missing a simple "!" :(. Ahhhh ! When trying something new like this you always tend to think it's your own fault ! My problem with directories not accepting security descriptors was not quite correct. When using; acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser) sd.SetSecurityDescriptorDacl(1, acl, 0) win32security.SetFileSecurity('g:\\TestACL\\pot',win32security. DACL_SECURITY_INFORMATION,sd) The access is set for the directory but doesn't appear in the Explorer permissions viewer (Win 2000) because AFAICT the permissions will not be inherited by subdirectories or files (with these switched on the access 'ticks' appear). So next problem how do I turn them on programmatically ? I'm assuming I need to access the ACE headers and set bits for OBJECT_INHERIT_ACE CONTAINER_INHERIT_ACE If so, can I do this with the current win32/Python ? acl.AddAccessAllowedAce seems to have no reference to headers, does win32security just use a default header? Or have I completely misunderstood. (I can't believe that ther are thousands of Python users and no one is doing this kind of NT admin.) > As a workaround, simply ignore the exception. All future builds will > have this fixed. Thanks. -- ___ |im ---- ARM Powered ---- From aleaxit at yahoo.com Tue Apr 24 12:10:02 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Apr 2001 18:10:02 +0200 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) References: Message-ID: <9c48go020gv@news1.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.988071995.19962.python-list at python.org... [snip] > 12+2/3 - not ambiguous and valid if the above is valid (integer + rational), > I would probably want the compiler to start rolling literals together at > this point... otherwise there would be 2 runtime calculations going on > (division to form rational, then addition of integer). There are two runtime calculations in many "complex literals" (because there's actually no complex literal...:-) today, e.g -2.3+4.5j (because sign is also not part of the numeric literal...). Alex From aahz at panix.com Sun Apr 22 11:57:18 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Apr 2001 08:57:18 -0700 Subject: Threads on Win32 with Blocking calls References: Message-ID: <9buv0u$oqj$1@panix3.panix.com> In article , Campbell wrote: > >I've read in the thread documentation that not all blocking io functions >work well under threads. The C libs I am interfacing to are >threadworthy, but I need a bunch of threads that all block without >blocking each other. Everything seems to point to this being the >problem.. does anyone have tips or help, workaround or solution? The classic example is socket.gethostbyname() which on many platforms does not have a threadsafe, reentrant version. If you're talking about a library that you're interfacing to, and you want to release the global interpreter lock to remove blocking, you'll need to write a Python extension layer that uses the macros Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS to wrap your library. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Beware of companies that claim to be like a family. They might not be lying." --Jill Lundquist From timr at probo.com Mon Apr 2 00:19:05 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 01 Apr 2001 21:19:05 -0700 Subject: CGI Unicode issue? Message-ID: This post is off-topic for this newsgroup, but there is a fair amount of CGI experience here, and I couldn't come up with a precisely appropriate newsgroup. I have a web site controlled entirely by Python scripts, using HTMLgen.py and cgi.py as my primary tools. The site is used by a large number of ordinary users, and a couple of administrators with more full access. This week, one of the administrators started triggering assertion errors in my scripts in response to a form method=POST. As I dump the names and values in my cgi.FieldStorage object, I see the following: id+AAA- = ( FieldStorage('id+AAA-', None, 'p01682+AAA-') username+AAA- = ( FieldStorage('username+AAA-', ... subject+AAA-- = ( FieldStorage('subject+AAA--', ... and so on. The key problem here is the "+AAA-" strings, which should not be there. I look for the required "id" key in the cgi.FieldStorage object, and since "id+AAA-" does not match, this triggers the assertion. Later members have e-mail bodies; all special characters in those bodies have been replaced by these codes ($ => +ACU-, & => +ACY-, etc.). After a fair amount of web digging, I've learned that these codes are base64-encoded Unicode-16 characters. AAA is a base64 encoding for a 16-bit null. ACU is base64 encoding for 0024, the Unicode-16 dollar sign. The RFC on UTF-7 encoding mentions this +XXX- encoding. However, I don't understand why I see these. There is nothing in the CGI environment variables that indicates I should be expecting any kind of unusual encoding. There are no characters in the query string outside the ASCII 128. This user happens to be running Internet Explorer 5.5, and running the same query from IE 5.0 produces correct results. My fear is that this is an IE 5.5 bug, but I can find no mention of anything similar in a web search. Later keys in cgi.FieldStorage get even stranger; the +AAA- is followed by leftover characters from earlier strings. You can already see that in the "subject" member above; the second "-" is leftover from the "username" member. This gets worse in later members. The last member, "Button", is stored as: Button+AAA-AAA-ffice Space Available+AAA-yyy = (... For the time being, I have modified cgi.py to look for the +AAA- string in the name part of the query string; if found, I do a re.search for all strings matching "+A..-" and pass them through binascii.a2b_base64, then terminate the string at the first +AAA-. This seems to have worked around the problem, but I'm hoping someone can tell me they've seen this before, and I'm missing something fundamental. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From martin.franklin at westerngeco.com Tue Apr 17 08:16:43 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Tue, 17 Apr 2001 13:16:43 +0100 Subject: canvas drawing on button References: <3ADC32F7.95AD63C9@mek.dtu.dk> Message-ID: <3ADC342B.B0C526A@westerngeco.com> Brian: Try: import Tkinter root=Tkinter.Tk() img=Tkinter.PhotoImage(width=5, height=5) w='white' b='black' image_data=[ [ w, w, w, w, w ], [ w, w, b, w, w ], [ w, b, b, b, w ], [ w, w, b, w, w ], [ w, w, w, w, w ], ] for x in range(5): for y in range(5): img.put(image_data[x][y], (x, y)) images={1:img} # keep a referance.... b=Tkinter.Button(root, image=images[1]) b.pack() root.mainloop() Thanks, Martin. Brian Elmegaard wrote: > Hi, > > Is it possible in any way to make python generate a bitmap/image of a > tkinter canvas item and use that for a button bitmap/image? > > or, > > can I make a canvas on a button? > > or, > > do I really have to make the drawing outside of python? > -- > Brian > http://www.et.dtu.dk/energysystems > http://www.rk-speed.dk http://fiduso.dkhttp://sunsite.auc.dk/dk-tug > \TeX, tak -- Martin Franklin Workstation Support (Tel. Work 01234 224793, Home 01234 881722) Western G., Manton Lane, Bedford, Bedfordshire, MK41 7PA martin.franklin at bedford.waii.com From alex at shindich.com Thu Apr 5 02:55:37 2001 From: alex at shindich.com (Alex Shindich) Date: Thu, 5 Apr 2001 06:55:37 +0000 (UTC) Subject: PEP 245 References: Message-ID: <3ACC16C1.B43D6F0A@shindich.com> > * Newsgroups: comp.lang.python > * From: "Tim Peters" > * To: > * Subject: RE: PEP 245 > * Date: Thu, 5 Apr 2001 01:30:53 -0400 > * Organization: Baymountain > * Importance: Normal > * In-Reply-To: > * List-Archive: > * List-Help: > * List-Id: General discussion list for the Python programming language > * List-Post: > * List-Subscribe: , > * List-Unsubscribe: , > > ------------------------------------------------------------------------ > > So far, I bet Guido hasn't even read the relevant PEPs. > I sincerely hope so! > > One thing still bothers me -- Perl people will have a real reason to > > laugh. Indeed, interfaces in a loosely typed language that supports > > introspection -- that's a real joke! > > oh-ya-fud-and-ridicule-carry-a-lot-of-weight-ly y'rs - tim It sure does! ;)  -- Alex Shindich mailto:alex at shindich.com Visit http://www.shindich.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: alex.vcf Type: text/x-vcard Size: 194 bytes Desc: Card for Alex Shindich URL: From dalke at acm.org Tue Apr 10 00:01:47 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 9 Apr 2001 22:01:47 -0600 Subject: other python ideas References: <9atmor$dji$2@nntp9.atl.mindspring.net> Message-ID: <9au0pp$rua$1@slb7.atl.mindspring.net> Douglas Alan: >alias StringIO = cStringIO >try: > dummy = StringIO::someObject >except ImportError: > alias StringIO = StringIO Doesn't this introduce the same problems you have with import? Specifically, you may end up with lots of "alias" statements which are unneeded by the module? It's also somewhat awkward in that you need to know an object inside of the cStringIO/StringIO module for which to test. >or > >try: > StringIO = __import__("cStringIO") >except ImportError: > StringIO = __import__("StringIO") Not as nice looking with more complicated imports try: import Some.Patented.Module as ModuleX except ImportError: import My.Non.Patented.But.Slower.Module as ModuleX where you'll need ModuleX = __import("Some.Patented.Module").Patented.Module But then, I've never liked that aspect of __import__. Regardless, then in your proposal later on you would use StringIO::StringIO That means the implementation would need to first check if StringIO is defined in the module and, if not, do the __import__. >> Or the not so common practice of >> [call trace example] >The same way you have just done it above, only without the import >statement and replace > > math = TraceCalls(math) > >with > > math = TraceCalls(__import__("math")) > >If in "math::foo", "math" turns out to refer an object other than a >module object, the language can still go with the flow, just like in >normal Python. So your construct of "X::Y" acts like if X exists: return X.Y else: __import__(X).Y What about multilevel imports, say, xml.sax.handler? Could I use xml.sax::handler.ContentHandler or would I need to do xml::sax::handler.ContentHandler ? What if xml.sax is really class sax: def __getattr__(self, name): import new return new.module(name) >Personally, I hate maintaining import lists. As a general >rule, I think it is bad to have to maintain the same information in >two different places. But it isn't the same information. One says that a name refers to a module, or a class, or an instance, or a function. The other one says what to do with the name. def what_is(obj): print "This is", obj.__doc__ import math what_is(math) math = math.cos what_is(math) class math: pass what_is(math) math = math() what_is(math) Hmm. Thinking about this. How would you implement import math what_is(math) in your scheme? Perhaps as what_is(math::) ? > Having to do so results in dead code that loads unused modules. I mentioned your "alias" has the same problem. There are tools which address unneeded imports. One was announced just a few days ago. A couple years ago I worked on mods to kwparser's lint program to support 1.5 syntax and gave Guido a list of a few dozen module references to delete. Even with this there will be cruft functions, classes, etc. which won't be fixed with this proposal, so it tries to solve part of the problem without really addressing the whole thing. (Oh, and I helped with the code coverage program distributed in the Tools section to help that more general case :) >Also, I know people who won't use Python because they >want to be able to reload modules reliably, as you can on a Lisp >Machine. The quick answer is to let them work on Lisp Machines. Now consider: import spam def f(x, eggs = spam.eggs): return eggs(x) * eggs(x+1) Because f's default value for eggs is defined at module import time there is no way to reload(spam) and have f's function redefined. Instead, you need to do a reload of this module as well. Your proposal would change this to def f(x, eggs = spam::eggs): return eggs(x) * eggs(x+1) but still have the same problem that a reload(spam) won't rebuild f. So you don't fully solve the problem you want to solve. It's even worse when you have: # viking.py import spam class Parrot: def __init__(self, eggs = spam.eggs): self.eggs = eggs def f(self, x): return self.eggs(x) * self.eggs(x+1) ---- % python >>> import viking >>> bird = Viking.Parrot() >>> # oops! edit spam to fix a bug in eggs >>> import eggs >>> reload(eggs) >>> reload(viking) # just to be safe >>> bird.f(9) # returns wrong answer because bird keeps a reference to the *old* # Viking.Parrot definition and the instance keeps a reference to # the *old* eggs. >>> So you are only fixing one part of a larger issue, which is rebuilding everything in Python dependent on a module. > Unfortunately, the Common Lisp module system is unbearably > complex. Whereas Python's system is quite easy to explain and works just about like everything else namespace related. And I must confess to not knowing anything other than the most elementary parts of Lisp. Then again, I can point to precisely 1 person in all of computational biology and chemistry which use it... which is as many people as I know using Prolog or Ruby, and 1/2 the number I know of who have used Smalltalk. I suspect that means something. Andrew dalke at acm.org From rjohnson at exotic-eo.com Thu Apr 12 02:49:27 2001 From: rjohnson at exotic-eo.com (Robert Johnson) Date: Wed, 11 Apr 2001 23:49:27 -0700 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> <9b203102hla@news2.newsguy.com> Message-ID: <3ad54f9f$0$36580$e2e8da3@nntp.cts.com> > Python, with a suitable installation, can use ActiveX (through various > means, but the best and most flexible way is through Internet Explorer, > a highly-reusable collection of excellent components) *on Windows > platforms* -- this doesn't help you if you want your applications to > be used on NON-Windows platform. > > What platforms, exactly, do you want to target? Why does your app > need to be a "web" one (DOES it)? Why does it need to be client-side > (DOES it)? > > If the answers are 'all platforms', MUST be web-based e.g to allow > it being updated at any time, it must be client-side e.g. to leave > the server with a light load, then I think the ONLY answer you can > try is the JVM -- as least as a plug-in, it's available for most > browsers, and Python can run on reasonably-updated versions of it > (see www.jython.org). Tkinter cannot run on the JVM -- it can only > run natively on the various different platforms; you will have to > use Java-classes for your GUI's -- awt, swing, whatever. > I think that Java might be the only option. I doubt I would run into many Macs as the target would be scientists who would more than likely use Windows or Unix/Linux boxes. Plus, about half our customers are Europe/Asia and I don't believe Mac has much foothold there. But the fact that they may use Unix/Linux would seem to suggest a Java solution. From wtanksle at dolphin.openprojects.net Thu Apr 5 20:39:44 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 06 Apr 2001 00:39:44 GMT Subject: Curl, the language/environment/markup language...(Spanish Civil War)... References: <3ACBB03A.C9ADDEC5@earthlink.net> Message-ID: On Fri, 06 Apr 2001 00:25:24 GMT, Ron Stephens wrote: >www.curl.com is the new website that I think just went up last Friday. >Curl Corporation is a new MIT inspired outfit whose owners includes Tim >Berners-Lee and Michael Dertoutzos (sp??) . I went there and I find it >interesting, I wonder if anyone else has checked it out. If so, what do >you think??? New? Curl, the language, is _old_. It's kind of a replacement for HTML, TeX, Javascript, and CSS, all in one language. http://www.cag.lcs.mit.edu/curl/ The corporation's Curl is different, although apparently the same basic idea. No competition from or to Python. Ugh, what a horrible startup time -- no competition to Java either. I liked the original language, although it had very basic problems. >Ron Stephens -- -William "Billy" Tanksley From roviol at venmex.com Wed Apr 11 10:48:39 2001 From: roviol at venmex.com (Roland Oviol) Date: Wed, 11 Apr 2001 10:48:39 -0400 Subject: Newbie, problem array Message-ID: <3AD46EC7.A97E836@venmex.com> hello, It's the problem >>>d1=[[0,0]] >>>d2=d1 #reference no copy >>>d2[0][0]=3 >>>d2 [[3,0]] >>>d1 [[3,0]] ok but, >>>d1=[[0,0]] >>>d2=d1[:] #copy, no reference >>>d2[0][0]=3 >>>d2 [[3,0]] >>>d1 [[3,0]] Why, is copy, no reference How copy a object? Excluse me, my english Gracias (Thank's), Saludos, Roland From jmarshal at mathworks.com Tue Apr 10 10:15:27 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 10 Apr 2001 14:15:27 GMT Subject: Class Variable Question References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> Message-ID: <9av4hv$dho$1@news.mathworks.com> Douglas Alan wrote: > try: > set x = 3 > except NameError: > let x = 3 This would go nicely with lexical scoping. From cce at clarkevans.com Wed Apr 4 19:37:12 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Wed, 4 Apr 2001 18:37:12 -0500 (EST) Subject: PEP 245 In-Reply-To: References: Message-ID: On Wed, 4 Apr 2001, Alex Shindich wrote: > I see your point. But I think that proposed interface behavior is > missing a very important attribute -- an explicit facility for > acquiring interface references. This can be done with PEP 246 Clark From sholden at holdenweb.com Fri Apr 13 17:18:14 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Apr 2001 17:18:14 -0400 Subject: Tkinter App Wanted References: <3AD7647B.6A4B555B@direct.ca> Message-ID: <51KB6.174114$5H6.6146759@e420r-atl2.usenetserver.com> Ask, and it shall be granted. tkMenuTest.py is shown below [...pauses to run old code...] aaarrrggghhh ... sorry, this is *context* menus (right-button on a canvas). Oh well, I've included it anyway, in case it's useful later. Now, hang on [... ferkles about in John Grayson's Python stuff...] ah yes, menu.py from chapter 4. Hope he won't mind, it's freealy available from his web site (I think). If you haven't read John Grayson's "Python and Tkinter Programming" it's well worth a read. Source code at the foot of the message. regards Steve "Brian & Colleen" wrote in message news:3AD7647B.6A4B555B at direct.ca... > Is anyone willing to share the source for a small Tkinter app (maybe an > editor or file viewer) that includes a menu. I'm having problems getting > a menu to work inside an encapsulated application.#! /usr/bin/env python > > from Tkinter import * > > class App: > frame=Frame(master) > frame.pack() > > self.button=Button(frame,text="QUIT",fg="red",command=frame.quit) > self.button.pack(side=LEFT) > > self.hi_there=Button(frame,text="Hello",command=self.say_hi) > self.hi_there.pack(side=LEFT) > > def say_hi(self): > print "Hi there, everyone!" > > root=Tk() > app = App(root) > root.mainloop() > > Somewhere inside the App class, I'd like to include a basic menu > (File-Save As, Exit) etc. so that when I create an instance of App, all > the pieces are there. > > Thanks in advance. > ----------menutest.py---------- # menutest.py # Makes a window pop up by rightclicking the canvas. from Tkinter import * import regsub def getgeometry(something): s = something.geometry() return map(int, regsub.split(s, "[x+]")) root = Tk() root.canvas = Canvas(root, height=100, width=100, background='#674689') root.canvas.pack() def new_file(event=None): print "Opening new file" menu = Menu(root) menu.add_command(label="New...", underline=0, command=new_file) menu.add_command(label="Open...", underline=0, command=new_file) menu['tearoff'] = 0 def activate_menu(event=None): # event.x, event.y is the relative mouse position sizex, sizey, x, y = getgeometry(root) menu.tk_popup(x+event.x, y+event.y) #menu.tk_popup(x,y) root.canvas.bind("", activate_menu) root.mainloop() ----------menu.py---------- from Tkinter import * def new_file(): print "Open new file" def open_file(): print "Open existing file" def stub_action(): print "Menu select" def makeCommandMenu(): CmdBtn = Menubutton(mBar, text='Button Commands', underline=0) CmdBtn.pack(side=LEFT, padx="2m") CmdBtn.menu = Menu(CmdBtn) CmdBtn.menu.add_command(label="Undo") CmdBtn.menu.entryconfig(0, state=DISABLED) CmdBtn.menu.add_command(label='New...', underline=0, command=new_file) CmdBtn.menu.add_command(label='Open...', underline=0, command=open_file) CmdBtn.menu.add_command(label='Wild Font', underline=0, font=('Tempus Sans ITC', 14), command=stub_action) CmdBtn.menu.add_command(bitmap="@bitmaps/RotateLeft") CmdBtn.menu.add('separator') CmdBtn.menu.add_command(label='Quit', underline=0, background='white', activebackground='green', command=CmdBtn.quit) CmdBtn['menu'] = CmdBtn.menu return CmdBtn def makeCascadeMenu(): CasBtn = Menubutton(mBar, text='Cascading Menus', underline=0) CasBtn.pack(side=LEFT, padx="2m") CasBtn.menu = Menu(CasBtn) CasBtn.menu.choices = Menu(CasBtn.menu) CasBtn.menu.choices.wierdones = Menu(CasBtn.menu.choices) CasBtn.menu.choices.wierdones.add_command(label='Stockbroker') CasBtn.menu.choices.wierdones.add_command(label='Quantity Surveyor') CasBtn.menu.choices.wierdones.add_command(label='Church Warden') CasBtn.menu.choices.wierdones.add_command(label='BRM') CasBtn.menu.choices.add_command(label='Wooden Leg') CasBtn.menu.choices.add_command(label='Hire Purchase') CasBtn.menu.choices.add_command(label='Dead Crab') CasBtn.menu.choices.add_command(label='Tree Surgeon') CasBtn.menu.choices.add_command(label='Filing Cabinet') CasBtn.menu.choices.add_command(label='Goldfish') CasBtn.menu.choices.add_cascade(label='Is it a...', menu=CasBtn.menu.choices.wierdones) CasBtn.menu.add_cascade(label='Scipts', menu=CasBtn.menu.choices) CasBtn['menu'] = CasBtn.menu return CasBtn def makeCheckbuttonMenu(): ChkBtn = Menubutton(mBar, text='Checkbutton Menus', underline=0) ChkBtn.pack(side=LEFT, padx='2m') ChkBtn.menu = Menu(ChkBtn) ChkBtn.menu.add_checkbutton(label='Doug') ChkBtn.menu.add_checkbutton(label='Dinsdale') ChkBtn.menu.add_checkbutton(label="Stig O'Tracy") ChkBtn.menu.add_checkbutton(label='Vince') ChkBtn.menu.add_checkbutton(label='Gloria Pules') ChkBtn.menu.invoke(ChkBtn.menu.index('Dinsdale')) ChkBtn['menu'] = ChkBtn.menu return ChkBtn def makeRadiobuttonMenu(): RadBtn = Menubutton(mBar, text='Radiobutton Menus', underline=0) RadBtn.pack(side=LEFT, padx='2m') RadBtn.menu = Menu(RadBtn) RadBtn.menu.add_radiobutton(label='metonymy') RadBtn.menu.add_radiobutton(label='zeugmatists') RadBtn.menu.add_radiobutton(label='synechdotists') RadBtn.menu.add_radiobutton(label='axiomists') RadBtn.menu.add_radiobutton(label='anagogists') RadBtn.menu.add_radiobutton(label='catachresis') RadBtn.menu.add_radiobutton(label='periphrastic') RadBtn.menu.add_radiobutton(label='litotes') RadBtn.menu.add_radiobutton(label='circumlocutors') RadBtn['menu'] = RadBtn.menu return RadBtn def makeDisabledMenu(): Dummy_button = Menubutton(mBar, text='Disabled Menu', underline=0) Dummy_button.pack(side=LEFT, padx='2m') Dummy_button["state"] = DISABLED return Dummy_button root = Tk() mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) CmdBtn = makeCommandMenu() CasBtn = makeCascadeMenu() ChkBtn = makeCheckbuttonMenu() RadBtn = makeRadiobuttonMenu() NoMenu = makeDisabledMenu() mBar.tk_menuBar(CmdBtn, CasBtn, ChkBtn, RadBtn, NoMenu) root.title('Menus') root.mainloop() From tuttledon at hotmail.com Sun Apr 8 23:16:13 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Mon, 09 Apr 2001 03:16:13 GMT Subject: Komodo: First Impressions References: <9anhhr$mka$1@news.ycc.yale.edu> Message-ID: <1Q9A6.39360$Ho5.9857740@typhoon.southeast.rr.com> And let us not forget the $295.00 price tag it has for doing any "real" work. PythonWin works just fine thank you! Don From owen at astrono.junkwashington.emu Mon Apr 2 14:32:18 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 02 Apr 2001 11:32:18 -0700 Subject: Python and Java Compared? References: <3ac6f744_1@news4.newsfeeds.com> Message-ID: <9aagjo$sfk$1@nntp6.u.washington.edu> In article <3ac6f744_1 at news4.newsfeeds.com>, "Dry Ice" wrote: >First, I'd most like to hear from those >who have some balanced experience at BOTH, >as opposed to 'fans' of one or the other who >have only dabbled in a secondary effort. > >I would like to select one development environment >to manage everything in a cluster-server project, >from accounting-database to server CGI to distributed >computing jobs. > >Platform: Linux, and a few Windows machines- at >least at the beginning. > >If you had to choose... Both are reasonable. They have decent syntax, built in garbage collection, integrated networking libraries, good support, good documentation. Python's strenths include: - Dynamically typed and interpreted. Both of these make code clearer, much easier to write and much more malleable. Interpreted code is also easier to test. It is hard to overstate how valuable these factors are for reliability -- far outweighing, in my mind, the value of strong typing (though better optional type checking would be nice to have). - Well designed class libraries that are easy to use. I find Java's a bit cluttered and overly complex. This is partly a by-product of dynamic vs static typing. Check out the relative size of the books for each language some time; it's an eye opener. Java's strengths include: - Interfaces (which may get added to Python). - Lack of multiple inheritance. In my view MI adds more risk than advantage. Others, of course, will assign the advantage to Python. - Integrated GUI. There are many GUI choices for Python but none are really well integrated and support can be an issue. - Jython means you can write Python scripts in Java and, to some extent, have the best of both worlds. I've not tried it, though. I'm sure I'm missing a lot, but it's a start. Smalltalk is another language you should consider (try out Cincom's noncommercial package). It is missing interfaces, but otherwise has most of the strengths listed above. It also has the best development tools and development time of the bunch. -- Russell From ben at co.and.co Fri Apr 6 06:19:41 2001 From: ben at co.and.co (ben at co.and.co) Date: Fri, 06 Apr 2001 10:19:41 GMT Subject: [ANNOUNCE] AHTS, A HTML Templating System Message-ID: <1Lgz6.12464$ii5.1120006@afrodite.telenet-ops.be> [ My apologies if you already received this. ] AHTS stands for A HTML Templating System. It is an implementation of the templating system invented by Ars Digita, ACS Templating, in Python. AHTS tries to mimic the designer side (i.e. the tags) of the ACS templating system as close as possible. This is the very first, alpha, 0.0, release, so don't expect it to be bugfree. Homepage, more info: http://ahts.sourceforge.net Greetings, -- ben . de . rydt at pandora . be ------------------ your comments http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora From roy at panix.com Mon Apr 16 08:37:15 2001 From: roy at panix.com (Roy Smith) Date: Mon, 16 Apr 2001 08:37:15 -0400 Subject: smtplib References: <3adab0a5@news.actrix.gen.nz> Message-ID: "Steve Holden" wrote: > For the record, smtpli.SMTP.sendmail() does *not* look at the message > envelope at all: so, for example, you implement blind Cc's by including > recipients in the to_addrs list when they don't appear in the message > headers inside To: or Cc:. I think you've got that backwards. The To: and Cc: lines are part of the headers, not the envelope. The address list you give in the function call *is* the envelope. You are correct that putting addresses in the functional argument list and not the headers is how you implement Bcc, you've just got the terminology mixed up. From rob at hooft.net Fri Apr 6 04:37:54 2001 From: rob at hooft.net (Rob Hooft) Date: 06 Apr 2001 10:37:54 +0200 Subject: python modules as user configuration files References: Message-ID: I use the following: ------------------------------------------------------------------- # __version__ = '$Id: config.py,v 1.139 2001/04/06 08:04:01 hooft Exp $' # # Configurable GUI parameters (like colors) # i_am_a_developer=0 background='red' [...100 variables omitted...] xwindows=11 # System-level and User-level changes. _gl=globals().keys() import os for _filename in ["/usr/local/lib/nonius-config.py", os.environ["HOME"]+"/.nonius-config", "nonius-config"]: if os.path.exists(_filename): _filestatus=os.stat(_filename) _filemode=_filestatus[0] _fileuid=_filestatus[4] if (_fileuid==os.getuid() or _fileuid==0): if _filemode&002==0: execfile(_filename) else: print "WARNING: Skipped '%s': writeable by others."%_filename else: print "WARNING: Skipped '%s': owned by someone else."%_filename del _filemode,_fileuid,_filestatus del os,_filename # Test for obsoleted and/or unknown variables. for _key in globals().keys(): if _key in _gl or _key[0]=='_': pass elif _key=='userpc': print "WARNING: Configuration variable 'userpc' obsolete" print " please change your configuration files accordingly" else: print "WARNING: Configuration variable %s not known. Misspelled?"%_key del _gl if __name__=="__main__": k=globals().keys() k.sort() for name in k: if name[0]!='_': print name,"=",repr(globals()[name]) --------------------------------------------------- -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From mary.stern at virgin.net Wed Apr 25 10:00:35 2001 From: mary.stern at virgin.net (mary) Date: Wed, 25 Apr 2001 15:00:35 +0100 Subject: followup: vertical slices from a matrix in a dictionary?... Message-ID: <9c6laa$2f9q$1@sp15at20.hursley.ibm.com> Well I found the answer to my previous post (in the excellent 'Essential Python Reference' book by David M Beazley - highly recommended), but now I have a follow-up question. I can use 'map(None, a, b, c)' to take 'vertical slices out of tuples a, b and c. I want to generalise this to a dictionary of tuples. I'm a bit stuck on how to call map with a varying number of arguments, ie: Here's a program which works as desired, but is not generalised: --------------------------------- x = {} x['gamma'] = (1,2,3) x['beta'] = (4,5,6) x['alpha'] = (7,8,9) print x print x.keys() # --- sort keys y = x.keys() y.sort() print y # --- take vertical slices of x (in y-order) z = map(None, x[y[0]], x[y[1]], x[y[2]]) <---How do I generalise this call?... print z ---------------------------------------------------- But I want to take a dictionary with any number of keys, sort them into alphabetica order, and then get the 'vertical slices' in alphabetival order (ie how do I avoid hardcoding the x[y[0], x[y[1]], etc...) Any help appreciated! :) - Tushar From spahievi at vega.bg Mon Apr 23 15:34:42 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Mon, 23 Apr 2001 22:34:42 +0300 Subject: ANN: Polygon Boolean Operations In-Reply-To: <6k4tdtg8kfjvgfvd83iu1oitvt02bhvub9@4ax.com> References: <0upkdt09u0v50rkhbdv5ecl6ml0jac260t@4ax.com> <6k4tdtg8kfjvgfvd83iu1oitvt02bhvub9@4ax.com> Message-ID: <827714406.20010423223442@vega.bg> I made python interface to 2 polygon libraries. I only need union operation but others are easy to add. win32 binaryes and sources at www.vintech.bg/~niki/python Packed with distutils, but not tested except on win32. -- Best regards, Niki Spahiev From neotaku at free.fr Wed Apr 25 02:58:50 2001 From: neotaku at free.fr (Neotaku) Date: Wed, 25 Apr 2001 06:58:50 GMT Subject: Help for access method of wxPython object References: <9c4id9$6ov$1@newsreaderm1.core.theplanet.net> Message-ID: Thanks you so much Robin and Franz it work very well ^^ "Robin Dunn" a ?crit dans le message news: dGkF6.378$GdX.55181534 at news.randori.com... > You can also use wxPyTypeCast on what is returned from GetChildren, so the > OP could do this: > > obj = wxPyTypeCast(self.GetChildren()[26], "wxTextCtrl") > obj.SetValue("Testing") > > Hopefully the need for this ugly hack will also go away with the upcoming > changes I mentioned yesterday. > > Robin > > > "Franz GEIGER" wrote in message > news:9c4id9$6ov$1 at newsreaderm1.core.theplanet.net... > > Had a similar problem. Thanks to Robin Dunn, he showed me how to solve it: > > You have to use Getters like this, to access the control: > > > > def GetTextctrlText(self): > > return wxPyTypeCast( self.FindWindowById(ID_TEXTCTRL_TEXT), > > "wxTextCtrl" ) > > > > wxDesigner(), which I really can recommend, did this for me by a simple > > button click. > > > > See the related thread on this: > > > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=40bf7162e9580db9& > > seekd=909081131#909081131 > > > > Hope this helps. > > > > Best Regards > > Franz GEIGER > > > > "Neotaku" wrote in message > > news:CieF6.475$6H6.2077927 at nnrp3.proxad.net... > > > > > > Hello, > > > > > > Here is my problem, i take an object control from a windows like > this > > > obj = self.GetChildren()[26] > > > print obj.GetName() > > > > > > self is a windows and the 26th object is a textcontrol. so this code > > > work well and i can get the control's name but when i want to do that : > > > obj.SetValue("Testing") > > > > > > i have always this error : AttributeError : 'wxWindowPtr' instance > has > > > no attribute 'SetValue' > > > i don't understand why it doesn't work ? the only way it can work is > > > like this : self.MyTextCtrl.SetValue("Testing") > > > > > > Thanks a lot for you help > > > > > > Using : wxPython, Boa Constructor, NT4 Win32 > > > > > > > > > > From grey at despair.rpglink.com Mon Apr 16 11:21:58 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Mon, 16 Apr 2001 15:21:58 -0000 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! References: <3adafeb8@nntp.server.uni-frankfurt.de> Message-ID: On 16 Apr 2001 16:16:24 +0200, Michael 'Mickey' Lauer wrote: >Steve Lamb wrote: >>>take place in just 4 days, especially when Easter, Passover, and US taxes >>>are going on at the same time? >> What, you think everyone who uses Python is Christian/Cathoic (et al) and >> American? Heck, only one of those three dates has any significance to me. >Now do you dare to tell us which one? ;) Well, in theory, I already have considering two are linked, no? However, far be it for me to pass up on the chance for an anecdote for those who want it in pixels. :) Last week I went to lunch with a few coworkers. We went to a nice local place that is frequented by many people from our company. End result, the staff is quite friendly to anyone wearing our logo. As we left the following conversation ensued. Waitress: "Have a good weekend. Hope you get a day off for the holiday!" Me: "What holiday?" Waitress (puzzled look): "Easter!" Me: "Oh... Well, guess you know who the Atheist in the group is now, huh?" Hmmm, now did those taxes get in the mailbox or are they still sitting on the computer at home? Grrrrr. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From greybria at direct.ca Fri Apr 13 16:41:32 2001 From: greybria at direct.ca (Brian & Colleen) Date: Fri, 13 Apr 2001 13:41:32 -0700 Subject: Tkinter App Wanted Message-ID: <3AD7647B.6A4B555B@direct.ca> Is anyone willing to share the source for a small Tkinter app (maybe an editor or file viewer) that includes a menu. I'm having problems getting a menu to work inside an encapsulated application.#! /usr/bin/env python from Tkinter import * class App: frame=Frame(master) frame.pack() self.button=Button(frame,text="QUIT",fg="red",command=frame.quit) self.button.pack(side=LEFT) self.hi_there=Button(frame,text="Hello",command=self.say_hi) self.hi_there.pack(side=LEFT) def say_hi(self): print "Hi there, everyone!" root=Tk() app = App(root) root.mainloop() Somewhere inside the App class, I'd like to include a basic menu (File-Save As, Exit) etc. so that when I create an instance of App, all the pieces are there. Thanks in advance. -- Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From Randy.L.Kemp at motorola.com Thu Apr 5 12:43:41 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 5 Apr 2001 11:43:41 -0500 Subject: Python Books for 2002 Message-ID: So why not a Python for Dummies or a Perl for Idiots book? -----Original Message----- From: aahz at panix.com [mailto:aahz at panix.com] Sent: Thursday, April 05, 2001 10:29 AM To: python-list at python.org Subject: Re: Python Books for 2002 In article <03BA7FF29A7003C0.58A7996FD1867709.07757E6DB814C605 at lp.airnews.net>, Cameron Laird wrote: > >Here's a hazard of concision: it abbreviates sometimes to confusion. >I think a "40 page 'python in depth' treatise" would be *snapped up* >at retail, even at $10 or 20 US. The market to which Fredrik is >apparently referring is that of either the publishers or distributors, >who find this sort of innovation anathema. Ever since I saw _Borland C++ for Dummies_, I have concluded that *nothing* is truly anathema to computer book publishers. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "The only problem with Microsoft is they just have no taste." --Steve Jobs From shindich at itginc.com Wed Apr 4 18:25:12 2001 From: shindich at itginc.com (Alex Shindich) Date: Wed, 4 Apr 2001 22:25:12 +0000 (UTC) Subject: PEP 245 Message-ID: Michel, Thank you for the explanations! Your reply did clear up some of the concerns I had regarding this PEP. I still have a few objections though: >> 1. What is the point of interfaces without static typing? >To assert a contract is one. To separate various implementations of the >same interface without them loosing a common usage is another. >No mandatory enforcement is being proposed. This means that interface support in Python will be limited to three applications: 1. Clear documentation of the interfaces 2. Separation of inheritence hierarchy from the implementation hierarchy 3. An ability to dtermine if a particular object supports a specific interface. Am I missing anything out? >> 2. At what point will the compliance with the interface definition be >> done, at compile time, or at run time? >There is no madatory compliance or interface enforcement proposed in 245. >These things are optional, and they should be optional. Turn on for >unit-testing, debugging, etc, turn off for production and speed. Great! >> If the compliance is checked at run time, then interface checking is as >> good as as simply assuming that the method is implemented. Today, I can >> compile code like "f.doSomething ()" without f actually implementing >> doSomething. At run time I would get an AttributeError thrown into my >> face. In fact, the run time compliance is available already. > >Interfaces, strong or weak, are not going to solve any of these problems >in a magic bullet fasion. There's a million ways around even strong >interfaced languaged, even ones that go so far as to check pre and >post-condition contract boundaries. I was not trying to identify the problems. On the contrary, my point was that run-time checking is supported today, i.e. if the method is not present, an AttributeError exception will be thrown. BTW. Are you planning on throwning an InterfaceError exception instead of AttributeError? >One of the major reasons for the PEP is to assert that an object can be >used in a certain way, without caring about how it is implemented. It's >telling you something about what it can do, without you having to know the >difference between the flat-file implementation and the one that uses a >relational database. >Currently this ability in Python is weak, and is based on looking at >classes. But classes are not meant to be explicit interfaces, they are >ways of sharing implementaiton. I see your point. But I think that proposed interface behavior is missing a very important attribute -- an explicit facility for acquiring interface references. Per you proposal, the reference to the object is indistinguishable from the reference to the interface. In Java the reference to the interface is obtained using a type cast, i.e. IProgrammer prg = (IProgrammer) obj; In COM, the same is accomplished through the use of QueryInterface, i.e. IProgrammer * pIProgrammer = NULL; HRESULT hr = pIObj->QueryInterface (IID_IProgrammer, reinterpret_cast (&pIProgrammer)); if (SUCCEEDED (hr)) ... or CComQIPtr tIProgrammer(pIObj); if (!tIProgrammer) ... There is no such thing proposed in PEP 245. If the interfaces are added to Python, I would like to have a way of distinguishing between references to the object and references to the interface. In fact, I would like that to be more similar with COM rules where class implmenetor is responsible for the implementation of QueryInterface (although default behaviour should be provided). This permits playing all sorts of identity tricks, such as component aggregation, and tear-offs. How about adding __getinterfacereference__ that as name implies returns the interface reference? I guess a built-in getinterface (object, interface) -> interface reference would have to be added as well. >No, Java interfaces are just compile time enforcement. The syntax is >vaguely similar. But the concept is similar. Java interfaces assert a contract, and allow documenting it. In Java one can find out if class implements an interface. The syntax is extremely similar... Not that there is anything wrong with Java syntax. >Take me for example. If I were a python object, I'd be an instance of a >class that is generalized by two other classes, my mom and dad. That's my >type, my genetics. class Dad: ... class Mom: ... class Son (Dad, Mom): ... >Now, let's say you were a function that expected a >'Python programmer'. You could wire that expectation to my implementation >(my class), but then, I'd be the only "kind" of python programmer you could >use. You could wire it to my generalized classes, but then you could only >use me and my two sisters, and they're not python programmers. Let's say that a programmer does a number of tasks, among them are: 'writeRequirements', 'design', 'implement' In that case it is reasonable to expect that every programmer should implement those three methods. In which case I can write code like: # Client code son = Son () if has_attr (son, writeRequirements): son.writeRequirements () if has_attr (son, design): son.design () if has_attr (son, implement): son.implement () Assuming that I had interfaces, I would write: interface Programmer: """""" def writeRequirements (self): """""" def design (self): """""" def implement (self): """""" ... class Son (Dad, Mom) implements Programmer: ... # Client code son = Son () if implements (son, Programmer): son.writeRequirements () son.design () son.implement () What are the benefits of using the interface? Documentation is one of the biggest advantages. Also, an ability to ask the object if it implements interface as a whole comes in handy and reduces the number of if statements. Although the version of client code that uses exceptions is as simple. Now let's assume that there is an inexperienced programmer who does not write requirements yet, but is capable of doing everything else... It seems like our interface needs to be split up into two -- Analyst and Programmer interface Programmer: """""" def design (self): """""" def implement (self): """""" ... interface Analyst" """""" def writeRequirements (self): """""" class Son (Dad, Mom) implements Analyst, Programmer: ... # New client code son = Son () if implements (son, Analyst): son.writeRequirements () if implements (son, Programmer): son.design () son.implement () As you can see the client code had to change. Let's see what would client code withut interfaces look like? # Client code son = Son () if has_attr (son, writeRequirements): son.writeRequirements () if has_attr (son, design): son.design () if has_attr (son, implement): son.implement () As you can see, the version with if has_attr() still works just fine! (Assuming that has_attr works...) The point is -- the proposed definition of interfaces brings very little to the table. Everythinbg it offers can one way or another be done using existing language constructs. Sometimes, the use of interfaces introduces backward-compatibility problems. The biggest benefit that I see in the PEP 245 is the documentation. I like the fact that documentation will be structured in the form of the interface definition as oppose to a sparate help file. I also like an ability to determine if the object implements interface as a whole. But I can live without it using introspection. If the notion of "__getinterfacereference__" were added, I would see a lot more value in the PEP. Regards, Alex Shindich -- Posted from mailgw2.itginc.com [38.149.119.13] via Mailgate.ORG Server - http://www.Mailgate.ORG From neo at thezion.net Mon Apr 9 04:49:25 2001 From: neo at thezion.net (Neo) Date: Mon, 9 Apr 2001 10:49:25 +0200 Subject: Pythonwin break execution Message-ID: <9arsv3$6ho02$1@ID-35431.news.dfncis.de> What is the key for to break the script execution in pythonwin? Tnx -- -- Neo ************************************ Follow the White Rabbit... Knock Knock Neo... ICQ #42292922 Webmaster di www.thezion.net La prima community di web developer Ad Free The first web developer's community Ad Free ************************************ From bas.vangils at home.nl Wed Apr 11 14:05:37 2001 From: bas.vangils at home.nl (bas.vangils at home.nl) Date: Wed, 11 Apr 2001 18:05:37 GMT Subject: sort dictionary by value References: Message-ID: Robin Thomas wrote: * Q: Can dictionaries be sorted? * A: No. Dictionaries have no concept of ordering of their items, such that * the items can be "re-ordered" in the dictionary by sorting them. ehh I knew that... * Q: Can I retrieve all of the items in a dictionary and sort them? * A: Yes. true, that is what I meant ... * >>> d = some_big_dictionary() * >>> i = d.items() * # sort by value * >>> i.sort(lambda x,y: cmp(x[1],y[1])) * # sort by key * >>> i.sort(lambda x,y: cmp(x[0],y[0])) and that's the one which probably solves my problem. So, thanks a lot -- Bas van Gils An invasion of armies can be resisted, but not an idea whose time has come. (Victor Hugo) From roccomoretti at netscape.net Fri Apr 20 20:07:00 2001 From: roccomoretti at netscape.net (Rocco Moretti) Date: Fri, 20 Apr 2001 20:07:00 -0400 Subject: Python compiler? References: Message-ID: <3AE0CF24.9020303@netscape.net> Steve Holden crafted these words: > There's an article on the May edition of DDJ called "Compiling Perl/Tk > Scripts" by Cameron Laird that might also be useful. The abstract is, > people want to compile because of 1) speed; 2) code security; 3) size; > 4) fashion (i.e., just because it's cool); 5) packaging (easier to > deploy, no separated interpreter installation needed). > > Of all three er.. five, compiling dynamic scripting languages only > effectively gives us number 4 & 5. > > Steve I think you may be overstating your case. The article in question, as it's title suggests, only looked at Perl/Tk compilers, and only at those on MS-Windows, a sample size of two. It didn't even mention compilers for any other language, or even any other platform. In fact, if you want to be a stickler, you might not even consider them "compilers." I know nothing about the products, but from the article it seems that they are equivalent to a "freeze" tool, wrapping the perl script with a minimal interpreter in a standalone executable. Thus you get 4) and 5), because you now have a single executable. You don't get 3) because you have both the script and the interpreter. (Even though stripped down, it is still sizable.) Heck, for compiling small C programs you don't get a size benefit due to the loader code and the included library functions. Code security (2) is out because the "compiled" programs store the original perl script as a plaintext string in the executable. (Easily findable by anyone with a hex editor.) And since you're still interpreting the program, you aren't going to get a speed advantage (1). My take on the article is that its directed at clueless IT directors who see "compiler" in the program's name and think it's a pancea to their problems. (Perhaps Mr. Laird, who has been seen in this newsgroup, could clarify, and add his comments on how he thinks Python relates.) Note that a "true" compiler, which converts the script itself to machine code and optimizes it, may see benefits in all five points. If Python will see such a compiler is still an open question. -- Rocco Moretti From f8dy at yahoo.com Mon Apr 23 15:59:01 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Mon, 23 Apr 2001 15:59:01 -0400 Subject: Dive Into Python: call for comments (long) Message-ID: <9c21d4$bhtck$1@ID-77331.news.dfncis.de> Chapter 4 of "Dive Into Python" ( http://diveintopython.org/ ) is almost done, and I would like to devote Chapter 5 to PyUnit ( http://pyunit.sourceforge.net/ ), the new unit testing framework included in Python 2.1. This is a general call for help to anyone who has had experience writing unit tests in other platforms (or worked with PyUnit in particular), and anyone who has opinions about my Python coding style and The Pythonic Way. The example program for chapter 5 is a simple Python module to convert to and from Roman numerals (inspired by a thread on c.l.py a few weeks ago) and a corresponding set of test cases and suites. Both are listed below. My questions: 1. Is this a good example module to teach unit testing? Too simple? Too complex? I thought it would be a good candidate because it (a) consists of two functions which are reciprocals of each other (so a sanity check would be to make sure that fromRoman(toRoman(n)) == n for all n in the domain), (b) has a limited domain (integers from 1 to 3999), (c) runs quickly (I can run through all possible inputs in < 2 seconds), and (d) requires no external resources (database, external files, &c). The format of the book is that each chapter teaches lessons that directly relate to a specific example program, so if the example program is no good, the whole chapter suffers. 2. Assuming this is a reasonable module to test, is the module well-written? Feel free to suggest alternative, more Pythonic ways of doing things. It uses rich data structures (a tuple of tuples of string/integer/compiled RE) rather than rich code, custom exceptions raised signal errors, multi-variable assignment in for loops, and module-level attributes like __author__ and __version__ that show up in PyDoc. (Many of you will be happy to hear that it uses neither list comprehensions nor "".join().) In each of the first 4 chapters, I have written extensively on code which I then changed based on feedback from more intelligent readers than myself, who knew about built-in functions I should have used (hi Alex), or more efficient patterns (hi Sean), or obscure use cases (hi Fred), &c. I'd like to shake these bugs out before I write the chapter; like bugs in code, bugs in books are easier to fix during design than after deployment. 3. Assuming the module is well-written, are the test cases any good? I found a good article on JavaWorld.com ( http://www.javaworld.com/javaworld/jw-12-2000/jw-1221-junit.html ) which listed some first principles for writing unit tests in JUnit, much of which applies to PyUnit as well. The test cases I've included test (a) reciprocal sanity (fromRoman(toRoman(n)) == n for all reasonable n), (b) a 10% sampling of inputs to test against a set of (externally verified) known outputs, (c) a set of bad inputs for toRoman() (negative numbers, numbers too large, non-integers) and fromRoman() (a variety of invalid Roman numerals). Is there some basic class of tests that I'm missing? Are there other specific cases I should be testing? 3. Assuming the tests are valid and reasonable, are the test cases and test suites well-organized? Some "related" tests are grouped together in the same class; for instance, all 4 "bad input" tests for toRoman() are in the ToRomanBadInputs class (descended from unittest.TestCase). Should these be broken out into separate classes, or should tests that are currently separated be grouped into one class? Much of this is PyUnit-specific, and I suspect it is also based on personal taste, but since I'm new to PyUnit, I have no personal taste to guide me. (Based on my other code, some would argue I have no taste at all.) 4. Assuming the test cases are well-organized, am I using the PyUnit framework the way it was meant to be used? Am I making things too difficult for myself in any way? There's nothing worse than basing a teaching lesson on unnecessarily complex code; it confuses the readers who don't know any better and annoys the readers who do. Thank you all in advance for any assistance. -M #--start of roman.py """Convert to and from Roman numerals""" __author__ = "Mark Pilgrim (f8dy at diveintopython.org)" __version__ = "1.1" __date__ = "21 April 2001" import re #Define exceptions class RomanError(ValueError): pass class OutOfRangeError(RomanError): pass class NotIntegerError(RomanError): pass class InvalidRomanNumeralError(RomanError): pass #Define digit mapping and patterns romanNumeralDigits = ( \ ('M', 1000, re.compile('^MM?M?')), ('CM', 900, re.compile('^CM')), ('D', 500, re.compile('^D')), ('CD', 400, re.compile('^CD')), ('C', 100, re.compile('^CC?C?')), ('XC', 90, re.compile('^XC')), ('L', 50, re.compile('^L')), ('XL', 40, re.compile('^XL')), ('X', 10, re.compile('^XX?X?')), ('IX', 9, re.compile('^IX')), ('V', 5, re.compile('^V')), ('IV', 4, re.compile('^IV')), ('I', 1, re.compile('^II?I?'))) #Define pattern to detect valid Roman numerals romanNumeralPattern = \ re.compile('^M?M?M?(CM|CD|D?C?C?C?)(XC|XL|L?X?X?X?)(IX|IV|V?I?I?I?)$') def toRoman(n): """convert integer to Roman numeral""" if not (0 < n < 4000): raise OutOfRangeError, "number out of range (must be 1..3999)" if int(n) <> n: raise NotIntegerError, "decimals can not be converted" result = "" for roman, integer, pattern in romanNumeralDigits: while n >= integer: result += roman n -= integer return result def fromRoman(s): """convert Roman numeral to integer""" s = s.upper() if not romanNumeralPattern.search(s): raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s result = 0 for roman, integer, pattern in romanNumeralDigits: match = pattern.search(s) if match: lenmatch = len(match.group()) result += integer * lenmatch / len(roman) s = s[lenmatch:] return result #--end of roman.py #--start of romantest.py #!/usr/bin/python """Unit test for roman.py""" __author__ = "Mark Pilgrim (f8dy at diveintopython.org)" __version__ = "1.0" __date__ = "21 April 2001" import roman import unittest #----------------- #Define test cases #----------------- class SanityCheck(unittest.TestCase): """test that fromRoman(toRoman(n))==n for all n""" def testSanity(self): """test that fromRoman(toRoman(n))==n for all n""" for n in range(1, 4000): s = roman.toRoman(n) fullcircle = roman.fromRoman(s) self.assertEqual(n, fullcircle, \ "%(n)s --> %(s)s --> %(fullcircle)s" % locals()) class KnownValuesBase(unittest.TestCase): """base class to set up tests that require a set of known values""" def setUp(self): """define a set of known values""" unittest.TestCase.setUp(self) self.knownValues = ((31, 'XXXI'), (148, 'CXLVIII'), (294, 'CCXCIV'), (312, 'CCCXII'), (421, 'CDXXI'), (528, 'DXXVIII'), (621, 'DCXXI'), (782, 'DCCLXXXII'), (870, 'DCCCLXX'), (941, 'CMXLI'), (1043, 'MXLIII'), (1110, 'MCX'), (1226, 'MCCXXVI'), (1301, 'MCCCI'), (1485, 'MCDLXXXV'), (1509, 'MDIX'), (1607, 'MDCVII'), (1754, 'MDCCLIV'), (1832, 'MDCCCXXXII'), (1993, 'MCMXCIII'), (2074, 'MMLXXIV'), (2152, 'MMCLII'), (2212, 'MMCCXII'), (2343, 'MMCCCXLIII'), (2499, 'MMCDXCIX'), (2574, 'MMDLXXIV'), (2646, 'MMDCXLVI'), (2723, 'MMDCCXXIII'), (2892, 'MMDCCCXCII'), (2975, 'MMCMLXXV'), (3051, 'MMMLI'), (3185, 'MMMCLXXXV'), (3250, 'MMMCCL'), (3313, 'MMMCCCXIII'), (3408, 'MMMCDVIII'), (3501, 'MMMDI'), (3610, 'MMMDCX'), (3743, 'MMMDCCXLIII'), (3844, 'MMMDCCCXLIV'), (3940, 'MMMCMXL')) def tearDown(self): """stub for cleaning up after test cases""" pass class ToRomanKnownValues(KnownValuesBase): """test toRoman with known values""" def testKnownValues(self): """test toRoman with known values""" for n, s in self.knownValues: result = roman.toRoman(n) self.assertEqual(s, result, \ "toRoman(%(n)s) = %(result)s, should be %(s)s" % locals()) class FromRomanKnownValues(KnownValuesBase): """test fromRoman with known values""" def testKnownValues(self): """test fromRoman with known values""" for n, s in self.knownValues: result = roman.fromRoman(s) self.assertEqual(n, result, \ "fromRoman('%(s)s') = %(result)s, should be %(n)s" % locals()) class ToRomanBadInput(unittest.TestCase): """test toRoman with a variety of bad inputs""" def testTooLarge(self): """test toRoman with large input""" self.assertRaises(roman.OutOfRangeError, roman.toRoman, 4000) def testZero(self): """test toRoman with 0 input""" self.assertRaises(roman.OutOfRangeError, roman.toRoman, 0) def testNegative(self): """test toRoman with negative input""" self.assertRaises(roman.OutOfRangeError, roman.toRoman, -1) def testDecimal(self): """test toRoman with non-integer input""" self.assertRaises(roman.NotIntegerError, roman.toRoman, 0.5) class FromRomanBadInput(unittest.TestCase): """test fromRoman with a variety of bad inputs""" def testTooManyRepeatedNumerals(self): """test fromRoman with too many repeated numerals""" for s in ('MMMM', 'DD', 'CCCC', 'LL', 'XXXX', 'VV', 'IIII'): self.assertRaises(roman.InvalidRomanNumeralError, roman.fromRoman, s) def testRepeatedPairs(self): """test fromRoman with repeated pairs of numerals""" for s in ('CMCM', 'CDCD', 'XCXC', 'XLXL', 'IXIX', 'IVIV'): self.assertRaises(roman.InvalidRomanNumeralError, roman.fromRoman, s) def testMalformedAntecedent(self): """test fromRoman with malformed antecedents""" for s in ('IIMXCC', 'VX', 'DCM', 'CMM', 'IXIV', 'MCMC', 'XCX', 'IVI', 'LM', 'LD', 'LC'): self.assertRaises(roman.InvalidRomanNumeralError, roman.fromRoman, s) #------------------ #Define test suites #------------------ def toRoman(): """make test suite for all toRoman test cases""" return unittest.TestSuite( \ map(unittest.makeSuite, (ToRomanKnownValues, ToRomanBadInput))) def fromRoman(): """make test suite for all fromRoman test cases""" return unittest.TestSuite( \ map(unittest.makeSuite, (FromRomanKnownValues, FromRomanBadInput))) def knownValues(): """make test suite for all known values test cases""" return unittest.TestSuite( \ map(unittest.makeSuite, (ToRomanKnownValues, FromRomanKnownValues))) def badInput(): """make test suite for all bad input test cases""" return unittest.TestSuite( \ map(unittest.makeSuite, (ToRomanBadInput, FromRomanBadInput))) def all(): """make full test suite for all of roman.py""" sanity = unittest.makeSuite(SanityCheck) return unittest.TestSuite((sanity, toRoman(), fromRoman())) #------------------- #Define test program #------------------- class TestProgram(unittest.TestProgram): USAGE = """\ Usage: romantest.py [options] [test] Options: -h, --help print this usage summary -v, --verbose print test case descriptions while testing -q, --quiet print nothing while testing testname in ('all', 'toRoman', 'fromRoman', 'knownValues', 'badInput', 'SanityCheck', 'ToRomanKnownValues', 'FromRomanKnownValues', 'ToRomanBadInput', 'FromRomanBadInput') if none specified, defaults to 'all' Examples: %(progName)s - run all tests %(progName)s -v toRoman - run toRoman test suite with verbose output %(progName)s -q SanityCheck - run sanity check with minimal output """ if __name__ == "__main__": TestProgram(defaultTest="all") #--end of romantest.py From sholden at holdenweb.com Mon Apr 9 18:31:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Apr 2001 18:31:45 -0400 Subject: Windows Win32 API Interface? References: <3ad22f43_3@news4.newsfeeds.com> Message-ID: "Dry Ice" wrote in message news:3ad22f43_3 at news4.newsfeeds.com... > One of the charms of Visual Basic is the > ability to call the Win32 API with relative > simplicity. > > Does Python offer this ability? > Python as developed by Guido et al, no. Python with Mark Hammond's win32 extensions, definitely yes. Take a look at www.activestate.com - they provide an ActivePython distribution which includes those extensions, and I believe you can also download a build of the extensions only. regards Steve From syring at email.com Wed Apr 25 08:49:15 2001 From: syring at email.com (Karl M. Syring) Date: Wed, 25 Apr 2001 14:49:15 +0200 Subject: win32ras still broken? References: <3AE6BCCA.1040606@ActiveState.com> Message-ID: <9c6h6h$cfkji$1@ID-7529.news.dfncis.de> "Mark Hammond" schrieb im Newsbeitrag news:3AE6BCCA.1040606 at ActiveState.com... > Bill Tolbert wrote: > > > A few weeks ago someone mentioned that win32ras was giving an api_error, > > "The buffer is invalid". I just pulled the latest win32all build 138 from > > ActiveState and I'm still getting the error. > > > I didn't see that post. There have been no recent changes to > win32ras, but the Dial function works fine for me. Well on ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on win32 we have win32ras.EnumEntries() which gives pywintypes.api_error: (632, 'RasEnumEntries', 'The structure size is incorrect.' Duh! Karl M. Syring From paulp at ActiveState.com Wed Apr 11 13:49:41 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 11 Apr 2001 10:49:41 -0700 Subject: call of non-function (type string) error References: <20010411152524.94347.qmail@web10308.mail.yahoo.com> Message-ID: <3AD49935.AAAC7293@ActiveState.com> Graham Guttocks wrote: > > ... > >>> CIPHER = "DES3" > >>> import Crypto.Cipher > >>> cipher = getattr(Crypto.Cipher, CIPHER) > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: DES3 As Andrew pointed out this is an annoying corner case where you probably do have to use exec. I'm not really thrilled with all of these corner cases in Python's package handling. On the other hand, once you have the module object you can use getattr to get the "new" function out of the module. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From just at letterror.com Mon Apr 23 11:08:11 2001 From: just at letterror.com (Just van Rossum) Date: Mon, 23 Apr 2001 17:08:11 +0200 Subject: [Python-Dev] Class Methods References: <027401c0c9ab$5e3c88f0$e000a8c0@thomasnotebook> <200104201626.LAA06384@cj20424-a.reston1.va.home.com> <3AE32257.C75E01FB@letterror.com> <9c1d73$b84qa$1@ID-59885.news.dfncis.de> Message-ID: <3AE4455B.EB2FEAC@letterror.com> Thomas Heller wrote: > > "Just van Rossum" wrote ... > > I once proposed (and implemented as an extension to the metaclass hook) > > this: > > > > class Foo: > > __class__ = WeirdClass > > > > I still don't think that's all that bad, especially since it screams > > magic at you... > > Is your code available somewhere? No, but I just found the patch in my archives. It's probably against 1.5.2, so might not even apply to 2.x. I've pasted it below. Just - - - - - 8< - - - - - - - - - - - - - *** ceval.c Tue Dec 1 05:44:30 1998 --- jmetapatch/ceval.c Tue Dec 1 05:44:12 1998 *************** *** 2672,2681 **** --- 2672,2738 ---- if (!PyString_Check(name)) { PyErr_SetString(PyExc_SystemError, "build_class witn non-string name"); return NULL; } + /* __BEGIN__ of Just's Hook + + Guido's metahook is defined as follows: + - if one of the bases has a __class__ attribute (but is + itself not a class!), call that thing with (name, + bases, methods) + In addition I propose almost the opposite: + - if the "methods" dict (__dict__ from the Python + perspective) has a __class__ key, call that thing with + (name, bases, methods) + + This means that metaclasses are not special anymore, and + you have to specify a metaclass *explicitly* to get meta + behaviour. Example: + + class Foo: + __class__ = MyMetaClass + + as apposed to + + MyMeta = MyMetaClass("MyMeta", (), {}) + + class Foo(MyMeta): pass + + as it is with Guido's hook. + + Reasons for this new hook: + - Guido's hook abuses inheritance syntax, making it + impossible to inherit from metaclasses without special + trickery. + - implementing Meta stuff seems cleaner. Or maybe it's + just me... + + At first I thought Guido's hook would not be compatible with + mine, but they work together beautifully: inheritance works + just like you would expect. + */ + { + PyObject *callable = NULL; + callable = PyDict_GetItemString(methods, "__class__"); + if (callable) { + PyObject *args; + PyObject *newclass = NULL; + PyDict_DelItemString(methods, "__class__"); + args = Py_BuildValue( + "(OOO)", name, bases, methods); + if (args != NULL) { + newclass = PyEval_CallObject( + callable, args); + Py_DECREF(args); + } + return newclass; + } else { + PyErr_Clear(); + } + } + /* __END__ of Just's Hook */ n = PyTuple_Size(bases); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(bases, i); if (!PyClass_Check(base)) { /* Call the base's *type*, if it is callable. From dontspamsetzer at nwlink.com Mon Apr 30 01:21:50 2001 From: dontspamsetzer at nwlink.com (Matt Setzer) Date: Sun, 29 Apr 2001 22:21:50 -0700 Subject: drives in a file chooser References: <3aecd342$0$39601$6e49188b@news.goldengate.net> Message-ID: <3aecf663$1_2@news.nwlink.com> I don't think there's a way to do it from the os module, but if you've got the win32 extensions installed this should do it : from win32file import GetLogicalDrives def GetDrives() : "Returns a list of valid drives on this system, in order" drives = [] driveMask = GetLogicalDrives() for i in range( 0, 31 ) : if driveMask & ( 1 << i ) : drives.append( chr( ord( 'a' ) + i ) ) return drives Matt Setzer "Volucris" wrote in message news:3aecd342$0$39601$6e49188b at news.goldengate.net... > Is there a way to get a list of the drives available (on win32: c:, a:, b:, > d:, etc.)? Ultimately, I want to make a file chooser in a Tkinter app. > Desperatly I tried > > os.listdir(os.path.abspath('c:\\..')) > > but that does nothing useful. Otherwise, I could just confine my users to a > single drive and say it's a security feature. > > greg > > From vanharen at cycletime.com Fri Apr 6 03:40:50 2001 From: vanharen at cycletime.com (Jeremy R Van Haren) Date: Fri, 06 Apr 2001 07:40:50 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <995o0u$itc$1@news.mathworks.com> <0oodbtgdgc3tv452iiqs29n2rd3534dc2k@4ax.com> Message-ID: <3ACD7301.D812BEF9@cycletime.com> Michael Hudson wrote: > > Tim Roberts writes: > > > Joshua Marshall wrote: > > > > > >A switch statement may just be syntactic sugar, but not necessarily in > > >a simple way. A good compiler will compile switch statements into > > >jump-tables or, at worst, binary searches. Cluttery to code by hand. > > > > > >Sure this is "just" an efficiency thing, but switches can get quite big. > > > > But Python, at least today, is not compiled. > > Yes it is (at least in this context). > > > Switch statements in an interpreted language are not as big of a > > "win". > > There's no reason that the bytecode compiler couldn't do binary search > jiggery-pokery, although if I was doing it, I'd probably use a > dictionary. > > Cheers, > M. > > -- > MGM will not get your whites whiter or your colors brighter. > It will, however, sit there and look spiffy while sucking down > a major honking wad of RAM. -- http://www.xiph.org/mgm/ Actually, switch "implementation" above that uses dictionary's which is hashed. So a supported switch statement should be able to do hash as well. From fgeiger at datec.at Sat Apr 7 03:37:36 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Sat, 7 Apr 2001 09:37:36 +0200 Subject: Anyone able to compare the commercial IDEs available? References: <9akseh$ncs$1@newsreaderm1.core.theplanet.net> <9ame63$fg4$1@newsreaderm1.core.theplanet.net> Message-ID: <9amg6d$gco$1@newsreaderm1.core.theplanet.net> > it did was to tell me that it did not find the license file. Seems that it Stupid me, I simply got lost in their new website structure... You have to subscribe, then to sign in again, then to view your account where you find a Komodo License installer. Download it, install it, and everything's o.k. again... Best reagrds Franz "Franz GEIGER" wrote in message news:9ame63$fg4$1 at newsreaderm1.core.theplanet.net... > > I'm not sure what you mean by "commercial". Komodo is Open Source, > > Yesterday I downloaded Komodo 1.0 (seems just being released) and the first > it did was to tell me that it did not find the license file. Seems that it > was Open Source as it was in beta state... > > Regards > Franz > > "Moshe Zadka" wrote in message > news:mailman.986622789.16473.python-list at python.org... > > On Fri, 6 Apr 2001, "Franz GEIGER" wrote: > > > > > I'm aware of three commercial IDEs for Python: > > > -- PythonWare > > > -- BlackAdder > > > -- Komodo > > > > I'm not sure what you mean by "commercial". Komodo is Open Source, > > so why didn't you list IDLE and PythonWin too? > > > > In any case, there's also WingIDE. > > > > -- > > "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than > Python? > > looking for someplace else to grab power."|YODA: No...no... no. Quicker, > > -- Wichert Akkerman (on debian-private)| easier, more seductive. > > For public key, finger moshez at debian.org > |http://www.{python,debian,gnu}.org > > > > From glenfant.nospam at bigfoot.com Tue Apr 3 05:41:24 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Tue, 3 Apr 2001 11:41:24 +0200 Subject: CGI script to count downloads References: <3AC95ECE.B8F5E93E@cosc.canterbury.ac.nz> Message-ID: <9ac5k2$2389$1@news5.isdnet.net> Isn't it easier to include this count in a more general site statistics features that parses your web server's log (eg use some kind of Webaliser). Gilles "Greg Ewing" a ?crit dans le message news: 3AC95ECE.B8F5E93E at cosc.canterbury.ac.nz... > I'm trying to write a script that will keep a count > of the number of times a file is downloaded. So far, > the script just takes the name of the required file, > opens the file, and passes on its contents. > > It works fine, except for one annoying thing: > When Netscape pops up the box requesting a file > name for saving, the default filename seems to be > constructed in a screwy way from parts of the > URL. For instance, if the URL used to retrieve the > file is > > download.py?file=download/akaroa2.6.1doc.tar.gz > > then the default filename that Netscape gives me > is > > akaroa2.6.1doc.tar.py > > So, my question is, can I put anything in the > headers of the response to give the browser a > hint as to what name the file should be saved > under? > > Or is there a better way of going about this > whole counting business? > > This is the script I'm using: > > #!/usr/local/cosc/bin/python > print "Content-Type: compressed/gzip" > print > import cgi, sys > form = cgi.FieldStorage() > path = form["file"].value > f = open(path) > sys.stdout.write(f.read()) > f.close() > > -- > 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 panix.com Sun Apr 22 15:19:07 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Apr 2001 12:19:07 -0700 Subject: Python-2.1(Windows) Optional supproject build problems References: Message-ID: <9bvarb$i0o$1@panix2.panix.com> In article , Tim Peters wrote: > >when-you-think-for-yourself-you-get-to-solve-the-problems-you-create- > for-yourself-too-ly y'rs - tim .sigfile! -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Beware of companies that claim to be like a family. They might not be lying." --Jill Lundquist From nhodgson at bigpond.net.au Sun Apr 22 17:49:49 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Sun, 22 Apr 2001 21:49:49 GMT Subject: ActivePython 2.1 (build 210) References: <007501c0cb74$06080e50$d938a8c0@Hadfield> Message-ID: <1mIE6.8027$ff.64619@news-server.bigpond.net.au> Mark Hadfield: > 1. The quotes are not necessary. > > 2. Adding the quotes does no harm for standard Windows path-searching > applications, eg cmd.exe & the Run dialogue box I had some trouble with the quoted path on W2K as well. Can't remember the details as I was rushed trying to get something else to work at the time, but removing the quotes was one of a set of things done which fixed the problem. Not a high quality fault report but ActiveState should be aware that there could be some problems here. Neil From hannah at schlund.de Thu Apr 26 09:34:38 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 26 Apr 2001 15:34:38 +0200 Subject: Python Performance vs. C++ in a Complex System References: <20010422105252.B5762@mozart.chat.net> Message-ID: <9c985e$753$1@c3po.schlund.de> Hello! In article , Gabriel Ambuehl wrote: >[...] >That's what I thought. As long as you aren't a good programmer able to >play with poll()/select() while a sleep, the whole network >programming, if it comes down to speed, is horrible to do. Dunno. For me, programming always new select() based main loops wasn't *too* difficult. However, after factoring out some common code in a C++ basis, writing reactive network servers got even easier, still without the overheads of pthreads. Of course, it's even neater to do that with a thread abstraction with a lightweight implementation, such as stackless python is supposed to be (or Erlang, or SML/NJ's CML implementation, or ...). >[...] >Threading in either C or C++ is a major PITA. Since the compiler >doesn't take complete care of the memory management, you can do >serious fuck ups with threads (and as we all know, buffer overflows >are common even in normal apps). That, and also, at least I like a message based threading model much more, however, I ran into major deadlocks when trying to do that in C/pthreads once, and rewrote it to do shared accesses on the data structures, protected by locks. Probably I've done too much Erlang lately *g* >[...] Kind regards, Hannah. From e_tsang at trillium.com Wed Apr 18 18:22:27 2001 From: e_tsang at trillium.com (Tsang, Edward1) Date: Wed, 18 Apr 2001 15:22:27 -0700 Subject: queston with glob!! Message-ID: Thanks for your pointer, but after reading the doc. I do not undertstand what it means .. def func1(): import os.path, glob os.path.walk(currentDir,self.buildFileList,fileList) fileList = glob.glob(currentDir+os.sep+'*') return fileList def func2(): listDir = os.listdir('.') fileList = [] fileList = self.buildFileList(listDir,fileList) Then I should expect fileList containing all the files with the full path names ... But I have got the following error: File "/sd/ps/alexma/proj/ntharn/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ File "/la02/qa/etsang1/ts/9005016/modules/gui/msggen.py", line 246, in openfile fileList = self.buildFileList(listDir,fileList) File "/la02/qa/etsang1/ts/9005016/modules/gui/msggen.py", line 233, in buildFileList os.path.walk(currentDir,self.buildFileList,fileList) File "/sd/ps/alexma/pyprefix/lib/python1.5/posixpath.py", line 262, in walk TypeError: string, list I think I do not undertstand the doc, especially confusing what the funciton visit is and what arguments to pass to it ... Can you give me some help?? -----Original Message----- From: Sean 'Shaleh' Perry [mailto:shaleh at valinux.com] Sent: Wednesday, April 18, 2001 2:58 PM To: EdwardT Cc: python-list at python.org Subject: RE: queston with glob!! > > There files inside these directories which I want ot search and store > recursively from the current diretory down deep to the lowest level of > subdirectory. > I use glob.glob(currentDir+os.sep+'*') > But this can only get me the subdirectory not the files down. If I want down > one more level, then I need to write this glob.glob(currentDir + os.sep + > os.sep +'*') > which is not a good approach as it is too rigid. > > How can I modify the code to search down to the deepest level? > look at the docs for os.path, specifically walk(). From fredrik at pythonware.com Fri Apr 6 13:04:15 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Apr 2001 17:04:15 GMT Subject: Booleans (was: Conditional operator in Python?) References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> <9aadjg$ipg$1@nntp6.u.washington.edu> <9acvud$uk6$1@nntp6.u.washington.edu> <3ACDF088.88E7406A@alcyone.com> Message-ID: Erik Max Francis wrote > This is true. I would be mollified if there were a builtin operator > that tests truth in the same way that if ...: does. It would be named > something like bool or boolean and would return a 0 or 1 and nothing > else. > > >>> bool(0) > 0 > >>> bool(3) > 1 > >>> bool('hello') > 1 > >>> bool('') > 0 > >>> bool([]) > 0 > >>> bool([1]) > 1 > >>> bool(None) > 0 >>> from operator import truth >>> truth(0) 0 >>> truth(3) 1 >>> truth('hello') 1 >>> truth('') 0 >>> truth([]) 0 >>> truth([1]) 1 >>> truth(None) 0 >>> print truth.__doc__ truth(a) -- Return 1 if a is true, and 0 otherwise. Cheers /F From mwh21 at cam.ac.uk Mon Apr 2 11:18:46 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Apr 2001 16:18:46 +0100 Subject: HOWTO restrict multiply inherited class to on sub-class References: Message-ID: lkcl at angua.rince.de (Luke Kenneth Casson Leighton) writes: > okay. c++ time. > > class Base > { > }; > > okay, i've forgotten my c++. c++ pseudo-code time :) > > class Base1 > { > }; > > class Inherited: public Base1, public Base > { > }; > > x = new Inherited(); > > y = (Base1*)x; > ^^^^^^^ > > how do you do _this_ in python? Don't. What does it buy you? Python doesn't really do data hiding. > i.e. i have a Database-access class that inherits from about > six separate sub-database classes. > > i want another class to have access to only ONE of the subsets > of functionality. Why? [...] > any clues, anyone? Try this: import types, new class Casted: def __init__(self, wrapped, klass): self.wrapped = wrapped self.klass = klass def __getattr__(self, attr): try: return self.wrapped.__dict__[attr] except KeyError: try: attr = getattr(self.klass, attr) except AttributeError: raise else: if type(attr) is types.MethodType: return new.instancemethod(attr.im_func, self.wrapped, attr.im_class) else: return attr def cast(inst, klass): return Casted(inst, klass) class Base1: def foo(self): print 1 class Base2: def bar(self): print 2 class Derived(Base1, Base2): pass Then: >>> d = Derived() >>> d.foo() 1 >>> d.bar() 2 >>> c = cast(d, Base1) >>> c.foo() 1 >>> c.bar() Traceback (most recent call last): File "", line 1, in ? File "", line 10, in __getattr__ AttributeError: class Base1 has no attribute 'bar' This doesn't (and can't) work on instance attributes - they don't really have a concept of which class they belong to. And if you thought the above looks hairy, so do I. I thought it would be simpler when I started... oh, and it might be wise to write self.__dict__['$wrapped'] where I wrote self.wrapped (& similar for klass) above, to avoid potential conflicts with these names in the wrapped instances. I hope you reconsider your need to do this, but if you don't, HTH. Cheers, M. -- Need to Know is usually an interesting UK digest of things that happened last week or might happen next week. [...] This week, nothing happened, and we don't care. -- NTK Know, 2000-12-29, http://www.ntk.net/ From dsh8290 at rit.edu Mon Apr 23 13:30:08 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 23 Apr 2001 13:30:08 -0400 Subject: bit by LONG_BIT (was Re: ActivePython 2.1 (build 210)) In-Reply-To: ; from sholden@holdenweb.com on Sun, Apr 22, 2001 at 02:04:22PM -0400 References: <000c01c0c958$141f6240$d938a8c0@Hadfield> <5f6rb9.ke1.ln@alltel.net> <3AE2316E.59CD5E96@student.gu.edu.au> <3AE2EB1B.3656F989@seebelow.org> Message-ID: <20010423133008.B13119@harmony.cs.rit.edu> On Sun, Apr 22, 2001 at 02:04:22PM -0400, Steve Holden wrote: | "Courageous" wrote ... | > | > Re: Cygwin | > | [ ... ] | > | > I've seldom had any problems. One thing which sucks is that there | > is no real support for ctrl-z/bg. You generally have to remember to | > & everything in advance. This has been so problematic for me that | > I keep a scripts to intercept certain frequently executed commands | > which sweeps up their arg lines and then calls the binary with an | > automatic & appended to it. | > | Well, if you insist on using tcsh it may be that you lack the job control | features. But using /bin/sh on my Win98 box I find that I can indeed | interrupt a task with ^Z and put it in the background with bg. I use bash under cygwin -- I see both situations. If the app is a cygwin app the job control works (including CPython 2.1!). If the app is a win32 app (no cygwin1.dll) the job control doesn't work (except ^C to kill it). BTW, where did you get a cygwin-aware gvim? I'd really like that. -D From grey at despair.rpglink.com Tue Apr 10 16:43:04 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 10 Apr 2001 20:43:04 -0000 Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> <3ad34bff.1635308863@News.CIS.DFN.DE> Message-ID: On Tue, 10 Apr 2001 18:12:44 GMT, costas at meezon.com wrote: >No dream here. There is an old adage that applies to IDE's just as >good as to people. >"Familiar of many, master of none" Not that it means anything to the majority of IT consumers. Compare the travisty called Outlook versus components that do the same thing. Ever know that ICQ has a PIM in it? In a great many cases, yes, specialization is a good thing. I completely agree with it. However, when it comes to things which are highly related to one another, IDE and languages, for example, I do not believe that specialization on one language over another would offer benefits far in excess of the ability to be able to work on a project which includes elements of different programming languages (C/C++ with embedded Python anyone?) without having to fire up several different tools to do so. Oddly enough this is called "integration" and is where the I, or Integrated, from IDE comes from. :P -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From pulsar at qks.com Fri Apr 20 23:05:53 2001 From: pulsar at qks.com (David Simmons) Date: Sat, 21 Apr 2001 03:05:53 GMT Subject: python on the smalltalk VM References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> Message-ID: Hi Folks, Let me clarify a few things (noting that similar information will be available sometime next week on the new www.smallscript.net site specifically on SmallScript and .NET). o SmallScript is a "superset" of existing dynamic language Smalltalk dialects (not a subset as was commented in quoted pages from SmalltalkConsulting). As was noted from the postings, SmallScript is not an IDE. It is a new language that extends existing Smalltalk language facilities. Its goals and technical foundations are derived from my experience over the last 10 years in developing QKS Smalltalk, virtual machines, cross platform frameworks, and (SmalltalkAgents) IDE technology. o SmallScript is *not* a superset (in any way) of existing Smalltalk frameworks -- which is where the superset/subset confusion probably comes from. It is a language and the required core/kernel framework to represent the universal object model, the SmallScript language, and the facilities needed to support the module linker/loader and compiler services. o The release date for a first public review version was changed from December of 2000 to July of 2001. o Smalltalkers should think about SmallScript as being a modular Smalltalk with many language extensions to support a wide range of features found in other popular languages which are not typically found in Smalltalk dialects. For those who have followed the evolution of QKS Smalltalk many of these features will be familiar. Many of these extended features are just exposing the AOS (Agents Object System) Platform's object model and metaprogramming and reflection facilities. o The AOS Platform execution engine, core object-model/language frameworks, and a corresponding SmallScript compiler will be free. The Microsoft.NET platform version of the SmallScript compiler and related .NET dynamic/scripting language libraries for .NET deployment will not be free. The .NET version will be available in a bundle with Microsoft's Visual Studio 7. o QKS will have other frameworks and probably one or more sets of tools for working with SmallScript. The "free" vs "commercially sold and maintained" status of these additional elements will be determined on a case by case basis. My personal goal is to foster community growth of the basic frameworks and services (including redundant/overlapping implementations). QKS commercial focus is primarily on vertical frameworks / domain specific frameworks (which may include the broad generic market for Microsoft.NET tools). o The SmallScript language is layered on top of a (unnamed) declarative XML language that reflects the AOS object model (basically it is simpler to view the XML language as part of SmallScript). As such, other languages can be implemented using the core frameworks parser and compilation frameworks. Work is being done in this area for Scheme, Python, and interest has been expressed for Basic, JScript/EcmaScript, and PHP. One of the notable features of this facility is the ability to write methods directly in SmallScript that consist of C, C++, and assembly -- hence there are *no* primitives. o The AOS Platform (v4) is a small, shared library execution engine with a hi-performance extensible jit architecture supporting a universal object model. The AOS Platform (v4) will be available for Win32 x86, Linux x86, and MacOSX PPC (other platforms are possible). The entire SmallScript system including compiler and frameworks can be deployed as a single DLL (on Win32) that is about 800kb that number includes its' 400kb or so of resources. The execution architecture is designed to support adaptive installation so it can be drag-installed or run directly without requiring any installation procedure (it has a variety of features to support integration into COM and automatic exposure of any class or object as a component -- theoretically this should be mappable to CORBA as well). The shared library model allows SmallScript code or similarly generated AOS code modules to be executed inside of existing processes and automatically integrates with the native pre-emptive threading model. Typical (total) execution time from launch to exit (including simple script compilation and execution) is on the order of 35-80ms depending on disk drive speed and processor speed. The smallest executable application one can produce using SmallScript on Win32 is something on the order 60 or so bytes of x86 machine code in the form of a couple kb .EXE file. Typical asynchronous foreign function calling (in or out) is measured in 10's of millions of calls per/second including the dynamic/adaptive marshalling and exception management for calling through mechanisms such as COM/ActiveX, etc (which the JIT optimizes). The AOS platform's object model supports dynamic languages and typing that includes a full type architecture, concrete and abstract interfaces (mixins), namespaces, closures, continuations, unified string/character model (for NLS/Unicode/CodePages/etc), and multi-method dispatch (method selection based on type overloading of arguments). ** The comments on the compilation of large Smalltalk images are based on numbers taken from builds of the kernel system and auxilliary modules. The SmallScript compilation+module build rate is somewhere around 1 million lines per minute; numbers are significantly higher for just processing object model code or generating parse trees for syntax coloring. The SmallScript compiler is written in (itself) SmallScript. -- Dave Simmons QKS Smalltalk - SmallScript "Keith Ray" wrote in message news:k1e2i3t4h5r6a7y-D8B8D8.09114419042001 at news... > In article , "Chris > Gonnerman" wrote: > > > ----- Original Message ----- > > From: "Andrew Dalke" > > Subject: python on the smalltalk VM > > > > > > > http://www.smalltalkconsulting.com/html/SmalltalkSolutions2001%232.html > > > > This URL appears dead to me... is there an alternate location? > > I don't have a problem loading the URL > > > Here is a snippet from that page: > > After the break I attended the Building COM and .NET in SmallScript ? by > David Simmons for a few minutes > > About 70 people in attendence. Standing room only. > > David talked about his Smallscript goals, he then launched into an > explanation of how Smallscript is build by showing us the source code. > If you were a Microsoft developer this would have been very interesting, > and it is interesting to see how it all interfaced to the existing MS > framework for development. > > David's take is that Smalltalk is built wrong for scripting, it has a > monolithic image. It really should be a bunch of Smalltalk pieces. > Smallscript isn't a Smalltalk traditional image. It's the best features > of the language but changed for doing scripting. > > SmallScript is small, it is free, it's not an IDE. It's a compiler and > execution engine. Someone else needs to build an IDE and frameworks, QKS > may build a simple IDE but these aren't an important part of their > research. Smallscript like all scripting languages is text based just > tackle it with your emac editor. > > Someone asked what is the revenue model for QKS? > It's not tools (We all know that today, look around how many tools > companies are there?) > Consulting is a big part > Microsoft is a big part. > Python is a big part for the execution engine, this is a new area. The > Smalltalk VM runs Python 10 to 100x faster. {JMM I should point out the > Perl and Python folks are working toward having/wanting/needing a > universal VM} > > SmallScript is subset of Smalltalk dialects, not of the frameworks. You > can migrate frameworks, and it has a lot of features for foreign > function interoperability. > > David then moved on within his slides and talked about the files you > need to support Smallscript. The point being there are only a few small > files required. > > He then brought up the VisualStudio project for building this and > explained how the VM starts and worked us thru what happens when the VM > launches. The execution path is very short and took about 85ms on this > machine, thus 12 executions a second. A more optimized VM, this was a > test VM, would run faster. However David pointed out on a heavier loaded > machine you could have at least a 30ms variation in startup times > because of system load. But the key point here was that you can run a > lot of individual scripts per second if required. > > Later at lunch David pointed out that perhaps it wasn't clear in the > presentation that the entire image is built from the class definitions > at startup, there is NO image. It's all built from the definitions > really really fast. On termination a module can decide if it must save a > persistent state, which could be loaded on restarting. In fact If I > recall correctly he say that a rather large smalltalk image would be > built by the engine in less than 6 seconds. From nothing to a known > state on each startup, this is a important concept. > > On-ware to DLL hell, well maybe not. .Net get out of this problem > domain. Components are self describing and have versioning which allows > you to resolve all the requirements to run an application and to move > things around without harming the application. Smallscript allows you to > build small DLLS which are compiled very quickly. Smallscript takes the > strengths of Smalltalk, it's a simple grammar it's untyped. And it's > easy to refactor and change versus C or C++. In Smalltalk it was hard to > deal with the outside, handing a Smalltalk object to an external DLL > is/was an adventure. In .Net it just gets passed, no wrapping or > marshalling etc. > > Alas at this point I had an errand to run. > > -- > From aleaxit at yahoo.com Tue Apr 24 09:17:24 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Apr 2001 15:17:24 +0200 Subject: Python Graphics Libraries? References: <3aec6835.990663@news.newsguy.com> Message-ID: <9c3ud201hao@news1.newsguy.com> "Owen F. Ransen" wrote in message news:3aec6835.990663 at news.newsguy.com... > Python Graphics Libraries? Are there any? BMP or Vector? PIDDLE, aka SPING, http://piddle.sourceforge.net/, is a nice simple graphic front-end with many back-ends so you can easily 'draw' on different output libraries (GUI's, PDF files, images, ...). Alex From stephen_purcell at yahoo.com Thu Apr 19 11:47:07 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 19 Apr 2001 17:47:07 +0200 Subject: Is there a string function that will tell me... In-Reply-To: ; from terrence@mactexas.com on Thu, Apr 19, 2001 at 02:51:51PM +0000 References: Message-ID: <20010419174707.C11612@freedom.puma-ag.com> Terrence Spencer wrote: > In the Foxpro language the is a function called: > > AT(SearchingFor,StringToSearch,Count) > > So if I want to find out what location the 3rd "e" is in the string > "terrence" I would say: > > ?at("e","terrence",3) > > and that would return 7, the location of the 3rd "e". To find the first, use the standard function string.find :- >>> import string >>> s = "Municipal Advisory Council of Texas" >>> string.find(s, "Texas") 30 >>> To find the nth occurrence, roll your own function :- >>> def findnth(s, substr, count): ... pos = -1 ... for i in xrange(count): ... pos = string.find(s, substr, pos+1) ... if pos == -1: break ... return pos ... >>> findnth(s, 'i', 3) 13 >>> >>> findnth("terrence", "e", 3) 7 -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From mal at lemburg.com Wed Apr 25 17:15:58 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 25 Apr 2001 23:15:58 +0200 Subject: ANN: mxNumber -- Experimental Number Types, Version 0.2.0 Message-ID: <3AE73E8E.E9152718@lemburg.com> ANNOUNCING mxNumber - Version 0.2.0 Python Interface to GNU MP Number Types INTRODUCTION ------------ As you all know, Moshe Zadka has been pushing for a new rational number type recently (at the conference) and also implemented a proof- of-concept implementation of his rational PEP 239. Since the GNU Multi-Precision Lib (GMP) already has all these tools providing what people want most when it comes to numbers (precision and speed), I thought that wrapping these as Python types would be a good idea. I know that Alex Martelli has been working on a similar approach, but that project (gmpy) seems to be inactive. Anyway, even though the GMP is available for most Unix platforms and MacOS, there was no relyable port for Windows. This was a show- stopper for me, so I decided to port GMP to Windows, which was harder than I thought, but well, it's done now. There's still no web-page for this package, so I'm providing the needed information in this posting. WHAT'S NEW ? ------------ The 0.2.0 release is an alpha release. Everything is still in flux, so expect bugs, strange behaviour etc. Still, the package provides some interesting insights into the issues you run into when dealing with computational representations of numbers. For now, you should consider the package a pure fun-package and playground for experiments. New in this release are a parser for rational strings (formats "1/2" and "3 1/3"), plus a new constructor FareyRational() which was inspired by an algorithm written by Scott David Daniels and posted to the Python Cookbook; see http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52317 The FareyRational() constructor allows you to convert floating point numbers to rationals, e.g. 1.3333 to 4/3. INTERFACE --------- The package is part of the eGenix.com EXPERIMENTAL package and called mx.Number. It provides access to three numerical types: 1. Integer(value) -- arbitrary precision integers much like Python long only faster 2. Rational(nom,denom) -- rational numbers with Integers as numerator and denominator 3. Float(value[,prec]) -- floating point number with at least prec bits precision 4. FareyRational(value, maxden) -- calculate the best rational represenation n/d of value such that d < maxden DOWNLOADS --------- * GMP 3.1.1 - Unix: GMP 3.1.1 must be installed (http://www.swox.com/gmp/) - Windows: GMP 3.1.1 is included in the download archives for Windows * Python 2.1 * Optional: egenix-mx-base package available from http://www.lemburg.com/files/python/ * The "egenix-mx-experimental" package which includes mx.Number: Source: http://www.lemburg.com/files/python/egenix-mx-experimental-0.2.0.zip RPM: http://www.lemburg.com/files/python/egenix-mx-experimental-0.2.0-1.i386-py2.1.rpm Windows installer: http://www.lemburg.com/files/python/egenix-mx-experimental-0.2.0.win32-py2.1.exe Usage is simple: ---------------- from mx.Number import * f = Float(3.141) r1 = Rational(3.141) r2 = Rational(2, 3) r3 = FareyRational(1.33333, 1000) i = Integer("1231231231231231231231231") The coercion model will (someday) look like this: Float ^ | --------> Python float | ^ | | | Rational | ^ | | Python long -----> Integer ^ ^ | | -------- Python integer Complex numbers are not integrated into the picture since I think that they should not be auto-coerced. Some of these arrows are not implemented yet, others are not shown (e.g. Integer(2) + "3" works as one would expect ;-). Note that this is still a very rough version. Feedback is welcome. QUESTIONS --------- * What do you think about this coercion model ? Shouldn't we have a PEP for this ? * Please try out the rational type and see if it fits your needs -- the results are sometimes surprising (due to the IEEE representations of floats); I'm sure this proof of concept will raise a few more questions regarding the usefulness of switching to rationals for literals like 1.123. * This implementation also showed that even though the coercion patches have made integraton of numerical types easier, a full integration is still hard to achieve. Some issues: - string formatting cannot be "overridden" to allow formatting of these new types - there is no way of providing PyArg_ParseTuple() parser markers for the types - there is no way to bind the types to a Python literal, e.g. by specifying a number literal modifier which is then bound to the type: 1234L -> long("1234"), 1234.123F -> Float("1234.123"), 2R / 3 -> Rational(2, 3) etc. Comments ? -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From carlcrewe at aol.com Sun Apr 22 20:09:09 2001 From: carlcrewe at aol.com (CarlCrewe) Date: 23 Apr 2001 00:09:09 GMT Subject: Tkinter and wxPython References: Message-ID: <20010422200909.07202.00000394@ng-cb1.aol.com> VB, VC++ and Delphi are window's big environments on windows. I have never tried this but in "Python programming on Win32", O'Reiley, they have used the Delphi RAD tools to build python code. From stephen_purcell at yahoo.com Wed Apr 18 05:31:49 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 18 Apr 2001 11:31:49 +0200 Subject: reading empty input In-Reply-To: <3add5c72_4@goliath.newsfeeds.com>; from jblazi@hotmail.com on Wed, Apr 18, 2001 at 11:06:12AM +0200 References: <3add5c72_4@goliath.newsfeeds.com> Message-ID: <20010418113149.A7330@freedom.puma-ag.com> Janos Blazi wrote: > a=-1 > while a!="empty": > a=input() > if "a!=empty": > > this is pseucode of course. The while loop should run until the user > responds to the input prompt by the enter key (and no real input) > > How can I do this? Have I to use raw_input? Yes: def command(s): print "command:", s while 1: a = raw_input() if not a: break command(a) print "finished" -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From tim.one at home.com Thu Apr 19 10:57:57 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 19 Apr 2001 10:57:57 -0400 Subject: Python 2.1 for Cygwin does not "threading" In-Reply-To: <9bmnhq$2dck$1@news5.isdnet.net> Message-ID: [Gilles Lenfant] > I just made an update of my cygwin tools and noticed a new python > distro available for cygwin. Yup! Thanks to Jason Tishler, 2.1 Python compiles out of the box for Cygwin. > But the threading stuff don't work! > > Is it a "bug" or a feature ? Neither. Cygwin pthreads isn't ready for prime time yet, so the Cygwin Python is compiled without thread support for now. See the NEWS file in Python's source distribution for other known Cygwin glitches. From grante at visi.com Mon Apr 2 16:42:12 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 02 Apr 2001 20:42:12 GMT Subject: Results not quite what I expected References: <9aangq$enl$1@panix2.panix.com> Message-ID: In article <9aangq$enl$1 at panix2.panix.com>, Aahz Maruch wrote: >>> I tried your suggestion, and I am close, but not quite. What >>> is happening with the number split? >> >>Ripping off somebody's apt observation: >> >> A programmer has a problem. He decides to use a regular >> expression. Now he has two problems. :) > >That's a paraphrase and unattributed. Here's the correct version, from >my quotefile: > > 'Some people, when confronted with a problem, think "I know, I'll use > regular expressions". Now they have two problems.' --Jamie Zawinski, > comp.lang.emacs Thanks. I figured it was c.l.p where I saw that. -- Grant Edwards grante Yow! .. I want a COLOR at T.V. and a VIBRATING BED!!! visi.com From paulp at ActiveState.com Sun Apr 1 00:26:18 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 31 Mar 2001 21:26:18 -0800 Subject: PythonLabs Team Moves to ActiveState References: Message-ID: <3AC6BBFA.9E65B634@ActiveState.com> Guido van Rossum wrote: > > PythonLabs Team Moves to ActiveState > ALL YOUR LANGUAGES ARE BELONG TO US. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From sholden at holdenweb.com Tue Apr 17 20:49:31 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 17 Apr 2001 20:49:31 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: "Douglas Alan" wrote in message news:lc7l0j6u6h.fsf at gaffa.mit.edu... > "Alex Martelli" writes: [ ... ] > > As you seem totally unwilling or unable to understand that > > Weltanschauung to any extent, I don't see how you could bring Python > > any constructive enhancement (except perhaps by some random > > mechanism akin to monkeys banging away on typewriters until 'Hamlet' > > comes out, I guess). > > $#@# you too. You are very rude. > Rude, perhaps, but not usually abusive. *Please* resist the temptation to post in this vein in future. this-newsgroup-has-a-happy-flavor-because-we-work-at-it-ly y'rs - steve From aleaxit at yahoo.com Mon Apr 2 07:58:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Apr 2001 13:58:32 +0200 Subject: list vs tuple References: +ADw-mailman.986154903.21843.python-list+AEA-python.org+AD4- +ADw-62Mx6.1152+ACQ-p5.4531+AEA-news1.rivrw1.nsw.optushome.com.au+AD4- +ADw-slrn9cg648.7dt.wtanksle+AEA-dolphin.openprojects.net+AD4- Message-ID: <9a9pim02qi6@news2.newsguy.com> "deadmeat" wrote in message news:ivXx6.1192$p5.4652 at news1.rivrw1.nsw.optushome.com.au... > > They're called lists, not arrays. > > So what other term applies to tuples and lists? They're both arrays, given > a Pythonic twist. "Sequence" is the term used in the Python documentation to describe the commonalities between tuples, lists, arrays, and other data structures yet which conform to the same interface. The term 'array', in core Python, denotes of course a different kind of sequence: see standard module 'array'. The same term is also used in Numeric Python to describe yet another kind of data structure, closest to the 4/5 meanings you quote. Alex From paulp at ActiveState.com Fri Apr 13 16:11:25 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 13 Apr 2001 13:11:25 -0700 Subject: Pythonwin interactive window editing? References: <3AD7560F.9FFDB567@hotmail.com> Message-ID: <3AD75D6D.259D2DC0@ActiveState.com> scott wrote: > > Just installed Pythonwin (ActivePython build 202) on NT4. Seems very > nice so far except... I'm curious: if you just installed, why didn't you install build 203, which is newer? > Previously (an hour ago) I used the history feature of IDLE 0.6 that > came with BeOpen Python 2.0 to recall previous commands (Alt-p etc). Is > something like this available in the Pythonwin interactive window? Use your up and down arrow keys and then hit "enter" when you get to the line you want to reuse. >... > P.S. > On a related note, I can't seem to use IDLE anymore. I tried to start > c:\Python20\Tools\IDLE\idle.pyw > I got an error message (unable to locate DLL tk83.dll). Sure enough, > this isn't on my system. > Is IDLE supposed to work using Pythonwin? The solution is described here: http://www.activestate.com/ASPN/Downloads/ActivePython/Extensions/ But it is geared towards ActivePython build 203! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From me at nospam.net Thu Apr 5 02:07:13 2001 From: me at nospam.net (Scottie) Date: Wed, 4 Apr 2001 23:07:13 -0700 Subject: A couple garbage collector questions References: Message-ID: "Tim Peters" wrote in message news:mailman.986419387.4136.python-list at python.org... >...Sure, depending on the size of the integer. But Python uses C's "int" type > for refcounts, and offhand I don't know of any platform on which read or > write of a C int is interruptible.... a non=naturally aligned int may straddle a page boundary, and a page fault on half of the store might happen. I'm not sure all memory refrains from the write until both pages are updatable. If so, the page fault can escelate to a deschedule which can..... -Scott David Daniels From robin at jessikat.fsnet.co.uk Thu Apr 12 05:11:24 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 12 Apr 2001 10:11:24 +0100 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> Message-ID: In article , Neal Norwitz writes OK I switched to the CVS latest and it seems better. I'm still getting the messages from imported modules rather than the real one ie c:\python\reportlab\graphics\widgetbase.py:0 No __init__() in subclass (LinePlotProperties) c:\python\reportlab\graphics\widgetbase.py:1 No module doc string here widgetbase is imported by lineplot, but the above errors are certainly for linplot.py itself. I'm also getting a warning about not calling the base class even when I have got an apply(BASE.__init__,.....) I suppose this is more difficult than the straight call. -- Robin Becker From skoer at adams.com Mon Apr 9 09:24:02 2001 From: skoer at adams.com (Stephan Koerner) Date: Mon, 09 Apr 2001 09:24:02 -0400 Subject: Hello, C to Python ( .c -> .py)? Message-ID: <3AD1B7F2.38F908CF@adams.com> Hello, I have been using a home grown scripting utility which, in essence, is a 'C' interpreter (Subset of ANSI C). I would like to move away from this utility in favor of using Python. To complete this task I wish to convert the legacy 'C' based scripts to .py files. Has anyone tried converting 'C' to Python? Any comments would be appreciated thanks, Stephan -- From skip at pobox.com Thu Apr 5 13:34:52 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 5 Apr 2001 12:34:52 -0500 (CDT) Subject: A couple garbage collector questions In-Reply-To: <9ahr7g$3ar$1@c3po.schlund.de> References: <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> <9ahr7g$3ar$1@c3po.schlund.de> Message-ID: <15052.44220.905908.97670@beluga.mojam.com> >>> Reference-counting exacts very heavy performance costs, no matter >>> what you back it up with. Hannah> Correct. *Except* if the compiler does heavy optimization of Hannah> reference count updates (i.e. if you can prove that some basic Hannah> block just increases the RC, later decreases it, having a net Hannah> effect of +- 0, you can drop both RC updates, and so on). This is unlikely to happen in practice. A basic block consists of a straightline piece of code containing no branches. There's no reason to increment a reference count and decrement it within the same basic block, since the object's reference count can't be decremented to zero by some other piece of code. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From michael at stroeder.com Mon Apr 30 13:04:12 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 30 Apr 2001 18:04:12 +0100 Subject: Revised Python job survey References: Message-ID: <3AED9B0C.3F8A36F2@stroeder.com> "Clark C . Evans" wrote: > > This way you can tell your management, well I only got 20 > respondants who said they'd move to LA to code in Python. Maybe your main problem is to find people who are willing to relocate to LA. ;-) Ciao, Michael. (3 years of Python experience now) From whisper at oz.nospamnet Sun Apr 22 13:58:54 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 22 Apr 2001 17:58:54 GMT Subject: socket timing problem References: <3ADCE798.118B113D@mediaone.net> <180420012047095504%timo@alum.mit.edu> <9bpgpe029i6@news1.newsguy.com> Message-ID: <9bv64u$2he$2@216.39.170.247> In article , db3l at fitlinxx.com says... > "Alex Martelli" writes: > FWIW, it was reported on comp.lang.tcl that NT4.0sp4 introduced some breakage in the tcp/ip stack that was fixed in a subsequent service pack. Dave LeBlanc > > I've used it successfully (with my changes as incorporated) > > under NT4 SP6 (I do have a recent 'Platform SDK' installed, > > but I don't think it changes anything in this regard). > > Hmm - we're still having difficulties. For example, the accept() > wrapper seems to return a native socket and not a TimeoutSocket. But > at least for us (also NT4 SP6), the socket that accept() returns when > the main socket was non-blocking is also non-blocking. Thus, when you > later attempt to send/receive over it, you're non-blocking, but > without the wrapper support of the TimeoutSocket class. This seems to > particularly show up when trying to use this with Fredrik's XMLRPC > library. > > We also seem to get a code 10022 but with why[1] set to "winsock > error" rather than "Invalid argument" in the connect processing. > > It sounds like I'll just poke around a little more and see if I can > summarize everything in one swoop. Thanks. > > -- > -- David > From Peek at LVCM.comNOSPAM Mon Apr 16 02:50:23 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Sun, 15 Apr 2001 23:50:23 -0700 Subject: do...until wisdom needed... References: Message-ID: Hmmm... nice syntax, but still ambiguous ("a" may ALREADY be equal to "b" before the loop starts, and it is not obvious that the loop executes once anyway.) I too share your dislike for the control structures at the end of code blocks-- but, what to do? (Pun intended!) "deadmeat" wrote in message news:HZvC6.2488$p5.8503 at news1.rivrw1.nsw.optushome.com.au... > > Here is my question-- If Python WERE to have a "do...until" construct, > what > > would be the best way to implement the syntactical rules? > > until a == b: > some > thing > > ie. the same as while, except until guarantees at least a single recursion. > this would mean very little change to Python to implement, just a minor > modification on the while handler. > > it's not as clear as do (code) until but I don't like ending code blocks > with with control structures... esp. not in Python. > > > > From tdelaney at avaya.com Mon Apr 23 20:25:15 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 24 Apr 2001 10:25:15 +1000 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) Message-ID: > > > The normal way to create a Rational is to write Rational(2, 3). > > > The next release will also have a string parser for rational > > > numbers (in the format "2/3" and probably "12 2/3" too). > > ^^^^^^ > > ^^^^^^ > > Just a note: > > This one is cultural and could generate lots of confusion. > > The only way I can parse it is 12*2/3 (I'm French). > > No French book (I know of) uses this notation: 38/3 or 12+2/3 > > is used instead. It's as if you wrote the complex number > > 3+4j as "3 4j" (look: "3 4j + 4 5j * 1 7j", hmmm...). > > The notation is quite common in financial business and > mathematics. I agree that it can be confusing, but since the > parser will only accept a single rational in the string, I > believe that at least when using Rational() this behaviour > can be accepted. The situation is different for literals, > of course... Of course, we should probably aim for a notation which is consistent *now*. 12 2/3 - ambguous across cultures. 38/3 - not ambiguous, but falls into the problem of integer truncation. Nevertheless, I would prefer this notation, and deprecate integer division notation in favour of 'mod' (since this would be a major incompatible language change anyway, might as well make a new keyword at the same time ;). 12+2/3 - not ambiguous and valid if the above is valid (integer + rational), I would probably want the compiler to start rolling literals together at this point... otherwise there would be 2 runtime calculations going on (division to form rational, then addition of integer). Tim Delaney From sholden at holdenweb.com Fri Apr 27 14:05:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Apr 2001 18:05:04 GMT Subject: Sending e-mails with attachments. References: Message-ID: "Mikhail Astafiev" wrote in message news:mailman.988393790.7853.python-list at python.org... > [Env: Win2k, Python 1.52] > > Hi! > > I'm not familiar with Python. The code below works OK excluding that > message body is empty. I've tried a lot of variants but I'm always > getting either message without body, or message with body but attached > zip file is corrupted! :(( > May be someone can tell me how to make the code below working, i.e. > generate message with body and proper zip file attached?.. > > Thanks in advance. > > def generate_mime_message( from_address, to_address, subject, > file_to_send, file_name, write_to ): > """Generate multipart MIME message with attached file in base64 encoding > Params: string from_address, to_address, subject > string file_to_send - path to existent ZIP file > string file_name - send zip with specified name > string write_to - store completed message to this file > Return: -""" > > try: > fp=open( write_to, "wc") > except(Exception),err: > print "can't open file for writing '%s':%s. Abnormal function termination"%(write_to,err)) > return > > toplevel=MimeWriter.MimeWriter(fp) > > toplevel.addheader("Date", time.ctime(time.time())) > toplevel.addheader("From", from_address ) > toplevel.addheader("To", to_address ) > toplevel.addheader("Subject" , subject ) > toplevel.addheader("MIME-Version", "1.0") > toplevel.addheader("X-Mailer" , XMAILER ) > toplevel.flushheaders() > > f=toplevel.startmultipartbody("mixed", > mimetools.choose_boundary(), > prefix=0) > > f.write("MESSAGE_BODY") > > # first toplevel body part > mfp = toplevel.nextpart() > > mfp.addheader("Content-Transfer-Encoding", "base64") > mfp.addheader("Content-Disposition", > "attachment; filename=\"%s\""%file_name) > > m = MimeWriter.MimeWriter (mfp.startbody("application/zip")) > > try: > fpin=open( file_to_send , "rb") > base64.encode(fpin, f ) > fpin.close() > except(Exception),err: > print "can't open file '%s' to send:%s. Empty section created!"%(file_to_send,err)) > > toplevel.lastpart() > fp.close() > Here's a tested example which may show you wehre you're going wrong. regards Steve import MimeWriter, base64 # # Writes a multipart mail message: text plus associated graphic # mfile = "multimsg.eml" f = open(mfile, "w") # Create a MimeWriter mail = MimeWriter.MimeWriter(f) mail.addheader("From", "Steve Holden , Steve Holden """) mail.addheader("Subject", "The Python You Wanted") mail.addheader("Received", """from thinker [64.134.121.94] by mail.holdenweb.com (SMTPD32-6.04) id A244C78500BA; Fri, 09 Mar 2001 07:33:38 -0500""") # Mail will be multi-part: First part explains format part1 = mail.startmultipartbody ("mixed") part1.write("This is a MIME-encoded message, with attachments. " "If you are seeing this message your mail program probably cannot " "show you the attachments. Please try another program, or read 'Web " "Programming in Python' to see the attached picture." """ Sorry ... Steve Holden """) # Second part is intended to be read part2 = mail.nextpart() f = part2.startbody("text/plain") f.write("Here we have a multipart message. This " "means that the message body must be processed " "as MIME-encoded content where possible [which " "it clearly is in Outlook Express]." """ regards Your Humble Author """) # Third part is a graphic, which we encode in base64 part3 = mail.nextpart() part3.addheader("Content-Transfer-Encoding", "base64") f = part3.startbody("image/gif", [["Name", "python.gif"]]) b64 = base64.encodestring(open("pythonwin.gif", "rb").read()) f.write(b64) # Never forget to call lastpart! mail.lastpart() From j.spies at hccnet.nl Thu Apr 5 18:00:03 2001 From: j.spies at hccnet.nl (Jaap Spies) Date: Fri, 06 Apr 2001 00:00:03 +0200 Subject: "Fastest growing programming language" References: <3AC93AE5.A97E1477@connecttel.com> <9aioh1$9mm$1@newshost.accu.uu.nl> Message-ID: <3ACCEAE3.8040308@hccnet.nl> Martijn Faassen wrote: > Rosimildo da Silva wrote: > >> Roy Smith wrote: >> >>> grante at visi.com (Grant Edwards) wrote: >>> >>>> It's based on the only metric that makes sense: the rate of >>>> increase of Usenet traffic in c.l.. >>> >>> By that measure, wouldn't Parrot be the fastest growing? :-) >> > >> Is this PARROT thing for real ? or was it just some >> April's Fool joke. ? > > > I don't know. I just know the PSU explicitly strongly denied there is > anything real whatsoever about Parrot. That is, if the PSU existed, which > it doesn't, of course. > > Regards, > > Martijn But Shakespeare said: Much Ado About Nothing: Scene I Act II: [BEATRICE] Scratching could not make it worse, an 'twere such a face as yours were. [BENEDICK] Well, you are a rare parrot-teacher. [BEATRICE] A bird of my tongue is better than a beast of yours. Jaap Spies From scarblac at pino.selwerd.nl Thu Apr 5 03:49:06 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Apr 2001 07:49:06 GMT Subject: PEP 245 References: Message-ID: Remco Gerlich wrote in comp.lang.python: > Clark C. Evans wrote in comp.lang.python: > > > It is clear to me that either I am the only one who things > > > that interfaces, at least in the proposed form, are next to > > > useless in Python, or those who agree with me do not read the > > > news group, or simply don't care enough to reply. > > > > Some mechanism is needed to identify an object as > > an implementer of a particular protocol, searching > > for the existance of "getitem" and the like seems > > like very poor practice. > > Common practice in Python is to do not even that, but just use the object as > given. If it doesn't have the methods then there will be an exception. > Heavy unit testing is necessary anyway. > > Even checking for existence of getitem and so on seems too rigorous to me to > use in every day Python. That's silly, you don't even normally check if your > input is actually an integer. > > I haven't actually followed the PEP discussion, but no, some formal > definition of interface may sound like a cool idea, just not one that should > have anything to do with Python... I just woke up and wrote something that looks too much like FUD. Never mind, I don't really know what I'm talking about, just typing up a first feeling about something, move along, nothing to see... I'll try to wake up and do some investigating first... -- Remco Gerlich From michel at digicool.com Tue Apr 3 13:49:58 2001 From: michel at digicool.com (Michel Pelletier) Date: Tue, 3 Apr 2001 10:49:58 -0700 (PDT) Subject: PEP 245 In-Reply-To: References: Message-ID: On Sun, 1 Apr 2001, Alex Shindich wrote: > I know I am going to get hate mail for this, but I have to get it off my > chest! > > I would like to get a few questions answered: Sure. > 1. What is the point of interfaces without static typing? To assert a contract is one. To separate various implementations of the same interface without them loosing a common usage is another. > All that a proposed definition of an interface guarantees, is that the > concrete classes will implement methods with certain names; no more and no > less. > > There is no guarantee that method doSomething declared in the > interface has anything in common with the method doSomething declared in the > concrete implementation class. Indeed, there is no requirement that > methods take the same parameters, not to mention that type checking is > impossible? What kind of contract is that? BTW, the return values are not > being checked either. No mandatory enforcement is being proposed. > 2. At what point will the compliance with the interface definition be > done, at compile time, or at run time? There is no madatory compliance or interface enforcement proposed in 245. These things are optional, and they should be optional. Turn on for unit-testing, debugging, etc, turn off for production and speed. > If the definition compliance is checked at compile time, then it will > be impossible to add implementation dynamically. That's right, which is why the proposal doesn't work that way. > Python has always > allowed modifications to the instances at run time. Not that it is always > pretty, but it is possible. Compile time checking would disallow this > technique. > > If the compliance is checked at run time, then interface checking is as > good as as simply assuming that the method is implemented. Today, I can > compile code like "f.doSomething ()" without f actually implementing > doSomething. At run time I would get an AttributeError thrown into my > face. In fact, the run time compliance is available already. Interfaces, strong or weak, are not going to solve any of these problems in a magic bullet fasion. There's a million ways around even strong interfaced languaged, even ones that go so far as to check pre and post-condition contract boundaries. As Bruce Eckell said at IPC9, Python doesn't assume your dumb. We don't want interfaces to assume that either. No madatory checking, no compile time enfocement, etc. One of the major reasons for the PEP is to assert that an object can be used in a certain way, without caring about how it is implemented. It's telling you something about what it can do, without you having to know the difference between the flat-file implementation and the one that uses a relational database. Currently this ability in Python is weak, and is based on looking at classes. But classes are not meant to be explicit interfaces, they are ways of sharing implementaiton. > Also, will it be possible to instantiate classes that do not implement all > the interface methods? Of course, although you would be breaking the contract and be a bad, bad little object. Then again, the user could always run the object through a verification step, our prototype implementation has a function that can do that for you, but the verification is just method names and signatures. > 3. I am just curious... Does any one smell Java here? No, Java interfaces are just compile time enforcement. The syntax is vaguely similar. > Not that I have > anything against Java, but I just wonder why Python should turn into > Java. Python is a wonderful, strong, and powerful OO language. It has a > set of its own patterns. Why does it have to support every possible > feature? If someone really misses strong typing and interfaces, maybe you > are trying to use the wrong language for the task? Perhaps, but again no strong typing system is proposed by PEP 245. > May be, Java is a > better language for this particular set of tasks? Or perhaps, you can > implement the same set of features using Python's real power -- > introspection and run time binding. Take me for example. If I were a python object, I'd be an instance of a class that is generalized by two other classes, my mom and dad. That's my type, my genetics. Now, let's say you were a function that expected a 'Python programmer'. You could wire that expectation to my implementation (my class), but then, I'd be the only "kind" of python programmer you could use. You could wire it to my generalized classes, but then you could only use me and my two sisters, and they're not python programmers. What you want is anyone, anybody, regardless of their genetic implementation, to work in your function because they assert "I am a python programmer." It's a contract, protocol, interface, call it what you will: class Michel(Reg, Loretta) implements PythonProgrammer: pass In terms of verification and enforcement, you can go through the expensive task of verifying my previous employment, my academic history, my contributions to python, etc, just once (verfication) or *every* time you worked with me (enforcement) or you could use the much cheaper method of trusting me when I say I am a Python programmer. PEP 245 does not specify the policy you can use, all are possible. The idea of PEP 245 is to separate object introspection from implementation. For example, you can create an object that quacks and swims like a dictionary, but will not work for you as the right hand component of an "exec 'x=5' in dict" statment. This is because the exec code checks the object based on its type, on its genetic makeup, not on the functionality it asserts itself to have. Similar problems lead to a lot of "if hasattr(obj, __getitem__):" etc code. So it has a __getitem__, what is it? A dictionary? A list? Both objects have __getitem__. What defines a "sequence" or a "mapping"? How do you know that this object that has a __getitem__ expects sequential integer keys, or is mutable? These things are currently just implied by the implementation, and often wired to a specific type, and the source of weird errors when you pass your code an object that has some method you're trying to imply the object's "interface" with. With interfaces, objects can assert they implement the SequenceInterface or the MappingInterface, or the MutableMappingInterface etc., and you can check for that without having to understand the type. -Michel From philh at comuno.freeserve.co.uk Thu Apr 12 06:07:08 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 12 Apr 2001 11:07:08 +0100 Subject: Komodo in violation of Mozilla Public License? References: <3AD36E75.EE5A5EA7@optushome.com.au> <3AD51590.C2B698DD@cosc.canterbury.ac.nz> Message-ID: On Wed, 11 Apr 2001 22:01:04 -0700, David Ascher wrote: >Greg Ewing wrote: > >> I think Phil was asking whether it's *feasible* to hand-edit >> the code produced by Komodo, not whether he's *allowed* to >> do that. In other words, does it produce code that is easy >> to read and modify? > >Sorry if I misunderstood. Currently Komodo does not produce any code. >In that sense Komodo is just an editor. OK. So what does it do that makes it easier than nedit or emacs, for writing python code? -- *****[ Phil Hunt ***** philh at comuno.freeserve.co.uk ]***** "Mommy, make the nasty penguin go away." -- Jim Allchin, MS head of OS development, regarding open source software (paraphrased). From moshez at zadka.site.co.il Wed Apr 4 16:45:07 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 04 Apr 2001 22:45:07 +0200 Subject: PEP 245 In-Reply-To: <9aes5k021tt@news1.newsguy.com> References: <9aes5k021tt@news1.newsguy.com>, Message-ID: As usual, Alex's posts are long and illuminating, but there is one point where I think he misrepresented me (a bit) On Wed, 4 Apr 2001 12:14:09 +0200, "Alex Martelli" wrote: [about using object.method=callable to override object.__class__.method] > (e.g., Moshe and others are on record as stating that they > strongly believe an object's __class__ should always change > if its behavior does -- i.e., they see the class/behavior > decoupling as an undesirable language feature, never to be > actually _used_) Let me clarify my position, since I do think this is a language feature. What I said is that adding *methods* (that is, Python functions with first argument bound to the object) is better done with __class__ mangling -- not that all behaviours do. See the ProxyHandler in urllib2 (Jeremy wrote that, for history's sake) as a place I think this technique is used to very good effect. Of course, that made documenting urllib2 close to impossible (see the documentation for the controtions I had to go through to properly document it ;-) Personally, other then the type-class dichotomy, I find Python's object model perfect -- while I do occasionally find faults in the language, none have been found by me in the object model. Well, the only slight wart is that custom setters and getters are *a bit* hard to get right -- I'd love something like __get_[attribute]__ and __set_[attribute]__ as "surgical getters and setters". -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From thomas at madeforchina.com Thu Apr 12 23:36:31 2001 From: thomas at madeforchina.com (Thomas Duterme) Date: Fri, 13 Apr 2001 11:36:31 +0800 Subject: os.system question Message-ID: <20010413113631.A2537@madeforchina.com> Hi folks, This may sound silly, but I have a question on os.system(). Let's say I have a script while calls some program XXX via os.system(). Will python wait for XXX to finish what its doing before continuing on with the rest of the script? ie ...some python code os.system('./XXX') some more python Do I need to call a wait() method after the system call? Or will python 'know' to wait? In this case I want python to wait for XXX to finish, but what if I wanted python to just mosey on down while launching a subprocess...(ie not wait) How would this be done? TIA, Thomas From hlt2000 at hotmail.com Sat Apr 21 06:23:33 2001 From: hlt2000 at hotmail.com (hlt2000 at hotmail.com) Date: Sat, 21 Apr 2001 10:23:33 GMT Subject: how to write file with configparser Message-ID: <3ae15ddc.7279927@news.xs4all.nl> I,m using the ConfigParser module to read my ini file. After my program has ran I want to update the ini file. With configdict.set I modify an option to a new value. How do I write this back onto my file system? cfgfile=open('config.ini',' rw') ... cfgdict.set(....) ... cfgdict.write(cfgfile) This gives an IOerror: (0,Error) What is the right way to do this? TIA, Hans From bsass at freenet.edmonton.ab.ca Thu Apr 5 13:50:10 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 5 Apr 2001 11:50:10 -0600 (MDT) Subject: Python Books for 2002 In-Reply-To: Message-ID: On Thu, 5 Apr 2001, Kemp Randy-W18971 wrote: > So why not a Python for Dummies or a Perl for Idiots book? Dummies and idiots should not be allowed to program, so why encourage them. ;) From aleaxit at yahoo.com Wed Apr 11 06:16:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Apr 2001 12:16:31 +0200 Subject: Newbie Q: var params References: Message-ID: <9b1atp01r0b@news2.newsguy.com> "zzzzz" wrote in message news:bnj7dto6gf5859sd7sl4v00ch6ue7ejagl at 4ax.com... > Hi all, > > I (possibly incorrectly) thought that parameters passed in functions > were modifiable by default in Python, here is some code that I tested A function is passed (references to) objects that may be either modifiable (e.g., lists) or not (e.g., tuples). > It looks like "parameter=[2,4,6,8]" creates a new local variable that No, it just *RE-BINDS* your local variable 'parameter' so it now refers to this new list object -- which has no effect on whatever 'parameter' was previously bound to, and has nothing to do with modifiable objects. Assuming 'parameter' is currently bound to a list (e.g., that a list object was passed as the corresponding actual parameter), you can perform modifying-operations on the list you were passed in; e.g., the modification "substitute all of the list contents": parameter[:] = [2, 4, 6, 8] Alex From news at myNOSPAM.org Mon Apr 23 04:57:56 2001 From: news at myNOSPAM.org (Stephen Hansen) Date: Mon, 23 Apr 2001 08:57:56 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: "Neil Hodgson" wrote in message > BCC tries hard to find never used value settings, including some that > other compilers don't warn about. For example, IIRC, this generates a > warning because the 1 is never read: > int i = 1; > if (c) > i = 2; > else > i = 3; > As does the same thing in a switch statement. BCC may also sometimes work > out when loops will never be run or be run only once. I can't recall all the > cases but BCC has always been accurate when its given me this warning. That's the reply I just received from the borland.* newsgroups. That just strikes me as *weird*. It explains the infinate spam of warning messages I get, though, since quite a few pointers are initialized to NULL and that NULL is never read in. This is not something I think the Gods'o'Python would care to have fixed, though. Dispite a 'no warnings' policy :) --S (replace 'NOSPAM' with 'seraph' to respond in email) From scarblac at pino.selwerd.nl Thu Apr 5 03:23:26 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Apr 2001 07:23:26 GMT Subject: PEP 245 References: Message-ID: Clark C. Evans wrote in comp.lang.python: > > It is clear to me that either I am the only one who things > > that interfaces, at least in the proposed form, are next to > > useless in Python, or those who agree with me do not read the > > news group, or simply don't care enough to reply. > > Some mechanism is needed to identify an object as > an implementer of a particular protocol, searching > for the existance of "getitem" and the like seems > like very poor practice. Common practice in Python is to do not even that, but just use the object as given. If it doesn't have the methods then there will be an exception. Heavy unit testing is necessary anyway. Even checking for existence of getitem and so on seems too rigorous to me to use in every day Python. That's silly, you don't even normally check if your input is actually an integer. I haven't actually followed the PEP discussion, but no, some formal definition of interface may sound like a cool idea, just not one that should have anything to do with Python... -- Remco Gerlich From yawyi at gmx.de Wed Apr 11 19:47:08 2001 From: yawyi at gmx.de (Johannes Stezenbach) Date: Thu, 12 Apr 2001 01:47:08 +0200 Subject: Thread-blocking (was: socket.gethostbyname() thread-safe?) References: <3AD1ABD0.FB728F28@stroeder.com> <9av6ni$9ao$1@panix6.panix.com> <3AD33118.8C16E617@stroeder.com> <9b0aqi$erj$1@panix6.panix.com> <3AD3C2B4.8A0F4E0E@stroeder.com> Message-ID: Michael Str?der wrote: >The whole HTTP serving stuff seems to work just fine. But the >underlying LDAP libs (OpenLDAP 1.2.x in my case) are known not to be >thread-safe. Therefore I'm using locks to protect calls into >python-ldap methods. My problem is that sometimes the whole thing >blocks. Mainly if the ldap.open() call (creating a new connection) >does not return or the client aborts the connection. Sounds like a C code problem. gdb is your friend. Hint: libpthread redefines some libc functions for thread safety. You must link ldapmodule with -lpthread. You must also compile with -D_REENTRANT, *even if ldapmodule itself does not use pthread functions directly*. >Two questions: >- Does the python-ldap module also has to set the global interpreter >lock as mentioned in the API docs (api/threads.html)? When the threads are created in Python and call out to a C extension module, the global interpreter lock is already held by that thread. Blocking C functions in the extension module should be surrounded by Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS to *release* the global interpreter lock and allow other threads to run. This is done correctly in ldapmodule. >- What is a good practice of exception handling to avoid blocking? >Should I catch all exceptions to avoid that the thread won't call >properly thread.exit(). Is this already done by >SocketServer.ThreadingMixIn? Calling thread.exit() explicitely is unnecessary. But see below. > def handler(self,*args): > req = args[0] > try: > w2lhandler.HandleHTTPRequest(req.inp,req.out,req.err,req.env) > except: > # Avoid blocking > pass > req.Finish() > thread.exit() Looks fishy. I assume it "blocks" when req.Finish() isn't called (unterminated fcgi call)? That's what try/finally is for: def handler(self,*args): req = args[0] try: w2lhandler.HandleHTTPRequest(req.inp,req.out,req.err,req.env) finally: req.Finish() HTH, Johannes From rjroy at takingcontrol.com Thu Apr 19 14:00:47 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 19 Apr 2001 18:00:47 GMT Subject: Newbie question: how to determine "is-a" relationship References: Message-ID: <3adf26c6.4547281@news1.on.sympatico.ca> On Thu, 19 Apr 2001 10:46:53 -0500, "Jake Baker" wrote: >Gosh. I've been using Python since 96 and I don't know this! Wow! > >Say I have a class heirarchy that looks like A, B <- A, C <- A, etc.... > >I have a list of objects (which I know arbitrarily are all A or sublasses = >of A) and want to filter them based on which subclass they are. > >How do I go about doing this? You help is greatly appreciated! > >Thanks, > - Jake Baker > > I think that instanceof will do the trick. See the Python Library Reference under Built-in Functions (Doc\lib\built-in-funcs.html) Bob From jimd at vega.starshine.org Fri Apr 13 08:01:35 2001 From: jimd at vega.starshine.org (Jim Dennis) Date: 13 Apr 2001 12:01:35 GMT Subject: First Python Script: Roman Numbers Message-ID: <9b6pqv$1seu$1@news.idiom.com> Here's my first Python script. Way back when I was taking classes at a community college and learning Pascal, I got an assignment to convert numbers to roman numeral strings. After tangling with the various rules for a bit, I realized that I could actually eliminate most of the conditionals by using a more elegant list of tokens. Since then I use the "toRoman" as a stock exercise for teaching myself new scripting and programming languages. I've even used version in Bourne syntax for teaching classes in shell scripting (I've included that, too). Here's the script, I'll let it speak for itself: #!/usr/bin/env python # Roman Number Converter # by James T. Dennis (c)2001 # This code is released and licensed under the terms of the GPL # or, at the user's option, the BSD license as specified at the # following URLs: # http://www.freebsd.org/copyright/freebsd-license.html # http://www.gnu.org/copyleft/gpl.html # # In any event it is provided free of charge, "as-is" and wholly # without any warranty. Use it, mangle it, incorporate it into # any software that will have it. # Convert natural numbers to their Roman numeral representations # and vice versa. # First we associate a list of numeric values with # their Roman numeral (string token) equivalents as follows: Rom={} Rom["M"] = 1000 Rom["CM"] = 900 Rom["D"] = 500 Rom["CD"] = 400 Rom["C"] = 100 Rom["XC"] = 90 Rom["L"] = 50 Rom["XL"] = 40 Rom["X"] = 10 Rom["IX"] = 9 Rom["V"] = 5 Rom["IV"] = 4 Rom["I"] = 1 RomSeq = ( "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ) # In this case we create a Python dictionary (otherwise we'd # create two arrays, one of integer values and the other of strings # and use our own functions to search them and translate using a # common index). We also create a sequence tuple in descending # order. It's for interating over the value list in a convenient order. # We include the two letter tokens (IV, CM, CD, XC, etc) because # it makes our main conversion loop simpler (as we'll see). # Basically it means we can loop straight through without having # to encode a bunch of parsing conditionals (the sequence, including # the two letter tokens already incorporates most the the parsing # rules for roman numeral strings). # This allows us to convert from Arabic to Roman in about 7 lines # of code; and from Roman back to Arabic less than 20 # Here's how we use these data structures: def toRoman (n): result="" if n < 1 or n > 4000: return None ## raise IndexError? for i in RomSeq: while Rom[i] <= n: result = result + i n = n - Rom[i] return result # Our result starts as an empty string. # We interate over the sequence of roman numeral component strings # if the corresponding value (the value associated with "M" or "CM" # etc) is greater than our number, we append the current string to # our result and subtract its corresponding value from our copy of n # Converting from a roman numeral string back to arabic representation # is a bit trickier. We can try using the same data structure. However, # we could encounter many types of errors. # We were able to filter out all invalid integers with a single compound # conditional but there are lots of ways to compose strings that are # *not* valid roman numerals. def fromRoman (s): result=0 s = s.upper() # Start by converting to upper case for convenience for i in RomSeq: # A Roman number, in canonical form, is # sorted from the larger tokens towards the # lower valued ones. Thus IIMXCC is not # a proper roman number (it would have to be # sorted to MCXCII or 1192). In fact CMM is # also not valid --- it would have to be MCM # and CMCM is is not valid at all it can't # be simply re-arranged, it must be re-written # (MDCCC) # So we simply walk through the list of tokens # in sequence (just as we did for convert toRoman) # and we compare each token to the "head" of the # remaining string. seen = 0 limit = 1 if i in ("M", "C", "X", "I"): limit = 3 # The M, C, X and I tokens make appear in sequences # up to three times. All others may only appear once # each head = s[:len(i)] while i == head: # on a match (head of string matches token): # track number of times we've see this token # vs. the token's sequence limit seen = seen + 1 if seen > limit: break s = s[len(i):] # behead the remaining string head = s[:len(i)] # and get the new head of the string result = result + Rom[i] # oh yeah, and add corresponding value to result if s == "": return result ## The following simply prints a list ## by converting to a roman number *and back*. longest="" for i in range(1,4000): s=toRoman(i) if i != fromRoman(s): print "Error? is %s really %d" % (s, i) print "%5d\t%s" % (fromRoman(s), s) if len(s) > len(longest): longest = s print longest #### End of script The last 10 lines are just a test suite. I've noticed that this script works fine under Python 2.x but it seems that s.upper() isn't in Python 1.5.x (or that I have to import a string module; I didn't spend time on that). Here's a shell script version of just the "toRoman()" function: #!/bin/bash valarray="1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10" valarray="$valarray X 9 IX 5 V 4 IV 1 I" [ "$1" -lt 4000 ] || { echo "Can't Represent numbers over 4000 in this character set" >&2 exit 1 } n="$1" set -- $valarray while [ "$n" -gt 0 ]; do # build roman numeral while [ "$n" -lt "$1" ]; do # find scale shift 2 done while [ "$n" -ge $1 ]; do # add values to result let n-=$1 result=$result$2 done done echo $result From aleaxit at yahoo.com Thu Apr 5 08:08:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Apr 2001 14:08:50 +0200 Subject: Changing global variables in tkinter/pmw callback References: <3ACC21BF.14E708B7@mek.dtu.dk> <3ACC4EB1.376225AF@mek.dtu.dk> Message-ID: <9ahn9k02l6j@news2.newsguy.com> "Brian Elmegaard" wrote in message news:3ACC4EB1.376225AF at mek.dtu.dk... [snip] > non-CS-engineer it's too hard to get a meaningful explanation. Can it be > written in a few words, so I may understand why lists are (and have to > be) so different from "normal" variables? [snip] > > I'll leave it to alex to write the long, pedagogical explanation. > > Looking forward to it. Hmmm, OK, let's have a try. The Python world is made up of "objects", aka "values", and "references", that are bound to those objects. OK so far? All you can do to a 'reference' is bind it to some object. If a reference was already bound to an object, and you are now binding it to another object, this is also called 're-binding' the reference. Binding (and re-binding) is most often done through the so-called "assignment statement": the reference that is affected is indicated by what is on the left of the '=' sign in such a statement, the object being bound, by what is on the right of said sign. (For completeness: "un-binding" a reference is also possible; the 'del' statement is used for that purpose; a reference 'exists' if and only if it's bound to some object -- it starts 'existing' when a binding is first done, it ceases to 'exist' if and when un-bound; conversely, one could also say that an object exists if and only if one or more references are bound to it, and be _almost_ right). The key thing to remember: in se and per se, the fact of re-binding a reference, which was previously bound to object X, so that it is now bound to object Y, _has NO observable effect on either X or Y_ (except for such things as the possible 'side effect' of an object going away completely if no references whatsoever are bound to it, a garbage-collection issue which may work differently in different Python implementations). Some objects can 'contain' references: for example, if an object has "attributes", you can think of those as references which have names and are contained by the object; what you can think of as (global) variables are nothing more (and nothing less) than the attributes of an object (a module-object, i.e., an object whose type is types.ModuleType). [_Local_ variables of a function are treated in a special way -- in some sense, they 'exist' even when not yet bound, which is why you can get an UnboundLocalError if you refer to them when they are not bound]. Not all references 'contained' in an object need be there as named attributes of the object. A dictionary object contains 'items', which are key-value pairs: each key, and each value, is a reference. A list object contains 'items' which are just references, held in some specific order and identifiable by progressive number ('index'). Some objects are *mutable*, which means their state may be changed (others, such as strings, tuples, and numbers, are immutable). So, coming to your original example, you had: """ In apply I do: def apply(self,button,buttons,setting): setting= button.cget('text') """ The body of this 'apply' is just re-binding a reference which happens to be a local variable of this apply function. It is, specifically, an 'argument' of it, but arguments are just local variables whose initial binding on a given function-call is effected before the function-body starts executing (to either default values, or values supplied by the caller). Re-binding a local variable (be it an argument, or not) can never have any possible effect on anything outside this specific function, anyway. This is a simple consequence of what I identified above as "the key thing to remember": re-binding a reference affects only that reference, NOT the object which that reference happened to be previously bound to. You say you now changed things: """ I use a list instead of a "variable" for the CurrentCanvasSetting. This allows me to use it as a global variable, and I can get the wanted """ I _think_ you mean you are now doing something like: def apply(self,button,buttons,setting): setting[0] = button.cget('text') This is re-binding, *NOT* the (local-variable) reference named 'setting', but, rather, the (indexed) "0-th slot" of whatever (e.g., a list) 'setting' is bound to. This *mutates* the object that 'setting' is bound to -- thus, it may indeed be 'observable from outside', since there may be any number of other references to said object, besides the local one (argument) named 'setting'. You are re-binding a reference *CONTAINED* in the object that 'setting' is bound to: and that is the crucial difference. It's not between "lists" and "variables": you could perfectly well mutate a module-object by re-binding one of its variables (named attributes), just as you can mutate a list-object by re-binding one of its items (indexed 'slots'). To achieve such an effect, you would pass the module-object as 'setting' argument to this 'apply', then have a body such as: setting.foobar = button.cget('text') (Or, you could use a 'grab-bag instance object' -- it does not have to be a module-object; see for example http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52308). Alex From aleaxit at yahoo.com Wed Apr 25 05:40:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Apr 2001 11:40:37 +0200 Subject: best way to take vertical slices from a matrix? References: <9c50pc$5vtg$1@sp15at20.hursley.ibm.com> Message-ID: <9c65vj01hsq@news2.newsguy.com> "mary" wrote in message news:9c50pc$5vtg$1 at sp15at20.hursley.ibm.com... > I have a simple problem and am interested to find > the 'best' way to do this in python: > > Given a list such as: > > x[0] = (1,2,3) > x[1] = (4,5,6) > x[2] = (7,8,9) > > what's the best way to 'take vertical slices' from this > matrix, ie end up with: > > y[0] = (1,4,7) > y[1] = (2,5,8) > y[2] = (3,6,9) List comprehensions may be simplest: y = [ [x[i][j] for j in range(3)] for i in range(3) ] but they'll give you lists, not tuples as in your example's notation; you'll have to explicitly use the tuple builtin for transformation if you do require tuples. Alex From grey at despair.rpglink.com Wed Apr 18 05:23:55 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 18 Apr 2001 09:23:55 -0000 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: On Tue, 17 Apr 2001 23:39:00 -0700, Ken Peek wrote: >Tyrant! "The tree of liberty is watered from the blood of tyrants and >patriots"... Who knows, I could be a patriot. :P -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From sholden at holdenweb.com Thu Apr 26 09:41:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Apr 2001 13:41:00 GMT Subject: how to explain this memory usage References: Message-ID: "javalist" wrote in message news:mailman.988284459.28229.python-list at python.org... > Hello python-list, > > in the python 2.0 interpreter,I write some code to make the interpreter > allocate more than 20M memory,and then I del all the object that I > create,but python still using that 20M memory,I try import gc,and then > use gc.collect,no good.python has 20M in memory still. > also the interpreter has 20M in memory,but seems python knows they are > pointing nothing and reuse these 20M when I try again allocating more > object in python,it didn't increase memory until the first 20M is > occupied by the new allocated object > > Best regards, > javalist mailto:javalist at 21cn.com > QUALIFICATION: You may get better, conflicting, advice from those who have studied the code, but... The point of garbage collection is to release memory occupied by deleted objects back to the Python interpreter *for re-use to store new objects*. If Python is like most other language interpreters, it will never say to itself "Why, I've just reclaimed 20MB of memory, perhaps the OS would like some of that back, let's see". In other words, the memory allocated to a process running a Python program moves upwards from the current high-water mark, never downwards. It's actually quite unusual for programs to give back memory to the OS in any case, except the special one of "I've finished, you can have it ALL". regards Steve From bkline at rksystems.com Wed Apr 11 13:24:17 2001 From: bkline at rksystems.com (Bob Kline) Date: Wed, 11 Apr 2001 13:24:17 -0400 (EDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: <20010411120018.Y56173-100000@open-systems.net> Message-ID: On Wed, 11 Apr 2001, Chris Watson wrote: > > What? How does anything you wrote support the assertion that changing a > > single letter of a work in the public domain entitles you to a > > legitimate copyright claim in the derived work? > > Go read cluase 2 of the GPL. Its pretty clear what I wrote supports > that the use of GPL code in any application public domain or NOT, > will be under a GPL copyright. It makes absolutely no difference what clause 2 of the GPL says. Anyone can craft a license which has unlimited amounts of nonsense in it. That doesn't change the _fact_ that making a de minimis alteration to a work in the public domain will _not_ entitle you to a _legitimate_ copyright in the derived work. -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com From mertz at gnosis.cx Tue Apr 10 17:25:51 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Tue, 10 Apr 2001 17:25:51 -0400 Subject: Komodo in violation of Mozilla Public License? (fwd) Message-ID: David Ascher (Komodo Tech Lead) in email asked for clarification of why I thought the Komodo licensing terms violate the MPL. I'd like to clarify for the list, since this IMO is a matter of general concern to the Python community (David is BCC:'d). The Mozilla Public License seems to live at: The chief sections that apparently conflict with Komodo's commercial licensing terms: 3.1. Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. Komodo is available--as far as I can determine--only under a substantially different license than the MPL. Specifically, the ActiveState license imposes many terms that additionally restrict the recipients rights. 3.2. Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. ActiveState does not make source code for their modifications available. That seems pretty staightforward. Even if there is some other provision in the MPL that somehow authorizes ActiveState's license (I don't see it, but again, IANAL), the terms certainly seem to violate the *spirit* of the open source communities participation in the Mozilla project. Btw. Ascher also mentioned IBM's Web Browser for OS/2, which was also recently released. As an actual living OS/2 user (most of the time; check my headers sometime), I was aware of this release and even read the discussion of it on an OS/2 newsgroup. I confess, however, that since Warpzilla is also available free-of-cost and with full sourcecode, I failed to give much thought to IBM's licensing terms. I admit that there seems to be a similar issue... but also understand that it is *really* unlikely that IBM failed to look at everything with a large team of good lawyers. Yours, Lulu... From tim.one at home.com Sun Apr 22 19:51:14 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Apr 2001 19:51:14 -0400 Subject: Nested Scopes in Idle/PythonWin In-Reply-To: Message-ID: [Michael Hudson] [bytecodehacks suppressed to protect the innocent ] > ... > Fourth (optional) argument to __builtin__.compile, anyone? I'd submit > a patch to code{,op}.py but if nested scopes are going to be the > default in 2.2 there ain't a lot of point. This has much less to do with nested scopes than with PEP 236's *real* topic: dealing with incompatible language changes during a transition period. Nested scopes is just the first example of that, and the same problems will reoccur, mutatis mutandis, if any other gimmick ever falls unders this mechanism (and whether it's spelled "__future__" or "directive transitional" or "up yours" or ...). > Bah. This is annoyingly crap, I'm afraid. I wish I'd known about > this before 2.1 went out. You should read every PEP cover to cover every day . For nested scopes I didn't consider this to be more than a minor nuisance at worst: I simply won't type gobs of nested functions directly to a shell prompt anyway. I've played with nested scopes a *lot* in IDLE, but in a sane way: put my temp code in an IDLE edit window, with a future statement at the top, then use IDLE's "Run Script" to run it and show the results in the shell window. This is easy. It could be unbearable for *other* kinds of incompatible changes, though. For example, if 1/2 is changed to mean 0.5, then we definitely need to solve IDLE's (and PythonWin's, and PythonWorks's, and Emacs Python-process buffer's, and ...) simulated shell problems here. So there's not a rush, and it needs a clean solution. For example, codeop.py's compile_command could grow an optional list of "feature name" arguments, and then when compile_command decides a command is complete, recompile it with those future-features in effect. It probably doesn't need hacks at the bytecode level -- and the front-end simulated shells don't work at that level anyway (all *they* can do is recognize future statements when they appear, remember the names of the future features in a "sticky list" of strings, and pass them on to whatever they're using that eventually calls compile_command). More convenient for everyone may be an API telling the compiler "OK, assume these future-features until somebody tells you to stop assuming them". Then we get the joy of managing hidden global state across uncooperative modules . From mwh21 at cam.ac.uk Sun Apr 1 08:58:35 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Apr 2001 13:58:35 +0100 Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> Message-ID: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes: > Sat, 31 Mar 2001 21:22:54 -0800, Erik Max Francis pisze: > > > The Python FAQ, for instance, suggests x ? a : b can be reliably > > substituted with > > > > (x and [a] or [b])[0] > > It computes both a and b. No it doesn't: />> def f(): |.. print 1 |.. return 1 \__ />> def g(): |.. print 2 |.. return 2 \__ ->> (0 and [f()] or [g()])[0] 2 2 ->> (1 and [f()] or [g()])[0] 1 1 > A correct solution is > (0 and (lambda: a) or (lambda: b))() This also works. > Yes, it is ugly. This is also true. Cheers, M. -- . <- the point your article -> . |------------------------- a long way ------------------------| -- Cristophe Rhodes, ucam.chat From roger-anderson at uiowa.edu Fri Apr 20 17:12:08 2001 From: roger-anderson at uiowa.edu (Roger A) Date: Fri, 20 Apr 2001 16:12:08 -0500 Subject: ActiveState PPM probs References: Message-ID: <9bq8h1$h5q$1@flood.weeg.uiowa.edu> I used PPM to install numeric but when I try to install PIL I get "ERROR: Package PIL not found in the repository ActiveState Package Repository: etc,etc. Also how do we know what packages are available? Roger "Paul Prescod" wrote in message news:mailman.987760592.5640.python-list at python.org... > Tim H wrote: > > > > ... > > > > Anyway just installed y'alls (ActiveState) Python 2.1 on Win98 and fired up > > ppm and did install PIL. There is a PIL directory with only a readme and a > > scripts folder. I know there should be way more than that in there. > > Importing PIL fails (there is a PIL.pth) no matter how its spelled. > > 'ppm>verify pil' indicates PIL is up to date. > > You hit a transient problem with our network or mirrors. :( I've fixed > it now. Please do a: > > ppm> verify -uf pil > > to upgrade your PIL. > From hannah at schlund.de Mon Apr 23 12:05:35 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 23 Apr 2001 18:05:35 +0200 Subject: A couple garbage collector questions References: <9av51u$hs3$1@c3po.schlund.de> Message-ID: <9c1jsf$2er$1@c3po.schlund.de> Hello! In article , Jeremy Hylton wrote: [reference count updating optimizations] >This would be a mammoth project for Python. The Python VM performs >reference counting without any compiler support. The compiler emits >an instruction like DUP_TOP (duplicate object on top of stack). The >VM incremenents the reference count of the object as part of the >DUP_TOP implementation. Yes, agree. From a practical POV, it'd probably be difficult both to switch completely to a GC (e.g. a generational one), and to optimize RC updates. Except... I don't know python's internal implementation structures, but if it could be possible to change the current VM interpreter into either a load-time VM->native compiler (doing some dataflow analysis on the VM level for optimizations), or some JIT based interpreter/compiler hybrid, you'd perhaps be able to gain some speed even with retaining the external interface to the rest of the runtime as well as extension modules. >The Python VM instructions are high level and, thus, fairly >expensive. To get compiler support for managing reference counts, >we'd need to go with a completely different VM that included reference >count operations as part of the instruction set. The current >per-instruction overhead would dwarf the cost of the ref counts. So >without a significant redesign, this approach would probably slow down >the interpreter enormously. >The idea seems reasonable, so far as I can tell. But we have neither >the compiler infrastructure nor the VM support we would need to make >it work. Yep. And it seems, there is not too much real pressure for a change of that complexity either, as Python will surely be fast enough for most of its usage areas, anyway. >Jeremy Kind regards, Hannah. From m.hadfield at niwa.cri.nz Tue Apr 3 18:28:19 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 4 Apr 2001 10:28:19 +1200 Subject: Windows madness References: <986336346.203429@clam-ext> Message-ID: <008001c0bc8d$6286b5a0$d938a8c0@Hadfield> This is just a test: I am replying to newsgroup posting (mine) via the mailing list. I want to see if by some magic it appears as a follow-up on the newsgroup, or indeed if it appears at all. Apologies for wasted bandwidth, though I must say I am not the only person who has been wasting bandwidth on this list/group recently! --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From benjamin.altman at noaa.gov Mon Apr 16 13:22:36 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Mon, 16 Apr 2001 13:22:36 -0400 Subject: do...until wisdom needed... References: <3ADB1C3C.F1AD88ED@noaa.gov> Message-ID: <3ADB2A5C.5A50F840@noaa.gov> Ugliness aside, it would work since it is dependant on indentation. In your example you would have to do: while cond(): #bla #bla #bla #do some stuff until cond2() So the #do some stuff is done until cond2() is satisfied. The until is inline with the #bla code and the contents of the until are indented one level further. Remco Gerlich wrote: > Benjamin.Altman wrote in comp.lang.python: > > Any answer does not seem ideal in Python, but what about an indent concluded with an > > "until" like: > > > > # do some stuff > > # do some more stuff > > until condition == true > > So how would you put that after another block? > > while cond(): > #bla > #bla > #bla > > #do some stuff > until cond2() > > That doesn't work. You need a proper non-indented block start. > > Besides, it's ugly :). > > -- > Remco Gerlich From dalke at acm.org Wed Apr 11 11:26:03 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 11 Apr 2001 09:26:03 -0600 Subject: converting string to dict ? References: Message-ID: <9b1tab$1ce$1@slb4.atl.mindspring.net> /F wrote: >>>> eval("{'name': 'Cleopatra'}", {"__builtins__": {}}) >{'name': 'Cleopatra'} > >the __builtins__ stuff is optional, but provides some protection >from evil data providers: Note that it isn't full protection. Consider eval("[0] * (2 ** 31)") which will cause most machines to run out of memory. Andrew dalke at acm.org From dalke at acm.org Tue Apr 17 21:38:41 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 17 Apr 2001 19:38:41 -0600 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: <9bir7a$5vo$1@slb3.atl.mindspring.net> Alex Martelli wrote: >> "There should be ONE 'obviously correct' way to do it" is one of the >> Python mantras Douglas Alan responded: >This is a BAD mantra. Not as bad as the Perl mantra, "There should be >3294369 ways to do it", but extremes are rarely ideal. "The truth lies >somewhere in the middle." Huh? His mantra isn't an extreme. "There must be only one way to do it" is an extreme. That is, pure orthogonality is an extreme. Saying there "should be one 'obviously correct' way" means there could be other obviously correct ways as well as non-obvious ways, but those designs aren't Pythonic. >Besides, there are many uses for procedural macros other than for >providing trivial syntactic sugars that are best done by using the >sugar already provided. You all are going to have to explain things to me. My physics degree never told me what "procedural macros", "hygenic macros", etc. mean. My best guess is they are transformations which act on parse trees before finalizing the parsing, vaguely like what templates do for C++ (which my physics degree did tell me about). If that's the case then I can see how they would be useful, because one nice thing about templates is to allow A = B + n * C to be implemented element-wise for matricies without producing intermediates. But every time I look to see how templates work I sigh in relief that someone else has done the hard work. C++ aside, could you present an example of how these might be used in Python? I'm finding it hard to conceive of significantly better ways to write code than what Python has already. (I don't see list comprehensions or string method as all that significant.) By example I mean how it might look written in Python, not how it is done in Lisp, Scheme, Dylan or other language not used by computational physicists/chemists/biologists. Mind you also that justifications based on performance (as with my element-wise addition) don't have much weight with me. For that I rewrite in C. My main, number one concern is to have a programming language where both software developers and life scientists (medicinal chemists, biophysicists, structual biologists, etc.) can use it and enjoy using it. I would need to be convinced that someone whose programming training is a semester of FORTRAN and a couple of years of shell scripting can learn how 90% of the features in a language works without having to get any special training beyond help from coworkers and books. >See Guy Steele, "Growing a Language": > > http://cm.bell-labs.com/cm/cs/who/wadler/gj/Documents/steele-oopsla98.pdf > >"We need to put tools for language growth in the hands of the users" That tools is the C (or Java) implementation, no? Otherwise growth into forms like Stackless and Alice never would have taken place. I use Python because I don't think one language provides everything. So really I don't use Python, I use Python and C/C++ .. and http and popen and .... So CPython does provide the tools I (as a user) need to help the language grow. And I've done so by contributing code back to Python. >> You have not explained, I think, why _YOU_ would want to use Python >> rather than Common Lisp, Scheme, or Dylan. > >There are numerous reasons. The fact that the others are not widely >used, are not tuned for scripting, do not have as elegant a syntax, >are not as easy to learn, are not available on every platform known to >man, do not start up in a fraction of a second, do not come with a >huge library of useful tools, etc., are all salient reasons. And yet >there remain others. How does this jibe with your statement that Lisp "even though it was invented in the '50's, ... remains today one of the most modern of languages." Does this mean with 40+ years of development, Lisp does not have features of some modern language, in that it isn't widely used, not tuned, etc.? Those two statements don't go together, unless you split "language" features of a language from "lets you do work" features of an implementation. As mentioned, I'm heavily weighted towards the latter. I feel it is the job of language designers to convince me the former really is useful and my job to evaluate if they've done a good job. Python passes that test. >Macros are typically used to good >effect and typically make programs easier to understand, rather than >harder. Often they are essential to making certain programs >maintainable. In another language, you would have to resort to >prepossessing or data driven code-generation instead. So if my job is to evaluate if a language designer has done a good job, I would need to see an example relevant to how Python works. Could you show how this might be used in a Python-like deriviative? Cases I can think of from my C background can all be done with things like: if cond: def spam(): pass else: def spam(): pass or def make_spam(data): def spam(n = len(data)): return n return spam or klass = new.classobj("Spam", (), {}) or (*very* rarely) d = {} exec "def Spam():\n\tpass\n" in d func = d["Spam"] In another branch of this thread you said: > A language without procedural macros is clearly less expressive than > one that has them. This statement needs no support. I don't necessarily want that expressiveness. I can write (and have written) Python code which takes a C function definition, builds it as a Python extension and imports it into Python. That is clearly more expressive than stock Python but it isn't something I want available because it scares me having to think that every module I use can have a mix of C and Python code. So what needs support is not the expressiveness itself but the usefulness of the expressiveness. > For instance, > if I had procedural macros, I wouldn't need to bug the language > implementers to add variable declarations -- I could do it myself. In my limited understanding of hygenic macros, wouldn't you only be able to apply macros to a sufficiently Python-like language, in order to transform it internally to a Python representation? That is, you couldn't use hygenic macros to convert Pascal code into Python. (Is that what the 'hygenic' part means?) Suppose your user tests show that the best way to add variable declarations to Python is via a language syntax the current implementation doesn't have, so cannot be handled through macros. What would you do then? Andrew dalke at acm.org From benjamin.altman at noaa.gov Tue Apr 17 10:08:32 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Tue, 17 Apr 2001 10:08:32 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: <3ADC4E60.C827D8A0@noaa.gov> If Python is supposed to provide one obviously correct way of doing things why did they create the lambda notation? Alex Martelli wrote: > At a MICRO level ("programming in the small") it's never been > part of Python's design goals to provide many ways to express > one design idea. "There should be ONE 'obviously correct' way > to do it" is one of the Python mantras -- clearly an ideal, one > that is totally unattainable of one dreams of something being From footech at get2net.dk Tue Apr 3 04:30:17 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Tue, 3 Apr 2001 10:30:17 +0200 Subject: list vs tuple References: <3AC6805F.7E26327A@san.rr.com> <3AC70676.A5C5FECF@hack.org> <_lGx6.1144$p5.4395@news1.rivrw1.nsw.optushome.com.au> Message-ID: deadmeat wrote in message news:_lGx6.1144$p5.4395 at news1.rivrw1.nsw.optushome.com.au... > > done lots of Python training lately? in my experience, *everyone* > > can understand Python's object model in about five minutes. > > Do the first 5 minutes of the tutorial mention this? No.. so the newcomer to > Python will go off thinking one thing, and not know any better until s/he > gets to the relevant section. > > > because you're smarter than everyone else > > I don't ever claim such.. what I am saying is that one learns a certain > method early on, namely that a = b copies b to a. This is not so in Python, > and the tutorial breezes by this little detail as if one really could reset > thy brain. > > It's all nice and easy once Python is learned, but who reads the entire > documentation before typing a single character? Nobody. With an > interpreter in one hand, and the documentation in another, the programmer is > encouraged to read some, then play with what is learned. Only after the > programmer has experiemented is he then told what he just 'learned' about > Python is wrong, and here's the real story. > > > Then the confusion is caused by the documentation, not the language itself (the standard Python tutorial it not exactly well-written). I was also also a bit confused by code like your example in the beginning - but I got better. Now I'm mildly confused by Pascal instead :-) Mikkel Rasmussen From tim at worthy.demon.co.uk Tue Apr 17 14:58:34 2001 From: tim at worthy.demon.co.uk (Tim Howarth) Date: Tue, 17 Apr 2001 19:58:34 +0100 Subject: With or Using References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> Message-ID: <2b95c26c4a%tim@worthy.demon.co.uk> In message <3ADC5AE1.53C3C4FE at alcyone.com> Erik Max Francis wrote: > Tim Howarth wrote: > > > Being lazy, I wondered if something like the following was possible in > > Python? > > Hopefully not. In every language that kind of syntax has been > introduced, it has only led to trouble. I've met it in Delphi and assumed it was the norm for object properties. > It saves a small amount of typing (and not very much) at the expense of > a lack of clarity and the addition of ambiguity. I thought with Python's block indenting it would be pretty clear what was being referred to. -- ___ |im ---- ARM Powered ---- From francois.granger at free.fr Sun Apr 1 11:54:50 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sun, 01 Apr 2001 15:54:50 GMT Subject: Converting an integer base 10 to a binary number References: <3AC1E898.D5929C44@fh-hof.de> <1er3z6w.13vo4oy1rq8rjmN%francois.granger@free.fr> Message-ID: <1er6q7o.1mtta8w1r0vf96N%francois.granger@free.fr> Robert Amesz wrote: > I'm afraid it doesn't work for x == 0, and you'll get into trouble when > x is a float. Thanks for all corrections. -- Premi?re loi du support technique: "Si ?a marche, ne changez rien" From jojo at virtutech.se Thu Apr 5 09:45:37 2001 From: jojo at virtutech.se (Jesper Eskilson) Date: 05 Apr 2001 15:45:37 +0200 Subject: Returning objects from PythonCOM servers Message-ID: Hi! Is there any sample code out there which shows how to create and manipulate an object where the object's type has been extracted from a type library? /Jesper -- ------------------------------------------------------------------------- Jesper Eskilson jojo at virtutech.se Virtutech http://www.virtutech.se ------------------------------------------------------------------------- From wtanksle at dolphin.openprojects.net Wed Apr 11 14:58:42 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 11 Apr 2001 18:58:42 GMT Subject: ActiveState Ruby? References: Message-ID: On Tue, 10 Apr 2001 14:31:31 -0400, snowzone wrote: >In comp.lang.python, you wrote: >> I find it more relevant to speculate on whether Python would fork if the >> merpeople start invading our cities riding on the backs of giant king >> crabs. >which is about what i expect from the python ng when i ask a legitimate >question That's a bit ambiguous: are you expecting Python to fork when you ask a legitimate question, or are you expecting the merpeople to start an invasion? I wouldn't let that stop me from asking a legitimate question, but you of course have to set your own risk tolerance levels. >thanks for not disappointing... Anytime. One thing's for sure: we know what you're NOT expecting! Bring in the COMFY CHAIR! The error in your question is manifold: you assume that something here could cause Python to fork (unlikely); you assume that forks are easy to do (false); and you assume that forks are bad (also false). -- -William "Billy" Tanksley From anton at vredegoor.doge.nl Mon Apr 23 11:59:17 2001 From: anton at vredegoor.doge.nl (Anton Vredegoor) Date: Mon, 23 Apr 2001 17:59:17 +0200 Subject: operators and datatypes for sets Message-ID: <9c1jdj$phb$1@news.hccnet.nl> There has been some discussion about sets some time ago, but I could find no conclusive information. The consensus seemed to be to use a dictionary as the underlying data type. In order to revive the discussion (or to make it explicit here, if it was not dead but only invisible to me) I would like to present some test code I have made. I would post it here but since it is 142 lines long I will just give a link: http://home.hccnet.nl/a.vredegoor/smallset/smallset.py or the html version: http://home.hccnet.nl/a.vredegoor/smallset/smallset.html The basic idea is to use lists as the underlying datatype and to do member administration by setting bits to '1' or '0' in a longint. This has the advantage of doing very fast operations. There are also some disadvantages, one of them is having to specify a 'universe'. There is a also a PEP about this, http://python.sourceforge.net/peps/pep-0218.html but this PEP is about a language change, which is way out of my league since I am only talking about a module. I have used the 'in' operator for determining if a set is a subset of another set. This is different from its normal use where it is used for checking if an element is in a set. Further I have used the '/' operator for 'set1 without the elements in set2'. This is also unusual. I have also added a new operator '~' which can be available because the universe is specified. It gives all elements that are not in the set. These are just suggestions. Please let me know what you think or show me some better code, improvements would also be very welcome. Anton. From delgado at okeeffe-pc3.la.asu.edu Fri Apr 27 08:47:51 2001 From: delgado at okeeffe-pc3.la.asu.edu (Olaf Delgado Friedrichs) Date: 27 Apr 2001 12:47:51 GMT Subject: best way to take vertical slices from a matrix? References: <9c50pc$5vtg$1@sp15at20.hursley.ibm.com> Message-ID: Duncan Booth wrote: >delgado at okeeffe-pc3.la.asu.edu (Olaf Delgado Friedrichs) wrote in >: > >> If your rows can be tuples, you need something like >> >>>>> def vslice(a,j): >> ... return apply(map, [None] + map(tuple, a))[j] >> ... >> >Surely a single map is sufficient to do everything the original question >asked? >>>> print x >[(1, 2, 3), (4, 5, 6), (7, 8, 9)] >>>> apply(map, (None,) + tuple(x)) >[(1, 4, 7), (2, 5, 8), (3, 6, 9)] You are right, of course! I still get singleton tuples wrong, occasionally, which might explain why I did not think of this variant. Olaf From rickymz at yahoo.com Tue Apr 24 11:55:34 2001 From: rickymz at yahoo.com (CyberGuest) Date: Tue, 24 Apr 2001 11:55:34 -0400 Subject: Python compiler? References: Message-ID: <3AE5A1F6.3010909@yahoo.com> can't wait to see it! Jeff Epler wrote: > On Tue, 17 Apr 2001 22:35:56 GMT, news-server.columbus.rr.com > wrote: > >> Has everyone contemplated upon creating a python 'compiler', which can >> produce a self-contained binary executable? (for when speed is an absolute >> neccessity) ..or does such a thing exist already? I'd love to give game >> development in Photon a run, and feel that it's simply not fast enough to >> perform some operations. >> >> Any thoughts/comments are appreciated. >> Brian >> >> > > > I started work on a project of this type. > > I implemented basic type information (ints, floats, sequences, mappings, > functions, the last three with parametric types), the concept of > "type widening" (a type which contains at least the union of the two given > types) and the concept of the result of an operation such as addition, > subscripting, slicing, and calling. (actually, I think slicing was not > yet implemented) > > Then I implemented a type inference engine which worked on Python > bytecodes. At each bytecode, the types of each local and each active > stack position are determined. In the presence of looping constructs, > the code is repeated until the type information "settles" (So it's > possible to write functions which currently take infinite time in the > inferencer. Example: > def f(t): > x = None > for i in range(t): > x = [x] > return x > ). About a > dozen bytecodes were actually implemented, not the full set. Since a > function's result type is parametric on its input type, calling the > inference function with a bytecode function and proposed arguments. > Thus, given > def f(x): > return x*x > you might propose that f be given an integer: > >>> infer(f, (IntType()) > IntType > or a float: > >>> infer(f, (IntType()) > FloatType > > Another concept I introduced is the "solidification" of a function. > Certain globals and module contents can be marked as "solid", and loads > of them will be hoisted into constant loads. Typically, builtins like > 'range', the 'math' module, and its contents would be marked as "solid". > This sidesteps the issue of whether the type inference is correct given > the possible future modification of range(), and is a small > optimization. (These builtins are given type information by hand) > > Next I implemented a native code generator using GNU Lightning for JIT > compilation (Emitting C code would be another alternative). Using the > type information, it was hoped that the following optimizations could > be performed: > * Float and integer arithmetic done inline > * Calls from JIT functions to JIT functions as native calls > * Overhead of the bytecode interpreter loop gone > I implemented a similar subset of bytecodes in the JIT compiler as in > the inference system. > > This system can't JIT compile any useful code yet, and much of it has > become outdated by bytecode changes since Python 1.5.2. Exception > handling was another big issue which I hadn't made so much as a nod to. > > If anybody's interested in this code, I'll be happy to send you what I > have. It's covered under a Python-style license. > > Jeff From whisper at oz.net Thu Apr 12 22:34:13 2001 From: whisper at oz.net (Dave LeBlanc) Date: 13 Apr 2001 02:34:13 GMT Subject: OT - Closing Off An Open-Source Product References: Message-ID: <9b5oj5$kim$2@216.39.170.247> I'd sure like to know what some of this minorly modified and tainted code is! I'm aware that Flex was stolen by the FSF, although the author might bear some responsibility in that case. Flex was covered by an agreement reached between the Justice Dept. and the University of California since much of the work was done under government contract, at a time when such work was public property. This is actually where the Berkely license originated. Of course, these days, you get the gov't to pay for the work and then you get the benefit... Dave LeBlanc On Thu, 12 Apr 2001 07:18:49 -0500 (CDT), Chris Watson wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > > > >> what if "hackers" working for a big GPL guy takes your non-GPL'd open >> source code, makes a usually trivial change, and instead of contributing >> the change back to the original author, they redistribute the result as >> their own code, under GPL? > >It happens with the BSDL. Of course it's ALLOWED by the GPL. The BSDL is >FREE CODE. Thats the whole point. What good is writing free code if you >dont allow people to use it as much as possible and in as many way's as >you can? It's not free code if they can't use it for whatever purpose. > >> has happened to me many times... >> (and for some reason, non-GPL folks never do things like that. go figure) > >Because the License is not free, and unrestricted. It's an embrace and >extend tactic. They take free code and GPL it, killing its free nature. >But I have started adding a new clause to my BSDL code now killing their >ability to do that. > >============================================================================= >- -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek >Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas >Home: scanner at deceptively.shady.org | http://open-systems.net >============================================================================= >WINDOWS: "Where do you want to go today?" >LINUX: "Where do you want to go tomorrow?" >BSD: "Are you guys coming or what?" >============================================================================= >irc.openprojects.net #FreeBSD -Join the revolution! >ICQ: 20016186 >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.0.4 (FreeBSD) >Comment: Made with pgp4pine 1.75-6 > >iD8DBQE61Z0yoTcdKVapx58RAiGQAJ95WwleJuU2caDiczWnGzgMqG/WlgCfXlFN >bmC1oLnwSY+uviUksrxflyo= >=UIyy >-----END PGP SIGNATURE----- > > > From nessus at mit.edu Wed Apr 18 02:11:38 2001 From: nessus at mit.edu (Douglas Alan) Date: 18 Apr 2001 02:11:38 -0400 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: Courageous writes: > Well, perhaps you're a bit of a prima donna, but you may very well > be right; I've observed over the years that the more exposure to > various languages one has, the less dogmatic one tends to be. I've devoted a lot of my time to evangelizing Python. I've talked in public, giving free Python tutorials. Python appears prominently on my web site (and no other language does). I've rallied endlessly at work against significant resistance for people to use Python and set an example by using it heavily myself against significant resistance. *Every* time I meet someone who is interested in programming languages, I tell them about Python. And if they use Perl or TCL, I patiently explain to them the benefits that they would see by switching to Python. Consequently, I have *earned* my right to criticize Python. I do it out of love. I have no qualms with someone who disagrees with my assessments and thinks the coin should land on the other side of a trade-off (all of life is about trade-offs), but it rankles my sensibilities when someone claims that I am an ignoramus who hasn't thought about the issues enough and isn't familiar with the Python aesthetic. All of these things are quite untrue. > I hope you're not mistaking you interaction with this one person as > some kind of indication of the character of the Python community, by > the way: Pythoners tend to be fairly open minded, in general, even > if we do value simplicity to the point of being rather rabid about > it. My experience prior to Alex Martelli and Steve Lamb was always good, so I'll try not to let them get to me. I agree that simplicity is a virtue. I don't want Python to end up like Common Lisp, the kitchen sink of programming languages. Dylan, however, avoided that mistake and has macros, multimethods, etc., so it sets an example of what is possible in a non-obese language. > Mr. Peters was quite right: the correct thing to do is submit a PEP. > Major bonus points if you grab the Python source and create a > patch which allows hygienic procedural macros for those who > would like to add this patch to their installation. I'll put it on my schedule to think about how to do it right. But first I have to design a whole new language for this course I'm in the middle of taking.... |>oug From vincent_a_primavera at netzero.net Mon Apr 2 11:19:22 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Mon, 2 Apr 2001 11:19:22 -0400 Subject: Simple looping question... In-Reply-To: <01040211034102.00574@tos1> References: <01040211034102.00574@tos1> Message-ID: <01040211192203.00574@tos1> Hello, Problem solved... I appreciate the help! Thank you, Vincent A. Primavera On Monday 02 April 2001 11:03, Vincent A. Primavera wrote: > Hello, > In a piece of code similar to this I am trying to read all the lines from > a file but no more. How can I set the "range" of this loop to stop when it > reaches the end of the file? > > for i in range(???): > a = fil1.readline() > print a > > Thank You, > Vincent A. Primavera From tim.one at home.com Mon Apr 16 19:56:30 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 16 Apr 2001 19:56:30 -0400 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! In-Reply-To: Message-ID: [Don Tuttle] > Reading PEP 226, it only sets April 17 as a tenative release date. > There is no mention of when any betas or release canditates should > be released. Well, of course not, if this is the first time you read it: we update PEP 226 regularly to reflect current reality. The things under "Past release dates" today *used* to be under "Tentative future release dates". Over time, as the planned becomes the past, release dates "move down". Check again late tomorrow, and there will likley be nothing left under the "tentative" section. Then you can complain we gave no warning at all . > No mention of only 4 days for a final test. I assume people can subtract 13 from 17 without our help. > .. > Are you implying that after just 2 of the 4 additional days of > testing, Python 2.1 can now be certified 100% bug free? No, it's not bug free, and never will be. From the inside of the development process, though, it's obvious we passed the point of diminishing prerelease testing returns long enough ago that the release is ready to go. > Did you get at least one tester on every platform to commit to > testing RC1 during this 4day period? As I said, prerelease testing is a volunteer effort, and we don't have commitments from anyone to test anywhere. If that's important to your company, you could, e.g. pay people to test the things you care about on the platforms you care about. BTW, I don't think anyone could even enumerate all the platforms Python runs on. We certainly don't have testers for all of them -- and wouldn't if we waited another year. > If not, it seems rather presumptive that your objectives will be > met by simply posting it over a very busy holiday weekend! Do you find Python to be unstable? I don't. Guido's doing what he's always done for release testing, except getting more volunteers than ever before, and history is a better judge of effectiveness than Usenet FUD. > As a rule I try to keep beta software off my servers. It will be > at least a month or two before they see Python 2.1. IOW, you won't help test no matter what we do. Fine -- multiply yourself by 200,000. holiday-weekends-have-nothing-to-do-with-this-ly y'rs - tim From daniel.dittmar at sap.com Tue Apr 10 04:47:15 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Tue, 10 Apr 2001 10:47:15 +0200 Subject: Glueing Python with other languages References: Message-ID: <9auhal$7kr$1@news1.wdf.sap-ag.de> > I am having trouble using Python as a glue with other languages. I > can't seem to find any simple examples to show how to go about this. If you want to call C/C++ from Python: - Python source, directory Modules has lots of examples - SWIG is the classic to generate this stuff from C declarations - http://www.boost.org/libs/python/doc/index.html is the new kid on the block If you want to call Python from C: http://www.python.org/doc/current/api/veryhigh.html Daniel -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ From borealis3 at home.com Mon Apr 2 17:40:05 2001 From: borealis3 at home.com (Gary Walker) Date: Mon, 02 Apr 2001 21:40:05 GMT Subject: Newbie has question that's not exactly Python... Message-ID: But since I'm learning Python, I'd like to post it here, and hope someone will post some example code in Python... Background: I'm excited by the object oriented simplicity Python offers; I'm a Delphi programmer by day, and it's the similar exception handling, object creating, etc. that I really dig, not to mention PIL, the Python Imaging Library. I'm also jazzed by the web, and so Python seemed a natural choice for a new language to pick up... Here's the question: When a web app needs to produce an image, it's usually a trivial task: simply reference the image in the HTML code, and voila. How does one go about producing a dynamically generated image? That is to say, one that didn't exist until the python script ran? I hope I don't have to save it to some tempfile, and reference *that* in my python code. Thinking aloud here: Ideally, one would reference a SCRIPT instead of an image, and the script would return the image to the, the... page?? Can anyone provide a really simple example of how I'd go about something like this?? Does this question make sense?? I know what I'm *trying* to say here, but I might not be succeeding at saying it... :) TIA, Gary Walker From bos at hack.org Sun Apr 1 11:30:20 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sun, 01 Apr 2001 17:30:20 +0200 Subject: list vs tuple References: <3AC6805F.7E26327A@san.rr.com> <3AC70676.A5C5FECF@hack.org> <_lGx6.1144$p5.4395@news1.rivrw1.nsw.optushome.com.au> Message-ID: <3AC7498C.7F828D38@hack.org> deadmeat wrote: > Do the first 5 minutes of the tutorial mention this? No.. so the newcomer to > Python will go off thinking one thing, and not know any better until s/he > gets to the relevant section. By then, s/he will be able to correct his/hers erronious thoughts. What's the problem with that? -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From matt at virtualspectator.com Wed Apr 25 16:34:23 2001 From: matt at virtualspectator.com (Matt) Date: Thu, 26 Apr 2001 08:34:23 +1200 Subject: python, zope, UML .... ? In-Reply-To: <3AE71AFC.E2EBDFFD@VerizonWireless.com> Message-ID: > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Bill Scherer > Sent: Thursday, April 26, 2001 6:44 AM > Cc: python-list at python.org > Subject: Re: python, zope, UML .... ? > > > David LeBlanc wrote: > > > Now all that's needed is a UML tool based on WxWindows or tkinter! > > Are you volunteering to head up a project? Please? Sort of, when I get the time. I can certainly put together a framework, though my UML experience is pretty low compared to my normal scribbling of diagrams on A1 paper. Questions I have are : - What do people like most about UML (broad question ...) - What rendering technologies make sense ? I was thinking of either of the following a)WxWindows or tkinter ... though I have yet to use any of those, I'm sure they are simple. b)OpenGL ... with my own widget set .... of which I do have more experience. c)html, PIL, and javascript ... which for some reason doesn't seem so absurd, so worth talking about. > > I usually use uml with my larger projects. The tools are always written > in java (OD, Argo, Thorn), and run miserably and use lots of memor... > Anyway, a Python based UML CASE tool could be a GREAT thing to have. > > Then integrate it with IDLE.... > > - Bill > > -- > http://mail.python.org/mailman/listinfo/python-list > From utzqtk at adsmontreal.com Fri Apr 20 00:30:15 2001 From: utzqtk at adsmontreal.com (utzqtk at adsmontreal.com) Date: Fri, 20 Apr 2001 04:30:15 GMT Subject: BUY AND SELL ALMOST ANYTHING ONLINE Message-ID: Visit the webs best free online classified ads web site where you can buy and sell almost anything right online! Its fast, easy and FREE! From aleaxit at yahoo.com Mon Apr 16 16:52:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 16 Apr 2001 22:52:21 +0200 Subject: break levels References: <3ADB447A.56CE45AA@noaa.gov> Message-ID: <9bfm370h6a@news2.newsguy.com> "Benjamin.Altman" wrote in message news:3ADB447A.56CE45AA at noaa.gov... > Is there a particular reason that Python can't break over multiple > loops? Example: > for i in range(0,10): > for j in range(0,10): > if some_condition: > break(2) > > which would break out from the inner and outer loop. This would be > similar to the Bourne shell usage of break. I suppose you could do a > try and throw an exception instead but it seems that sometimes doing a > break(x) would be convenient. See the recent 'named blockes' (sic) thread, where the same functionality was desired the Java way (giving a loop a name, and using the name on the break, rather than using a number on the break -- much more readable and robust, IMHO). Besides exceptions, make-into-a-function (since _return_ can then be used to break out of the nested loops that were made into a function) is also a workaround here (although in some cases I agree that multi-level break _would_ be handy). Alex From scarblac at pino.selwerd.nl Tue Apr 3 05:47:19 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 3 Apr 2001 09:47:19 GMT Subject: alny way of not using glob? References: <9aar5f$8n9$1@news.netmar.com> Message-ID: edwardt at trillium.com wrote in comp.lang.python: > Hi I am trying to get a list of the files in the current direcoty by > using glob. But I have the following trouble: > 1. glob is a standard module in python 2.0 but not 1.5.2 whihc I am > currently using and the sys admin has no intention to upgrade it ... > 2. glob is unix dependent? My script needs to run in windows also ... Glob is also a standard module in 1.5. It is cross platform. So no problem. > The code I am using is: > targetFiles = reduce(operator.add, map(glob.glob, arguments[1:])) > > value is arguments[1:] is "*.py" ["*.py"], more likely. > when I print targetFile, it is: > ['tp_tc_TNLC01.py', 'tp_tc_TNLC02.py', 'tp_tc_TNLC04.py', 'tp_tc_TNLC0 > 6.py', 'tp_tc_TNLC07.py', 'tp_tc_TNLC08.py', 'tp_tc_TNLC09.py', 'tp_tc > _TNLC10.py', 'tp_tc_TNLC11.py', 'tp_tc_TNLC14.py', 'tp_tc_TNLC15.py', > 'tp_tc_TNLC16.py', 'tp_tc_TNLC17.py'] > > How can I get around that?? Around what? Looks good to me, what did you expect it to be? -- Remco Gerlich From philh at comuno.freeserve.co.uk Wed Apr 11 15:14:14 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Apr 2001 20:14:14 +0100 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <9b0pqq$1kt$1@news1.xs4all.nl> Message-ID: On 11 Apr 2001 05:24:42 GMT, Boudewijn Rempt wrote: >Dry Ice wrote: > >> programmers and the results begin to show fatigue. >> Slick as Java is, for example, I have found the >> real-world results of which I'm aware so far to >> be troubling in the Windows environment. Still >> evaluating, but it does not look good. > >> What "substantial" is might be defined in terms >> of project length. Perhaps something which would >> take a good programmer several months. > >In that case Kura qualifies: it's about 20.000 lines >of Python (including a few thousand lines generated >by the gui builder) What GUI builder are you using? -- *****[ Phil Hunt ***** philh at comuno.freeserve.co.uk ]***** "Mommy, make the nasty penguin go away." -- Jim Allchin, MS head of OS development, regarding open source software (paraphrased). From claird at starbase.neosoft.com Mon Apr 9 11:20:01 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Apr 2001 10:20:01 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 9) References: <57B2E1BA161B6C9D.AB31E8467EC3176C.F05A376F89B952EB@lp.airnews.net> Message-ID: <77A9ACB944CD926D.87C2E7C15038F9A0.79617FBB22808934@lp.airnews.net> In article <57B2E1BA161B6C9D.AB31E8467EC3176C.F05A376F89B952EB at lp.airnews.net>, Oleg Broytmann wrote: . . . Oops. My error. It was actually Steve Holden who wrote this. And, thanks to the miracles of automation, I managed to insert myself somewhere in the middle and make a mistake that utterly obscured the fact. My apologies, all around. Next week, whatever faults I commit, they'll be different from this one. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aahz at panix.com Thu Apr 12 15:01:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Apr 2001 12:01:06 -0700 Subject: Threading question References: Message-ID: <9b4u1i$1m3$1@panix3.panix.com> In article , Steve Holden wrote: > >I don't use threads much myself, but the docs suggest the statement you >quote only *creates* a thread, and that you will have to call its run() >method to start it executing. This would, I presume, require > >tmp.run() NO! DON'T DO THAT! You need to call the start() method. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From chris at voodooland.net Fri Apr 13 12:24:23 2001 From: chris at voodooland.net (Chris Watson) Date: Fri, 13 Apr 2001 11:24:23 -0500 (CDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: Message-ID: <20010413111735.R1041-100000@open-systems.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Why is that bad, but taking free code and putting it into a closed-source > product, thus also killing its free nature, is somehow good? Ok. Again I refer to my original argument to this. Assuming foo.c version 1.0 released under the BSD license. Company X comes along and grabs a copy of foo.c version 1.0. Modifies it and refuses to release *their* work. Or their copy of version 1.0 of foo.c. Ok now, tell me what divine creature came alone with pointy horns or angel wings and completely irradicated foo.c version 1.0 under a BSDL off the face of the earth. The *same* version company X took a copy of and modified? The mozilla person never answered this. Simply because it is not possible. Cannot happen. Will not happen. This is a red herring and has no basis in reality whatsoever. You cannot completely remove a piece of code released to the public. It just is not possible. So the GPL must have other motives since this whole "but GPL keeps it free" crap is allowed to be spewed regardless if it's patently false. You cannot remove or close up the original works released to people as open source. Anyone who says that should try a different brand of mind altering pharmaceutical. ============================================================================= - -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: Made with pgp4pine 1.75-6 iD8DBQE61yg9oTcdKVapx58RAsnqAJ9K+dQkUfA54yvxZoxOddO8FoRKFwCcCCHu QCcJtRGOii0PYXpjFh7nKNA= =e9bT -----END PGP SIGNATURE----- From tim.one at home.com Fri Apr 13 18:42:51 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 13 Apr 2001 18:42:51 -0400 Subject: still wondering (was Re: Pep 245) In-Reply-To: <%CKB6.167$E4.7391@uchinews> Message-ID: [Aahz] > I'm still not claiming that I've met Tim. [Ben Wolfson] > But are you claiming that you *haven't* met Tim, or are you just > refraining from comment? I expect most sane people would agree Aahz is commenting entirely too much on this issue, so it can't be the latter. As he says, he hasn't claimed to have met Tim. clearing-up-confusion-is-a-special-skill-ly y'rs - tim From ullrich at math.okstate.edu Wed Apr 11 12:00:45 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 11 Apr 2001 16:00:45 GMT Subject: After Parrot, what next? References: Message-ID: <3ad47f1c.74626801@news.okstate.edu> On 10 Apr 2001 11:54:35 GMT, neelk at alum.mit.edu (Neelakantan Krishnaswami) wrote: >Roy Smith wrote: >> A bunch of us were discussing the new Parrot syntax (i.e things like >> "left_angle_bracket_right_angle_bracket") today and came up with a great >> idea for a new language syntax, which mixes the best ideas of Parrot and >> XML. Instead of: >[ snip ] >> you'd do: >> >> >> line >> getlines >> >> >> line >> >> >> >> >> So, what'ya think? > >You're too late. > > http://www.w3.org/TR/xexpr > >Yes, I thought it was a joke at first too, but no joy. How can >anyone possibly consider this a good idea? The mind boggles. :( The fact that TeX already exists does not mean there's no need for MathML, nor is MathML a replacement for TeX; they have different uses in different domains. >Neel From sill at localhost.kitenet.net Sun Apr 8 06:17:19 2001 From: sill at localhost.kitenet.net (rainy) Date: Sun, 08 Apr 2001 10:17:19 GMT Subject: Good Editor? (What's the big deal with syntax colouring?) References: <008F0A63472BD311AF9800104BCD102561CD3E@minirex.vmlabs.com> <99erbn$3e@gap.cco.caltech.edu> Message-ID: On Tue, 27 Mar 2001 16:44:29 -0500, D-Man wrote: >On Thu, Mar 22, 2001 at 10:38:00PM -0800, Nathaniel Gray wrote: >| Timothy Grant wrote: >| > Now if only else didn't highlight but else: did > >$ vim $VIM/syntax/python.vim > >;-) you can adjust the regexes to your preferences > >| Ah, but that's what auto-indent is for! When NEdit doesn't indent the >| first line of a block I know I forgot the colon at the end of the last line. >| >| One of these days I'll send in my ultra-improved auto-indent Python macros >| for NEdit. I'm still working on the auto-dedent macros... > >I can't wait for auto-dedent in vim, it has most of the auto-indent >correct. Anyone want to work on making it? Vim is python-scriptable >as well. > >-D I tried to script it in python so that it'd indent only when the last line ends in a colon, but it didn't work for some reason. I even asked on relevant newsgroup but nobody could help. So, right now I simply have a list of keywords liek if, else, class, etc in cinw like this in my .vimrc: set cinw= :autocmd BufNewFile,BufRead *.py set cinw=try,if,def,except,for,while,else, elif,class I don't remember why, but the first line there is needed because by default cinw has some keywords it indents on.. in *all* files! Or maybe not by default but because of some other option i have set.. > > -- Andrei From olaf.zanger at soli-con.com Sun Apr 22 09:24:11 2001 From: olaf.zanger at soli-con.com (Olaf Zanger) Date: Sun, 22 Apr 2001 13:24:11 GMT Subject: Cross-platform serial port access References: <99d274$ogv$1@news.netpower.no> Message-ID: <3AE2DC7A.E308B287@soli-con.com> hi there, call it late :-) answer is better than none i have the same question as you have my guess: win95: http://starship.python.net/crew/roger/SioModule os2: also on starship linux: ftp://ftp.visi.com/users/grante/python/ they are not platform independent i used the lcom.py to get my own findings. so i can call the other modem and get a connection. that's it then, nothing works anymore. have you got any clue? thanks in before olaf David Brown schrieb: > > I am relatively new to Python, but am planning to use it for a number of > small programs that should be able to run both on Windows (for initial > development and testing) and Linux (once we get a server running properly). > Some of these programs will need to communicate with external devices using > a serial port - is this going to work in a portable fashion using Python? > Does anyone know if Linux supports RTS toggle handshaking (i.e., the RTS > line is high while transmitting, for convenient connection to RS-485 > convertors), and is it easy to control from Python? Are there any Python > modules designed to work with modems? > > Thanks for any help in getting me started. > > David Brown > Norway -- soli-con Engineering Zanger Dipl.-Ing. (FH) Olaf Marc Zanger Lorrainestrasse 23 3013 Bern / Switzerland Fon: +41-31-332 9782 Mob: +41-76-572 9782 mailto:info at soli-con.com mailto:olaf.zanger at soli-con.com http://www.soli-con.com From footech at get2net.dk Sun Apr 22 06:54:30 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Sun, 22 Apr 2001 12:54:30 +0200 Subject: difflib Message-ID: Has anybody got any references for the algorithm used in difflib. The documentation says: "The basic algorithm predates, and is a little fancier than, an algorithm published in the late 1980's by Ratcliff and Obershelp under the hyperbolic name ``gestalt pattern matching.'' The idea is to find the longest contiguous matching subsequence that contains no ``junk'' elements (the Ratcliff and Obershelp algorithm doesn't address junk). The same idea is then applied recursively to the pieces of the sequences to the left and to the right of the matching subsequence. This does not yield minimal edit sequences, but does tend to yield matches that ``look right'' to people." and there is a link to Dr. Dobbs journal, but the article is only available on cd-rom. Are there any explanations available elsewhere? Mikkel Rasmussen From owen at astrono.junkwashington.emu Tue Apr 10 13:02:18 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Tue, 10 Apr 2001 10:02:18 -0700 Subject: Class Variable Question References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> Message-ID: <9aveat$10aq$1@nntp6.u.washington.edu> In article , "Steve Holden" wrote: >That's correct. Python gives you "enough rope to shoot yourself in the >foot", and so does not offer the protection schemes associated with >statically-types languages like Java and C++. This increases the flexibility >of the language, at the (slight) risk of errors which would not occur in >Java or C++. I just wanted to point out that there are dynamically typed languages that do not allow modifying instances once they are created (except by modifying the class itself). Smalltalk is an excellent example. Dynamic typing is a wonderful thing and one of Python's many strengths. However, being able to modify instances is less obviously a positive feature. I believe the Python's way is called "prototyping". A class is a prototype or object factory for creating new objects. Once you get the object you can do anything you like with it. I'm not a big fan of prototyping for several reasons: - typos can cause the kind of damage you mentioned - it complicates type checking, implementation of safe interfaces, etc. However, it presumably does have uses, and it hasn't caused much trouble for me, so I'm not complaining too hard. On the whole Python is a very nice language -- a reasonable class implementation, nice exception handling, good collection classes, runs on nearly everything, good for large and small projects... My guess is that the reason Python uses prototyping is that it was simpler to implement the language that way. -- Russell From sheila at spamcop.net Fri Apr 13 16:15:23 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 13 Apr 2001 20:15:23 GMT Subject: Pythonwin interactive window editing? References: <3AD7560F.9FFDB567@hotmail.com> Message-ID: What I did: I left my BeOpen install of Python intact and went here: http://www.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all and grabbed build 138, which is the Win32all extensions for BeOpen Python 2.0. Then I installed build 138. Now I have my choice, of using either IDLE 0.6 or PythonWin. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Fri, 13 Apr 2001 19:40:23 GMT, scott wrote in comp.lang.python in article <3AD7560F.9FFDB567 at hotmail.com>: :Just installed Pythonwin (ActivePython build 202) on NT4. Seems very :nice so far except... : :Previously (an hour ago) I used the history feature of IDLE 0.6 that :came with BeOpen Python 2.0 to recall previous commands (Alt-p etc). Is :something like this available in the Pythonwin interactive window? I :uninstalled BeOpen Python 2.0 before installing Pythonwin. :Thanks in advance. : :P.S. :On a related note, I can't seem to use IDLE anymore. I tried to start :c:\Python20\Tools\IDLE\idle.pyw :I got an error message (unable to locate DLL tk83.dll). Sure enough, :this isn't on my system. :Is IDLE supposed to work using Pythonwin? : :The following (and the fact that IDLE is included in Activestates :distribution) seems to indicate it should: :http://www.activestate.com/ASPN/Downloads/ActivePython/More :"New in this version: ... this distribution includes the _tkinter module :which allows the use of the IDLE IDE... : :Can I / how can I use IDLE from the Pythonwin distribution? :Again, thanks for any insights. From grey at despair.rpglink.com Tue Apr 17 20:13:50 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 18 Apr 2001 00:13:50 -0000 Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCC813.97DD9D6F@Lugoj.Com> Message-ID: On Tue, 17 Apr 2001 15:47:47 -0700, James Logajan wrote: >If your objection is that there are too many releases of the language, then >I would agree completely. Guido and the entire Python development team need >to take a five year vacation. Releasing new versions more often than about >every two years, except for bug fixes, is probably self destructive. If Larry Wall's experience is any marker, no, it isn't. Again, using Larry Wall's experience major releases of the language come slower and slower as the language matures. Anyone have Larry's address to the Perl/O'Reiily conference last year (Monterey, Ca)? He even states that the releases come slower and slower as time goes on. Ahh, here it is, no specifics, "As the size of the Perl core and libraries gets bigger, it takes longer to rev a major release, so it naturally gets slower. Perl 1, Perl 2, Perl 3, Perl 4, Perl 5. [Sound of beat on drum gets slower] Then we start getting subreleases and then they get slower. Then we get sub-sub versions, and they get slower and slower. Eventually the subversions are taking as long as the original Perl 1 - Perl 2 thing, but that's because they are actually accomplishing just as much." I know how people loathe Perl comparisons here but fast releases early on are to be expected and it doesn't seem to have harmed Perl's advance through the programming world. In fact, wonder what we could devine from the Java release schedule. ;) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From kens at sightreader.com Thu Apr 19 00:51:00 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 18 Apr 2001 21:51:00 -0700 Subject: Any Neural Net code in Python? I want to filter out spam email Message-ID: <003801c0c88c$54fd7fd0$04090a0a@upcast.com> "Dan Maas" says: > > I've been saving up all the spam messages I get for the past two months. > > I have about 1869 spam messages saved. > > Now I'd like to develop a neural net based filter for my email program > > and train it to recognize these messages as spam. > > Cool... I assume the main thing you are worrying about is accidentally > rejecting non-spam emails, which might happen too easily with a > naive keyword-based system. > > How about this - apply a whole set of tests to the message. Each test > gives a "spammness" score - e.g. 10 points for being all caps, 50 points > for having the word 'viagara', 100 points for having a suspicious From: > address like *@yahoo.com. Add the scores from the different tests, and > if the sum exceeds, say, 200 points, then call it "spam." > > So, how do you figure out a good value for each test score? This is where > you could use a neural network or genetic algorithm. Pick a set of > scores, feed the program lots of messages (both spam and non-spam), and > see how accurate it is. Iterate until it rejects every spam email and > accepts every non-spam... > > Dan > -- > http://mail.python.org/mailman/listinfo/python-list Excellent idea, Dan. That's conveniently sidesteps the most difficult issue: getting the neural network to actually come up with linguistic rules. Once an intelligent human specifies the set of rules, the neural net should have no difficulty coming up with an optimal non-linear function of pre-processed features (i.e. the "rules") to identify spam. Analysis of the weights after training will help remove rules that turn out to be irrelevant. In other words, the input vector is simply the results from your arbitrary rule set. Since irrelevant rules are fairly harmless (other than decreasing performance), one could initialize it to include a rule for every word that occurs in spam messages more often than in non-spam messages. Then supplement it with rules like the ones you mention. Here's another idea for acquiring sample data. Send 'please send me more info' messages to everyone who has sent you spam, with your newly created spam recipient email address. Your address will probably be sold to everyone. BTW, make sure your spam recipient is on an ISP that does -not- defend against spam! (Technically, it's not actually spam you'd be receiving since you are explicitly requesting it, but close enough :-) I want to be involved in this project. Let's take this offline. - Ken ---------------------------------------------------- Copyright (c) 2001 by Ken Seehof This document may not be distributed, copied, duplicated, or replicated, or duplicated in any form without express permission by Ken Seehof. Permission is hereby granted. kseehof at neuralintegrator.com ---------------------------------------------------- The opinions expressed herein are not necessarily those of George W. Bush. -------------- next part -------------- An HTML attachment was scrubbed... URL: From philh at comuno.freeserve.co.uk Sat Apr 14 06:51:29 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 14 Apr 2001 11:51:29 +0100 Subject: OT - Closing Off An Open-Source Product References: Message-ID: On Fri, 13 Apr 2001 17:03:48 -0500 (CDT), Chris Watson wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > > >> I'm not sure I fully understand the implications of this license. >> Let's consider two scenarios. > >Right. I will try and clarify. This clause simply means. That given in >your example my code P, Can not be put under the GPL or any other >restrictions. If you add my code to a GPL app, the GPL would violate my >license. Not your license as you stated in your previous post. I see no clause "you can't link it to the GPL" in the license. > Hence making for a lawsuit. It's strictly meant to contain the >GPL. Keeping GPL code GPL is fine. Trying to GPL my code is not fine. It >would be illegal. I have no problem like i've stated if people want to GPL >their code. That is their choice. But I need some guarantee that the >clause 2 of the GPL cannot infect *my* code against my wishes. The >standard BSDL does not ensure that. I have to have some clause that >combats clause 2 of the GPL. Is this getting clear? Your intention is clear, now, yes. But your license *as currently written* doesn't forbid linking your code with GPL'd code > You are free to use my >work in any fashion you choose. If it is used in a larger GPL work, I have >no doubt a court would find the GPL does not apply to my code. Now you have lost me. I agree that a court would find this, but so what? P is under your license. PP is under your license. Q is under the GPL. Therefore anything that links with Q+PP must also be GPL'd. So I ask you again, and I'd like you to answer yes or no, so I can understand your position (and quote the relavant bits you are answering): (1) is it your intention that the linking of Q with PP be illegal? (2) is it your opinion, in your license as it stands, that a court would actually rule that the linking of Q with PP is illegal? > Regardless >of clause 2. You used my code knowing that clause 3 in my license >prevents the GPL from used on my copyrighted code. Correct PP is still licensed under your license, not the GPL. But Q *is* licensed under the GPL. Is it your intention to forbid this (presumably under the legal doctrine that Q is a derivative work of PP)? >Whatever code you >write, you can let the GPL taint, May I suggest that you stop using emotionally loaded language. If you do so, you are likely to benwefit by finding your thought processes become clearer. I know you don't like the GPL; there's no need to labour the point. > or put whatever license on it you wish. So, in my example, you've no objection to me GPLing Q, even though it means that some users of PP (those that use it with Q) will have to GPL their code? >The main point being once my code is BSDL'ed you can't take away the >freedom offered by that license with the GPL or any other viral license. But how is it taking away freedom? It is no more doing so than using your code in a proprietary product, which you are happy with. I don't understand your position. >I see it as the standard BSDL with the added benefit that it stays BSDL. >But my clause does not FORCE my will onto others, or FORCE them to use my >license. No more than the GPL does, or Microsoft's EULA does. All licenses impose conditions, that's their whole point. If you don't like the license conditions, don't use the code. > It just enforces my license on my code. Nothing more nothing >less. I hope I explained that well enough. Nope. And as the 2nd call has been >made to kill this thread from the lists, just reply to me privately if you >wish to continue this. The lists is probably sick of this by now. > -- *****[ Phil Hunt ***** philh at comuno.freeserve.co.uk ]***** "Mommy, make the nasty penguin go away." -- Jim Allchin, MS head of OS development, regarding open source software (paraphrased). From phd at phd.fep.ru Tue Apr 24 10:41:35 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 24 Apr 2001 18:41:35 +0400 (MSD) Subject: curses.panel Message-ID: Hello! Is there anyone who program with curses these days? These days are full of GUI and CGIs, but as they included curses.panel as a new module in curses, I think there are curses users. I want to learn curses. Yes, curses. If I would want to write a GUI - I'd do it with graphical toolkit, probably wxWindows. But now I want to learn curses. I am newbie in curses programming. I never wrote curses programs in C, and I want to learn curses by programming in Python. Ok, I wrote few very simple program - they work. So I started to write more complex program... and stumbled upon panels. I cannot use panels - cannot change stack order, e.g. Can anyone help? from time import sleep import curses, curses.panel def make_panel(stdscr, h,l, y,x, str): win = stdscr.subwin(h,l, y,x) win.erase() win.box() win.addstr(2, 2, str) panel = curses.panel.new_panel(win) return win, panel def test(stdscr): curses.curs_set(0) stdscr.box() stdscr.addstr(2, 2, "panels everywhere") win1, panel1 = make_panel(stdscr, 10,12, 5,5, "Panel 1") win2, panel2 = make_panel(stdscr, 10,12, 8,8, "Panel 2") stdscr.refresh() sleep(1) panel1.top(); curses.panel.update_panels() stdscr.refresh() sleep(1) # This DOES NOT work! panel1 is still bottom panel :((( for i in range(50): # This works... partially... panel1 is not updated :((( panel2.move(8, 8+i) stdscr.refresh() sleep(0.1) sleep(1) if __name__ == '__main__': curses.wrapper(test) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at pythonware.com Mon Apr 23 10:53:07 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 23 Apr 2001 14:53:07 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: Stephen Hansen wrote: > It explains the infinate spam of warning messages I get, though, > since quite a few pointers are initialized to NULL and that NULL is > never read in. This is not something I think the Gods'o'Python > would care to have fixed, though. Dispite a 'no warnings' policy :) other compilers complain about possible "use before assignment" if you don't initialize them to NULL... Cheers /F From moshez at zadka.site.co.il Sat Apr 7 01:50:41 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 07 Apr 2001 07:50:41 +0200 Subject: Booleans (was: Conditional operator in Python?) In-Reply-To: <3ACDF088.88E7406A@alcyone.com> References: <3ACDF088.88E7406A@alcyone.com>, <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> <9aadjg$ipg$1@nntp6.u.washington.edu> <9acvud$uk6$1@nntp6.u.washington.edu> Message-ID: On Fri, 06 Apr 2001 09:36:24 -0700, Erik Max Francis wrote: > This is true. I would be mollified if there were a builtin operator > that tests truth in the same way that if ...: does. It would be named > something like bool or boolean and would return a 0 or 1 and nothing > else: > > >>> bool(0) > 0 > >>> bool(3) > 1 > >>> bool('hello') > 1 > >>> bool('') > 0 > >>> bool([]) > 0 > >>> bool([1]) > 1 > >>> bool(None) > 0 It's called operator.truth -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From moshez at zadka.site.co.il Tue Apr 3 15:59:32 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 03 Apr 2001 21:59:32 +0200 Subject: Boolean Values Message-ID: For all those crying for boolean values, here's a simple module that will hopefully solve all your needs: =========== Boolean.py ============== # Boolean.py class _true: def __nonzero__(self): return 1 class _false: def __nonzero__(self): return 0 class _dunno: def __nonzero__(self): raise ValueError("I dunno") import __builtin__ __builtin__.true = _true() __builtin__.false = _false() __builtin__.dunno = _dunno() =========== /Boolean.py ============== Use as follows: Python 2.1b2 (#1, Mar 24 2001, 09:04:30) [GCC 2.95.3 20010219 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import Boolean >>> if true: ... print "yay!" ... yay! >>> if false: ... print "wrong" ... >>> if dunno: ... print "huh?" ... Traceback (most recent call last): File "", line 1, in ? File "Boolean.py", line 12, in __nonzero__ raise ValueError("I dunno") ValueError: I dunno To the people who don't know me yet: when I say "it can be done in Python in 20 lines, here's the code", I usually mean "I don't think it has any merit. Nobody's done it not because it's hard, but because it's useless" ;-) I'm only clarifying lest someone will actually try to get this integrated into Python ;-) -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From jkraska1 at san.rr.com Thu Apr 26 19:17:52 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 26 Apr 2001 23:17:52 GMT Subject: Win32 Extenstion modules How To ??? References: <3AE7ADC9.C82A9C18@yahoo.com> Message-ID: Re: EXTENSIONS >> Does anyone have any complete examples allow with how >> to set up MS VC++ 6 In your Python distribution, go to the "pc" directory and then goto the "example_nt" directory. There is a Visual C++ example of a simple module there. You'll want to make certain that your include path reflects the python "Include" directory, and that your Library path includes the location of the python[X].dll and .lib. Once you work past this trivial example, if you desire to impliment a full Python object, take a look at objects/xxobject.c. You will also eventually benefit from looking at the implementations of listobject.c and dictobject.c, although don't start with these. Lastly, __Essential Python Reference__ has an outstanding section on Extending and Embedding. I found it a very useful learning tool.. C// From jmg at ecs.soton.ac.uk Wed Apr 25 08:03:32 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 25 Apr 2001 13:03:32 +0100 Subject: How do I do this without class methods ? References: <9c63jk01duq@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > If attributes with the same name are set on both > instance and class, and you access that name through > an instance, the class attribute will not be fetched > (unless you explicitly ask for it, self.__class__.wodger). The last line is intersting new information, thanks. > If as it seems you're always accessing attribute .wodger from > instances, never classes, and only ever wants to set it on a > per-class basis instead (so all the instances extant get affected) This is almost exactly what I want (apart from an edifying discussion around the subject - for your contribution to which, I thank you) Specifically, what I want to be able to do (in context of the toy model) is to say `Look, guys, today's number is N', before any instances of the woderwicks and their relatives are created, and then have everyone (those already extant, and those yet to be born) pronounce that number in his own fashion whenever he is called upon to do so: w = woderwick() -> zero r = rodrigo() -> cero and_the_Lord_said_let_the_number_be( 2 ) woderwick() -> two rodrigo() -> dos print w.wodger -> two print r.wodger -> dos > maybe what you need is a different approach: > > class woderwick: > bwian = [ 'zero', 'one', 'two', 'many' ] > _wodger_index = 0 # default index > def __getattr__(self, name): > if name=='wodger': > return self.bwian[self._wodger_index] > raise AttributeError, name > def __init__ ( self ): > print self.wodger So far, great . . . > # Affect class through instance... > def welease_bwian ( self, N ): > self.__class__._wodger_index = N . . . but this is not quite what I want; instead I would like to be able to change the index for ALL classes in the hierarchy in one go. This should do the trick: def welease_bwian( index ): woderwick._wodger_index = index Hmm . . . this whole example is making me misspell return as weturn. Thanks, Jacek (Full version performing to spec. below . . .) ----------------------------------------------------------- class woderwick: bwian = [ 'zero', 'one', 'two', 'many' ] _wodger_index = 0 # default def __getattr__ ( self, name ): if name == 'wodger': return self.bwian[self._wodger_index] raise AttributeError, name def __init__ ( self ): print self.wodger def welease_bwian( index ): woderwick._wodger_index = index class rodrigo(woderwick): bwian = [ 'cero', 'uno', 'dos', 'demasiados' ] class roderich(woderwick): bwian = [ 'gar nichts', 'eins', 'zwei', 'viele' ] class roderik(roderich): # :-) bwian = [ 'geen bal', 'een', 'twee', 'te veel' ] class rafal(woderwick): bwian = [ 'figa z makiem', 'raz', 'dwa', 'kupa' ] # Defaults work w = woderwick() # zero r = rodrigo() # cero # Change number for all present and future instances welease_bwian( 1 ) print w.wodger # one woderwick() # one print r.wodger # uno rodrigo() # uno From fredrik at pythonware.com Fri Apr 6 03:38:59 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Apr 2001 07:38:59 GMT Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <3AC680EE.997108AB@northwestern.edu> <3ac69340_2@news4.newsfeeds.com> <3AC8BF11.1501D4E2@seebelow.org> <9aib2g01rch@drn.newsguy.com> Message-ID: John J. Lee wrote: > > Yes, but are they doing it in "real time"? > > You make it sound as if that were the only kind of programming worth > doing! ;-) I've used Python in really serious real time systems -- they get huge amounts of new data every 15 minutes or so, and must get rid of them before the next batch arrives... (and if they're not finished by 6 pm, *everyone* will notice ;-) Cheers /F From db3l at fitlinxx.com Wed Apr 4 19:38:43 2001 From: db3l at fitlinxx.com (David Bolen) Date: 04 Apr 2001 18:38:43 -0500 Subject: Newbie has question that's not exactly Python... References: Message-ID: "Chris Gonnerman" writes: > Andrew was right on the money regarding the print statement > and the extra \n it adds. I generally do it like this, > though, *depending* on that extra newline. On my Apache > server under Python 1.5.2, this works great. I didn't need > the \r's either. Just FYI, but including CR ('\r') would be technically more accurate, as HTTP (and the majority of text based IETF network protocols) define CRLF as the official line terminator (except for individual entity blocks which can have locally defined terminators). But most client implementations will be written to just look for the LF ('\n') and strip any trailing CR or LF. -- -- 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 rcameszREMOVETHIS at dds.removethistoo.nl Sun Apr 8 18:24:29 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sun, 08 Apr 2001 22:24:29 GMT Subject: Refined: How do I launch 'somewhere/Sweety.py' without 'somewhere/'? References: <3acfd343.1841976@news.muenster.de> <3ad04333.273637@news.muenster.de> Message-ID: Martin Bless wrote: >It seems my question wasn't precise enough. Meanwhile I know better >what I'm looking for ;-) > >Currently I'm deleloping several useful scripts that reside in >*different subdirs* of my import hierarchy. I'd like to be able to >call them from an arbitrary directory, without changing that >directory, so for example I could have my own directory listing by >issuing a command like > PYTHON MyDir.py >Though MyDir.py is on the import-path, it seems it isn't found for >executing unless I specify explicitly its exact path. > >*** So my QUESTION goes like this: >How can I launch scripts that lie in different subdirs in my import >paths from an arbitrary directory without having to specify the path >of the script and without changing the directory? If you're talking about Windows (which you seem to be) and all you're trying to do is save some keystrokes (any other point eludes me, to be honest) why don't you make some shortcuts to your PYTHON.EXE with the proper commandlines? Robert Amesz From jcopella at cfl.rr.com Fri Apr 13 12:59:57 2001 From: jcopella at cfl.rr.com (John Copella) Date: Fri, 13 Apr 2001 16:59:57 GMT Subject: [Q] Rolling your own binary distribution/installation of Python 2.0 References: <9asndg0k9p@news1.newsguy.com> Message-ID: Hmmm. I looked into the "Installer" utility you referred me to (and the FAQ another gentleman mentioned) and these are close, but don't quite address the problem. I probably didn't explain this very well, but I don't have a top-level script to "freeze" -- which is the precondition these tools seem to require. What I need to do instead is provide just the Python runtime facilities (interpreter, modules, etc.) so that field engineers can develop scripts on the customer's machine. The ideal would be to just tar and zip the contents of --prefix at some suitable location, but I suspect this approach is too simple-minded. I need to support HP-UX and AIX, fwiw. Did I miss something? Clearly this is possible -- ActiveState has done it (unfortunately only for Windows, Linux and Solaris), I'm just hoping it's not a lot of work. Any additional ideas short of digging into the Python installation scripts and rolling my own? John Copella Alex Martelli wrote in message news:9asndg0k9p at news1.newsguy.com... > "John Copella" wrote in message > news:NFkA6.14489$Qi6.1515105 at typhoon.tampabay.rr.com... > > I am in the early phases of developing a product based on Python and will > > need to provide a binary distribution for customers who do not already > have > > Python installed. Of course, the distribution should be installable > > anywhere in the filesystem. Is there any easy way (thinking here of an > > existing utility or install script) to package my Python binaries so that > > they can be installed in an arbitrary location in the filesystem? For > > A binary distribution will of course need to depend on the > specific platform you're deploying on. If it's Windows, > see http://starship.python.net/crew/theller/py2exe/; if > it's not (or, just to explore all possibilities, even if > it IS:-), see the links at the end of the same page, most > particularly Gordon McMillan's "installer". > > > Alex > > > From sholden at holdenweb.com Wed Apr 11 15:09:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Apr 2001 15:09:05 -0400 Subject: Help for urllib error : 'no host given' References: Message-ID: <1Y1B6.150820$5H6.5454426@e420r-atl2.usenetserver.com> wrote... > > Hello, > > I cannot understand why I get the following error. > > 1) Here is an extract of the web page content I want to parse : > ------------- > function RedirectPage() > { > document.location ="http://www.nicewebsite.com"; > } > ------------- > > > 2) Here is the program I use to extract the URL to which I need to redirect my > browsing (ugly, I agree) > ------------- > q=re.compile("document.location =.*") > t2=q.search(f3) # f3 contains the full string of the web page > b= t2.group() > q1=re.compile('[^document.location ="].*[^";]') > t4=q1.search(b) > redirectURL=t4.group() > f4=urllib.urlopen(redirectURL).read() > -------------- > The program successfully extracts the name of the Url. I can print the exact > text "http://www.nicewebsite.com" (without the quotes). > > > 3) And finally here is the traceback I get : > ----------------------- > Traceback (innermost last): > File "./MyProgram", line 157, in ? > f4=urllib.urlopen(redirectURL).read() > File "/usr/lib/python1.5/urllib.py", line 59, in urlopen > return _urlopener.open(url) > File "/usr/lib/python1.5/urllib.py", line 157, in open > return getattr(self, name)(url) > File "/usr/lib/python1.5/urllib.py", line 272, in open_http > return self.http_error(url, fp, errcode, errmsg, headers) > File "/usr/lib/python1.5/urllib.py", line 285, in http_error > result = method(url, fp, errcode, errmsg, headers) > File "/usr/lib/python1.5/urllib.py", line 456, in http_error_302 > return self.open(newurl, data) > File "/usr/lib/python1.5/urllib.py", line 157, in open > return getattr(self, name)(url) > File "/usr/lib/python1.5/urllib.py", line 247, in open_http > if not host: raise IOError, ('http error', 'no host given') > IOError: [Errno http error] no host given > --------------------------- > > > For professional reason, I had to change the web site name above. Could in any > case urllib() be sensitive to the content of the requested URL (full of "&" > chars) ? > > Thank you for any help. > Patrick: Maybe it's the URL: >>> import re, urllib >>> q=re.compile("document.location =.*") >>> t2=q.search(f3) >>> b= t2.group() >>> q1=re.compile('[^document.location ="].*[^";]') >>> t4=q1.search(b) >>> redirectURL=t4.group() >>> redirectURL 'http://www.nicewebsite.com' >>> f4=urllib.urlopen(redirectURL).read() >>> f4 '\015\012 \015\012 \015\012 \015\012\015\012' >>> Seems to work fine with the URL you gave, so have you checked that the URL you are using really is a valid one? It looks like you might have missed a slash out: >>> urllib.urlopen("http:/www.nosuchsitehere.com") Traceback (innermost last): File "", line 1, in ? File "d:\python20\lib\urllib.py", line 61, in urlopen return _urlopener.open(url) File "d:\python20\lib\urllib.py", line 166, in open return getattr(self, name)(url) File "d:\python20\lib\urllib.py", line 261, in open_http if not host: raise IOError, ('http error', 'no host given') IOError: [Errno http error] no host given Hope you track it down. regards Steve From vincent_a_primavera at netzero.net Thu Apr 5 09:47:52 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Thu, 5 Apr 2001 09:47:52 -0400 Subject: Paths... Message-ID: <01040509475202.00606@tos1> Hello, I am in the process of converting a Unix shell script into Python. What can I do to set and export a path equivalent to PATH=:/usr/bin; export PATH? Thank You, Vincent A. Primavera From dalke at acm.org Tue Apr 3 17:57:45 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 3 Apr 2001 15:57:45 -0600 Subject: Newbie has question that's not exactly Python... References: Message-ID: <9adh1i$vgf$1@slb6.atl.mindspring.net> Gary Walker: >Here's some actual code of mine that doesn't work: > >************************************ >#!/usr/bin/python > >import StringIO, cgi, os, sys, string, Image > >im = Image.open('backgroundimage.gif') add--> , "rb" <-- here ^^ to make it im = Image.open('backgroundimage.gif', "rb") else it won't work on MS Windows or Macs. ># here I'll be drawing all over my image... > ># Now I want to send it to a browser... >sfp = StringIO.StringIO() >im.save(sfp,'gif') > >print 'Content-Type: image/gif\r\n\r\n' Replace this with sys.stdout.write("Content-Type: image/gif\r\n\r\n") because print adds its own "\n" after it prints the text. >sys.stdout.write(sfp.getvalue()) Andrew dalke at acm.org From e_tsang at trillium.com Mon Apr 16 19:19:12 2001 From: e_tsang at trillium.com (Tsang, Edward1) Date: Mon, 16 Apr 2001 16:19:12 -0700 Subject: How to search for and display files in a bunchof subdirectory?? Message-ID: Hi I am trying to write gui that can search and display all the files in subdirectories... Let say I invoke the script in directory d, but I have abunch of subdirectories under d. tpTcCTFTEST10/ tpTcCTFTESTTIGHT02/ tpTcTNLC14_2/ tpTcTNLC6_5/ tpTcCTFTEST11/ tpTcCTFTESTTIGHT03/ tpTcTNLC15_1/ tpTcTNLC6_6/ tpTcCTFTEST12/ tpTcCTFTESTTIGHT04/ tpTcTNLC16_1/ tpTcTNLC6_7/ tpTcCTFTEST13/ tpTcCTFTESTTIGHT05/ tpTcTNLC16_2/ tpTcTNLC6_8/ tpTcCTFTEST14/ tpTcCTFTESTTIGHT06/ tpTcTNLC17_1/ tpTcTNLC7_1/ tpTcCTFTEST16/ tpTcCTFTESTTIGHT07/ tpTcTNLC1_1/ tpTcTNLC8_1/ tpTcCTFTEST17/ tpTcCTFTESTTIGHT08/ tpTcTNLC1_2/ tpTcTNLC8_2/ tpTcCTFTEST18/ tpTcCTFTESTTIGHT0811/ tpTcTNLC2_1/ tpTcTNLC8_3/ tpTcCTFTEST19/ tpTcCTFTESTTIGHT09/ tpTcTNLC2_2/ tpTcTNLC9_1/ tpTcCTFTEST7/ tpTcCTFTESTTIGHT12/ tpTcTNLC4_1/ tpTcTNLC9_2/ tpTcCTFTEST8/ tpTcTNLC10_2/ tpTcTNLC6_1/ tpTcTNLC9_3/ tpTcCTFTEST9/ tpTcTNLC11_1/ tpTcTNLC6_2/ tpTcTNLC9_4/ tpTcCTFTESTTIGHT01/ tpTcTNLC11_2/ tpTcTNLC6_3/ tpTcCTFTESTTIGHT010/ tpTcTNLC14_1/ tpTcTNLC6_4/ and each subdirectory contains a file tp_acc.1. I want to do some processing to this file, but asking the user to click each folder and input the file name is just too much work for them, how can I just display the files in the subdirectories. If the user want the same processing to be done on all of the files , he can just click on the options to process it all. If they want to process part of the sub directory, user also allowed to do so? Thanks From aahz at panix.com Mon Apr 2 20:25:26 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Apr 2001 17:25:26 -0700 Subject: "Fastest growing programming language" References: <4b8y6.1297$bv.292187@typhoon2.ba-dsg.net> Message-ID: <9ab59m$br5$1@panix6.panix.com> In article <4b8y6.1297$bv.292187 at typhoon2.ba-dsg.net>, David Allen wrote: > >Whenever people speak in vague absolutes like "fastest", >"best", "most flexible", "best documented", etc, >they're either lying to you, or they're in marketing. What's the difference? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "One World, One Web, One Program" - Microsoft Promotional Ad "Ein Volk, Ein Reich, Ein Fuehrer" - Adolf Hitler We don't see a similarity. We really don't. From ullrich at math.okstate.edu Mon Apr 9 11:53:35 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 09 Apr 2001 15:53:35 GMT Subject: Class Variable Question References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> Message-ID: <3ad1d833.1644215966@news.okstate.edu> On Mon, 9 Apr 2001 07:33:24 -0700, "Robert Johnson" wrote: >I am new to Python and I just read something that I thought was peculiar. >Is it true that a user can add to the variables of a class just by naming >the new variable? > >Like: > >ClassObject.var1=5 > >Would this create a variable "var1" inside the class even though the creator >of the class never intended it to be there (there was no var1 originally)? Yes. >If I mistype the variable in my code, a new variable inside the class is >created rather than flagging the error? Is there a way to prevent this so >users cannot add variables? It's not entirely clear to me whether you mean to be talking about setting attributes of classes or attributes of class instances. If you're talking about class instances, aka objects, you can prevent unauthorized additions by using a custom __setattr__ method: class c: def __init__(self,x): self.x=x def __setattr__(self, name, value): if name=='x': self.__dict__['x']=value else: raise 'invalid access' o=c(42) print o.x o.x=17 print o.x o.xx=24 print o.xx doesn't work, exactly as it shouldn't. But I don't know how to prevent someone from erroneously adding xx to the class: If things are as above then c.xx=24 works. (You might think you could prevent access to o.xx with a custom __getattr__ method, but that doesn't work because __getattr__ is not called unless the attribute name is not found "in the usual places".) > It seems to me that the user could just >override a class with unrelated data. > >Thanks in advance, > >Robert Johnson > > From l at acm.org Thu Apr 19 22:44:05 2001 From: l at acm.org (Lester McCann) Date: Thu, 19 Apr 2001 21:44:05 -0500 Subject: Can only import select as root? References: <3ADF75FF.C005932C@acm.org> Message-ID: <3ADFA275.CE889E07@acm.org> > | >>> import select > | Traceback (most recent call last): > | File "", line 1, in ? > | ImportError: No module named select > | >>> > > What are the permissions on that module? Try > > $ ls -l /usr/lib/python-2.1/Lib/select.py* There is no such file in the Python lib directory on my system. (I ran 'find' from the root of the directory tree to verify that it doesn't exist anywhere.) As I can access it when running as root, I'm assuming that it's built-in somehow. I agree that it seems like a permission problem, but... Thanks anyway. Any other suggestions, anyone? --lester From angler at voicenet.com Sun Apr 15 16:19:33 2001 From: angler at voicenet.com (Gregory T. Weber) Date: Sun, 15 Apr 2001 20:19:33 GMT Subject: Newbie Question Message-ID: <3ADA012D.E7B28E9B@voicenet.com> I just started with the Learning Python book and was not able to get one of the simplest programs working. I suspect that the installation is at fault and want to confirm before going any further. Using Python 2.0 on Solaris 2.6. The code is #! /usr/bin/python print 'First Program' At the command line this works fine > python first.py First Program After making first.py executable I figured I could do this >first.py but I get the error print: Command not found. Thanks, Greg From fredrik at pythonware.com Sat Apr 28 09:50:25 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 28 Apr 2001 13:50:25 GMT Subject: 24bit display on Unix machine References: <3AEA20E5.37AD2426@centropolisfx.com> Message-ID: Nickson Fong wrote: > How can i display a 24bit image in Python Tkinter(Unix)? for the basics, see my earlier post on Tkinter jpeg/gif display. if the image is displayed with 256 colours also on a 24-bit display, you have to specify create a truecolor toplevel window: top = Toplevel(root, visual="truecolor") w = Label(top, image=myimage) w.pack() more info from "an introduction to tkinter": "[The visual option] controls the "visual" type to use for this window. This option should usually be omitted. In that case, the visual type is inherited from the root window. Some more advanced displays support "mixed visuals". This typically means that the root window is a 256-color display (the "pseudocolor" visual type), but that individual windows can be displayed as true 24-bit color (the "truecolor" visual type). On such displays, you may wish to explicitly set the visual option to "truecolor" for any windows used to display full-color images. Other possible values include "directcolor", "staticcolor", "grayscale", or "staticgray". See your X window documentation for details. You cannot change this option once you've created the window. quoted from: http://www.pythonware.com/library/tkinter/introduction/toplevel.htm > centropolisfx ilm, weta, centropolis. I think we have a trend here ;-) Cheers /F From curt at hagenlocher.org Thu Apr 5 13:44:27 2001 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 5 Apr 2001 10:44:27 -0700 Subject: PEP 245 Message-ID: <200104051744.KAA09885@dopey.hagenlocher.org> > Some mechanism is needed to identify an object as > an implementer of a particular protocol, searching > for the existance of "getitem" and the like seems > like very poor practice. But you can have this functionality without changing the syntax of the language or adding new keywords. Do it the same way that C++ does, by defining the interface as a class. Other than an extremely light frosting of syntactic sugar, the only advantage I see in PEP 245 is that the interface definition gets to omit one line of code per method declaration: raise InterfaceError, "your message here". Java is the canonical example of a widely-used programming language that distinguishes between classes and interfaces. In the case of Java, this distinction is necessary, because multiple inheritance of classes is not allowed. This issue does not exist in Python. -- Curt Hagenlocher curt at hagenlocher.org From py.list at mulga.com.au Mon Apr 16 22:04:45 2001 From: py.list at mulga.com.au (Michael Hall) Date: Tue, 17 Apr 2001 11:34:45 +0930 (CST) Subject: Python and Apache In-Reply-To: <3ADB7443.F189F871@alcyone.com> Message-ID: What extension does the CGI script have ... .py or .cgi ? Might make a difference. Mick On Mon, 16 Apr 2001, Erik Max Francis wrote: > David Fuess wrote: > > > Yes, that's what I thought also, but I am able to execute > > > > /usr/local/bin/python /home/httpd/cgi-bin/hello > > > > and it works. Also I've checked and everything is where it's supposed > > to be. "which python" returns "/usr/local/bin/python". Interesting > > though that when I attempt ./hello when CWD=/home/httpd/cgi-bin I get > > the file not found error also(?). I'm wondering if the /cgi-bin/ -> > > /home/httpd/cgi-bin is working correctly. > > Well, check it. > > If the paths are correct, then it's probably either 1. the script is > executable by you but not by nobody (what Apache runs as) or 2. you have > Apache configured in such way that it will execute CGI scripts only if > they end in .cgi. > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ Let he who does not know what war is go to war. > \__/ (a Spanish proverb) > Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ > A highly categorized list of Web links. > -- > http://mail.python.org/mailman/listinfo/python-list > From tim.one at home.com Sat Apr 21 18:56:30 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 21 Apr 2001 18:56:30 -0400 Subject: Iterators, generators and 2.2 (was RE: do...until wisdom needed...) In-Reply-To: Message-ID: [Aahz] > Generators (called "iterators") are going to be 2.2. They'll be > more powerful that Icon's generators; it's not clear whether they'll > be a full-fledged substitute for coroutines. [Neelakantan Krishnaswami] > {\mr_burns Excellent.} > > Is this the iterator idea that Ping posted about a couple of months > back? What is the PEP number for this? I'm curious how the existing > iteration protocol will interact with the new iterators. This is getting confused. Iterators != generators (sorry, Aahz! it's more involved than that). Aahz gave you the PEP number for iterators, and last night Guido checked an initial implementation into the 2.2 CVS tree. In Python terms, "for" setup looks for an __iter__ method first, and if it doesn't find it but does find __getitem__, builds a lightweight iterator around the __getitem__ method instead. So the "for" loop works only with iterators now, but there's an adapter providing iterators by magic for old sequence objects that don't know about iterators: C:\Code\python\dist\src\PCbuild>python Python 2.2a0 (#16, Apr 20 2001, 23:16:12) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> def f(s): ... for i in s: ... print i ... >>> from dis import dis >>> dis(f) 0 SET_LINENO 1 3 SET_LINENO 2 6 SETUP_LOOP 25 (to 34) 9 LOAD_FAST 0 (s) 12 GET_ITER >> 13 SET_LINENO 2 16 FOR_ITER 14 19 STORE_FAST 1 (i) 22 SET_LINENO 3 25 LOAD_FAST 1 (i) 28 PRINT_ITEM 29 PRINT_NEWLINE 30 JUMP_ABSOLUTE 13 33 POP_BLOCK >> 34 LOAD_CONST 0 (None) 37 RETURN_VALUE >>> The backward compatibility layer described above is hiding in the new GET_ITER opcode. Of course builtin lists (and so on) define the iterator slot directly now, so GET_ITER simply returns their iterator directly. Loops are less complicated (internally) now, and run significantly faster. User-defined types and classes no longer *need* to (ab)use __getitem__ to implement iteration (which is of particular interest to Greg Wilson right now, who is implementing a Set class and doesn't *want* to define __getitem__ because it's semantically senseless). None of that should be controversial in the least. More controversial is that iteration over dict keys has been tentatively added (and note that this is another thing made *possible* by breaking the old connection between __getitem__ and iteration): >>> dict = {"one": 1, "two": 2} >>> for k in dict: ... print k ... one two >>> This is significantly faster, and unboundedly more memory-efficient, than doing "for k in dict.keys()". The dict.__contains__ slot was also filled in, so that "k in dict" is synonymous with "dict.has_key(k)", but again runs significantly faster: >>> "one" in dict 1 >>> "three" in dict 0 >>> File objects have also grown iterators, so that, e.g., for line in sys.stdin: print line now works. Iterators can be explicitly materialized too, via the new iter() builltin function, and invoked apart from the "for" protocol: >>> i1 = iter(dict) >>> i1 >>> dir(i1) ['next'] >>> print i1.next.__doc__ it.next() -- get the next value, or raise StopIteration >>> i2 = iter(dict) >>> i1.next() 'one' >>> i2.next() 'one' >>> i1.next() 'two' >>> i2.next() 'two' >>> i1.next() Traceback (most recent call last): File "", line 1, in ? StopIteration >>> Note that this allows a simple memory-efficient implementation of parallel sequence iteration too. For example, this program: class zipiter: def __init__(self, seq1, *moreseqs): seqs = [seq1] seqs.extend(list(moreseqs)) self.seqs = seqs def __iter__(self): self.iters = [iter(seq) for seq in self.seqs] return self def next(self): return [i.next() for i in self.iters] for i, j, k in zipiter([1, 2, 3], "abc", (5., 6., 7., 8.)): print i, j, k prints 1 a 5.0 2 b 6.0 3 c 7.0 Now all that is just iteration in a thoroughly conventional sense. There is no support here for generators or coroutines or microthreads, except in the sense that breaking the iteration==__getitem__ connection makes it easier to think about *how* generators may be implemented, and having an explicit iterator object "should" make it possible to go beyond Icon's notion of generators (which can only be driven implicitly by control context). Neil Schemenauer is currently thinking hard about that "in his spare time", but there's no guarantee anything will come of it in 2.2. Iterators are a sure thing, though (not least because they're already implemented!). not-only-implemented-but-feel-exactly-right-ly y'rs - tim From Peek at LVCM.comNOSPAM Wed Apr 18 01:45:15 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Tue, 17 Apr 2001 22:45:15 -0700 Subject: LOOP wisdom found (was: do...until wisdom found)... References: <3ADC6F1F.DE1A2FB1@mentor.com> <3ADCA101.6059336E@mentor.com> <0c3D6.5161$sk3.1518317@newsb.telia.net> Message-ID: OK-- I think the people in this news group have finally broke through my thick skull... We can build no less than THREE looping constructs with only TWO keywords. If we have to make the language simple, then let's make it REALLY simple. I dislike the keywords "while" and "break"-- here's why: For a "newbie" (who is just learning to program) either "repeat" or "loop" conveys more information about what is about to happen. Of these, the universal meaning of "loop" seems to be more wide spread. (EVERYBODY knows what a "loop" is, even if they have never programmed before.) (Make believe a newbie is learning to program computers.) "break"-- well? What does this mean? "If I type 'break', will it crash the computer?" The keyword "break" is a "hold-over" from a previous language. I kind of like "leave" instead of "break". It is more intuitive, and conveys what it is supposed to do. A close second would be "exit", but that is probably going to be used for something else. Now, a loop "in the _nature_ of a while loop" would look like this: # do the test before the body, just like "while"-- loop: if condition: leave # some stuff # some more stuff And, a loop "in the _nature_ of a do...until loop" would look like this: # do the test after the body, just like "do...until"-- loop: # some stuff # some more stuff if condition: leave And, an infinite loop would look like this: # never do a test, so we have an "infinite loop"-- loop: # some stuff # some more stuff Of course, in either case, there is nothing to stop you from the bad programming practice of putting in as many "if condition: leave" statements as you like, in any place you like. So what? You cannot legislate morality... THIS code is easy to learn and understand. I too, have it on good authority that Python 3000 will address the eternal (and infernal) "looping controversy" . As to just what that "somehow" will be, we will just have to wait and see what Guido will bless. (MY money is on simplicity!) --Nih!!! --KP "Fredrik Lundh" wrote in message news:0c3D6.5161$sk3.1518317 at newsb.telia.net... < snip > > in python 3000, expect "while" to be replaced with "loop/if/break" ;-) < snip > From benjamin.geer at btinternet.com Wed Apr 25 21:09:21 2001 From: benjamin.geer at btinternet.com (Benjamin Geer) Date: Thu, 26 Apr 2001 02:09:21 +0100 Subject: Making a python extension in c++ References: <988067008.220977@db.lineo.com> Message-ID: <9c7sng$sfd$1@plutonium.btinternet.com> In article <988067008.220977 at db.lineo.com>, "Erik Weber" wrote: > Has anyone compiled a C++ based extension? If so, what > did your Setup file look like? I've only done this using SWIG (http://www.swig.org), but I don't suppose it's much different if you've written everything by hand. See this page for an example: http://www.btinternet.com/~benjamin.geer/python/embedding.html It shows how to make a C++ extension, as well as how to embed Python in a C++ program. -- Benjamin Geer http://www.btinternet.com/~benjamin.geer From atul at dsfinternet.com Wed Apr 11 01:11:52 2001 From: atul at dsfinternet.com (atul) Date: Wed, 11 Apr 2001 10:41:52 +0530 Subject: Guide me Message-ID: <2vo0b9.8k.ln@dsfintranet.dsf> hi I am a java programmer and i want to know that how python can be usefulll to me. Please help me. I have heard a lot about python . How can i get started and whether it can be learnt easily by me From glenfant.nospam at bigfoot.com Sun Apr 8 13:09:29 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Sun, 8 Apr 2001 19:09:29 +0200 Subject: urllib with user/password References: <9ao1v9$2tot$1@news5.isdnet.net> Message-ID: <9aq5o4$9tf$1@news2.isdnet.net> Thanks steve... It works! From MarkH at ActiveState.com Tue Apr 10 20:55:36 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 11 Apr 2001 00:55:36 GMT Subject: threads blocked during import? References: Message-ID: <3AD3AB9C.6080800@ActiveState.com> Geoff Talvola wrote: > I was wondering the other day: if two threads try to import the same > module at the same time, what happens? I wrote a test program, and it > looks like an import blocks all other threads from importing. This is > probably a good thing, since you only want the module to be imported once. > > Here's the test program, and the helper module that it imports. Running > it on my WinNT box shows that the 2nd thread to try to import the module > blocks while the first thread is importing it, and the module doesn't > get imported twice. That's a good thing. > > My question for the gurus is, can I count on this locking taking place, > and put code that absolutely needs to run only once at module level > without any special locking? Yes. The Python win32com support actually discovered Python had a bug in this area, so Guido added an explicit lock just for this case. Mark. From claird at starbase.neosoft.com Thu Apr 5 14:44:01 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Apr 2001 13:44:01 -0500 Subject: Python Books for 2002 References: <03BA7FF29A7003C0.58A7996FD1867709.07757E6DB814C605@lp.airnews.net> <9ai305$so3$1@panix2.panix.com> Message-ID: In article <9ai305$so3$1 at panix2.panix.com>, Aahz Maruch wrote: >In article <03BA7FF29A7003C0.58A7996FD1867709.07757E6DB814C605 at lp.airnews.net>, >Cameron Laird wrote: >> >>Here's a hazard of concision: it abbreviates sometimes to confusion. >>I think a "40 page 'python in depth' treatise" would be *snapped up* >>at retail, even at $10 or 20 US. The market to which Fredrik is >>apparently referring is that of either the publishers or distributors, >>who find this sort of innovation anathema. > >Ever since I saw _Borland C++ for Dummies_, I have concluded that >*nothing* is truly anathema to computer book publishers. . . . Incidentally, as no one else has called me on this, I need to make it explicit: my own posting abbreviated. It would be easy to conclude from what I'd written that I can only whine about publishers, and lump them all in the same dark kettle. I do recognize several are inno- vative, and a few courageous. I generalized. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ramagnus at zvw.de Wed Apr 18 05:13:58 2001 From: ramagnus at zvw.de (Rolf Magnus) Date: Wed, 18 Apr 2001 11:13:58 +0200 Subject: Ignore test References: <22.987460261553@iw1.etin.com> Message-ID: <9bjlop$qut$3@news.sns-felb.debis.de> mathteechr wrote: > This would be a test. > What did you expect? I expected that people are intelligent enough to use a _test_ newsgroup for tests. From skip at pobox.com Sun Apr 29 23:49:53 2001 From: skip at pobox.com (skip at pobox.com) Date: Sun, 29 Apr 2001 22:49:53 -0500 (CDT) Subject: Sockets: Sending/receiving arbitrary amounts of data In-Reply-To: References: Message-ID: <15084.57569.940879.881625@beluga.mojam.com> Daniel> Just starting to get my head around sockets ... Daniel> ... I'd just like to know if there is a 'high-level' way to Daniel> implement this so that client and server handle the requests Daniel> regardless of how much data is being sent/recv'd ? Neil Schemenauer already responded about adding terminators and such to indicate end of message for homegrown protocols. I will go a bit off-topic and suggest that unless one of the following is true: * you are using this exercise solely for a bit of education, or * you will be speaking to a service for which there is already an existing protocol but for which Python doesn't already provide a library (this excludes protocols like FTP, Telnet, NNTP and SMTP) that you look at using something like XML-RPC, which already exists and is supported by many libraries written in many different languages (including Python, of course). XML-RPC can be found at http://www.xmlrpc.com/. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From jepler at inetnebr.com Fri Apr 13 22:36:18 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Sat, 14 Apr 2001 02:36:18 GMT Subject: __sub__ for string References: <3AD6C15B.13AB23CC@hack.org> <1zzB6.7026$4N4.1532639@newsc.telia.net> <3AD6C653.70A8663E@hack.org> <9b6k5g$ccg$1@slb5.atl.mindspring.net> Message-ID: On Fri, 13 Apr 2001 04:24:48 -0600, Andrew Dalke wrote: > So what does "abc" / "ab" equal? 1 + ("ab" + "c"j) From rdasilva at connecttel.com Mon Apr 2 22:33:32 2001 From: rdasilva at connecttel.com (Rosimildo da Silva) Date: Tue, 03 Apr 2001 02:33:32 GMT Subject: "Fastest growing programming language" References: Message-ID: <3AC93AE5.A97E1477@connecttel.com> Roy Smith wrote: > > grante at visi.com (Grant Edwards) wrote: > > It's based on the only metric that makes sense: the rate of > > increase of Usenet traffic in c.l.. > > By that measure, wouldn't Parrot be the fastest growing? :-) Is this PARROT thing for real ? or was it just some April's Fool joke. ? -- Rosimildo da Silva rdasilva at connectel.com ConnectTel, Inc. Austin, TX -- USA Phone : 512-338-1111 Fax : 512-918-0449 Company Page: http://www.connecttel.com Home Page: http://members.nbci.com/rosimildo/ From gustav at morpheus.demon.co.uk Tue Apr 3 17:36:48 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Tue, 03 Apr 2001 22:36:48 +0100 Subject: ANNOUNCE: python-win32 mailing list References: Message-ID: <00akctkookgikblonimag3q8g69p09mis6@4ax.com> On Tue, 03 Apr 2001 16:44:55 GMT, "Fredrik Lundh" wrote: >Paul Moore wrote: >> Fair enough. If that is the case, then a Python-Windows SIG would be a >> better option, as it fits the existing infrastructure. > >Friday 20-Jun-1997 the Pythonwin-SIG was decommissioned. Mark >Hammond, the list's owner, describes it this way (slightly reformatted): > > In a nutshell, we are going to shut down Pythonwin-sig so the > traffic moves back to the main Python newsgroup. The main reasons > for this are: [...] Gosh, yes. I remember this now. Was it really that long ago? I think that says it all really. If there is a genuine need for a split (I don't believe so personally) then splitting comp.lang.python is the best way forward. Paul. From dalke at acm.org Thu Apr 19 23:39:38 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 19 Apr 2001 21:39:38 -0600 Subject: Performance measurements (was: python on the smalltalk VM) References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> <4EA03F26C2C54BAB.26EA5ACB1D9CD09A.30161D811690E63A@lp.airnews.net> Message-ID: <9bob1n$csc$1@slb1.atl.mindspring.net> Douglas Alan wrote: >All this should come as no shock -- 100 times slower for an >interpreted language is just par for a good interpreter. Before the >spiffy Self compiler, state of the art was 10x slower than C for a >really bitchin' highly optimized Smalltalk compiler. I have a package called PyDaylight which puts a deep Python layer (with OO, exceptions, iterators, etc) on top of a C library for chemical informatics. I've done a lot of timing tests on the library to see how the Python code compares to morally equivalent C code. In most cases it's about a factor of ten. The fastest case is a 50% slowdown for code which is mostly in the extension - and it should be faster now that Python has xreadlines. The slowest case was a factor of 40 for code which did a lot of array lookup and used the __getattr__ hooks My timing tests have put Python code anywhere from 50% slower than C code (when most of the work was done in a C extension) to 40x. This slowest case was for code that did a lot of list lookups instead of pointer increments, and used the object layer heavily, which is translates attribute lookups to the C level via getattr calls. Most code is O(10x) slower. Of course, to balance it out in most cases the code itself is an order of magnitude fewer lines of code and an order of magnitude easier to read. So I don't agree with your estimate of 100x slower, at least for the domain of programs I've investigated. Andrew dalke at acm.org From jeremy at digicool.com Wed Apr 18 10:49:12 2001 From: jeremy at digicool.com (Jeremy Hylton) Date: Wed, 18 Apr 2001 10:49:12 -0400 (EDT) Subject: Deprecate self In-Reply-To: References: <9bji5k$417$0@216.39.170.247> Message-ID: <15069.43368.443908.127285@slothrop.digicool.com> >>>>> "MvL" == Martin von Loewis writes: MvL> whisper at oz.net (Dave LeBlanc) writes: >> Since self is used for every method of every class, isn't it a >> bit redundant? I don't know of another OO language that makes you >> manually carry around the "this"/"self" pointer/reference... MvL> In Smalltalk, invocations of operations on self always require MvL> to provide the self argument. You don't have to declare it as a MvL> method argument, though. Modula-3 was mentioned in another post. There is a reason other than simple clarity (I like using an explicit self) for this approach. Python's rules for local variables would interfere with attribute access. Since Python eschews variable declarations, any assignment to a name inside a code block makes that name a local variable. By this rule alone, there would never by a way to assign to an instance variable :-). You'd need a mechanism like the global statement to say "This name isn't a local." We had an opportunity to change the attribute access approach when nested scopes were introduced, but we went out of our way (well, sort of) to preserve the self.attr approach. Jeremy From jafo at tummy.com Tue Apr 17 22:03:52 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 17 Apr 2001 20:03:52 -0600 Subject: ANNOUNCE: Python 2.1 final release In-Reply-To: <200104171429.JAA23792@cj20424-a.reston1.va.home.com>; from guido@digicool.com on Tue, Apr 17, 2001 at 09:29:44AM -0500 References: <200104171429.JAA23792@cj20424-a.reston1.va.home.com> Message-ID: <20010417200352.A28871@tummy.com> On Tue, Apr 17, 2001 at 09:29:44AM -0500, Guido van Rossum wrote: >Yes, the *final* release of Python 2.1 is now available. Thanks again I've updated my set of RPMs against 2.1. I've similarly upgraded my 2.1 beta announcement to 2.1 final, and am including it below. Changes in this version are: Upgrade to 2.1 final. Binary and package name is "python2" by default. Comment out the first (non-comment) line of the .spec file to build "python". Fixes the path to python2 in pydoc based on the above. Uses "--with-pymalloc" when configuring. Included Tony Seward's patch to fix the expat module's header path. Split out devel and tkinter packages. Enjoy, Sean ====================== Shy of RPMs because of library or other dependancy problems with most of the RPMs you pick up? The cure, in my experience is to pick up an SRPM. All you need to do to build a binary package tailored to your system is run "rpm --rebuild .src.rpm". The Source RPM and binaries for RedHat and KRUD 7.0 are at: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS/python2-2.1-1tummy.src.rpm ftp://ftp.tummy.com/pub/tummy/RPMS/binaries-KRUD-7.0-i386/ You'll also need the following to build the SRPMSs: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS/expat-1.1-3tummy.src.rpm (Note, KRUD is our RedHat-based distribution with all errata applied. Binaries should work on a stock RedHat 7.0 system, particularly if you have the errata applied). Again, this one builds the executable as "python2", and can be installed along-side your normal Python on the system. Want to check out a great new feature? Type "pydoc string" or "pydoc -g" from your shell. Download the SRPM from above, and most users can install a binary built against exactly the set of packages on their system by doing: rpm --rebuild expat-1.1-3tummy.src.rpm rpm -i /usr/src/redhat/RPMS/i386/expat*-1.1-3tummy.i386.rpm rpm --rebuild python-2.1b2-1tummy.src.rpm rpm -i /usr/src/redhat/RPMS/i386/python*2.1b1-1tummy.i386.rpm Enjoy, Sean -- The structure of a system reflects the structure of the organization that built it. -- Richard E. Fairley Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From sholden at holdenweb.com Mon Apr 16 12:40:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: 16 Apr 2001 11:40:21 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 16) Message-ID: <960A47E8CE027158.4FB78ED98349BB7C.B18AB0F52D878FFE@lp.airnews.net> Per Gummedal announces Python for the AS/400 has now reached Beta 0.6: http://home.no.net/pgummeda Gerard H?ring announces PyAda now supports Windows and Solaris platforms as well as Linux and FreeBSD: http://pyada.sourceforge.net Sean Reifschneider releases RPMs (source, and Red Hat 7.0 binary) for the Python release candidate 2.1c1: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS/python2-2.1c1-1tummy.src.rpm ftp://ftp.tummy.com/pub/tummy/RPMS/binaries-KRUD-7.0-i386 Fred Drake has updated the Python 2.1 development documentation into final release form: http://python.sourceforge.net/devel-docs/ A second release candidate is announced after a small but significant bug is found in dictionary-handling code: http://www.python.org/2.1/ Alex Shindich and Curt Hagenlocher follow up discussions on interface specification in Python with a paper on the "Implied Interface" design pattern: http://www.shindich.com/sources/patterns/implied.html Pete Shinners announces the 1.0 implementation of PyGame, an SDL-based game authoring framework: http://pygame.seul.org/ Questions are raised about whether ActiveState's Komodo violates the Mozilla Public License. ActiveState seems to be OK in both letter and spirit, but the thread assumes a life of its own: http://groups.google.com/groups?ic=1&th=adeed2bd2eec0958 Commas in list comprehensions cause confusion, which takes a little sorting out: http://groups.google.com/groups?ic=1&th=edf0cf4c559318e0 Robert Johnson innocently expresses surprise at Python's namespace flexibility, triggering a flood of responses (warning: this thread includes the word 'floccinaucinihilipilification'): http://groups.google.com/groups?ic=1&th=36898cb3c796116b Robin Becker innocently enquires about defining abstract base classes, and receives several suggestions: http://groups.google.com/groups?ic=1&th=3f2bbdc09e263baa The world fails to become any wiser about whether Aahz and Tim Peters have actually met: http://groups.google.com/groups?ic=1&th=1b5dcfa1b5125fbc ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From stephen_purcell at yahoo.com Sat Apr 14 05:25:17 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sat, 14 Apr 2001 11:25:17 +0200 Subject: building a large file In-Reply-To: <20010414160900.A7013@madeforchina.com>; from thomas@madeforchina.com on Sat, Apr 14, 2001 at 04:09:00PM +0800 References: <20010414160900.A7013@madeforchina.com> Message-ID: <20010414112517.C27249@freedom.puma-ag.com> Thomas Duterme wrote: > Hi everyone, > > So I need to build a very large file. Essentially, I need > to go through a directory and recursively append the > contents of each file from that directory to a file. > > Here's what I'm doing right now: > > for x in os.listdir('.'): > os.system('cat '+x+' >> mylargefile) > > Is there any smarter way to do this in python? If you use the function os.path.walk() you can do everything in 100% Pure Python (TM): >>> import os >>> output = open('/tmp/everything','wb') >>> def append(out, dirname, names): ... for name in names: ... fullpath = os.path.join(dirname, name) ... if not os.path.isfile(fullpath): continue ... stream = open(fullpath,'rb') ... while 1: ... block = stream.read(512) ... if not block: break ... out.write(block) ... stream.close() ... >>> os.path.walk('projects/python-snippets', append, output) >>> output.close() Notes: * 'append' is called for the directory 'projects/python-snippets' and all its subdirectories * The 'names' argument of 'append' is a list containing the result of 'os.listdir' for 'dirname' * 'append' loops through 'names', skipping names that are not files * Files are copied blockwise to the 'out' stream: if files are smallish, the 'while' loop could be replaced with "out.write(stream.read())" See the documentation of os.path.walk for more details: http://www.python.org/doc/lib/module-os.path.html -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From sheila at spamcop.net Sat Apr 7 12:41:17 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 07 Apr 2001 16:41:17 GMT Subject: looking for command-pipe performance advice References: Message-ID: On 6 Apr 2001 16:36:42 -0000, jason-dated-14a0ce692bc19405 at mastaler.com wrote in comp.lang.python in article : :Sheila King writes: : :> Couldn't you just do this? :> :> headers = rfc822.Message(sys.stdin, 0) :> :> # header examination # :> :> inject_message = os.popen('/var/qmail/bin/qmail-inject', 'w') :> inject_message.write(headers+'\n') :> inject_message.write(sys.stdin.read()) :> inject_message.close() : :This returns a TypeError for me. : :First: : : Traceback (most recent call last): : File "./inject.py", line 10, in ? : inject_message.write(headers+'\n') : TypeError: __add__ nor __radd__ defined for these operands Oops. Sorry. I wasn't trying very hard there. I have a script that filters email/examines headers for me, and I do not use cStringIO or StringIO. I read from standard input. Here are a few relevant lines from my code: origheaders=rfc822.Message(sys.stdin, 0) raw_body = sys.stdin.read() newheader = string.join(origheaders.headers,"") newheader += "X-Filter: some header field inserted here\n" line = "\n" body = string.join(raw_body, "") mssg = newheader+line+body Then I send the message using the smtplib module. Um, so instead of using StingIO objects, I take the input and turn it into strings. Is this more effecient than what you were doing? I have no idea. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :Then after removing the '\n': : : Traceback (most recent call last): : File "./inject.py", line 10, in ? : inject_message.write(headers) : TypeError: read-only character buffer, instance : :This "read-only character buffer" error was why I was using StringIO :initially. From spike at oztourer.nl Fri Apr 20 08:55:03 2001 From: spike at oztourer.nl (Steve Pike) Date: Fri, 20 Apr 2001 12:55:03 GMT Subject: ANNOUNCE: PikiePikie 0.2 released Message-ID: <3ae02cec.23301579@news.cablewanadoo.nl> A new version of PikiePikie is now available from http://pikie.darktech.org/cgi/pikie. WHAT IS IT? PikiePikie is a Wiki clone written in Python. It supports interactive web sites whereby anyone and everyone can modify the content of a site. WHAT'S NEW? The main enhancements over the initial release are: - support for web logs - bookmarks within pages - extended WikiName syntax See http://pikie.darktech.org/cgi/pikie?ImplementedPikieEnhancements for a more complete list of changes WHERE IS IT? The source can be downloaded from http://pikie.darktech.org/cgi/pikie?DownloadPage From fredrik at pythonware.com Thu Apr 19 02:35:59 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 19 Apr 2001 06:35:59 GMT Subject: Compiler warning for PIL References: <3ADE7713.EC4641F4@erols.com> Message-ID: Edward C. Jones wrote: > I use RedHat 6.2 Linux on a PC. The compiler is egcs-2.91.66. I get the > following warning when making PIL 1.1.1: > > ././encode.c: In function _encode_to_file': > ././encode.c:153: warning: implicit declaration of function `write' > > What does this mean? that the encode.c really should include "unistd.h" on linux/unix, but doesn't. you can ignore the warning. Cheers /F From MarkH at ActiveState.com Sun Apr 22 18:52:14 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 22 Apr 2001 22:52:14 GMT Subject: NTFS permissions References: <1e232f6f4a%tim@worthy.demon.co.uk> Message-ID: <3AE360DA.5030806@ActiveState.com> Tim Howarth wrote: > Having serached Google I've found a couple of queries about this but no > easy solutions. Eeek! I must have missed them. > results in an error message "the data area passed to a system call is > too small" but the permissions are copied. sigh*. This is a trivial bug in win32security. The C++ code is missing a simple "!" :(. As a workaround, simply ignore the exception. All future builds will have this fixed. Mark. From fuess at att.net Mon Apr 16 14:20:38 2001 From: fuess at att.net (David Fuess) Date: Mon, 16 Apr 2001 18:20:38 GMT Subject: Python and Apache Message-ID: I'm having a heck of a time convincing my Apache web server that it's ok to run Python CGI scripts. The test script "hello" does indeed exist in the proper directory and runs fine under Python from the command line. But when I try to run it from a browser as in http:///cgi-bin/hello it fails. Any ideas? Thanks, Dave Kernel: Red Hat Linux release 6.2 (Zoot) Kernel 2.2.14-5.0 on an i586 Apache: Apache/1.3.12 (Unix) (Red Hat/Linux) Python: BeOpen 2.0.1 ----- BEGIN httpd.conf SNIPIT ----- ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/" AllowOverride None Options ExecCGI Order allow,deny Allow from all ----- END http.conf SNIPIT ----- ----- BEGIN SCRIPT SNIPIT --- #!/usr/local/bin/python import os, sys, cgi, string, time print "Content-type: text/html" # identify response as HTML print # end of headers print "" print "About Me" ----- END SCRIPT SNIPIT --- ----- BEGIN error_log SNIPIT --- [Mon Apr 16 11:02:42 2001] [error] (2)No such file or directory: exec of /home/httpd/cgi-bin/hello failed [Mon Apr 16 11:02:42 2001] [error] [client xxx] Premature end of script headers: /home/httpd/cgi-bin/hello ----- END error_log SNIPIT --- From BPettersen at NAREX.com Fri Apr 27 14:41:30 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Fri, 27 Apr 2001 12:41:30 -0600 Subject: Whither SmallScript? (was Re: Integer micro-benchmarks) Message-ID: > From: Steven D. Majewski [mailto:sdm7g at Virginia.EDU] > On Fri, 27 Apr 2001, Andrew Hunt wrote: > > > I personally like the style and dynacism of Ruby. For > instance, to declare > > a class that inherits from another class you simply have: > > > > class Foo < Bar > > def myMethod > > File.new ("test.dat", "w") { |f| > > f.puts "Hello world!" > > } > > end > > end > > What do the vertical bars around the f ("|f|") above indicate ? > > ( Maybe it's those extra non alphanumeric operator looking chars > that make folks think of Perl -- even if they are used differently, > to someone that doesn't read Ruby, it looks like more "line noise".) It defines a local variable of the enclosing anonymous block (hi Alex :-) It's similar to how SmallTalk defines variables, which I presume would explain why they like it (?) -- bjorn From dinu at reportlab.com Wed Apr 25 11:33:55 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Wed, 25 Apr 2001 15:33:55 GMT Subject: Floating point (in)accuracy? Message-ID: <3ae6eb73.802364759@news.vr.in-berlin.de> Apparently the python mailiing lists on python.org are blocked, so let me ask here. Is there any good reason for the following behaviour to be different on Python 1.5.2 and 2.0? Dinu Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> 3.14 3.14 >>> 10*3.14 31.4 >>> PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> x = 10 * 3.14 >>> x 31.400000000000002 >>> x == 31.4 0 >>> 3.14 3.1400000000000001 >>> -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From webmaster at pawntastic.com Mon Apr 23 22:54:27 2001 From: webmaster at pawntastic.com (alki) Date: Tue, 24 Apr 2001 02:54:27 GMT Subject: Example of Function Message-ID: Will someone please give me how a function is written and how it's used? Thx. From mwh21 at cam.ac.uk Thu Apr 12 04:19:55 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 12 Apr 2001 09:19:55 +0100 Subject: how to calculate the size of sys.stdin? References: Message-ID: grante at visi.com (Grant Edwards) writes: > In article , Robin Thomas wrote: > > >sys.stdin is more like a pipe, and not a regular file. You > >can't ask a pipe how many bytes it contains before you read > >from it. > > Actually, you can. > > At least on some Unix systems, the FIONREAD ioctl() call will > tell you how many bytes there are in a pipe waiting to be read. > IIRC, it also works on some tty devices as well. Probably not > very portable, and somebody could have shoved more bytes into > the other end after the ioctl() and before the read(), so you > could get more that you expect, but you shouldn't get less. That's interesting for a pet project of mine. How on earth does one go about learning things like that? Is this sort of stuff in Stevens' APUE? Cheers, M. -- We did requirements and task analysis, iterative design, and user testing. You'd almost think programming languages were an interface between people and computers. -- Steven Pemberton (one of the designers of Python's direct ancestor ABC) From BrianQ at ActiveState.com Wed Apr 11 17:11:29 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Wed, 11 Apr 2001 14:11:29 -0700 Subject: Easy question In-Reply-To: <9b2fdh$3ph$1@news7.svr.pol.co.uk> Message-ID: <001101c0c2cb$faef24a0$b503a8c0@activestate.ca> How about something like this: # No testing, of course myList = [] file = open( 'testfile', 'r' ) for i in file.readlines( ): myList.append( [int(j.strip( )) for j in i.split('\t')] ) -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Duncan Smith Sent: Wednesday, April 11, 2001 1:39 PM To: python-list at python.org Subject: Easy question I need to read some data from a file. Each (tab delimited) row corresponds to an array index eg. 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 ... And I need something like, [[0,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], ...] What's the best way of doing this? Cheers in advance. Duncan Smith -- http://mail.python.org/mailman/listinfo/python-list From andrew_dot_henshaw_at_earthling_dot_net Mon Apr 16 22:43:10 2001 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Mon, 16 Apr 2001 22:43:10 -0400 Subject: do...until wisdom needed... References: <9bdv6f$quq$1@news.udel.edu> <9be82a$eq7$1@slb6.atl.mindspring.net> Message-ID: I have difficulties with all the proposals that have been given in the past for a suitable 'until' syntax. However, I have advocated that 'do' as an alias for 'while 1', would be cleaner, more elegant, and simpler to grasp for new programmers (e.g., children). Therefore, in a half-attempt to answer your question, I believe that most Pythonic implementation of do-until would be: do: some code if condition: break Andrew Henshaw From robin900 at yahoo.com Mon Apr 2 15:49:20 2001 From: robin900 at yahoo.com (Robin Thomas) Date: Mon, 02 Apr 2001 15:49:20 -0400 Subject: Why not an __assign__ method? In-Reply-To: <5.0.2.1.0.20010331004906.021bc9b0@mail.inet.com.br> References: <4.3.1.2.20010330115856.0256bb00@exchange.starmedia.net> <5.0.2.1.0.20010330125432.0216c4b0@mail.inet.com.br> Message-ID: <4.3.1.2.20010402145858.00df7770@exchange.starmedia.net> At 01:39 AM 3/31/01 -0300, Carlos Alberto Reis Ribeiro wrote: >Robin, please have some patience, and read my entire answer before >replying. I think I have a good point here. I didn't mean to discourage you or disparage your idea; I do think it's a good idea. Instead, I wanted to encourage you to have some patience with your idea. Explore the Python source and get an implementation working first; after that, the proposal and subsequent PEP are easier to keep focused. It also makes it easier to keep the community discussion focused if there is a runnable and testable implementation of the proposal. Without a driving implementation, it is easy for the discussion to become unduly abstract, religious, or personal. Best of luck once you get the source; I look forward to reading your discoveries and updated proposal. -- robin900 at yahoo.com _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From aleaxit at yahoo.com Tue Apr 24 18:26:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Apr 2001 00:26:03 +0200 Subject: Named code blockes References: Message-ID: <9c613001b5q@news2.newsguy.com> wrote in message news:mailman.988139077.14935.python-list at python.org... [snip] > One genius clamored for a huge new mechanism that would at > last, in the Plenitude of Glory, let him write "let x = y" > versus "set x = y" so he'd get ``declarations'' -- and then, > when somebody showed him how easily he could set things up > so as to write "let.x = y" and "set.x = y", he claimed his > coworkers would kill him if he programmed that way. Well > isn't that obvious, that being able to have a SPACE there > instead of a PERIOD is the be-all, end-all of programming?! > Isn't it _absolutely_ obvious that placing a period there > will lead to justified homicide...? > > > (In defense of the "genius" mentioned above, just because > one does not agree with another's opinion does not warrant > rudeness in one's posts.) I fully agree that rudeness is not warranted JUST because of disagreement -- it only becomes warranted, if at all, if the "other" is being rude first. So I don't see how this observation "defends" our sweetly beloved genius in any way. But pursuing this would no doubt lead us along the same old garden path once again -- is it "rude" to point out how ridiculous somebody is being by his advocacy of a certain idea, for example? Or is it rude to post ridiculous ideas in the first place?-) Bah, no matter -- I do NOT consider daydreaming about being able to have an unnamed function/codeblock in any way ridiculous, just maybe a misplaced emphasis in my opinion. A completely different level of disagreement:-). Alex From jhg at galdon.com Wed Apr 25 06:37:46 2001 From: jhg at galdon.com (Juan Huertas) Date: Wed, 25 Apr 2001 12:37:46 +0200 Subject: iterating through humongously large key lists!! References: <3AE69EF6.46C74A31@herts.ac.uk> Message-ID: <9c6910$t8m$1@talia.mad.ttd.net> You can try to store the dict in a b-tree file (bsddb) using cPcikle and access the keys sequentialy whit the next or prev methods. Mark blobby Robinson escribi? en el mensaje de noticias 3AE69EF6.46C74A31 at herts.ac.uk... > Is it is possible to interate through the keys of a dictionary object > without loading the entire key list into memory? I am working with a > situation where I need to interate through a dictionary containly > routinely millions and potentually many millions of keys. Not only is it > painfully slow to generate the list, but it eats into my memory > significantly too. Please tell me there is a better way. > > Blobby > From bob_cannard at mentor.com Tue Apr 17 16:01:05 2001 From: bob_cannard at mentor.com (Bob Cannard) Date: Tue, 17 Apr 2001 13:01:05 -0700 Subject: do...until wisdom found... References: <3ADC6F1F.DE1A2FB1@mentor.com> Message-ID: <3ADCA101.6059336E@mentor.com> Dennis Baker wrote: > > On Tue, 17 Apr 2001 09:28:15 -0700 Bob Cannard wrote: > > ) Has no one else found that the majority of while-type > ) loops actually need some code before the test and some > ) after? Doubly so in Python where it seems impossible > ) to embed a local side effect in the while condition. > ) As a result, most non-for loops degenerate into > ) > ) while 1: > ) set up for this cycle > ) if c: break > ) whatever needs to be done > > That's a product of poor design. I consider it a failure to resort to this sort > of construct. The only time I resort to it is with Error trapping code where > you are forced to do something drastic. For the purpose of debugging code > readability and reliability you are always better off doing things the "Right" > way. I was waiting someone to say that. No, Dennis, it's not a product of poor design. It's a product of examining many problems with clear eyes, without the distorting lens of a widely-accepted but insufficiently questioned dogma. There are always ways that the general loop can be transformed into a while loop. Every single one of them involves additional complexity: code duplication, the addition of flag variables, a break statement, or the construction of an iterator. The break statement and the iterator are the only transforms that do not divorce the structure of the source code from the structure of the problem. The iterator is IMO the most satisfactory of these, but I also need to get my job done and my software to meet its performance requirements; together they do not allow the luxury of using an iterator every time. I don't like using break statements, but I dislike them less than the alternatives: code duplication (a bug waiting to happen) or flag variables (spaghetti data, the structured programming zealot's solution to spaghetti code). And the break statements would not be necessary at all if the general loop - which is (unknown to many) supported directly and successfully by many languages, including the Bourne shell and its descendants such as bash and ksh - was carefully considered instead of being dismissed out of hand as not canon. To say that the "while" loop is the "right" way is to simply accept the dogma. The while loop should be a tool, not a religion, and like all tools it is not suited to all situations. Practical experience - over and over again, through my 25 or so years in this business - shows clearly that the it is usually ill-matched to the problem; the very existence of iterators such as xreadlines is testament to this. Whereas most branches of engineering accept the sound principle that form follows function, software engineering seems to insist on using a form that is clearly ill-suited to the function, and instead bludgeons the function until it fits the form. You will find yourself hard pressed to convince me that this makes a program clearer, more reliable, and easier to debug. Cheers, Bob. From chris.gonnerman at usa.net Tue Apr 24 09:00:37 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 24 Apr 2001 08:00:37 -0500 Subject: NTFS permissions References: <1e232f6f4a%tim@worthy.demon.co.uk> <3AE360DA.5030806@ActiveState.com> <8b4a16f4a%tim@worthy.demon.co.uk> <3AE4BAB0.3090204@ActiveState.com> <1af319704a%tim@worthy.demon.co.uk> Message-ID: <002401c0ccbe$90996b40$a100000a@local> ----- Original Message ----- From: "Tim Howarth" Subject: Re: NTFS permissions > In message <3AE4BAB0.3090204 at ActiveState.com> > Mark Hammond wrote: > > > Tim Howarth wrote: > > > > > My problem with directories not accepting security descriptors was > > > not quite correct. > > > > So next problem how do I turn them on programmatically ? > > > > > > It appears the win32 extensions lack this capability. > > Thanks, again, nice to know it's not me ! > > I guess I'll have to stick to cacls.exe for now. > > (Except, that echoes output to my user creator web page, need to sort > that out....change stdout whilst calling cacls ?) Use the os module to manipulate the "real" stdout/stderr before running your ill-behaved program. Assuming you want the external program's output hidden: import sys, os # save my real stdout for my use later. sys.stdout = os.fdopen(os.dup(1), "w") # might also want: # sys.stderr = sys.stdout # or alternately: # sys.stderr = os.fdopen(os.dup(2), "w") # or you might not. # close real stdout and stderr os.close(1) os.close(2) # protect against accidents: os.open("nul", "w") os.open("nul", "w") As file descriptors (even under Windoze) are allocated on a first-available basis, the NUL device gets the fd #1 and #2 positions. This is to prevent us from opening another file later and accidentally getting the real stdout or stderr munged. > > My MSDN CD has an article "HOWTO: Set Security on a NTFS Folder > > Programmatically" that shows exactly what you want (although in VB code!). > > Yes, that's probably what I found when trying to work out how to do this > - VB being more readable to me than similar things in C. > > > It would be cool to add this support, and not _too_ much work - I would > > be happy to help, but don't have the time to do it all right now... > > Is there any way to do a generalised API call with win32 ? (Staying in > Python, I've no/very little knowledge C-wise and certainly none about > compiling win32 from sources.) There is a calldll module. I don't remember where it's from, but you can find it on Parnassus. From bokr at accessone.com Wed Apr 25 03:53:55 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 25 Apr 2001 07:53:55 GMT Subject: GetTickCount vs. clock for msec resolution References: <8f7vdtk3ukd35mbr15bass72mg2erf95ks@4ax.com> <94f7etcb92ctccmn8gi70bafbsd6p6guug@4ax.com> Message-ID: <3ae67d02.173496715@wa.news.verio.net> On Sun, 22 Apr 2001 22:30:44 -0700, Tim Roberts wrote: >"Tim Peters" wrote: [... >For those of who might not know the derivation of that number, it's an >interesting study in how a convenience can become encoded as history. When >IBM was building the original IBM PC in 1980, their charter was to produce >it as cheaply as possible with as many off-the-shelf components as >possible. They needed a motherboard clock of some kind for timing. Well, >the most common crystal in the world at the time (and probably now, too!) >was the 14.31818 MHz crystal used in television flyback circuits. This was >a little fast for their purposes, so they passed it through a divide by 12 >circuit. > >14,318,180 / 12 = 1,193,180, and the rest is history. The TV connection was interesting new info for me. As you know, a little arithmetic shows where that silly almost-55 ms tick comes from too -- count to 2^16: (1/1193180)*65536 = 0.0549254 sec, for 18.206482 hz. From scarblac at pino.selwerd.nl Thu Apr 19 19:07:19 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Apr 2001 23:07:19 GMT Subject: Newbie question: how to determine "is-a" relationship References: <3adf26c6.4547281@news1.on.sympatico.ca> Message-ID: Robert Roy wrote in comp.lang.python: > On Thu, 19 Apr 2001 10:46:53 -0500, "Jake Baker" > wrote: > > >Gosh. I've been using Python since 96 and I don't know this! Wow! > > > >Say I have a class heirarchy that looks like A, B <- A, C <- A, etc.... > > > >I have a list of objects (which I know arbitrarily are all A or sublasses = > >of A) and want to filter them based on which subclass they are. > > > >How do I go about doing this? You help is greatly appreciated! > > > >Thanks, > > - Jake Baker > > I think that instanceof will do the trick. See the Python Library > Reference under Built-in Functions (Doc\lib\built-in-funcs.html) Just a slight correction, the function is called 'isinstance'. He could also look directly at the objects' __class__ member, or even __bases__. -- Remco Gerlich From py.list at mulga.com.au Mon Apr 23 07:26:07 2001 From: py.list at mulga.com.au (Michael Hall) Date: Mon, 23 Apr 2001 20:56:07 +0930 (CST) Subject: Python vs. PHP In-Reply-To: <9c09pr$73j$1@brokaw.wa.com> Message-ID: If you're working on web applications, what is it that Python could give you that PHP doesn't already provide, especially considering you already know PHP, PHP is as simple and clean (in its own way) as Python, and PHP is very easy to install and configure with Apache and MySQL? Mick From dalke at acm.org Tue Apr 10 11:34:59 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 10 Apr 2001 09:34:59 -0600 Subject: Class Variable Question References: <3ad306b1$0$47992$e2e8da3@nntp.cts.com> Message-ID: <9av9cj$la0$2@slb7.atl.mindspring.net> Robert Johnson wrote: >>>"Ken Seehof" wrote in message >>>news:mailman.986858653.28960.python-list at python.org... > >>>You can always protect against certain bugs by reducing the >>>expressiveness and flexibility of a language, but that's not always >>>a good idea. For example, by removing the addition operator, we >>>can prevent errors such as y = x+3 when we really mean y = x+2. > >This doesn't make sense. Getting rid of the addition operator does prevent >y=x+3 errors but it also prevents what is intended: y=x+2. I am not sure >this example demonstrates the point you are trying to make. I took this in the same vein of Q: how do I get rid of this cold? A: Well, you could always chop your head off. Andrew dalke at acm.org From sholden at holdenweb.com Sun Apr 8 00:03:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Apr 2001 00:03:10 -0400 Subject: Class design: accessing "private" members References: <962352843.1667731268@news.libertysurf.fr> <8jhuvn01vs0@news2.newsguy.com> Message-ID: "Steven D. Arnold" wrote in message news:mailman.986695793.20923.python-list at python.org... > > 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. [ Discsussion of "properties" vs."attributes" overlooked] > Having said all that, I admit a little hypocrisy: in short scripts on > rare occasions, I do not use accessors. Sometimes they're more > trouble than this script is worth. However, beware of that sort of > thinking. Little throwaway scripts very often end up hanging around > a long time and it's good to craft every line of code carefully with > that in mind. This is sound practice, but a Pythonic liberty has always given the intelligent programmer enough rope to shoot themselves in the foot, if you'll forgive a little metaphor-mixing. In otehr words, Python allows you to do it either way. If you don't know enough to discriminate between the cases when it's a bad idea and the cases when it's a good idea then you should just be grateful you found Python before someone wrapped you in the C++/Java straitjacket. although-straitjackets-aren't-entirely-bad-thngs-and-can-improve-the-lives-o f-mad-wearers-ly y'rs - steve From phd at phd.russ.ru Mon Apr 2 11:04:54 2001 From: phd at phd.russ.ru (Oleg Broytmann) Date: 2 Apr 2001 10:04:54 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 2) Message-ID: <44B237E5B1C138E8.BF42458E7AB2C3CA.C9AC6A79333B04E7@lp.airnews.net> Guido van Rossum writes an excellent April First Joke :) http://mail.python.org/pipermail/python-list/2001-April/035964.html PythonLabs Team Moves to ActiveState http://groups.google.com/groups?lr=&group=comp.lang.python&safe=off&ic=1&th=dff8073ca41805c&seekd=907446976 Another nice joke: Programming Parrot is the definitive reference for the new, dynamic programming language, Parrot, a language intended to merge the indubitable strengths of the twin Open Source scripting giants, Perl and Python http://www.perl.com/pub/2001/04/01/parrot.htm http://www.oreilly.com/parrot/ http://use.perl.org/article.pl?sid=01/03/31/206248 http://slashdot.org/articles/01/03/28/1742237.shtml Other jokes http://lzip.sourceforge.net/ http://groups.yahoo.com/group/python-list/message/130567 http://groups.yahoo.com/group/python-list/message/130644 http://groups.yahoo.com/group/python-list/message/130646 Well, now to the more serious side of things Moshe Zadka is going to release Python 2.0.1 http://mail.python.org/pipermail/python-list/2001-March/035238.html Fred Drake updates the development docs http://groups.yahoo.com/group/python-list/message/130165 Clark Evans continues to push his __query__ proposal http://groups.yahoo.com/group/python-list/message/129832 http://groups.yahoo.com/group/python-list/message/129849 Carlos Alberto Reis Ribeiro joins the discussion http://groups.yahoo.com/group/python-list/message/129898 The PEP has got number 246 http://groups.yahoo.com/group/python-list/message/130111 Paul Moore writes PEP for using site-packages on all platforms http://groups.yahoo.com/group/python-list/message/130334 Paul Magwene starts to collect hints and tips for interactive startup script http://groups.google.com/groups?lr=&group=comp.lang.python.*&safe=off&ic=1&th=170c03b484af4f99&seekd=909430480 Alex Martelli writes an incredible code for making diff on two strings http://groups.yahoo.com/group/python-list/message/130321 Simon Brunning publsihes multi-serach/replace script http://groups.yahoo.com/group/python-list/message/129806 Will Ware publishes code to search for latitude/longitude/mapping http://groups.yahoo.com/group/python-list/message/130273 Dave Kirby releases Python Mock Objects to the Python and XP communities http://groups.yahoo.com/group/python-list/message/130063 A philosophical tutorial to Twisted Python http://twistedmatrix.com/page.epy/philosophy.html Jack Jansen releases MacPython 2.1b2 http://groups.yahoo.com/group/python-announce-list/message/1111 Easel's Ken Kocienda: Python is a good initial choice for several reasons. It is a quick prototyping language that scales up well as a project becomes larger, it has a wealth of libraries, and it has very good bindings to GTK+. Also, Python's rexec and Bastion features give us the tools to address some of the security concerns raised by shipping code around the Net that executes on local systems http://www.linuxpower.org/display.php?id=209 Everyone and his brother want his own ZODB Jeremy Hylton announces CVS for StandaloneZODB http://groups.yahoo.com/group/python-list/message/129951 Andrew Kuchling synced his ZODB tarball with Zope 2.3.1 final http://groups.yahoo.com/group/python-list/message/130399 Zope: Jerry Spicklemire collects a list of latest zope announces http://lists.zope.org/pipermail/zope/2001-March/086709.html Zope 2.3.1 final http://lists.zope.org/pipermail/zope-announce/2001-March/000401.html The most interesting change is added logic to use query operator (and, near, andnot, or) http://www.zope.org/Products/Zope/2.3.1/CHANGES.txt Tres Seaver releases Zope Content Management Framework 1.0 http://lists.zope.org/pipermail/zope-announce/2001-March/000399.html Alexandre Ratti updates the compilations of Zope Howtos and Tips http://lists.zope.org/pipermail/zope-announce/2001-March/000398.html Hot threads of the week: list vs tuple http://groups.google.com/groups?lr=&group=comp.lang.python.*&safe=off&ic=1&th=23523b1723e238b9&seekd=908994596 Substantial Apps Written in Python http://groups.google.com/groups?lr=&group=comp.lang.python&safe=off&ic=1&th=798983d5cc9a6bb2&seekd=907507373 Conditional operator in Python http://groups.google.com/groups?lr=&group=comp.lang.python&safe=off&ic=1&th=adca2c03587ce242&seekd=907415529 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aleaxit at yahoo.com Mon Apr 9 15:49:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Apr 2001 21:49:22 +0200 Subject: Class Variable Question References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> Message-ID: <9at3ks01304@news1.newsguy.com> "Douglas Alan" wrote in message news:lc3dbiou2u.fsf at gaffa.mit.edu... > "Steve Holden" writes: > > > That's correct. Python gives you "enough rope to shoot yourself in > > the foot", and so does not offer the protection schemes associated > > with statically-types languages like Java and C++. This increases > > the flexibility of the language, at the (slight) risk of errors > > which would not occur in Java or C++. > > Actually, there's no extra flexibility than if you used different > syntaxes for variable initialization and variable assignment. Of course there is -- if you did the latter, you would for example have to use different syntax for the first pass through a loop than for further ones. You might choose to have THREE approaches: one that works just as well for the first binding and for other re-bindings, one that just works for the first binding, one that just works for re-bindings. Funny enough, it's trivial to have that...: def firstBind(object, attname, value): if hasattr(object, attname): raise AttributeError, attname return setattr(object, attname, value) def reBind(object, attname, value): if not hasattr(object, attname): raise AttributeError, attname return setattr(object, attname, value) and, of course, use setattr for the common case, where you do not care whether it's the first binding or a further one. Deciding which approach the assignment-statement is syntax sugar for is not currently feasible (except for binding to attributes of instances) -- you always get "setattr semantics" then. It would take incredibly little to make it feasible for most assignments -- just a couple of bits on each dictionary object, optionally 'locking' it against certain changes -- as dictionaries are what underlies most assignments (local-variables being the exception, and rather an issue for most such metaprogramming approaches). Gotta work on a patch for that one of these days (hmmm, better do a PEP first). I draw the line at having two subtly different syntax-sugar forms for two of the three kinds of binding (first-binding, re-binding, any-binding) and I think that having _three_ subtly different syntaxes is even worse. We have that in our proprietary scripting language (which is embedded in all of our applications), but I consider that a _defect_ of the language, not a plus (it was designed a long time ago, and compatibility means we can of course never take such a 'feature' away:-) -- in many years of experience, I've seen it confuse newbies (and occasionally old hands, too) far more often than I have seen it used in arguably profitable ways. Having ONE kind of assignment (and function call syntax for other, non-assignment kinds of manipulation) seems far preferable. > > There is magic you can do to restrict operations of this kind, but most > > Python programmers are happy to accept the language as it is, since in > > practise this doesn't appear to be a problem. > > In practice it is a *very* significant problem. This is certainly one > of the largest sources of bugs. And it is, annoyingly enough, one of > the few valid complaints that Perl devotees can make against Python. Oh? How many large Python applications have you written, that you can so confidently assert this language characteristic is "one of the largest sources of bugs" in said applications, against the unanimous opinion of several of us who HAVE developed such apps...? Extraordinary claims require extraordinary proof -- and, clearly, it *is* a rather extraordinary claim for you to make, that you know "one of the largest sources of bugs" in a language, better than people more experienced in said language (and please don't think that we ONLY know that language -- I still gain most of my daily bread & champagne dealing with _other_ languages, e.g. by being the official "C++ guru" for my employer!-). I await with interest your display of 'extraordinary proof' to match. BTW, the only controlled empirical experiment of language comparison of which I'm aware doesn't match your unsupported assertions -- Ptyhon (and, admittedly, Perl) shined in terms of both productivity AND resulting-program solidity against other languages supporting static compile-time checks (such as Java, in particular). > > Look at it this way: you can spend the 60% time saving you will make > > by programming in Python to make sure you have not made such errors! > > Why not be honest: It's a wart on the language. If you're deliberately trying to insult, you're choosing your barbs pretty well -- here, implying dishonesty (a deliberate lie) in the technical assertions of people you have (as far as I know) never met. We have professional reputations, you know, and I consider you at the very least one of the rudest louts to have recently darkened the face of this newsgroup. Alex From loewis at informatik.hu-berlin.de Wed Apr 25 04:54:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Apr 2001 10:54:21 +0200 Subject: How do I do this without class methods ? References: Message-ID: Jacek Generowicz writes: > # This only works, for the base class (no surprise) > def welease_bwian( N ): > woderwick.wodger = woderwick.bwian[N] How about def welease_bwian(klasse, N): klasse.wodger = klasse.bwian[N] So, instead of writing roderick.welease_bwian(3), you'd write welease_bwian(roderick, 3) In most languages with static methods, you cannot do this, since classes are not first class objects (or maybe they are, but have other funny limitations). Regards, Martin From cribeiro at mail.inet.com.br Sun Apr 22 20:54:40 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sun, 22 Apr 2001 21:54:40 -0300 Subject: GUI - VCL Use In-Reply-To: <20010422202544.12212.00000114@ng-cb1.aol.com> Message-ID: <5.0.2.1.0.20010422215102.02370b60@mail.inet.com.br> At 00:25 23/04/01 +0000, CarlCrewe wrote: >Has anyone used a RAD tool such as Borland C++ Builder or Delphi (same VCL) to >write GUI for python I'm thinking hard about doing it. I'm used to Delphi - not that I think it's the best tool around, but it does have a nice set of visual components, and the language is much more consistent than C++ (at least from my point of view). It also generates decent code. There is a Python for Delphi project, at http://www.multimania.com/marat/delphi/python.htm I have installed it and played a little bit. It seems to work, but I haven't done any serious project with it, so your mileage may vary. My idea is to have the interface written in Delphi, and business logic and user extensions written in Delphi. Carlos Ribeiro From tebeka at lycosmail.com Thu Apr 12 08:27:06 2001 From: tebeka at lycosmail.com (Miki Tebeka) Date: Thu, 12 Apr 2001 15:27:06 +0300 Subject: Python Programming Ettiquette References: Message-ID: <9b46ut$jo9@news.or.intel.com> Hello zzzz, >... > a) Directly modify the parameter: > b) Return the result, keeping the passed parameter untouched: As a follower of the functional appraoch I vote for b. I you don't have good reasons (like efficiency), never change a parameter passed to a function. Bye. ---------------------------------------------------------------------------- -- Smile, damn it, smile. lambda msg: 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From aleaxit at yahoo.com Sat Apr 14 14:40:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Apr 2001 20:40:14 +0200 Subject: Named code blockes References: Message-ID: <9ba5nf01lil@news1.newsguy.com> "Steven D. Majewski" wrote in message news:mailman.987267203.15768.python-list at python.org... > > > On Sat, 14 Apr 2001, Miki Tebeka wrote: > > >Alex: > > > In Python, you can code around this problem in various ways (besides [snip] > I wouldn't call it a code-around though -- that just one of the I would. If one can break out of one level of loop with the break statement, why would exceptions be the 'designed' way to break out of two or three levels? It's not that rare a need. It's not an issue of optimization for me, but of clear and explicit expression of design intent. Alex From aleaxit at yahoo.com Tue Apr 24 09:53:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Apr 2001 15:53:27 +0200 Subject: NTFS permissions References: <1e232f6f4a%tim@worthy.demon.co.uk> <3AE360DA.5030806@ActiveState.com> <8b4a16f4a%tim@worthy.demon.co.uk> <3AE4BAB0.3090204@ActiveState.com> <1af319704a%tim@worthy.demon.co.uk> Message-ID: <9c40gn01k6i@news1.newsguy.com> "Tim Howarth" wrote in message news:1af319704a%tim at worthy.demon.co.uk... [snip] > Is there any way to do a generalised API call with win32 ? (Staying in > Python, I've no/very little knowledge C-wise and certainly none about Yes, Sam Rushing's "calldll" is oriented to exactly that -- let you call any DLL routine (including API's) on Win32. You will find versions for Python 1.5.2 and 2.0 listed among the very interesting stuff at http://www.nightmare.com/software.html (don't know how hard it would be to adapt the 2.0 version to 2.1 -- presumably not terrible). Alex From bauhahnm at clara.net Tue Apr 24 20:33:41 2001 From: bauhahnm at clara.net (Maurice Bauhahn) Date: Wed, 25 Apr 2001 01:33:41 +0100 Subject: Jython: How to import escaped Unicode and export utf-8? Message-ID: <3AE61B65.3E150107@clara.net> I've been having some problems processing Unicode imports and exports. My imports of escaped Unicode (u'\u1780' or '\u1780') end up in my lists as: ["u'\\u1780'"] and .write as u'\u1780'. >From the command line I can get something useful by writing: u'\u1780'.encode('utf-8') but it does not appear to work within my jython script. Any suggestions? Cheers, -- Maurice Bauhahn United Kingdom Home Email: bauhahnm at clara dot net From vinil at chl.cz Fri Apr 27 09:40:22 2001 From: vinil at chl.cz (ViNiL) Date: Fri, 27 Apr 2001 15:40:22 +0200 Subject: Tkinter and NON iso8859-1 fonts Message-ID: <20010427154022.A11426@ns.chl.cz> Hi! I cannot display non ISO-8859-1 text on any of Tk widget, despite I specify f.e. font="*-iso8859-2". Did I miss something? Or is there someone, who sucessfully displayed iso-2 text? Thanks. -- ViNiL the GNU hippie From kentsmith at dxsys.com Sat Apr 28 11:21:44 2001 From: kentsmith at dxsys.com (kentsmith at dxsys.com) Date: Sat, 28 Apr 2001 15:21:44 GMT Subject: Jobs in Toronto Message-ID: Expertise: Tkinter, Python, O-O programming Location: Downtown Toronto Jobs: 12 full-time positions, good pay, supportive environment, interesting applications Methodology: Extreme programming Industry: film/television (Preferably local programmers; we'd rather not deal with relocation fees or travel) reply: python at purevanilla.com From footech at get2net.dk Tue Apr 24 07:40:49 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Tue, 24 Apr 2001 13:40:49 +0200 Subject: ANNOUNCE: SnakeCharmer v1.0 References: <3AE4435A.DD7CD675@schlund.de> Message-ID: Carsten Gaebler wrote in message news:3AE4435A.DD7CD675 at schlund.de... > SnakeCharmer is a small CGI script that collects information about the > local Python interpreter, environment variables and installed Python > modules. It was inspired by PerlDiver > (http://www.scriptsolutions.com/programs/free/perldiver/) and has a > similar layout. > > SnakeCharmer can be downloaded from http://snakefarm.org/ > > Suggestions for a better name are welcome. :-) Snakecharmer is also the name of the Danish band "Sort Sol"s new album. ;-) Mikkel Rasmussen From dsavitsk at e-coli.net Tue Apr 3 19:44:49 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 3 Apr 2001 18:44:49 -0500 Subject: Tkinter scrolling canvas nightmare Message-ID: i have been trying to scroll a canvas widget for weeks now. if anybody can offer some suggestions i would be very happy to hear them. i can get all of the stuff i want to appear, and the scrollbars move, but the canvas just sits there. also, PMW (scrolledframe in particular) would be a better solution, but it doesn't seem to give me control over the scroll bars programatically or allow me to tie one of the scrollbars to 2 scrolled frames. if anyone can help with that it would be great too (even helping me to modify the scrolledframe class). here is some sample code. this version is copied almost verbatim from john shipman's tutorial. i have other non-working versions if anyone is interested in them too ;-) thanks, doug ------------------------------------------- from Tkinter import * class contain: def __init__(self, parent): self.f = Frame(parent, bg='#ff0000', border=0) self.f.pack(expand=NO, anchor=NW) self.c = Canvas(self.f, bg='#00ff00', width=600, height=400, scrollregion=(0,0,1200,800)) self.c.grid(row=0, column=0) self.sy = Scrollbar(self.f, orient='vertical', command=self.c.yview) self.sy.grid(row=0, column=1, sticky=N+S) self.sx = Scrollbar(self.f, orient='horizontal', command=self.c.xview) self.sx.grid(row=1, column=0, sticky=E+W) self.c['xscrollcommand'] = self.sx.set self.c['yscrollcommand'] = self.sy.set for i in range(50): Label(self.c, text='label # ' + str(i), relief=RIDGE).pack(side=LEFT, padx=5, pady=5, expand=NO) if __name__ == '__main__': root = Tk() x = contain(root) mainloop() From jmarshal at mathworks.com Fri Apr 6 12:13:37 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 6 Apr 2001 16:13:37 GMT Subject: operator on functions References: Message-ID: <9akpvh$74k$1@news.mathworks.com> Szalay Zoltan wrote: > Hi everybody out there! > It would be a nice feature of Python syntax providing an operator to > compose a function from another two: > h=f*g . I mean (f*g)(x)=f(g(x). Though maybe a little thought needs to go into multiple arguments (to f): (f*g)(x) => f(g(x)) -vs- apply(f*g, x) => apply(f, apply(g, x)) or some hybrid. From qrczak at knm.org.pl Sun Apr 1 09:39:34 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 1 Apr 2001 13:39:34 GMT Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> Message-ID: 01 Apr 2001 13:58:35 +0100, Michael Hudson pisze: > > > (x and [a] or [b])[0] > > > > It computes both a and b. > > No it doesn't: Oops, of course, stupid me. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From steven at haryan.to Tue Apr 3 09:56:51 2001 From: steven at haryan.to (Steven Haryanto) Date: Tue, 03 Apr 2001 20:56:51 +0700 Subject: excluding unit test code In-Reply-To: References: Message-ID: <4.3.2.7.2.20010403205643.02c5a008@bdg.centrin.net.id> At 4/3/2001 06:54 AM, you wrote: > What do you mean by "exclude"? The same way -OO excludes doc-string from the source code, i.e.: it is optimized away by the compiler, and never gets into the object code/loaded into memory/executed. > If this were C, > I'd say that you could just use "#if 0" around the > test blocks for when you ship production code. > The quick way is to convert: > > some_test_code() > > into > > if None: > some_test_code() > > if that's OK with you. That way it will never be > executed. How else you would do it depends on your > definition of "excluded". You could hide it in > another module, or just cut it out altogether. After being advised by Steve Purcell, I think I will go with something like 'if __DEBUG__' instead of 'if 0' or '#if DEBUG' (running the Python source through cpp first), so clients _can_ execute the test code. Thanks, Steve From rcameszREMOVETHIS at dds.removethistoo.nl Tue Apr 10 18:20:44 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Tue, 10 Apr 2001 22:20:44 GMT Subject: other python ideas References: Message-ID: Douglas Alan wrote: >rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) writes: > >> Getting rid of import statements is *evil*. It means the >> dependencies in your code will be hidden from others. > >How's that? All you'd have to do is grep for "::". [...] It's not >like import statements all have to be at the top of the file in >Python code as it is. They certainly aren't in my code. But I don't *want* to be forced to search through your source, I prefer to look at the top the file and see what's imported (and how) at a glance. Importing modules at the top of the file isn't syntactically required, but I would say it's highly recommended, unless there are very good reasons not to do so. Remember: "Python gives you enough rope to let shoot yourself in the foot," but that doesn't mean that you're under any obligation to do so. ;-) >> Also, install and freeze packages have a harder determining what >> modules are needed (which is hard enough as it is). > >It would be no harder than it is now. "module::foo" would just be >syntactic sugar for "__import__("module").foo" (along with a more >efficient implementation technique). Well, using __import__() really should be kept to a minimum as well, IMHO. >>> Another problem is that if you import individual objects from a >>> module, and then you reload the module, the individual objects >>> remain out of date. This causes you to end up trying in the >>> debugger to track down bugs that turn out to debugger-only bugs. > >> Blame the debugger, not Python's module syntax. The debugger >> really should start from scratch if you've edited a module, >> otherwise you're actually modifying the program while it is still >> running. Very unsafe, and there's no general way to fix that. > >Sure there is. And I don't want to start from scratch. A Lisp >Machine just runs one big Lisp (even the OS is in that one big Lisp) >that never goes away until you reboot it. In such an environment, >being able to reliably reload modules is essential. > > [snip] Switching back to Python: it probably wouldn't be very hard to delete the dictionary which holds all variables initialized by a module (and those variables may hold references to data, functions and class definitions) but what if - for instance - one such variable contained data needed for subsequent calculations? There's no general way to determine what data is safe to keep and what should be discarded and recalculated. In a limited way - e.g. just to replace a simple, non-aliased function which doesn't have side effects - it could be done safely, of course. But for a debugger it would be very hard, if not impossible to determine if those conditions are met. A Python module is *not* a library: it's a piece of code which, when executed, will build certain data structures, which you can use from then on. Correctly building those data structures may or may not depend on executing that code in full and the exact same order it's in the file. Just take a look at the (admittedly silly) example below. def _one(): return 0 # Oops! one = _one Now what would happen if the '_one()' is corrected (it surely needs to be!) and only the 'def _one():' function is reloaded? That wouldn't change 'one' at all. And so I'll restate: there is no general way of importing or reloading part of a module which is guaranteed to work. >Recall again that I'm not suggesting that Python be changed, at >least not before Python 3k. I'm just pointing out what would make a >better language. There's no need to be defensive, we all like to bounce our ideas off others. I, for one, just don't like this particular idea. Robert Amesz From be at mek.dtu.dk Tue Apr 17 08:11:35 2001 From: be at mek.dtu.dk (Brian Elmegaard) Date: Tue, 17 Apr 2001 14:11:35 +0200 Subject: canvas drawing on button Message-ID: <3ADC32F7.95AD63C9@mek.dtu.dk> Hi, Is it possible in any way to make python generate a bitmap/image of a tkinter canvas item and use that for a button bitmap/image? or, can I make a canvas on a button? or, do I really have to make the drawing outside of python? -- Brian http://www.et.dtu.dk/energysystems http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From zenchm at usa.net Sun Apr 22 11:17:06 2001 From: zenchm at usa.net (Zenon C.) Date: Sun, 22 Apr 2001 15:17:06 GMT Subject: wxPython built for 2.1? - INSTALL problems References: Message-ID: I've been trying to install wxPython-2.2.5-Py20.EXE for the last two days on Win2000 Professional. I instaled it to c:\wxpython. No problems but then the demo will not wotk. C:\wxpython\demo>python demo.py Traceback (most recent call last): File "demo.py", line 3, in ? import Main File "Main.py", line 15, in ? from wxPython.wx import * ImportError: No module named wxPython.wx I checked the path: >>> import sys >>> sys.path ['', 'c:\\wxpython', 'c:\\wxpython\\demo', 'c:\\python21\\dlls', 'c:\\python21\\lib', 'c:\\python21\\lib\\plat-win', 'c \\python21\\lib\\lib-tk', 'c:\\python21'] >>> Then I tried: >>> import wxPython.wx Traceback (most recent call last): File "", line 1, in ? ImportError: No module named wxPython.wx >>> Then I tried: >>>import wx I get an alert box with this message: The dynamic link library python20.dll could not be found....... I searched my system for python20.dll - it is not anywhere in my system. I am completely lost. There seem to be many such problems listed on the wxPython user list. But no answers that would help. I know from reading that list that there are many people struggling with getting it to work. Any thoughts on what is going on? Thanks Zenon "G K" wrote in message news:YlsE6.10749$U4.2472137 at news1.rdc1.tn.home.com... > Subject says it all. > -- Gabor > > > From lloyd at venix.com Fri Apr 27 13:23:21 2001 From: lloyd at venix.com (Lloyd Kvam) Date: Fri, 27 Apr 2001 13:23:21 -0400 Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> <3ADF54F1.6000409@hccnet.nl> <3AE0F802.3983C9DB@01019freenet.de> <9brd4f0p7u@news1.newsguy.com> <3AE1D1DE.BF3CEA18@Lugoj.Com> <9c6sfi$e02$2@godfrey.mcc.ac.uk> Message-ID: <3AE9AB09.70C26456@venix.com> A functional programming language requires that every function return the same result from the same inputs. A "non-functional" function can make that clearer. If a bank has a function add_to_balance that takes a deposit value as an argument and returns your new balance, that would be non-functional. add_to_balance(3) returns 3 add_to_balance(3) returns 6 add_to_balance(3) returns 9 One of the benefits of a functional language is that it is easier to implement parallel processing. http://cm.bell-labs.com/cm/cs/who/wadler/guide.html goldaryn wrote: > > James Logajan summoned a gibbering mouther that screamed: > >Alex Martelli wrote: > >> [...] since Python does have list comprehensions, [...] > > > >Not being a computer scientist, I hope you can excuse a profoundly ignorant > >question, but what are (or is?) "list comprehensions"? And another question > >(probably harder to answer): is there someplace on the web or in print where > >I can find a good definition of "functional programming"? I'm pretty sure it > >doesn't mean classical procedural notation, more like mathematical or > >logical notation, but I can't be sure. > > > >Many years back I did some application development using such a beast (at > >least I think that is what it was trying to accomplish), but in the end one > >had to rely on procedural elements to get information in and out and do some > >other pedestrian things. > > > >Thanks! > > Searching Google (www.google.com) with "immutable types functional > programming" I got this URL. Should do the job. > http://gnosis.cx/publish/programming/charming_python_13.txt > > Basically, functional programming is not sequential processing of command > using variables. You define methods. You're right, it is hard to define :) > > I learnt SML at first year of university. If you're keen you might try that as > an example language. Search Google. > > g. -- Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358 voice: 603-443-6155 fax: 801-459-9582 From claird at starbase.neosoft.com Fri Apr 6 09:41:34 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 6 Apr 2001 08:41:34 -0500 Subject: Python Books for 2002 References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> Message-ID: <11A279245FF128F8.7A0E8AF314DD0135.E3C0007C3BD57C8C@lp.airnews.net> In article , John J. Lee wrote: >On 5 Apr 2001, Cameron Laird wrote: > >> In article , >> Simon Brunning wrote: >[...] >> 2. C++: it might be an OK language, but look at >> the destruction it leaves in its wake. > >Explain? . . . I thought I was being cute--specifically, I was trying lightly to inspire, "Look, even a discussion *about* using C++ leaves c.l.p in shambles; imagine what an actual implementation does to a project team." I'm serious about that. Maybe it's wonderful stuff--in fact, I've been fond of C++ at several times, and still use it frequently--but anything (like children's organized sports in the USA, certain religions, and Kashmiri cartography) that inspires such violent clashes makes me wonder whether a better approach isn't overdue. The complementary point I also recognize, of course: C++ is about such important things that it's *worth* starting a fight. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From mal at lemburg.com Tue Apr 3 13:36:43 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 03 Apr 2001 19:36:43 +0200 Subject: mxODBC chokes on dates! Any Help? References: Message-ID: <3ACA0A2B.C42C1BE5@lemburg.com> Owen Ap Owen wrote: > > I'm using mxODBC from Python 2.0 under Win32. I have a functional ODBC > connection but when I try to select data that includes date fields mxODBC > chokes. > > Here's what I'm doing. > > >>> import mx.ODBC.Windows > >>> import mx.DateTime > >>> conn = mx.ODBC.Windows.connect('JTech',user='tech',password='tech') > >>> cur = conn.cursor() > >>> cur.execute('SELECT jci_num, test_date, weight, standard_25 FROM > zwick_data') > >>> from pprint import pprint > >>> pprint(cur.description) > (('jci_num', 12, None, None, 30, 0, 0), > ('test_date', 11, None, None, 23, 3, 1), > ('weight', 5, None, None, 5, 0, 1), > ('standard_25', 6, None, None, 15, 0, 1)) > >>> data = cur.fetchall() > Traceback (innermost last): > File "", line 1, in ? > InternalError: ('S1003', 0, '[Microsoft][ODBC Driver Manager] Program > type out of range', 3013) > > I've tried this using three seperate ODBC dsn connections. In every case > I get a "Program type out of range" error whenever I try to select any > data that includes a date field. > > If I connect to the ODBC connection using any other method besides mxODBC > I can fetch the date fields without a problem. > > Am I missing something obvious? Any suggestions? Please check out the latest version (2.0.1). This version includes a work-around for the problems the MS ODBC manager has with the ODBC 3.5 C type codes for date/time values. PS: I'm not reading this newsgroup on a regular basis. If you run into problems, please send the reports to support at egenix.com or mal at lemburg.com Thanks, -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From claird at starbase.neosoft.com Wed Apr 18 16:01:36 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Apr 2001 15:01:36 -0500 Subject: Hygienic macros (was: do...until wisdom needed...) References: <9bjm6v$be8$0@216.39.170.247> Message-ID: <3F46C4A3A2062DA5.5CB9A9C751AF022F.E982CE1742EE4A33@lp.airnews.net> In article , Douglas Alan wrote: . . . >Kind of. Except God is in the details. Tcl is slow and its semantics >are messy. None of this applies to hygienic procedural macros. >Hygiene keeps the semantics clean, the macros run at compile-time -- >not at run-time, and the code that is being treated as data has >structure -- it's not just a string. Also, procedural macros are >designed to be used sparingly, not for everything. > >|>oug While I shan't quibble about several details on which I think reasonable people can disagree, I do think it's important to combat the misconception that idiomatic Tcl is rife with mysterious macro-like things. This is NOT true, although it's widely-enough believed to have inspired a comp.lang.tcl thread just this morning. Yes, there have been times when procedural macros became unjustifiably fashionable in Tcl. We're past that now. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim.one at home.com Mon Apr 16 02:02:55 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 16 Apr 2001 02:02:55 -0400 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! In-Reply-To: Message-ID: [Guido] > We found and fixed a rare but serious bug in the dictionary code, and > fixed enough small nits to warrant a second release candidate for > Python 2.1 -- the final release is still planned for Tuesday, April > 17. [Don Tuttle] > Perhaps I'm dense, but how do you expect any signifgant field > testing to take place in just 4 days, especially when Easter, > Passover, and US taxes are going on at the same time? There won't be massive testing done on the release candidate for (among others) the reasons you gave. But the planned 2.1 release date was announced 6 months ago (on 16-Oct-2000), and has been on public display in PEP 226 since then. 2.1c2 is the sixth(!) 2.1 pre-release we've made, starting in January: if massive testing hasn't occurred over that stretch of time, it never will (like all other things Pythonic, prerelease testing is a volunteer activity, and the mere passage of time doesn't significantly increase the number of test volunteers). With the exception of an excruciatingly subtle and rare pre-existing bug discovered in 2.1c1 and fixed this weekend (significant? yes! there goes your theory ), 2.1 bugs reported for some time now have been shallow and mostly platform-specific, and mostly on minority platforms. In the absence of any reason to believe people who've put off testing since January are going to change their minds now, the point of the quick prerelease is mostly to ensure that no *new* platform-specific glitch snuck in with the last round of minor tweaks. BTW, I expect 2.1 is the best-tested release in Python's history, thanks to the many people who downloaded one of the prereleases and gave it a shot. If you're one of them, thanks! If not, I don't buy that it's because you've been waiting since January to get Easter, Passover and taxes out of the way . although-i-have-i-just-don't-buy-it-for-you-ly y'rs - tim From ed_tsang at yahoo.com Tue Apr 24 13:06:38 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Tue, 24 Apr 2001 17:06:38 -0000 Subject: Anyway to check if a variable exits in other python file without NameError? Message-ID: <9c4bqu+o7fd@eGroups.com> Hi am tryin to find if another variable, called EVENTHANDLEr exits in a file caled pixit.py. pixit.py looks like: EVENTHANDLER = {} print EVENTHANDLER The following is the script I am test trying, but it always print None. wWhat gives? Any suggestion? Or is ther another way? guiCb = CtfGui(None) pixitObj = None EventHandler = None def setPixit(value): global pixitObj global guiCb # setting value of guiCb global EventHandler pixitObj = value guiCb.pixitObj = value # copy value print "where are you?" try: EventHandler = guiCb.pixitObj.EventHandler print EventHandler except: pass exec("import pixit") exec("reload(pixit)") setPixit(pixit) if EventHandler != None: print "Hi" else: print EventHandler From s713221 at student.gu.edu.au Sat Apr 21 20:59:19 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 22 Apr 2001 00:59:19 +0000 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: Message-ID: <3AE22CE7.FC00ED7E@student.gu.edu.au> > BINGO! We have a winner! This thread should probably die. I just got done > hashing out a long thread on the python lists about the evil's and > hypocricy of the FSF socialsts saying their license is free. Which is a > total load or SH*T. It's about as free as china. As another poster said, with freedom comes responsibility. *grins* Since "your side" seems so fond of talking about the "Real World" what would happen to source that was released without the protection of one of the various open source licenses? I agree that the original GPL is definitely at the far end of the spectrum, and may not be appropriate for all cases, but to say that the GPL licence is "evil" and "hypocritical" seems very UN-Real. > > Like Karl Marx, it'd do him and his cult worshippers a world of good > > to go out, get jobs, and work for a living for a while. Might put some > > of his deranged notions in proper perspective. Go reread what he's > > written without the rose-tinted glasses. > > Actually they couldnt do that in their world. The GPL puts programmers out > of a job. You cant make any money on GPL software. Hence the ammount of > linux companies going T*TS up. You simply cannot sustain a viable income > from giving away your R&D code. But that is exactly what stallman and the > FSF want. To destroy IP, and kill the software industry. And looking at > the ammoung of linux companies who have failed, the rest are not far > behind. It clearly shows what the GPL is designed to do. *hmmm* I'm coming from the viewpoint of a student who had to recently pay >$100 dollars (Including student rebate) for a Microsoft program that the University DEMANDED I use because Microsoft (With a quite cunning piece of business acumen, I must admit.) spent years developing a strangle-hold on institutions' imaginations. Now I don't have anything against big business, overall it's pretty good (Thinking chocolate and bottled beer), but when a group of companies starts to squeeze money out of those who can ill afford it, they really should feel ashamed about squealing when somebody gets sick of it and organizes a freer and cheaper alternative, now shouldn't they? Seems to me that most software companies got TOO good at making money. The way I see it, there should be a natural balance between the best interests of business, and the best interests of the customer, which is what the Open Source community seems to be drifting towards. *paraphrasing like crazy* "In the beginning there was only One Software. But immediately this One became Two, Commercial and Open Source, which soon became Four: GPL, LGPL, Proprietary and ShareWare. These four elements formed and split and reformed again. And out of this chaos formed a Stone Egg. Warmed by GPL, cooled by Proprietary, nourished by LGPL and ShareWare, from this egg hatched a stone Monkey, and it's nature was ... IRRREPRESSIBLE." > > What has he done for us (instead of to us) *lately*? Nothing. He's a > > waste of meat. > > Compare, for instance, to Linus or Guido. They write code. Any fame > > they get is justified, because they've written *GOOD* code. Eric S. > > Raymond is a borderline case; he does write code, sometimes very useful > > code (and sometimes stuff like C-Intercal...). But he's also a > > shameless exhibitionist, and needs about a 99% fame reduction. > > Linus hasnt written probably 10% of the Linux OS. Ill bet 90% of it work > of others. So Linus hasnt dont a whole heck of a lot for anyone either. How much of the python interpreter have you written? How often do you use it? Would it exist if Guido hadn't had an idea to create a better, more explicit language. If he and the other workhorses behind the interpreter want to GPL it *shrugs*. It's not as if they're demanding you GPL your scripts, now is it? Using an analogy, my mother and father originally only contributed twenty minutes of sweating and grunting to start me off, but it'd be damned hard for me to be here without them. > > Until someone infects some non-GPL code with the GPL. Then it's been > > stolen. > > Thats one of the main points of the GPL. Destroy IP, and ownership. Among > other things. > > > >long as you have not used FSF software and violated its license -- in > > Sure yet again this is not freedom. "Play by our rules or go reinvent the > wheel and play in another sandbox." There is no freedom in the GPL. GET > OVER IT. "We wanna use your cool free GPL source in our commercial software, but if you want it back, we wanna make you pay for it." > What makes me laugh is guido and the rest of whatever committee there is > for Python trying to negotiate to get the Python license GPL compatible. > WHO THE HE** CARES IF IT IS GPL COMPATIBLE! I could care less about > bending to the will of some socialist nut case group like the FSF. People > act like it's a big friggin deal to be "GPL compatible". I hope it never > happens with Python. I would tell RMS and the rest of the FSF crowd to get > bent. We dont care about being inline with you're stupid corrupt agenda. Well I kind of like the idea that, as Python has been community written, nobody can take that code away from the community behind some closed source license. Maybe a GPL isn't required, but I'd still like to see a LGPL applied to python. Anycase, my 50c worth. Hey, inflation, don'tchaknow. If it makes you feel better, just think of it as each paragraph as an "upgrade". Joal Heagney/AncientHart From wolfer at pacbell.net Wed Apr 11 15:48:40 2001 From: wolfer at pacbell.net (Randy Wolfe) Date: Wed, 11 Apr 2001 12:48:40 -0700 Subject: wxPython on Win98 - install help needed Message-ID: Trying to get wxPython 2.2 going on my Win98 box.. I have successfully installed Python 2.1 (it works). I've downloaded and installed wxWindows 2.2.6. I've downloaded wxPython 2.2. I've downloaded and installed Borland's C++ 5.5 to compile wxW per the instructions for BCC5.5 found at ftp://www.remstar.com/pub/wxwin/2.2.6/install_msw.txt - I've tried both the DEBUG and RELEASE modes - I've checked the source code of the provided wxW apps and they include the appropriate preprocessor directive. My start menu allows me to run the wxW dialog editor and the Life game (although these are wxW *.exe apps). I have set the environment variables BCCDIR=c:\Borland\bcc55 and WXWIN=c:\wx2 I have moved wxPython to c:\Python21\wxPython to hopefully satisfy path issues Problem is this: wxPython demo.py will not run from c:\python21\wxpython\demo (can't find wxPython.wx, can't import wxc). Is there a specific tree or path structure required for Python, wxPython, and wxWindows? The compiler instructions for the bcc55 are: c:\wx2\src\msw> make -f makefile.b32 Any help will be greatly appreciated - Thanks Randy Wolfe wolfer at pacbell.net From aleaxit at yahoo.com Fri Apr 6 12:26:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Apr 2001 18:26:43 +0200 Subject: SAFEARRAY(ISpecific*)* type in COM Automation from Python References: Message-ID: <040f01c0beb6$5e65a960$102b2bc1@cadlab.it> "Putland, Karl" writes...: > > I have to call a method on an Automation object that needs > > a parameter of type SAFEARRAY(IFoo*), where IFoo is a (dual) > > interface defined in that same type library. I can make [snip] > Bellow is a snipped dredged up from a Python > COM server I wrote a while back. I think > you will find this helpful. First create > a collection, then wrap the collection. But I shouldn't be passing a Collection -- rather, a SAFEARRAY(IFoo*). How would a Collection object help...? Let me try to cut this down to a toy-sized example. Say I have a server that implements the following relevant part of an IDL file, with the 'obvious' toy implementation: [ object, uuid(8078B16D-2AA6-11D5-9E61-0060B0EB1D67), dual, helpstring("IFoo Interface"), pointer_default(unique) ] interface IFoo : IDispatch { [propget, id(1), helpstring("property TheString")] HRESULT TheString([out, retval] BSTR *pVal); [propput, id(1), helpstring("property TheString")] HRESULT TheString([in] BSTR newVal); }; [ object, uuid(8078B16F-2AA6-11D5-9E61-0060B0EB1D67), dual, helpstring("IFooMaker Interface"), pointer_default(unique) ] interface IFooMaker : IDispatch { [id(1), helpstring("method MakeFoo")] HRESULT MakeFoo([in]BSTR TheString, [out, retval]IFoo* *pVal); }; [ object, uuid(8078B173-2AA6-11D5-9E61-0060B0EB1D67), dual, helpstring("IDigester Interface"), pointer_default(unique) ] interface IDigester : IDispatch { [propget, id(1), helpstring("property Catenation")] HRESULT Catenation([out, retval] BSTR *pVal); [id(2), helpstring("method CatGeneric")] HRESULT CatGeneric([in]SAFEARRAY(VARIANT) *array, [out, retval] LONG* processed); [id(3), helpstring("method CatSpecific")] HRESULT CatSpecific([in]SAFEARRAY(IFoo*) *array, [out, retval] LONG* processed); }; Methods CatGeneric and CatSpecific of the Digester object are identical, in fact their C++ implementations are: STDMETHODIMP CDigester::CatGeneric(SAFEARRAY **array, LONG *processed) { return aux(array, processed, this->Catenation); } STDMETHODIMP CDigester::CatSpecific(SAFEARRAY **array, LONG *processed) { return aux(array, processed, this->Catenation); } for some appropriate auxiliary function aux that goes through the array, etc, etc. Now, in Python...: D:\>python Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> from win32com.client.gencache import EnsureDispatch as disp >>> foomaker = disp('comtoy.FooMaker') >>> dir(foomaker.__class__) ['CLSID', 'MakeFoo', '__doc__', '__module__', '_prop_map_get_', '_prop_map_put_' ] >>> a=foomaker.MakeFoo("uno") >>> b=foomaker.MakeFoo("due") >>> c=foomaker.MakeFoo("tre") >>> foolist=[a,b,c] >>> digester = disp('comtoy.Digester') >>> dir(digester.__class__) ['CLSID', 'CatGeneric', 'CatSpecific', '__doc__', '__module__', '_prop_map_get_' , '_prop_map_put_'] >>> digester.CatGeneric(foolist) 3 >>> digester.CatSpecific(foolist) Traceback (most recent call last): File "", line 1, in ? File "d:\python20\win32com\gen_py\8078B161-2AA6-11D5-9E61-0060B0EB1D67x0x1x0\I Digester.py", line 34, in CatSpecific return self._oleobj_.InvokeTypes(0x3, LCID, 1, (3, 0), ((24585, 1),),array) pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1) >>> i.e.: method CatGeneric is fine and peach; method CatSpecific, I seem to be just unable to call -- there's a Type mismatch com_error somewhere in the infrastructure. How CAN I somehow massage the foolist in order to pass it to the CatSpecific method...? Because, in the actual server I must drive, there IS no 'CatGeneric' equivalent...:-( Alex From tjg at exceptionalminds.com Mon Apr 9 15:21:41 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 9 Apr 2001 12:21:41 -0700 Subject: Initializing Pmw In-Reply-To: <3AD2066C.4CB4D14C@uniserve.com>; from bvdpoel@uniserve.com on Mon, Apr 09, 2001 at 11:58:52AM -0700 References: <3AD2066C.4CB4D14C@uniserve.com> Message-ID: <20010409122141.D16656@trufflehunter.avalongroup.net> On Mon, Apr 09, 2001 at 11:58:52AM -0700, Bob van der Poel wrote: > However, I can't seem to get other Pmw programs to work. I get an error > message > > ImportError: No module named Pmw Move it up one directory, or setup a Pmw.pth file in site-packages. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 12 days 21:29 hours ago<< From kzaragoza at mediaone.net Mon Apr 30 15:34:49 2001 From: kzaragoza at mediaone.net (Kris J. Zaragoza) Date: Mon, 30 Apr 2001 19:34:49 GMT Subject: Hygienic macros (was: do...until wisdom needed...) References: <9bkfmm$es3$0@216.39.170.247> Message-ID: On 18 Apr 2001 15:59:42 -0400, Douglas Alan wrote: >I don't need a reference because I'm one of those (ex-) Lispers. I >love Lisp and I hate Tcl with a passion. Python is much, much closer >to Lisp than Tcl is. If you were to change the syntax of Python to be >Lisp-like, you might even count it as a dialect of Lisp. There's no >amount of syntactic sugar that could do that to Tcl. > >|>oug Agreed. After extolling the virtues of Python to a a friend of mine, he finally tried it. His response: "Now I know why you like Python so much. It's Lisp without the parentheses!" -Kris -- Kris J. Zaragoza | "Unfortunately, most people can't out-think a kzaragoza at mediaone.net | grapefruit." --Jon Bodner From paulp at ActiveState.com Thu Apr 5 20:44:44 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 05 Apr 2001 17:44:44 -0700 Subject: Classes, OOP, Tkinter general comments and detailed questions... References: <3ACBADAC.C7843F96@earthlink.net> Message-ID: <3ACD117C.CDEF6286@ActiveState.com> Ron Stephens wrote: > > I love Python. But I am having trouble getting to understand classes > well enough to use them. This is especially a problem because I want to > use Tkinter. I programmed a little in assembler, Basic, PL/1, and > Fortran in college (math and physics majors). Procedural programming > seems logical to me. Programs must follow the logic, and programs thus > can do only one thing. I am appealing for help from the group, seeking > ideas to help me find a way to understand the use of Python classes. I'm not sure if your problem is *really* with OO programming. Have you ever created a GUI in a non-OO language? The basic difference between ordinary programming and GUI programming is that in GUIs, things happen when the use decides they happen and your program has to be organized so it is ready for whatever happens. In a procedural program you lay out the order of things from the start. Even if you program a GUI in (let's say) C or FORTRAN, you need to get used to event-driven programming. That's different from OO. You can follow the logic in an OO program from top to bottom just as you do a procedural program. You just need to remember that when you call foo.bar, the actual "bar" you call will depend on the "foo" you are dealing with. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From bauhahnm at clara.net Wed Apr 25 17:00:23 2001 From: bauhahnm at clara.net (Maurice Bauhahn) Date: Wed, 25 Apr 2001 22:00:23 +0100 Subject: Jython: Upper-ASCII characters '\351' from chr(233) References: <3AE08EC7.C03FEA39@clara.net> <3AE09FED.14ECF107@clara.net> Message-ID: <3AE73AE6.E2D08917@clara.net> Thank you, Steve. Maybe it would help if I could explain what I am doing. I'm trying to write a programme to transcode eight-bit encodings to Unicode encodings (the Cambodian/Khmer language) and then do letter-pair frequency studies. Since I will be comparing characters (not integers) to compare against the key, I need to have characters as the key. That effort has in fact now been successfull. My next problem, discussed elsewhere in comp.lang.python, is to import Unicode escaped characters/strings from another 8-bit encoded file into a Jython dictionary. (Presumably the solution is in the codecs module). Steve Holden wrote: > "Maurice Bauhahn" wrote in message > news:mailman.988158281.19384.python-list at python.org... > > Thank you very much for your persistent help. > > > > I was able to get the 8th bit characters to act as keys...with a somewhat > > complex construction: chr(int(linesplit[0])). Linesplit had decimal > > numbers in text format. > > > Would this shed any light on your original question or help in solving your > problem more compactly? Note that this is CPython, not Jython, but > portability should make all this work in both implementations. From what > I've read, it seems to be your need to see decimal numbers in the source > whcih led you to these contortions. > This solved the problem I first encountered (which was probably an artifact of something on the same line!). > > Your original assertion that > > """ > >>> chr(127) > '?' (in fact a character like a house) > """ > > is quite correct, but I don't see why a weird printable representation makes > a character unsuitable for use as a dictionary key. Maybe I missed your > point. Anyway ... > I do not worry about the shape of the characters (why those of Khmer are much more novel in any case;-)). > > >>> # Construct a string of all chars from 0 to 255 > >>> chars = "".join(map(chr, [i for i in range(256)])) > >>> # Use decimal value to access single characters > >>> # and use them as dictionary keys > >>> dict = {} > >>> dict[chars[233]] = "Two hundred thirty-three" > >>> dict[chars[27]] = "escape" > >>> dict["\033"] > 'escape' > >>> dict["\351"] > 'Two hundred thirty-three' > >>> dict > {'\033': 'escape', '\351': 'Two hundred thirty-three'} > >>> > > In other words, having constructed the chars[] list, you can index it with > decimal numbers to get the characters you want. chars could equally have > been a list of single-character strings, with the same effect. Yes, it is the list of single-character strings that I am using (now successfully). > > > If this doesn't help you at all, please feel free to ignore my rantings. > Thank you for the questions and desire to help! > > regards > Steve > > > linesplit = split('\t',encodingline) > > if (len(linesplit) > 5): > > try: > > templist = linesplit[2:4] > > templist.append(split(';|:',linesplit[4])) > > templist.append(strip(linesplit[5])) > > encodedict[chr(int(linesplit[0]))] = templist > > print templist > > except ValueError: > > logerror('My error', linesplit[0]) > > else: > > logerror('Not >5 fields long', linesplit) > > -- Maurice Bauhahn 2 Meadow Way Dorney Reach MAIDENHEAD SL6 0DS United Kingdom Home Tel: +44(0)1628 626068 Work Tel: +44(0)1932 878404 Home Email: bauhahnm at clara.net Work Email: mbauhahn at brio.com From ^NOSPAM^ifi at ifi.it Wed Apr 11 04:58:53 2001 From: ^NOSPAM^ifi at ifi.it (accattatevillo) Date: Wed, 11 Apr 2001 10:58:53 +0200 Subject: Guide me References: <2vo0b9.8k.ln@dsfintranet.dsf> Message-ID: <3AD41CCD.A33927D1@ifi.it> atul wrote: > > hi > I am a java programmer and i want to know that how python can be usefulll to > me. > www.jython.org HTH Stefano From dan at www.cgsoftware.com Mon Apr 2 02:39:08 2001 From: dan at www.cgsoftware.com (Daniel Berlin) Date: Mon, 2 Apr 2001 02:39:08 -0400 (EDT) Subject: POLLY: An IDE for Parrot In-Reply-To: Message-ID: On Mon, 2 Apr 2001, Warren Postma wrote: > Polly 1.0 > --------- > > What Is It? > ----------- > > A nice Integrated Development Environment (IDE) for the Parrot language > invented by GvR and the Wall-meister, with contributions from the open > source community. > > Online Help Feature > -------------------- > > When you hit F1, it will print out a random insult, and suggest that you > read a randomly generated ANSI, > ISO, or MIL-STD spec serial number, Ooh ooh. can it point you to sections that don't exist, saying something like "Section 37.2.1 of the ANSI standard [serial number 59129120918201212] *obviously* explains why this is", when the standard only goes up to section 12? > and impolitely suggest that you go away, > or it will pop up a prefabricated answer from the code-snippet library of > one of the friendly neighborhood usenet-Bots, translating from Python > internal syntax to Parrot syntax for display, and inserting one hard to find > scope error along the way, courtesy of mangled indentations, similar to the > functionality built into Outlook Express. Warning, these mangling rules may not work on IMAP or HTTP servers. > This feature alone should really > lower the congestion on comp.lang.perl and comp.lang.python substantially. Except for the posting of the user tracking serial numbers, right? > > GUI Builder > ------------ > > The GUI uses a combination of Tk, wxWindows, and the raw XLib and Win32 GDI > APIs. Yummy. > The GUI Frames manager has a built in "themes" mode that can simulate > (a) incredibly ugly Tk widgets, (b) Win32 text widget that flicker, and > Win32 32x32 16 color Icons that just plain refuse to appear, or (c) > WxWindows widgets that consume 10Kb of additional memory per window event or > mouse click, for each item on the screen. I think I've seen "c" , but it was productized under the name "Microsoft Outlook". You also forget the native mode, which displays gtk windows that randomly print assertions and useles warnings to the console, and look really nice , with antialiased fonts and all, but only if the font is 37k in filesize, not mono-space, or you haven't bolded the second word. Otherwise, it looks like someone ran across the screen dropping the antialiased letters at random places. It also crashes in weird and exciting ways, never reproducable the same way twice, but often enough to make you scared to do things in it. IE, it adapts the user to it, rather than adapting to the user. > > > Any interest? I'm in. From nessus at mit.edu Wed Apr 18 17:23:28 2001 From: nessus at mit.edu (Douglas Alan) Date: 18 Apr 2001 17:23:28 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9bjtbr02108@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > "Douglas Alan" wrote in message > > > Does this mean with 40+ years of development, Lisp does not have > > > features of some modern language, in that it isn't widely > > > used, not tuned, etc.? > > No one ever did a version of Lisp that was highly tuned for scripting. > http://www.gnu.org/software/guile/guile.html doesn't count...? > [It's Scheme, but we've already established that you do consider > that a version of LISP]. Beats me. I looked at it a few years ago and it was incomplete and way too slow to start up, just like the Scheme Shell. Perhaps it has improved since then, but I doubt it has caught up to Python, since Python is a quickly moving target, due in no small part to its huge library base. If someone is willing to convince me otherwise, however, I might switch. I'm always open to using the best tool that is available, rather than being dogmatic about one particular tool. > > set x = 3 > > gets tranlated into > > try: > > x > > x = 3 > > except NameError: > > How wonderful. And > set x = y + z > will no doubt get translated into Something Totally Different > to avoid erroneously raising a VariableNotBound for 'x' when > the problem is actually that y and/or z give NameError's or > such an error bubbles up from y's __add__ or ... You know, Mr. Martelli, I'm not 'tupid. It was an *illustrative* example, not a reference manual. For the purposes of illustration, the code I presented was fine. I know perfectly well how to write robust macros, having written many of them in days gone by. And you know what? They worked and were bug-free. > Us humble mortals would of course use a try/except/else instead, > totally nullyfying this problem (indeed, that IS just the kind > of thing the else clause on the try statement is there for), but > I guess this minute attention to such trifling details as doing > things right is exactly what makes us unworthy of grokking the > Tao of Python Macros (I mean, just imagine taking the trouble to > learn a language thoroughly and using it accurately before one > starts to advocate changing and complexifying it -- how TACKY!). All you're convincing me of is that you are an asshole who is more concerned with trying to humilliate other people than trying to have any sort of intelligent conversation. Never mind that I have spoken in public, giving free Python tutorials and that I have relentlessly evangelized Python as far and wide as I have been able to. I've put my time and effort where my mouth is. Because I have a somewhat different slant on things than you do, you would try to make me feel that I'm not part of the Python community. In doing so, you do nothing more than alienate someone who is *very* passionate about programming languages, programming language design, and Python in particular. Why don't you tell your theory that anyone who thinks an extensible syntax might be a useful feature doesn't understand the "wellenbrofferpoftenbuft" of Python to Guido, since I saw him muse in this very newsgroup several years ago on how an extensible syntax might be a nice feature . I take it from what you say that Guido doesn't understand the "wellnenstoflebuft" of Python either. You are not a good force for the Python community, Mr. Martelli. You are an antagonistic fool. Your hypothetical army of monkeys sitting at typewriters would better serve the community. |>oug From rdsteph at earthlink.net Fri Apr 13 20:19:00 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 14 Apr 2001 00:19:00 GMT Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <9b7iaq0dep@news2.newsguy.com> <9b814u$39p$1@slb4.atl.mindspring.net> Message-ID: <3AD648BA.60A7E557@earthlink.net> What is "MIX"???? Andrew Dalke wrote: > Alex-bot: > > the answer is: "because, in a well-designed language, there > >is no situation in which ``nothing else will do as well''":-). > > I've just been rereading some of Knuth's "The Art of Computer > Programming." I don't do it very often because I get a > headache trying to understand his use of gotos, which aren't > simply nested (directly convertable to structured loops) > and which aren't error-handling-like (convertable to exceptions). > > So Python is not a well-designed language for direct > translation of MIX code because it doesn't have gotos. > > No need to followup - just wanted to complain about MIX (again :) > > Andrew > dalke at acm.org From johngrayson at home.com Fri Apr 13 19:15:12 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Fri, 13 Apr 2001 23:15:12 -0000 Subject: Fwd: Re: Tkinter App Wanted Message-ID: <9b81a1+qdkl@eGroups.com> --- In python-list at y..., "Steve Holden" wrote: > Now, hang on [... ferkles about in John Grayson's Python stuff...] > ah yes, menu.py from chapter 4. Hope he won't mind, it's freealy > available from his web site (I think). > > If you haven't read John Grayson's "Python and Tkinter Programming" > it's well worth a read. Source code at the foot of the message. > > regards > Steve Thanks for the plug! Now, don't anybody tell my publisher! http://www.manning.com/Grayson/Source.html 2 example chapters: http://www.manning.com/Grayson/Chapters.html John Grayson From robin at stop.spam.alldunn.com Fri Apr 6 17:02:46 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Fri, 6 Apr 2001 14:02:46 -0700 Subject: Python Books for 2002 References: Message-ID: <2aqz6.726$0zl.40108117@news.randori.com> "Neil Hodgson" wrote in message news:gz6z6.6427$Xi1.49792 at news-server.bigpond.net.au... > Remco Gerlich: > > Kemp Randy-W18971 wrote in comp.lang.python: > > > So why not a Python for Dummies or a Perl for Idiots book? > > > > Python users aren't dummies... > > But we *are*. I am far too dumb to understand my Perl programs. > I've always considered it the other way around. I'm too smart to use or even to take the time to understand Perl, and would only use it if I were really dumb. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From phd at phd.fep.ru Thu Apr 19 08:20:32 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 19 Apr 2001 16:20:32 +0400 (MSD) Subject: Python interface to DNS resolver? In-Reply-To: <3ADED4BB.B140802A@stroeder.com> Message-ID: On Thu, 19 Apr 2001, Michael [iso-8859-1] Str?der wrote: > > http://alumni.dgs.monash.edu.au/~anthony/python/ > > Is it me or does this URL not work anymore? The README quoted dated 1998 :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Thu Apr 26 11:54:55 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Apr 2001 17:54:55 +0200 Subject: how to explain this memory usage References: Message-ID: <9c9gcg02coi@news2.newsguy.com> "Remco Gerlich" wrote in message news:slrn9egcc7.3cs.scarblac at pino.selwerd.nl... [snip] > Python can free the memory, but that doesn't mean it's available for another > program then. On some operating systems (Windows) it simply means that this > program can re-use the memory. So programs don't grow smaller, only bigger. > > Not a Python issue, anyway. Simply the way the OS does it. In Windows NT, at least, it's perfectly possible for a program to give whole pages back to the operating system so that other programs can reuse the memory (basically the space on the paging file -- *physical* memory is of course reused all the time, and *address space* is quite separate between processes anyway). The _C runtime library_ may or may not take advantage of this, but MSVCRT.DLL does for large allocations. To confirm, make this C++ source into an EXE: #include #include void step() { printf("Press Enter to continue: "); char buf[80]; gets(buf); } int main(int argc, char* argv[]) { printf("Before allocating\n"); step(); void* pc = malloc(1000*1000); printf("After allocating a MB\n"); step(); free(pc); printf("After freeing it\n"); step(); return 0; } Now run it, examining process resources (e.g. with the NT Task Manager) at each step. You'll see memory consumption as seen from the OS jumping up, then jumping down again. Small allocations _can_ at times be blocked into large ones for this purpose, too -- but not always (if even a tiny bit remains allocated inside one 8192-byte page, the whole page will not be given back... only if ALL the bits are 'freed' can the whole page be a candidate for "giving it back to the OS" -- else, THAT page can only be "reused" within that single process). Alex From roy at panix.com Sun Apr 1 21:20:48 2001 From: roy at panix.com (Roy Smith) Date: Sun, 01 Apr 2001 21:20:48 -0400 Subject: Parrot... is Python dead now? References: Message-ID: "Tim Peters" wrote: > while left_angle_right_angle: > > was a significant step backwards from both Perl's > > while (<>) { > > and Python's > > for line in sys.stdin.xreadlines(): Except, that I had always thought the names of the < and > characters were "bra" and "ket", which would naturally lead to while braket: no? From matt at mondoinfo.com Fri Apr 20 19:30:11 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 20 Apr 2001 23:30:11 GMT Subject: Problem with smtplib: message vanishes References: <3AE0C320.B7D92F7C@aon.at> Message-ID: On Sat, 21 Apr 2001 01:15:44 +0200, Gregor Lingl wrote: >I've got the following problem: > >Using smtplib as discribed in the documentation and also in Lutz' >Programming Python to send emails, I'm able to send mails without >error messages. [. . .] >... which means: the message-text is missing completely. >When looking at the 'source-code' of the message, I find: >Message-ID: >Return-Path: [. . .] >Subject: python-mehl2 >Vielleicht geht's so! >probieren wirs's aus >Gr??e >Gregor >X-Mozilla-Status: 0000 >X-Mozilla-Status2: 00000000 >X-UIDL: 987804705.4637304.SSP1NO49,S=520 Gregor, You need a blank line after your headers. It looks like your script creates at least some of the headers in the message (the subject line for example). RFC822 specifies a blank line between the end of a message's headers and the beginning of the body. Since it seems that your script doesn't add the blank line, Netscape adds its own headers at the bottom. Regards, Matt From bauhahnm at clara.net Sun Apr 29 03:39:07 2001 From: bauhahnm at clara.net (Maurice Bauhahn) Date: Sun, 29 Apr 2001 08:39:07 +0100 Subject: Jython: How to import escaped Unicode and export utf-8? References: <3AE61B65.3E150107@clara.net> <3AEBACBD.935949AC@clara.net> Message-ID: <3AEBC51B.EE58F45@clara.net> I took the second issue to heart and tried to accommodate this by importing from a text file u'\u17\u80'. The following is what resulted. H:\jy>jython Jython 2.1a1 on java1.2.2 (JIT: symcjit) Type "copyright", "credits" or "license" for more information. >>> execfile('h:\\jy\\teste.py') Traceback (innermost last): File "", line 1, in ? UnicodeError: unicode escape decoding error: truncated \uXXXX Hence, it appears that not only is it not possible to import \uXXXX, it is also appears impossible to handle any Unicode escape above the first 256 characters...effectively ignoring Unicode altogether??? Is there something I am missing? Cheers, Maurice Maurice Bauhahn wrote: > It appears that the problem is that programmers have killed a substantial part > of the Unicode side of Jython. The README.txt file which accompanies Jython > 2.1.a1 > > - Text files will pass data read and written through the default > codecs for the JVM. Binary files will write only the lower eight > bits of each unicode character. > > - The \x escape have changed, now it will eat two hex characters > but never more. The behaviour matches CPython2.0 > > Presumeably the first item is only referring to the default 'ASCII'...which > can be changed. The second is, however, disasterous, if I understand it > propeprly. > > Cheers, > > Maurice > > Martin von Loewis wrote: > > > Maurice Bauhahn writes: > > > > > My imports of escaped Unicode (u'\u1780' or '\u1780') end up in my lists > > > as: > > > > > > ["u'\\u1780'"] > > > > I very much doubt this. This looks more like the repr of a list, > > instead of like the list itself. That could be an incompatibility of > > repr for Unicode objects in Python, but I assume that the list is > > still build correctly. > > > > > and .write as u'\u1780'. > > > > In CPython, that would give an exception. You cannot write a Unicode > > object onto a stream without encoding it first. > > > > > From the command line I can get something useful by writing: > > > > > > u'\u1780'.encode('utf-8') > > > > > > but it does not appear to work within my jython script. > > > > That should work. How does it fail? > > > > Regards, > > Martin > > -- From chris at voodooland.net Thu Apr 12 08:30:45 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 12 Apr 2001 07:30:45 -0500 (CDT) Subject: Komodo in violation of Mozilla Public License? In-Reply-To: Message-ID: <20010412072218.F3140-100000@open-systems.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > The reason I suggested the GPL is that it might fit ActiveState's > purposes because another company couldn't put ActiveState's code > in a proprietary, competing product, and not share their changes > with ActiveState. Personally, again I fail to see the point of releasing open source if you dont want *everyone* to benefit. Otherwise just dont do it. > >> I personally have no problems with Komodo being released on a > >> non- Open Source license. > > > >Me either. It's there work. Glad you think they they have the right to use > >their work as they see fit. :-) > > Even if they want to GPL it? Even if they GPL it. It is *their* code. They can do whatever they want with it. And license it how they see fit. But cutting off youre nose to spite your face and using the GPL is not how I obviously like to see code open sourced. But of course it is their choice. ============================================================================= - -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: Made with pgp4pine 1.75-6 iD8DBQE61Z/6oTcdKVapx58RAtr2AJ0e0dp87ecF+e7RiAu9g3duHrlMAQCfeEbt ldnzV45rxSt0aOchtJGAuUY= =cGnB -----END PGP SIGNATURE----- From aleaxit at yahoo.com Sat Apr 7 18:28:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Apr 2001 00:28:46 +0200 Subject: COM lifetimes References: <3acf7e10$0$837$6e49188b@news.goldengate.net> Message-ID: <9ao4820jpu@news2.newsguy.com> "Volucris" wrote in message news:3acf7e10$0$837$6e49188b at news.goldengate.net... > When I do the following, Word doesn't close. > >>> from win32com.client import Dispatch > >>> w = Dispatch("Word.Application") > >>> w.visible = 1 > >>> w = None > I though python was to handle this. How do I close a COM object? I'm using > PythonWin 2.0. Any ideas? Word chooses not to terminate automatically if it is Visible; your script can still choose to terminate it explicitly by calling w.Quit(). Alex From vincent_a_primavera at netzero.net Thu Apr 12 08:26:47 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Thu, 12 Apr 2001 12:26:47 +0000 Subject: #define (was Re: python-list@python.org) In-Reply-To: <9b4gck0cdd@news1.newsguy.com> References: <01041208054801.01378@tos1.ralphpill.com> <9b4gck0cdd@news1.newsguy.com> Message-ID: <01041212264703.01378@tos1.ralphpill.com> Hello, Thank you for the help. It's nice to see someone willing to share knowledge instead of sarcasm. Vincent A. Primavera. On Thursday 12 April 2001 15:07, Alex Martelli wrote: > "Vincent A. Primavera" wrote in message > news:mailman.987079936.13897.python-list at python.org... > > > Hello, > > What I am trying to accomplish is to shorten statements such as > > stdscr.addstr(10, 10, 'This is a test...', curses.color_pair(1))... ;o} > > nothing too complicated. > > You don't need a #define (i.e., macros) for this; just wrap this > statement into a function, with whatever arguments and defaults > you desire. > > Suppose, for example, that (were this C) you would code: > > #define SAY(text,y) stdscr_addstr(10, y, text, curses_color_pair(1)) > > The Pythonic equivalent would then be: > > def SAY(text, y): > stdscr.addstr(10, y, text, curses.color_pair(1)) > > and of course, you can have default-valued arguments: > > def SAY(text, y, color=None): > if color is None: color = curses.color_pair(1) > stdscr.addstr(10, y, text, color) > > > Nothing too complicated -- just nice, powerful, simple. > I.e., Python. > > > Alex From bsb at winnegan.de Mon Apr 2 16:14:56 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 02 Apr 2001 22:14:56 +0200 Subject: pwd module vs Linux shadow passwords In-Reply-To: <020420011250371650%jwbaxter@olympus.net> References: <020420011250371650%jwbaxter@olympus.net> Message-ID: <87ae5zhxdr.fsf@winnegan.de> "John W. Baxter" writes: > Using Python 1.5.2 (and earlier) on BSDi, the pwd module's getpw... > functions are able to retrieve the encrypted password (from > /etc/master.passwd) if run as root. > > Using Python 1.5.2 and 2.1b1 on Linux (RH 6.2), the functions do not > similarly dig the encrypted password out of /etc/shadow. > > Is the latter action intentional, or is something not being set up It's the main point of shadow passwords, cf. http://www.linuxworld.com/linuxworld/lw-2000-07/lw-07-shadowpasswords.html Thanks Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From news at dorb.com Sun Apr 15 19:21:08 2001 From: news at dorb.com (Darrell) Date: Sun, 15 Apr 2001 23:21:08 GMT Subject: string.join is abysmally slow References: Message-ID: ### The name list is a built-in, avoid using such names joinList = [] for line in buf.split("\012"): # Comment or blank line? if line == '' or line[0] in '#': continue else: joinList.append(string.strip(line)) ##### Move the following out of the loop # "address1|address2|address3|addressN" regex = string.join(joinList,'|') regex = '"' + regex + '"' #<-- Are you matching the quotes ? reo = re.compile(regex, re.I) ################ Another approach import re, string buf=""" # xxxx re1 re2 # """ sep=")|(" buf = re.sub("\012+",sep, re.sub("#.*", "",buf) ) breakOff = len(sep)-1 print buf[breakOff:-breakOff] """output --> (re1)|(re2)""" --Darrell "Graham Guttocks" wrote: > > I've run into a performance problem in one of my functions, and wonder > if I could get some recommendations on how to speed things up. > From m.1.robinson at herts.ac.uk Thu Apr 26 07:49:19 2001 From: m.1.robinson at herts.ac.uk (Mark blobby Robinson) Date: Thu, 26 Apr 2001 12:49:19 +0100 Subject: iterating through humongously large key lists!! References: Message-ID: <3AE80B3F.8514A5E1@herts.ac.uk> I was originally running v1.5.2 so I have installed v2.1 this morning, ...deep breath...lets just say it wasn't a smooth installation. I am a linux newbie and I was a hairs breadth from switching right back to windows NT (must miss those blue screens I guess ;). Anyhow, thats all working now, funnily enough, the code that returned the keyerror previously is now working fine it seems, so I guess that was just a 'feature' of older versions. Thanks for your help guys, pure genius!! From qrczak at knm.org.pl Sat Apr 21 17:02:07 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Apr 2001 21:02:07 GMT Subject: How best to write this if-else? References: Message-ID: Sat, 21 Apr 2001 16:02:46 -0400, Roy Smith pisze: [...] > Is there really no more straight-forward way to do what I want? regexps = map(re.compile, ['...', '...', '...']) # Or in Python >= 2.0: # regexps = [re.compile(r) for r in ['...', '...', '...']] for r in regexps: m = r.match(line) if m: text = m.group(1) break else: # None matched. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From stephen_purcell at yahoo.com Tue Apr 24 12:21:27 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 24 Apr 2001 18:21:27 +0200 Subject: Easy way to find set of quotes In-Reply-To: <3AE5A1BC.9E2472C6@nmt.edu>; from shippy@nmt.edu on Tue, Apr 24, 2001 at 09:54:36AM -0600 References: <3AE5A1BC.9E2472C6@nmt.edu> Message-ID: <20010424182127.A17819@freedom.puma-ag.com> Jeff Shipman wrote: > I'm reading a file that has a kind of mark-up > language, and I'm supposed to convert it all > to HTML. No problem, really, it's no that > hard of a mark-up language, but there are a > couple things for which I'm sure python has > some tricks that would make life easier which > I don't know about. Sounds like a Wiki. Are we doing your homework? > My question is: is there an easy way to find all > of these different patters and surround the proper > text? Note that things inside quotes are not > touched. So, if I had ""my '''text'''"", that > would output

my '''text'''
. > I know that python must have something handy for > this besides going through character-by-character > and keeping track of my current location. > Unfortunately, I'm not allowed to use regular expressions. Doh! This *is* your homework! Does this newsgroup query count as effective use of resources, or as unfair assistance? :-) I'll restrain myself to the following hint: Look at the string module, specifically string.find(). Good luck! -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From dbrueck at edgix.com Wed Apr 11 11:31:51 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Wed, 11 Apr 2001 09:31:51 -0600 Subject: What is a .pyd file References: <34E36CB1EDA21DD1.1102B4E7FC31643E.F5EC0C27FD685BB3@lp.airnews.net> Message-ID: <0b2901c0c29c$9414c610$450514ac@PRODUT2KDAVE> > I understand .py, .pyw, .pyc and .dll files. However, I see .pyd files in > the ActiveState Python 2.0.203 tree, e.g., multiarray.pyd in the Numeric > directory; also much of the win32 extensions. multiarray.pyd looks like a > Windows DLL and dumpbin seems to agree. Is it built as a DLL and then > renamed? If so, why? Hi David, You and dumpbin are right, it is a Windows DLL. The extension is just a convenient way of marking the file as a Python extension module. This is particularly useful if your extension module wraps an already-existing third-party C library. For example, if you saw in your directory: opengl.dll opengl.pyd then it'd be a reasonable bet that the first is the C library and the second is a Python extension module that uses it. -Dave From James_Althoff at i2.com Mon Apr 9 17:30:58 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 9 Apr 2001 14:30:58 -0700 Subject: writing to locals Message-ID: Got it. (Your suggestion has the added benefit that the localsDict has _only_ the c1, c2, ... variables defined and not the other vars in the method!) Thanks, Fredrik! James_Althoff at i2.com wrote: > ... my class ... > > def setFormula(self,formulaString): > self.formula = formulaString > > def getCalculatedValueAt(self,rowIndex): > count = self.getColumnCount() # excludes the calculated column > localsDict = locals() > for columnIndex in xrange(count): > columnID = 'c' + str(columnIndex+1) > columnValue = self.getValueAt(rowIndex,columnIndex) > localsDict[columnID] = columnValue > try: > value = eval(self.formula) > except: > value = 'Invalid formula' > return value localsDict = {} for columnIndex in xrange(count): columnID = 'c' + str(columnIndex+1) columnValue = self.getValueAt(rowIndex,columnIndex) localsDict[columnID] = columnValue try: value = eval(self.formula, localsDict) except: value = 'Invalid formula' return value Cheers /F From NoSpam at NoSpam.com Thu Apr 26 19:47:04 2001 From: NoSpam at NoSpam.com (Tom) Date: Thu, 26 Apr 2001 23:47:04 GMT Subject: variable naming... References: <3ae934d3.2582143@news.newsguy.com> Message-ID: "Owen F. Ransen" wrote in message news:3ae934d3.2582143 at news.newsguy.com... > Gonna get a lot of flames for this one maybe... > > In C I am used to using the notation where the first bit > of the name tells you the type of the variable: > > int iNumFlames ; // integer > char szFlame[MAX_CHARS] ; // zero terminated string > > and so on. I presume this is not reccommended in Python? > I've found it very helpful in C... Yes, I find 'hungarian' notation quite useful too, but it seems to be associated with MS and is frowned upon. Too bad. Tom. > Is there an "official" or "semi-official" style, like when > to use lowercase and uppercase and mixed? > > > > > -- > Owen F. Ransen > http://www.ransen.com/ > Home of Gliftic & Repligator Image Generators From robin at jessikat.fsnet.co.uk Sat Apr 14 08:57:31 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 14 Apr 2001 13:57:31 +0100 Subject: thread conditional code References: Message-ID: <2AVsHJA7kE26EwmR@jessikat.fsnet.co.uk> In article , Tim Peters writes ... >> That way I could conditionally lock access to contentious >> variables and avoid thread overhead when not needed. > >I'm afraid the only way to be sure of that is to build Python without >threads -- only the OS knows how many threads exist at any given time. If >it's *possible* for another thread to pop into existence in your Python code, >then you have to lock even before it pops into existence, lest it pop into >existence "in the middle" of one of your critical sections that you cleverly >avoided locking, and then enter the (unlocked) critical section at the same >time. If the threads you deal with are too well behaved for that, then >there's no need for any locks at all . > >trying-to-cheat-locks-is-the-#1-cause-of-thread-disasters-ly y'rs - tim > > if only one (the main) thread exists at the beginning of my critical section and I'm not creating any threads how could one pop into existence? If python threads aren't initialised and I don't do the initialisation who else can do it? What I'm really asking is how to avoid initialising the threading checks without losing the possibility of locking. I assumed probably wrongly that there is an overhead to running multiple threads because of the ceval thread switch tests; after scanning the source code I suspect you have the thread switch overhead whether or not the thread stuff is initialized and then it makes no sense to avoid using it. -- Robin Becker From jojo at virtutech.se Mon Apr 9 10:06:18 2001 From: jojo at virtutech.se (Jesper Eskilson) Date: 09 Apr 2001 16:06:18 +0200 Subject: Returning objects from PythonCOM servers References: <3ACD729A.5090401@ActiveState.com> <3ACEB662.7000705@ActiveState.com> Message-ID: Mark Hammond writes: > Look for "record" in the win32com\test directory. There are some examples. > However, it will depend on the type library if it works - the record must > have a GUID. > > If the makepy generated file has no reference to any "record"s, then I'm > afraid you can't use these particular ones. If "fixing" the TLB an option? It's possible to make modifications to the TLB, yes. /Jesper -- ------------------------------------------------------------------------- Jesper Eskilson jojo at virtutech.se Virtutech http://www.virtutech.se ------------------------------------------------------------------------- From kelley at bioreason.com Mon Apr 30 11:07:20 2001 From: kelley at bioreason.com (Brian Kelley) Date: Mon, 30 Apr 2001 16:07:20 +0100 Subject: ANN: mxNumber -- Experimental Number Types, Version 0.2.0 References: Message-ID: <3AED7FA8.138433BB@bioreason.com> > That's fine for C, but makes no sense in a Python interface; i.e., wtf is > MAX_ULONG in Python terms? Python doesn't even have an unsigned integral > type. > > So that's where the silly arguments start. Just pick *something*. For > example, sys.maxint is closest in spirit to MAX_ULONG, but shares the defect > of the GMP definition that it's ambiguous whether it means "infinity" or "a > whole lot but nevertheless finite" in this context. -1 would make more sense > for Python, and is not ambiguous; GMP doesn't have that choice, though, since > it returns an unsigned result. > Hmmm. Looks like I missed most of the previous discussions, I'll have to hunt dejanews. > > more good stuff at > > http://www.swox.com/gmp/manual/gmp_6.html#SEC30 > > Right, they have lots of good stuff. The functions aren't all well-defined > in Python terms, though, and sometimes not even in C terms; e.g., > > Function: unsigned long int > mpz_scan1 (mpz_t op, unsigned long int starting_bit) > Scan op, starting with bit starting_bit, towards more significant > bits, until the first set bit is found. Return the index of the > found bit. > > The docs there really don't define what "starting_bit" or "index" mean > (perhaps 0-based, with index i being bit 2**i? i.e., starting with 0 "from > the right"?). Then what do you think mpz_scan1(0, 0) returns? That is, > there are no 1 bits in 0 for scan1 to find. I can guess that they return > MAX_ULONG again in such cases, but they don't say so, and as above -1 is > probably a better result for Python to return. > I was confused by this as well, I had to expose the function and play with it to figure out what they meant. > > > This is more what I meant: > > > > >>i = mx.Number.Integer("100101011101010") > > >>pickle.dump(i,0) > > "cmx.Number\n_I\np0\n(S'10101010101010'\np1\ntp2\nRp3\n." > > > > The string S'10101010101010' is a fairly wasteful encoding for a > > bit vector. > > Sure. Is it actually a problem for you in practice, or is just something > that offends because it's provably less than optimal? Note that text-mode > pickles are *meant* to be easily human-readable too, and there's no clearer > way to "encode" the decimal integer 100101011101010 than as the string > "10101010101010" It is a problem in practice. I am writing a caching system for bit vectors and response time is important. I have no problem with text mode pickles, it just seems slightly odd that the binary mode uses (essentially) the same encoding while marshal seems to have a much more efficient binary encoding. > -- Python does the same for its own native long (unbounded > int) pickles. A mild compromise would be to use a hex string instead (still > easily readable, encodes 4 bits per byte instead of ~3.3, and should be very > much faster for pickle<->internal conversions of very long ints). I was thinking along these same lines. Anyway, it seems like I can avoid the whole problem by renaming mx.Number.Integer as "BitVector" This is what I am using this structure for anyway. Then I can avoid all of these problems. So let me ask this question, would anyone mind a contributed type BitVector to mx.Number? Then I can add all of the fun stuff like Tanimoto, Euclidean and Jaccard distances... Thanks for listening. Brian Kelley From nessus at mit.edu Tue Apr 17 18:24:54 2001 From: nessus at mit.edu (Douglas Alan) Date: 17 Apr 2001 18:24:54 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > "There should be ONE 'obviously correct' way to do it" is one of the > Python mantras This is a BAD mantra. Not as bad as the Perl mantra, "There should be 3294369 ways to do it", but extremes are rarely ideal. "The truth lies somewhere in the middle." Besides, there are many uses for procedural macros other than for providing trivial syntactic sugars that are best done by using the sugar already provided. It's not a good idea to throw the baby out with the bathwater just because something can be misused. > Or else, join an existing party and try to influence it so its > political program becomes closer to your wishes. Which is also > fine. But you have to learn enough about political parties to see > what aspects of their program ARE ones you can influence -- > "superficial" ones, so to speak, the kind that ARE going to be > changeable -- and which ones are the VERY NATURE of the party. If > the things you find unacceptable are deep-rooted ones in the party's > membership and history, then, in general, striving to change them is > similar to trying to teach a pig to whistle -- it wastes your time, > and annoys the pig. And it's unlikely to produce the kind of melody > that will make the resulting MP3 a real hit. I've been programming in Python plenty long enough to understand its essence. Just because many people misstate its essence (by overgeneralizing or undergeneralizing), doesn't make them right. > It appears to me that the changes you want to see in Python are very > much of the pig-whistling kind: you want variables to be declared > (in another thread), you want infinitely variable syntax sugar via > macros (at least, I hope, of the hygienic kind). Of course, of the hygenic kind. I'm not a barbarian. But hygenic *and* procedural. Not the annoying kind that they added to Scheme. > Hmmm, you sure you wouldn't want some sort of explicit bracketing in > lieu of indentation for grouping, or inheritance to be restricted to > single rather than multiple, or...?-) No, of course I wouldn't. > Are you perchance at the same time an activist in the Republican > Party striving to make the party support higher taxes, stricter > Federal control on States, and more welfare including free > health-care for all...? I'd never have anything whatsoever to do with the Republican party. > just like a non-type-safe, non-class-centered Eiffel Eiffel isn't (compile-time) safe as it is. > a non-pure, non-lazy Haskell, Purely applicative languages are rarely applicative, so Haskell seals its own fate. But that doesn't mean that something good, and somewhat less pure won't rise from its ashes. > or a Python with declarations and hygienic macros, would have no > real reason to survive. That's nonsense. It would be an even better langauge, with more safety and more power, and more likely to be able to continue to evolve to meet the needs of an ever-changing tomorrow. > Such disintegrations due to "loss of core values" don't ALWAYS > happen -- the old _name_ may happen to survive even as the deep > nature of the language is totally changed, cfr. Fortran -- but they > happen regularly enough to explain why somebody who particularly > cares for a language's (or a party's) current core-values will react > to the proposal of so-called "improvements" which are in fact rather > obvious attacks against its core.]. See Guy Steele, "Growing a Language": http://cm.bell-labs.com/cm/cs/who/wadler/gj/Documents/steele-oopsla98.pdf "We need to put tools for language growth in the hands of the users" > > Sure, macros are a long rope, but some tasks require a long rope. > IF there are tasks that require a year-light worth of rope (a > separate debate), it's still extremely silly to want to attach that > thread to unsuitable frames. > There are so MANY languages whose core values do *NOT* include > simplicity and stylistic uniformity, that it's truly perverse to > strive to destroy such uniformity and simplicity in one of its few > "safe harbors". Simplicity is maintained with a simple understandable model, and a clean, elegant core, not by resistance to new features that would be very useful. Stylistic uniformity sounds like some sort of communist manifesto to me, and I want nothing to do with it. I prefer a language that helps me implement my vision with style and panache. Python does that just fine, thank you, and with a few improvements it would do so even better. > > Take a look at Guy Steele's maxim that a large language is impossible > > to design well, but a small language is doomed to die. A language > The obvious consequence if one believed that would be to design a > mid-size language No, his point is that *any* language, if it is to survive and be widely used, will someday become a large language. Since a large language cannot be designed up front, if you want the large language that your small language will become to remain an elegant language, it behooves you to plan well for the inevitable and unrelenting growth of your language from a small one to a large one. > -- isn't that what Steele tried to do in Java? Guy Steele didn't design Java. His comments are aimed, I think, in part, in implying in that Java must change if it is to survive. It needs, for instance, parameterized types, operator overloading, and lightweight objects. > > needs to be able to grow over time. Procedural macros in Lisp allowed > > Lisp to continue to evolve over time, so that even though it was > > invented in the '50's, it remains today one of the most modern of > > languages. It was able to do this, in part, by allowing every user to > > experiment with adding language features, not just the language > > Illuminati. > So use Lisp! Who's holding you back? It IS an excellent language > and has splendid implementations. Why do you want to make Python > into Lisp? And should I also move to New Zealand because I don't like the fact that Amtrak sells information to the DEA? I don't respect the Not Invented Here syndrome -- I see it time and time again in the intransigence of people to take good ideas from other sources because they didn't think of it themselves. Good ideas are good ideas, and it behoves us to accept them where we find them. There are plenty of reasons why I don't use Lisp for scripting, and if you have used both of them, you would know *many* possible answers to this question. > Some of us believe Common Lisp is too complex. Indeed it is. "The truth lies somewhere in the middle." > Some of us think that hygienic macros make _Scheme_ too big too. You would be wrong about that. But Scheme-style hygenic macros are cumbersome and unpleasant to use for real-world problems. What one really wants is procedural macros like Common Lisp, but that are also hygenic. > Even _Dylan_, for all of its beauty, and the true awesome power of > multi-methods, is not what I use, in good part *BECAUSE* of the > complication macros engender in my view. I don't use Dylan because no one else uses it. > You have not explained, I think, why _YOU_ would want to use Python > rather than Common Lisp, Scheme, or Dylan. There are numerous reasons. The fact that the others are not widely used, are not tuned for scripting, do not have as elegant a syntax, are not as easy to learn, are not available on every platform known to man, do not start up in a fraction of a second, do not come with a huge library of useful tools, etc., are all salient reasons. And yet there remain others. > They have hygienic macros AND variable declarations too. You say > that's what you want -- OK, there they are. Great. They also lack things that Python has. If I switched to them, and wanted to bring the things I like about Python to them, no doubt their Illuminati would tell me that I should go back to using Python. Well, here I am. > > And macros don't ensure that *any* given program is impossible to > > understand -- it only helps nutty programmers make programs that are > > impossible to understand. Conversely, macros can help wise > > programmers in making programs that are shorter, easier to understand, > > easier to code, and easier to maintain. > Sure -- a perfect programmer (a very hypothetical beast) will use > ANY given tool perfectly (by definition). All you say here applies > just identically to the NON-hygienic macros of C, for example. They > CAN in fact be used to good effect (cfr. the Python C API for some > good, typical examples), and C would not be half as successful as it > is if it didn't have its preprocessor or some other equivalent tool. > _IN PRACTICE_, out in the field, you'll find C macro abuse rampant > -- one of the most serious causes of maintenance nightmares. C macros are a monstrosity, so it's no wonder that in the practice there is rampant macro abuse. _IN PRACTICE_ there is not rampant macro abuse in the Lisp world. Macros are typically used to good effect and typically make programs easier to understand, rather than harder. Often they are essential to making certain programs maintainable. In another language, you would have to resort to prepossessing or data driven code-generation instead. > As you seem totally unwilling or unable to understand that > Weltanschauung to any extent, I don't see how you could bring Python > any constructive enhancement (except perhaps by some random > mechanism akin to monkeys banging away on typewriters until 'Hamlet' > comes out, I guess). $#@# you too. You are very rude. |>oug From aahz at panix.com Mon Apr 16 01:15:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Apr 2001 22:15:02 -0700 Subject: Python Performance vs. C++ in a Complex System References: <9bd7gi$cq1$1@panix3.panix.com> Message-ID: <9bdv4m$nar$1@panix2.panix.com> In article , Elliott Chapin wrote: > >I wonder if microthreads work like traditional Forth multitasking, >which is controlled roundrobin: Roughly speaking, PAUSE marks safe exit >points, and jumps to the next task if multitasking is on. Each task >saves no more than it really needs. Being thoroughly familiar with neither Forth nor microthreads, I can't be sure, but I believe that sounds right. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "If we had some ham, we could have ham & eggs, if we had some eggs." --RH From qrczak at knm.org.pl Sat Apr 14 18:37:15 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 14 Apr 2001 22:37:15 GMT Subject: Stepping backwards in for loop? References: Message-ID: Sat, 14 Apr 2001 13:37:54 -0300, Carlos Ribeiro pisze: > It would be a *lot* easier if strings had a reverse method, or if the > reverse() methods returned the reversed string. However, similarly to > sort(), the Python-way-of-doing-things must have some good reason for > reverse() to behave this way (as a inplace operation on the list). I don't think there is a deep reason, except some efficiency. The functional style would provide these operations as returning new versions. They could be added to Python under names reversed() and sorted() to avoid confusion. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From cribeiro at mail.inet.com.br Tue Apr 3 07:31:01 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Tue, 03 Apr 2001 08:31:01 -0300 Subject: A couple garbage collector questions In-Reply-To: <9ac030$h95$1@news1.wdf.sap-ag.de> References: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> Message-ID: <5.0.2.1.0.20010403081633.00a16cc0@mail.inet.com.br> At 10:02 03/04/01 +0200, Daniel Dittmar wrote: > > Something nobody has mentioned yet is that RC is cache-friendly, > > whereas pure M&S is quite cache-hostile. This is important > >But RC is quite thread hostile (as you have to lock on increment/decrement). >Not a problem in current Python because of the global lock, but possibly >limiting in the future. I believe that mark and sweep may behave even worse with threads. You'll have to use locks anyway, but it's possible that you need to keep the lock much longer. As for the *total* amount of work needed, I believe that it is approximately constant for any decent garbage collector. What changes is (mostly) the distribution in time. Why? The number of destructors calls is going to be the same for any GC (except for any memory leaks :-). If you have objects with slow destructors, they're going to dominate the time for GC anyway. So the total amount of time spent in the GC is going to be about the same, regardless of the algorithm (as I have said, for any *decent* GC). The way the GC distributes its work along time changes the *perception* of the performance. Some GC cause long pauses, and that is perceived as a bad thing, because it affects the responsae time, sometimes in a unpredictable way. I think that this is an advantage of the ref-count GC used by Python. It's not *absolutely* predictable, but it does a good job in GC'ing objects as soon as they're dereferenced, making for a smoother process without the bumps normally associated with "other" popular GCs in the market. Carlos Ribeiro From debl at nospamtheworld.com Thu Apr 26 19:41:06 2001 From: debl at nospamtheworld.com (David Lees) Date: Thu, 26 Apr 2001 23:41:06 GMT Subject: Can IDLE and ActiveState 2.1 Coexist? References: <3AE653A2.98636FAA@nospammytheworld.com> <000401c0cd42$ca317b70$d938a8c0@Hadfield> Message-ID: <3AE8B229.C4883CA@nospamtheworld.com> I did as suggested and removed Python 2.1 and then installed the ActiveState 2.1 version. I am unable to find how to start IDLE. There is an IDLE subdirectory, but it appears to just be extensions used by the ActiveState version. Can you tell me where how to start up IDLE? Thanks, David Lees Mark Hadfield wrote: > > From: "David Lees" > > > I installed Python 2.1 on my Win98 box to get IDLE. When I started to > > install Activestate 2.1 with windows extensions, a message popped up, > > warning that having 2 versions of Python may break both. > > Correct. They would trample on each other's registry keys. > > > Does anyone > > have tips on installing both IDLE and PythonWin? > > ActivePython 2.1 has IDLE. So you could remove the standard Python 2.1 and > just install ActivePython. > > Or keep current Python and add win32 extensions from > http://www.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all > > --- > Mark Hadfield > m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield > National Institute for Water and Atmospheric Research > > -- > Posted from clam.niwa.cri.nz [202.36.29.1] > via Mailgate.ORG Server - http://www.Mailgate.ORG From jkraska1 at san.rr.com Mon Apr 16 20:01:40 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 17 Apr 2001 00:01:40 GMT Subject: do...until wisdom needed... References: Message-ID: On Sun, 15 Apr 2001 21:44:08 -0700, "Ken Peek" wrote: >Sometimes, when writing code, I find it would be nice if there were a >"do...until" construct in Python. One of the essential appeals of Python is its small number of forms. This small number of forms ensures that new Python programmers are more likely to be able to read code written by experienced Python programmers. There's a thousand people who have "it would be nice" recommendations for new Python forms. This, however, is unPythonic. Try another language. Or get the Python source and add all the forms you want. You might call it: "PythonWithExtraStuffToMakeItHarderToLearn". C// From mertz at gnosis.cx Sun Apr 29 12:45:26 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Sun, 29 Apr 2001 12:45:26 -0400 Subject: Python job survey Message-ID: Well... lessee. Self-selected survey. Mangled return address. Possible address harvesting scheme. Slightly silly questions. But still... I enjoyed reading the responses of the couple people who posted them to the list :-). So... How old are you: b.1964 How many years have you been programming: For (some) money, since 1983 For fun, since 1979 How long have you been using Python: About 2.5 years. Where do you live: Small town, Western Massachusetts Would you consider relocating to Los Angeles: Maybe, for a WHOLE LOT of money and/or other job appeal. Would you require visa sponsorship: Nope. What is your current salary: Freelancer. Typically $75/hour (or per contract, which works out to about this). I don't work all that hard, so I make less per year than a fulltime multiplier would suggest. What field do you work in: (finance, internet, movies, etc) Various. Sometimes computer-based training and publishing (as a computer writer). From flfmrrs at fds.com Mon Apr 30 10:34:41 2001 From: flfmrrs at fds.com (flfmrrs at fds.com) Date: Mon, 30 Apr 2001 14:34:41 GMT Subject: problems with PythonInterpreter class from Java Message-ID: <5KeH6.4003$SZ5.317296@www.newsranger.com> For some reason I am having problems using the PythonInterpreter class when I attempt to embed Jython. There are no errors whatsoever when I compile, but when I attempt to run it, I get this: Exception in thread "main" java.lang.NullPointerException at org.python.core.PyJavaClass.lookup(PyJavaClass.java:39) at org.python.core.PyObject.(PyObject.java:46) at org.python.core.PySingleton.(PySingleton.java:8) at org.python.core.PyNone.(PyNone.java:7) at org.python.core.PySystemState.initStaticFields(PySystemState.java:34) at org.python.core.PySystemState.initialize(PySystemState.java:320) at org.python.core.PySystemState.initialize(PySystemState.java:294) at org.python.core.PySystemState.initialize(PySystemState.java:287) at org.python.util.PythonInterpreter.(PythonInterpreter.java:61) at org.python.util.PythonInterpreter.(PythonInterpreter.java:45) at SimpleEmbedded.main(SimpleEmbedded.java:6) Line 6 in SimpleEmbedded.java is where the PythonIntepreter variable is initialized. This occurred when trying to run the embed demo that comes with Jython. I am using the 1.3 SDK from Sun, and Jython-2.0. Any ideas? Thanks, -Ryan From phawkins at spamnotconnact.com Wed Apr 4 23:03:01 2001 From: phawkins at spamnotconnact.com (Patricia Hawkins) Date: 04 Apr 2001 22:03:01 -0500 Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> <3aa3a3f0.36440038@news.laplaza.org> <0zXo6.19377$ML1.968149@e420r-atl2.usenetserver.com> Message-ID: >>>>> "SH" == Steve Holden writes: SH> However, if you want to *read* C or C++ code rather than write it, Harbison SH> and Steele might be a better choice. Yup -- I was about to recommend that in addition to K&R. C, A Reference Manual, Samuel P. Harbison and Guy Steele, 4th Edition, Prentice Hall, 1995 -- Patricia J. Hawkins Hawkins Internet Applications, LLC From phrxy at csv.warwick.ac.uk Thu Apr 5 22:55:36 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 6 Apr 2001 03:55:36 +0100 Subject: problem executing python scripts in cygwin bash shell In-Reply-To: References: <69AD80E50414598C.875157435733CF34.B50964BA627F4825@lp.airnews.net> Message-ID: On Thu, 5 Apr 2001, D-Man wrote: [...] > #!/bin/bash > > //d/apps/Python20/python.exe $* [...] Aha! Good idea. Perhaps even better: #!/bin/sh temp = "$@ " //d/apps/Python20/python `cygpath -w $1` ${temp#* } Yuck. It does seem to work, though. Aren't you glad you can use Python instead of shell scripts? John From sholden at holdenweb.com Sat Apr 14 13:50:17 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 14 Apr 2001 13:50:17 -0400 Subject: why does activestate (win98) python not support globbing References: <9b4of1$j16$1@bmerhc5e.ca.nortel.com> <%_GB6.168016$m04.6637795@e420r-atl1.usenetserver.com> Message-ID: "Robert Amesz" wrote ... > Steve Holden wrote: > [ ... sensible stuff deleted ...] > > >but-when-did-vendors-try-to-be-consistent-ly y'rs - > >[Ss][Tt][Ee][Vv][Ee] > > Hey, a regex'ed, case insensitive first name! Why not make it into > > [Ss][Tt][Ee]+[Vv][Ie]?[Ee] > > In that case it also matches the way your mother used to call you when > dinner was ready. > Well, of course it completely fails to represent the vocal emphases which let me know how much trouble I was in at the time. And we'll leave it at just one vowel after the "v", if you don't mind! :-) regards [Ss][Tt][Ee][Vv][Ee] From ungarop at yahoo.com Wed Apr 4 11:09:03 2001 From: ungarop at yahoo.com (Peter J. Ungaro) Date: Wed, 04 Apr 2001 15:09:03 GMT Subject: Python/CGI and 502 errors under IIS Message-ID: Hello all, I am trying to use ActiveState ActivePython 2.0 for CGI scripting under W2K Professional/IIS 5.0. I am working on a laptop that is acting as the web server as well as my development machine. I am trying to learn Python... Every time I try to execute a test script either by direct URL or by a form POST, I get a 502 error (Bad Gateway) in the server log file: 19:47:46 127.0.0.1 POST /www_test/script/test.cgi 502 My site has Read/Execute permission, and I have registered Python in the Application Mapping area (as a Script Engine) of the IIS config tool for the .py and the .cgi extensions (and I have tried both). Any ideas on what I am doing wrong? Why would I be seeing a Bad Gateway error? Thank you, Peter From boud at rempt.xs4all.nl Mon Apr 16 05:31:10 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 16 Apr 2001 09:31:10 GMT Subject: The Kompany & Black Adder References: Message-ID: <9bee4u$l72$1@news1.xs4all.nl> Andrew Brown wrote: > I have been playing with a beta version on Windows 2000. Apparently it > works better on other platforms. For me at the moment it is completely > unusable, largely because it crashes every time it enters the debugger (and > also when I start a new project). The editor is a mess, too. On the other > hand, the email support I have been getting has been courteous, helpful, and > well-informed. I think these guys will get there in the end. The next beta > should be usable, and the one after that useful. I really hope they succeed, > and not just because I paid for it :-) > Has anyone used BA successfully under Linux? I've used BlackAdder (second beta - the first one was more of a statement of intent) on Windows 95, Windows 2000 and Linux (SuSE 6.4, 8.0 and 7.1). I haven't had many stability problems, but there are many lacunae. I can't find a python output window, for instance. However, I think that most of the problem will be resolved before the final release. And the gui designer - based on Qt Designer - must rank as the best and most complete gui designer available for Python. PyQt is already one of the most full-featured Python gui toolkits, and Qt designer makes it very easy to design complex layouts using PyQt's layout manager classes, for instance. The other components of BlackAdder are very good, too, like the editor Scintilla. I think that the future of BlackAdder is very bright, since it is so tightly coupled to Qt's progress, which is rapid. The next generation of Qt offers even better internationalisation and a vastly expanded gui designer - features BlackAdder will provide, too. And there's a book on BlackAdder in PyQt in the works. I'm currently writing the chapters on string handling and 'theming and skinning' ;-). -- Boudewijn Rempt | http://www.valdyas.org From hannah at schlund.de Wed Apr 25 13:06:58 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 25 Apr 2001 19:06:58 +0200 Subject: A couple garbage collector questions References: Message-ID: <9c707i$p4a$1@c3po.schlund.de> Hello! In article , Daniel Berlin wrote: >[...] >As for data on the other side, i've never seen non-atomic reference >counting exact a huge performance penalty, in a well-designed application. >INCREF is a macro that expands to (with depythonified equivalent names) : >object->refcount++. >DECREF is a macro that expands to (with depythonified equivalent names): >if (object->refcount--) free(object) And in a threaded environment, that is in fact: INCREF -> lock(refcnt_mutex) object->refcount++ unlock(refcnt_mutex) DECREF -> lock(refcnt_mutex) object->refcount-- if (! object->refcount) free(object) unlock(refcnt_mutex) The refcnt_mutex can either be global (much contention) or per refcnt (memory overhead for lock datastructure in addition to the refcnt itself). Or it could be per ((size_t)object) >> A_FEW_BITS pages, or anything similar. >I'm pretty curious as to how you think this will exact a huge performance >cost. >Cache locality isn't hurt, why the heck would you decref an object you >hadn't just used? Why the heck would you incref an object you weren't >about to use? Objects you fill into collections/remove out of them? The actual reference to the object instance data may be arbitrarily near/far away from the refcnt operations. >So where is the huge performance cost i'm paying? See, one assignment x = y is in general in fact an if (x != nil) DECREF(x) if (y != nil) INCREF(y) x = y So, expanded, that is: if (x != nil) { lock(x->refcnt_lock) x->refcnt -- unlock(x->refcnt_lock) if (! x->refcnt) free(x) } if (y != nil) { lock(y->refcnt_lock) y->refcnt++ unlock(y->refcnt_lock) } x = y On real GC's, it is just: x = y No lock overhead and potential lock contention, and even in the single threaded case (no locks), you still have a significant instruction overhead. Except if you achieve to eliminate most INCREF/DECREFs through intelligent global dataflow analysis. Kind regards, Hannah. From kragen at dnaco.net Mon Apr 2 21:12:48 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Tue, 03 Apr 2001 01:12:48 GMT Subject: A couple garbage collector questions References: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> Message-ID: In article , Douglas Alan wrote: >The fact that Python uses referencing counting for its front-line GC >has some very desirable properties. Two come immediately to mind: > > (1) Predictable destructor semantics. This is in contrast to Java, > in which destructors are useless because you don't know if and > when they will ever be called. I mostly disagree. If the timing of destructor calls was really predictable, you'd just call them yourself instead of depending on the GC to do it for you. If you know you're done with a file, for example, you can close it; if no part of your program knows when to close it (because more than one part of your program is using it, and they stop using it in an indeterminate order) then you don't really know when the destructor will be called, either. It *is* more deterministic than a real GC, but it's still a long way from "predictable" by my lights. > (2) No long GC pauses. Again, I mostly disagree. You get long GC pauses when the last reference to any large, complex data structure (or a data structure with slow destructors) gets overwritten or goes out of scope. >You might be able to make a "real garbage collector" that has these >properties, but it would, I believe, be pretty complicated. You can't even make a reference-counting GC that has these properties --- you need C++-style (Limbo-style?) auto_ptrs. >Since referencing-counting typically gets rid of 99.9% of all garbage, Reference-counting typically gets rid of 100% of all garbage. But sometimes it gets rid of 0% of all garbage, or (more often) somewhere in between. Which garbage it will actually collect is a global property of your program and cannot always be deduced from looking at the code that handles that garbage. >backing it up with a simple mark & sweep GC seems adequate for most >purposes. Reference-counting exacts very heavy performance costs, no matter what you back it up with. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From rdsteph at earthlink.net Fri Apr 13 23:31:05 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 14 Apr 2001 03:31:05 GMT Subject: General Decision Menu (Basketball, Programming Lnag. gerneral etcetc Message-ID: <3AD675A5.7E058FEF@earthlink.net> I guess i better stop posting these long spaghetti code things, but this is the first pass at a menu based general decision analysis thing...it has four parts, one is general any question, two is programming language choosier expert system , tow is scripting language chooser, four is a basketball predictor expert sysstem...does anyone know of any Python expert system type of programs I could look at are??? I am interested in any artificial intelligence Python programs or Expert System Python programs... anyway...this program runs fine under Python Win but fails under IDLE for unknown reasons..."Tcl error expected boolean got??" after I give it the first answer to the first prompt... Decision_Analysis_Beta3.py print "A program to help you make decisions." print print def decisionanalysis(): # This code is placed in the public domain def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_number(prompt): res = None while res is None: try: res = float(raw_input(prompt)) except ValueError: pass return res # First, ask the user to enter the lists options = get_list("Enter your options", "Option %d: ") criteria = get_list("Enter your criteria ...", "Criterion %d: ") # Next, get the user to rank his criteria. I use a system where higher # is better, so that an undesirable characteristic can be given a negative # weight. # # {} is a dictionary, it can be indexed by (nearly) any expression, # and we will index it with the names of the criteria. # number of the criterion) rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) # Next, get the user to score each option on all the criteria. # Here, we index the dictionary on the pair (option, criterion). # This is similar to a two-dimensional array in other languages score = {} print print "Enter score for each option on each criterion" print for o in options: print print "Scores for option %s" % o print for c in criteria: score[o, c] = get_number("Criterion %s: " % c) # Calculate the resulting score for each option. This equation # is different from Rod Stephen's original program, because I # make more important criteria have higher rankings, and even let # bad criteria have negative rankings. # The "result" dictionary is indexed with the names of the options. result = {} for o in options: value = 0 for c in criteria: print o, c, rankings[c], score[o, c] value = value + rankings[c] * score[o, c] result[o] = value # Now, I want to take the dictionary result, and turn it into a ranked list results = result.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first print print "Results, in order from highest to lowest score" print print "%5s %s" % ("Score", "Option") # Take the pairs out of results in order, and print them out for option, result in results: print "%5s %s" % (result, option) def ProgramLanguageFinal(): print "This is a program to help give you an idea which programming languages you should consider learning. While there are any number of languages you might consider, this program considrs only 11 of teh most popluar ones. The program will ask you to input a ranking or weighting for a number of criteria that may be of importance in choosing your next programming language." def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_number(prompt): """ get_number(prompt) -> float This function prompts for a number. If the user enters bad input, such as "cat" or "3l", it will prompt again. """ res = None while res is None: try: res = float(raw_input(prompt)) except ValueError: pass return res options = ["Python", "Perl", "Ruby", "Tcl", "JavaScript", "Visual Basic", "Java", "C++", "C", "Lisp", "Delphi"] criteria = ["ease of learning", "ease of use", "speed of program execution", "quality of available tools", "popularity", "power & expressiveness", "cross platform?", "cost"] rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) # Next, get the user to score each option on all the criteria. # Here, we index the dictionary on the pair (option, criterion). # This is similar to a two-dimensional array in other languages score = {("Python", "ease of learning"):100, ("Python", "ease of use"):100, ("Python", "speed of program execution"):10, ("Python", "quality of available tools"):70, ("Python", "popularity"):50, ("Python", "power & expressiveness"):100, ("Python", "cross platform?"):100, ("Python", "cost"):100, ("Perl", "ease of learning"):50, ("Perl", "ease of use"):90, ("Perl", "speed of program execution"):30, ("Perl", "quality of available tools"):50, ("Perl", "popularity"):75, ("Perl", "power & expressiveness"):100, ("Perl", "cross platform?"):100, ("Perl", "cost"):100, ("Ruby", "ease of learning"):50, ("Ruby", "ease of use"):100, ("Ruby", "speed of program execution"):20, ("Ruby", "quality of available tools"):20, ("Ruby", "popularity"):10, ("Ruby", "power & expressiveness"):100, ("Ruby", "cross platform?"):80, ("Ruby", "cost"):100, ("Tcl", "ease of learning"):100, ("Tcl", "ease of use"):100, ("Tcl", "speed of program execution"):10, ("Tcl", "quality of available tools"):50, ("Tcl", "popularity"):40, ("Tcl", "power & expressiveness"):10, ("Tcl", "cross platform?"):100, ("Tcl", "cost"):100, ("JavaScript", "ease of learning"):70, ("JavaScript", "ease of use"):75, ("JavaScript", "speed of program execution"):10, ("JavaScript", "quality of available tools"):50, ("JavaScript", "popularity"):100, ("JavaScript", "power & expressiveness"):40, ("JavaScript", "cross platform?"):50, ("JavaScript", "cost"):100, ("Visual Basic", "ease of learning"):50, ("Visual Basic", "ease of use"):100, ("Visual Basic", "speed of program execution"):20, ("Visual Basic", "quality of available tools"):100, ("Visual Basic", "popularity"):100, ("Visual Basic", "power & expressiveness"):50, ("Visual Basic", "cross platform?"):1, ("Visual Basic", "cost"):1, ("Java", "ease of learning"):15, ("Java", "ease of use"):50, ("Java", "speed of program execution"):50, ("Java", "quality of available tools"):100, ("Java", "popularity"):100, ("Java", "power & expressiveness"):100, ("Java", "cross platform?"):100, ("Java", "cost"):100, ("C++", "ease of learning"):10, ("C++", "ease of use"):25, ("C++", "speed of program execution"):90, ("C++", "quality of available tools"):100, ("C++", "popularity"):100, ("C++", "power & expressiveness"):100, ("C++", "cross platform?"):100, ("C++", "cost"):100, ("C", "ease of learning"):15, ("C", "ease of use"):10, ("C", "speed of program execution"):100, ("C", "quality of available tools"):100, ("C", "popularity"):100, ("C", "power & expressiveness"):100, ("C", "cross platform?"):110, ("C", "cost"):100, ("Lisp", "ease of learning"):20, ("Lisp", "ease of use"):30, ("Lisp", "speed of program execution"):70, ("Lisp", "quality of available tools"):50, ("Lisp", "popularity"):25, ("Lisp", "power & expressiveness"):110, ("Lisp", "cross platform?"):80, ("Lisp", "cost"):90, ("Delphi", "ease of learning"):50, ("Delphi", "ease of use"):110, ("Delphi", "speed of program execution"):85, ("Delphi", "quality of available tools"):100, ("Delphi", "popularity"):30, ("Delphi", "power & expressiveness"):100, ("Delphi", "cross platform?"):80, ("Delphi", "cost"):10} # Calculate the resulting score for each option. # The "result" dictionary is indexed with the names of the options. result = {} for o in options: value = 0 for c in criteria: value = value + rankings[c] * score[o, c] result[o] = value # Now, I want to take the dictionary result, and turn it into a ranked list results = result.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first print print "Results, in order from highest to lowest score" print print "%5s %s" % ("Score", "Option") # Take the pairs out of results in order, and print them out for option, result in results: print "%5s %s" % (result, option) def ProgramLanguageScript(): def get_list(heading, prompt): print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_number(prompt): res = None while res is None: try: res = float(raw_input(prompt)) except ValueError: pass return res # First, ask the user to enter the lists options = ["Python", "Perl", "Ruby", "Tcl", "JavaScript", "Visual Basic"] criteria = ["ease of learning", "ease of use", "speed of program execution", "quality of available tools", "popularity", "power & expressiveness", "cross platform?", "cost"] # Next, get the user to rank his criteria. I use a system where higher # is better, so that an undesirable characteristic can be given a negative # weight. # # {} is a dictionary, it can be indexed by (nearly) any expression, # and we will index it with the names of the criteria. # (For a more traditional program, we could use a list and index by the # number of the criterion) rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) # Next, get the user to score each option on all the criteria. # Here, we index the dictionary on the pair (option, criterion). # This is similar to a two-dimensional array in other languages score = {("Python", "ease of learning"):100, ("Python", "ease of use"):100, ("Python", "speed of program execution"):10, ("Python", "quality of available tools"):50, ("Python", "popularity"):50, ("Python", "power & expressiveness"):100, ("Python", "cross platform?"):100, ("Python", "cost"):100, ("Perl", "ease of learning"):50, ("Perl", "ease of use"):90, ("Perl", "speed of program execution"):30, ("Perl", "quality of available tools"):50, ("Perl", "popularity"):75, ("Perl", "power & expressiveness"):100, ("Perl", "cross platform?"):100, ("Perl", "cost"):100, ("Ruby", "ease of learning"):50, ("Ruby", "ease of use"):100, ("Ruby", "speed of program execution"):10, ("Ruby", "quality of available tools"):20, ("Ruby", "popularity"):10, ("Ruby", "power & expressiveness"):100, ("Ruby", "cross platform?"):80, ("Ruby", "cost"):100, ("Tcl", "ease of learning"):100, ("Tcl", "ease of use"):100, ("Tcl", "speed of program execution"):5, ("Tcl", "quality of available tools"):50, ("Tcl", "popularity"):40, ("Tcl", "power & expressiveness"):10, ("Tcl", "cross platform?"):100, ("Tcl", "cost"):100, ("JavaScript", "ease of learning"):70, ("JavaScript", "ease of use"):75, ("JavaScript", "speed of program execution"):10, ("JavaScript", "quality of available tools"):50, ("JavaScript", "popularity"):100, ("JavaScript", "power & expressiveness"):40, ("JavaScript", "cross platform?"):50, ("JavaScript", "cost"):100, ("Visual Basic", "ease of learning"):50, ("Visual Basic", "ease of use"):100, ("Visual Basic", "speed of program execution"):20, ("Visual Basic", "quality of available tools"):100, ("Visual Basic", "popularity"):100, ("Visual Basic", "power & expressiveness"):50, ("Visual Basic", "cross platform?"):1, ("Visual Basic", "cost"):1} # Calculate the resulting score for each option. This equation # is different from Rod Stephen's original program, because I # make more important criteria have higher rankings, and even let # bad criteria have negative rankings. # The "result" dictionary is indexed with the names of the options. result = {} for o in options: value = 0 for c in criteria: print o, c, rankings[c], score[o, c] value = value + rankings[c] * score[o, c] result[o] = value # Now, I want to take the dictionary result, and turn it into a ranked list results = result.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first print print "Results, in order from highest to lowest score" print print "%5s %s" % ("Score", "Option") # Take the pairs out of results in order, and print them out for option, result in results: print "%5s %s" % (result, option) def Basketball(): print "This is a program to help you decide which team will win a basketball game" print print "When prompted, enter a number ranking each team on the prompted team skill on a scle form 1 to 100, with 1 being terrible and 100 being the best imaginable" print team_one = raw_input ("What is the name of team one:") team_two = raw_input ("What is the name of team two:") criteria = {"speed":100, "size":66, "jumping_ability":50, "defense":60, "shooting":75, "ballhandling":50, "rebounding":50} scoreonespeed = input ("rank the team speed of %s on a scale of 1 to 100:" % team_one) scoretwospeed = input ("rank the team speed of %s on a scale of 1 to 100:" % team_two) scoreonesize= input ("rank the team size of %s on scale of 1 to 100" % team_one) scoretwosize= input ("rank the team size of %s on scale of 1 to 100" % team_two) scoreonejumping_ability= input("rank the jumping ability of %s" % team_one) scoretwojumping_ability= input("rank the jumping ability of %s" % team_two) scoreonedefense = input ("ramk the defense of %s" % team_one) scoretwodefense = input ("ramk the defense of %s" % team_two) scoreoneshooting = input ("rank the shooting ability of %s" % team_one) scoretwoshooting = input ("rank the shooting ability of %s" % team_two) scoreoneballhandling= input("rank the ballhandling ability of %s:" % team_one) scoretwoballhandling= input("rank the ballhandling ability of %s:" % team_two) scoreonerebounding = input ("rank the rebounding ability of %s" % team_one) scoretworebounding = input ("rank the rebounding ability of %s" % team_two) scoreteamone = (criteria["speed"])*(scoreonespeed) + (criteria["size"])*(scoreonesize) +(criteria["jumping_ability"])*(scoreonejumping_ability) +(criteria["defense"])*(scoreonedefense) + (criteria["shooting"])*(scoreoneshooting) +(criteria["ballhandling"])*(scoreoneballhandling) +(criteria["rebounding"])*(scoreonerebounding) scoreteamtwo = (criteria["speed"])*(scoretwospeed) + (criteria["size"])*(scoretwosize) +(criteria["jumping_ability"])*(scoretwojumping_ability) +(criteria["defense"])*(scoretwodefense) + (criteria["shooting"])*(scoretwoshooting) +(criteria["ballhandling"])*(scoretwoballhandling) +(criteria["rebounding"])*(scoretworebounding) print "%s has a power ranking of %d" % (team_one, scoreteamone) print print "%s has a power ranking of %d" % (team_two, scoreteamtwo) if scoreteamone > scoreteamtwo: print "%s wins!!!" % team_one elif scoreteamone == scoreteamtwo: print "the two teams are a toss-up!!!" else: print "%s wins!!!" % team_two print "Please enter the number for the type of decision you wish to analayze:" print "1. General Decision Analysis, you choose the options, criteria, etc." print "2. Help in Choosing Programming Language amongst 11 popular languages" print "3. Help in choosing scripting programming language amongst 6 scripting languages" print "4. Which Basketball Team will win the Game???" while 1: # loop forever choice = input("Please type in the number of the type of decision-program you wish to run from above and hit enter:") if choice ==1: decisionanalysis() elif choice ==2: ProgramLanguageFinal() elif choice ==3: ProgramLanguageScript() elif choice ==4: Basketball() elif choice =="quit": break # exit from infinite loop else: print "Invalid operation" From graham_guttocks at yahoo.co.nz Fri Apr 27 16:55:16 2001 From: graham_guttocks at yahoo.co.nz (Graham Guttocks) Date: Fri, 27 Apr 2001 13:55:16 -0700 (PDT) Subject: Python version of binascii.b2a_hex (binary to hex conversion)? In-Reply-To: <15081.55762.421088.13897@anthem.wooz.org> Message-ID: <20010427205516.65576.qmail@web10303.mail.yahoo.com> Barry A. Warsaw" wrote: > def unhexlify(s): > acc = [] > append = acc.append > # In Python 2.0, we can use the int() built-in > int16 = string.atoi > for i in range(0, len(s), 2): > append(chr(int16(s[i:i+2], 16))) > return string.join(acc, '') Greetings Barry, I don't mean to look a gift horse in the mouth so to speak, but is there a way to unhexlify using all builtins such as what I've done with hexlify here? def hexlify(b): return "%02x"*len(b) % tuple(map(ord, b)) Regards, Graham __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From db3l at fitlinxx.com Mon Apr 23 12:43:07 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Apr 2001 12:43:07 -0400 Subject: Win32 and blocking threads References: Message-ID: Campbell writes: > Are Python/win32 Threads == Windows threads? Or are they, in the style > of ActivePerl's Threads, rather braindead? I know this is a FAQ of > sorts but I have read that document and many others in confusion still. Yes, under Win32, Python threads are Win32 threads and thus OS threads. We use them all the time in our code and they work very nicely with various blocking operations. However (and this is important), Python overall still uses a global interpreter lock to control its execution of the interpreted code. So even though you can have multiple OS threads, if any of them block while still holding the GIL, it will prevent any of your other Python code from running. Python code itself won't have this problem (the interpreter releases the GIL periodically after processing a small number of opcodes), but internal C code within the Python interpreter or in extension modules can do this. In general, anytime the Python interpreter itself (or its standard modules) make calls to the OS that might block, it will release the GIL around the code, permitting other Python code to run. The same is generally true for extension modules. However, if a piece of code forgets to do this, then the blocking operation can also block other Python threads. So an important question here is likely to ask precisely what blocking call are you using in your threads, and if that call is from some extension module, has that extension module properly released the GIL across the call? -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From tim.one at home.com Fri Apr 20 13:44:40 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Apr 2001 13:44:40 -0400 Subject: [Python-Dev] Class Methods In-Reply-To: <034901c0c9b3$fcaa6bd0$e000a8c0@thomasnotebook> Message-ID: [Thomas Heller] > ... > PS: I find it strange that everyone so far seems to be against it. I didn't get that sense yet. I did get the sense they're not actively *for* it yet, and the questions asked so far explain why: What does it buy us? What are the current alternatives? What are the costs (not least of all in terms of breaking existing code)? It's a bunch of tradeoffs, and it appears that few who aren't steeped in Smalltalk's view of the world understand what the practical *attraction* is. The same questions get asked even for wholly non-controversial changes, like, say, adding an optional ">> file" clause to "print" . by-default-it's-best-to-resist-everything-ly y'rs - tim From aahz at panix.com Tue Apr 10 20:49:26 2001 From: aahz at panix.com (Aahz Maruch) Date: 10 Apr 2001 17:49:26 -0700 Subject: Chocolate [was Re: Python Books for 2002] References: <9avoac02uou@news2.newsguy.com> Message-ID: <9b09mm$t8a$1@panix6.panix.com> In article <9avoac02uou at news2.newsguy.com>, Alex Martelli wrote: > >[P.S: the very idea of coffee being OT on a comp.* group is, I think, >an oxymoron -- don't _all_ we nerds survive mostly on caffeine...?] Nope. I use adrenaline instead. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From duncan at rcp.co.uk Thu Apr 12 04:32:13 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Thu, 12 Apr 2001 08:32:13 +0000 (UTC) Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <9b0pqq$1kt$1@news1.xs4all.nl> <3ad49fc4_3@news4.newsfeeds.com> Message-ID: "Steve Holden" wrote in : > I have an idea Ken was being ironic. With my English background that > stood out a mile. Are you American, by any chance? Seems like irony > isn't easily spotted by natives of the USA (with some notable > exceptions, of course). > If I remember correctly, alt.fan.pratchett came up with a solution to this problem by inventing a new smiley (Fe) to indicate irony. From dsavitsk at e-coli.net Fri Apr 6 17:56:14 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 6 Apr 2001 16:56:14 -0500 Subject: CGI on IIS References: <41qz6.12087$mA.4075932@newsrump.sjc.telocity.net> Message-ID: <1Yqz6.12118$mA.4098666@newsrump.sjc.telocity.net> "Neil Hodgson" wrote in message news:Hlqz6.7979$Xi1.61371 at news-server.bigpond.net.au... > doug: > > i have done this > > > > > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Script > > Map > > .cgi c:\Program Files\python.exe -u %s %s > > > > but all i get back is > > > > "%1 is not a valid Win32 application. " > > Try quoting the "c:\Program Files\python.exe" as it contains a space. > > Neil very close. I had to do this (quoting the path) but through the IIS manager instead of the registry. thanks for the suggestion. i'll write this up with specifics and put it up at http://www.e-coli.net/pyiis.html by the end of the day. doug From sholden at holdenweb.com Sun Apr 29 13:01:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 29 Apr 2001 17:01:02 GMT Subject: Sockets: Sending/receiving arbitrary amounts of data References: Message-ID: "Daniel Klein" wrote in message news:pneoetskbee729lra63ksqj5o06vkpeo84 at 4ax.com... > Just starting to get my head around sockets and I'm using PP2E by Mark Lutz as > my guide. > > The examples all seem to indicate that you need to send/recv a specific > (maximum) amount of data. The examples all use '1024' bytes to send or recv. > Although this can be increased, there is always the possiblility of needing > more. > Indeed. A big problem in networking generally is knowing what to expect! > What if the server doesn't know in advance how much data will be sent from the > client? The server is waiting for '1024' bytes and the client sends down 10k. The server's recv() call will return 1024 bytes, and the remainder will be buffered somewhere in the socket between the client's (sender's) transport layer and the receiver's (server's) transport layer. On the other side, asking for 1024 bytes doesn't always mean that's what you'll get. It's just a maximum. When the other end closes its socket you should eventually receive a return from a recv() call with no data. This indicates there will be no more data. Otherwise your recv() calls will block (i.e., hang waiting for data) untilt something comes in. There is no need to have senders sending the same sized chunks of data as receivers receive. You just keep reading more with recv() until the protocol tells you this is the end of hte transmission. > Does this mean I have to first send a "here's how much is coming" message to > the server so that the server can receive it in '10' 1k chunks? Protocols at the application level are expected to make it clear how much data will be transmitted, either by including byte counts or by using message formats with unambiguous terminators. > And likewise if > the server sends more than is expected to the client. I don't mind doing it > this way, I'd just like to know if there is a 'high-level' way to implement > this so that client and server handle the requests regardless of how much data > is being sent/recv'd ? > It's all pretty much in the hands of the protocol your application uses. > Thanks in advance for any light you can shed on this, > > Daniel Klein > Portland, OR USA > I wrote an FTP stream handler which uses socket calls, it may help you a little. http://www.holdenweb.com/Python/PDCode/ftpStream.py The test code for the module might give you some ideas, although there I'm just reading the whole data stream until there's nothing left. To interact, you'll need to detect the end of the client's requests at the server (and, of course, vice versa). regards Steve From bos at hack.org Wed Apr 11 01:10:03 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Wed, 11 Apr 2001 07:10:03 +0200 Subject: libstdc++-libc6.2-2.so.3 HELP ! References: <3AD32477.BE2F7AC4@to.alespazio.it> Message-ID: <3AD3E72B.1F4B157@hack.org> "luca giay at to.alespazio.it" wrote: > python: error in loading shared libraries: libstdc++-libc6.2-2.so.3: > cannot open shared object file: No such file or directory This question has nothing to do in comp.lang.python, but install the packet containing the file libstdc++-libc6.2-2.so.3. It should be some egcs-package or similiar. Search the net. -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From barry at digicool.com Fri Apr 27 18:16:36 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 27 Apr 2001 18:16:36 -0400 Subject: Python version of binascii.b2a_hex (binary to hex conversion)? References: <15081.55762.421088.13897@anthem.wooz.org> <20010427205516.65576.qmail@web10303.mail.yahoo.com> Message-ID: <15081.61380.821169.502419@anthem.wooz.org> >>>>> "GG" == Graham Guttocks writes: GG> Greetings Barry, GG> I don't mean to look a gift horse in the mouth so to speak, GG> but is there a way to unhexlify using all builtins such as GG> what I've done with hexlify here? | def hexlify(b): | return "%02x"*len(b) % tuple(map(ord, b)) Well, depends on how you define `builtins' :) Do you mean functions in the builtin module, or C builtin functions? Or are you looking for a convenient one-liner? Essentially the unhexlify I posted uses only C builtin functions, e.g. [].append, strop.atoi, range, len, chr, strop.join. I don't remember if anybody came up with a nice one-liner when the thread was debated eons ago. Cheers, -Barry From whisper at oz.net Tue Apr 3 21:01:27 2001 From: whisper at oz.net (Dave LeBlanc) Date: 4 Apr 2001 01:01:27 GMT Subject: Newbie has question that's not exactly Python... References: Message-ID: <9adrp7$4aa$0@216.39.170.247> I did an experiment where I tried to load a gif file into IE directly from disk (File:Open). Instead of displaying it inline, it brought up the helper app associated with gif files. I believe that you'll have to add just a bit of html around your image before a browser is going to accept it. I don't believe that "content-type image/gif" is enough! According to the html standard, at least is needed to start things off. This seems to be a fairly standard minimal template for an html file: Untitled <-- Image here --> (Change the "HTML 4.0 Transitional" to 3.2 if that suits you: "HTML 3.2".) I have seen html sources (View:source) that got away with just: Dave LeBlanc On Tue, 03 Apr 2001 21:08:31 GMT, "Gary Walker" wrote: >Chris, > >Your answer *looks* like it might work, but, unfortunately, it doesn't. Let >me quickly say that I realize that you were typing it off the top of your >head, and so one really shouldn't expect it to run. But to me, it looks >rather complete... but I think something's missing... > >Here's some actual code of mine that doesn't work: > >************************************ >#!/usr/bin/python > >import StringIO, cgi, os, sys, string, Image > >im = Image.open('backgroundimage.gif') ># here I'll be drawing all over my image... > ># Now I want to send it to a browser... >sfp = StringIO.StringIO() >im.save(sfp,'gif') > >print 'Content-Type: image/gif\r\n\r\n' >sys.stdout.write(sfp.getvalue()) >************************************ > >Do you (or anyone else please??) see what's wrong here? It seems like it >oughta work. > >As you can see, I've incorporated most of Chris's solution (see below), but >I'm not a savvy enough Python programmer to know what's missing. I'd love to >know the "right" way of doing this, so I can get on with the next piece of >my program... > >Can anyone suggest a working solution? > >Thanks!! > >Gary Walker > >Chris Gonnerman wrote in message ... >>You could use the Python Imaging Library. I'm no expert on it; I use >>gdmodule, >>but PIL is more "standard." You would do something like this in a cgi: >> >> import sys >> from PIL import Image >> from StringIO import StringIO >> >> img = Image.open("background.gif") # or Image.new(...) for a blank >>image >> # ... do some drawing on the image ... >> sfp = StringIO() >> img.save(sfp, "gif") # possibly with keyword options >> sys.stdout.write(sfp.getvalue()) >> >>The StringIO is required as the save() method of the Image object requires >>seek() and tell() methods, so we can't just say >> >> img.save(sys.stdout, "gif") # BIG NO NO >> >>because sys.stdout may be attached to a pipe or socket. >> >>As I said, I'm no expert on PIL, so your mileage may vary. There may be an >>easier way to do this... anyone else care to comment? >> > > > From rcameszREMOVETHIS at dds.removethistoo.nl Sun Apr 8 18:24:25 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sun, 08 Apr 2001 22:24:25 GMT Subject: disregard References: Message-ID: Steve Holden wrote: > [...] > >It turned out that my "small change" to the print-header routine had >actually been made to the print-line routine, as a result of which >shortly before Christmas the 300-page report had become a 600-page >report, in which every other line read "AND A HAPPY CHRISTMAS FROM >STEVE HOLDEN AND ANDY PARTRIDGE". LOL And wasn't that a nice christmas suprise... >that-kind-of-christmas-doesn't-come-every-year-so-now-i-test-everythi >ng-ly y'rs - steve Ah, we live and learn. Provided the experience doesn't kill us first. Robert Amesz From throw_away_fish at hotmail.com Sun Apr 15 04:02:57 2001 From: throw_away_fish at hotmail.com (throw_away_fish) Date: Sun, 15 Apr 2001 08:02:57 GMT Subject: WHY is the Python Community so... Message-ID: <3ad95544.6744057@news.prodigy.net> Why is the Python Community so nice? This is great. I think that we should cite this as a reason we like, learn, and love Python. Not only is it readable, fast, etc. etc. etc.... OUR NEWSGROUPGS ARE PIMP! Anyways. Long live us. From alex at server01.shindich.com Sun Apr 1 04:21:05 2001 From: alex at server01.shindich.com (Alex Shindich) Date: Sun, 1 Apr 2001 00:21:05 -0800 (PST) Subject: PEP 245 Message-ID: I know I am going to get hate mail for this, but I have to get it off my chest! I would like to get a few questions answered: 1. What is the point of interfaces without static typing? All that a proposed definition of an interface guarantees, is that the concrete classes will implement methods with certain names; no more and no less. There is no guarantee that method doSomething declared in the interface has anything in common with the method doSomething declared in the concrete implementation class. Indeed, there is no requirement that methods take the same parameters, not to mention that type checking is impossible? What kind of contract is that? BTW, the return values are not being checked either. 2. At what point will the compliance with the interface definition be done, at compile time, or at run time? If the definition compliance is checked at compile time, then it will be impossible to add implementation dynamically. Python has always allowed modifications to the instances at run time. Not that it is always pretty, but it is possible. Compile time checking would disallow this technique. If the compliance is checked at run time, then interface checking is as good as as simply assuming that the method is implemented. Today, I can compile code like "f.doSomething ()" without f actually implementing doSomething. At run time I would get an AttributeError thrown into my face. In fact, the run time compliance is available already. Also, will it be possible to instantiate classes that do not implement all the interface methods? 3. I am just curious... Does any one smell Java here? Not that I have anything against Java, but I just wonder why Python should turn into Java. Python is a wonderful, strong, and powerful OO language. It has a set of its own patterns. Why does it have to support every possible feature? If someone really misses strong typing and interfaces, maybe you are trying to use the wrong language for the task? May be, Java is a better language for this particular set of tasks? Or perhaps, you can implement the same set of features using Python's real power -- introspection and run time binding. -- Alex Shindich mailto:alex at shindich.com Visit http://www.shindich.com/ From Maniac at alltel.net Tue Apr 17 14:44:40 2001 From: Maniac at alltel.net (Maniac) Date: Tue, 17 Apr 2001 13:44:40 -0500 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! References: <160420012327456092%jwbaxter@olympus.net> Message-ID: John W. Baxter wrote: > In article , Tim Peters > wrote: > >> If not, I don't buy that it's because you've >> been waiting since January to get Easter, Passover and taxes out of the >> way . > > Tim leaves out the suicide of Emperor Otho (69AD), and Wilber Wright's > birth (1867) and Charlie Chaplin's birth (1889). And that's just > today's (Apr 16) celebrations, yesterday (besides Easter) there was > the sinking of the Titanic to commemorate. And before that MLK > birthday, and President's Day, and Mardi Gras, and so on, including the > April 2, 1502 death of Prince Arthur, son of Henry VII, which cleared > the way for Henry VIII later on. > > It's a wonder any software testing ever gets done. ;-) It's also always someone's birthday. History was always easier to remember; back when there wasn't quite as much history to remember. ) -- Maniac at alltel.net 40? 37' 9" N, 96? 57' 24" W ? A single tasking guy in multi tasking world From root at rainerdeyke.com Tue Apr 24 14:19:22 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 24 Apr 2001 18:19:22 GMT Subject: Named code blockes References: <0P5F6.85546$J%5.30205213@news2.rdc2.tx.home.com> <9c45qg01sui@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9c45qg01sui at news1.newsguy.com... > "Rainer Deyke" wrote in message > > In Python, unnamed objects have an additional benefit: there is a single > > consistent way of naming them. Consider: > > > > a = 5 > > b = lambda: None > > def c(): > > pass > > > > These are three assignments, but only two look like assingments. The > > They are three ways to bind (or re-bind) names, but only two of them > ARE "assignments" -- Python's syntax defines assignments, plain and > augmented, rather precisely, and there is no 'def' keyword there:-). I count four ways ('import', 'def', '=', and augmented assignment), not counting 'globals().set' and similar tricks. > > special syntax for the third case does not make it clear to newbies that > 'c' > > is a reference like any other which happens to refer to a function object. > > And you think newbies will find the definition for b any clearer?! No, because the keyword 'lambda' has no intrinsic meaning. Lambda syntax in its current form is problematic, but that doens't mean the idea behind it is. Some obvious readability improvements: 1. Change the keyword. b = lambda: None --> b = function: None 2. Place parenthesis around the argument list. b = function: None --> b = function(): None Of course unnamed functions will remain crippled as long as their body is limited to a single expression, and embedding a statement suite in an expression in Python is problematic because of indentation issues. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From Eugene.Leitl at lrz.uni-muenchen.de Mon Apr 23 08:29:01 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Mon, 23 Apr 2001 14:29:01 +0200 (MET DST) Subject: AIX ./configure for Python 2.1 to use gcc instead of cc_r ? In-Reply-To: <20010423125158.A695@freedom.puma-ag.com> Message-ID: On Mon, 23 Apr 2001, Steve Purcell wrote: > Try the following: > > ./configure --with-gcc Thank you. That did work (gcc --version reporting 2.95.2), I now only get a few failed regression tests, probably mostly due to missing libraries. test test_zipfile skipped -- No module named zlib test_zlib test test_zlib skipped -- No module named zlib 113 tests OK. 2 tests failed: test___all__ test_pty 22 tests skipped: test_al test_bsddb test_cd test_cl test_dl test_gdbm test_gl test_gzip test_imgfile test_largefile test_linuxaudiodev test_minidom test_nis test_openpty test_pyexpat test_sax test_sunaudiodev test_sundry test_winreg test_winsound test_zipfile test_zlib make: 1254-004 The error code from the last command is 1. Freeze seems to work, too: python freeze.py hello.py make ./hello Hello world... so I'm happy. I would suggest that ./configure --with-gcc should be made default, as cc_r (don't know which version) has trouble with Python 2.1. From alwagner at tcac.net Mon Apr 16 22:51:20 2001 From: alwagner at tcac.net (Albert Wagner) Date: Mon, 16 Apr 2001 21:51:20 -0500 Subject: Can't find Idle-0.6 Message-ID: Idle-0.6 is supposed to be packaged with Python-2.0, but only Idle-0.5 is in the Python-2.0 dist. Does anyone know where I might find Idle-0.6? From bogus@does.not.exist.com Wed Apr 4 16:32:37 2001 From: bogus@does.not.exist.com () Date: 4 Apr 2001 22:32:37 +0200 Subject: PC software for 10$/cd Message-ID: <3acb84e5$1@news.takas.lt> Send me an email I'll send you a list Thank you software1for10 at hotmail.com From root at rainerdeyke.com Tue Apr 17 23:10:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 18 Apr 2001 03:10:12 GMT Subject: ANNOUNCE: A *second* Python 2.1 release candidate! References: <160420012327456092%jwbaxter@olympus.net> Message-ID: "Robin Becker" wrote in message news:Zj1+fTAoWM36EwoR at jessikat.fsnet.co.uk... > Adolf Hitler; this thread is now complete! Godwin's law requires that you actually compare one of the participants in the thread to him. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From robin at jessikat.fsnet.co.uk Sat Apr 14 16:04:48 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 14 Apr 2001 21:04:48 +0100 Subject: ANNOUNCE: A Python 2.1 release candidate! References: <3AD8A21D.34800DB9@home.com> Message-ID: In article <3AD8A21D.34800DB9 at home.com>, Don O'Donnell writes ... > >PLEASE DON'T DUMB DOWN PYTHON... IT'S SO BEAUTIFUL AS IT IS! > .... >> In 2.2, it will become a SyntaxError instead. >> >How sad. > >-don it often seems that the Gods are unaware of the effects of their God like design decisions; they appear to want everyone to read and understand every detail of the scriptures and at the same time make these scriptures terse and opaque. The Gods are often patronising and attempt to justify changes to their past erroneous decisions by asserting surprise to the masses. I'm not in the least suprised by the current __debug__ behaviour. I'm more suprised by magic behaviour. Exactly what are the magic variables, where are they documented and why if tracing function entry and exits is so useful don't we have a -trace flag. A programming language with more than 240 documents about improvements/changes can hardly be optimal and the retreat into python- dev seems indicative of something wrong. -- Robin Becker From aleaxit at yahoo.com Mon Apr 2 17:40:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 2 Apr 2001 23:40:48 +0200 Subject: Results not quite what I expected References: Message-ID: <9aarkb0s6a@news1.newsguy.com> "Kemp Randy-W18971" wrote in message news:mailman.986239804.14212.python-list at python.org... > Alex: > I tried your suggestion, and I am close, but not quite. What is happening with the number split? [snip] > number = re.compile(r'\d+\.?d*') As I see was pointed out already, you omitted a \ right after the ?. Nobody ever said regular expression syntax is _nice_ or forgiving!-) However, I still suspect re's are the simplest tool for your job (which I haven't seen precisely specified yet -- for example, do you want 'numbers' to include an optional leading sign, a trailing exponent, or...?). The alternatives require you to use other tools to identify runs of contiguous digits, then look at non-digits right before and after digits (and right between runs, if you need to pick up a decimal point as a part of a 'number') to pick up various possible non-digit 'decorations'. Re's offer compact ways to express this kind of things, although of course they do not obviate the need to specify very completely and precisely what you want to happen in various anomalous cases -- e.g., say your text has the line foo 23.45.67 bar what number or numbers should be extracted from this line? The above re, when corrected, will parse it as two numbers: 23.45 67 but IS this OK for your application, or can you somehow guarantee that no such anomaly will ever possibly occur...? Alex From jon at csh.rit.edu Wed Apr 25 00:40:27 2001 From: jon at csh.rit.edu (Jon Parise) Date: Wed, 25 Apr 2001 00:40:27 -0400 Subject: Python game developers In-Reply-To: ; from vanevery@3DProgrammer.com on Tue, Apr 24, 2001 at 09:12:03PM +0000 References: Message-ID: <20010425004027.E19987@csh.rit.edu> On Tue, Apr 24, 2001 at 09:12:03PM +0000, Brandon J. Van Every wrote: > Is there a mailing list that focuses on game development, and what people > have / haven't / can / cannot achieve in Python as game developers? You probably want to check out the pygame modules: http://pygame.seul.org/ -- Jon Parise (jon at csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member From mark at chem.uwa.edu.au Tue Apr 24 18:15:32 2001 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 24 Apr 01 22:15:32 GMT Subject: Broken configure script for solaris in 2.1? References: Message-ID: jason petrone writes: >I noticed some old threads about problems compiling python2.1 on solaris. >My trial license for the Sun Workshop Compiler ran out, so I had to compile >python with gcc and had the same problems. >It seems to me that the error is around line 583 of configure.in: >SunOS/5*) > if test "$GCC" = "yes" > then LDSHARED='$(CC) -shared' > else LDSHARED="ld -G"; > fi ;; >`gcc -shared` doesn't seem to work, but using `gcc -G` or `ld -G` works fine. >I assumed that gcc used whatever linker was available on the system, but now >I'm wondering if it doesn't do linking itself. If it does, then it would make >sense that this doesn't work, since it shouldn't be able to link archives >built with non-gnu ar and ranlib. >Hope someone knows the right thing to do. It really would be nice for python >to compile out of the box on solaris/gcc. Early on in the alpha cycle there was an issue with Solaris/gcc (the -fPIC option to gcc was not being used, leading to errors when linking), but this has been fixed for some time. 2.1 and its modules compile happily on my Solaris boxes (Solaris 8, gcc 2.95.2). Have you got the final release of 2.1? "configure.in" should have around line 637: if test -z "$CCSHARED" then case $ac_sys_system/$ac_sys_release in SunOS*) if test "$GCC" = yes; then CCSHARED="-fPIC"; fi;; and output from "make" should include lines like the following when building the shared extensions: building 'struct' extension creating build creating build/temp.solaris-2.8-sun4u-2.1 gcc -g -O2 -Wall -Wstrict-prototypes -fPIC -I. -I/export/home/mark/src/python/CV S/python/dist/src/./Include -I/usr/local/include -IInclude/ -c /export/home/mark /src/python/CVS/python/dist/src/Modules/structmodule.c -o build/temp.solaris-2.8 -sun4u-2.1/structmodule.o creating build/lib.solaris-2.8-sun4u-2.1 gcc -shared build/temp.solaris-2.8-sun4u-2.1/structmodule.o -L/usr/local/lib -o build/lib.solaris-2.8-sun4u-2.1/struct.so The core part of python is compiled by lines like: gcc -c -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -o Modu les/python.o Modules/python.c The library is built like so: ar cr libpython2.1.a Parser/acceler.o etc, etc, etc and Python itself linked like so: gcc -o python \ Modules/python.o \ libpython2.1.a -lpthread -lsocket -lnsl -ldl -lthread -lm Hope this helps... -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From James_Althoff at i2.com Tue Apr 24 13:42:00 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 24 Apr 2001 10:42:00 -0700 Subject: Named code blockes Message-ID: Yep. I agree. Jim On Mon, Apr 23, 2001 at 04:49:01PM -0700, James_Althoff at i2.com wrote: | | | | In Java unnamed (anonymous, inner) classes | are used all over the place in Swing-GUI code. | Not advocating -- just pointing it out. :-) | | IMO that is a kludge to work-around for a significant language deficiency -- if functions (and classes) were first-class objects the function object itself could be passed as the event handler! -D From joonas at olen.to Sun Apr 15 16:19:50 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Sun, 15 Apr 2001 23:19:50 +0300 Subject: how to import from variable source References: <20010414160900.A7013@madeforchina.com> Message-ID: <3ADA0266.4D21B9C2@olen.to> Rob Brown-Bayliss wrote: > > Hello > > I am building a shell type app that imports modules depending on the > users actions. > > I do not want to have the import routines hard coded, rather I would > like to import from a variable like so: > > module = 'mymod' > import module > > Only, as I found out I get an error stating that there is not module > called module. > > Is this possible in python? Is there a better way perhapse? > > Thanks, You can use exec statement. module = 'mymod' exec "import "+module -- #!/usr/bin/python for y in 0,1: for x in range(y,32,2):print "J ojoonoansa sP at aoalleans.mtaoa "[x], print From tim.one at home.com Sun Apr 1 18:40:14 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 1 Apr 2001 18:40:14 -0400 Subject: parrot! In-Reply-To: <0FNx6.176893$tP3.2720141@news1.rdc1.bc.home.com> Message-ID: [Luke] > ... > http://www.oreilly.com/parrot/ > > the time stamp says on Sunday April 01, @02:20PM > that would suggest to late for a april fools right? Indeed, far too late. Plus everyone knows O'Reilly has no sense of humor! It's just a shame that some joker posted a forgery from "Guido" to comp.lang.python last night. Even worse that I played along with it, for which I apologize. It apparently made everyone think that *everything* they read today is a joke. if-parrot-is-a-joke-then-so-is-this-msg-ly y'rs - tim From cribeiro at mail.inet.com.br Sat Apr 14 15:10:16 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 14 Apr 2001 16:10:16 -0300 Subject: python-dev summary, 2001-03-19 - 2001-04-12 In-Reply-To: <3AD8876A.CDC6E4AF@ActiveState.com> References: <26TB6.193$E4.7668@uchinews> Message-ID: <5.0.2.1.0.20010414160909.022ebde0@mail.inet.com.br> At 10:22 14/04/01 -0700, Paul Prescod wrote: >Ben Wolfson wrote: > > [[locals.append(here),remotes.append(there) for here,there in\ > > [stripped.split('\t') for strippied in\ > > [line.strip() for line in open(fn).readlines()]\ > > if stripped]\ > > if path.exists(here)] for fn in filenames if path.exists(fn)] What is this? Is it a Python code obfuscation competition? Carlos Ribeiro From scarblac at pino.selwerd.nl Wed Apr 4 13:33:43 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Apr 2001 17:33:43 GMT Subject: "not x in" vs. "x not in" References: <1iIy6.1426$p5.5346@news1.rivrw1.nsw.optushome.com.au> Message-ID: deadmeat wrote in comp.lang.python: > > Why is there a "not in" operator? For clarity? > > (Not that I oppose "not in" in any way. I like it. I'm just curious.) > > We also have "x != y" in addition to "not x == y" :) And even x <> y... -- Remco Gerlich From jared at tgflinux.com Thu Apr 12 13:51:51 2001 From: jared at tgflinux.com (Jared Lee Peterson) Date: 12 Apr 2001 10:51:51 -0700 Subject: Threading question Message-ID: <987097922.7170.1.camel@jardrum.tgflinux.com> I have a question regarding threading in python. Let me start by saying I am on a RedHat Linux 6.2 box with the standard python 1.5.2 that ships with it. I am writing a test script that I need to spawn various threads. I could probably do this without threads but I was curious to see how they work in python so I am trying to get them working. Basically I need to spawn a thread that is just making a system call (os.system()) to another script. However when I create the thread with the target set it seems to call the other script just fine but the thread blocks execution and does it does not resume in the first script while that the other thread does it thing. This is how I am spawning the thread ... tmp = Thread(target=os.system(other_script.py)) Ideally I want to be able to loop over a list of scripts and spawn threads for each one and monitor their exectuion. I have tried to look online for docs on python threading and there are none so if someone could help me out here that would be great. It is probably obvious just by my email that I am not the threading master for sure. Thanks a lot Jared From robin at jessikat.fsnet.co.uk Tue Apr 24 05:28:38 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Apr 2001 10:28:38 +0100 Subject: PyArg_Parse weirds Message-ID: can someone jog my cpu to solve a problem with this C fragment else if(PyObject_HasAttrString(value,"red") && PyObject_HasAttrString(value,"green") && PyObject_HasAttrString(value,"blue")){ double r, g, b; PyObject *v, *s; printf("object seen\n"); v = PyObject_GetAttrString(value,"red"); i = PyArg_Parse(v,"d",&r); s = PyObject_Str(v); printf("v=%8.8X=%s i=%d r=%g\n", v, PyString_AsString(s), i, r); Py_DECREF(s); Py_DECREF(v); when run I see object seen v=008213B8=0.0 i=0 r=8.23537e-164 so I'm getting the attribute ok and it is a float (checked in python) so why does my PyArg_Parse of v fail? -- Robin Becker From barry at digicool.com Wed Apr 18 17:00:34 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 18 Apr 2001 17:00:34 -0400 Subject: MIME/Base64 oddities References: Message-ID: <15070.114.514120.578454@anthem.wooz.org> >>>>> "DG" == David Given writes: DG> I'm using MIMElib and base64lib to decode mail archives, and DG> I'm finding what I suspect are bugs. In particular: I'm not terribly surprised. mimelib is alpha-ish software, and I've got some patches on my personal CVS server that I haven't released yet. I've just applied for an SF project named "mimelib" so if approved, I'll be moving the code to a more public place (until and if it ever becomes part of Python's standard library). DG> * On some base64 blocks, base64lib gives me `Incorrect DG> Padding' exceptions. DG> * On some messages, mimelib bails out with `illegal argument DG> type for built-in operation' errors in section_divider. On DG> others, in particular mailer daemon multipart messages, it DG> keeps handing me the same attachment indefinitely. DG> I can provide sample messages that cause both of these errors; DG> it's completely reproducable. Has anyone encountered anything DG> like this before? Who wrote these modules? Are there any DG> known bugfixes? I wrote mimelib, 'natch. Please send sample messages directly to me and I'll run them through my current code base. Also, let me know if it's okay to add them to a PyUnit-based test suite that I'm going to (eventually) add. Thanks, -Barry From dsh8290 at rit.edu Wed Apr 4 18:16:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 4 Apr 2001 18:16:31 -0400 Subject: Rounding error In-Reply-To: <3ACB98ED.1F239885@ihug.co.nz>; from matthewm@ihug.co.nz on Thu, Apr 05, 2001 at 09:58:05AM +1200 References: <3ACB98ED.1F239885@ihug.co.nz> Message-ID: <20010404181631.A4249@harmony.cs.rit.edu> On Thu, Apr 05, 2001 at 09:58:05AM +1200, Matthew wrote: | Hi, | | I'm calculating a bunch of co-ordinates as below. I'm using | Round(,2) but as you can see rounding errors are happening... | How do I overcome this? I'm using ActivePython Build203. Don't use FP. Floating point is inherently inaccurate. You said they are co-ordinates, 2-d or 3-d? I would recommend creating a Point class, something along the lines of: class Point : def __init__( xn , xd , yn , yd ) : self.xn = xn self.xd = xd self.yn = yn self.yd = yd ... where xn is the integer part and xd is the decimal part. Both should be integers. Do the rounding yourself on the [xy]d parts if you really want it rounded (mod 100 should work for that, but check for overflow and handle it properly). HTH, -D From aleaxit at yahoo.com Sun Apr 29 17:38:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 29 Apr 2001 23:38:18 +0200 Subject: xml parsing with sax References: <9cbl2q0kca@news1.newsguy.com> Message-ID: <9ci1lc2k56@news2.newsguy.com> "Harald Kirsch" wrote in message news:yv2y9sm469d.fsf at lionsp093.lion-ag.de... [snip] > > Fortunately, the parser just calls .read(N) on its > > *That* was the information I was missing. The rest is then more or > less straighforward, as your example code demonstrates. This is not a formally documented constraint on the parser (alas, until and unless interfaces or protocols do get formalized in Python, we'll have to live with lots of informal mentions of [e.g.] "file-like objects" that never clarify WHICH file-object methods do need to be implemented...), but for the current implementation it can be determined experimentally. Code inspection on the library sources AND running a few experiments on an instrumented filelike object (that delegates all to a file but also prints out what is being called) to confirm one's understanding gives you that with a few minutes' investment. Alex From swart at deadspam.com Thu Apr 26 00:46:44 2001 From: swart at deadspam.com (Steve Wart) Date: Thu, 26 Apr 2001 04:46:44 GMT Subject: Integer micro-benchmarks References: <5MLF6.98590$166.1840160@news1.rdc1.bc.home.com> Message-ID: 1.2GHz Athlon, Win2K SP2, 512Mb RAM -> David 333 PII, Win2K SP1, 192Mb RAM -> Steve [I gotta get in Redmond's good books :)] "David Simmons" wrote ... > "Steve Wart" wrote ... > > Here is some more silliness. > > > > If you take the #triangle method and turn it into a block closure, as below, > > in VW it takes almost 10 seconds (on my 333 PII) > > Really! 10 seconds versus 7 seconds? > > Good goobley goo. I just ran it on VW and got the times: > > 1784ms for 9,000,000 loops using local to the block. > > 4102ms for 9,000,000 loops using as a method temp (shared with the block). > How come I have about a 30% difference and yours is over 100%? Is this a CPU caching thing? > The same runs on SmallScript were: > 1313ms vs 1380ms respectively This is the AOS VM? I wonder how it would do on the .NET VM? If you are not at liberty to say, tap twice :) Does SmallScript come with AOS? Steve From warren-postma at home.com Fri Apr 27 19:43:25 2001 From: warren-postma at home.com (Warren Postma) Date: Fri, 27 Apr 2001 23:43:25 GMT Subject: G3 AllInOne on Ebay References: Message-ID: I blame outlook express, or incredible personal stupidity, or both. From dalke at acm.org Tue Apr 10 20:43:56 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 10 Apr 2001 18:43:56 -0600 Subject: Python Books for 2002 References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> <9av8vs$68g$1@panix3.panix.com> <9avhkm0tjh@drn.newsguy.com> Message-ID: <9b09j0$c1m$1@slb6.atl.mindspring.net> Phil Martel wrote: >Grant Griffin wrote: >> In that vein, one significant advantage that Python books >> have over online docs is that they have much better indices. >> (Also, you can take 'em into the potty.) >One word: "laptop" Two more words: "wireless ethernet" Andrew dalke at acm.org From aleaxit at yahoo.com Thu Apr 12 04:29:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Apr 2001 10:29:59 +0200 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> <9b203102hla@news2.newsguy.com> <3ad54f9f$0$36580$e2e8da3@nntp.cts.com> Message-ID: <9b3p2k02mvp@news1.newsguy.com> "Robert Johnson" wrote in message news:3ad54f9f$0$36580$e2e8da3 at nntp.cts.com... [snip] > > What platforms, exactly, do you want to target? Why does your app > > need to be a "web" one (DOES it)? Why does it need to be client-side > > (DOES it)? [snip] > I think that Java might be the only option. Only if client-side is a must, and it doesn't seem to be. > I doubt I would run into many > Macs as the target would be scientists who would more than likely use > Windows or Unix/Linux boxes. Plus, about half our customers are Europe/Asia > and I don't believe Mac has much foothold there. I think Mac as a higher market-share in Italy than in the US, not that this is very relevant to your problems. > But the fact that they > may use Unix/Linux would seem to suggest a Java solution. Nah, a server-side solution is probably preferable, and in that case Python is no doubt better (if there are any heavy computations involved, you can speed them up by using Python to control speedy extension modules -- Numeric and PIL are great for their jobs, and since you've already indicated that your target _server_ is NT, you can also use just about any useful COM components you may have around if they help). Alex From paul.moore at atosorigin.com Tue Apr 24 10:21:11 2001 From: paul.moore at atosorigin.com (Paul Moore) Date: Tue, 24 Apr 2001 16:21:11 +0200 Subject: How best to write this if-else? References: Message-ID: <66fu5qax.fsf@atosorigin.com> Mike C. Fletcher writes: > Hmm, what does Perl do when there's multiple threads using the same re > concurrently? Segfault :-) Perl's threading is still broken. Perl 6, maybe... Paul. From bos at hack.org Sun Apr 1 06:39:51 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sun, 01 Apr 2001 12:39:51 +0200 Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com><71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com><7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: <3AC70577.779E4238@hack.org> deadmeat wrote: > That is what happens in Pascal This is not Pascal. -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From emile at fenx.com Sat Apr 21 10:09:05 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 21 Apr 2001 07:09:05 -0700 Subject: how to write file with configparser References: <3ae15ddc.7279927@news.xs4all.nl> Message-ID: <9bs4gc$b0jga$1@ID-11957.news.dfncis.de> That should work. Do you have the config.ini elsewhere opened and locked or perhaps insufficient rights to the file? -- Emile van Sebille emile at fenx.com --------- wrote in message news:3ae15ddc.7279927 at news.xs4all.nl... > I,m using the ConfigParser module to read my ini file. After my > program has ran I want to update the ini file. With configdict.set I > modify an option to a new value. > > How do I write this back onto my file system? > > cfgfile=open('config.ini',' rw') > ... > cfgdict.set(....) > ... > cfgdict.write(cfgfile) > > This gives an IOerror: (0,Error) > > What is the right way to do this? > > TIA, > Hans From shindich at itginc.com Wed Apr 4 23:32:58 2001 From: shindich at itginc.com (Alex Shindich) Date: Wed, 4 Apr 2001 20:32:58 -0700 Subject: PEP 245 Message-ID: I guess I should just give up my fight against PEP 245... It is clear to me that either I am the only one who things that interfaces, at least in the proposed form, are next to useless in Python, or those who agree with me do not read the news group, or simply don't care enough to reply. It is also obvious to me that there is serious thrust for interface adoption coming from "Digital Creations"... (Do new Guido's employers have a lot of say in the situation? I can speculate that they do... but then again I don't know for sure.) One thing still bothers me -- Perl people will have a real reason to laugh. Indeed, interfaces in a loosely typed language that supports introspection -- that's a real joke! Regards, AlexS From mal at lemburg.com Fri Apr 20 06:48:11 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 20 Apr 2001 12:48:11 +0200 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) References: <190420011747549837%jwbaxter@olympus.net> Message-ID: <3AE013EB.BE299799@lemburg.com> "John W. Baxter" wrote: > > In article , M.-A. > Lemburg wrote: > > > I'm sure this proof of > > concept will raise a few more questions regarding the > > usefulness of switching to rationals for literals like > > 1.123. > > I might be more tempted to create a Rational containing 1.123 by writing > Rational(1123, 1000). (Not to mention the opportunities for > obfuscation: Rational(2246, 2000) being just a non-obscure one. > > And Paul makes a good case for Rational("1.123") I think. Well, Moshe's plan is to have 1.123 result in a Rational(1123, 1000) being created (instead of a Python float). The extension should make playing with this idea a whole lot easier. -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From dalke at acm.org Sun Apr 22 07:50:30 2001 From: dalke at acm.org (Andrew Dalke) Date: Sun, 22 Apr 2001 05:50:30 -0600 Subject: A list of Python users? References: Message-ID: <9bugi1$i2v$1@slb2.atl.mindspring.net> Daniel Klein wrote: >I've search Google Groups and found a few names mentioned but >I'm looking for more. Young whippersnappers. Think a search engine does everything. http://www.python.org/psa/Users.html Note that Google is in that list! BTW, the PSA page says: > The PSA no longer serves a purpose I beg to differ. The PSA also showed the list of names of people who used Python. I used to be there - in the teens if I recall (I did a good job of renewing my membership early :) Also, there are at least six pharma/biotech companies missing from that list. Andrew dalke at acm.org From rdsteph at earthlink.net Sat Apr 7 13:19:32 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 07 Apr 2001 17:19:32 GMT Subject: Boa: Is it ready for simple gui design??? Message-ID: <3ACDEF66.BE33779E@earthlink.net> I know its alpha, I know its not finished, many widgets and controls are not yet implemented. I found the online help files, they are pretty good. I only need to do fairly simple data input and output forms and front ends at this time. Before I spend the considerable time to learn the GUI designer part of Boa Constructor well enough to use it, can anyone tell me whether it is far enough along to be able to use it to design simple GUI front ends?? I do not mind being artificially restricted to whichever buttons, menus etc. are already implemented in Boa Constructor, as long as there are enough to get along with for simple use, and it is far enough along to generate working frame and widget combinations, because:::>>> I find the basic design, style, and ideology behind Boa Constructor to be really beautiful and just what I am looking for... check it out if you haven't already...is it free for now as far as I can tell??? Will it be costly when it is completed, or will a version of it always be available for free??? Is it open source?? Does anyone know??? Has anyone used it??? Does anyone have an opinion about Boa Constructor??????? It lloks to me like a beautiful, reasonably easy to learn and use, visual GUi designer for wxPython. All comments greatly appreciated... Ron Stephens From hinsen at cnrs-orleans.fr Tue Apr 10 08:24:28 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 10 Apr 2001 14:24:28 +0200 Subject: Chocolate [was Re: Python Books for 2002] References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> <11A279245FF128F8.7A0E8AF314DD0135.E3C0007C3BD57C8C@lp.airnews.net> <9akknn0p3@news2.newsguy.com> <9aupgl01lvq@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > > Come to France - chocolatewise this is a highly civilized country. > > And not _only_ chocolatewise -- in bread AND wine AND cheese, as well I strongly disagree about bread, that's the only food I have to import. Back to Python: from Europe.France import chocolate, wine, cheese # comment out one of from Europe.Italy import chocolate, wine, cheese # these lines from Europe.Germany import bread from Europe.Netherlands import vla ... for food in dir(): if food[:2] != '_': eat(food) -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From chris.gonnerman at usa.net Sat Apr 21 01:46:23 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 21 Apr 2001 00:46:23 -0500 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: <9blulk$dtj$1@panix6.panix.com> Message-ID: <007101c0ca26$6a79a960$a100000a@local> ----- Original Message ----- From: "Brandon J. Van Every" Subject: Re: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha > "Chris Gonnerman" wrote in message > news:mailman.987738512.19013.python-list at python.org... > > > > I'm not sure how it's a consequence. Your copyright protects you exactly > > as much with or without the source code. Ignoring patches/diffs is about > > as hard as ignoring spam (which I'm sure you do every day, just like me). > > Is that a deliberately dumb comment, or are you just unaware that one of the > rights of copyright is the right to make derivative works? Let's not get rude, even in a divisive thread like this. The beauty of this list has always been the politeness (esp. compared to certain other language- oriented newsgroups/lists). Yes, I am aware of that fact, and I am also aware that the right is not automatically granted. If he writes his license correctly (from his POV, allowing no derivative works) then my assertion is correct. Or are you saying I have misunderstood something else? After all, I am no lawyer. > It is way easier > to make a derivative work if you have the source code. In the real world, > if it's easier for someone to transgress, then your copyright enforcement > problem is more difficult. True. But in the real world, harder transgressions simply attract more determined transgressors. As our friend Kamikaze says, there are tools to help decompile his code, leading to his cranky reaction. From tjreedy at udel.edu Wed Apr 11 20:06:18 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 11 Apr 2001 20:06:18 -0400 Subject: Komodo in violation of Mozilla Public License? References: Message-ID: <9b2r54$f3o$1@news.udel.edu> from http://mozilla.org/editorials/mozilla-overview.html [Occasionally the multiple roles played by a contributor cause confusion. For example, Netscape is a major contributor to the Mozilla code. At the same time, Netscape uses the Mozilla code as the basis of its Netscape 6 product. This has caused some people to mistakenly believe that the Mozilla code and Netscape 6 are the same thing. This is not correct.] Anyone is free to use Mozilla code to create a product, and to combine Mozilla code with other code to create that product. Netscape does this, starting with Mozilla code, adding a set of Netscape specific items and additional code, and creating Netscape 6. Anyone is also free to use a subset of the Mozilla code in a product. Many companies do this, using the Gecko layout engine, for example. From mal at lemburg.com Fri Apr 20 10:02:26 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 20 Apr 2001 16:02:26 +0200 Subject: ANN: Experimental Number Types (Integer, Rational, Floats) References: <190420011747549837%jwbaxter@olympus.net> <5.0.2.1.0.20010420083412.02364290@mail.inet.com.br> Message-ID: <3AE04172.86F37BF1@lemburg.com> Carlos Ribeiro wrote: > > At 12:48 20/04/01 +0200, M.-A. Lemburg wrote: > >Well, Moshe's plan is to have 1.123 result in a Rational(1123, 1000) > >being created (instead of a Python float). The extension should > >make playing with this idea a whole lot easier. > > The problem is that, as of now, you have no way to know if the user > supplied you with > > Rational(1.123) > > or > > Rational(1.122999999999...) # as many 9's as your platform supports > > So I think that creating rationals must use either the Rational(a/b) form, > or the Rational(string) form. Please bear in mind that, for Moshe's plan to > work, it would be needed to convert the number to the rational format at > the parser level, when it is still represented as a string. Right, that's the idea. > Using a float to make rational value does not make sense given all problems > of the float representation. True, it's just there for convenience and to display the fact that neither IEEE floats nor mx.Number.Floats cannot represent fractions to an arbitrary precision. > The result can't be trusted, except if you > supply both the float and the number of decimal digits you are working with > (example: Rational(1.123, digits=3). This way the conversion routine can > round up the number before trying to convert it to the rational format. That would be a new Decimal type then :-) (which is actually what I'm after, since I need them for database interfacing) -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From samschul at pacbell.net Wed Apr 25 17:46:19 2001 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 25 Apr 2001 14:46:19 -0700 Subject: Graduate thesis on Python-related subject References: Message-ID: I found that the amount of lines of code removed due to refractoring the application is never recognized by management in defining the efficiency of a program. Also scripting languages tend to provide better wrappers, that hide the complexity of an application. Sam Schulenburg wrote in message news:mailman.988227001.4064.python-list at python.org... > In comp.lang.python, you wrote: > > > >I'm planning to do my graduate thesis (pro gradu) for MsC on (yet > >unconfirmed and still vague) subject tightly related to Python. In > >short, the main goal is to test hypothesis that a program (or some other > >piece of code) written in a very high level language or scripting > >language (specifically Python in my study) is 3-10 times shorter > >measured in lines of code than a program written in traditional system > > I consider this a somewhat naive hypothesis to test. If you take a problem that > needs primitives easily expressed in Python, and not in , > sure, the program is shorter. > (obvious example: string processing (although Perl is better at it)). > > On the other hand, if I select a problem oriented for a logical language, and > I compare Python with Prolog, I know I can describe the problem in less code > in the latter langyage. > > > > I consider #lines of code (in whatever definition of line) not very useful. In > fact, in the past years, I have moved away from considering #lines anything > near relevant. > The real criterium of choosing a language is thus different. I haven't figured > out what exactly, but concepts like 'readability' play an important role imho. > > >forthcoming research would be to study measuring overall (why, what, > >how) and to speculate on scripting languages in general. I know that > >the main subject (measuring Python programs) would be kind of "stating > > Covering everything is way too complex imho. > There are good reasons for us to end up with a particular choice. In general, > we consider every choice we make the best option at that time. > That is valid for just about everything, from operating systems, editors, > favourite language, to the colour of the furniture. > > In other words, I choose Python when I consider Python to be the best candidate > for the job, and I choose C++ when I consider that language better for the > particular problem I need to solve. > > Therefore, I don't understand what you gain by comparing solving the same > problem in 2 languages, and comparing the result. > > >research, so no new scientific results is required) is that hopefully > >this kind of work could be ("sort of") referenced and "the obvious" > > Getting stuff mentioned is not that difficult. Getting stuff noticed is the > real challenge. In the latter case, you need to have a firm base of logical > assumptions. As I tried to do above, I am not convinced that #lines is anything > near relevant. > > >would be somewhere stated explicitely. Also my intention would be to > >study (possible) special features of Python. Now (after the short > >introduction :-), my question would be: > > > >Is there "official" (or other) interest in such study? > > > >The reason for me to ask this is that in Helsinki University we are > >supposed to write graduate thesis in one's native language, but it is > >possible to write it in english. Now, I'm still not sure whether I > >should write it in english. If there would be some real interest for > > You should reverse the question imho. > School is the last place where you can spend time learning. As soon as you > finish school, and go to work, you are supposed to work. That is, you perform > tricks you learned on school upon request from your boss. > (I know this is a somewhat negative attitude towards work, but he, I work at a > university... :-) ) > The goal of work (and your boss) is to earn money, not to develop you further. > > Learning anything after leaving school is a lot more difficult than before > leaving school. Also, at school you are allowed to fail. If you try writing > English, but it doesn't go as planned, you'll just need more time to finish the > thesis. In a company, you have a hard deadline of finishing a report, and if > you fail, you lose a customer (not something that you want to happen too often). > > >this kind of study, I could very well write it in english. (If I would > >get e-mail from the BDFL, I wouldn't have to hesitate at all ;-). > >Related, one has to do an explicit application to be allowed to write > >the thesis in english and a short motivation from someone other than me > >wouldn't hurt. :-) > > At the end of the year, there is 1 big Europe. Do you think finnish is the > common language that will be spoken in Europe ? I have some serious questions > with that assumption. In that perspective, your school should prepare its > students for a future in Europe rather than Finland. > (I have to confess that don't know whether Finland is part of Europe, but even > if it is not, having a big neighbour 'Europe' on the other side of the border > does have its impact). > For you, it means you can move around in Europe if you choose to do so. > > > Albert > -- > Signature is being repaired, sorry for the inconvenience > From aleaxit at yahoo.com Thu Apr 19 07:35:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Apr 2001 13:35:10 +0200 Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> Message-ID: <9bmihc09eh@news1.newsguy.com> "D-Man" wrote in message news:mailman.987629727.6736.python-list at python.org... > On Wed, Apr 18, 2001 at 01:43:54PM +0200, Martin von Loewis wrote: > | neelk at alum.mit.edu (Neelakantan Krishnaswami) writes: > | > | > Hi Paul, I think I will have to disagree with you on this point. ints > | > and arrays are not objects in Java, whereas the corresponding things > | > in Python are. > | > | This is OT, but arrays in Java are objects. You create them with new, > | they follow an inheritance hierarchy, can be polymorphically passed > | where Object is allowed, and support introspection. > > They are objects (of a sort, more like a C struct IMO), but they do > not inherit from java.lang.Object and thus can't be passed to a method > that wants a java.lang.Object. Not in the Java I know. > Also where is the inheritance hierarchy for arrays you mentioned? In Java, if X inherits from Y, then array-of-X inherits from array-of-Y. This, given mutability, is unfortunately wrong, and breaches Java's compile-time type-safety: you can pass an array-of-X to a method as an array-of-Y argument, and the method then tries to stick into the array a Y instance (compile-time correct) that is not an X -- and you get a runtime type violation (specs mandate that a specific exception be raised for this, fortunately, so you don't get random undiagnosed errors as you might for similar array bloopers in C++). Alex From SBrunning at trisystems.co.uk Mon Apr 2 10:46:21 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 2 Apr 2001 15:46:21 +0100 Subject: Self descibing scripts Message-ID: <31575A892FF6D1118F5800600846864D78BA5B@intrepid> > From: Neil Benn [SMTP:neil.benn at cambridgeantibody.com] > Oooo, thanks Fredrik, that's close - the only problem is that > it > doesn't return parameters required for the methods. D'ya know if it is > possible to do that? Neil, See Alex Martelli's posting on Friday, subject line 'how query function args'. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From tim.one at home.com Wed Apr 18 19:41:21 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 18 Apr 2001 19:41:21 -0400 Subject: Howto: testall not in verbose mode In-Reply-To: <9bgs11$1vg@news.or.intel.com> Message-ID: [Miki Tebeka] > To check python I run python -c "import test.testall". > Everything works fine but I get the message: > > CAUTION: stdout isn't compared in verbose mode: a test > that passes in verbose mode may fail without it. > > How do I run the same tests not in verbose mode? As the comment at the top of testall.py says, # Backward compatibility -- you should use regrtest instead of # this module. Do python Lib/test/regrtest.py instead, or, even better make test if you're on a box with a Unixish OS. From jp at NOSPAMdemonseed.net Fri Apr 20 20:28:16 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Sat, 21 Apr 2001 00:28:16 +0000 Subject: PyQT legalities (was Re: Tkinter and wxPython) References: <3AE06DBC.4CD95EA1@qvlinc.com> Message-ID: <07kqb9.3b7.ln@demonseed.net> Cameron Laird wrote: > In article , wrote: >>I would love to use PyQT, but doesn't it require shelling out $$$ to trolltech >>for a QT-win32 license? > . > No! > It's a good question. Boudewijn has researched this > carefully, though, and talked to the Trolltech people. > His unequivocal conclusion, worked out with Trolltech's > knowledge: "PyQt is free for Windows and Unix." While this may be ok in theory, I am still unable to find PyQT binaries for win32. Could someone with a QT-win32 license compile PyQT and put it up somewhere for others to use? -jason From ed_tsang at yahoo.com Mon Apr 23 16:54:08 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Mon, 23 Apr 2001 20:54:08 -0000 Subject: python pickle, __getstate__, setstate__ problem Message-ID: <9c24pg+9qs6@eGroups.com> I have a problem about my script in initializeing the class attribtes and, pickle them and load them back again in the next invokation. Here is some backgrond: The script that I wrote is for drawing the primitives, received from and sent to the Implementation under test. The reason I am using pickle is to store the state of the Gui, like all the data user entered to the script, so that when the scirpt got invoked again, the ser do not need to reenter te again. All the states are stores as class attributes in class GuiState. To remember the last known state of Gui. Class Gui either load the the last known instance of GuiState State through using python pickle or create a new instance when that failed or the first time the script is invoked. When the suer click on quit, that will invoke the quit function of class Gui. Class Gui will then update all the class GuiState attributes through calling the updateAttribute of class GuiState. Then store the object as persistence objects through calling pickle.dump. But I ran into two problems: 1. whenever some of the states are not given values (e.g. user no selecting a input file or output file) the whole script hangs on quit. I traced that to inside the function of updateAttribute of Class Gui State when it try to append the elements of inputFileList to self.inputFileList, it will have an infinite loop!!! That is why I comment those lines out. But without actually copying the contents, I doubt the Class GuiState will get the values of the attributes, as I suspect what I am doing in the code that I sent you just copy the reference which will be destroyed afer the porcess exists .... I print out the list of inputFileList & outputFileList: inputFile List ['/la02/qa/etsang1/ts/9005016/modules/gui/1'] outputFileList [] outputFileList has nothing in it as no outputFile has been selected. ..... Thatlets me suspect if the way I initialise the two list simply but assigning [] to them in the init mehtod of Class GuiState is correct or not ... signed .... 2. when some of the attributes are not set during the last invokation of script, even though they are initiliazed. There seems to have problem in loading them back in through pickle. Instead of getting attributes that contain the initilized values, an istance is returned cauaing error!! Sample error message when when user does not set self.type as below, even though they have been set as zero before: Exception in Tkinter callback Traceback (innermost last): File "/sd/ps/alexma/proj/ntharn/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ File "msggen.py", line 284, in buildMSC value = self.type.get() File "/sd/ps/alexma/proj/ntharn/lib/python1.5/lib-tk/Tkinter.py", line 119, in get ValueError: invalid literal for int(): PY_VAR5 start shelf attributes end self inputName and outputName ['/la02/qa/etsang1/ts/9005016/modules/gui/1'] [] end shelf all attributes [1] + Terminated python msggen.py Acutally I suspect the attributes have been shelved at all .... as when the program loads and try to get the values, it found an istance!! as shown in above error message!! Can someone kindly have a look at the the way I shelf, relaod the attributes?? Or are they due to another problem. I know thisis a long posting .. but not many people seems to know pickle nor python on my end to provide assitance. Thanks Below is the code: the new stuff is marked by #### from Tkinter import * from tkFileDialog import * from Dialog import Dialog import re import string import time import os import stat import math # to preserve class instance attributes import pickle def makeMenu(gui): # make menu button : "File" File_button = Menubutton(gui.menuframe, text='File', underline=0) File_button.grid(row=0, column=0, sticky=W) tempText = Text() color = tempText.cget('background') Dummy_button = Menubutton(gui.menuframe, width=63, activebackground=color, highlightcolor='Blue',text='', underline=0) Dummy_button.grid(row=0, column=1, sticky=W) Dummy_button.menu = Menu(Dummy_button) File_button.menu = Menu(File_button) File_button.menu.add_command(label='Open Test Log ...', underline=0, command=gui.openfile) File_button.menu.add_command(label='Save Message Sequence Chart...', underline=0, command=gui.save) File_button.menu.add('separator') File_button.menu.add_command(label='Quit', underline=0, command=gui.quit) File_button['menu'] = File_button.menu gui.menuframe.tk_menuBar(File_button, Dummy_button) def getTabs(line): num=0 for char in line: if (char != '\t'): break num=num+1 return(num) ######################################################333 # customer object to hold the state of class Gui class GuiState: def __init__(self): self.inputName = StringVar() self.outputName = StringVar() self.inputName.set("") self.outputName.set("") self.inputFileList = [] self.outputFileList = [] self.stackname = StringVar() self.stackname.set("") self.name = StringVar() self.iut = StringVar() self.name.set("") self.iut.set("") # define all buttons self.type = IntVar() self.type.set(0) # return data representaton for pickled object def __getstate__(self): oldDict = self.__dict__ # get attribute dictionary del oldDict['inputName'] del oldDict['outputName'] del oldDict['inputFileList'] del oldDict['outputFileList'] del oldDict['stackname'] del oldDict['name'] del oldDict['iut'] del oldDict['type'] return oldDict # restore object state from data representation generated by _getstate__ def __setstate__(self,dict): self.inputName = open(dict['inputName']) self.outputName = open(dict['outputName']) self.inputFileList = open(dict['inputFileList']) self.outputFileList = open(dict['outputFileList']) self.stackname = open(dict['stackname']) self.name = open(dict['name']) self.iut = open(dict['iut']) self.type = open(dict['type']) def updateAttribute (self,inputName,outputName,stackname,name,iut,type,inputFileList,outpu tFileList): print "start shelf attributes" self.inputName.set(inputName) self.outputName.set(outputName) print "end self inputName and outputName" print inputFileList, outputFileList #if inputFileList != []: # print "shelf nonempty inputFileList" # map(self.inputFileList.append,inputFileList) # print "end shelf inputFileList" #else: # print "self empty inputFileList" # self.inputFileList = [] #if outputFileList != []: # print "self nonempty outputFileList" # map(self.outputFileList.append,outputFileList) # print "end self outputlist" #else: # self.outputFileList = [] self.inputFileList = inputFileList self.outputFileList = outputFileList self.stackname.set(stackname) self.name.set(name) self.iut.set(iut) self.type.set(type) print "end shelf all attributes" return ###################### END NEW############################# class Gui: def __init__(self, master, img): self.master = master; # define each frame # main frame is at the very top # button frame is the command button frame # list frame is used for all of the list boxes # quit frame is used for the quit button self.headerframe = Frame(self.master, width = 80) self.headerframe.grid(row=0, column=0, sticky='W') self.menuframe = Frame(self.headerframe, relief=RAISED, borderwidth=2, width = 80) self.menuframe.grid(row=0, column=0, sticky='W') makeMenu(self) self.logoframe = Frame(self.headerframe, width = 80) self.logoframe.grid(row=0, column=0, sticky='E') # column affects locaton of logo self.buttonframe = Frame(self.master, width = 80) self.buttonframe.grid(row=1, column=0, sticky='W') self.octetframe = Frame(self.master, width = 80) self.octetframe.grid(row=2, column=0, sticky='W') self.octetframe2 = Frame(self.master, width = 5) self.octetframe2.grid(row=80, column=0, sticky='W') self.listFrame = Frame(self.master, width = 80) self.groupsList = Frame(self.listFrame, width = 50) self.groupsList.grid(row=0, column=0, sticky=N) # intialize Gui state class try: # depersist and display an object self.stateObj = pickle.load(open("msc.dat","rb")) except: ########################## NEW START ####################### # invoke the first time self.stateObj = GuiState() self.inputName = StringVar() self.outputName = StringVar() self.inputName.set(self.stateObj.inputName) self.outputName.set(self.stateObj.outputName) self.inputFileList = self.stateObj.inputFileList self.outputFileList = self.stateObj.outputFileList self.stackname = StringVar() self.stackname.set(self.stateObj.stackname) self.name = StringVar() self.iut = StringVar() self.name.set(self.stateObj.name) self.iut.set(self.stateObj.iut) # define all buttons self.type = IntVar() self.type.set(self.stateObj.type) ########################## NEW END ####################### self.counter = IntVar() self.ie = Checkbutton(self.buttonframe, text="Build ALL ", variable=self.type, onvalue = 1, offvalue =0) self.ie.pack() self.ie.grid(row=0, column=1, pady=10, sticky=W) self.build = Button(self.buttonframe, text="Build", command=self.buildMSC) self.build.grid(row=0, column=3) self.clear = Button(self.buttonframe, text="Clear", command=self.clear) self.clear.grid(row=0, column=4) # define all labels Label(self.logoframe, image=img).grid(row=0,column=4,sticky=E) # define all listboxes self.pdudfn = Text(self.octetframe, font='*-Courier-Bold-R-Normal-*-120-*', height=20, width=80) self.pdudfn.grid(row=0, column=0, sticky=W) self.pdudfn.tag_config('HIGHLIGHT', background="White") self.pdubuild = Text(self.octetframe2, font='*-Courier-Bold-R-Normal-*-120-*', height=5, width=80) self.pdubuild.grid(row=0, column=0, sticky=W) self.pdubuild.tag_config('HIGHLIGHT', background="White") # define all scrollbars self.pdudfn.scrollY = Scrollbar(self.octetframe, orient=VERTICAL) self.pdudfn['yscrollcommand'] = self.pdudfn.scrollY.set self.pdudfn.scrollY['command'] = self.pdudfn.yview self.pdudfn.scrollY.grid(row=0, column=1,sticky='NS') self.pdubuild.scrollY = Scrollbar(self.octetframe2, orient=VERTICAL) self.pdubuild['yscrollcommand'] = self.pdubuild.scrollY.set self.pdubuild.scrollY['command'] = self.pdubuild.yview self.pdubuild.scrollY.grid(row=0, column=1,sticky='NS') def buildMSC(self): value = self.type.get() if value == 1: self.buildAllMsc() self.saveArrows() def clear(self): self.pdubuild['state']=NORMAL self.pdubuild.delete("0.0", END) self.pdudfn.delete("0.0", END) self.pdubuild['state']=DISABLED filename = self.outputName.get() try: self.fd = open(filename,"w") except IOError: Dialog(self.master, text="Cannot open file to clear.", title="Error", bitmap='error', default=0, strings=('OK',)) return self.fd.close() def save(self, event=None): defaultfile = self.inputName.get() if self.type.get() == 1: Dialog(self.master, text="Application is under auto mode. File names are self generated.", title="Error", bitmap='error', default=0, strings=('OK',)) return outputName = asksaveasfilename(defaultextension=".arr", filetypes=["{Message Sequence Chart} {.arr}"], initialfile="%s.arr"%defaultfile ) self.outputName.set(outputName) try: self.fd=open(outputName,"w"); self.fd.close(); except IOError: Dialog(self.master, text="Cannot open file to save.", title="Error", bitmap='error', default=0, strings=('OK',)) except: pass def buildFileList(self,arg,dirname,files): inputfile = self.inputName.get() if inputfile == "": return inputfile = os.path.basename(inputfile) for file in files: if re.search(inputfile,file): fullpath= os.path.join(dirname, file) if fullpath[-4:] == '.arr': pass else: self.inputFileList.append(fullpath) self.outputFileList.append(fullpath+'.arr') self.inputFileList.sort() self.outputFileList.sort() def openfile(self, event=None): try: inputName = askopenfilename(filetypes=["{Test Log Files} {*}"]) if inputName == "": Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return self.inputName.set(inputName) self.inputFileList.append(inputName) outputName = inputName + '.arr' self.outputName.set(outputName) self.outputFileList.append(self.outputName) except: Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return def quit(self, event=None): ########################## NEW START ####################### self.stateObj.updateAttribute (self.inputName,self.outputName,self.stackname,self.name,self.iut,self .type,self.inputFileList,self.outputFileList) self.menuframe.quit() # persist and dump object attributes. pickle.dump(self.stateObj, open("msc.dat","wb")) ########################## NEW END ####################### def ctfPrint(self,string): if self.outputName.get() == "": self.save() #Open file and append string fd = open(self.outputName.get(),"a+") fd.write(string) self.pdudfn.insert(END, string) #Close file fd.close() def createTestList(self): line = None inputfile = self.inputName.get() try: fd = open(inputfile, 'r') except IOError: Dialog(self.master, text="Cannot open file", title="Error", bitmap='error', default=0, strings=('OK',)) return # display status to stdout and status window stateString = "\nBuild MSC for %s"%inputfile print stateString self.pdubuild.insert(END, stateString) trclist = fd.readlines() strip = string.strip for x in range(0,len(trclist)): trclist[x]=strip(trclist[x]) fd.close() idx = 0 counter = 0 tstlist = [] for line in trclist: if line == "": # skip blank line continue if line[0] == "-": counter = counter+1 if counter == 1: tstlist.append([]) if counter > 0: tstlist[idx].append(line) if counter == 4: idx = idx + 1 counter = 0 return tstlist def getData(self): self.name.get() self.iut.get() self.inputWindow.destroy() def stackData(self): self.inputWindow = Toplevel(self.master) self.inputWindow.geometry("+%d+%d" % (self.master.winfo_rootx ()+180, self.master.winfo_rooty()+180)) self.inputWindow.title("Enter stack data") Label(self.inputWindow, text ="Please enter the 2 letter prefix for each stack seperated by a space.").grid(row=1, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text = "There must be a minimum of 2 stacks and a maximum of 5.").grid(row=2, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text = "The second entry is the IUT i.e Xx Yy Zz").grid(row=3, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text="Stack Names:").grid(row=4, sticky=W) self.e1 = Entry(self.inputWindow, textvariable=self.stackname, width=35) self.e1.grid(row=4, column=1, sticky="EW", pady=1) okButton = Button(self.inputWindow, text="Ok", command=self.getData) okButton.grid(row=5, column=1, sticky=W, pady=6) self.inputWindow.wait_window() def buildAllMsc(self): index = 0 listDir = os.getcwd() os.path.walk(listDir,self.buildFileList,None) if self.inputFileList != []: for file in self.inputFileList: self.inputName.set(file) self.outputName.set(self.outputFileList[index]) self.saveArrows() index = index +1 self.master.update() self.pdubuild.insert(END, "Processing Completed") else: Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return def saveArrows(self): tstList = None temp = None stackList = {} numStacks = None upper = 0 lower = 0 mngmt = 0 other = 0 columnWidth = None emptySpace = None arrowLine = None stack = None emptyLine = None space = "" stacknames = "" upperTx = None upperRx = None lowerTx = None lowerRx = None mngmtTx = None mngmtRx = None otherTx = None otherRx = None lowerFunction = None upperFunction = None mngmtFunction = None otherFunction = None test = None testList = None event = None eventList = None line = None function = None if self.outputName == "": save() tstList = self.createTestList() if tstList == None: return temp = self.stackname.get() # first time invoked if self.counter.get() == 0: self.stackData() temp = self.stackname.get() self.counter.set(1) # this is no the first run, stackname should be stored already temp = self.stackname.get() if temp == "": return # clear msc window self.pdudfn.delete("0.0", END) stackList = string.split(temp) numStacks = len(stackList) upper = 0 lower = 0 mngmt = 0 other = 0 if numStacks > 2: lower = 2 if numStacks > 3: mngmt = 3 if numStacks > 4: other = 4 columnWidth = 70/(numStacks-1) emptySpace = " "*columnWidth arrowLine = "-"*(columnWidth-1) stack = "|%s"%emptySpace emptyLine = stack*(numStacks-1) + "|\n" space = "" stacknames = "" for name in stackList: stacknames = stacknames + space + name space = " "*(columnWidth - len(name)+1) # Arrow for event travels from upper stack to the right? upperTx = "|%s>"%arrowLine + stack*(numStacks-2) + "|\n" upperRx = "|<%s"%arrowLine + stack*(numStacks-2) + "|\n" upperFunction = "|%s" + stack*(numStacks-2) + "|\n" lowerTx = stack + "|<%s"%arrowLine + stack*(numStacks-3) + "|\n" lowerRx = stack + "|%s>"%arrowLine + stack*(numStacks-3) + "|\n" lowerFunction = stack + "|%s" + stack*(numStacks-3) + "|\n" mngmtTx = stack + "|<--%s"%(arrowLine*2) + stack*(numStacks- 4) +"|\n" mngmtRx = stack + "|%s-->"%(arrowLine*2) + stack*(numStacks- 4) +"|\n" mngmtFunction = stack + "|%s" + stack*(numStacks-4) + "|\n" otherTx = stack + "|<----%s"%(arrowLine*3) + stack*(numStacks- 5) +"|\n" otherRx = stack + "|%s---->"%(arrowLine*3) + stack*(numStacks- 5) +"|\n" otherFunction = stack+ "|%s" + stack*(numStacks-5) +"|\n" split = string.split strip = string.strip search = re.search linecounter = 0 for test in tstList: evntsList = [] if linecounter < 1: self.ctfPrint(stacknames + "\n") linecounter = linecounter +1 isFunction = FALSE for line in test: if ((search( "CallFunc", line) != None) or (search ( "@event@", line) != None)): wordList = split(line) for word in wordList : if isFunction == TRUE : print "Found a primitive: %s"%word newLine = "Transmit : " + word evntsList.append(newLine) isFunction = FALSE break if word == "CallFunc": isFunction = TRUE if (search("@event@", word)) != None : word = re.sub("@event@", "", word) print "Found an event: %s"%word newLine = "Received : " + word evntsList.append(newLine) break for event in evntsList: function = split(event)[2] extra_info = split(event, function)[1] extra_info = strip(extra_info) if event[0:8] == "Transmit": if event[14:16] == stackList[upper]: function = function + " "*(columnWidth-len (function)) extra_info = extra_info + " "*(columnWidth-len (extra_info)) self.ctfPrint(upperTx) self.ctfPrint(upperFunction%function) self.ctfPrint(upperFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[lower]: function = " "*(columnWidth-len(function)) + function extra_info = " "*(columnWidth-len (extra_info)) + extra_info self.ctfPrint(lowerTx) self.ctfPrint(lowerFunction%function) self.ctfPrint(lowerFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[mngmt]: function = emptySpace + "|" +" "* (columnWidth-len(function)) + function extra_info = emptySpace + "|" +" "* (columnWidth-len(extra_info)) + extra_info self.ctfPrint(mngmtTx) self.ctfPrint(mngmtFunction%function) self.ctfPrint(mngmtFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[other]: function = (emptySpace + "|")*2 +" "* (columnWidth-len(function)) + function extra_info = (emptySpace + "|")*2 +" "* (columnWidth-len(extra_info)) + extra_info self.ctfPrint(otherTx) self.ctfPrint(otherFunction%function) self.ctfPrint(otherFunction%extra_info) self.ctfPrint(emptyLine) elif event[0:8] == "Received": if event[14:16] == stackList[upper]: function = function + " "*(columnWidth-len (function)) extra_info = extra_info + " "*(columnWidth-len (extra_info)) self.ctfPrint(upperTx) self.ctfPrint(upperFunction%function) self.ctfPrint(upperFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[lower]: function = " "*(columnWidth-len(function)) + function extra_info = " "*(columnWidth-len (extra_info)) + extra_info self.ctfPrint(lowerTx) self.ctfPrint(lowerFunction%function) self.ctfPrint(lowerFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[mngmt]: function = function + " "*(columnWidth-len (function)) + stack self.ctfPrint(mngmtRx) self.ctfPrint(mngmtFunction%function) self.ctfPrint(emptyLine) elif event[14:16] == stackList[other]: function = function + " "*(columnWidth-len (function)) + stack*2 self.ctfPrint(otherRx) self.ctfPrint(otherFunction%function) self.ctfPrint(emptyLine) self.ctfPrint("hor \n") # Main function, run as a standalone program def main(): sep = os.sep print "Loading \n" root = Tk() tharnbase = os.environ['THARN'] img = PhotoImage (file=tharnbase+sep+'modules'+sep+'gui'+sep+'trillium.gif') gui = Gui(root,img) root.protocol('WM_DELETE_WINDOW', root.quit) root.title("TRILLIUM MSC Builder") root.iconname("MSCBld") root.mainloop() if __name__ == '__main__': main() From nessus at mit.edu Wed Apr 18 03:05:54 2001 From: nessus at mit.edu (Douglas Alan) Date: 18 Apr 2001 03:05:54 -0400 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: "Fredrik Lundh" writes: > Douglas Alan wrote: > > I'll tell you who I've listened to quite carefully: Guido, who has a lot > > of good ideas, and the designers of Lisp (eg, Dave Moon, John McArthy, > > Guy Steele, all of whom I've met personally) > so when did any of these guys last tell you that they know more > about programming languages and programming language design than you > do or ever will? They didn't -- I figured that out by myself. On the other hand, I think Dave Moon, at least, would have had qualms no telling me this if I had had the gall to tell him to "sit down. shut up. read. learn." |>oug From ed_tsang at yahoo.com Tue Apr 24 18:29:52 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Tue, 24 Apr 2001 22:29:52 -0000 Subject: How to write List Object to a File?? Message-ID: <9c4up0+m9u4@eGroups.com> I currently have a list and woulr like to store the contents into a text fiel whihc I can read back ... For example: a = ['a','b','c','d'] #do something like fd = open('txt.txt','w') fd.write(a) Traceback (innermost last): File "", line 1, in ? TypeError: read-only buffer, list What to do?? And I can't use pickle ... later on I would like to read it back... fd = open('txt.txt','r') iniInfo = fd.readlines() b=[] b = iniInfo[0] # copy list contents into c map(c.append,b) I think this also not work right ? Can someone kindly tell me how to do write and read a list to a file? Thanks From bas.vangils at home.nl Tue Apr 10 16:17:11 2001 From: bas.vangils at home.nl (Bas van Gils) Date: Tue, 10 Apr 2001 20:17:11 GMT Subject: python 2 latex References: <3dn19ofuk4.fsf@ute.cnri.reston.va.us> Message-ID: <3AD36BE6.C338AFFF@home.nl> Andrew Kuchling wrote: > Try py2tex: ftp://ftp.cwi.nl/pub/jeroenm/py2tex/ > > I'm working on a new release of py2tex with a Web page. It doesn't do > color, but patches would be cheerfully accepted. I'll definately give it a look. I'm not that good a programmer, but will see if I can make something of that source-code ;-) Bas -- Bas van Gils An invasion of armies can be resisted, but not an idea whose time has come. (Victor Hugo) From jmarshal at mathworks.com Wed Apr 4 18:03:05 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 4 Apr 2001 22:03:05 GMT Subject: "not x in" vs. "x not in" References: Message-ID: <9ag5mp$gm2$1@news.mathworks.com> Rainer Deyke wrote: > To me, 'a is not b' is confusing. It reads like 'a is (not b)', but acts > like 'not (a is b)'. When I want to check for non-identity, I always use > the form 'not (a is b)'. I suggest a new operator: a ain't b From Peek at LVCM.comNOSPAM Mon Apr 16 10:09:34 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Mon, 16 Apr 2001 07:09:34 -0700 Subject: do...until wisdom needed... References: <3ada7eb9$1_5@goliath2.newsfeeds.com> <9be78v0p7r@news1.newsguy.com> Message-ID: Please see my answer to Andrew Dalke in a sub-thread above... From chris.gonnerman at usa.net Sat Apr 21 10:55:57 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 21 Apr 2001 09:55:57 -0500 Subject: how to write file with configparser References: <3ae15ddc.7279927@news.xs4all.nl> <9bs4gc$b0jga$1@ID-11957.news.dfncis.de> Message-ID: <005f01c0ca73$2d6ad600$a100000a@local> wrote in message news:3ae15ddc.7279927 at news.xs4all.nl... > I,m using the ConfigParser module to read my ini file. After my > program has ran I want to update the ini file. With configdict.set I > modify an option to a new value. > > How do I write this back onto my file system? > > cfgfile=open('config.ini',' rw') Your problem is here. Read/write access is like this: cfgfile=open('config.ini', 'r+') > ... > cfgdict.set(....) > ... > cfgdict.write(cfgfile) > > This gives an IOerror: (0,Error) > > What is the right way to do this? > > TIA, > Hans From adjih at crepuscule.com Fri Apr 20 10:04:49 2001 From: adjih at crepuscule.com (Cedric Adjih) Date: 20 Apr 2001 14:04:49 GMT Subject: Performance measurements References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> <4EA03F26C2C54BAB.26EA5ACB1D9CD09A.30161D811690E63A@lp.airnews.net> <053ED57371C519DA.34D9DB7AB2BF67B7.D8F1EC202BF942A4@lp.airnews.net> Message-ID: <9bpfm1$a6h$1@ites.inria.fr> Cameron Laird wrote: > In article , > Douglas Alan wrote: > . > . > . >>I'm just quoting Guido from a while back. This is, of course, for >>doing number crunching using only bare Python and normal loops. If >>you use NumPy or PyAPL or some other highly optimized C-coded >>extension to do matrix operations on large matrices, then you can of >>course do as well as C, because your number crunching is really being >>done by C. This is assuming you can figure out a way to turn your >>number crunching problem into operations on large matrices. >> >>All this should come as no shock -- 100 times slower for an >>interpreted language is just par for a good interpreter. Before the >>spiffy Self compiler, state of the art was 10x slower than C for a >>really bitchin' highly optimized Smalltalk compiler. >> >>|>oug > > Help me, Mr. Alan. I remember a time when "100 times > slower for an interpreted language [was] just par for > a good interpreter." I have a lot of trouble repro- > ducing that today. If it'll help, I can pull some of > my '80s era hosts and interpreters from the closet. > Yes, I get a factor of between 100 and 300 for empty > loops, but, as soon as they do anything useful, the > multiple drops down to a range more like ten--definitely > not a hundred. I respectfully disagree. For most code that really need speed, a factor of 100 is plausible. x10 is probably the difference when you are using the python libraries. Myself I've tried (again) to write a alpha/beta solver for a game: the C++ version was x100 faster (quickly optimized to x1000), even though the board itself was already in C++. That's okay because I expected it. Another dramatic example of Python not top speed on some cases is the raytracer entry CuttySark at last ICFP programming contest: (eliminated because too slow) ; CuttySark is 25000+ times slower than the top entry (partly because of lack of algorithmic optimization), and 300+ times slower than a C++ entry, which, from the results, didn't look optimized either. [and for a good laugh, just try to run it on JPython.] Or even an image compression algorithm I prototyped in Python: it was 1000x slower than the first C++ version (now 10000x slower than the somewhat optimized version). Or even in the C parser I tried to interface with Python (): it takes forever. Then again, in all those cases, it's not a problem, since python is used to write quickly a prototype, and low performance is expected, but if Python is advertised to be 10x slower, this will generate lots of disappointement. > What I remember Guido saying is something like, "Maybe > Python is only one one-hundredth as fast on do-nothing > loops; I can live with that, that is, I have more im- > portant things to spend my time on" (that's heavily > paraphrased). > > I'll summarize: I don't understand what point is > being made when someone says, "Interpreters are 1% as > fast as compilers", and the evidence all has to do with > empty loops. It makes me think I'm missing something. I'd think it's true on any purely CPU intensive task in Python, and it can be easily be worse. > If you mollify the claim to 10% as fast, I ... well, in > that case, I can at least believe we're looking at the > same data. I'd think it's true when taking into account Python lib, including operations of strings, of course tasks with lots of I/O, or generally data-structures fitting those of Python, such as the following pi calculation for instance: --- Prec=1000 ; I=pow(10L,Prec) ; vPi=0L ; k=0 while 1: v=(((I<<2)/(8*k+1)-(I<<1)/(8*k+4)-I/(8*k+5)-I/(8*k+6))>>(4*k)) vPi=vPi+v k=k+1 if v==0: break print "iterations=", k, "pi=",vPi --- > Again, I recognize the Lisp community has a long and > interesting history with performance comparisons. I'm > not reflecting on that at all. I'm talking about cur- > rent Python and, let's say, gcc--I take those to be > consistent with your intent. Basically it somewhat depends on what you are doing. -- Cedric From boud at rempt.xs4all.nl Sun Apr 22 16:51:43 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 22 Apr 2001 20:51:43 GMT Subject: GUI Toolkit API? References: <3AE0C796.3020500@netscape.net> <9bsii2$42j$1@news1.xs4all.nl> Message-ID: <9bvg8v$gjb$2@news1.xs4all.nl> Vadim Zeitlin wrote: > On 21 Apr 2001 18:12:18 GMT, Boudewijn Rempt wrote: >>However, if you want to have all the great extensions that >>every toolkit provides, then you'll have to write emulation code for >>the missing bits, _if_ you're set on using what's already available. >>That's the position of wxWindows. Correct me if I'm wrong, but I rather >>had the impression that all the really interesting, high-level widgets >>wxWindows offers are custom-coded for wxWindows, like the html-widget. > wxHTML is one of the rare examples - most of the other other controls are > implemented natively at least on one platforms (usually Win32 where the native > LNF is the most important). I think only wxGrid doesn't have any native > implementations - the other high-level widgets such as wxTreeCtrl or > wxListCtrl are implemented natively under Win32. Maybe someone will write the > GTK+ versions of those one day as well (in fact, they do exist, but wxWin > versions are better and so nobody is interested in using/improving them). That's more or less what I mean - if platform A has a great X, then you'll want to emulate that on platform B and C - and if sometimes you have to write something fresh anyway - with the chance of creating something that's better than anything already in existence. -- Boudewijn Rempt | http://www.valdyas.org | Christos Voskrese! From bos at hack.org Fri Apr 13 06:47:43 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 13 Apr 2001 12:47:43 +0200 Subject: __sub__ for string References: <3AD6C15B.13AB23CC@hack.org> <1zzB6.7026$4N4.1532639@newsc.telia.net> <3AD6C653.70A8663E@hack.org> <9b6k5g$ccg$1@slb5.atl.mindspring.net> Message-ID: <3AD6D94F.255C17A5@hack.org> Andrew Dalke wrote: > So what does "abc" / "ab" equal? I'll show the Pike-eqvivalents: > string s = "this is a string"; Result: "this is a string" > s / " "; Result: ({ /* 4 elements */ "this", "is", "a", "string" }) > s - " "; Result: "thisisastring" > s * 2; Result: "this is a stringthis is a string" > s + s; Result: "this is a stringthis is a string" Since they exists in Pike, I just wondered the reason why they don't exist in Python. And I've got the answer for that by now. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From wiener at rap.ucar.edu Wed Apr 18 23:11:57 2001 From: wiener at rap.ucar.edu (Gerry Wiener) Date: 18 Apr 2001 21:11:57 -0600 Subject: Problem building 2.1 on Debian Linux 2.2.13/2.2.17 In-Reply-To: Neil Schemenauer's message of Wed, 18 Apr 2001 18:31:07 -0700 References: <651yqqxa47.fsf@virga.rap.ucar.edu> Message-ID: <653db5y45e.fsf@virga.rap.ucar.edu> Unsetting PYTHONHOME and doing a clean configure and build from the tar distribution fixed the problems I was having. Thanks Neil. --Gerry From xyzmats at laplaza.org Sat Apr 14 22:53:30 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sun, 15 Apr 2001 02:53:30 GMT Subject: Python Books for 2002 References: <03BA7FF29A7003C0.58A7996FD1867709.07757E6DB814C605@lp.airnews.net> <9ai305$so3$1@panix2.panix.com> Message-ID: <3ad90cdb.36557787@news.laplaza.org> On Thu, 5 Apr 2001 13:57:13 -0400, "Steve Holden" wrote: >> Ever since I saw _Borland C++ for Dummies_, I have concluded that >> *nothing* is truly anathema to computer book publishers. > >Yes, that is surely one of those books which should consist entirely of >blank pages. Nowadays, of course, it is considered elitist to claim not to >be a dummy. Next it will be "Nuclear Power Station Design for Dummies" >(although, remembering Three Mile Island, the operations staff clearly had >their own volume in that series). Sigh. Me dear ol' Dad is a somewhat-retired physics professor who has had many a student that later headed in the direction Steve alludes to. His commentary on the qualifications of those students has never been encouraging... Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From orcmid at email.com Tue Apr 10 20:00:42 2001 From: orcmid at email.com (Dennis E. Hamilton) Date: Tue, 10 Apr 2001 17:00:42 -0700 Subject: Komodo in violation of Mozilla Public License? (fwd) In-Reply-To: Message-ID: I had just taken a look and here's my totally-intellectual, legally-uninformed (TILU) appraisal of the situation: First, there is a Covered Work (or Works) that were covered by the MPL that have been used in building Komodo. That is, some portion, perhaps substantial, includes code or modifications of code from MPL-covered works. If that isn't the case, the conversation is over. So long as Covered Works are relied upon, then the following provisions kick in without exception: 3.1 License applies to modifications *of* *the* *Covered* *Work* as you noted 3.2 Source Code must be made available for the modified *Covered* *Work* under the conditions set forth in the MPL. There are very definite conditions on the duration of availability of the source. 3.5 License notices must be included in Source Code of the modified *Covered* *Work* as specified in the MPL. 3.6 Executable-only distributions can occur and must be accompanied by a description of how to obtain the source code along with notice of licensing under the MPL. It is by virtue of 3.1 that one cannot add additional conditions on the use or application of the *Covered* *Work* or its modification (that is, identifying free and commercial classes, withholding source, restricting redistribution, etc.) None of that is acceptable with regard to the *Covered* *Work* or its modifications. OK, this part is simple. Here's where it gets tricky: 3.7 Allows for incorporation of the *Covered* *Work* (modified or not) in a larger work. MPL is not a viral license and the larger work can have a different license applied to those portions that are not portions of the *Covered* *Work*. However, the *Covered* *Work* (possibly modified) needs to be identified and the licensing of the covered work preserved. You could view this as part of the aggregation provision in the Open Source Licensing model (and in the GPL). It is not clear that one needs to continue to offer the *Covered* *Work* (modifications) as part of distribution of a larger work, but it would certainly be necessary if the packaging were such that the Covered Work were easily separable from the larger work for separate use. This may just be a place where the MPL is inprecise. 6.3 Addresses the derivative work case. Please note that the MPL is *not* *viral*, though it is not exactly a BSD-like (or Python-like) license either. 6.3 allows a derivative work to be distributed under a quite different license and there are instructions about how to use the MPL license notice with such a work, along with a few simple conditions that must be satisfied. Since Komodo is prospectively a derivative work of whatever MPL'd *Covered* *Works* they incorporated code from, this is the likely case that applies. The way to tell is to examine the license for Komodo and see how it acknowledges reliance on portions of MPL *Covered* *Works* (as modified) and whether it independently offers the MPL *Covered* *Works* under the MPL. Here they be sea serpents. -- Dennis -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Lulu of the Lotus-Eaters Sent: Tuesday, April 10, 2001 14:26 To: python-list at cwi.nl Subject: Re: Komodo in violation of Mozilla Public License? (fwd) David Ascher (Komodo Tech Lead) in email asked for clarification of why I thought the Komodo licensing terms violate the MPL. I'd like to clarify for the list, since this IMO is a matter of general concern to the Python community (David is BCC:'d). The Mozilla Public License seems to live at: The chief sections that apparently conflict with Komodo's commercial licensing terms: 3.1. Application of License. [ ... ] Komodo is available--as far as I can determine--only under a substantially different license than the MPL. Specifically, the ActiveState license imposes many terms that additionally restrict the recipients rights. 3.2. Availability of Source Code. [ ... ] ActiveState does not make source code for their modifications available. That seems pretty staightforward. [ ... ] Yours, Lulu... From DavidA at ActiveState.com Wed Apr 11 15:24:24 2001 From: DavidA at ActiveState.com (David Ascher) Date: Wed, 11 Apr 2001 12:24:24 -0700 Subject: Komodo in violation of Mozilla Public License? References: Message-ID: <3AD4AF68.748EE1F3@ActiveState.com> Fredrik Lundh wrote: > > David Ascher wrote > > Likable, probably -- but also, very possibly, out of business. We > > (ActiveState) are in the fairly unusual position of trying to be both > > valued community members and a successful business at the same > > time. > > not that unusual in the python universe, though -- cannot think of > any Python tools provider that doesn't also do open source stuff... > > Secret Labs, the WingIDE guys, theKompany, eGenix... (etc) Sure. As far as I can tell, we all make similar compromises on topics such as licensing and pricing. I think of all of us as being in the same boat, which is still pretty small compared to the number of companies out there. --david From ykingma at accessforall.nl Thu Apr 26 16:56:24 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Thu, 26 Apr 2001 21:56:24 +0100 Subject: Caching Strategies/Database question References: <3AE84904.C69D88C0@bioreason.com> Message-ID: <3AE88B71.A2E86D53@accessforall.nl> Brian Kelley wrote: > > I am using a dictionary to hold > > {string:[list of integers]} > > key: values > > The dictionary is randomly accessed to add an integer to the list > referenced by the string. > > I have been exploring several differnent caching strategies ranging from > bsddb3 to the metakit toolkit for caching/retrieving these to disk. One > of the problems that I am facing is that because the dictionary is > randomly accessed after the database gets to a certain size performance > goes WAY down with every strategy that I have tried. (Note that > integers are never removed if that helps) I have had success speed-wise > with MySQL but I simply cannot deliver that in my application, it's way > too costly to administer. > Adding RAM will help, but probably only temporarily. Since you're not deleting anything you might change the physical record format to: (string, nextInteger) and simply append these records, ie. using a heap like structure. Eventually replace the string by a smaller key and keep a separate table of (string, smaller key). Needless to say that although this might solve your integer adding problem, retrieval is now not as easy as it was. To solve that you might add backpointers and a pointer to the last added nextInteger record in (string, smaller key) table. No free lunch, sorry. Locality of reference is the only real solution. You might try to build up in RAM, then sort, then write to disk. > Has anyone examined a similar problem? Thanks in advance. > > Brian Kelley Good luck, Ype -- email at xs4all.nl From Haris_member at newsranger.com Tue Apr 3 09:14:23 2001 From: Haris_member at newsranger.com (Haris Lekasas) Date: Tue, 03 Apr 2001 13:14:23 GMT Subject: locking files on freebsd References: <9aafdf$dv6$1@nntp6.u.washington.edu> Message-ID: Thanks it seems fcntl.lockf(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB, 8192, 0, 0) will do the job.. Haris In article <9aafdf$dv6$1 at nntp6.u.washington.edu>, Donn Cave says... > >Quoth Haris Lekatsas : >| Hello, >| I have a problem with locking files. The following code will work on several OS >| but it seems >| to fail on FreeBSD giving an IOError. >| Any ideas? >| >| f = open('filename', 'w') >| fd = f.fileno() >| flock = struct.pack('2h8l', FCNTL.F_WRLCK, 0, 0, 0, 0, 0, 0, 0, 0, 0) >| fcntl.fcntl(fd, FCNTL.F_SETLKW, flock) > >The struct is the wrong size (and order.) Look at /usr/include/fcntl.h >to see the struct layout (at least, that's where I find it on NetBSD 1.5, >whose struct comes out to only 24 bytes, as opposed to the 36 bytes >generated by your format.) > >If it works for you, it would be easier to use fcntl.lockf(). The >Python implementation of that function handles the flock struct itself, >and borrows the API of the Berkeley flock() function. The lockf() >function is X/Open standard, and works with the same locks (and same >twisted semantics) as the fcntl POSIX 1003.1 F_WRLCK; I would say >it's a wrapper around the latter, but I'm not sure it always is. > > Donn Cave, donn at u.washington.edu From dalke at acm.org Sun Apr 22 21:00:45 2001 From: dalke at acm.org (Andrew Dalke) Date: Sun, 22 Apr 2001 19:00:45 -0600 Subject: A list of Python users? References: Message-ID: <9bvuvh$dq8$1@slb3.atl.mindspring.net> Jan Dries wrote: >Indeed, but as to IBM, it only says "Python was ported to OS/390 UNIX >System Services to facilitate automated testing of internet tools." Not >exacty my idea of "IBM extensively using Python in many areas of the >company", as Ron put it. >That's why I asked for more references. ... >But >some good references to IBM would make my case to sell Python to my >management a whole lot easier. Did a Google search for: +site:ibm.com python -developerWorks -"mailing list" but didn't find much in the way of hits refering to internal use of Python by IBM. The developerWorks may include some mentions, but there were too many generic (non-IBM specific) matches to evaluate. Here's what I did find. http://www-1.ibm.com/servers/eserver/zseries/zos/unix/python.html ] Python was ported to OS/390 UNIX System Services to facilitate ] automated testing of internet tools. http://domino.watson.ibm.com/MathSci/SIAMwork.nsf/d8aaf9108ec678a38525663400 552c87/c980c2fd8079388185256634005d2e1c?OpenDocument ] The Graphical User Interface (GUI) in VBM is implemented in Python http://www8.software.ibm.com/solutions/isv/igssg.nsf/NFbankWeb/86256529006D5 512002569E7005D1677?opendocument ] Business Problem: ] Enabling e-business practices simply, securely and effectively for SMB's. ] Programming Languages used: ] C, C++, Python, PHP, Javascript http://www.almaden.ibm.com/cs/people/bayardo/vinci/vinci.html ] Vinci: A Service-Oriented Architecture for Rapid Development of ] Web Applications ... ] Vinci already includes XTalk stacks in C++, Java, Perl, Python, and PalmOS. Andrew dalke at acm.org From dsh8290 at rit.edu Mon Apr 16 16:02:52 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 16 Apr 2001 16:02:52 -0400 Subject: Stop python In-Reply-To: <9bfam2$hn2$0@216.39.170.247>; from whisper@oz.net on Mon, Apr 16, 2001 at 05:38:10PM +0000 References: <3AD975A6.112ABBBA@elisra.com> <9bfam2$hn2$0@216.39.170.247> Message-ID: <20010416160251.A28966@harmony.cs.rit.edu> On Mon, Apr 16, 2001 at 05:38:10PM +0000, Dave LeBlanc wrote: | How would this terminate the parsing of a Python program (as opposed | to execution)? Actually, you're right. I doesn't stop parsing. If you want python to stop parsing a file, you must insert a syntax error . Python parses, then byte-compiles the whole file before it begins execution. The Bourne shell simply parses and executes as it reaches statements (AFAIK). -D From chris.gonnerman at usa.net Tue Apr 3 09:02:53 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 3 Apr 2001 08:02:53 -0500 Subject: alny way of not using glob? References: <9aar5f$8n9$1@news.netmar.com> Message-ID: <01a001c0bc3e$69e6c6e0$a100000a@local> ----- Original Message ----- From: Subject: alny way of not using glob? > Hi I am trying to get a list of the files in the current direcoty by > using glob. But I have the following trouble: > 1. glob is a standard module in python 2.0 but not 1.5.2 whihc I am > currently using and the sys admin has no intention to upgrade it ... Actually glob is a standard module in 1.5.2... in fact it appears to be pure Python, no C code at all. I am attaching glob.py and fnmatch.py from 1.5.2 for you to try out. > 2. glob is unix dependent? My script needs to run in windows also ... Nope. I use it all the time on Windows. > The code I am using is: > targetFiles = reduce(operator.add, map(glob.glob, arguments[1:])) > > value is arguments[1:] is "*.py" Actually it's [ *.py" ], that is, a list of one item which is "*.py". > when I print targetFile, it is: > ['tp_tc_TNLC01.py', 'tp_tc_TNLC02.py', 'tp_tc_TNLC04.py', 'tp_tc_TNLC0 > 6.py', 'tp_tc_TNLC07.py', 'tp_tc_TNLC08.py', 'tp_tc_TNLC09.py', 'tp_tc > _TNLC10.py', 'tp_tc_TNLC11.py', 'tp_tc_TNLC14.py', 'tp_tc_TNLC15.py', > 'tp_tc_TNLC16.py', 'tp_tc_TNLC17.py'] Is this not a correct list of filenames? > How can I get around that?? What do you want it to do? -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: fnmatch.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: glob.py URL: From hughett at mercur.uphs.upenn.edu Mon Apr 16 10:39:48 2001 From: hughett at mercur.uphs.upenn.edu (Paul Hughett) Date: 16 Apr 2001 14:39:48 GMT Subject: Fortran Parser Question References: <20010413.162812.1909002904.4134@adam-aurag.crm.umontreal.ca> Message-ID: <9bf07k$54n$1@netnews.upenn.edu> Hassan Aurag wrote: : I am trying to write a Fortran parser in python. : What I need is really simple. Given a fortran file, get all variables : with their type and decompose arthmetic operations. Stuff like a = b+c : .... and check their types to see if those ops can be dangerous when : ported on various platforms. : So, I won't need a full fledged compiler, but really something simple. I : am new to regular exps and friends, so if anyone can help with something : simple I can start with, please drop me a note! I think you may be approaching this problem from the wrong direction. Rather than building your own half-baked compiler, consider using an existing Fortran compiler that is really, really picky and is often used for writing portable software. The Gnu folks write a lot of portable software and I know from experience that their gcc compiler is--with the right options--pretty good at catching non-portable constructs. I don't have much experience with their Fortran compiler (g77) but I'd certainly check whether it's also good at catching non-portable constructs. If it works, it's certainly going to be much easier than writing your own. Another option: go to www.netlib.org, which is a site for numerical analysis software, written mostly in Fortran, and browse around for Fortran programming tools. It wouldn't surprise me if something like what you want already exists. Look also at f2c, which is a Fortran-to-C converter; even if it doesn't provide good diagnostics, it contains a Fortran parser already written which you can try adapting. Paul Hughett From piet at cs.uu.nl Mon Apr 30 14:28:11 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 30 Apr 2001 20:28:11 +0200 Subject: How to make execfile exit? References: Message-ID: >>>>> Campbell (C) writes: C> I've got a cute server now, for an incoming connection it identifies the C> destination, and runs execfile on the correct python script. My problem C> is that once the file is being run, I can find no way to exit from the C> execfile function unless the sys.exit() statement is executed in the C> root of the script. An example might excuse my explanation: Your description is difficult to understand, but I guss that you mean to catch the error from the main program. In reality sys.exit raises the SystemExit exception, so you can catch this one. Or any other exception that you use instead. E.g. me = funkyclass() try: execfile('destination.py') except SystemExit, e: print e print "execfile finished" And it should be class funkyclass, not def. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From fran at stat.Berkeley.EDU Fri Apr 27 13:32:36 2001 From: fran at stat.Berkeley.EDU (Fran Rizzardi) Date: 27 Apr 2001 17:32:36 GMT Subject: freeze, VC++6.0 and Python 2.0 or 2.1 Message-ID: <9ccafk$ki1$1@agate.berkeley.edu> I have successfully frozen Python code that uses Tkinter using VC++5.0 and Python 2.0 under NT 4.0. I'd now like to upgrade to VC++6.0 but even the Python 2.1 freeze/README still says to use VC++5.0. Has anyone successfully frozen Python code with Python 2.0 or 2.1 using VC++6.0? And did it use Tkinter? (I don't expect Tkinter to really be an issue, but you never know.) Thanks in advance, Fran Rizzardi From tim.one at home.com Sun Apr 22 15:20:19 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Apr 2001 15:20:19 -0400 Subject: Submitting Bugs at Sourceforge In-Reply-To: Message-ID: [Stephen] > I'm in the process of working on the Python-2.1 sources to make them > compile from Borland C++Builder, since it has a free compiler out there > and all. Cool! > ... > Now, my question: I submitted 4 bug-reports on the various minor > fixes that needed to be done, and have 4 left that I havn't sent in > yet. Just in general, would it be better for me to send in a batch of > those little fixes, or submit each one as a seperate bug report? For > the most part, they're changing various #defines which at the moment > assume Win32 = Visual C++. Patches are much better than bug reports, if you can make a patch: when you merely describe what you need in English, it's time-consuming to deal with the description, and the person who (therefore reluctantly <0.9 wink>) takes it on has NO WAY to tell whether their interpretation of what you wrote actually fixes the problem on your platform. If you can't make a patch, second best is to gather up *all* the changes you need, stick the new versions of the files on the web, and submit one patch to SourceForge containing URLs to the new files. It would actually be better to upload the new files as attachments to the patch, but SourceForge has a low limit on the size of file attachments so that may not work. Next best is to email the new files to me directly: since you're fiddling with PC\config.h, I have to test the changes anyway to guarantee they don't break the non-Borland Windows builds. A caution in advance: there are some things we won't accept anymore. Python requires an ANSI-conforming C compiler now, and changes that seek to #ifdef their way around broken compilers and libraries have a good chance of getting rejected, especially if it's a compiler relatively few people use (historically, people using "challenged" compilers submit patches and then vanish, and nobody remains who can fix the new bugs introduced when the old bugs in the platform compiler eventually get *fixed*). From graham_guttocks at yahoo.co.nz Thu Apr 5 15:36:22 2001 From: graham_guttocks at yahoo.co.nz (=?iso-8859-1?q?Graham=20Guttocks?=) Date: Fri, 6 Apr 2001 07:36:22 +1200 (NZST) Subject: python modules as user configuration files Message-ID: <20010405193622.8799.qmail@web10307.mail.yahoo.com> Greetings Python Experts, For my application, I would like users to have a python module as a configuration file to define variables and whatnot. Is there any way to explicitly import a particular file using its full path name? Such as: >>> import /home/graham/config (to load ~/config.py) All I could figure out was to append the user's home directory to sys.path before import. >>> import os, sys >>> sys.path.append(os.path.expanduser("~")) >>> import config My other question is: is there way to store a python module as a dot-file (i.e, "~/.config.py"). It seems by default this is not allowed: >>> import .config File "", line 1 import .config ^ SyntaxError: invalid syntax Regards, Graham _____________________________________________________________________________ http://my.yahoo.com.au - My Yahoo! - Have news, stocks, weather, sports and more in one place. From a at a Tue Apr 10 13:33:34 2001 From: a at a (news.comm2000.it) Date: Tue, 10 Apr 2001 17:33:34 GMT Subject: Class Variable Question References: <3ad1c7e9$0$196$e2e8da3@nntp.cts.com> <9aveat$10aq$1@nntp6.u.washington.edu> Message-ID: >Russell wrote: > I'm not a big fan of prototyping for several reasons: > - typos can cause the kind of damage you mentioned > - it complicates type checking, implementation of safe interfaces, etc. I'm feeling the way python handles classes as a natural consequence of his not-typed-checked nature, so all the language seems 'more' coerent to his filosofy, and so more 'natural' and, at the end, easier to use... It is in the 'nature' of python that interface implementation must be coerced more reading the interface documentation than writing coercion code... but writing coercion code can still be done... > My guess is that the reason Python uses prototyping is that it was > simpler to implement the language that way. I guess that the dynamic nature of python has leaded the language to his natural actual implementation. If all, from the bases, is implemented with dynamic-feature in mind, You can bet that implementing dynamic class object was easier than implementing C++ style class... Paolo Invernizzi paoloinvernizzi at dmsware.com From jkraska1 at san.rr.com Tue Apr 24 18:46:24 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 24 Apr 2001 22:46:24 GMT Subject: string->list->string References: <65m9eto745v6gsocbor6gmrd5f25k1e1g0@4ax.com> Message-ID: <8t0cetsvnusicetpriv21lg3jio1rndlct@4ax.com> >we might have understood that you really meant mylist=list(alpha). The wonderful thing about usenet is that you're all but guaranteed to be taunted for any idiocy. :) >Part of your cinfusion could be that you are reading the wrong >documentation. The translate used above is the translate method of the >string type, not the translate function of the string module Oh. oh. oh. Yeah. ARG. Someone also showed me a nice trick with the re module. C// From aahz at panix.com Thu Apr 12 14:54:17 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Apr 2001 11:54:17 -0700 Subject: Python Programming Ettiquette References: Message-ID: <9b4tkp$he$1@panix3.panix.com> In article , zzzzz wrote: > >If I want to change a variable value from within a function I believe >I have two options: > >a) Directly modify the parameter: >x=[1,2,3] >def add4tolist(inputlist): > inputlist.append(4) >add4tolist(x) >x >[1,2,3,4] If you want to do this, you should make x a class instance, so that instead you're doing x.add4tolist() -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From rerhol at gmx.de Thu Apr 19 02:05:51 2001 From: rerhol at gmx.de (Georg Lohrer) Date: 19 Apr 2001 06:05:51 GMT Subject: syntax-error with new Python 2.1 and pyFTPd.py and pyFTPdrop.py References: <9bkbql$goe$1@news.mch.sbs.de> Message-ID: <9blv7v$m3o$1@news.mch.sbs.de> On Wed, 18 Apr 2001 15:42:17 GMT, Fredrik Lundh wrote: >Georg Lohrer wrote: >> I've just compiled and run the new python 2.1 version successfully. >> But using the pyFTPd.py and pyFTPdrop.py scripts the same syntax-error >> will be raised in socket.py: >> >> import sys, socket, string, os, os.path, time, fnmatch, types >> File "/home/gelo/lib/python2.1/socket.py", line 251 >> total += len(line) >> ^ >> I've tried several ways to cast out the failure, but it doesn't want >> to go. So, has anybody at moment have any experiences with this fault? >> Or does anybody know a way to eliminate it? > >I strongly doubt Python said "I've tried several ways to cast out >the failure" ;-) > >are you sure you didn't get a SyntaxError or some kind of warning? > Hmm, the complete message is: 'import site' failed; use -v for traceback Traceback (innermost last): File "./pyFTPdrop.py", line 14, in ? import sys, syslog, socket,string, os File "/user/lgx00460/lib/python2.1/socket.py", line 251 total += len(line) ^ Does that clear up anything? Ciao, Georg From max at alcyone.com Mon Apr 16 15:19:24 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 16 Apr 2001 12:19:24 -0700 Subject: Apache/Win 95 Irregularity References: Message-ID: <3ADB45BC.513BDA5B@alcyone.com> Steve Holden wrote: > Sorry, hit the wrong button before I could attach the files. Here they > are. Stop posting. Read the FAQs in news.newusers.questions. Resume after you've learned that posting attachments in non-binaries newsgroups is a very, very bad idea. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ What do women want? \__/ Sigmund Freud Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From noselasd at frisurf.no Tue Apr 24 05:51:39 2001 From: noselasd at frisurf.no (Nils O. Selĺsdal) Date: Tue, 24 Apr 2001 11:51:39 +0200 Subject: What does a function do? References: Message-ID: "alki" wrote in message news:dW2F6.3685$5t3.283453 at newsread1.prod.itd.earthlink.net... > What does a function do? I read a book, but I have no idea what the purpose > of a function is. def square(number): #define a function named square and takes one inpt parameter, return number*number; #this is the (simple) body of the function, it uses the parameters given to it and return a result... The square function takes one imput parameter and return its square.. call it like a=square(4) a now contains 4 . I suggest that you take a look at the tutorials and some simple examples at www.python.org From com-nospam at ccraig.org Tue Apr 17 09:36:58 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 17 Apr 2001 09:36:58 -0400 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> Message-ID: <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Douglas Alan writes: > What happened to giving programmers enough rope to hang themselves? > What happened to the desire for flexibility and expressive power? You can still get this, just not in Python. If you want a long rope, you still have Lisp, C, C++, and Perl. One of the principles that makes Python so popular is its simplicity. Any reasonably skilled programmer can learn every important part of the Python syntax in less than a day. Sure C++ is a more flexible language than Python. But, I have read the entire language reference for Python, it took a couple hours; it would take me a couple hours to carry the C++ language reference up to my 4th floor desk. I have never seen a Python program that I couldn't sit down and read with little effort; I rarely see a Perl program that I can. If you go adding macros to Python then you remove that simplicity. You would make it so that any programmer can add arbitrary levels of complexity to the syntax used in the program, and thus before reading through code a programmer would have to read and understand the macros used. You can do this now by passing your program through m4 before Python parsing it, but you wouldn't be programming in Python. And that really is the point. -- Christopher A. Craig "You could shoot Microsoft Office off the planet and this country would run better. You would see everyone standing around saying, 'I've got so much time now.' " Scott McNealy (CEO of Sun) From greg at cosc.canterbury.ac.nz Thu Apr 5 21:52:24 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 06 Apr 2001 13:52:24 +1200 Subject: Conditional operator in Python? References: Message-ID: <3ACD2158.A7F044F7@cosc.canterbury.ac.nz> Tim Peters wrote: > > hard-to-believe-that-semantically-significant-leading-zeroes- > ever-seemed-like-"a-good-idea"-to-anyone-ly y'rs - tim Indeed. That's one "feature" of C that Python should definitely NOT have imitated! -- 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 sdm7g at Virginia.EDU Mon Apr 23 09:59:49 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 23 Apr 2001 09:59:49 -0400 (EDT) Subject: Python 2.1 running on Mac OS X 10.0.1 here In-Reply-To: <220420011219006651%jwbaxter@olympus.net> Message-ID: It's a process resource limit problem. If you set: "limit stack 4096" in the shell (tcsh -- it's a different syntax for sh/bash) the re test will run without error. -- Steve Majewski From astpspd at pea.or.th Fri Apr 27 02:13:37 2001 From: astpspd at pea.or.th (Tawee Laoitichote) Date: Fri, 27 Apr 2001 13:13:37 +0700 Subject: How to create 3 dimension array from 1 & 2 dimension array Message-ID: <002701c0cee1$32ec8a20$24130180@astpspd> Dear John, The 2-d array is to keep the state transition probabilities table whilst the 1-d array is to keep each transition step. Each step is calculated then keep in the state transition table then I get the 3 dimension array. In my case, the 2-d array has a shape of 4 by 4 with 3-step transition. Say : py> print P1 [[ 0.0803014 0.18393972 0.36787944 0.36787944] [ 0.63212056 0.36787944 0. 0. ] [ 0.26424112 0.36787944 0.36787944 0. ] [ 0.0803014 0.18393972 0.36787944 0.36787944]] py> print P1.shape (4, 4) py> print P2 [[ 0.2494705 0.28544118 0.3002118 0.16487652] [ 0.28330432 0.25160736 0.23254416 0.23254416] [ 0.35097196 0.319275 0.23254416 0.09720887] [ 0.2494705 0.28544118 0.3002118 0.16487652]] py> print P3 [[ 0.29303419 0.29166457 0.2628715 0.15242975] [ 0.26191727 0.27299442 0.27531827 0.18977005] [ 0.29925757 0.28544118 0.25042473 0.16487652] [ 0.29303419 0.29166457 0.2628715 0.15242975]] Tawee From robin900 at yahoo.com Fri Apr 6 11:14:10 2001 From: robin900 at yahoo.com (Robin Thomas) Date: Fri, 06 Apr 2001 11:14:10 -0400 Subject: Binary arithmetic optimization (Was: Why not an __assign__ method?) In-Reply-To: <3ACD7B2C.372E4A3E@chello.nl> References: <5.0.2.1.0.20010331004906.021bc9b0@mail.inet.com.br> <4.3.1.2.20010330115856.0256bb00@exchange.starmedia.net> <5.0.2.1.0.20010330125432.0216c4b0@mail.inet.com.br> Message-ID: <4.3.1.2.20010406105515.00c06100@exchange.starmedia.net> At 10:15 AM 4/6/01 +0200, Roeland Rengelink wrote: >Carlos Alberto Reis Ribeiro wrote: > >[extensively about a proposal to add a new magic method __onassign__ to >solve a problem in arithmetic expressions] > >Hi, > >I've looked at another approach to solve the problem under >consideration. This approach seems to work and does not require a magic >__onassign__ method. It does require some refcount magic, which makes >this procedure somewhat unobvious. Yes, I agree with you that __onassign__ is not necessary. I also agree that an object's reference count is the key to the solution. I do not agree that any "magic" needs to be done to any object, either by copying it or setting some flag. I sent a possible solution to Carlos, but did not post it to the list. I thought that the list's interest in our topic had waned, and that the discussion should be taken offline. The ensuing responses from you and others convince me that, hey, maybe it does belong on this list. Here's the message in question (appended, not quoted or attached)... --------- I've been thinking about your in-place operator optimizations. Two main approaches I have considered: 1) Doing it at the bytecode level. Bytecodes that would produce "new" objects mark that position on the stack (not the object on the stack itself) as a candidate for in-place operator optimization. If, later in the bytecode, a BINARY_* would execute with the marked position being second from the top (the left operand of the binary op), the BINARY_* opcode is replaced with the corresponding INPLACE_* opcode. 2) Exploiting the fact that, in the CPython virtual machine, the stack must own its own reference to each object on the stack, one reference for each stack position. When the VM executes an opcode, it pops the objects off the stack, them does some stuff, and only as the final act decrements the reference counts of the objects it popped. Thus, when the VM POP()s an object from the stack, it still owns a reference to it. And if the object's reference count is 1, then only the stack can reach the object. This is tantamount to having the object marked 'temp'. No stacks in other frames refer to the object, nor does any other Python object, if ob_refcnt == 1. Then, we can have the code for BINARY_OP check the left operand object. If ob_refcnt == 1, it's a "temp" object, and we can do the inplace operation instead. No change to the compilation phase is needed. Here's a test implementation, a patch against 2.1b1 Python/ceval.c. Looks like it works. *** Python/ceval.old Thu Apr 5 19:59:56 2001 --- Python/ceval.c Thu Apr 5 20:05:05 2001 *************** *** 410,415 **** --- 410,418 ---- #define SETLOCAL(i, value) do { Py_XDECREF(GETLOCAL(i)); \ GETLOCAL(i) = value; } while (0) + /* Inplace operator optimization macro */ + #define CAN_IOP(x) (x->ob_refcnt == 1) + /* Start of code */ #ifdef USE_STACKCHECK *************** *** 883,889 **** case BINARY_POWER: w = POP(); v = POP(); ! x = PyNumber_Power(v, w, Py_None); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 886,895 ---- case BINARY_POWER: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlacePower(v, w, Py_None); ! else ! x = PyNumber_Power(v, w, Py_None); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 893,899 **** case BINARY_MULTIPLY: w = POP(); v = POP(); ! x = PyNumber_Multiply(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 899,908 ---- case BINARY_MULTIPLY: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceMultiply(v, w); ! else ! x = PyNumber_Multiply(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 903,909 **** case BINARY_DIVIDE: w = POP(); v = POP(); ! x = PyNumber_Divide(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 912,921 ---- case BINARY_DIVIDE: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceDivide(v, w); ! else ! x = PyNumber_Divide(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 913,919 **** case BINARY_MODULO: w = POP(); v = POP(); ! x = PyNumber_Remainder(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 925,934 ---- case BINARY_MODULO: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceRemainder(v, w); ! else ! x = PyNumber_Remainder(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 937,944 **** else x = PyInt_FromLong(i); } else ! x = PyNumber_Add(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 952,961 ---- else x = PyInt_FromLong(i); } + else if (CAN_IOP(v)) + x = PyNumber_InPlaceAdd(v, w); else ! x = PyNumber_Add(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 962,969 **** else x = PyInt_FromLong(i); } else ! x = PyNumber_Subtract(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 979,988 ---- else x = PyInt_FromLong(i); } + else if (CAN_IOP(v)) + x = PyNumber_InPlaceSubtract(v, w); else ! x = PyNumber_Subtract(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 1000,1006 **** case BINARY_LSHIFT: w = POP(); v = POP(); ! x = PyNumber_Lshift(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 1019,1028 ---- case BINARY_LSHIFT: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceLshift(v, w); ! else ! x = PyNumber_Lshift(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 1010,1016 **** case BINARY_RSHIFT: w = POP(); v = POP(); ! x = PyNumber_Rshift(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 1032,1041 ---- case BINARY_RSHIFT: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceRshift(v, w); ! else ! x = PyNumber_Rshift(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 1020,1026 **** case BINARY_AND: w = POP(); v = POP(); ! x = PyNumber_And(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 1045,1054 ---- case BINARY_AND: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceAnd(v, w); ! else ! x = PyNumber_And(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 1030,1036 **** case BINARY_XOR: w = POP(); v = POP(); ! x = PyNumber_Xor(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 1058,1067 ---- case BINARY_XOR: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceXor(v, w); ! else ! x = PyNumber_Xor(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); *************** *** 1040,1046 **** case BINARY_OR: w = POP(); v = POP(); ! x = PyNumber_Or(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); --- 1071,1080 ---- case BINARY_OR: w = POP(); v = POP(); ! if (CAN_IOP(v)) ! x = PyNumber_InPlaceOr(v, w); ! else ! x = PyNumber_Or(v, w); Py_DECREF(v); Py_DECREF(w); PUSH(x); -- robin900 at yahoo.com _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From sebrosa at artenumerica.com Wed Apr 11 23:00:17 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Thu, 12 Apr 2001 04:00:17 +0100 Subject: IndexError: string index out of range References: Message-ID: <3AD51A41.AB7FF9D3@artenumerica.com> f.readline() in your function function get_line() eventually returns '', and then you are trying to extract the first element of an empty string: ''[0] This produces an IndexError. Sebrosa From jkraska1 at san.rr.com Mon Apr 16 20:23:33 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 17 Apr 2001 00:23:33 GMT Subject: Python extension package namespace References: <9bg1j4$s8k$1@lynx.unm.edu> Message-ID: <6f3ndtcb10qqnv44otin7242j1v26tlj98@4ax.com> On 17 Apr 2001 00:09:08 GMT, tuthach at aix09.unm.edu (Tu-Thach) wrote: >I have written a simple test extension module for Python and called it >testxyz. What I'd like to know is how can I make the module so that when >I call it from Python I can use >from test.testxyz import * You need to prep up your directory with "__init__.py" C// From rtexier at elikya.com Tue Apr 3 04:24:40 2001 From: rtexier at elikya.com (Romuald Texier) Date: Tue, 3 Apr 2001 10:24:40 +0200 Subject: A couple garbage collector questions References: Message-ID: <9ac1c4$bde$1@news.irisa.fr> Douglas Alan wrote: > I have a couple of questions regarding the new Python garbage > collector: > > (1) Why does it use the rather unusual algorithm it does, rather > than a more typical mark and sweep? The per-object storage cost > for the extra reference count is surely greater than the bit or > two required for a typical mark and sweep. > > (2) Why does the algorithm need back-pointers for the object chain? > > Just curious. Thanks. > > |>oug The Ruby language uses a mark and sweep GC but it seems that it prevents it from using native threads (in particular Posix Threads) whereas the Python GC is thread safe. -- Romuald Texier From scarblac at pino.selwerd.nl Thu Apr 26 08:45:00 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 26 Apr 2001 12:45:00 GMT Subject: Adding optional 'explicit' declaration? References: <9c63ps$i4h$1@upsn21.u-psud.fr> Message-ID: Laurent Pointal wrote in comp.lang.python: > The idea is to optionnaly allow to force an explicit variable declaration > in Python functions/methods for compilation time check. > > The transparent creation of variables in Python is really nice, but there > are times when it become a bug source, essentially because of misstyping of > variable names. Does anyone have any numbers on this? People make this claim all the time, but in practice my typos are always caught at compile time or immediate testing already. I believe bugs like this are really rare. Does anyone have numbers from a real project on how many bugs were caused by typos like this? What percentage of all bugs was that? This looks to me like a feature request based on FUD that we're arguing against with FUD, some facts would be nice... > What do you think of this? The types-sig is a whole special interest group about this topic. I think that there are many cases in which you can't do the checks at compile time anyway (libraries that aren't strictly typed, eval()), and even more cases in which type checking would be bad (passing a UserList instead of a list). But that's mostly opinion, as I said, facts would be nice. And similar to Alex's excellent rant, I hope people aren't trying to make Python the one language to use for everything... -- Remco Gerlich From thomas at xs4all.net Tue Apr 24 11:54:06 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 24 Apr 2001 17:54:06 +0200 Subject: File locking In-Reply-To: ; from martinkaufmann@yahoo.com on Tue, Apr 24, 2001 at 03:02:36PM +0000 References: Message-ID: <20010424175405.H16486@xs4all.nl> On Tue, Apr 24, 2001 at 03:02:36PM +0000, Martin Kaufmann wrote: > Could somebody help me? I have a script that writes its output in a > logfile. This logfile is needed to check whether a task has already be > done. Several workstations are now using the same script (via nfs). So I > implemented the following file locking mechanism: > > logfile = posixfile.open(LOGFILE, 'a') > logfile.lock('|w') > [code snipped...] > log_string = '%s %s%s %d %s %s\n' % (mytime, host, url, > error_code, message, hostname) > logfile.write(log_string) > logfile.lock('u') > logfile.close() > > But I still get problems with two processes trying to write at the same > time. What is wrong with my implementation? NFS and fnctl/flock type locking do not go well together; see this recent posting of mine on python-dev for a longer explanation: http://mail.python.org/pipermail/python-dev/2001-April/014267.html If you're serious about locking over NFS, take a look at Mailman's LockFile module, which uses the 'link/stat' lock method which used to be in the 'open' manpage of several Linux distributions. We've used this lock method with BSDI, Linux and Network Appliance NFS servers, and BSDI, FreeBSD, Linux, SunOS and Solaris clients. It should work on all compliant NFS clients (which, granted, doesn't say that much -- but our experiences so far have been good.) You can find Mailman on www.list.org, or use the cvsweb running on Sourceforge to grab just LockFile.py. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jarober at mail.com Tue Apr 17 22:42:41 2001 From: jarober at mail.com (James A. Robertson) Date: Wed, 18 Apr 2001 02:42:41 GMT Subject: Musing out loud... [Why not Smalltalk?] References: <3AB70920.EB9116A8@idiom.com> <3AB76204.92D7FE30@shebs.cnchost.com> <3AB78893.2E9B8D47@ix.netcom.com> <99aamk$hoi$1@news.cs.tu-berlin.de> <99bdvh$ka2$1@news.cs.tu-berlin.de> <3AB96FF6.9EBBA182@idiom.com> <99cdje$cmv$1@news.cs.tu-berlin.de> <3AD81135.E4ADBB88@Desk.org> <3AD98C4C.FD3B94EC@Desk.org> <9bc6hq$6ab$1@nntp9.atl.mindspring.net> <9bisjb$k5j$1@slb7.atl.mindspring.net> Message-ID: <3ADCFFFD.4C8CD355@mail.com> Eric Clayberg wrote: > > "Piercarlo Grandi" wrote in message > news:yf366g3awne.fsf at sabi.ClaraNET.co.UK... > > > > Thus I find it a bit bizarre to imagine that "it took the Anamorphic > > team to pull them all together and prove that they worked in concert", > > because the Self group not only largely developed them, but they did > > that themselves (actually it was mostly just one guy for the > > Smalltalk-80 clone) and in the most straightforward way possible. > There's also this: Self took SCADS of memory to do it's thing, while HotSpot was relatively lightweight. The funny thing is, Sun had to do a lot of work anyway - optimizing tricks for Smalltak are not equivalent to optimizing tricks for Java > Then explain why Sun bought Anamorphic and their HotSpot technology for > *several* tens of millions of dollars. If Sun already had all this in house, > they had no reason to buy HotSpot. Were you around when the Anamorphic team > was shopping HotSpot around to the highest bidder? Did you see their > technology in action? I think you are severely underestimating the > significance of what the Anamorphic/HotSpot team developed. Apparently Sun > did not... > > -Eric -- James A. Robertson Product Manager (Smalltalk), Cincom jarober at mail.com From tim.one at home.com Sun Apr 29 16:48:04 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 29 Apr 2001 16:48:04 -0400 Subject: Opening up PEPS a little more. In-Reply-To: Message-ID: [Tom] > ... > - Is there a way to 'subscribe' to a PEP so that I receive > notification (or a copy of the PEP) each time its updated? Nope. The PEP sources are just another part of the CVS tree, and you can look at *all* CVS checkin msgs here: http://mail.python.org/pipermail/python-checkins/ Or you can subscribe to that list: http://mail.python.org/mailman/listinfo/python-checkins But that's it: all or nothing. > ... > - If I go to the list of PEPS, and choose #234, I get the > following page: > http://python.sourceforge.net/peps/pep-0234.html But I now see > that this is two revisions behind. So I'm guessing that the PEP > maintainer has to update these links manually. Yes, only a plain text form of the PEP is under CVS control. The HTML form is generated by a program, and people who check in changes to the text form are supposed to generate the HTML, then scp that by hand to SourceForge. That's something people seem to forget often, though. > ... > - It would be nice if each PEP had a public discussion forum. Sure. I don't know how to do it, though, and it requires a volunteer who does. In the meantime, some mailing lists have sprung up related to a few PEPs: http://sourceforge.net/mail/?group_id=5470 I personally can't keep track of all the Python-related mailing lists anymore, though, and the Geocrawler system (the thing SourceForge mailing lists hook up to) has such poor archive facilities as to be essentially useless for archiving. So better IMO to discuss PEPs on comp.lang.python, with a clear "[PEP nnn]" tag in the Subject line. From sholden at holdenweb.com Wed Apr 25 15:49:41 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 25 Apr 2001 19:49:41 GMT Subject: mysqldb simple question (find unique number) References: Message-ID: "Jacek Pop?awski" wrote in message news:slrn9eckbh.2f7.jp at localhost.localdomain... > id_producenta is primary key (int) for table producent > I need to find unique value for it, I use that code: > > dbh.query('select id_producenta from producent'); > res=dbh.store_result() > how=res.num_rows(); > id=[] > for i in range(how): > r=res.fetch_row() > id=id+[int(r[0][0])] > del res > return max(id)+1; > > Looks quite long... how to write it in better way? > MySQL implements the max() SQL function. Your current code has your database client program scanning all rows to find the maximum value. Try something along the lines of (untested): dbh.query('select max(id_producenta) from producent') res = dbh.store_result() # should only be one row! m = int(res.fetch_row()[0]) return m+1 Of course, you will realise that problems might arise should any two users concurrently try to use any such routine, since NySQL (as far as I remember) does not support transactions. regards steVe From whisper at oz.net Wed Apr 18 05:19:27 2001 From: whisper at oz.net (Dave LeBlanc) Date: 18 Apr 2001 09:19:27 GMT Subject: Hygienic macros (was: do...until wisdom needed...) References: Message-ID: <9bjm6v$be8$0@216.39.170.247> Sounds so much like Tcl! On 17 Apr 2001 20:59:52 -0400, Douglas Alan wrote: >Lisp has traditionally had "procedural macros". Procedural macros in >Lisp are a kind function -- they are implemented in Lisp, but the >return value of the macro, rather than being returned as a function >value, is taken to be a piece of code. This is easier in Lisp than >in most languages because Lisp code is a kind of Lisp data structure. >The code that is returned by the macro call, which is executed at >compile-time, is used to replace the original call to the macro. > >This allows a programmer to define new syntactic forms. These behave >differently from normal function calls, since they can do things like >rebind variables in the scope of the macro invocation, etc., and they >avoid procedure call overhead, so they can be used to effectively >force inlining. > >The problem with non-hygienic macros is that variable names used by the >macro implementation can conflict with variable names that are passed >into the macro. Hygienic macros solve this problem by putting the >variables in different namespaces. > >Hope this helps. > >|>oug From frandebo at latt.if.usp.br Fri Apr 27 13:59:12 2001 From: frandebo at latt.if.usp.br (Francisco) Date: Fri, 27 Apr 2001 14:59:12 -0300 Subject: HELP: python2.1: "SRE module mismatch" Message-ID: Hello folks, I compiled python2.1 with Debian (potato) Linux and I`m getting a problem with sre module. Anything that tries to use sre will end up like this: File "/usr/local/lib/python2.1/glob.py", line 4, in ? import fnmatch File "/usr/local/lib/python2.1/fnmatch.py", line 13, in ? import re File "/usr/local/lib/python2.1/re.py", line 28, in ? from sre import * File "/usr/local/lib/python2.1/sre.py", line 17, in ? import sre_compile File "/usr/local/lib/python2.1/sre_compile.py", line 15, in ? assert _sre.MAGIC == MAGIC, "SRE module mismatch" AttributeError: MAGIC any hints on what I can do to solve this? -- Francisco. S?o Paulo, Brasil. __o `\<, _____(*)/(*)_____ From s713221 at student.gu.edu.au Thu Apr 19 06:36:48 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Thu, 19 Apr 2001 10:36:48 +0000 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <9bkg2g$fnt$0@216.39.170.247> Message-ID: <3ADEBFC0.ABD33822@student.gu.edu.au> Dave LeBlanc wrote: > I was going to mention super, but given the multiple inheritance > nature of Python, it wouldn't work. If you want super functionality, a poster a year or so ago, submitted this little hack for a situation where he wanted to use a derived class with multiple base classes, but without having to retype dozens of lines of code. class friendly: def __init__(self): print "Hello" class friendlier(friendly): def __super(self): return friendly def __init__(self, name): self.__super().__init__(self) print name As long as you've only got single inheritance, or are only interested in the first class, you can automate it as follows: class friendlier(friendly): def __super(self): return self.__class__.__bases__[0] Useful in some situations, Joal Heagney/AncientHart From neilh at scintilla.org Thu Apr 12 19:29:33 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 12 Apr 2001 23:29:33 GMT Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> <9b1sf4$2hm3$1@news4.isdnet.net> <3ad47a9b$0$47989$e2e8da3@nntp.cts.com> <3AD5C5BA.4365643F@bt.com> Message-ID: Alan Gauld: > ActiveX doersn't work on Mac or Linux. ActiveX controls have been implemented for the Mac. I subscribed to the Mac ActiveX mailing list back when doing a lot of COM work but there was very little activity and I think Microsoft stopped bothering to put out code or documentation. Its likely the support is still in IE for Mac as Microsoft builds almost everything on top of COM. Neil From philh at comuno.freeserve.co.uk Wed Apr 11 17:40:59 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 11 Apr 2001 22:40:59 +0100 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> <9b1sf4$2hm3$1@news4.isdnet.net> <3ad47a9b$0$47989$e2e8da3@nntp.cts.com> Message-ID: On Wed, 11 Apr 2001 08:40:19 -0700, Robert Johnson wrote: > >"Gilles Lenfant" wrote in message >news:9b1sf4$2hm3$1 at news4.isdnet.net... >> What about running an activeX on a Mac or Linux box ? >> If you want a real cross platform support (any OS and any browser) you >> should consider using jython to make applets in python. >> www.jython.org >> Warning: this requires you program the GUI with java packages (Swing or >AWT) >> and not with usual "pythonic" Tkinter. >> and AFAIK, Swing applets swing applets run only with Netscape 6 or with IE >+ >> Java 2 plugin. >> > >Python and TKInter don't work on Mac or Linux boxes? Yes they do. They just don't work *as web applets*. But python/Tkinter is a very good solution for multi-platform programming, IMO. -- *****[ Phil Hunt ***** philh at comuno.freeserve.co.uk ]***** "Mommy, make the nasty penguin go away." -- Jim Allchin, MS head of OS development, regarding open source software (paraphrased). From ben.hutchings at roundpoint.com Sun Apr 29 21:45:06 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 29 Apr 2001 18:45:06 -0700 Subject: Method to give name of class instance? References: <3aecaef9.340108430@news.mindspring.com> Message-ID: timothyr at timothyr.com (Timothy L. Robertson) writes: > Hi Everyone, > > I've been enjoying learning Python very much, but have hit a little > snag. I want a way to find out the name of a class instance from a > method. eg. > > >>>classinstance=MyClass() > >>>classinstance.myname() > 'classinstance' > > Is there a way to do this? No, instances don't have names because they may have any number of names bound to them, even none at all. Example 1: a = MyClass() b = a Here, both a and b refer to the same instance. Example 2: a = [MyClass()] Here, no name refers to the instance. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From grante at visi.com Mon Apr 2 22:29:39 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 03 Apr 2001 02:29:39 GMT Subject: "Fastest growing programming language" References: Message-ID: On Mon, 02 Apr 2001 21:53:31 -0400, Roy Smith wrote: >grante at visi.com (Grant Edwards) wrote: >> It's based on the only metric that makes sense: the rate of >> increase of Usenet traffic in c.l.. > >By that measure, wouldn't Parrot be the fastest growing? :-) Nope -- in only counts once there's a c.l.parrot. I don't make up the rules... -- Grant Edwards grante Yow! I am a traffic light, at and Alan Ginzberg kidnapped visi.com my laundry in 1927! From fredrik at pythonware.com Mon Apr 9 16:13:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 09 Apr 2001 20:13:14 GMT Subject: writing to locals (was RE: execfile: NameError exception thrown for things in locals()) References: Message-ID: James_Althoff at i2.com wrote: > ... my class ... > > def setFormula(self,formulaString): > self.formula = formulaString > > def getCalculatedValueAt(self,rowIndex): > count = self.getColumnCount() # excludes the calculated column > localsDict = locals() > for columnIndex in xrange(count): > columnID = 'c' + str(columnIndex+1) > columnValue = self.getValueAt(rowIndex,columnIndex) > localsDict[columnID] = columnValue > try: > value = eval(self.formula) > except: > value = 'Invalid formula' > return value localsDict = {} for columnIndex in xrange(count): columnID = 'c' + str(columnIndex+1) columnValue = self.getValueAt(rowIndex,columnIndex) localsDict[columnID] = columnValue try: value = eval(self.formula, localsDict) except: value = 'Invalid formula' return value Cheers /F From fredrik at pythonware.com Mon Apr 16 12:31:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 16 Apr 2001 16:31:26 GMT Subject: Apache/Win 95 Irregularity References: Message-ID: Steve Holden wrote: > Under Windows 95 using Apache/1.3.19 and ActivePython (original build) I get > something which IE 5.5 reports as being a 2326-byte GIF file containing a > 259 x 32-pixel image whose appearance bears no relation to the Apache logo: http://www.python.org/doc/FAQ.html#7.12 Q. cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! summary: the output stream is opened in text mode under Windows. to get binary mode, run the interpreter with the -u option. > #!C:\Python20\python this might work: #!C:\Python20\python -u > ## > ## image.py: serve a GIF image > ## > import sys, base64 > o = open("C:/Program Files/Apache > Group/Apache/htdocs/apache_pb.gif","rb").read() > sys.stdout.write('Content-Type: image/gif\r\n') > sys.stdout.write('Content-Length: %d\r\n\r\n' % len(o)) > sys.stdout.write(o) Cheers /F From cmg at uab.edu Thu Apr 12 10:28:36 2001 From: cmg at uab.edu (Chris Green) Date: 12 Apr 2001 09:28:36 -0500 Subject: OT - Closing Off An Open-Source Product References: <20010412071455.B3140-100000@open-systems.net> Message-ID: "Chris Gonnerman" writes: > > But I have started adding a new clause to my BSDL code now killing their > > ability to do that. > > Mind showing us your license? Sounds interesting. One method would be to simply add the advertising style clause back in to a BSD license. I'm not for that but it's the simplest way I can think of. -- Chris Green This is my signature. There are many like it but this one is mine. From nils.hensel at online.de Mon Apr 23 15:38:08 2001 From: nils.hensel at online.de (Nils Hensel) Date: Mon, 23 Apr 2001 21:38:08 +0200 Subject: Newbie question about dictionaries in classes References: Message-ID: <9c2083$7dn$1@news.online.de> If you declare aaa in the class body it will be a class varaible instead of an instance variable which means that it's shared by all instances of this class. If you want each myclass to have it's own aaa you must declare a constructor that initializes this special instance like this: class myclass: def __init__ (self, dict = None): # by looking at your code I presume that you want to initialize your class with a dictionary if dict is None: dict = {} self.aaa=dict def add(self,u): (self.aaa)[u]=1 def show(self): print self.aaa HTH, Nils "Jacek Pliszka" schrieb im Newsbeitrag news:Pine.LNX.4.30.0104232122310.23315-100000 at ift4.fuw.edu.pl... > Hi! > > I just started to learn Python and I got stuck with the following > problem: > > class myclass: > aaa={} > def add(self,u): > (self.aaa)[u]=1 > def show(self): > print self.aaa > > ula=myclass({}) > > ula.add(13) > > ola=myclass({}) > > ula.add(11) > > ola.add(11) > > ula.show() > > ola.show() > > then I get the result that aaa in both ula and ola > is identical!!! I thought that aaa will be different for > ula and ola!! > > What am I doing wrong? > > Thanks in advance for any help, > > Jacek > > From emile at fenx.com Wed Apr 11 22:38:51 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 11 Apr 2001 19:38:51 -0700 Subject: Chocolate [was Re: Python Books for 2002] References: <3AD3C751.CF669272@cosc.canterbury.ac.nz> <5eRA6.411$C4.21656@uchinews> <3AD50BB3.E71891A2@cosc.canterbury.ac.nz> Message-ID: <9b34mv$7onun$1@ID-11957.news.dfncis.de> But wouldn't it just as likely then be: person.be_consumed_by(substance) -- Emile van Sebille emile at fenx.com --------- "Greg Ewing" wrote in message news:3AD50BB3.E71891A2 at cosc.canterbury.ac.nz... > Ben Wolfson wrote: > > > > from Animals.Mammals import Human > > > > hungry_person = Human() > > > > So that the hungry_person can .consume() the comestibles. > > But the method of consumption depends on the class > of the substance, so dispatching on it seems > appropriate. Perhaps > > substance.be_consumed_by(person) > > Then in the future one could define additional > classes of substance such as Cocaine and Heroin > and the code will continue to work. > > -- > 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 nessus at mit.edu Mon Apr 16 00:47:49 2001 From: nessus at mit.edu (Douglas Alan) Date: 16 Apr 2001 00:47:49 -0400 Subject: Class Variable Question References: <9at1ul010vn@news1.newsguy.com> <3ad2a7dd$0$47987$e2e8da3@nntp.cts.com> <9aush501oro@news2.newsguy.com> <9bcjpp01t9n@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Marcin 'Qrczak' Kowalczyk" wrote: >>> Your C++ compiler doesn't catch all the typos you can make where >>> you type '+' while meaning to type '-', or '>' intending '<', etc, >>> for example. > > Of course. No language catches such typos. > > It doesn't imply that catching detectable typos (e.g. using names > > which are not defined) is worthless! > No, it just puts that worth in perspective. It's worth _something_, > sure -- but not very much. You are just dead wrong here, Alex. Perhaps it's not worth much to *you*, in which case you should speak for yourself. You are not speaking for *me*, however, because I know precisely how much it is worth to me, and it's worth a *lot*. You can't deign to tell me how much something is worth to me because you have no way of knowing, now do you? This doesn't mean I don't recognize that there are often trade-offs between safety and expressive power. I love Python for its expressive power. I love Lisp for having even more expressive power. (Procedural macros, I love you!) I often curse dynamic languages for not catching certain bugs for me at compile time. Consequently I love C++ for helping me make programs that require very little time debugging. On the other hand, I curse C++ for constraining me in all sorts of ways that really get under my skin. If I were forced to program in only one language, C++ wouldn't be the one. If you want to believe that there's One True Answer, feel free, but keep it to yourself. The rest of us realize that life is about trade-offs. Regarding the specific proposal in question -- to require declaring a variable before using it -- counter to what you say, this does *not* result in any less flexibility or expressive power. It may result sometimes in a bit more typing, but that is it. There may be many good reasons to exclude such a feature from the language at this point, backwards compatability being a salient one, but this doesn't mean that many people wouldn't find this to be a very useful feature to have, and that it wouldn't reduce the debugging load of many programmers. It would certainly significantly reduce mine, since this type of typo is one that I'm particularly prone to, and it often results in bugs that are rather difficult to track down. Just because you don't make this type of typo a lot, doesn't mean the rest of us are so fortunate. But this is one of the main reasons that Python appeals to the "rest of us", as opposed to Perl. Perl is much less typo resistant. A small typo in Perl is very likely to cause the program to do something different and wrong, rather than causing an immediately detectible error. This, in my opinion (and in the opinion of the legendary David Moon), is bad programming language design. A language should be as resistant to typos as it is convenient to make it. When the programmer makes a typo, it should in most cases cause the program to generate an obvious error. To disagree with this premise is to agree with the Perl philosophy, rather than the Python philosophy. Thank goodness Python wasn't designed with the philosophy that unit tests should be used to catch all typos. If it were, I'd hate Python as much as I hate Perl. |>oug From tdelaney at avaya.com Sun Apr 1 21:22:15 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 2 Apr 2001 11:22:15 +1000 Subject: list vs tuple Message-ID: Either he's a troll, or deadmeat hasn't learned yet that much of what he learned in high school was "lies-to-children". Deadmeat: most of what you learned about programming from the age of 7 is quite simply bad habits which need to be broken. Almost all the programmers I know can quite happily swap from one language to another with minimal time to aclimatise to the idiosyncracies of each language. I myself have known over 20 programming/scripting languages which were *not* one-off uses only, quite a few of which I've forgotten now. And I'm only 27. I fully expect to have a working knowledge of at least an additional 5 over the next couple of years. Some will get used for one task, and then quickly discarded. Others, such as Python, will quickly become an integral part of my toolset. Tim Delaney Avaya Australia +61 2 9352 9079 All recipient(s) of this email have permission to forward or reply to this email, quoting this email in full or in part. > > > Reset your brain. > > > > Anyone who thinks a programmer can do this is quite insane. > I've been > > programming since I was 7 or 8, and did advanced > mathematics throughout > > highschool. Forgetting such basic principles is not > possible, esp. not > > with the given documentation which gives nothing to fill > that void until > > later. > > A lot of people who were a bit more open-minded than you, did > succeed in > "resetting their brain" and accepting and understanding the > Python object > model. Many people here have been trying to explain it you, > and pointed out > that there really is no inconsistency here. It is now clear > that they have > been wasting their time. You obviously don't want to learn; > you want to > keep on seeing Python through your Pascal-goggles and then > complain that > things don't work the way you expect. If that is the case, > then do it in > private and stop bothering people who do understand the language. From hohage at muenster.de Mon Apr 16 21:45:24 2001 From: hohage at muenster.de (sven) Date: Mon, 16 Apr 2001 21:45:24 -0400 Subject: new bee question :Collection of objects Message-ID: <01041621452400.02386@localhost.localdomain> Hello Manoj, in Zope you can use an external method in which you can define arrays. Then you can iterate over this external method. You can't just define outside of Zope a *.py file and then use it in Zope. It has to be in the ZODB (Zope Object Data Base) to be reached from inside of Zope. To put an object or an array into ZODB normally you define a product or if it's just a small script, you can use an external method. Hope this helps. From sholden at holdenweb.com Sat Apr 7 17:04:14 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 7 Apr 2001 17:04:14 -0400 Subject: Which happens first? References: <3ACE89D7.9106E941@mail.verizon.net> Message-ID: <0gLz6.111478$5H6.4148690@e420r-atl2.usenetserver.com> "Lloyd Hugh Allen" wrote in message news:3ACE89D7.9106E941 at mail.verizon.net... > John Yeager wrote: > > > > I know that this may be a dumb questio, yet I am new to programming and I > > am courious in a mathmatical expression such as ( 16 * ( 15j + ( 4.2 - > > 3.9 ) + 20 ) / -2 ) % 5 which happens first is the () or is it the > > conversion to the complex number?? I would think it would be the () > > US folks use the convention "PEMDAS", "Please excuse my dear aunt > sally", to remember > . > > Aussie folks (according to some mailing list a year or two ago--maybe AP > Calc?) use "GEMA": . > The UK, of course, *has* to be different. The father of one of my friends was a maths teacher, who was saddled with the nickname BODMAS, which is the UK version: brackets, of, divide, multiply, add, subtract. Of course it should really have been B to indicate some operators have equal priority, but you can't have everything. regards Steve From kc5tja at garnet.armored.net Wed Apr 18 13:43:25 2001 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 18 Apr 2001 10:43:25 -0700 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <9bjl2901ifj@news1.newsguy.com> Message-ID: On Wed, 18 Apr 2001 14:40:41 GMT, Rainer Deyke wrote: >namespace jam { > int x = 5; > void f() > { > std::cout << ::jam::x << std::endl; > } >} > >Another thing that C++ got right and Python got wrong. I::think Python::has::better scoping::designator ::though. ::-) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From nomail at nomail.com Tue Apr 3 14:26:53 2001 From: nomail at nomail.com (Dry Ice) Date: Tue, 3 Apr 2001 11:26:53 -0700 Subject: Python and Java Compared? References: <3ac6f744_1@news4.newsfeeds.com> Message-ID: <3aca143c_2@news4.newsfeeds.com> [...] Observations greatly appreciated. > If you need/want to run in browsers, use jython to generate Java > bytecodes from your Python source and pack it up in a jar. > How about applet production? Possible with Jython? From news at myNOSPAM.org Sun Apr 22 05:59:48 2001 From: news at myNOSPAM.org (Stephen) Date: Sun, 22 Apr 2001 09:59:48 GMT Subject: Submitting Bugs at Sourceforge Message-ID: Hello, I'm in the process of working on the Python-2.1 sources to make them compile from Borland C++Builder, since it has a free compiler out there and all. I'm done, actually, except for peering at the msvcrt and decide how I want to fix that one:) Its actually been incredibly simple, since its just mostly a matter of different spellings of various constants/functions (when VC names something _function, borland names it function... and when borland names something _function, VC names it function. Grr!) I just managed to get a python21.dll out of it C++Builder, so I imagine its been halfway a success :) Now, my question: I submitted 4 bug-reports on the various minor fixes that needed to be done, and have 4 left that I havn't sent in yet. Just in general, would it be better for me to send in a batch of those little fixes, or submit each one as a seperate bug report? For the most part, they're changing various #defines which at the moment assume Win32 = Visual C++. Anyways. Off to bed. --Stephen (replace 'NOSPAM' with 'seraph' to respond in email) From wolfson at uchicago.edu Wed Apr 11 00:40:12 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Tue, 10 Apr 2001 23:40:12 -0500 Subject: Chocolate [was Re: Python Books for 2002] References: <3AD3C751.CF669272@cosc.canterbury.ac.nz> Message-ID: <5eRA6.411$C4.21656@uchinews> In article <3AD3C751.CF669272 at cosc.canterbury.ac.nz>, "Greg Ewing" wrote: > Simon Brunning wrote: >> >> from Europe.England import beer >> >> > for food in dir(): >> > if food[:2] != '_': >> > eat(food) > > But beer has to be drunk, not eaten, so you'll need > > for comestible in dir(): > if comestible[:2] != '_': > comestible.consume() But this is bad design, since the comestible doesn't consume anything, but is consumed by an eater. Something like from Animals.Mammals import Human hungry_person = Human() So that the hungry_person can .consume() the comestibles. Besides, the OED seems to be telling me (I can't tell because the web site's design is confusing) that "comestible" refers only to things one eats anyway. -- Barnabas T. Rumjuggler The women come and go, Speaking of the Regis Philbin Show -- Joe Frank From mhuening at zedat.fu-berlin.de Tue Apr 10 06:58:28 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Tue, 10 Apr 2001 12:58:28 +0200 Subject: image size References: <9auksc$6s696$1@fu-berlin.de> <3AD2DF56.833A252C@hack.org> Message-ID: <9auoqq$75t8n$1@fu-berlin.de> Rikard Bosnjakovic wrote: > > Use PIL. > Thanks a lot!! I just downloaded PIL. Great! Matthias From bosahv at netscapenospam.net Mon Apr 16 00:05:55 2001 From: bosahv at netscapenospam.net (Bo Vandenberg) Date: Mon, 16 Apr 2001 04:05:55 GMT Subject: Stability On Win32 -- Graphics Message-ID: I have to work primarily in a windows environment and I've been looking for RAD tools for Network administration. I've been looking at Wxpython and Tkinter as GUIs for my users. Unfortunately there is nothing of this kind yet on our network, can someone tell me if there is a deployment\stability advantage to either? I'm not concerned so much at this time with speed. Can either of them be as easily packaged to expand on the client machine simply??? Which requires more libraries\support files. Bo Thanks in Advance. From sholden at holdenweb.com Mon Apr 9 12:49:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 9 Apr 2001 12:49:08 -0400 Subject: other python ideas References: <9asj350g42@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9asj350g42 at news1.newsguy.com... > Us pythmen sure seem to come to simplicity by tortuous ways... > Erm, shouldn't that be "pythpeople" or "pythpersons", or in your case "pythbots"? politically-correct-ly y'rs - steve From r_olson at acusd.edu Sat Apr 21 16:25:01 2001 From: r_olson at acusd.edu (Rick Olson) Date: Sat, 21 Apr 2001 13:25:01 -0700 Subject: Does Python seem appropriate for me? Message-ID: Hi-- I'm doing some research developing some algorithms for solving scheduling problems. In the past, I have done most of my work using MS C/C++ v. 7 or the Watcom compiler on a PC because I could run the result in a DOS environment making it easy to write big batch files and run comparisons to other code on a system with little system overheard. I am now getting ready to start a new project. WIN2k has eliminated DOS from my list of options, so I thought I'd take the plunge into Linux. The work has essentially three parts: a) Conceptual developing/coding algorithm b) Tuning algorithms to get good performance c) Running comparisons against algorithms developed by other people. Step b) would be best done with a GUI. Speed isn't as important as it will be in step c. There are many parameter settings to try and it would be nice to have a "control panel" that I can use to enter parameters and see results keep track of things. Step c) is best done at the command line level. I will run each instance of an algorithm by itself with as few system processes as possible running. Consequently, I would like the program to be self-contained with input from a command line and no GUI interface. Output will consist of one or two numbers. >From what I've picked up in other ngs it sounds like Python with Tkinter may be the answer. It sounds like I can write a GUI interface that can extract the information from the screen. This info can be the command line prompts to a call execute the program. Q1> Can I (relatively easily) also use the output from the program to change display? This would allow an interactive test bed. Q2> Does it seem like Python+Tkinter is an appropriate approach? I don't want to need to become highly skilled in either to do the job. If I can piece the interface together in a week or two I'd be content. Q3> Assuming Python makes sense, what books would you recommend. Again, I don't need to acquire deep understanding. I like the "learn by stealing examples" approach, but have been burned too many times by buggy examples. Should I pick up a Tk/Tcl book or two, also? Q4> I like GUI programming environments. I'm not thrilled with using gdb to debug. Is there an X-Windows or KDE programming environment I should pursue? (Or is there something I've been missing about gdb) What references would you recommend? It seems like lots of books have single chapters on these topics, but I'd rather have a dedicated source. Q5> I'm inclined to go with the Red Hat Distribution. Is there any reason I shouldn't? Do I need a Linux book or are the docs on the Red Hat and Linux pages adequate? Thanks in advance- Rick Olson Industrial and Systems Engineering University of San Diego From grey at despair.rpglink.com Fri Apr 20 06:10:46 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 20 Apr 2001 10:10:46 -0000 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9bjtbr02108@news1.newsguy.com> <9bl6i701e09@news1.newsguy.com> <9bmgid081b@news1.newsguy.com> <9bng2l019nb@news1.newsguy.com> Message-ID: On 19 Apr 2001 17:58:40 -0400, Douglas Alan wrote: >My dictionaries disagree with your dictionary. My Webster says that >abuse "stresses harshness and unfairness of verbal attack". It is the >*attack* that must be "harsh" for words to be "abusive" -- the words >themselves do not need to be harsh. Well, gee, Alex hasn't been harsh in my book. I mean, you're the one who made the comment, and I'm paraphrasing here.... $#%$ you! You know, fsck you in unix terms. I think that given the two labels and the two people in the thread you're the abusive one. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From sholden at holdenweb.com Fri Apr 20 23:11:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 20 Apr 2001 23:11:04 -0400 Subject: Python compiler? References: <3AE0CF24.9020303@netscape.net> Message-ID: "Rocco Moretti" wrote in message news:3AE0CF24.9020303 at netscape.net... > Steve Holden crafted these words: > If so, then some _other_ Steve Holden, I suspect. This attribution appears to be wrong. regards StEvE > > > There's an article on the May edition of DDJ called "Compiling Perl/Tk > > Scripts" by Cameron Laird that might also be useful. The abstract is, > > people want to compile because of 1) speed; 2) code security; 3) size; > > 4) fashion (i.e., just because it's cool); 5) packaging (easier to > > deploy, no separated interpreter installation needed). > > > > Of all three er.. five, compiling dynamic scripting languages only > > effectively gives us number 4 & 5. > > > > Steve > > I think you may be overstating your case. > > The article in question, as it's title suggests, only looked at Perl/Tk > compilers, and only at those on MS-Windows, a sample size of two. It > didn't even mention compilers for any other language, or even any other > platform. > > In fact, if you want to be a stickler, you might not even consider them > "compilers." I know nothing about the products, but from the article it > seems that they are equivalent to a "freeze" tool, wrapping the perl > script with a minimal interpreter in a standalone executable. > > Thus you get 4) and 5), because you now have a single executable. > > You don't get 3) because you have both the script and the interpreter. > (Even though stripped down, it is still sizable.) Heck, for compiling > small C programs you don't get a size benefit due to the loader code and > the included library functions. > > Code security (2) is out because the "compiled" programs store the > original perl script as a plaintext string in the executable. (Easily > findable by anyone with a hex editor.) And since you're still interpreting > the program, you aren't going to get a speed advantage (1). > > My take on the article is that its directed at clueless IT directors who > see "compiler" in the program's name and think it's a pancea to their > problems. (Perhaps Mr. Laird, who has been seen in this newsgroup, could > clarify, and add his comments on how he thinks Python relates.) > > Note that a "true" compiler, which converts the script itself to machine > code and optimizes it, may see benefits in all five points. > > If Python will see such a compiler is still an open question. > > -- > Rocco Moretti > > > > From aleaxit at yahoo.com Fri Apr 6 05:59:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Apr 2001 11:59:37 +0200 Subject: python modules as user configuration files References: Message-ID: <9ak42902ajr@news2.newsguy.com> "Robin Thomas" wrote in message news:mailman.986503148.3570.python-list at python.org... [snip] > I would recommend not using "import", which would actually install the > module in sys.modules and possibly screw up imports of other, legitimate > modules you have created. Also, importing from a fullpath is not very > straightforward. I agree that execfile looks like a better match for the original poster's needs (except it may need the ```exec "pass"''' kludge to use it inside a function, as another thread just mentioned), but "importing from a fullpath" isn't all that hard, I think. Something like the following might suffice, I believe: def importFullpath(path, modname): import imp try: found = imp.find_module(modname, [path]) except: return None try: return imp.load_module(modname, *found) finally: file.close() Alex From whisper at oz.nospamnet Sun Apr 22 03:07:04 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 22 Apr 2001 07:07:04 GMT Subject: Python-2.1(Windows) Optional supproject build problems Message-ID: <9btvuo$nr6$0@216.39.170.247> All the projects say that needed 3rd party source headers are in ..\..\<3rdPartySource>. For example, the include path for expat/xmlparse is "..\..\expat\xmlparse". However, the pcbuild/readme.txt files says to put them in as a sibling of PCbuild's parent directory - in the example given, "dist". Alas, the grandparent (..\..) of PcBuild is "\" since I think most people are going to install to the root... >From the PCbuild/readme.txt file: "The following subprojects will generally NOT build out of the box. They wrap code Python doesn't control, and you'll need to download the base packages first and unpack them into siblings of PCbuilds's parent directory; for example, if your PCbuild is .......\dist\src\PCbuild\, unpack into new subdirectories of dist\." As you can see from reading this, the parent directory of PCbuild is src, not dist. Actually, when I read the readme.txt file, initially I was under the impresion that there should be a dist directory under Python-2.1. Didn't make a whole lot of sense to me at the time, but one never knows ;-) My sugggestion would be to have a directory under Python-2.1 called "packages" which would be the parent directory of all 3rd party sources needed to compile the "optional" packages, and to fix the VC project files appropriately. Dave LeBlanc From wolfson at midway.uchicago.edu Sun Apr 1 00:25:44 2001 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Sun, 01 Apr 2001 05:25:44 GMT Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6B9C5.68EFC041@alcyone.com> Message-ID: In article <3AC6B9C5.68EFC041 at alcyone.com>, Erik Max Francis wrote: >Emile van Sebille wrote: > >> Yes, it comes up. Generally, except for short-circuiting, the >> solutions >> follow: >> >> >>> 1 and 2 or 3 >> 2 >> >>> 0 and 2 or 3 >> 3 > >Yeah, but the short-circuiting exceptions are what make that construct >not worth using, since if used identically as a replacement for a >conditional expression, it won't work when a is 0 (or any other >expression that evaluates to false). Easily, if unreadably, solved: (condition and (a,) or (b,))[0] -- Barnabas T. Rumjuggler You do not use a macintosh instead you use a tandy Kompressor break your glowstick Kompressor eat your candy From donod at home.com Wed Apr 18 00:40:41 2001 From: donod at home.com (Don O'Donnell) Date: Wed, 18 Apr 2001 04:40:41 GMT Subject: do...until wisdom found... References: Message-ID: <3ADD1B1F.3CEC9915@home.com> Ken Peek wrote: > ... > Some people have suggested that "loop:" is a much better keyword than "do:". > Now I am wondering if they are right-- maybe so. I will have to think about > that some more-- maybe "loop:" IS more readable (by a programming newbie) than > "do:"... hmmm.... > I think "repeat:" is better than "do:" and "loop:". "do:" doesn't really express what's going on, and "loop:" is slangy and idiomatic "programmereese". but-not-getting-why-you-need-it-ly y'rs - Don From tanzer at swing.co.at Sun Apr 29 07:13:51 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Sun, 29 Apr 2001 13:13:51 +0200 Subject: using lambda to print everything in a list In-Reply-To: Your message of "29 Apr 2001 07:39:56 GMT." Message-ID: scarblac at pino.selwerd.nl wrote: > Christian Tanzer wrote in comp.lang.python: > > > > "Alex Martelli" wrote: > > > > > My personal impression is that lambda is a (minor) > > > nuisance. Naming the code fragment that you want > > > to pass to some other function, by making it a > > > nested function, seems clearer & handier to me. > > > > What about using `map' to apply a method to each element in a list? > > > > Like in: > > > > map (lambda s : s.capitalize (), l) > > > > I wouldn't call a loop clearer in this case, despite the lambda. > > That is debatable, but the list comprehension is fine: > > [ s.capitalize() for s in l ] Yes, that is the best alternative. Hope I get rid of 1.5.2 soon. > > For strings, one could of course pass `string.capitalize' to `map'. > > Unfortunately, this loop hole exists only for strings, and the powers > > that be plan on making the string module obsolete, anyway. > > I really don't think they plan on that. IIRC a while ago there was quite some discussion on deprecating the string module with the BDFL clearly in favor of doing so. -- 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 root at [127.0.0.1] Mon Apr 16 02:06:31 2001 From: root at [127.0.0.1] (deadmeat) Date: Mon, 16 Apr 2001 06:06:31 GMT Subject: do...until wisdom needed... References: Message-ID: > Here is my question-- If Python WERE to have a "do...until" construct, what > would be the best way to implement the syntactical rules? until a == b: some thing ie. the same as while, except until guarantees at least a single recursion. this would mean very little change to Python to implement, just a minor modification on the while handler. it's not as clear as do (code) until but I don't like ending code blocks with with control structures... esp. not in Python. From pipi10 at wp.pl Fri Apr 6 15:02:26 2001 From: pipi10 at wp.pl (pi) Date: Fri, 6 Apr 2001 21:02:26 +0200 Subject: POST Message-ID: <9aksot$dhg$1@korweta.task.gda.pl> What I can fill the form on www (method POST) ----- POST /glosuj/ HTTP/1.0 Host: nlp.wp.pl Accept: text/html, text/plain, application/msword, audio/x-mpeg, audio/x-pn-realaudio, audio/x-pn-realaudio-plugin, text/sgml, */*;q=0.01 Accept-Encoding: gzip, compress Accept-Language: pl Accept-Charset: iso-8859-2, iso-8859-1;q=0.01, us-ascii;q=0.01 Pragma: no-cache Cache-Control: no-cache User-Agent: Lynx/2.8.4dev.8 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.5a Content-Type: application/x-www-form-urlencoded Content-Length: 120 url=http%3A%2F%2Fwww.smiechuwarte.prv.pl%2F&rank=4&group=fun&comment=koment&nick=email at w.pl&reward=rmf-s&submit=Oddaj+glos --- Please help me. -- 3.1415 From kalle at gnupung.net Wed Apr 11 18:25:06 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Thu, 12 Apr 2001 00:25:06 +0200 Subject: Easy question In-Reply-To: <001401c0c2d4$e4194310$b503a8c0@activestate.ca>; from BrianQ@ActiveState.com on Wed, Apr 11, 2001 at 03:15:17PM -0700 References: <20010411234908.B375@apone.network.loc> <001401c0c2d4$e4194310$b503a8c0@activestate.ca> Message-ID: <20010412002506.D375@apone.network.loc> Sez Brian Quinlan: > Kalle wrote: > > Also, this will blow up if there is a tab at the end of the line: > > I was assuming that the data format is: > > ::= *(\t)* > > So it would be an error in the datafile if a tab is not succeeded by an > integer. Of course, it all depends on what the original poster wanted :-) It's just that I've had too many bad data files thrown at me. Wounds that never heal. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From dbrueck at edgix.com Thu Apr 19 12:14:10 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Thu, 19 Apr 2001 10:14:10 -0600 Subject: Newbie question: how to determine "is-a" relationship References: Message-ID: <0b4301c0c8eb$d08ee7b0$450514ac@PRODUT2KDAVE> Hi Jake, Try the issubclass and isinstance functions: >>> class A:pass >>> class B(A):pass >>> class C(A):pass >>> q = [A(),B(),C()] >>> for z in q: ... print z.__class__ ... print isinstance(z,A), isinstance(z,B),isinstance(z,C) __main__.A 1 0 0 __main__.B 1 1 0 __main__.C 1 0 1 >>> print issubclass(B,A) 1 >>> print issubclass(A,A) 1 >>> print issubclass(C,A) 1 >>> print issubclass(C,B) 0 -Dave ----- Original Message ----- From: "Jake Baker" To: Sent: Thursday, April 19, 2001 9:46 AM Subject: Newbie question: how to determine "is-a" relationship Gosh. I've been using Python since 96 and I don't know this! Wow! Say I have a class heirarchy that looks like A, B <- A, C <- A, etc.... I have a list of objects (which I know arbitrarily are all A or sublasses of A) and want to filter them based on which subclass they are. How do I go about doing this? You help is greatly appreciated! Thanks, - Jake Baker -- http://mail.python.org/mailman/listinfo/python-list From Patrick.Bussi at space.alcatel.fr Wed Apr 11 13:35:28 2001 From: Patrick.Bussi at space.alcatel.fr (Patrick.Bussi at space.alcatel.fr) Date: Wed, 11 Apr 2001 19:35:28 +0200 Subject: Help for urllib error : 'no host given' Message-ID: Hello, I cannot understand why I get the following error. 1) Here is an extract of the web page content I want to parse : ------------- function RedirectPage() { document.location ="http://www.nicewebsite.com"; } ------------- 2) Here is the program I use to extract the URL to which I need to redirect my browsing (ugly, I agree) ------------- q=re.compile("document.location =.*") t2=q.search(f3) # f3 contains the full string of the web page b= t2.group() q1=re.compile('[^document.location ="].*[^";]') t4=q1.search(b) redirectURL=t4.group() f4=urllib.urlopen(redirectURL).read() -------------- The program successfully extracts the name of the Url. I can print the exact text "http://www.nicewebsite.com" (without the quotes). 3) And finally here is the traceback I get : ----------------------- Traceback (innermost last): File "./MyProgram", line 157, in ? f4=urllib.urlopen(redirectURL).read() File "/usr/lib/python1.5/urllib.py", line 59, in urlopen return _urlopener.open(url) File "/usr/lib/python1.5/urllib.py", line 157, in open return getattr(self, name)(url) File "/usr/lib/python1.5/urllib.py", line 272, in open_http return self.http_error(url, fp, errcode, errmsg, headers) File "/usr/lib/python1.5/urllib.py", line 285, in http_error result = method(url, fp, errcode, errmsg, headers) File "/usr/lib/python1.5/urllib.py", line 456, in http_error_302 return self.open(newurl, data) File "/usr/lib/python1.5/urllib.py", line 157, in open return getattr(self, name)(url) File "/usr/lib/python1.5/urllib.py", line 247, in open_http if not host: raise IOError, ('http error', 'no host given') IOError: [Errno http error] no host given --------------------------- For professional reason, I had to change the web site name above. Could in any case urllib() be sensitive to the content of the requested URL (full of "&" chars) ? Thank you for any help. --- Patrick Bussi patrick.bussi at space.alcatel.fr Any opinions expressed are my own and not necessarily those of my Company. From rcalco at cortechs.com Sun Apr 1 01:32:59 2001 From: rcalco at cortechs.com (Bob Calco) Date: Sun, 1 Apr 2001 01:32:59 -0500 Subject: PythonLabs Team Moves to ActiveState In-Reply-To: Message-ID: Guido... admitting that Python will a.) never be popular b.) without curly braces? This HAS to be an April fool's joke. Some things in my mind are far fetched but feasible -- for instance, world peace, intergallactic economic cooperation, free music on the internet, Republicans and Democrats working together, George W. Bush becoming an articulate, charismatic speaker, Al Gore developing a sense of humor about pregnant chads, the Mir crashing without mishap in the South Pacific, the whole 80's thing, the whole 90's thing for that matter, even a Real Middle Class Tax Cut some day -- but Guido changing python to make the indentation scheme obsolete in favor of Perlesque syntax... and Perl's numerical model... The notion that Larry "There's More Than One Thousand Ways To Do It" Wall and Guido "You Only Really Need To Do It One Way" van Rossum can agree on ANYTHING where language design is concerned... Something of the fantastic in the very idea, I tell ya... Not-believing-a-word-of-it-and-doing-a-bad-Tim-Peters-imitation-because-the- day-that-I-can-do-a-worthy-Tim-Peters-imitation-is-the-day-Python-adopts-cur ly-braces-ly yours, Bob Calco CorTechs, Inc. rcalco at cortechs.com # -----Original Message----- # From: python-list-admin at python.org # [mailto:python-list-admin at python.org]On Behalf Of Guido van Rossum # Sent: Saturday, March 31, 2001 7:55 PM # To: python-list at python.org # Subject: PythonLabs Team Moves to ActiveState # # # PythonLabs Team Moves to ActiveState # # To all Python users and developers: # # Less than half a year ago, I moved with my team to Digital # Crations, in the # hope of finding a new permanent home for Python development. At # Digital Creations we've done several good things for Python, # such as forming # the Python Software Foundation and the management of the # Python 2.1 release. # # Unfortunately, Digital Creations's original plans for # PythonLabs didn't # work out as hoped, and we weren't able to reach mutual agreement on # workable alternative plans - despite trying for months. # # I am proud to have found a new home for my entire team: starting # today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself # are working for ActiveState. We will be spending part of our # time on core Python development (including Jython and Mailman) and # part of our time on Python infrastructure improvements that also # benefit ActiveState's efforts such as Komodo and Python.NET. # # Python will remain Open Source; ActiveState has no desire to # monetize or brand the Python language or specific Python # distributions. All future work we do on Python as ActiveState # employees will be owned by the PSF. # # We're excited to be working for ActiveState: they are one of # the companies # most committed to Python, and they have great products! Plus, we know # they have deep financial backing. We trust that ActiveState will # provide a stable home for Python for many years. # # ActiveState has also offered to take over hosting of the # python.org and starship sites. On behalf of the Python community, # we're grateful for this support of the two prime community sites for # Python, and we expect to be implementing the transitions shortly. # # These are exciting times for the PythonLabs team - and also for Python # and its community. Mainstream successes for Python are showing up # everywhere, and we're proud to be a part of such a smart and friendly # community. A great year lies ahead! # # Note, however, that moving to ActiveState will have some minor effects # on the future of Python development. ActiveState is concerned about # the seeming rift between the Perl and Python communities and wants # to do its best to help the Open Source scripting community # work together. # In order to make it easier for Perl programmers to transition # to Python, # we will add optional curly braces for Python. While we are fully aware # of the effect this will have on Python usability, we have # finally decided # to bite the bullet and accept that until this happens, Python # will never # be popular. # # Barry has already approved PEP 357, Adding Block Delimiters to Python. # Since we are heavily commited to backwards compatability, a transition # period of three months has been mandated. For those who want # the changes # to start sooner, we added "from __future__ import block_delimiters" in # Python 2.1, which will be released about two weeks from now. # # Larry Wall and I agreed that now it makes sense for Perl to have # the Perl compiler enforce correct indentation in Perl sources. This # will probably be implemented in Perl 5.7, and will certainly # be in Perl 6. # Also, after some talks with Larry, I've decided to adopt the Perl # numerical model for Python. The Perl model is simple, predictable and # easy to explain. This is a small enough change that it does not need # a PEP, and Moshe will implement it before 2.1rc1 is out. # # Now that the catalog-sig finally has a fully working product, # ActiveState # decided they will base a CPAN competitor on it. This server # will be able # to deal with both Perl and Python modules. While the client will remain # completely Open Source, it was decided that the server will remain # ActiveState proprietary. While it is true that the original server was # written by the Python community, ActiveState has put a lot of effort # into making it general enough, and we need to justify the # costs somehow. # # --Guido van Rossum (home page: http://www.python.org/~guido/) # # # -- # http://mail.python.org/mailman/listinfo/python-list # From christian at rocketnetwork.com Thu Apr 19 22:33:25 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Thu, 19 Apr 2001 19:33:25 -0700 Subject: dynamic casting in python Message-ID: <9bo76f$q82$1@bob.news.rcn.net> How do I do it? Is it possible? From flognat at flognat.myip.org Sun Apr 22 06:14:41 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Sun, 22 Apr 2001 10:14:41 GMT Subject: Python Performance vs. C++ in a Complex System References: Message-ID: Hmm.. A thought... you need to fetch a bunch of URLs in parallell, instead of using one thread per URL, have you considered doing a handler of some kind that sets up and runs select on all sockets fetching pages? /Andy / Gabriel Ambuehl wrote: | Hello Courageous, | | Sunday, April 15, 2001, 10:26:23 PM, you wrote: | > Having completed both cores, and with the C++ core HIGHLY OPTIMIZED, | > I was finally able to perform a performance test of the the C++ | system | > versus the Python system. To my surprise, the C++ core only beat | Python | > by about 30%. Given the obvious inequities in coding time in both | efforts, | > plus whatever future coding time inequities I might project onto | users of | > either core by implication of the programming language, I was quite | > surprised by these results. | | This is very interesting. I've got to implement a server resource | monitoring system and had a shot at it in my beloved Python. While | Python's | threading obviously works (something I can't really say about C++ as | it appears to be not very well thought the whole stuff), | I found it to be very slow. I'm now thinking about | whether I should try to reimplement the whole url stuff in C (being | C/C++ novice) to see whether this would speed up the whole process (or | is there any C implementation of an httplib for Python that works with | it's threading?). The major PITA I continually stumbling across is | the fact that I need to have concurrent service checks, so a single | threaded app with a large queue as scheduling mechanism isn't of much | use. I've been thinking about a fork() based solution (AFAIK this is | what NetSaint is doing) but the reporting of the results isn't doable | in any halfway reliable or elegant way and it obviously requires way | more resources than a threaded app. The original idea was to have a | constantly running thread for every resource to monitor (which can get | kinda | problematical ram usage wise in very big networks but this isn't my | problem | just now as I can throw upto 1GB RAM on this even for a few number of | hosts[2]). which then schedules itself using sleep(). This appears to | be | working perfectly but slow in Python and not at all (due to libcurl[3] | related crashes) in C/C++. | | Ideally, I'd want to implement the whole stuff in C++ (or probably | some wild mix of C and C++, which generally works pretty ok) with | existing | libraries but obviously nobody thought about giving the threading | stuff some flag that would take care of the data (so that pointers | can't get fucked by non thread safe libs while something other is | executed) | and I clearly lack the programming experience to do such a complicated | task myself (I think it would be possible but I've some worries about | the performance penalties this could cause). | | But your report is pretty encouraging to try it again in Python with | an httplib implemented in C (as said, any pointers to such a beast | would be appreciated). | | Given that I might decide to use libcurl (http://curl.haxx.se) as a | starting point | (which doesn't appear to be threadsafe at all to me, even if some | other people | state it is for their apps [1]) what does Python do with non thread | safe | modules in a threaded app? Crash? Do some magic to get the data | consistent | before switching threads? Not defined? Never tested? ANY comment | (preferably from people who know) on this topic as well as on the | stability of the threading stuff (I sometimes had strange crashes | during the loading of the program but once it was running, it kept | running) would be greatly appreciated. | | | | | Best regards, | Gabriel | | [1] Everything is fine as long as I don't try to do concurrent fetches | which I desperately need. | | [2] Python did some two hundred concurrent threads with about 30 MB | RAM usage on FreeBSD which would be very nice if I could only get | CPU utilization way down. | | [3] Pointers to any thread safe HTTP or even better HTTP and HTTPS | libs are very welcome. Preferably code that isn't GPL'd so I can use | it in a closed source project (but I'd be willing to deal with the | author of good lib to get a license for this). From James_Althoff at i2.com Mon Apr 23 19:49:01 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 23 Apr 2001 16:49:01 -0700 Subject: Named code blockes Message-ID: Alex Martelli writes: Sure, naming something and passing the name as a stand-in for the thing itself IS syntax at some level. So what? Do you often use, say, unnamed classes, or modules, or attributes of class instances, or feel that being able to leave them unnamed would be "a very powerful programming device" wrt having to name them?! So what's so different about code blocks...? Alex In Java unnamed (anonymous, inner) classes are used all over the place in Swing-GUI code. Not advocating -- just pointing it out. :-) From bbhaydon at bigpond.com Thu Apr 5 05:50:59 2001 From: bbhaydon at bigpond.com (Brett Haydon) Date: Thu, 5 Apr 2001 19:50:59 +1000 Subject: newbie question: Mod_python or php? References: <986371258.262634@nntp01.uskonet.com> Message-ID: <%%Wy6.9426$45.55375@newsfeeds.bigpond.com> Try getting started with the mod.publisher module within modpython. PHP is probably easier to get started with but I think that overall Python offers greater flexibility in the long run. I started the same way, fumbling around with no idea, but once I'd worked a few things out I managed to build a fairly solid e-commerce site in a week as an exercise. Theres no way I would have completed the same exercise in PHP in that time (unless I'd cheated). However, finding someone to host modpython, thats another story! Brett "Hanna Joo" wrote in message news:986371258.262634 at nntp01.uskonet.com... > Hi. I have been playing around with php and so on, trying to set up simple > sites with database connections. Then I read about mod_python and downloaded > it. However, the manual, to me, was something close to hieroglyphs. Becase I > am quite new to programming and new to python, I would really appreciate > simple tutorials. At this moment I am leaning towards php as there is a lot > more support and documentation on php. Although the fact that I can code in > python is a great attraction, it seems rather complicated. > > I would like to hear from people who have used mod_python whether they find > it better/nicer etc than php. (if they do I will try once again to plough > through the manual...;) If so, I would like to know whether there are more > reasons besides being able to code in python - speed, functions etc. > > Hanna > > From nspurrier at bluelight.com Sun Apr 1 04:27:23 2001 From: nspurrier at bluelight.com (nspurrier at bluelight.com) Date: 1 Apr 2001 08:27:23 GMT Subject: Python SOAP -- any living projects? Message-ID: <9a6opb02hb4@news1.newsguy.com> Has anyone had any success in getting a Python SOAP client to talk to a third-party SOAP server? I had no luck with the Pythonware soaplib 0.8. I tried the included tests and I tried my own requests with many of the servers listed at the soapware validator: http://validator.soapware.org/ Maybe I'm doing something wrong. It looks easy. I have not tried Scarab yet. It looks older. Is it worth a try? ================================== Posted via http://nodevice.com Linux Programmer's Site From dalke at acm.org Tue Apr 3 21:44:27 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 3 Apr 2001 19:44:27 -0600 Subject: Newbie has question that's not exactly Python... References: <9adrp7$4aa$0@216.39.170.247> Message-ID: <9aduf4$p6e$1@nntp9.atl.mindspring.net> Dave LeBlanc wrote: >I don't believe that >"content-type image/gif" is enough! According to the html standard, at >least is needed to start things off. No. Images sent over http are not html, they are images. Or, to look at it another way. If your belief is correct, how do you escape the data in the GIF image (which is binary and could potentially be almost anything) so it doesn't have a "" or other HTML which would be interpreted by the browser. What the person was doing with the sys.stdout.write is the correct approach. Andrew dalke at acm.org From alan.gauld at bt.com Mon Apr 9 12:05:00 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 09 Apr 2001 17:05:00 +0100 Subject: OOT: real-world Smalltalk applications? References: Message-ID: <3AD1DDAC.698AD71@bt.com> Patricia Hawkins wrote: > >>>>> "SH" == Steven Haryanto writes: > SH> AFAIK, Smalltalk is a mature OO language that has inspired > SH> Is Smalltalk never used much anymore these days? > > Millennium Pharmeceuticals uses Smalltalk for their massive, complex > internal applications. Smalltalk tends to be used in-house by large corporations rather than for commerial shrink-wrap type apps. I know of several banks and finance companies who use it and at least one airline used to in the early 90's... Take a look at comp.lang.smalltalk and check out the domain names of the posters asking the hard questions :-) Alan g. From jp at ulgo.koti.com.pl Thu Apr 26 15:20:40 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: Thu, 26 Apr 2001 19:20:40 +0000 (UTC) Subject: mysqldb simple question (find unique number) References: <9c9hc2$5pt$1@laurel.tc.umn.edu> Message-ID: Brian Langenberger wrote: > It might be better to simply use MySQL's "auto_increment" tag for > the key column. That way, one can simply use "0" as the ID number > and MySQL will automatically generate a new, unique ID. thanks to everyone for help, next time I should think more, until I ask (I know SQL, and it was bad thinking "how to do it with mysqldb") -- I hate you and you hate me And everybody smiles So money talks and no-one walks But everybody's crawling "Evilution" - Ronnie James Dio From news at myNOSPAM.org Mon Apr 23 04:39:07 2001 From: news at myNOSPAM.org (Stephen Hansen) Date: Mon, 23 Apr 2001 08:39:07 GMT Subject: Submitting Bugs at Sourceforge References: Message-ID: "Tim Peters" wrote in message news:mailman.988006834.18496.python-list at python.org... > [Stephen] > > Alrighty, I'll get a clean download of the sources and re-put in my > > changes and make some patches. The problem is -- How does one > > make patches in Windows? > > [Neil Schemenauer] > > I would say downloading Cygwin would be your best bet. There are > > other Unix style diff ports as well. > > I expect I've tried every Windows diff and patch port there is by now, and > Cygwin's are the only ones that haven't screwed up (yet ). I guess the > ones buried in Windows CVS work too, but then poor Stephen would have to "cvs > diff -c" against the source tree on Windows. I really don't want his pain to > be infinite! Much to my surprise, I have Cygwin installed, too. I don't exactly remember ever installing it, nor running anything from it. So, problem solved, I found a diff/patch. :) > Provided there aren't many files here, I'm just as happy for Stephen to email > them (or any of the other non-patch alternatives). Whoops. Since I was able to actually make a patch, I submitted it to Sourceforge, 'tis #418147. Granted, I have a feeling that a couple ways I 'fixed' things aren't quite the Python Way, but they are what needs to be done. After they're looked at and I see how they end up really being implemented, I'll submit the patch to fix 'msvcrt', since theoretically I'll then know how the 'right' way to fix its problems are. :) --Stephen (replace 'NOSPAM' with 'seraph' to respond in email) From stefan2k1de at yahoo.de Mon Apr 23 03:25:06 2001 From: stefan2k1de at yahoo.de (stefan kusch) Date: Mon, 23 Apr 2001 07:25:06 GMT Subject: copy construktor problem by extending python with c++ using boost python lib Message-ID: <3ae3d8a9.3655125@news.t-online.de> hello... I want to embed and extend python with a c++ module using the boost python library. I created a simple class with a constructor and a copy constructor. The problem is that the boost library don't accept the copy constructor and the compiler (VC60, SP4) returns the following error: example1.cpp ..\..\..\..\boost/python/detail/extension_class.hpp(178) : error C2664: '__thiscall boost::python::detail::instance_value_holder< class mein::CObRegistry,class boost::python::detail::held_instance< class mein::CObRegistry> >::boost::python::detail::instance_value_holder< class mein::CObRegistry,class boost::python::detail::held_instance< class mein::CObRegistry> >(class boost::python::detail::extension_instance *, class mein::CObRegistry)' : Conversion of parameters 2 from 'const class mein::CObRegistry' in 'class mein::CObRegistry' not possible No copy constructor for class 'mein::CObRegistry' available What is going wrong? my systemconfiguration : win2000, VC60 SP4, python20, boost 1.21.1 . Thanks for all answers. Stefan ------------example code fragments--------------- ... #include namespace python = boost::python; namespace mein{ // Avoid cluttering the global namespace. class A { A(); A(A &a); ... }; A::A() { cout << "A construktor" << endl; } A::A(A &a)//copy constructor { cout << "A copy construktor\n"; ... } } using namespace mein; #include namespace python = boost::python; initgetting_started1() { try { // Create an object representing this extension module. python::module_builder this_module("getting_started1"); // Create the Python type object for our extension class. python::class_builder A_class(this_module, "A"); //Add the __init_-function A_class.def(python::constructor< >()); ... } catch(...) { python::handle_exception(); // Deal with the exception for Python } } From neotaku at free.fr Tue Apr 24 02:44:46 2001 From: neotaku at free.fr (Neotaku) Date: Tue, 24 Apr 2001 06:44:46 GMT Subject: Type Object of wxPython Control References: Message-ID: > Normally you would do object.__class__.__name__ but currently in wxPython > that will give you "wxWindow" because of the way SWIG is wrapping a new > shadow object around the C++ pointer. I expect to have either a workaround > or an actuall fix in place for the first or second 2.3.x release. Thanks i see, so i have to find another way for the moment and wait for your next release See ya ^_^ From chris.gonnerman at usa.net Sun Apr 8 22:27:40 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 8 Apr 2001 21:27:40 -0500 Subject: Newbie python query References: <9ar1fq$1pi3$1@raewyn.paradise.net.nz> Message-ID: <00a901c0c09c$b2b659a0$a100000a@local> ----- Original Message ----- From: "Ben Hawkes" Subject: Newbie python query > Hi, > > I've just started using python on my win95 box, and i'm a bit stuck. I'm > totally unsure on how to load a .py file into the interpreter and execute or > compile it into an executable, HELP! Python files are not normally compiled into executables; the stock install doesn't include that capability (it isn't simple). If you are designing your Python source files (*.py files) in a text editor, then running them from the command line, you would do: python my_program.py Note that python.exe must be in the path for this to work. You may need to amend the path in AUTOEXEC.BAT (and restart the computer) to add the Python directory. If you have a vanilla Windoze box, you would add this to the AUTOEXEC.BAT file: set path=c:\windows;c:\windows\command;c:\python20 Your Mileage May Vary. Alternately, you could use IDLE (check your Start Menu under Programs, Python 2.0) or install the win32all extensions and use PythonWin (which gives you an interactive interpreter and editor windows at the same time). Hope this helps. From tdelaney at avaya.com Wed Apr 25 20:01:53 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 26 Apr 2001 10:01:53 +1000 Subject: win32all on Pythonware Message-ID: Has anyone successfully used win32all with PythonWare Python 2.0? I know it can't be installed over the top, but I've tried copying the things from an ActiveState installation and doing some path trickery. I've got to the point of a traceback when importing win32api ... Can't load DLL/a DLL is missing or something along those lines (it's at home, I'm at work ...). Any assistance would be appreciated, but I'll understand if the answer is "it doesn't work (yet)". That's the indication I've got from web searches, newsgroup searches, etc. Tim Delaney From cory at c-riddell.com Mon Apr 30 09:44:59 2001 From: cory at c-riddell.com (cory at c-riddell.com) Date: Mon, 30 Apr 2001 13:44:59 -0000 Subject: import and the WSH Message-ID: <9cjq8r+tje4@eGroups.com> I have a file called msg.pys that contains one function: def Message(msg): WScript.Echo(msg) I have a second file foo.pys that has two lines: from msg import Message Message("hello") When I run foo.pys (under wscript.exe), it doesn't work. It pops up a box saying "NameError: global name 'WScript' is not defined". If I put the Message() function inside of my test.pys file, everything works fine. Sorry for such a simple question, but this has had me stumped for too long. -cory From aleaxit at yahoo.com Wed Apr 11 05:56:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Apr 2001 11:56:07 +0200 Subject: Class Variable Question References: <9at1ul010vn@news1.newsguy.com> <3ad2a7dd$0$47987$e2e8da3@nntp.cts.com> <9aush501oro@news2.newsguy.com> <3ad411ff$0$47987$e2e8da3@nntp.cts.com> Message-ID: <9b19nh01pud@news2.newsguy.com> "Robert Johnson" wrote in message news:3ad411ff$0$47987$e2e8da3 at nntp.cts.com... > > > Consider an *instance* of a std::map< std::string, std::string >, for > > example. You CAN "just add things on the fly" to it, can't you? Isn't > > it handy, indeed sometimes crucial, to be able to add any foo->bar > > mapping entry to the class on the fly, as and if and when the need > > arises, at runtime, rather than having to pre-declare all the set > > of 'keys' that are going to be allowed and/or mandatory for all > > instances of such a type...? > > I am not sure you understand the point I am trying to make here. Even if I Probably not, since it appears to me that the only difference (type-of-values apart) is in syntax-sugar. > were to make a map with void* where the type of the object being stored > becomes irrelevant, it still would not be what I am talking about. The only > way to add anything to your mapInstance is to add strings like: > > mapInstance["Python"]="Is cool, please don't shoot me." Yep, here you could only add _strings_ (with 'void*' you would gain a bit more flexibility, but not much usefulness) -- other compile-time-typesafe languages such as Java (if it had some way to have constrained generics) would let you use 'Object' as the value-type, so you could in fact add anything. > I can't simply expand the object by adding new variables that have nothing > to do with the laid-out definition of the map. Once I instantiate the map, > I can't simply type "mapInstance.newVariable=5". But that's just a syntax-sugar issue! For most Python objects, mapInstance.newVariable = 5 boils down to nothing more than mapInstance.__dict__['newVariable'] = 5 You "expand the object" by adding new entries to the dictionary it holds -- how is that different from being able to add new entries to any other dictionary/mapping, except syntactically? For object that DO define __setattr__, a closer semantic equivalent is: mapInstance.__setattr__('newVariable', 5) and again you could easily do basically the same thing in C++ by adding a template-method __setattr__ to your class (or in Java by adding a __setattr__ that takes 2 Object's). Whatever the object then does as a result of that method call is obviously up to the object; it's conventionally _expected_ to somehow 'store' the 'value' so it can later be 'retrieved' using the 'name' -- just like, e.g., when writing a C++ template I will _expect_ that calling foo.insert(std::makepair(bar,fum)); on a parameter object foo whose type I, template author, do not know, will have it behave std::map-like, etc. Does it strike you as ABSURD to be able to use foo.bar = fum as a syntactic shorthand for a method-call foo.whatever(bar, fum) ? Yet popular implementations of C++, such as Borland's and Microsoft's, add such syntax-sugary features to the standard C++ language (under name of 'properties'), and assignment-as-shorthand-for-a-method-call is hardly an alien concept to C++ (although it normally chooses to 'hook' it to the fully-solved LHS lvalue, absent extensions such as those mentioned that optionally allow somewhat finer granularity in such hooking). In Python, you get somewhat finer-grained 'hooking' of assign-to-attribute syntax, and a runtime equivalent of C++'s template (generic programming, in more general terms) philosophy of 'polymorphism by signature matching'. Why does such modest generalization look or feel so alien to you? To me, it looks like a typical case of "much ado about nothing", also known as building mountains out of mole- hills, I believe... Alex From pawelstol at poczta.onet.pl Mon Apr 9 13:58:34 2001 From: pawelstol at poczta.onet.pl (=?iso-8859-2?Q?Pawe=B3_Sto=B3owski?=) Date: 9 Apr 2001 17:58:34 GMT Subject: linux & users' python-extensions Message-ID: I've installed Python into /usr/local/bin and /usr/local/lib/Python2.0. Now I'd like to allow an ordinary user to maintain his own python-extensions modules (written in C/C++). So, each user's python programs should see the global modules hierarchy, but also allow the user to import his own modules and link coresponding C/C++ modules, when needed. Is it possible without cluttering global Python-configuration each time an user needs to play with his new extension-module? I'm new to Python, so any help will be appreciated; I found lots of docs on the web, but I can't find the exact answer to the above question (if it exists at all). TIA, yogin -- ___________________________________________ Linux User #165389 ICQ #47602612 .Bydgoszcz -[http://www.komputery.bydgoszcz.pl/linux]- From fredrik at pythonware.com Fri Apr 6 03:28:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Apr 2001 07:28:45 GMT Subject: Changing global variables in tkinter/pmw callback References: <3ACC21BF.14E708B7@mek.dtu.dk> <3ACC4EB1.376225AF@mek.dtu.dk> <3s0z6.5511$4N4.1170119@newsc.telia.net> <3ACD5D99.47AED2BE@mek.dtu.dk> Message-ID: Brian Elmegaard wrote: > > (when you type "s[0] = 10", you ask whatever "s" points to > > to replace item zero with a new value. in your case, you ask > > the list "s" to modify it's first item. anyone else referring to > > the same list object will see this change) > > And someone are. Could the same be done with the 10 in s=10? hint: do integer objects have any methods that you can use to modify their content? >>> s = 10 >>> dir(s) [] >>> a[0] = 1 Traceback (most recent call last): File "", line 1, in ? TypeError: object does not support item assignment >>> s.a = 1 Traceback (most recent call last): File "", line 1, in ? TypeError: attribute-less object >>> s() Traceback (most recent call last): File "", line 1, in ? TypeError: call of non-function Cheers /F From whisper at oz.net Tue Apr 17 12:00:10 2001 From: whisper at oz.net (Dave LeBlanc) Date: 17 Apr 2001 16:00:10 GMT Subject: do...until wisdom found... References: Message-ID: <9bhpaa$v0n$0@216.39.170.247> Asp of course :-) A little snake with a big bite. Dave LeBlanc On Mon, 16 Apr 2001 23:02:21 -0700, "Ken Peek" wrote: >Can anybody think of a good name for a "Python-like" new language for small >embedded processors? >Let's see-- "tinyPython"? nope-- has "Python" in it-- might make Guido mad. >Hmmm, maybe "Dragon"? Probably used by someone else? Hmmm... maybe ??? > >Any ideas? From paulp at ActiveState.com Tue Apr 17 00:42:02 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 16 Apr 2001 21:42:02 -0700 Subject: Perl & Python: Parrot References: <3adbc4e7$1_2@excalibur.gbmtech.net> Message-ID: <3ADBC99A.8C01F118@ActiveState.com> Eschathon wrote: > > That was quite an interesting joke. However, after a lot of deliberation I > decided that it would be an excellent idea to unite Perl and Python. When I > am doing CGI or bash scripting I always use the languages in conjunction. > Let me know what you guys think! Unfortunately Perl and Python have a very different design aesthetic. I don't see how the designs could be meaningfully merged. Nevertheless it is easy to make the two work together: http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52197 http://www.xmlrpc.com/ -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From vanevery at 3DProgrammer.com Wed Apr 25 16:37:41 2001 From: vanevery at 3DProgrammer.com (Brandon J. Van Every) Date: Wed, 25 Apr 2001 20:37:41 GMT Subject: big text strings References: <3AE70316.DF945F1A@san.rr.com> Message-ID: "Darren New" wrote in message news:3AE70316.DF945F1A at san.rr.com... > Well, if you're more interested in the text game itself than you are in > writing the text game interpreter, check out > http://www.tela.bc.ca/tela/tads/ the text adventure system. Very nice. We decided that we're not using a parser, so TADS offers no compelling value, being built pretty much to handle parser-based text adventures. Our model is much closer to Choose Your Own Adventure, with some NPCs and state tweaks. -- Cheers, www.3DProgrammer.com Brandon Van Every Seattle, WA For plot and pace, writers use words; game designers use numbers. Anything understood over time has plot and pace. From graham_guttocks at yahoo.co.nz Sun Apr 29 15:27:30 2001 From: graham_guttocks at yahoo.co.nz (Graham Guttocks) Date: Sun, 29 Apr 2001 12:27:30 -0700 (PDT) Subject: "chicken and egg" problem with modules and global vars Message-ID: <20010429192730.84049.qmail@web10301.mail.yahoo.com> Greetings, I'm running into a sort of "chicken and egg" problem involving modules, global variables and getopt command-line arguments and would appreciate some direction. I'm importing a module named "Defaults" at the top of my program which defines a number of default values as well as parses a user configuration file for more default values. These values are used in the program's function definitions including main(). I need the ability for the user to override the default location of his custom config-file which is defined in "Defaults". I'm doing this with getopt in main() by appending to __builtin__ so that "Defaults" can access it. The problem is that since "Defaults" is imported at the top of the program, the default config-file location is set as soon as this module is imported. I need getopt to be read first, but I can't just move "import Defaults" down into the body of main() because the function definitions above main() rely on it. Any ideas? Regards, Graham __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From aleaxit at yahoo.com Fri Apr 13 18:12:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Apr 2001 00:12:30 +0200 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> <3AD5C5B1.98ACEFB3@metaslash.com> <9otuNLAXvs16EwcK@jessikat.fsnet.co.uk> <3AD752A0.ECF538A4@metaslash.com> Message-ID: <9b7tnl0v7c@news2.newsguy.com> "Neal Norwitz" wrote in message news:3AD752A0.ECF538A4 at metaslash.com... [snip] > There are many cases where you want to write completely legal code, > but checker can't tell if it is a bug (thinko mistake) or what was intended. > Ideally, there would be finer grain control on the options. [snip] > One option would be to review the actual doc strings and look for hints > (similar to lint /*ARGSUSED*/). Perhaps "CHECKER.initsubclass = 1" ? > > Any ideas or comments? Exactly: I'd put the hints in comments (rather than in docstrings)...:-). Alex From tuttledon at hotmail.com Mon Apr 2 17:36:08 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Mon, 02 Apr 2001 21:36:08 GMT Subject: T-Shirts References: Message-ID: "Marc Poinot" > Where can I have Parrot T-shirts ? I believe O'reilly's got that concession. Contact LLewin at oreilly.com for price and availability. Don From news at myNOSPAM.org Mon Apr 23 13:56:11 2001 From: news at myNOSPAM.org (Stephen Hansen) Date: Mon, 23 Apr 2001 17:56:11 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: <%0_E6.185253$Ch.29734545@typhoon.we.rr.com> Except the module is not dependant on Visual C++. --S "bowman" wrote in message news:LnWE6.42$kz2.1197 at newsfeed.slurp.net... > > "Stephen" wrote in message > news:kLQE6.193167$LO3.30831301 at typhoon.we.rr.com... > > > > I still think 'msvcrt' needs to be renamed. :) > > How much more explicit can you get? It's 'MicroSoft Visual C++ RunTime', not > 'Borland C++ RunTime.' > > From JamesL at Lugoj.Com Sun Apr 29 01:10:36 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sat, 28 Apr 2001 22:10:36 -0700 Subject: Python job survey References: Message-ID: <3AEBA24C.471984@Lugoj.Com> Joseph Santaniello wrote: > How old are you: Okay, I'll humor you: born in 1956. > How many years have you been programming: Started '73 or '74. Been so long I don't remember. > How long have you been using Python: Since 1997. > Where do you live: Northern coast of California. Sunny Aptos. > Would you consider relocating to Los Angeles: Hell no. > Would you require visa sponsorship: To LA? I'd need a sanity check first. > What is your current salary: If you have to ask you can't afford it. > What field do you work in: (finance, internet, movies, etc) Work? Wait a minute, who said anything about work!? > Your responses are greatly appreciated! You're welcome. Did I get all the answers right? So what do I win? From pod at internode.on.net Tue Apr 17 12:13:54 2001 From: pod at internode.on.net (PoD) Date: Wed, 18 Apr 2001 01:43:54 +0930 Subject: canvas drawing on button References: <3ADC32F7.95AD63C9@mek.dtu.dk> Message-ID: <3ADC6BC2.448BFB2C@internode.on.net> Brian Elmegaard wrote: > > Hi, > > Is it possible in any way to make python generate a bitmap/image of a > tkinter canvas item and use that for a button bitmap/image? > > or, > > can I make a canvas on a button? > > or, > > do I really have to make the drawing outside of python? You could use the Python Imaging Library to draw your images. PoD. From root at [127.0.0.1] Mon Apr 2 05:20:14 2001 From: root at [127.0.0.1] (deadmeat) Date: Mon, 02 Apr 2001 09:20:14 GMT Subject: list vs tuple References: +ADw-mailman.986154903.21843.python-list+AEA-python.org+AD4- +ADw-62Mx6.1152+ACQ-p5.4531+AEA-news1.rivrw1.nsw.optushome.com.au+AD4- +ADw-slrn9cg648.7dt.wtanksle+AEA-dolphin.openprojects.net+AD4- Message-ID: > They're called lists, not arrays. So what other term applies to tuples and lists? They're both arrays, given a Pythonic twist. ar?ray (-r) v. tr. ar?rayed, ar?ray?ing, ar?rays. 1.. To set out for display or use; place in an orderly arrangement: arrayed the whole regiment on the parade ground. 2.. To dress in finery; adorn. n. 1.. An orderly, often imposing arrangement: an array of royal jewels. 2.. An impressively large number, as of persons or objects: an array of heavily armed troops; an array of spare parts. See Synonyms at display. 3.. Splendid attire; finery. 4.. Mathematics. 1.. A rectangular arrangement of quantities in rows and columns, as in a matrix. 2.. Numerical data linearly ordered by magnitude. 5.. Computer Science. An arrangement of memory elements in one or several planes. begin 666 schwa.gif M1TE&.#EA!@`/`/ ``/___P```"'Y! $`````+ `````&``\```(0A(^I>^$6 ,&H at 2N7MK9AP0% `[ ` end begin 666 amacr.gif M1TE&.#EA!P`/`/ ``/___P```"'Y! $`````+ `````'``\```(5A(\8RY'' 1H 3.5'@7M;-JZWS/^! H`#L` ` end begin 666 prime.gif M1TE&.#EA! `6`/ ``/___P```"'Y! $`````+ `````$`!8```(.A(^I$<;> *0)2JVHLO00$`.P`` ` end From dmaas at nospam.dcine.com Sun Apr 8 21:37:16 2001 From: dmaas at nospam.dcine.com (Dan Maas) Date: Mon, 09 Apr 2001 01:37:16 GMT Subject: UNIX domain sockets problem References: Message-ID: >> SERVER = socket(AF_UNIX, SOCK_DGRAM, 0) Change SOCK_DGRAM to SOCK_STREAM Dan From jkraska1 at san.rr.com Sun Apr 1 01:26:27 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 01 Apr 2001 06:26:27 GMT Subject: PythonLabs Team Moves to ActiveState References: <9a626p$3qrct$1@ID-11957.news.dfncis.de> Message-ID: >> and as you say, should provide a stable home for python development. >> You join a team of highly respected python people in this move, and the >> resulting products will be far from common, and that is exciting. > >Emile! I hadn't pegged you for such a shameless suck-up. Good show. *spank* "ouch!" *spank* "ouch!" :) C// From lloeffler at home.com Fri Apr 20 23:02:07 2001 From: lloeffler at home.com (ll) Date: Fri, 20 Apr 2001 22:02:07 -0500 Subject: Python vs. PHP References: <3AE0D4E7.FA51F14D@home.com> Message-ID: <3AE0F82F.AC66E5E5@home.com> Right, but what is the standalone performance like when using Python thru CGI? From stepheb at comm.mot.com Fri Apr 20 12:09:52 2001 From: stepheb at comm.mot.com (Stephen Boulet) Date: Fri, 20 Apr 2001 11:09:52 -0500 Subject: Error with string.strip References: <3AE05834.93331DA5@comm.mot.com> Message-ID: <3AE05F50.4D6B517F@comm.mot.com> Paolo Invernizzi wrote: > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > >>> import string > >>> string.strip(" 15157 ? 0:01 ttsession\012") > '15157 ? 0:01 ttsession' > > "Stephen Boulet" wrote in message > news:3AE05834.93331DA5 at comm.mot.com... > > Can someone tell me why this doesn't work? Thanks. > > > > >>> import string > > >>> string.strip("all's well as ends well ") > > "all's well as ends well" > > >>> string.strip(" 15157 ? 0:01 ttsession\012") > > File "", line 1 > > string.strip(' 15157 ? 0:01 ttsession\012') > > ^ > > SyntaxError: invalid syntax > > Hmm. I'm using 1.5.1 for HPUX 10.x. Maybe I need to upgrade... -- Stephen From jmarshal at mathworks.com Sun Apr 1 17:55:06 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 1 Apr 2001 21:55:06 GMT Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> Message-ID: <9a883q$k97$1@news.mathworks.com> Marcin 'Qrczak' Kowalczyk wrote: > Fri, 30 Mar 2001 15:25:14 -0500, Michael Prager pisze: >> To the naive user, the EFFECT is different. If the object is >> immutable, the statement appears to act just like it does in >> many other languages. (It may not really act that way, but the >> difference is hidden.) > Indeed. Python's behavior is perfectly consistent. The problem is that > for immutable types there is no difference between passing by value > and passing by reference, so a naive user might think that Python > passes by value. They don't realize that in this case there would > be no difference and that the same behavior could be also explained > differently. Python does pass by value. It's just that the "values" are references to begin with. In languages which pass by reference, assigning to the formal parameter changes the caller's state. From Randy.L.Kemp at motorola.com Tue Apr 3 08:57:41 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 3 Apr 2001 07:57:41 -0500 Subject: stupid questions ... Message-ID: Is this the same Microsoft that complained to the government about the decision to allow government firms to bid on open source software, in place of commercial software (published somewhere in www.mysql.com website a while back). Does Microsoft hold two sets of standards when it comes to open source? If it benefits them, it is OK, but if it affects their bottom line, then it is a bad thing? -----Original Message----- From: Armin Steinhoff [mailto:a-steinhoff at web.de] Sent: Tuesday, April 03, 2001 3:14 AM To: python-list at python.org Subject: stupid questions ... After reading that ... I have some questions about ActiveState. >From the ActiveState home page: ------------------------------------------------------------------------------- ActiveState and Microsoft Form a Perl of Relationship, William Peterson, IDC Flash, June 1999 Summary: What effect will Microsoft and ActiveState's ActivePerl agreement have on the Open Source community? ActiveState Corp. and Microsoft have signed an agreement to further integrate Perl (practical extraction and report language) with the Windows operating system. IDC wonders what effect this agreement will have on Open Source developers working on Perl. Additionally, IDC wonders if this type of agreement between an Open Source development company and Microsoft is the beginning of a larger Open Source strategy by Microsoft. ------------------------------------------------------------------------------- [Q]: - Is ActiveState (still?) financially independent from MS ?? - what is the real 'open source' strategy of MS regarding Perl + Python ? - after reading ActiveState statements like "blowing the others (OS) away" .. what is the strategy of ActiveState against(?) non MS operating systems ?? Armin From ed_tsang at yahoo.com Mon Apr 30 12:47:23 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Mon, 30 Apr 2001 16:47:23 -0000 Subject: (no subject) Message-ID: <9ck4ur+n5sc@eGroups.com> I am trying to print the traceback infor using the floowing code. I get the traceback info form call traceback.print_exception. the file that I want o print to is trcfile whihc has value of error.txt. How can I do that?? thanks trcfile = "error.txt" try: execCmd = "guiCb.pixitObj.%s"%eventHandler[0] exec(execCmd) except: printwrite(trcfile, "Ctf Error : Error executing eventhandler % s \nTraceback detail follows:\n"%eventHandler[0], "FAIL") exc = sys.exc_info() try: traceback.print_exception(exc[0],exc[1],exc[2],file = trcfile) finally: pass print "Test case fail exception raised\n" raise TestCaseFail From sebrosa at artenumerica.com Wed Apr 18 21:08:20 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Thu, 19 Apr 2001 02:08:20 +0100 Subject: How to Write words Vertically? References: <3ADC270D.3291CC63@ccsr.cam.ac.uk> Message-ID: <3ADE3A84.ED737ED8@artenumerica.com> XiaoQin Xia wrote: > > I am using Tk to draw 2-D charts. But I do not know how to write text > vertically on canvas. Would you please show me how to do it? > > Many Thanks from > XiaoQin (xq.xia at ccsr.cam.ac.uk) I think you can have multiline text in Label when you insert the charater '\n'. Try Label(text = 'something') for horizontal labels and Label(text = string.join('something', '\n')) for vertical labels. You can also play with "justify" to have the letters properly placed, like in Label(text = string.join('something', '\n'), justify = CENTER) Sebrosa From pulsar at qks.com Fri Apr 27 02:48:35 2001 From: pulsar at qks.com (David Simmons) Date: Fri, 27 Apr 2001 06:48:35 GMT Subject: Integer micro-benchmarks [Smalltalk Multi-Precision Numerics vis-a-vis Highly Optimized Fixed Size Integer C++ Numerics] References: <9c4sjf$qo$1@serv1.iunet.it> <9caaru$75k$1@serv1.iunet.it> Message-ID: <7D8G6.24022$Jh5.23280761@news1.rdc1.sfba.home.com> "Andrea Ferro" wrote in message news:9caaru$75k$1 at serv1.iunet.it... > "David Simmons" wrote in message > news:unqF6.19479$Jh5.19552912 at news1.rdc1.sfba.home.com... > > > ... > > Better still for our true testing purposes of raw numerics performance, what > > a hand coded assembly routine would do. I probably should hand code an > > assembly version since I'm really expert in that area and issues of > > pipelining -- I have often had to do this for small hot-spot areas where a > > C++ (or other static language) compiler just wasn't satisfactory. > > There's not much data cache work involved here. It's most register stuff. And > code is so tiny that should go to cache at first pass. My comment here had more to do with looking at pipelining (instruction scheduling) issues and ensuring that we really tested similar numerics rather than invariant optimizations. As you say, the instruction and data caches are basically irrelevant to the c++/assy code. The comments regarding the instruction and data caches were for the 10,000,000 case which generated LargeInteger values in Smalltalk and therefore invoked many other parts of the execution engine (possibly including one or more aspects of the automatic garbage collector facilities). ...snip interesting stuff... > Fiew years ago I heard rumours of experiments to add some sort of type awareness > to Smalltalk. Now, making smalltalk statically typed is a nonsense. But > *allowing* type specification of parameters, return types and some other > semantic aids (like the concept of constness to indicate a method is not > supposed to modify the object) could maybe enable very optimized execution. What > is the *current* smalltalk community position on this sort of reasoning. You're probably referring to StrongTalk? Or you may be referring to early information regarding my work on SmallScript? In any case, as I understand it, StrongTalk was not designed with the goals you're describing. SmallScript's intrinsic type system does enable those goals and can make extensive use of optional type information. The type system is formalized and integrated in with the language (including the mixin/MI interface system). As a result the type system enables transparent FFI marshalling, overloaded methods (multi-methods), etc. > /DisclaimerOn > I do not want to start a flame on this. I'm not suggesting in any way that > Smalltalk should be typed. I'm just asking what reasoning is behind NOT even > allowing that sort of meta information. Smalltalk now has namespaces and parcels > and protocols and other usefull stuff that was no-no for Smaltalkers in the > past. An *optional* meta info that tells to the JIT and to the compiler that a > method has no side effects or that it returns an object guaranteed to be of a > given class should not actually change the language. Or does it? > /DisclaimerOff ...snip more interesting comments... > hmmmm I'm still to keep up with Smalltalk "news". I'll take self some time in > the future. I told you, no matter how much I like this sort of languages I > couldn't yet "sell" their use here in Italy. But maybe that's because I'm doing > too much embedded stuff! Actually, its interesting you should say that. A 4:1 performance ratio for a worst case numerics scenario is not indicative of general performance. I would suggest that general purpose code on that same architecture would perform roughly equal to C++. Certainly the object allocation and GC would exceed performance of non-auto-(stack)-objects. The adaptive nature of the JIT enables optimizing various constructs that a static compiler could not. But most important of all is that an virtual machine opcode instruction set is *much* more compact in memory than statically compiled code and therefore it should be possible to support significantly more (easily upgradable) functionality in the same memory footprint. A dynamic language architecture allows restructuring of classes (objects) and their behavior on the fly without ever quitting an application -- that and many other dynamic language features are quite attractive for mobile computing, agent technology, factory automation systems, and data collection and processing facilities. ...snip more interesting stuff... Cheers, -- Dave S. > > Andrea Ferro > > --------- > Brainbench C++ Master. Scored higher than 97% of previous takers > Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0 > More info http://www.brainbench.com/transcript.jsp?pid=2522556 From donn at oz.net Fri Apr 20 00:37:22 2001 From: donn at oz.net (Donn Cave) Date: 20 Apr 2001 04:37:22 GMT Subject: Can only import select as root? References: <3ADF75FF.C005932C@acm.org> <3ADFA275.CE889E07@acm.org> Message-ID: <9boee2$lvk$0@216.39.151.169> Quoth Lester McCann : | (Quoting someone else) |>| >>> import select |>| Traceback (most recent call last): |>| File "", line 1, in ? |>| ImportError: No module named select |>| >>> |> |> What are the permissions on that module? Try |> |> $ ls -l /usr/lib/python-2.1/Lib/select.py* | | There is no such file in the Python lib directory on my system. (I ran | 'find' from the root of the directory tree to verify that it doesn't | exist anywhere.) As I can access it when running as root, I'm assuming | that it's built-in somehow. I agree that it seems like a permission | problem, but... ... but that isn't the name of the file. It used to be a built-in, and could theoretically still be built in, but normally in 2.1 it would be more like $prefix/lib/python2.1/lib-dynload/select.so (along with a whole bunch of other modules.) Donn Cave, donn at oz.net From akuchlin at mems-exchange.org Thu Apr 12 17:57:23 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 12 Apr 2001 17:57:23 -0400 Subject: Python & TKInter applets References: <3ad467f2$0$47994$e2e8da3@nntp.cts.com> Message-ID: <3d8zl5g4sc.fsf@ute.cnri.reston.va.us> philh at comuno.freeserve.co.uk (phil hunt) writes: > I personally find web-based applications easier to write and > deploy if the code is all on the server side. Then your users can > use any web browser. Agreed. About a year and a half ago, we wanted to build a fairly complicated GUI application, and began writing it using JPython and Swing. It was even packaged using some Java installer product (InstallShield?). However, practically no users ever bothered to download it because it was too much trouble, so we discarded it and simply did everything as a Web-based application. The interface provided by HTML forms is maddeningly restrictive at times -- no sliders, no type-in multiple choice boxes -- but in ubiquity it has everything else beat. --amk From dalke at acm.org Fri Apr 13 06:18:09 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 13 Apr 2001 04:18:09 -0600 Subject: calling superclass' method with list positional arg References: Message-ID: <9b6k2f$oe0$1@slb3.atl.mindspring.net> Steven Haryanto: >class BagOTricks(Bag): > > def __init__(*args): > self = args_[0] > # do something else first... > > # then pass the items to superclass' constructor > apply(Bag.__init__, args_) I've never seen it written that way. I've always used def __init__(self, *args): # do something else first ... # this pss the items to superclass' constructor apply(Bag.__init__, (self,) + args) In Python 2.0 you can also do Bag.__init__(self, *args) Andrew dalke at acm.org From sholden at holdenweb.com Thu Apr 26 13:21:34 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Apr 2001 17:21:34 GMT Subject: Python IMAP Server Code? References: Message-ID: Ha! So, you wait until I decide my current approach isn't possible and ask for help with a new one, then rather than giving me the asked-for help you tell me I'm WRONG, and my previous approach is in fact possible. What else can I say but ... thank you, your code looks interesting and I'll take a look at it :-) regards Steve "Mark Watts" wrote in message news:mailman.988301262.17724.python-list at python.org... > From: "Steve Holden" > > Does anybody have any IMAP server code I could lift? > > > > This is because I have finally given up on reverse-engineering Outlook > > Express' bizarre mail folder format, and am now taking an alternative > > approach. This will use a localhost-only IMAP server on the same host as > the > > mail client to allow transfer of mail messages into a more sensible > > repository. > > This code is in Delphi but it does a fair job of pulling data out of OE > mail > files. > > http://www.djpate.freeserve.co.uk/oexpress2.zip > > Hope this helps. > > -Mark Watts > > From jgraves3 at austin.rr.com Mon Apr 2 23:08:18 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Tue, 03 Apr 2001 03:08:18 GMT Subject: Python on the AS/400? References: Message-ID: <3ac93a8f.4016386@news-server.austin.rr.com> On Tue, 03 Apr 2001 02:12:25 GMT, kragen at dnaco.net (Kragen Sitaker) wrote: I wish I had answers for these questions. I make my living on the AS/400 but I love using Python for my own projects. (Quite often using data downloaded from the AS/400). Unfortunately, most of the programs written for the AS/400 are written in RPG so there are relatively few people who know 'C' and the AS/400. If you don't get an answer here, you might want to pose your question to comp.sys.ibm.as400.misc >- is there an AS/400 on which I could get an account (for under $1000, > say) so I could run some tests? Or do I have to buy my own? It > looks like they cost several thousand dollars on eBay. try http://www.netshare400.com/ for AS/400 access. As far as Ebay is concerned, I would be wary unless you are familiar with what you are getting. Many of the AS/400's on Ebay use the old CISC processors and in general are too old and slow for real work. In addition, the operating system license does not follow the machine and it would cost several thousand dollars to get a license. I hope this helps a little bit. ... jay From bedge at troikanetworks.com Tue Apr 24 10:55:36 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 24 Apr 2001 07:55:36 -0700 Subject: class based exceptions Message-ID: <20010424.075536.1065103348.683@mead.troikanetworks.com> Can one associate an exception handler with all member functions of a class without explicitly coding it in every member? My reasoning for this is that I have some CORBA wrapper classes. If any member fails with a omniORB.CORBA.COMM_FAILURE exception, I need to re-resolve the reference. Currently, I have to put an except statement in every method, and the code to execute is the same in all cases. eg: class wrap: def __init__(self): self.resolve() def resolve(self) #resolve corba reference def read(self) try: corba.read... except omniORB.CORBA.COMM_FAILURE self.resolve() # retry def write(self) try: corba.write... except omniORB.CORBA.COMM_FAILURE self.resolve() # retry From akuchlin at mems-exchange.org Wed Apr 11 12:37:02 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Apr 2001 12:37:02 -0400 Subject: call of non-function (type string) error References: Message-ID: <3dhezvfl5d.fsf@ute.cnri.reston.va.us> Graham Guttocks writes: > >>> CIPHER = "DES3" > >>> import Crypto.Cipher > >>> cipher = getattr(Crypto.Cipher, CIPHER) > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: DES3 I don't think the Cipher package automatically imports all subpackages, and this is a case where you really do need to use exec. Obviously the Cipher package should provide a function to retrieve the module for a given name... --amk From neal at metaslash.com Sun Apr 8 21:44:10 2001 From: neal at metaslash.com (Neal Norwitz) Date: Sun, 08 Apr 2001 21:44:10 -0400 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> Message-ID: <3AD113EA.AB961AEE@metaslash.com> David Lees wrote: > Looks useful, but the first thing I tried running it on is some threaded > socket code and checker.py seems to hang. I think it is trying to run > the code, which is a problem, because it is not located on the right > machine for running. I tried both from a DOS window in Win98SE using > Python 2.0 and also with PythonWin. Hmmm. From in the interpretter, can you do import: import your_module Does that work? If you send me your code or a small subset that you are having the problem with, I can take a look. Neal From aleaxit at yahoo.com Sun Apr 15 03:07:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Apr 2001 09:07:15 +0200 Subject: Named code blockes References: Message-ID: <005f01c0c57a$c63025a0$0300a8c0@arthur> "Steven D. Majewski" writes: > Typically, a named block has the name label at the top -- which is > not usually where the control is flowing to, and you have to hunt Right: it's where the control is _breaking away from_ (for a break; it IS, in fact, "where it's flowing to" for a continue). Note that this is even more obvious for the make-it-a-function alternative: return clearly shows what (function) you are EXITING from, but NEVER 'where the control is flowing to' -- it flows to wherever it needs to, that's not the point -- the point is terminating a conceptual unit (and a named loop is as much as a conceptual unit as a function: if it's code needs to occur exactly once, having it lexically inline at the single point of occurrence is a plus!). > and peek around to find the next executable statement. What's clear > and explicit about that ? A good part is in the name. break eggs_search You don't need context to see that this is terminating the 'search for eggs' named conceptual unit. "what happens next" ("where the control is flowing to") is obviously "whatever's next after searching for eggs", just as if this was a function named that way with a return statement here == indeed, the lexical situation in terms of "let me look for where this goes now" is easier than for function calls, where it's generally anything but clear at a first glance that a certain function is called from just one place, and where that place is. > A restricted use of GOTO is more (IMHO) clear. MHO differs. I don't want to think of this-then-that-then-the- other control flow in a VHLL, I want to think of named building blocks and their nesting and entering and exiting. > try/except blocks come in somewhere in between Goto and named > blocks for readability. Not a bad compromise if you don't want > to rely on disciplined use of goto. The target is pretty clear. It's lexically constrained, but lacks a name, which is a strong conceptual help (the name of the exception you raise can help, but that should be the reason for exiting, not WHAT you are exiting). > ( But maybe you're thinking of a different syntax for Python > than I can imagine from other lang. I've seen. If you show > me a clear example, I'll reconsider. ) Nope, I had in mind the same kind of syntax seen in other languages, sugary issues apart (it's minor from my POV whether naming a loop involves using 'as', a colon, or whatever) -- being able to name a block and to mention that name in a break. Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From jon at csh.rit.edu Tue Apr 3 11:12:09 2001 From: jon at csh.rit.edu (Jon Parise) Date: Tue, 3 Apr 2001 11:12:09 -0400 Subject: Thoughts about ActiveState ActivePython 2.0 203? In-Reply-To: <3sky6.83$Mt5.1655@newsfeed.slurp.net>; from bowman@montana.com on Tue, Apr 03, 2001 at 07:48:16AM -0600 References: <3ac968c3$1_3@news4.newsfeeds.com> <3sky6.83$Mt5.1655@newsfeed.slurp.net> Message-ID: <20010403111209.B28951@csh.rit.edu> On Tue, Apr 03, 2001 at 07:48:16AM -0600, bowman wrote: > > Thoughts about ActiveState ActivePython 2.0 203? > > Compared to what? Anything. > > The documentation is a poor relative compared to AS Perl. On my machine, at > least, nothing was installed in the Start menu, and the docs were separate > help files in the various directories. iirc, previous builds did a much > better install. My installation of ActivePython 2.0 build 203 happily installed the document as part of the "ActiveState ActivePython" program group. I've found the Windows Help-style documentation quite good (easy to search, anyway). I haven't spent much time in the Win32-specific documentation, however, not yet having a need for it. -- Jon Parise (jon at csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member From PCXsoft at intag.de Sat Apr 14 12:53:36 2001 From: PCXsoft at intag.de (Alexander Adam) Date: Sat, 14 Apr 2001 18:53:36 +0200 Subject: Need people Message-ID: <9b9v4p$jal$04$1@news.t-online.com> Hello there, I've created an new platform for all Tk-things (python,perl,tcl), and I need people to write some articles about it, here about tkinter and other python-guis ! Please send them to me (in html-format, pictures allowed, _no_ format!), so that i can add them and make the site online ! Thank you, =Alex= From dalke at acm.org Mon Apr 16 03:41:26 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 16 Apr 2001 01:41:26 -0600 Subject: do...until wisdom needed... References: <9bdv6f$quq$1@news.udel.edu> Message-ID: <9be82a$eq7$1@slb6.atl.mindspring.net> Ken Peek wrote: >Thank you for the history lesson. My question still stands-- I >don't care if it will be implemented or not. I am looking for >what would be the correct "Pythonic" construct if it WERE implemented... >"Terry Reedy" wrote: >> This has been discussed ad nauseum for years with no agreement. If and >> when maillist or newsgroup archives are available, you can review at your >> leisure. But that's Terry's point. No one has decided on a "Pythonic" construct, and there have been arguments on that topic. Nor did he mention anything about implementation. I just did a www.python.org/search for "do while until". The first hit was to: http://groups.google.com/groups?q=do+while+until&hl=en&lr=&group=comp.lang.p ython.*&safe=off&rnum=1&seld=943960637&ic=1 and since I don't know if that link will really work, the thread is named "why no "do : until"? and took place last December. (There are older threads, but not indexed by Google.) The consensus seems to be that there is no Pythonic syntax for a do/until construct. It boils down to indentation. Both your suggestions were proposed and it was decided that they didn't make sufficient sense: do: spam until cond was found to be nothing more than an alias for while 1: spam if not cond: break and not worth introducing new syntax. The other proposal is: do: spam until cond but this "does not fit a pythonic pattern for statements" (Martijn Faassen). Reread the full thread for details. So why didn't you believe that this exact history you were looking for already existed in the easily searchable archives, even after Terry pointed it out? Andrew dalke at acm.org From graham_guttocks at yahoo.co.nz Sun Apr 15 18:44:59 2001 From: graham_guttocks at yahoo.co.nz (=?iso-8859-1?q?Graham=20Guttocks?=) Date: Mon, 16 Apr 2001 10:44:59 +1200 (NZST) Subject: reusing sys.stdin? In-Reply-To: <00c501c0c3c5$1f9e1000$a100000a@local> Message-ID: <20010415224459.77982.qmail@web10305.mail.yahoo.com> "Ixokai" wrote: > You can save what is in them at any one point in time by just reading it > into a temporary variable for accessing later; the below will likely work > fine for you: > > import rfc822, sys, cStringIO > > stdin = cStringIO.StringIO(sys.stdin.read()) > > message_headers = rfc822.Message(stdin) Yes, it does. Thanks so much! Cheers, Graham _____________________________________________________________________________ http://movies.yahoo.com.au - Yahoo! Movies - Now showing: Dude Where's My Car, The Wedding Planner, Traffic.. From dhumphrey at pdqdot.net Fri Apr 6 19:06:52 2001 From: dhumphrey at pdqdot.net (David Humphrey) Date: Fri, 6 Apr 2001 18:06:52 -0500 Subject: problem executing python scripts in cygwin bash shell References: <69AD80E50414598C.875157435733CF34.B50964BA627F4825@lp.airnews.net> Message-ID: <697F935A043CAEB5.770CC0A776F0EEB7.BB64BD763D05E44E@lp.airnews.net> Thanks to all who responded. There are some good ideas here that jarred me back into the UNIX world where nearly anything is possible if you just think about it a bit. Regards, DLH "David Humphrey" wrote in message news:69AD80E50414598C.875157435733CF34.B50964BA627F4825 at lp.airnews.net... > I'm sure this one has been answered before, but I couldn't find the solution > in any of the newgroups, so here goes again. > > I can run bash scripts that are in the path but not python scripts. Each > script has the appropriate (I think) #! declaration on the first line. > Here's a short record of my tests: > > $ pwd > /home/administrator > > $ echo $PATH > /usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/c > ygdrive/c/BGIUtils:/cygdrive/d/Utils/Python20/:/cygdrive/d/Utils/ULTRAE~1:/c > ygdrive/d/Utils/Perl/bin/:/cygdrive/d/dlh/bin:. > > $ ls -al /usr/local/bin > total 1 > drwxr-xr-x 2 administ None 0 Jan 10 16:01 . > drwxr-xr-x 5 administ None 0 Jan 10 16:01 .. > -rwxr-xr-x 1 administ None 59 Apr 5 11:35 test.sh > -rwxr-xr-x 1 administ None 77 Apr 5 11:34 test1.py > -rwxr-xr-x 1 administ None 92 Apr 5 11:39 test2.py > > $ cat /usr/local/bin/test.sh > #!/usr/bin/bash > echo "Hello, World (from the bash script)" > > $ cat /usr/local/bin/test1.py > #!d:/Utils/python20/python.exe > print "Hello, World (from the python script)" > > $ cat /usr/local/bin/test2.py > #!/cygdrive/d/Utils/python20/python.exe > print "Hello, World (from the python test2 script)" > > $ test.sh > Hello, World (from the bash script) > > $ test1.py > d:\Utils\python20\python.exe: can't open file '/usr/local/bin/test1.py' > > $ test2.py > d:\Utils\python20\python.exe: can't open file '/usr/local/bin/test2.py' > > $ > > > From this, I infer that cygwin bash understands the #! notation properly, so > I must have a problem with paths or some other configuration parameter. > Also, I've run these same tests with c:\ instead of /cygdrive/c and d:\ > instead of /cygdrive/d. > > Has someone out there been successful doing this? > > Configuration details: > > Windows NT 4.0 > GNU bash, version 2.04.5(12)-release (i686-pc-cygwin) > ActiveState Python 2.0.3 > > Regards, > David L. Humphrey > Manager, Software Development > Bell Geospace, Inc > > > > > > > > > From jeremy at digicool.com Wed Apr 18 15:49:27 2001 From: jeremy at digicool.com (Jeremy Hylton) Date: Wed, 18 Apr 2001 15:49:27 -0400 (EDT) Subject: do...until wisdom needed... In-Reply-To: <3d1yqqf5pp.fsf@ute.cnri.reston.va.us> References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> <9bk0ce026c6@news1.newsguy.com> <3d1yqqf5pp.fsf@ute.cnri.reston.va.us> Message-ID: <15069.61383.667640.199392@slothrop.digicool.com> >>>>> "AMK" == Andrew Kuchling writes: AMK> Paul Prescod writes: >> And if some smart people can use hygenic macros to make Python >> code that is more maintainable or readable, why should they be >> disallowed? AMK> I'm increasingly opposed to new Python features, but I'm still AMK> not ruling out the idea of hygenic macros. Their presence AMK> might remove the pressure to add new features, which would mean AMK> the language core would be that more stable. I expect it's AMK> very difficult to provide a simple interface for them in AMK> Python, though, because the syntax, and the resulting parse AMK> trees, are more complicated and less regular than in Lisp; AMK> maybe I'm just pessimistic, though. Me, too. There's a nice paper, "Quasiquotation in Lisp," by Alan Bawden that says everything worth knowing about quasiquotation: http://www.bawden.org/alan/ The paper emphasizes the synergy between S-expressions and quasiquotation, although it sets out three goals for a successful quasiquotation system: """ * Quasiquotation should enable the programmer to write down what she wants the output to look like, modified only slightly in order to parameterize it. * The parameter expressions should appear inside the template, in the position where their values will be inserted. * The underyling data structures manipulated by quasiquotation should be rich enough to represent recursively defined data structures such as expressions. """ While I think I would like to see a good program-generating technique for Python, I can't see how to make it work well because Python doesn't have any data structures for representing Python programs other than code objects and strings. Neither seems useful for quasiquotation. Jeremy From neelk at alum.mit.edu Tue Apr 3 21:08:39 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 4 Apr 2001 01:08:39 GMT Subject: A couple garbage collector questions References: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> Message-ID: On Tue, 03 Apr 2001 16:02:51 +1200, Greg Ewing wrote: >Kragen Sitaker wrote: >> >> Reference-counting exacts very heavy performance costs, no matter what >> you back it up with. > > Something nobody has mentioned yet is that RC is cache-friendly, > whereas pure M&S is quite cache-hostile. This is important now that > most machine architectures are heavily reliant on cacheing for good > performance, and I believe that it is one of the main reasons for > retaining RC alongside the new GC mechanisms. Naive question: wouldn't adding a word (for the RC) to every object make locality worse? I'd appreciate an explanation of why it improves locality -- this seems highly nonintuitive to me. Besides, the whole thing seems a moot point to me: dictionaries are probably the most commonly used data structure in a Python run (they are used to implement modules, classes, instances, and um dictionaries), and they are about as cache-hostile a data structure as you can find. Neel From tuttledon at hotmail.com Wed Apr 18 14:09:43 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Wed, 18 Apr 2001 18:09:43 GMT Subject: Create/Edit Win32 Shortcuts? Message-ID: I can't believe that Python doesn't have the ability to create/edit Win32 shortcuts (.lnk files). But after an hour of searching the archives and my books I can't find anything at all. Would someone point me in the right direction? Don From chris at voodooland.net Thu Apr 12 16:55:08 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 12 Apr 2001 15:55:08 -0500 (CDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: Message-ID: <20010412154507.G5427-100000@open-systems.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > > Mind showing us your license? Sounds interesting. > > One method would be to simply add the advertising style clause back in > to a BSD license. I'm not for that but it's the simplest way I can > think of. Also what you can do is the following, which is about as legal as the GPL if it's ever challenged so you would have to run it by an attorney: # 3. The license on this code can not be changed or altered in any way. # No additional terms, conditions, or restrictions may be placed on # this code. That is taken out of context. The full license looks as such: # Copyright 2001 Chris Watson (scanner at jurai.net). All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer. # 3. The license on this code can not be changed or altered in any way. # No additional terms, conditions, or restrictions may be placed on # this code. This pretty much ensures the code can be used in source form OR binary form, and that you CANNOT add any additional items, conditions, terms, restrictions, etc.. By doing so you would violate my license. This guarantees people cant corrupt my code with the GPL. Remove clause 3 and they can. Because clause 1 and 2 do *not* prohibit the code from being GPL'ed. 3 Should stop it dead. Now as a negative side effect, companies are not allowed to add their own restrictions to it either :-/ So you could ammend clause 3 with: # I am completely happy to allow this code to be licensed in # other ways for a commercial entity, just mail me at the above # address. So that they can get youre permission to create their own whatever license of it. Is this ideal for a company probably not. But a slight inconvenience for a company to simply ask me if they can remove clause 3 for their code or modify said license is WAY better IMO then the Red FSF and GPL people being *allowed* to corrupt my code. ============================================================================= - -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: Made with pgp4pine 1.75-6 iD8DBQE61hY0oTcdKVapx58RAvSKAJwNL8d4r3puhSEl6EG9Cbh5JcDjyACdEMLH In65eegBzaGs6l2kk3IKwAI= =SfuY -----END PGP SIGNATURE----- From dpalmer at americasm01.nt.com Thu Apr 12 13:25:52 2001 From: dpalmer at americasm01.nt.com (Palmer, Dan [SKY:1G21:EXCH]) Date: Thu, 12 Apr 2001 13:25:52 -0400 Subject: why does activestate (win98) python not support globbing Message-ID: <9b4of1$j16$1@bmerhc5e.ca.nortel.com> I was working through Programing python by Mark Lutz, and I can get Example 4-1 working under unix (from the 2.0 tar.gz), but when I tried to run this under windows (win98 or win2000) it generates an error. The following error is generated. In unix it expands the *.py to all the associated files. In windows it does not. Why the difference. pack1.py *.py > packed.txt Traceback Message-ID: <20010429205317.67380.qmail@web10302.mail.yahoo.com> Roman Suzi wrote: > 1- you can use getopt earlier: command line params usually have more > priority than config-file ones. OK, this is the simple thing to do, but is it the right thing? I don't want to be accused of bad program design. Here is what I did: I moved the getopt section out of main to the very top of the program; after import of the standard modules, but before import of my "Default" module and before my function declarations. Now things work, but somehow I'm uneasy about the way things look. > 2- global vars are bad idea. You can use os.environ to put > configuration (environment) parameters, such as config file, there. Great suggestion, thanks. Regards, Graham __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ From mhagger at alum.mit.edu Thu Apr 19 17:04:12 2001 From: mhagger at alum.mit.edu (Michael Haggerty) Date: Thu, 19 Apr 2001 21:04:12 GMT Subject: Idiom gone, or did it really ever exist? () is () References: Message-ID: "Delaney, Timothy" writes: > > > That is, I was attempting to distinguish between a call where > > > argument is passed a NULL tuple and a call where argument is > > > passed nothing at all. > > # Should always work > > class nullArgument: > """""" > > __nullArgument = nullArgument() > > def func (p=__nullArgument): > if p is __nullArgument: > print 'Default parameter' > else: > print 'Parameter passed' When I first faced this problem, I started typing in code that was equivalent to yours, until it occurred to me that there is no reason to instantiate the class--the class itself serves as a fine default argument. In other words, class __nullArgument: pass # Isn't this what pass is for? def func (p=__nullArgument): if p is __nullArgument: print 'Default parameter' else: print 'Parameter passed' Cheers, Michael -- Michael Haggerty mhagger at alum.mit.edu From jcollin at exis.net Tue Apr 17 10:35:14 2001 From: jcollin at exis.net (Jay Collins) Date: Tue, 17 Apr 2001 10:35:14 -0400 Subject: gc.setthreshold()? Message-ID: I was wondering if anyone has any tips for using gc.setthreshold()? I added : gc.enable() gc.set_debug(gc.DEBUG_STATS) gc.set_threshold(1,2,3) to one of my programs and I got all kinds of neato output that I have no idea what it does. heheh anyways, how would you figure out what to put in gc.set_threshold()? From mcherm at destiny.com Tue Apr 3 23:44:33 2001 From: mcherm at destiny.com (Michael Chermside) Date: Tue, 03 Apr 2001 22:44:33 -0500 Subject: PEP 245 Message-ID: <3ACA98A1.60D5C626@destiny.com> Alex... I just wanted to say that your statements (quoted below) were extremely clearly-worded and easy to understand. Nice job of explaining it... perhaps some of this wording should even go in the PEP. To me, this (and other parts of the post... I didn't want to waste bandwidth by quote excessively) clearly explains the intent of interfaces as well as what they are NOT intended to achieve. -- Michael Chermside On Sun, 1 Apr 2001, Alex Shindich wrote: > > Take me for example. If I were a python object, I'd be an instance of a > class that is generalized by two other classes, my mom and dad. That's my > type, my genetics. Now, let's say you were a function that expected a > 'Python programmer'. You could wire that expectation to my implementation > (my class), but then, I'd be the only "kind" of python programmer you could > use. You could wire it to my generalized classes, but then you could only > use me and my two sisters, and they're not python programmers. > > What you want is anyone, anybody, regardless of their genetic > implementation, to work in your function because they assert "I am a python > programmer." It's a contract, protocol, interface, call it what you will: > > class Michel(Reg, Loretta) implements PythonProgrammer: > pass > > In terms of verification and enforcement, you can go through the expensive > task of verifying my previous employment, my academic history, my > contributions to python, etc, just once (verfication) or *every* time > you worked with me (enforcement) or you could use the much cheaper method > of trusting me when I say I am a Python programmer. PEP 245 does not > specify the policy you can use, all are possible. > > The idea of PEP 245 is to separate object introspection from > implementation. For example, you can create an object that quacks and > swims like a dictionary, but will not work for you as the right hand > component of an "exec 'x=5' in dict" statment. This is because the exec > code checks the object based on its type, on its genetic makeup, not on the > functionality it asserts itself to have. From dinu at reportlab.com Wed Apr 25 13:01:11 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Wed, 25 Apr 2001 17:01:11 GMT Subject: Floating point (in)accuracy? References: <3ae6eb73.802364759@news.vr.in-berlin.de> Message-ID: <3ae70288.808274006@news.vr.in-berlin.de> On Wed, 25 Apr 2001 16:46:10 GMT, "Fredrik Lundh" wrote: >Dinu Gherman wrote: >> Apparently the python mailiing lists on python.org are blocked, so let >> me ask here. Is there any good reason for the following behaviour to >> be different on Python 1.5.2 and 2.0? > >python 1.5.2 is lying to you. for the full story, see: >http://www.python.org/cgi-bin/moinmoin/FrequentlyAskedQuestions#line24 > >Cheers /F I learned that we have many FAQs just minutes ago - thanks! Well, why not, in fact? Dinu -- Dinu C. Gherman dinu at reportlab dot com http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From greg at cosc.canterbury.ac.nz Mon Apr 9 01:31:10 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 09 Apr 2001 17:31:10 +1200 Subject: Conditional operator in Python? References: Message-ID: <3AD1491E.25558FF4@cosc.canterbury.ac.nz> Tim Peters wrote: > > for (j=KK+KK-2;j>KK-LL;j-=2) > ul[KK+KK-1-j]=0.0,u[KK+KK-1-j]=u[j]-ul[j]; y(u[KK])! -- 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 mwh21 at cam.ac.uk Fri Apr 20 06:13:30 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 20 Apr 2001 11:13:30 +0100 Subject: Python 2.1 performance References: Message-ID: Per Gummedal writes: > Running pystone (average 3) > AMD Duron 650 - win2000 > > 1.5.2 - 10605 > 2.0 - 10282 > 2.1 - 9482 > > Is pystone a special case or is there a general drop in performance ? Both, probably. pystone isn't particularly typical code - it accesses globabl variables a lot, for one thing - but 2.1 probably is going to be a little slower. This is could be due to the rich comparisons, but I doubt anyone really knows. I had a whirl on this sort of thing a while back; you can see my results here (on linux/x86): http://mail.python.org/pipermail/python-dev/2001-January/012330.html mal's pybench makes the CVS of about 3 months back about 3% slower than Python 2.0; I *doubt* the released version was much different (but as I said in a post yesterday - this is a hunch about performance, and therefore probably wrong). Can you try building using the optional memory allocator? I don't know how you do that on Windows, but it would be interesting. Cheers, M. -- I don't remember any dirty green trousers. -- Ian Jackson, ucam.chat From aahz at panix.com Wed Apr 18 15:07:19 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Apr 2001 12:07:19 -0700 Subject: PEP 6 revision Message-ID: [posted to c.l.py.announce and c.l.py; followups to c.l.py; cc'd to python-dev] [Barry, please update Post-History] Okay, here's the next version of PEP 6: PEP: 6 Title: Bugfix Releases Version: $Revision: 1.3 $ Author: aahz at pobox.com (Aahz) Status: Draft Type: Informational Created: 15-Mar-2001 Post-History: 15-Mar-2001 Abstract Python has historically had only a single fork of development, with releases having the combined purpose of adding new features and delivering bug fixes (these kinds of releases will be referred to as "feature releases"). This PEP describes how to fork off patch releases of old versions for the primary purpose of fixing bugs. This PEP is not, repeat NOT, a guarantee of the existence of patch releases; it only specifies a procedure to be followed if patch releases are desired by enough of the Python community willing to do the work. Motivation With the move to SourceForge, Python development has accelerated. There is a sentiment among part of the community that there was too much acceleration, and many people are uncomfortable with upgrading to new versions to get bug fixes when so many features have been added, sometimes late in the development cycle. One solution for this issue is to maintain the previous feature release, providing bugfixes until the next feature release. This should make Python more attractive for enterprise development, where Python may need to be installed on hundreds or thousands of machines. Prohibitions Patch releases are required to adhere to the following restrictions: 1. There must be zero syntax changes. All .pyc and .pyo files must work (no regeneration needed) with all patch releases forked off from a feature release. 2. There must be zero pickle changes. 3. There must be no incompatible C API changes. All extensions must continue to work without recompiling in all patch releases in the same fork as a feature release. Breaking any of these prohibitions requires a BDFL proclamation (and a prominent warning in the release notes). Version Numbers Starting with Python 2.0, all feature releases are required to have a version number the form X.Y; patch releases will always be of the form X.Y.Z. The current feature release under development is referred to as release N; the just-released feature version is referred to as N-1. Procedure The process for managing patch releases is modeled in part on the Tcl system [1]. The Patch Czar is the counterpart to the BDFL for patch releases. However, the BDFL and designated appointees retain veto power over individual patches. As individual patches get contributed to the feature release fork, each patch contributor is requested to consider whether the patch is a bugfix suitable for inclusion in a patch release. If the patch is considered suitable, the patch contributor will mail the SourceForge patch (bugfix?) number to the maintainers' mailing list. In addition, anyone from the Python community is free to suggest patches for inclusion. Patches may be submitted specifically for patch releases; they should follow the guidelines in PEP 3 [2]. The Patch Czar decides when there are a sufficient number of patches to warrant a release. The release gets packaged up, including a Windows installer, and made public. If any new bugs are found, they must be fixed immediately and a new patch release publicized (with an incremented version number). Patch releases are expected to occur at an interval of roughly one month. In general, only the N-1 release will be under active maintenance at any time. Patch Czar History Moshe Zadka (moshez at zadka.site.co.il) is the Patch Czar for 2.0.1. Issues To Be Resolved What is the equivalent of python-dev for people who are responsible for maintaining Python? (Aahz proposes either python-patch or python-maint, hosted at either python.org or xs4all.net.) Does SourceForge make it possible to maintain both separate and combined bug lists for multiple forks? If not, how do we mark bugs fixed in different forks? (Simplest is to simply generate a new bug for each fork that it gets fixed in, referring back to the main bug number for details.) History This PEP started life as a proposal on comp.lang.python. The original version suggested a single patch for the N-1 release to be released concurrently with the N release. The original version also argued for sticking with a strict bugfix policy. Following feedback from the BDFL and others, the draft PEP was written containing an expanded patch release cycle that permitted any previous feature release to obtain patches and also relaxed the strict bugfix requirement (mainly due to the example of PEP 235 [3], which could be argued as either a bugfix or a feature). Discussion then mostly moved to python-dev, where BDFL finally issued a proclamation basing the Python patch release process on Tcl's, which essentially returned to the original proposal in terms of being only the N-1 release and only bugfixes, but allowing multiple patch releases until release N is published. References [1] http://dev.scriptics.com:8080/cgi-bin/tct/tip/28.html [2] http://python.sourceforge.net/peps/pep-0003.html [3] http://python.sourceforge.net/peps/pep-0235.html Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From huzengjian at hotmail.com Wed Apr 11 09:45:30 2001 From: huzengjian at hotmail.com (zengjian) Date: Wed, 11 Apr 2001 09:45:30 -0400 Subject: Error of building Python on SGI Message-ID: <3AD45FF9.909C9DB5@hotmail.com> Hi, I have tried to install Python on my SGI according to the instruction of README. I always get the error message when I use 'make' or 'smake'. Can anyone be kind anough to help me? Zengjian Georgetown University Medical center huzj at giccs.georgetown.edu From MarkH at ActiveState.com Tue Apr 24 10:41:54 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 24 Apr 2001 14:41:54 GMT Subject: NTFS permissions References: <1e232f6f4a%tim@worthy.demon.co.uk> <3AE360DA.5030806@ActiveState.com> <8b4a16f4a%tim@worthy.demon.co.uk> <3AE4BAB0.3090204@ActiveState.com> <1af319704a%tim@worthy.demon.co.uk> Message-ID: <3AE590F2.9070304@ActiveState.com> Chris Gonnerman wrote: >>(Except, that echoes output to my user creator web page, need to sort >>that out....change stdout whilst calling cacls ?) >> > > Use the os module to manipulate the "real" stdout/stderr before running > your ill-behaved program. Assuming you want the external program's output > hidden: Or use the popen family so the output of the child process can be simply discarded or read into a string. Mark. From aleaxit at yahoo.com Fri Apr 6 15:02:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Apr 2001 21:02:58 +0200 Subject: Changing global variables in tkinter/pmw callback References: Message-ID: <004f01c0becc$dad3e6e0$0300a8c0@arthur> "Jonathan Claggett" writes: > >(Or, you could use a 'grab-bag instance object' -- it > >does not have to be a module-object; see for example > >http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52308). > > How about improving the Bunch class to allow subscript access to its > attributes? This makes an instance of Bunch reminiscent of a Javascript > instance. Oh, it's easy indeed (just delegate __getitem__ to self.__dict__), but the resulting confusion between items and attributes seems a strange target to aim for. If you want a dictionary, it's easy to make one: > >>> ex = Bunch(salary=10000, rank=5) Becomes: ex = { 'salary': 1000, 'rank': 5 } > >>> ex.rank > 5 > >>> ex['salary'] > 10000 If ex was a dictionary, the latter syntax would be the only allowed one. What I'm missing is the added-value of allowing both... > Or is this asking for trouble that I, an affirmed Python newbie, would not > be aware of? That's the trouble with languages, in addition to the syntax > rules there are always the undocumented 'good practice' rules :-) Only applicable 'good practice' rule that I can think of here is not going out of your way to promote confusion. Maybe I'm missing something...? Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From aleaxit at yahoo.com Sun Apr 29 17:18:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 29 Apr 2001 23:18:36 +0200 Subject: Dictionary of "structs" with functions as components? References: <9chp0n$sk2$1@news.jump.net> Message-ID: <9ci1l70k56@news2.newsguy.com> "Eric Sandeen" wrote in message news:9chp0n$sk2$1 at news.jump.net... > First a disclaimer - I'm pretty new to Python, and OOP is not really my > bag, so forgive me if this is a silly question... It ain't silly, and it would be no problem if it were... > I'm trying to create a data structure which holds information about > several different filesystems - for example: ext2, reiserfs, and xfs. I'd > like this to be easily extensible to add other filesystems, as well. The > type of information I'm including is name, magic number, position of magic > number in superblock, etc. So far, I'm doing something like this (these > values aren't right, just an example) : > > FSystems['ext2'].PrettyName = "ext2 filesystem" > FSystems['ext2'].MagicNo = 0xce32 > FSystems['ext2'].MagicNoPos = 1080 > > FSystems['xfs'].PrettyName = "XFS filesystem" > FSystems['xfs'].MagicNo = "XFSB" > FSystems['xfs'].MagicNoPos = 0 So far, so good. Presumably, then, you have some class such as: class FileSystem: pass or maybe it has some extra attributes, but this isn't mandatory (it's OK to add attributes per-instance). Still, it might handier to have: class FileSystem: def __init__(self, prettyName, magicNo, magicNoPos): self.prettyName = prettyName self.magicNo = magicNo self.magicNoPos = magicNoPos so that FSystems['ext2'] = FileSystem("ext2 filesystem", 0xCE32, 1080) and so on, will suffice. Strictly an issue of more convenience for you when you're filling the FSystems dictionary. > This way I can iterate over FSystems.keys() to do things like check for a > filesystem, create menus, etc. These activities are basically the same > regardless of the filesystem, so they're easy to handle in a single > function. But if some sub-activities differ in detail by filesystem, you may still use a common function for the overall structure and call the appropriate object methods for whatever. It's called the 'Template Design Pattern' and it's pretty important. Anyway...: > The problem comes when I'd like to define a unique function for each > filesystem to actually create the filesystem, since this will vary quite a > bit from fs to fs. I'd like to access it via something like > > FSystems[].unique_fs_function() > > In C, I'd have a pointer to the function I want. Is something like this > possible in Python? Just about everything in Python is accessed through references, which act much like pointers. Specifically, you can do, for example: def specific_ext2_creator(): # whatever you want here and then FSystems['ext2'].unique_fs_creator = specific_ext2_creator and you're all set to call the .unique_fs_creator() on this entry of your dictionary. Note that, like in C, just MENTIONING the function doesn't call it but rather yields/lets you set a reference; it's the presence of _parentheses_ () after the function name or other reference to it that let you actually CALL the thing. In C you may also indicate the referencing or dereferencing via the unary operators & and *, redundantly in the case of functions, but in Python "any mention is a reference" for functions just like for any other object. There are other approaches -- you may define a _subclass_ of FileSystem and use methods rather than function, and this is often handier, as the instance on which the method is being called will be always available as the first argument. But if you do want to work with functions rather than with classes and methods, you may do that too -- it's up to you, Python does support both paradigms well! Alex From jbaker at ummelec.com Thu Apr 19 11:46:53 2001 From: jbaker at ummelec.com (Jake Baker) Date: Thu, 19 Apr 2001 10:46:53 -0500 Subject: Newbie question: how to determine "is-a" relationship Message-ID: Gosh. I've been using Python since 96 and I don't know this! Wow! Say I have a class heirarchy that looks like A, B <- A, C <- A, etc.... I have a list of objects (which I know arbitrarily are all A or sublasses of A) and want to filter them based on which subclass they are. How do I go about doing this? You help is greatly appreciated! Thanks, - Jake Baker From sheila at spamcop.net Mon Apr 16 22:03:36 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 17 Apr 2001 02:03:36 GMT Subject: What can you do with python? References: Message-ID: On Mon, 16 Apr 2001 21:18:52 -0400, "Ice Cap" wrote in comp.lang.python in article : :What kind of stuff can you make with python? System patches? : http://groups.google.com/groups?num=25&hl=en&lr=&group=comp.lang.python.&th=798983d5cc9a6bb2&start=0&ic=1 -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From michael at stroeder.com Thu Apr 12 17:36:35 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 12 Apr 2001 23:36:35 +0200 Subject: Thread-blocking (was: socket.gethostbyname() thread-safe?) References: <3AD1ABD0.FB728F28@stroeder.com> <9av6ni$9ao$1@panix6.panix.com> <3AD33118.8C16E617@stroeder.com> <9b0aqi$erj$1@panix6.panix.com> <3AD3C2B4.8A0F4E0E@stroeder.com> Message-ID: <3AD61FE3.F06DFA2A@stroeder.com> Johannes Stezenbach wrote: > > Michael Str?der wrote: > >The whole HTTP serving stuff seems to work just fine. I could track down the problem a little bit more: The threads are blocking if the user aborts the loading of the web page (using the SocketServer.ThreadingMixIn). In this case an IOError exception is raised which never reaches the appropriate handler thread. The IOError exceptions show up after I stop my main thread. Any solution? Ciao, Michael. From zzizz_ at notmail.com Sat Apr 7 23:35:08 2001 From: zzizz_ at notmail.com (zzzzz) Date: Sun, 08 Apr 2001 13:35:08 +1000 Subject: Extended slicing Message-ID: <6glvctosv84iigfdkipbmsk1si3dl43fl7@4ax.com> Hi all, Just looking at the Reference Manual Release 2.0 dated Oct 16, 2000 at the section on 5.3.3 slicings. It appears to me that I should be able to use an extended slice like follows: x=range(20) y=x[3:4,6:10] However, when I try this on Python '2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)]' I get a traceback error "TypeError: sequence index must be integer". Is this feature implemented yet? Have I misread the definition of slicing? How do I know it's not implemented? From mwh21 at cam.ac.uk Wed Apr 25 15:55:39 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Apr 2001 20:55:39 +0100 Subject: Floating point (in)accuracy? References: <3ae6eb73.802364759@news.vr.in-berlin.de> <9c6vmq02kec@news2.newsguy.com> Message-ID: grante at visi.com (Grant Edwards) writes: > I presume that on typical platforms, it can't be guaranteed that > float(repr(x)) == x. I imagine this depends on your C library's atod and printf functions being any good. It certainly seems to be the case here: />> for i in range(100000): |.. x = random.random() |.. if x != float(repr(x)): |.. print x \__ ->> > If you pickle a float and then un-pickle it on the same platform are > you guaranted to end up with the same binary representation? Well: ->> pickle.dumps(3.14) 'F3.1400000000000001\n.' so iff repr(float(x)) is the same as x. But: ->> pickle.dumps(3.1,1) 'G@\x08\xcc\xcc\xcc\xcc\xcc\xcd.' So it looks like for binary pickles the answer is "yes". Cheers, M. -- 81. In computing, turning the obvious into the useful is a living definition of the word "frustration". -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From kelley at bioreason.com Fri Apr 27 17:34:46 2001 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 27 Apr 2001 22:34:46 +0100 Subject: ANN: mxNumber -- Experimental Number Types, Version 0.2.0 References: Message-ID: <3AE9E5F6.85F45783@bioreason.com> Tim Peters wrote: > [Brian Kelley] > > I have taken the opportunity to expose a couple of Integer methods > > > > Integer.popcount() - number of bits set > > Integer.setbit(bit) - set the bit indicated by bit > > Integer.clrbit(bit) - set the bit indicated by bit > > > > These are very useful for Aritificial Intelligence/feature vector > > algorithms. Is there any other desire to see these types of functions > > exposed? > > Yes, provided they're carefully defined. For example, what's the popcount > of -1? If you're viewing Integers as using 2's-comp notation (as Python > does), there's no obvious answer to that (-1 is an "infinite string" of 1 > bits), which makes it *especially* important to define what it does. All > previous attempts to define these kinds of things floundered to death in an > ocean of competing silly arguments. > This is actually defined from the original api although I am probably opening up the sea of silly arguments. Function: unsigned long int mpz_popcount (mpz_t op) For non-negative numbers, return the population count of op. For negative numbers, return the largest possible value (MAX_ULONG). more good stuff at http://www.swox.com/gmp/manual/gmp_6.html#SEC30 > Pickles are supposed to be platform- and release-independent, so you can't > change what the existing long format code does. Note that it's "a feature" > of text-mode pickles that they're composed of printable ASCII, too. It's > possible that you may be able to add a new format code to binary pickles. This is more what I meant: >>i = mx.Number.Integer("100101011101010") >>pickle.dump(i,0) "cmx.Number\n_I\np0\n(S'10101010101010'\np1\ntp2\nRp3\n." The string S'10101010101010' is a fairly wasteful encoding for a bit vector. There could be an encoded string form that generates the same bits but with fewer characters. Since mx.Number.Integer already takes a string as an initializer there could perhaps be an encoded string form that is also accepted. Note that 10101010101010 needs roughly 44 bits to store. The string is 112 bits in the pickle. I wasn't intending to modify pickle at this stage, just make (perhaps) a more efficient pickle representation. Brian Kelley From robin at jessikat.fsnet.co.uk Fri Apr 13 10:44:30 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 13 Apr 2001 15:44:30 +0100 Subject: idioms for abstract base classes References: <9b6qtv02h2i@news2.newsguy.com> Message-ID: In article <9b6qtv02h2i at news2.newsguy.com>, Alex Martelli writes >"Robin Becker" wrote in message >news:mZW4xJA40t16EwtA at jessikat.fsnet.co.uk... >> what's the best way to spell an abstract base class so that >> 0) base is B and A inherits from B >> 1) doing B() causes an exception >> 2) most of the initialisation code is common in B > [snip] >> is there a neater way to do this that knows when B is being instantiated >directly? > >Pretty easy: > >class B: > def __init__(self): > if self.__class__ == B: > raise AbstractClassException, B > # proceed with initialization tasks > >self.__class__ is set to the actual (most-derived) class >that is being instantiated, whether B's __init__ is being >executed explicitly or through inheritance. > > >Alex .... yes that's the sort of thing -- Robin Becker From glingl at aon.at Fri Apr 20 19:15:44 2001 From: glingl at aon.at (Gregor Lingl) Date: Sat, 21 Apr 2001 01:15:44 +0200 Subject: Problem with smtplib: message vanishes Message-ID: <3AE0C320.B7D92F7C@aon.at> I've got the following problem: Using smtplib as discribed in the documentation and also in Lutz' Programming Python to send emails, I'm able to send mails without error messages. But when trying to open it in Netscape-Messenger, I can see, that I received it nut I get something like Betreff: python-mehl2 Datum: Sat Apr 21 00:11:43 2001 Von: lingl at aon.at An: glingl at aon.at ... which means: the message-text is missing completely. When looking at the 'source-code' of the message, I find: Message-ID: Return-Path: Delivered-To: glingl at aon.at Received: (qmail 3793630 invoked from network); 20 Apr 2001 22:11:45 -0000 Received: from n408p010.adsl.highway.telekom.at (HELO INTERNET-WS) ([213.33.50.234]) (envelope-sender ) by qmail4.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 20 Apr 2001 22:11:45 -0000 From: lingl at aon.at To: glingl at aon.at Date: Sat Apr 21 00:11:43 2001 Subject: python-mehl2 Vielleicht geht's so! probieren wirs's aus Gr??e Gregor X-Mozilla-Status: 0000 X-Mozilla-Status2: 00000000 X-UIDL: 987804705.4637304.SSP1NO49,S=520 ..... which contains the message-text, which nevertheless is not displayed in the email-client-window. Perhaps the last three lines are the offending ones, because comparing the python-sent to normal emails, i find those lines before the message. Or something else is going wrong. How could I use the sendmail-method correctly? ... asks a little bit desparately Gregor Lingl From jgitomer at erols.com Thu Apr 26 20:03:50 2001 From: jgitomer at erols.com (Jerry Gitomer) Date: Fri, 27 Apr 2001 00:03:50 +0000 Subject: Caching Strategies/Database question References: <3AE84904.C69D88C0@bioreason.com> Message-ID: <9caqvl$hl8$1@bob.news.rcn.net> Brian Kelley wrote: > I am using a dictionary to hold > > {string:[list of integers]} > > key: values > > The dictionary is randomly accessed to add an integer to the > list referenced by the string. > > I have been exploring several differnent caching strategies > ranging from > bsddb3 to the metakit toolkit for caching/retrieving these to > disk. One of the problems that I am facing is that because > the dictionary is randomly accessed after the database gets to > a certain size performance > goes WAY down with every strategy that I have tried. (Note > that > integers are never removed if that helps) I have had success > speed-wise with MySQL but I simply cannot deliver that in my > application, it's way too costly to administer. > > Has anyone examined a similar problem? Thanks in advance. > > Brian Kelley > > > Here I go shooting from the hip without knowing all of the facts. (To give a proper answer I really should know how many bytes is each key/pointer pair, how many records will the database contain, and at what point do you hit the performance wall.) Assuming that data access is truly random the least expensive way of storing and accessing (assuming you are going to roll your own and not go with an existing product) is to add all new records at the end of the file, mark, but do not remove deleted records, and build indexes to access the records. The trick is building and maintaining the indexes. The solution is to build a multi-level index structure that is not fully populated. Each index entry will consist of three fields; the unique key for the record, the byte offset of the record in the file, and a one byte indicator telling wether this index entry addresses a lower level index block or a data record. The data and each level of the index should be in separate files. Assume that each such entry is 32 bytes long and that your OS block size is 8K. Rather than fully populate each block with 256 entries populate each index block with 250 entries. To build the index create a sorted list for the entire database and then populate the bottom level of the index. Next, build a sorted list consisting of the first entry in each block of the lower level. (Note that in this and any higher level index blocks the indicator must be set to show that this entry is pointing to an index block and not a data blcok.) Build the second level index. At this point consider the following each block in the second level index will point to 250 blocks in the first level index which will in turn point to 250 data records. If the second level index is held in memory each 2nd level block will allow you to access 62,500 records with no more than two disk accesses. If a third level index is needed you wil be able to access any one of 15,625,000 records with no more than three disk accesses. The reason for not fully populating the database and the indexes is to allow for expansion without total reorganization. The problem with this scheme being that if you need to add seven records to an index block it is necessary to split the block, that is create a new index block and move half of the entries in the split block into the new block. In general this should only happen at the first level, but you must still make provision for either splitting or total index reorganization. Hope this helps. Also, if you do implement it please contribute the code. -- Jerry Gitomer Once I learned how to spell DBA, I became one From robin at jessikat.fsnet.co.uk Tue Apr 24 06:31:22 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 24 Apr 2001 11:31:22 +0100 Subject: PyArg_Parse weirds References: Message-ID: In article , Michael Hudson writes >Robin Becker writes: > >> can someone jog my cpu to solve a problem with this C fragment >[snip] >> >> so I'm getting the attribute ok and it is a float (checked in >> python) so why does my PyArg_Parse of v fail? > >Works for me (well, something similar does). What exception is >getting set? If it's > >Traceback (most recent call last): > File "", line 1, in ? >TypeError: bad argument type for built-in operation > >then you probably haven't passed in a float. IOW, I don't think the >problem's in the code you posted. > >Could be wrong, of course. > >CHeers, >M. > I just get 0 back from the PyArg_Parse so have to assume it didn't work and as the value printed out suggests it hasn't put anything into r. -- Robin Becker From jeske at chat.net Sun Apr 22 13:52:52 2001 From: jeske at chat.net (David Jeske) Date: Sun, 22 Apr 2001 10:52:52 -0700 Subject: Python Performance vs. C++ in a Complex System In-Reply-To: <18630678994.20010421200529@buz.ch> Message-ID: <20010422105252.B5762@mozart.chat.net> --- In python-list at y..., Gabriel Ambuehl wrote: > Sunday, April 15, 2001, 10:26:23 PM, you wrote: >> Having completed both cores, and with the C++ core HIGHLY >> OPTIMIZED, I was finally able to perform a performance test of the >> the C++ system versus the Python system. To my surprise, the C++ >> core only beat Python by about 30%. Given the obvious inequities in >> coding time in both efforts, plus whatever future coding time >> inequities I might project onto users of either core by implication >> of the programming language, I was quite surprised by these >> results. Programs which are I/O bound, either because they talk to other slow programs, or because they do very little processing themselves, will likely perform similarly in C and Python. The Python version will use more memory. For example, at eGroups.com, Sam Rushing wrote an outgoing mailsender called "Newman", completely in Python and his Medusa async i/o framework. It performs exceedingly well and is only about 8000 lines of Python. If rewritten in C, it would use less memory, and probably perform slightly better. > This is very interesting. I've got to implement a server resource > monitoring system and had a shot at it in my beloved Python. While > Python's threading obviously works (something I can't really say > about C++ as it appears to be not very well thought the whole > stuff), I found it to be very slow. You can see some performance comparisons for operations common to scripting languages at my ScriptPerf page: http://www.chat.net/~jeske/Projects/ScriptPerf/ I'd say that C++ will perform much better threaded than Python, but you have to be the smart one doing the locking in C++, wheras Python helps you out a little bit. > I'm now thinking about whether I should try to reimplement the whole > url stuff in C (being C/C++ novice) to see whether this would speed > up the whole process (or is there any C implementation of an httplib > for Python that works with it's threading?). Last time I used httplib, it was terribly slow for two reasons. First, it was calling write() on the socket for each piece of the HTTP header. I made it build a string in memory and then only do one write() and it resulted in a major speed increase. Second, it does DNS lookups each time you call it. Adding a small DNS cache will get you another big speed win. > The major PITA I continually stumbling across is the fact that I > need to have concurrent service checks, so a single threaded app > with a large queue as scheduling mechanism isn't of much use. Python threading has never performed very well for me. Usually, this is because it's using Pthreads, and you may be using a user-space implementation of Pthreads. There are usually ways to get around single points of contention by just allocating your units of work in larger blocks. I recommend making a non-threaded test-harness and running the Python profiler on it. (after you fix httplib) > I've been thinking about a fork() based solution (AFAIK this is what > NetSaint is doing) but the reporting of the results isn't doable in > any halfway reliable or elegant way and it obviously requires way > more resources than a threaded app. Sure, you can report results. Just open pipes back to the main process, and when a child dies, read results off the pipe. If you have lots of results you might need to make the main process async/non-block and read results continuously. You can even use Python marshall to hand back complex data-types. Going multi-process does not have to mean using lots more resources. In Linux, a thread is pretty close to a process. If you load up all the code and then fork(), you'll have something which is pretty damn close to the efficiency of threading, without the locking overhead. > The original idea was to have a constantly running thread for every > resource to monitor (which can get kinda problematical ram usage > wise in very big networks but this isn't my problem just now as I > can throw upto 1GB RAM on this even for a few number of > hosts[2]). which then schedules itself using sleep(). This appears > to be working perfectly but slow in Python and not at all (due to > libcurl[3] related crashes) in C/C++. Sounds like you should look at the co-routine based version of the Medusa async-i/o library. It's basically select() based cooperative multitasking. If you go the next step and use Stackless python, you can really cut down on your memory usage. Generally I wouldn't suggest having hundreds of concurrent threads, even if you were writing your software in C. Just use async I/o with a few worker threads. > Ideally, I'd want to implement the whole stuff in C++ (or probably > some wild mix of C and C++, which generally works pretty ok) with > existing libraries but obviously nobody thought about giving the > threading stuff some flag that would take care of the data (so that > pointers can't get fucked by non thread safe libs while something > other is executed) and I clearly lack the programming experience to > do such a complicated task myself (I think it would be possible but > I've some worries about the performance penalties this could cause). You certainly should learn how to keep data safe in a threaded environment before you do threaded programming in C/C++. > [2] Python did some two hundred concurrent threads with about 30 MB > RAM usage on FreeBSD which would be very nice if I could only get > CPU utilization way down. Try: 1) optimizing httplib as I mentioned 2) don't spawn hundreds of threads, build an async I/O select loop (possibly with Medusa), and use a small number of worker threads to handle data. 3) run a python profile of your code in a single-threaded test harness -- David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske at chat.net From mal at lemburg.com Fri Apr 27 09:09:58 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 27 Apr 2001 15:09:58 +0200 Subject: ANN: mxNumber -- Experimental Number Types, Version 0.2.0 References: <5.0.2.1.0.20010426145150.02335ec0@mail.inet.com.br> Message-ID: <3AE96FA6.5C08B291@lemburg.com> Carlos Ribeiro wrote: > > At 23:15 25/04/01 +0200, M.-A. Lemburg wrote: > >Complex numbers are not integrated into the picture since I > >think that they should not be auto-coerced. > > What is the type of the real and imaginary terms of a complex number? Are > they floats today? For the C implementation of complex numbers, they are two C doubles today. The original Python implementation however (Demo/classes/Complex.py) does not seem to care about the types. > It should be possible to specify a complex number with > rational terms, don't you think? Sure, why not ?! > > - there is no way to bind the types to a Python literal, e.g. > > by specifying a number literal modifier which is then bound > > to the type: 1234L -> long("1234"), 1234.123F -> Float("1234.123"), > > 2R / 3 -> Rational(2, 3) etc. > > An optional (and unambiguous) way to specify a Rational literal would be > > 2R3 or 2r3 > > Some people may argue that its ugly. Note that I am not proposing that R > should be trated as an operator; it's just like the "." (dot) in floats, or > the "E" of the exponential notation. So the same rules apply - it's going > to be handled by the parser, and there should be no spaces between the numbers. > > WARNING: This is just a weird idea, but I think it's worth some > investigation. It's very common to have mathematical constructs such as > pi/4. Should these constructs be treated as "extended rationals"? It would > allow for a much easier way to expresse some useful numbers. I don't think > that this would be easy to handle, but anyway I'm curious about it... The 'r' notation looks weird. About the handling of common terms such as pi/4 -- well these are irrational numbers, so I guess the only possible way to deal with them is by using arbitrary precision generators... I don't think it is worth going down that lane though. -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From mnajmeddine at geo.census.gov Mon Apr 9 09:12:43 2001 From: mnajmeddine at geo.census.gov (Mohamed Najmeddine) Date: Mon, 9 Apr 2001 09:12:43 -0400 Subject: (no subject) Message-ID: signoff SERVLET-INTEREST From mwh21 at cam.ac.uk Wed Apr 25 16:22:51 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Apr 2001 21:22:51 +0100 Subject: Creating commands with Python References: <3ae72c79.2937814018@News.CIS.DFN.DE> Message-ID: costas at meezon.com writes: > Is there a way in Python to define new keyworded commands. For > example Python has the "import from" command. No. > If not, why does Python have this inconsitent keyword based command? Pragmatics? Cheers, M. -- ... but I guess there are some things that are so gross you just have to forget, or it'll destroy something within you. perl is the first such thing I have known. -- Erik Naggum, comp.lang.lisp From aleaxit at yahoo.com Sun Apr 15 05:08:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Apr 2001 11:08:00 +0200 Subject: how to import from variable source References: <20010414160900.A7013@madeforchina.com> Message-ID: <9bboat0sc8@news2.newsguy.com> "Rob Brown-Bayliss" wrote in message news:mailman.987320124.14328.python-list at python.org... [snip] > module = 'mymod' > import module > > Only, as I found out I get an error stating that there is not module > called module. > > Is this possible in python? Is there a better way perhapse? Standard module imp provides functions find_module and load_module that support this. See: http://www.python.org/doc/current/lib/examples-imp.html for Python code that uses them to mimic the import statement (without hierarchical packages) and is easy to tweak so as to decouple the diskfile name from the name you want to use for the module in your code. Alex From KPutland at servicemagic.com Fri Apr 6 11:41:47 2001 From: KPutland at servicemagic.com (Putland, Karl) Date: Fri, 6 Apr 2001 09:41:47 -0600 Subject: SAFEARRAY(ISpecific*)* type in COM Automation from Python Message-ID: > -----Original Message----- > From: Alex Martelli [mailto:aleaxit at yahoo.com] > Subject: SAFEARRAY(ISpecific*)* type in COM Automation from Python > > > A problem I hadn't seen yet -- wonder if anybody has already > solved it and can offer advice... > > I have to call a method on an Automation object that needs > a parameter of type SAFEARRAY(IFoo*), where IFoo is a (dual) > interface defined in that same type library. I can make > suitable objects that implement IFoo through suitable factory > methods in that object-model, but when I then try to pass a > list of those 'suitable objects' where the SAFEARRAY(IFoo*) > is required, I get a "type mismatch" COM error: > > Traceback (most recent call last): > File "", line 1, in ? > File > "d:\python20\win32com\gen_py\F4503A16-F637-11D2-BD55-005004004 > 05Bx0x1x0\I > ProfileCreator.py", line 31, in AddProfile > ret = self._oleobj_.InvokeTypes(0x1, LCID, 1, (9, 0), > ((24585, 1), (11, > 1)), > pCvs, autoConstraint) > pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1) > > Is there some known way to solve this peculiar problem...? > > > Alex > > Bellow is a snipped dredged up from a Python COM server I wrote a while back. I think you will find this helpful. First create a collection, then wrap the collection. --Karl def foo: ... tmpfields=[] for field in table_inst.fields: field._public_methods_ = ['read', 'write', 'append'] field._public_attrs_ = ['name', 'size', 'type' 'value'] name = string.lower(field.name) field = win32com.server.util.wrap(field) tmpfields.append(field) setattr(table_inst, name, field) # turn tmpfields into a collection if debug: print "\n turn tmpfields into a collection" print "\n tmpfields Before: " + `tmpfields` tmpfields=win32com.server.util.Collection(tmpfields,1) if debug: print "\ntmpfields After: " + `tmpfields` ### WOW I finally grok # Wrap the Collection. tmpfields=win32com.server.util.wrap(tmpfields) setattr(table_inst, "fields", tmpfields) # Return a wrapped table wrappedtable=win32com.server.util.wrap(table_inst) return wrappedtable From shippy at nmt.edu Fri Apr 27 00:22:37 2001 From: shippy at nmt.edu (Jeff Shipman) Date: Thu, 26 Apr 2001 22:22:37 -0600 Subject: My First CGI Script References: Message-ID: <3AE8F40D.64261D7@nmt.edu> Ben Ocean wrote: > **How do I capture the data? What I normally do first is form = cgi.FieldStorage() That grabs all of the data from your form. Then, you can grab the individual components of your form by using it like a dictionary. (ie: form["name"], form["address"]) There are a couple of good examples in the library reference. > **How do I write a Web page on the fly and assign it the name *Report*? What I usually do is just have the cgi print out the webpage to be viewed. You could always write the results to a file and call it Report.html and do some funky redirecting, but it's just nasty and you get into other security issues for which you need a C wrapper with the SUID bit to allow you to write to files in your directory (assuming you're using Linux) and...well, this is straying from the topic of Python. Anyway, as I was saying, what I normally do is just print the results to stdout like so: print 'Content-type: text/html\n\n' print '\n'\ ' \n'\ ' This is my name: '+form["name"]+'\n'\ ' \n'\ '' and your browser should pick it up just fine. Remember the above is just an example though and you should probably do error checking on the members of form you're trying to access before actually using them. Good luck! -- Jeff "Shippy" Shipman E-Mail: shippy at nmt.edu Computer Science Major ICQ: 1786493 New Mexico Institute of Mining and Technology Homepage: http://www.nmt.edu/~shippy From aleaxit at yahoo.com Wed Apr 4 06:14:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Apr 2001 12:14:09 +0200 Subject: PEP 245 References: Message-ID: <9aes5k021tt@news1.newsguy.com> "Alex Shindich" wrote in message news:mailman.986351706.5602.python-list at python.org... > >Yes: C++ sort-of-confuses "I implement an interface" and "I conveniently > >use [some part of] a class in my own implementation" under the single > >rubric of 'inheritance' -- pretty bad in itself, and the distinction > >between public and private inheritance is a helpful band-aid given this > >confusion. Better, of course, not to have the confusion at all. In > >Python, we also lack the band-aid, so it's _particularly_ important to > >avoid confusing these two concepts -- both important, but quite distinct. > > I personally rarely use inheritance in Python for anything else but to > describe interface-like behavior. For code reuse I prefer containment... But > that is just me... Would be nice if it were just you, but from my observation of Python programmers with C++ backgrounds I notice this conceptually erroneous and pragmatically inferior Python practice, while minoritarian, IS affecting quite a few Pythonistas and hampering their potential (I suspect an Eiffel background might have similar effects, but I have no direct observation to offer here). Nothing wrong with delegation (and/or containment, but the two issues are really separable) as an implementation technique -- e.g., in http://pythoncookbook.activestate.com/pythoncookbook/community/data/98525811 4 I show how to use _automatic_ delegation when inheritance is not available (e.g., from an object that is not of instance-type). But Python inheritance is *STRICTLY* about implementation and *NOTHING* else. Python gives *ABSOLUTELY* no indication that a class A inheriting from another class B will offer anything matching B's "interface" -- not even method signatures: class B: def __init__(self, *data): self.data = data def amethod(self, x): print "B: amethod",self.data,x def another(self): print "B: another",self.data class A(B): def another(self, x, y): print "A: another",self.data,x,y Here, A is inheriting from B strictly for the purpose of getting B's initialization, the 'data' attribute, and "amethod" -- it does NOT intend to offer B's interface, and indeed it overrides the 'another' method with a different and incompatible interface. Sure, the effects of inheritance _could_ be laboriously simulated by containment-and-delegation, but, here, there is no good reason to do so! Raise-to-integer-power can be laboriously simulated by a loop using just multiplication, but WHY should one do so, when the language offers raise-to-power as a built-in operator?! Maybe in the name of some confused "philosophy" that wants to keep the '**' operator for complex-number operations only, or...? Puh-leeze. Python inheritance is essentially about implementation -- a _great_ implementation technique whenever it's appropriate. And it cannot be replaced with containment-and-delegation _everywhere_, quite apart from it being silly to expend work to do so when feasible but not needed. C-&-D, for example, does not handle the crucial case of the design-pattern "Template Method", where a base object implements a higher-level operation in a method that calls upon lower-level operations as methods on 'self', so that derived objects can selectively override the lower-level methods and get the desired higher-level effects. Consider the standard sgmllib module, for example: HOW will you effectively reuse the very good code supplied in the SGMLParser class, in your implementation, except by deriving from it and selectively overriding/adding methods? *THAT* is what it is designed for -- a very good example of properly Pythonic use of inheritance! So, we ARE without language constructs that clearly assert "this object implements this protocol" or explicitly test whether this protocol-implementation has been asserted. It is not sensible to reserve class inheritance for this purpose, as above explained; it is confusing and inappropriate to use inheritance to express BOTH I-implement-this-protocol AND the normal I-use-this-in-my-implementation case, without even the C++ band-aid of private vs public inheritance to help distinguish the two very different cases. The PEPs on interfaces and on (bidirectional) protocol-adaptation address this situation, from two different angles, and both, IMHO, do so rather well. > >rules are respected, COM couldn't care less about HOW this is > >brought about, nor WHEN (COM has *NO* concept of "compile time"). > > OK!!!!!!!!!!!!!!!!! COM was a stupid example!!!!!!!!!!! Yes it only cares > about the memory layout of the virtual tables. And YES, COM components can > be written using anything that is capable of creating C++-compatible virtual (Not quite -- the methods in the almost-virtual-tables of COM need to use calling-convention __stdcall, with 'this' aka 'self' as the first [implicit] argument on the stack, while C++ compilers for Win32 platforms, depending on their brand, normally use __fastcall [arguments in registers] or else __thiscall ['this' aka 'self' in the CX register], for example -- a minor issue, but let's not spread _further_ misinformation about COM, shall we:-). > tables. It is just that I happened to write COM code using C++ on a very > frequent basis (and no, I do not use Wizards...), and for the most part I > implement multiple interfaces using multiple inheritance. Not that it is the > only way of doing it. Definitely not, but it can be quite fast and space-saving when used appropriately. *Strictly* an implementation issue, OF COURSE -- how much memory and machine-instructions will this approach use compared to others, how easy it will be to express in your chosen implementation language, etc. But that's EXACTLY what inheritance is all about, when used appropriately: fast, space-saving, convenient IMPLEMENTATION:-) > And why don't we stop the whole COM nonsense here! I love COM, I write COM > code all the time. And YES, I used it as a bad example. Let it rest already. No, since you keep making misleading observations about COM, I do not think it would be appropriate to leave those observations unanswered -- they might engender confusion and misunderstandings in somebody not fully conversant with this important technology (the existence of XPCOM, an emerging open-source and cross-platform componentization technology inspired from COM, only makes it MORE important to understand precisely what is, and isn't, expressed or implied by each technology). Further, COM provides an excellent counter-example to your main thesis, that interfaces and "compile-time-safety" _need_ to have anything at all to do with each other: COM itself is CRUCIALLY about interfaces, and yet it does NOT define any "compile-time" distinction from "run-time" (although, of course, some, but not all, of the _languages_ used for COM implementation may choose to draw this distinction, not COM itself). A proof-by-existence (and by-technical-success) is always impressive:-). > If you know so much about COM and you feel like arguing, we can find another > forum for that. It still has nothing to do with the original point, what is > the value of adding interface support to Python. It has a LOT to do with it, exactly because it shows how wonderful interfaces are in an environment where "compile-time" is not defined:-). > >There are more things in heaven and earth, Mr Shindich, > >Than are dreamt of in your philosophy. > I sense a lot of anger in you... Do you say that to everybody who quotes Shakespeare, or only to those who quote from his _tragedies_ specifically?-) > >access and usage) will work -- constraints on object implementers > >for the benefit of optimizations in the COM infrastructure (and, > >to a lesser degree of importance, for the benefit of client-side > >coders; > Huh? "lesser degree of importance, for the benefit of client-side coders"? > That is a very one-sided approach to the problem. Interface identity is What's "interface identity"? The semantic constraints are about *object* identity. I suspect we're talking at cross-purposes here, yet I thought I was explaining VERY clearly (at least for somebody fully conversant with COM) the constraints I was talking about. > being used for marshaling, but there is more to it. Not much more! Proxying, as well as marshaling; and some minor idioms enabled on the client-side (ability to hold _any_ one interface to an object, rather than having to use a designated specific one); that is about it. > I see identity > constraints as being useful because they enable the client coders to rely on > the particular semantics associated with the particular version of the > interface. This has nothing to do with object-identity semantics. If client code obtains an interface-pointer via the appropriate factory method IServiceProvider::QueryService (which is *NOT* subject to usual COM object-identity constraints!) rather than via QueryInterface (which *IS* subject to them), it can still "rely" on exactly the SAME _interface_ properties (which may not be much, given how often COM design violates the interface-segregation principle and thus ends up with lots of methods that will raise a not-implemented exception if called -- but, that is another issue). What client code CANNOT do, when it has used QueryService rather than QueryInterface, is rely on *object-identity* semantics -- there is NO guarantee whatsoever that the service-provider has supplied "itself" as the implementer of the requested interface; there are no constraints that ensure interfaces can be requested in any arbitrary order, or that multiple requests for the same interface will all succeed or all fail, etc, etc, if the requests come via QueryService -- while all of these things ARE guaranteed (and thus, constrained) if the requests come via QueryInterface. > I am sorry, at what point in time did I ask for a COM interface rules > lecture? When you make false assertions on Usenet, you implicitly ask for technically correct information on the subject -- since readers who are not able to distinguish falsehood from truth in a specific technical area may well be following the discussion, it IS an important service to them to ensure errors are appropriately pointed out and corrected. > WHAT DOES IT HAVE TO DO WITH THE DISCUSSION ON HANDS? A lot! I should be surprised that you do not see it. PEP 245 hinges interface-compliance on "identity constraints" (albeit, weakened ones wrt COM's, since an instance-object's class membership CAN change in Python), while the (as-yet-not- numbered, I believe) protocol-adaptation PEP has no identity constraints (the wrapper or adapter may be ANY object...). Understanding exactly what object-identity constraints buy you (and what they DON'T) is important to evaluating both PEPs. And COM is one good arena in which to discuss the effects of object-identity semantic constraints, because it's so widespread, well-specified, and well-understood -- of course, similarities and differences between the sets of use-cases of COM and Python need to be also well-understood, and taken into account. And, more generally...: Python is quite interesting from an OO point of view because it decouples object-identity, object-state (the __dict__ of an instance object can be modified), object class-membership (ditto for the __class__), AND to some extent object-behavior (since the object's __dict__ may contain bound-methods that will 'override', so to speak, methods from the __class__). It IS, of course, perfectly appropriate to debate which (if any) of these decoupling-possibilities should not be used at all (e.g., Moshe and others are on record as stating that they strongly believe an object's __class__ should always change if its behavior does -- i.e., they see the class/behavior decoupling as an undesirable language feature, never to be actually _used_), and/or _how_ they should be used if they ever are. The very existence of so many degrees of freedom may easily engender confusion, particularly in people with well-rooted backgrounds in languages and/or object-models that offer nothing comparable. One good way to get richer perspective is to look from SEVERAL points of view, i.e., comparing and contrasting Python's unusually-decoupled Object Model with that of SEVERAL other languages and OM's. This, of course, applies quite as much to proposed _modifications_ of Python's OM, as it does to understanding and optimal usage of said OM as it stands today. > >A _pragmatical_ person, on the other hand, takes into due > >account these limitations _and still documents these kinds > >of constraints_ as formally as feasible given whatever > >technology is at hand. > I use the technological marvel called text editor to document my code. Unfortunately, your documentation, not being subject to any constraint of formality, is quite apt to be as ambiguous and insufficient as (for example) that of the Python library, where it is often unclear (and occasionally incorrect) exactly WHAT protocol is requested from a given object. For example, often a "file-like object" may be mentioned, but it may not be made clear and unambiguous WHAT subset of builtin file-objects needs to be supplied by the object in question (does it need to have suitable .read, .readlines, .write, .writelines, .close, ...? does it need to let these be called with an integer argument and respect the semantics thereof? does it need to have a settable attribute named .softspace? etc, etc). When the author of client-code misinterprets exactly what the library author meant for "file-like object", he or she will risk wastefully expending much work implementing unneeded methods (or uneeded twists on their semantics, e.g., the integer argument to .read &c), or else may get surprised by not-always-crystal-clear exceptions coming up from deep in the bowels of library-code. Having protocols, aka interfaces, as a part of the language, would help a lot with this. The _exact_ characteristics of the protocol required from the object that client-code supplies may then be expressed formally, easily, and concisely, and checked most simply and explicitly. Bliss! (_particularly_ with the protocol-adaptation PEP, but that's a different issue). Sure, sure, it's not _indispensable_ to have the concept of interface, or protocol, in the language -- it can be laboriously kludged up as a series of conventions (but they would have to pervade the standard library to be really useful -- so, there would be no real gain in keeping them out of the language!-). But, once again, this is just like the case of the '**' operator: we COULD kludge something up if it wasn't there, but it's IMHO _much_ better to have it in the language -- clearer, faster, easier. Python is NOT obsessively minimalist: it's a *pragmatist*'s language...:-). > >is used instead of an array, and *THAT* is *OBVIOUSLY* not compile-time > >type-safe since ANY object can be stuffed into it -- it doesn't take > >much Java knowledge to point this out:-). > Wait till Java generics become available... That will be a substantial improvement to Java (I remember experimentally using a Java dialect called 'Pizza', years ago, and loving it; good generics were prominent in it). It's also interesting to reflect on why Python does not NEED generics (or, equivalently, C++ templates) -- and what is needed to keep this happy state of affairs if and when some kind of protocols, or interfaces, are introduced (basically, as long as just about _everything_ remains 'first-class', we're covered:-). > >And whoever thinks that a good design is less valuable when a > dynamically-typed language, rather than a > >statically-typed one, is to be used for the coding, needs far more > >reprogramming than I can supply:-). > When did I say about good design being only needed for statically types > languages? I think you are hallucinating... Did I ever say you think that? Who, exactly, is the one hallucinating? > What I SAID, is that Python has it's own SET OF INTROSPECTION-BASED PATTERNS > that generally allow you to accomplish same things as patterns that are more > INTERFACE BASED! In roughly the same sense as a loop of multiplications allows you to accomplish the same things as an application of the ** operator. If a design HINGES on interfaces, aka protocols, for a good part of its structuring (and I stated that this is a GOOD way to base the design of many software systems -- I did not see you express either agreement or disagreement with this thesis), it's a real pity that Python offers no good way to express that clearly and explicitly in the language itself. Laborious introspection is not a GOOD, clear, simple expression; class inheritance is simply not appropriate, as it is about implementation, not protocol. We WILL get excellent mileage from acknowledging protocols, also known as interfaces, as an explicit part of the language -- quite apart from any _further_ uses they might have in other languages. > IN ALL HONESTY, I WOULD LIKE TO DISCONTINUE THE COM DISCUSSION!!! If you > have something you would like to argue with me about, please mail me > directly. YOU MADE YOUR POINT EXPLAINING THAT COM IS NOT LANGUAGE-SPECIFIC, > AND THAT COMPILE TIME CHECKING IS PROVIDED BY THE USE OF C++ AND NOT COM > TECHNOLOGY ITSELF. BUT PLEASE, STOP COM LECTURES!!!! THIS IS A PYTHON > NEWSGROUP!!!! Please don't "shout". I have no special interest in discussing directly with you (and, indeed, I shouldn't be spending the considerable amount of time this discussion on the newsgroup is taking me -- but, I consider interfaces/protocols by far the best thing that could possibly happen to Python, and I hope that by showing that arguments against their introduction are weakly based and leaking from all sides I may possibly help a little -- helping a certain number of readers understand some crucial issues fully is always a better-leveraged use of time than doing so one-on-one). Yes, this IS a Python group, and the parallels (and lack thereof) between Python and other languages and object models (C++, COM, Java with and without generics, Haskell, etc) play a crucial role in helping some readers to a better understanding, both of things as they stand today, and of the potential effects of any possible modifications. And nobody is well-served if factually incorrect technical assertions are left unchallenged in a public forum: that can only help spread misinformation and confusion. Alex From fdrake at beowolf.digicool.com Fri Apr 13 14:15:38 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Fri, 13 Apr 2001 14:15:38 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010413181538.7BA3F28A06@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Final documentation for Python 2.1c1. From cribeiro at mail.inet.com.br Sat Apr 14 12:37:54 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 14 Apr 2001 13:37:54 -0300 Subject: Stepping backwards in for loop? In-Reply-To: Message-ID: <5.0.2.1.0.20010414133503.022e1ec0@mail.inet.com.br> At 14:10 14/04/01 +0000, Gustaf Liljegren wrote: >Can't figure out how to step backwards, character by character in a string. >I was looking for a loop countruct with a counter to handle this, but the >for loop in Python doesn't let me step backwards. What is the alternative? >>> a = 'abcde' >>> b = list(a) >>> b.reverse() >>> b ['e', 'd', 'c', 'b', 'a'] It would be a *lot* easier if strings had a reverse method, or if the reverse() methods returned the reversed string. However, similarly to sort(), the Python-way-of-doing-things must have some good reason for reverse() to behave this way (as a inplace operation on the list). Carlos Ribeiro From gabriel_ambuehl at buz.ch Sun Apr 1 14:09:30 2001 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Sun, 1 Apr 2001 20:09:30 +0200 Subject: Python, VB, Tkinter, and the future of GUI programming & CP4E In-Reply-To: <3AC60AF8.69618901@earthlink.net> References: <3AC60AF8.69618901@earthlink.net> Message-ID: <68720425877.20010401200930@buz.ch> -----BEGIN PGP SIGNED MESSAGE----- Hello Ron, Sunday, April 01, 2001, 7:38:51 PM, you wrote: > Why couldn't someone or some group create a higher level visual GUIi > front-end to Tkinter (or any good Tkinter alternative)? For instance, in > my preliminary study of Tkinter, I see that there are known, easily > repeatable blocks of code useful for creating many of the most useful > constructs. How hard would it be to put all of these blocks of code into > a visual, poke yoke (idiot proof) visual gui design front-end program > for Tkinter/Python? You want to have a look at http://boa-constructor.sourceforge.net which is quite close to some earlier version of Delphi, UI wise. > I am trying out Active States Komodo and it is really good, I love it; > it is a great IDE. ACK. If it only weren't that horribly sluggish. Best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.0.2i iQEVAwUBOsdgzsZa2WpymlDxAQEPqgf7BByAe9VaBE8gAZrD/w89Vuj2cYagPQ+/ 5zPFDNHcxq1SJOPY7Ft8kQjye254pPsUB3nrovMsPLJW/NprP2P2k49XXGb8mm34 akYQxTjGpg7qG3rQb2jxrMshUm5yDNazlzFGaEShFOrCjEvsJRJjHQDAb1YetFsi Xm1j+ZMO8JRfmIL1gNmwiX3zv9lgX1IUzNANCe/NicWBfXyGfMN63OOaBw1XjMUD BRV9fab/nfuwvnhysfYDA3Gg+W5C6wGRuXVvOVCfDfTX34a1Q7gcLyor5NSDS9G5 IFE49X/FUNDbwWQgz9+ur75haGVoO4FeI9h6eZiGDEfMB8suXki98A== =aZ/Y -----END PGP SIGNATURE----- From tuthach at aix11.unm.edu Wed Apr 18 18:50:04 2001 From: tuthach at aix11.unm.edu (Tu-Thach) Date: 18 Apr 2001 22:50:04 GMT Subject: Python extension package namespace References: <9bg1j4$s8k$1@lynx.unm.edu> Message-ID: <9bl5ms$dls$1@lynx.unm.edu> Never mind, I got it fixed. This is the problem: somehow when I put it under a subdirectory, called "tmp", and a also include the __init__.py file in this directory, the Python interpreter complains that Riff2 entry not found! I ended up deleting the directory and re-create it and it works! JFYI. Tu-Thach Tu-Thach (tuthach at aix09.unm.edu) wrote: : I have written a simple test extension module for Python and called it : testxyz. What I'd like to know is how can I make the module so that when : I call it from Python I can use : from test.testxyz import * : instead of using : from testxyz import * : It's is pretty much like putting python code into packages. I've tried : putting it under a sub directory, but it doesn't work. Anybody has any : suggestions? : Thanks, : Tu-Thach From sholden at holdenweb.com Fri Apr 13 13:50:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Apr 2001 13:50:43 -0400 Subject: why does activestate (win98) python not support globbing References: <9b4of1$j16$1@bmerhc5e.ca.nortel.com> Message-ID: <%_GB6.168016$m04.6637795@e420r-atl1.usenetserver.com> "Robert Amesz" ... > Steve Holden wrote: [ ... ] > > >Seems sensible since it's not the platform default for other command > >line programs? Nasty to have to glob wildcards, but consistent with > >the DOS heritage. > > Why nasty? This is one instance were I think UNIX has got it wrong. > It's much better to leave commandline parameters alone than to try and > interpret them in a particular way. Explicit is better than implicit. > Whichever way you write your programs you lose unless you specifically test the environment. If you glob by default then you end up globbing wildcard names which Unix users escaped because they wanted to refer to real files with wildcard characters in their names. But DOS/Windows works OK. If you *don't* glob by default then Unix works OK. But DOS/Windows passes you unglobbed names, expecting you to glob them, so you don't find the files. Perhaps I should have said "ugly"? The environments aren't consistent but-when-did-vendors-try-to-be-consistent-ly y'rs - [Ss][Tt][Ee][Vv][Ee] From nessus at mit.edu Thu Apr 19 02:31:57 2001 From: nessus at mit.edu (Douglas Alan) Date: 19 Apr 2001 02:31:57 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9blhdb$619$1@nntp9.atl.mindspring.net> Message-ID: Courageous writes: > > @let x = 3 > >where "@" means that a macro invocation is coming up. > Hrm. Don't think so. Any hypothetical Python-native macro utility > should be very tightly integrated such that it allows you to create > your own special-purpose dialect of the language on a per-project > basis if need be. One of the appeals of utilities like this is to > map domain-specific capabilities directly onto a computer > programming language. Tis one of the lasting contributions of Lisp > to the programming community, it is. I'm not sure I see how having macro invocations stand out *slightly* violates any of this. I've never quite liked the fact that in Lisp you may have trouble telling a procedure call from a macro invocation, considering that the semantics can be quite different. It's nice for macros that make their way into every day use, like "loop", since you'll recognize the name instantly. But it's not quite as nice when the macro is a bit more obscure. On the other hand, if "loop" had been called "@loop", instead, I wouldn't have lost any sleep over the inconvenience of having to type that "@". Perhaps in Python you could get away without having any special macro invoking syntax, but since I know nothing about how the Python parser is implemented, I have no idea how easy or hard that might be. I suspect you *could* get away without any special macro invoking syntax due to the way that Python is rather line-oriented. I.e., if a line is not a continuation line, and the second token on the line isn't ".", "=", "(", "+=", "+", etc., and the first token isn't a keyword, then look the first token up in the macro table. I wouldn't bet my life on this being workable without doing more research though. |>oug From michael at stroeder.com Wed Apr 4 03:55:31 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 04 Apr 2001 09:55:31 +0200 Subject: Apache insists on downloading instead of running my Python cgi-script... References: <5bAy6.14565$Bc2.834676@juliett.dax.net> Message-ID: <3ACAD373.DA39B605@stroeder.com> Dag Sunde wrote: > > I've had this behavior before, but can't for my life > remember what I forgot to configure... See the fine Apache docs! ScriptAlias would be a possibility. Ciao, Michael. From dougfort at downright.com Thu Apr 12 14:01:44 2001 From: dougfort at downright.com (Doug Fort) Date: Thu, 12 Apr 2001 14:01:44 -0400 Subject: How to get socket errors from 'connect'? References: <3AD5E720.F16E86AB@raqia.com> Message-ID: <3AD5ED88.F5A1C9FB@downright.com> > Try catching 'socket.error'. It includes a tuple of the form (errocode, explanation) > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > try: > val=sock.connect((url, port)) except socket.error, errortuple: print "socket error %s %s" % errortuple ..... > > except Exception: > print 'no luck connecting' > sock.close() > del sock > print val > sys.exit() > -- Doug Fort (dougfort at downright.com) Senior Meat Manager Downright Software LLC http://www.dougfort.net From zzizz_ at notmail.com Sun Apr 15 23:33:08 2001 From: zzizz_ at notmail.com (zzzzz) Date: Mon, 16 Apr 2001 13:33:08 +1000 Subject: Polygon Boolean Operations Message-ID: <0upkdt09u0v50rkhbdv5ecl6ml0jac260t@4ax.com> Has anyone ported Polygon boolean operations into Python? z. From zzizz_ at notmail.com Thu Apr 12 01:45:00 2001 From: zzizz_ at notmail.com (zzzzz) Date: Thu, 12 Apr 2001 15:45:00 +1000 Subject: Python Programming Ettiquette Message-ID: If I want to change a variable value from within a function I believe I have two options: a) Directly modify the parameter: x=[1,2,3] def add4tolist(inputlist): inputlist.append(4) add4tolist(x) x [1,2,3,4] b) Return the result, keeping the passed parameter untouched: x=[1,2,3] def add4tolist(inputlist): return (inputlist[:]).append(4) x=add4tolist(x) x [1,2,3,4] a) is simpler, however, it only works on immutable type b) is more general, however, you still have to be careful about accidently modifying mutable parameters. Is there any accepted programming etiquette on how to best go about this? Regards, zzzzz. --------------------- From ps54713 at swt.edu Wed Apr 25 12:56:00 2001 From: ps54713 at swt.edu (ps54713) Date: Wed, 25 Apr 2001 11:56:00 -0500 Subject: Bind Return Key Message-ID: <3AE701A0.4A03714E@swt.edu> HI!! I have a log on page where the user enters the username and password. It has an "OK" button which will allow the user to login once he clicks on it. But i also need to allow the user to use the return key from the keyboard instead of hitting the "OK" button Can anybody suggest how to bind the return key. I really appreciate it. Praveen From tanzer at swing.co.at Mon Apr 30 04:11:59 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 30 Apr 2001 10:11:59 +0200 Subject: Unbound methods of types In-Reply-To: Your message of "29 Apr 2001 18:42:19 PDT." Message-ID: Ben Hutchings wrote: > Let me try to explain myself more clearly. If strings were instances > of a class String, I could say String.foo to get the unbound string > method foo; as it is, there happens to be a string module so I can say > string.foo to get a function that works as if it were the unbound > string method (except where foo = join). For other sequences such as > lists, there is no such module to help. To pick a better example, I > can't say: > > map(types.DictType.keys, [{'a':1,'b':2,'c':3}, {'d':4,'e':5,'f':6}]) > > and get back something like: > > [['b', 'c', 'a'], ['f', 'd', 'e']] Doing this is a bad idea. If you map an unbound method, any polymorphism is lost (e.g., a UserDict instance in the list passed to map would not work). -- 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 Peek at LVCM.comNOSPAM Mon Apr 16 09:55:51 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Mon, 16 Apr 2001 06:55:51 -0700 Subject: do...until wisdom needed... References: <9bdv6f$quq$1@news.udel.edu> <9be82a$eq7$1@slb6.atl.mindspring.net> Message-ID: OK-- I will repeat a private email I sent to Paul Foley: I am writing my own language based on Python for deeply embedded systems. I am not trying to change the Python language. I would like all of the traditional looping constructs in my new language, and so was trying to get your opinion as to the best way to implement a "do...until" construct. Yes, I know that the "while" construct CAN be used, but it is not the "syntactic candy" that we have all come to know and love. I also plan on adding a logical XOR operator, a logical shift right, and a few other things such as absolute static typing, constants, constant pointers (for directing absolute I/O in memory mapped I/O systems), etc. etc. So, now that you know that I really am asking what I said I was asking, how about answering my original question? --Thanks "Andrew Dalke" wrote in message news:9be82a$eq7$1 at slb6.atl.mindspring.net... > Ken Peek wrote: > >Thank you for the history lesson. My question still stands-- I > >don't care if it will be implemented or not. I am looking for > >what would be the correct "Pythonic" construct if it WERE implemented... > > >"Terry Reedy" wrote: > >> This has been discussed ad nauseum for years with no agreement. If and > >> when maillist or newsgroup archives are available, you can review at your > >> leisure. > > But that's Terry's point. No one has decided on a "Pythonic" > construct, and there have been arguments on that topic. Nor > did he mention anything about implementation. > > I just did a www.python.org/search for "do while until". The > first hit was to: > http://groups.google.com/groups?q=do+while+until&hl=en&lr=&group=comp.lang.p > ython.*&safe=off&rnum=1&seld=943960637&ic=1 > and since I don't know if that link will really work, the thread > is named "why no "do : until"? and took place last December. > (There are older threads, but not indexed by Google.) > > The consensus seems to be that there is no Pythonic syntax for > a do/until construct. It boils down to indentation. Both your > suggestions were proposed and it was decided that they didn't > make sufficient sense: > > do: > spam > until cond > > was found to be nothing more than an alias for > > while 1: > spam > if not cond: break > > and not worth introducing new syntax. > > The other proposal is: > > do: > spam > until cond > > but this "does not fit a pythonic pattern for statements" > (Martijn Faassen). Reread the full thread for details. > > So why didn't you believe that this exact history you were > looking for already existed in the easily searchable archives, > even after Terry pointed it out? > > Andrew > dalke at acm.org > > > > > > > From neilh at scintilla.org Thu Apr 5 08:42:40 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 05 Apr 2001 12:42:40 GMT Subject: driving Internet Explorer with Python References: <9ahkf602hu2@news2.newsguy.com> Message-ID: <4LZy6.6012$Xi1.46408@news-server.bigpond.net.au> Alex Martelli: > "Neil Hodgson" wrote in message > [snip] > > Scripting IE is a /huge/ topic. I had a look and couldn't find a way to > > print to a particular device. > > I think you just need to win32print.SetDefaultPrinter('whatever'), > then use the .ExecWB method with the don't-prompt-user option (I > have not tested this). Looking up SetDefaultPrinter in MSDN gives two areas of information, one on the wshNetwork object and one on munging WIN.INI. It looks like the win32print module is a front end to wshNetwork or something cleverer has been done underneath. If it is the wshNetwork object then MSDN says the argument is the 'Remote printer name to set as default, such as "\\Server\Printer1". Note that strPrinterName cannot be a local name such as "LPT1:". ' Neil From paulp at ActiveState.com Fri Apr 20 05:59:33 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 20 Apr 2001 02:59:33 -0700 Subject: ActiveState PPM probs References: Message-ID: <3AE00885.DD0F3A58@ActiveState.com> Tim H wrote: > > ... > > Anyway just installed y'alls (ActiveState) Python 2.1 on Win98 and fired up > ppm and did install PIL. There is a PIL directory with only a readme and a > scripts folder. I know there should be way more than that in there. > Importing PIL fails (there is a PIL.pth) no matter how its spelled. > 'ppm>verify pil' indicates PIL is up to date. You hit a transient problem with our network or mirrors. :( I've fixed it now. Please do a: ppm> verify -uf pil to upgrade your PIL. > Also did a full search and > some of the available packages are not up to date, specifically py2exe is at > 0.2.5 I believe. Until Python has an equivalent for CPAN, the module updating procedure must be manual. So the modules get a little out of date while we are concentrating on a new Python release. We'll work on updating them soon. Yes, PPM is fairly new. As you can see we are still working out a kink or two in the distribution system, so we haven't made too big of a noise about it yet. When the time comes, enthusiastic word of mouth like yours will spread the word. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From danyelf at severus-alexander.ics.uci.edu Fri Apr 20 15:54:31 2001 From: danyelf at severus-alexander.ics.uci.edu (Danyel Fisher) Date: 20 Apr 2001 12:54:31 -0700 Subject: rexec, threads, and ugly crashes References: Message-ID: <9bq45n$fg5@severus-alexander.ics.uci.edu> mysteries within mysteries! I started stripping away code to find the absolute minimum that displays this phenomenon, and wound up with 35 lines of joy. For me, if I run this, then open a telnet session, the code will crash. It won't actually core dump, but it will complain that the interpreter is not initialized. If I change one line--if I set the server to "serve_forever"--everything works fine. Now, all that serve_forever DOES is repeatedly call "handle_request" This is nonintuitive behvior, to me. What am I missing? Danyel --- import SocketServer class SMTPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): def server_bind(self): """ Connects to a server. Pulled off of some web site's info on how to ensure that socket can be (re)used. """ import socket self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) SocketServer.TCPServer.server_bind(self) class SMTPHandler(SocketServer.StreamRequestHandler): """ """ exec_env = None def handle(self): print "ok" import rexec if self.exec_env is None: print "ABOUT TO START REXEC INIT" exec_env = rexec.RExec() print "FINSIHED REXEC INTI" # MAIN MODULE if __name__=='__main__': # Create an instance of our server class port = 1999 import socket server=SMTPServer(('', port), SMTPHandler) print "Server initted on port",port server.handle_request() # server.serve_forever() print ">>Stopped." From sandipan at vsnl.com Sat Apr 7 10:36:06 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Sat, 7 Apr 2001 20:06:06 +0530 Subject: Fw: amkCrypto Install Message-ID: <003401c0bf70$1c38c9e0$020000c3@node02> An update - I found out about the install command and did ./setup.py install 1 warning: warning: build_ext: old-style (ext_name, build_info) tuple found in ext_modules for extension 'Crypto.mxCrypto'-- please convert to Extension instance However, ./test.py still doesnt work. Same error. import: Unable to connect to X server () [No such file or directory]. ./test.py: sys.path: command not found ./test.py: args: command not found ./test.py: quiet: command not found ./test.py: syntax error near unexpected token `args.remove('' ./test.py: ./test.py: line 10: `if quiet: args.remove('--quiet')' Does it need to be run in XWindows ? (X server) Regards, Sandipan ----- Original Message ----- From: "Sandipan Gangopadhyay" To: Sent: Saturday, April 07, 2001 7:54 PM Subject: amkCrypto Install > 1. I received asn1.py from Jeremy. > 2. To make that work, I downloaded pisces-1_0a1.tgz > 3. To install that, I downloaded and installed Distutils-1_0_1. No problems > here (I used the faint hearted rpm -ivh route !) > 4. I already have openssl-0.9.4 installed and working fine. > > 5. Then, I also downloaded AMK's amkCrypto-0_1_2.tgz > This contains both AMK's Crypto and the changed form of MAL's mxCrypto. > And it reports being Distutils ready. > > However, I cant find out how to install it. > > ./test.py fails with: > import: Unable to connect to X server () [No such file or directory]. > ./test.py: sys.path: command not found > ./test.py: args: command not found > ./test.py: quiet: command not found > ./test.py: syntax error near unexpected token `args.remove('' > ./test.py: ./test.py: line 10: `if quiet: args.remove('--quiet')' > > ./setup.py fails with: > usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] > or: setup.py --help [cmd1 cmd2 ...] > or: setup.py --help-commands > or: setup.py cmd --help > error: no commands supplied > > I dont know what command to feed it. > > I looked here for instructions, but no luck- > http://www.amk.ca/python/code/crypto.html > amkCrypto-0.1.2/Doc/mxCrypto.html > amkCrypto-0.1.2/README > http://www.amk.ca/python/writing/pycrypt/ > > Any hints to help me ? > > I am on RH-6.1 and RH6.2 > > Regards, > > Sandipan > From shaleh at valinux.com Wed Apr 18 18:32:03 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 18 Apr 2001 15:32:03 -0700 (PDT) Subject: queston with glob!! In-Reply-To: Message-ID: On 18-Apr-2001 Tsang, Edward1 wrote: > Thanks for your pointer, but after reading the doc. I do not undertstand > what it means .. > def func1(): > import os.path, glob > > os.path.walk(currentDir,self.buildFileList,fileList) > > fileList = glob.glob(currentDir+os.sep+'*') > return fileList > > def func2(): > listDir = os.listdir('.') > > fileList = [] > fileList = self.buildFileList(listDir,fileList) > > Then I should expect fileList containing all the files with the full path > names ... > But I have got the following error: > one of python's greatest features is that you can do everything in the interactive interpreter. import os def printer(arg, dirname, names): for name in names: print os.path.join(dirname, name) os.path.walk('/tmp', printer, None) # None is 'arg' This will print the full name of every file in /tmp on my system: /tmp/.X11-unix /tmp/ssh-XXwRJMRM /tmp/.X0-lock /tmp/xfexec.547 /tmp/.ICE-unix /tmp/shaleh /tmp/xmms_shaleh.0 /tmp/texKgZaew /tmp/root /tmp/xfexec.598 /tmp/twirl /tmp/mp3_list /tmp/ksocket-shoon /tmp/xfexec.660 /tmp/quit.blend /tmp/texsNqTzm /tmp/zman2i75HO /tmp/xfexec.952 /tmp/jzip3ADB268412554AC /tmp/jzip3ADB271B15654AC /tmp/jzip3ADB279616E54AC /tmp/jzip3ADB27B017254AC /tmp/jzip3ADB29551A654AC /tmp/fileWnhbnN /tmp/file0oCaTs /tmp/.X11-unix/X0 /tmp/ssh-XXwRJMRM/agent.454 From barry at digicool.com Wed Apr 4 11:44:02 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 4 Apr 2001 11:44:02 -0400 Subject: cgi security References: <3ACAD8B7.BC513B68@stroeder.com> <607mctca04ihuq54gg3086pithjee1169j@4ax.com> Message-ID: <15051.16706.10992.96818@anthem.wooz.org> >>>>> "SK" == Sheila King writes: SK> More secure, I can believe. Less system overhead? That is SK> exactly the opposite information from what I got, when I asked SK> a question here a few weeks back about "efficiency in sending SK> email". I specifically asked in that thread, why someone else SK> had posted back in Feb. that using sendmail was the SK> "preferred" way of sending mail, rather than using the smtp SK> module. By default in Mailman, we use smtplib to connect to a local MTA and optimize that hand-off, but let the MTA manage delivery as best it can. This is by far the most efficient way to do it, and I believe most secure, but it does require you to fine-tune your MTA system. The rationale goes as follows: MTAs such as sendmail, qmail, Postfix, Exim, etc. are far better at managing their delivery queues, resends, system resources, etc. than anything we'd be able to do in Python. So we use Python for what its good at, and let the MTAs do what they're good at. Some MTAs are more equal than others though. I think the Mailman users community would say that qmail, Postfix, or Exim are generally better performers than sendmail, and among the former three, the preference comes down to other issues such as ease of configurability, "automatic" handling of mailing lists, etc. If you're really concerned with blasting tons of email through your system, there's lots you can do on the MTA, server, disk throughput side that will a great impact on performance. For example, if you're using smtplib to hand-off messages to a local MTA for final delivery, you want to be sure that the MTA does not try to do dns resolution of recipient domain names when accepting messages from localhost. SK> And I'd have to say that my experimenting confirms this. It is SK> MUCH faster to connect to sendmail/qmail/whatever MTA, than to SK> wait for the smtpmodule to open a connection. I'd absolutely agree, in general, and with some of the caveats above. SK> And, in the case that someone uses the smtplib option in my SK> script, rather than the sendmail option, my script has to go SK> to a lot more trouble to set the envelope sender and SK> recipient, the date field, the message-ID and so forth SK> myself. There is a definite impact on the script performance. Yep. -Barry From tim.one at home.com Sat Apr 21 19:51:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 21 Apr 2001 19:51:13 -0400 Subject: [Python-Dev] Class Methods In-Reply-To: <9brq3j$app53$1@ID-59885.news.dfncis.de> Message-ID: [Thomas Heller] > ... > There are (even in the standard python library) usage > patterns going like this: > > class X: > _inited = 0 > def __init__(self, ...): > if not _inited: > > .... > > This is really not instance but class initialization, > and it is deferred until the first instance has been > created. What if someone need the (calculated) class > attributes before this? I *suspect* you're reading the code incorrectly, but hard to say since that snippet doesn't make sense. If the actual test looks like if not X._inited: then, yes, maybe so. But if it looks like if not self._inited: then it's probably aiming at something quite different from class attribute fiddling. Whenever you see class X: attr = whatever ... def f(self): ... ... self.attr ... it's *most likely* the case that the class author is *exploiting* that self.attr will resolve to X.attr if self doesn't have its own attr. This is a memory-saving trick for attrs that *normally* have the same value across most instances. By letting self.attr defer to X.attr, the instance doesn't have to burn space in its own dict to record attr's value, for so long as the instance is happy to use the common value. *Binding* to self.attr gives the instance its own value for attr when the common value is not acceptable, and then a later reference to self.attr picks that up instead of the class value. Anyway, please point to some specific code in the std library that you think is doing class-attr fiddling of the kind you're talking about. Offhand I don't recall any (but know lots of places that use the trick I just described). From aleaxit at yahoo.com Fri Apr 6 04:45:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Apr 2001 10:45:00 +0200 Subject: Changing global variables in tkinter/pmw callback References: <3ACC21BF.14E708B7@mek.dtu.dk> <3ACC4EB1.376225AF@mek.dtu.dk> <3s0z6.5511$4N4.1170119@newsc.telia.net> <3ACD5D99.47AED2BE@mek.dtu.dk> Message-ID: <9ajvm90253c@news2.newsguy.com> "Brian Elmegaard" wrote in message news:3ACD5D99.47AED2BE at mek.dtu.dk... [snip] > > ("normal variables", like integers, floats, strings, belong to > > this category. if you want a new integer/float/string value, > > you have to create a new object) > > I think it's more the methodology in bindings that confused me, and then > lambdas also. You never HAVE to use a lambda: it's supposed to be a convenience, but, whenever you can use a lambda, you can just as well use a (named) local function object if that seems clearer to you (and often it WILL be clearer to most readers). > > (when you type "s[0] = 10", you ask whatever "s" points to > > to replace item zero with a new value. in your case, you ask > > the list "s" to modify it's first item. anyone else referring to > > the same list object will see this change) > > And someone are. Could the same be done with the 10 in s=10? If not then > why? Numbers of all kinds are among the _immutable_ objects (like tuples and strings). This is VERY much what you want, believe me... the only programming system I ever heard about which let numbers change value (by accident!-) was a Fortran-II compiler that, when you called a procedure: CALL FOO(3) would just pass the address of the memory word where it had stored the number 3. If FOO internally did (e.g.) N=N+1 on its integer argument N... then 3 now had a value of four!!! If some place after the call you had for example a loop such as DO 10, I=1,3 then the loop's body would 'of course' now be executed four times, for example. We _don't_ really want this, do we? Numbers *had better* be completely immutable objects -- programming becomes a funny game indeed if the actual values of numbers start changing from under our feet. It's unclear, on the other hand, if there NEED to be 'mutable' objects at all; Haskell, Erlang, and other functional programming languages, seem to do pretty well by only having immutable data. Still, that is a BIG conceptual break from the programming paradigms we're most familiar with (procedural, relational, object-oriented), which all hinge on having SOME mutable data (and some re-bindable references, too, in a sense). So, Python hits a pragmatical compromise: some of the key low-level objects (numbers, strings, tuples) are immutable; most kinds of objects at a somewhat higher 'structuring' level (lists, dictionaries, instances) are mutable. And it turns out that just about ALL references in Python are re-bindable -- items in tuples being the signal exception. Alex From wtanksle at dolphin.openprojects.net Fri Apr 20 22:11:25 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 21 Apr 2001 02:11:25 GMT Subject: Class Methods References: Message-ID: On Fri, 20 Apr 2001 11:34:08 -0600, Rainer Deyke wrote: >I consider classes/instances a special case of namespaces: one which allows >(multiple) instantiation and inheritance. Sounds reasonable. BTW, have you checked out the way Sather handles importation versus inheritance? >operator overloading? Don't name your function '__add__' then."). The >resulting programming language might look something like this: >namespace A: # Create a named unique object > pass >namespace B(A): # Similar to 'from ... import', but done through linking > # instead of copying >class C(A): # 'class' = namespace that requires/supports instantiation > # class inherits from namespace => functions in namespace > # are treated as "static" functions > pass >namespace D(C()): # namespace inherits from instance of class > pass Mine would look similar, except that in addition to Python's inheritance operator namespace C(A): pass I'd also provide a Sather interface operator and a Sather import operator: namespace C: from import * (Using a Sather interface AND a Sather from...import* adds up to the same thing as using a Python inheretance; the difference is when you use specific Sather imports to get exactly what you want.) >Rainer Deyke (root at rainerdeyke.com) -- -William "Billy" Tanksley From dmaas at nospam.dcine.com Fri Apr 20 22:34:05 2001 From: dmaas at nospam.dcine.com (Dan Maas) Date: Sat, 21 Apr 2001 02:34:05 GMT Subject: Help with Popen3 objects and ssh... Python 2.x References: Message-ID: >> I need to run and get the result of a command on a remote server >> through an ssh client. >> I can't find the way to send the password to the server. But I'm always >> asked interactively for the password through the console despite I >> write the "sh.tochild.write(passwd)" I posted the solution to this group some weeks ago: http://groups.google.com/groups?q=python+ssh+maas&hl=en&lr=&safe=off&rnum=1&seld=915710696&ic=1 Regards, Dan From clee at gnwy100.wuh.wustl.edu Thu Apr 12 10:46:46 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 12 Apr 2001 09:46:46 -0500 Subject: ANN: plpython - python integration with postgresql RDBMS Message-ID: <7u7l0quqeh.fsf_-_@gnwy100.wuh.wustl.edu> FYI: Andrew Bosma is working on integrating python with postgresql in order to allow the use of python as a built-in procedural language for database functions as you would with PL/pgSQL. It's a work-in-progress but it looks pretty cool and he's looking for feedback. Source is available from http://users.ids.net/~bosma/. I would say these are "developer" releases: compilation is a little tricky and may require that you build postgresql 7.1RC1 yourself. -chris To elaborate, plpython allows you to embed python into functions using the form: CREATE FUNCTION (..) RETURNS AS LANGUAGE 'plpython' For example, if you have a database which needs to maintain hashes of email messages you might create a function like this: CREATE FUNCTION handle_digest(text) RETURNS text AS 'import sha digest = sha.new(args[0]) return digest.hexdigest()' LANGUAGE 'plpython'; You could then create a trigger that called this function to update the hash using the CREATE TRIGGER. From paul.magwene at yale.edu Sat Apr 7 13:06:23 2001 From: paul.magwene at yale.edu (Paul Magwene) Date: Sat, 7 Apr 2001 13:06:23 -0400 Subject: Komodo: First Impressions Message-ID: <9anhhr$mka$1@news.ycc.yale.edu> I downloaded, installed, and played around with Komodo 1.0 for Windows this morning. The following are my first impressions of this beast: 1. It's awfully large! the Komodo folder on my machine weighs in at around 63 MB (the installer told me I'd need ~140 MB - I don't know if that was just overestimation or a bunch of other files got dumped in Windows root partitions). 2. The IDE is well layed out, attractive to the eyes, and easy to use. It appears to use Scintilla (or something that looks/works just like it), so it's got nice folding features, etc. Overall it provides a very appealing "look and feel." 3. Using the debugger is quite intuitive and it even plays nice with Tkinter programs (but see speed issues below). 3. The nice "look and feel" alluded to above seems to come at a price - this thing is dog-slow! I'm running Komodo on a Dual Pentium II 300 machine with 384 MB of RAM (NT4/sp6a, yadda yadda....), and no other processes running. Startup alone seems to take at least 10 secs. Once inside the editor, input speed, folding, etc. seems OK. However, there are still noticable (and annoying) delays when opening files, calling the help system, and debugging (which can feel glacial at times). My guess is that the speed is a reflection of the underling Mozilla engine, but whatever it's cause I think it will be the biggest impediment to wide-spread adoption of Komodo (at least until which time this issue is resolved). Komodo seems thoughtfully designed, and is very promising, but I can't imagine using it on a regular basis until it gets an order of magnitude faster. --Paul Magwene From nas at python.ca Thu Apr 5 09:31:57 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 5 Apr 2001 06:31:57 -0700 Subject: A couple garbage collector questions In-Reply-To: ; from tim.one@home.com on Thu, Apr 05, 2001 at 01:47:28AM -0400 References: <20010404194644.A15906@glacier.fnational.com> Message-ID: <20010405063157.A16493@glacier.fnational.com> Tim Peters wrote: > [Neil Schemenauer] > > To be fair I re-ran pystone with the freelists disabled for the > > referencing counting interpreter (source from CVS): > > That's a false fairness, though. Sure. I was trying to be a little more fair in the sense that Python has been tuned for reference counting and not for mark and sweep GC. I'm sure there are similar tricks that can be used for the Boehm GC. Neil From kca17 at dial.pipex.com Tue Apr 24 17:46:51 2001 From: kca17 at dial.pipex.com (Eddie and Babs) Date: Tue, 24 Apr 2001 22:46:51 +0100 Subject: Unique ID numbers for compile/runtime error messages? Message-ID: <3ae5f5cf$0$12244$cc9e4d1f@news.dial.pipex.com> No, you misunderstand me! The implementers don't have to document anything at all. They just have to add a unique number to the end of every error message string that the interpreter already generates as standard. Presumably, if the interpreter spews out "TypeError: call of non-function" then the message "call of non-function" is retrieved from the same string constant for each possible compilation scenario where this TypeError can occur (so if you change it to: "call of non-function (#123)" then the "123" will be displayed whenever this string constant is referenced). If the message doesn't come from the same string constant each time then perhaps it would be a good idea if it did. I apologise if there is a good reason NOT to do this, but I don't see one. It is the USER'S task to add whatever additional notes he/she needs to document the error. The number merely allows the user to order notes more effectively. This does mean that all error message strings that exist in the standard Python interpreter have to be enumerated, but there is certainly no need to think of and document every possible "meaning" of each error in advance (like knowing that some people are tripped up by case-sensitivity or whatever; obviously there is no way the implementors could know all such contexts). I should add that I am aware that users can supply their own message strings to exceptions that they raise in their own code. Obviously there is no way that all of these can have their own ID number. I am just talking about the commonly-occurring exceptions that can be raised by the interpreter. Things like:- TypeError: call of non-function NameError: There is no variable named 'zoink' IndexError: string index out of range KeyError: twarg (...and of course I am not saying that "There is no variable named 'zoink'" should have one error number and "There is no variable named 'ftosk'" should have another and so on for each variable name!). needs-only-one-volunteer-if-concept-is-understood-ly y'rs, The terminally misunderstood, &. ---------- > Sort of like my favorite PL/1 F-level compiler message: > > IEB042I: Impossible happened > > (I've probably not used the actual number) When you looked up IEB042I in the > IBM OS/360 Handbook of Error Messages (such a document existed, but was > probably called something even more turgid), it effectively told you this > was a compiler error which the designers wanted to know about. I remember > happily a visit from the IBM Systems Engineer (or was it the Customer > Engineer?) at which we produced about seventeen programs which had elicited > this message during the previous three months. > > Of course the real problem is that these error messages are simply responses > to exceptions. Assuming the real exception is correclty reported, (such as > TypeError above) this still leaves a good deal of leeway in explaining the > problem. Do we expect the implementers to document *every* possible reason > why a particular syntax error exception might be raised during compilation? > > Or do you want a Python Handbook of Error Messages? > > needs-an-army-of-volunteers-ly y'rs - stevE > From mthorsen at siving.hia.no Sun Apr 22 08:12:51 2001 From: mthorsen at siving.hia.no (Morten Thorsen) Date: Sun, 22 Apr 2001 14:12:51 +0200 Subject: Need help on configuring IIS to run jython-scripts (CGI) Message-ID: <3AE2CAC3.1631C334@siving.hia.no> Hi! I have problems running python-scripts on the jython interpreter when accessing them through Microsoft Internet Information Service and CGI (windows 2000). Can anybody please help me ? Here's some information: * Python-scripts works fine on the jython interpreter when started from the dos-shell, so jython is probably set up right * I've managed to configure IIS/CGI to understand and run perl-scripts (with perl.exe as the interpreter), so I guess I know how to map extensions to applications in IIS * In IIS I mapped .py files to hopefully be run under jython like this: c:\progra~1\jython\jython.bat %s %s (this is equivalent to what I did when I mapped perl-files...except for the application ofcourse) * The browser gives me some information saying that I'm not allowed to run the application. Since the python-scripts are located in the same directory as the working perl-scripts, My guess is that I (the web-user) am not allowed to feed jython (jython.bat), but I really don't have a clue...and at least not how to fix the problem If anybody have any solutions/recepies on how to fix this, I'll be very pleased. Thanks for your time! Best regards Morten Thorsen mthorsen at siving.hia.no From nessus at mit.edu Mon Apr 9 13:22:01 2001 From: nessus at mit.edu (Douglas Alan) Date: 09 Apr 2001 13:22:01 -0400 Subject: other python ideas References: Message-ID: Steve Purcell writes: > And equally, no programming language has ever been (or will ever be) > perfected, so it's not to anyone's benefit to pretend that such > perfection is possible! But many, many languages have been improved over time. Sometimes the newer version of the language is even more true to the language's original spirit than the original language itself. E.g., Lisp -> Scheme. > In my experience, extra language features tend to mean extra magic, > and I'm usually too dumb to understand all that voodoo stuff. That's > why I ended up using Python more than any other language... That's why language design is an art, and every feature needs to be considered very carefully. That's why in trade for the feature I want, I suggest removing another feature in trade. Of course, this makes it a proposal only to be really considered for a new but different Python-like language, or for Python 3k. Also, sometimes adding a language feature makes the language conceptually simpler, rather than more complicated. For instance, if Python supported lexical closures, this would make it cleaner and more elegant. It would remove the necessary voodoo of using unactualized optional arguments in nested functions. There are some features of Python that in my opinion should be *removed* for Python 3k. Python has some excess flexibility that is only rarely useful but makes it difficult for a compiler to generate efficient code. Should we want Python to achieve world domination, this is probably an important consideration. |>oug From chris at voodooland.net Tue Apr 10 22:17:07 2001 From: chris at voodooland.net (Chris Watson) Date: Tue, 10 Apr 2001 21:17:07 -0500 (CDT) Subject: Komodo in violation of Mozilla Public License? In-Reply-To: <3AD3B992.2020608@mozilla.org> Message-ID: <20010410210735.I45521-100000@open-systems.net> > This allows us to make sure that MPL code is always open and not > privatized. At the same time, it allows those building products to You know I usually let this slip because I get sick of license wars. But can you explain to me how the MPL or any other public license prevents the closing of source covered with that license? If I release foo.c version 1.0 under a MPL. And company A comes along and takes a copy of the source of foo.c 1.0 and closes it off and refuses to release work they did on it. Can you tell me what magical creature came along and removed foo.c version 1.0 under the MPL off the face of the globe? The same version that company A borrowed/used/stole/whatever. I mean maybe im missing something. Maybe I dont have enough conspiracy theory blood in me. But how can you close a copy of source that is given to the public? Who or what comes along and with divine intervention removes the public version from the planet? ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From grey at despair.rpglink.com Wed Apr 11 03:16:48 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 11 Apr 2001 07:16:48 -0000 Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> <3ad34fb4.1636258213@News.CIS.DFN.DE> Message-ID: On 10 Apr 2001 18:46:56 -0400, David Bolen wrote: >Needed? Perhaps not. But extremely convenient. Maybe before the invention of cut and paste regardless of form. IE, via mouse or screen. Call me crazy, but I just don't see the justification of time, effort and bloat for what is surely a little used feature in the modern computing world. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From michel at digicool.com Fri Apr 20 16:32:43 2001 From: michel at digicool.com (Michel Pelletier) Date: Fri, 20 Apr 2001 13:32:43 -0700 (PDT) Subject: [Python-Dev] Class Methods In-Reply-To: <200104201626.LAA06384@cj20424-a.reston1.va.home.com> Message-ID: On Fri, 20 Apr 2001, Guido van Rossum wrote: > Let x be an object, C its class, and M C's class. So, > > x.__class__ is C > C.__class__ is M > > Then x's methods are described in C.__dict__, and C's methods are > described in M.__dict__. > > The problem is that if you write C.spam, there could be two spams: one > in C.__dict__, one in M.__dict__. Which one to use? I think, at the expense of breaking code, M. > How does > Smalltalk resolve this? The problem is that for backwards > compatibility, at lease, C.spam must be the unbound version of x.spam, > because currently x.spam(...) can always also be written as > C.spam(x, ...). This is the part that choosing M would break. To get at C's shared instance attributes you could say something like C.instanceAttribute('spam')(x, ...). Yes, it's ugly. Perhaps someone can think of a more elegant spelling? > For regular methods it may be possible to avoid this simply by > choosing non-conflicting names, but I seem to recall that Jim wanted > to use class methods with certain special names (like __init__ or > __getattr__?), and I have no idea how to do this without dropping the > idea that x.spam(...) is C.spam(x, ...). So maybe that's the > solution? I'm not sure which idea you are talking about dropping, the first argument binding behavior, or the spelling of getting shared instance attributes from a class (C.spam). Just asking to make sure, cuz I don't think the first needs to change, just the spelling. BTW, you sent me some comments on the Components and Interfaces chapter of the Zope Developer's Guide where you noted that attributes of interface objects are not the attributes described by the interface and that this is "unfamiliar to the typical python programmer", ie: interface Hello: def hello(name): """ say hello to a name """ does not create a 'Hello.hello'. Instead, you need to say "Hello.getDescriptionFor('hello')". If we chose the more familiar 'Hello.hello' then the interface interface would be seriously limited, and any added functionality would need to be imported from an external module or be a builtin like isinstance(). Interfaces, like classes, wouldn't be able to have their own methods. -Michel From fluxent at yahoo.com Mon Apr 23 13:36:52 2001 From: fluxent at yahoo.com (Bill Seitz) Date: Mon, 23 Apr 2001 13:36:52 -0400 Subject: accessing detail about Exceptions Message-ID: I'm pretty new to Python, but my books are pre-v2. Is there any good example code anywhere for catching exceptions? I'm particularly interested in accessing the "associated value" info, without having trapped a particular type of exception (in other words, I want to catch with a generic "except:" if possible, not "except ValueError:"...) From phawkins at connact.com Thu Apr 5 23:15:15 2001 From: phawkins at connact.com (Patricia Hawkins) Date: 05 Apr 2001 22:15:15 -0500 Subject: Deleting dictionary items References: <98ug6n$q9d$1@news6.svr.pol.co.uk> Message-ID: >>>>> "WN" == Will Newton writes: WN> What's the best way to delete dictionary items? WN> I have a dictionary with tuples as keys, and I would like to delete all WN> keys with a certain element. First I wrote: WN> for item in td.data.keys(): WN> if item[attr] != value: WN> del td.data[item] WN> But will this work? Your code contradicts your text (do you mean "with a certain element", or != value?) so it's hard to tell what you want. But this code snippet is really easy to play with -- why don't you fire up a python interpreter and see what it does? -- Patricia J. Hawkins Hawkins Internet Applications, LLC From tim.one at home.com Fri Apr 20 16:56:39 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Apr 2001 16:56:39 -0400 Subject: Can't run "Python-2.1.exe" under NT... In-Reply-To: Message-ID: [Robin Dunn, on the Python-2.1.exe] > I had troubles with it too. On my Win2k system it crashed the > 16-bit subsystem (don't remember the exact terms used in the error > message) and even though I told it to restart no 16-bit apps would > run until after I rebooted. More info! Pretend *you're* on the receiving end of a bug report here . Raw Win2K or with SP1? Which flavor of Win2K (English, French, etc)? Were you logged on to an Administrator account? Restricted account? Etc. After you rebooted, did it work then? How far in the installation process did it get before crashing? Up until that point, and assuming you got far enough that this question makes sense, did you accept the defaults or change something? If the latter, which and to what? etc-etc-etc-ly y'rs - tim From phil at geog.ubc.ca Thu Apr 19 13:35:36 2001 From: phil at geog.ubc.ca (Phil Austin) Date: Thu, 19 Apr 2001 10:35:36 -0700 Subject: mxDateTime and Python 2.1? References: <3ADF046C.F14E50AD@schlund.de> Message-ID: <3ADF21E8.5C26916D@geog.ubc.ca> I had a similar problem, until I moved out of the install directory and restarted python. From a different directory the import works fine for me. Regards, Phil Gaebler wrote: > Hi there! > > I have installed the mx extensions version 2.0.0 with Python 2.1 but > mx.DateTime doesn't seem to work: From mwh21 at cam.ac.uk Thu Apr 19 18:03:38 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Apr 2001 23:03:38 +0100 Subject: python on the smalltalk VM References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> Message-ID: Douglas Alan writes: > After many years of research, they came up with a compiler for Self > that would generate code that runs about one half to one third the > speed of compiled C code. This is 30 to 50 times faster than > Python. No it isn't. At least, not for me. Generally I find that fairly optimized C modules are about 40-60 times faster than really optimized Python (I'm better at Python than C). Obviously "it depends", but I've found these numbers to be fairly consistent over a variety of tasks. > I see no reason that the same techniques couldn't be applied to > speed up Python, but it would probably be a hell of a lot of work > and slow down compile times significantly. I do wonder what the Symbolics Lisp Machine people could do with Python, or in fact any of the Common Lisp vendors. Would be a decidedly pricey experiment... Cheers, M. -- Haha! You had a *really* weak argument! -- Moshe Zadka, comp.lang.python From calisha at *SPAMFREE*.home.com Tue Apr 17 20:48:00 2001 From: calisha at *SPAMFREE*.home.com (Calishar) Date: Tue, 17 Apr 2001 20:48:00 -0400 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: Message-ID: <3gopdt089gf03pf7q1qnopn75kf7qtaqic@4ax.com> On 17 Apr 2001 19:33:33 GMT, kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) wrote: >>P.s. Sorry, but the uncontrollable, eternal sound file is a major >>hot-button of mine > > I agree, it's a major hot-button of mine, too. That's why I did it - >allowing it in a browser is wrong. Don't shoot the messenger, bitch at >Microsoft. |+) Yes, yet another wonderful innovation from the company that gave us all Bob. unfortunately I don't think that the fact they let you do it, makes it better for you to do it. In fact, since you say that you now it's wrong, and you went ahead and did it, that seems to make you further in the wrong. Sorry for venting on you this morning, I just found I am suffering from withdrawal from the quit-smoking medication (combined with Nicotine withdrawal). I won;t try to convince you to stop using that sound file on other pages but when you invite people to come see one of your pages, does it make sense to have a sound file that is going to make some of them panic, some of them freak, and just totally turn some of them away from what you are working on. > > (or, as Fred Lundh said, hit "stop" once the page loads...) Yet another gripe to Microsoft is the fact that the damned browser gives no indication that it is doing anything. Calishar From denchan at earthlink.net Fri Apr 27 11:32:05 2001 From: denchan at earthlink.net (Mark Sloboda) Date: Fri, 27 Apr 2001 11:32:05 -0400 (EDT) Subject: Controlling SaveAs Word 9.0 COM Message-ID: <380031919.988385525630.JavaMail.root@web622-wrb.mail.com> Hello, I have to open a Word file which is text, save it as DOS-encoded text under a different name, and close it. A similar VB code example is: myDocname = ActiveDocument.Name pos = InStr(myDocname, ".") If pos > 0 Then myDocname = Left(myDocname, pos -1) myDocname = myDocname & ".txt" ActiveDocument.SaveAs FileName:=myDocname, FileFormat:=wdFormatText End If In my Python code I have tried several approaches: from win32com.client import Dispatch Word = Dispatch("Word.Application") Word.Visible = 1 WordDoc = Word.Documents.Open("C:\\test.txt") WordDoc.SaveAs(FileName='C:\\TextTest2.txt',FileFormat='wdFormatDOSText') WordDoc.Close() Word.Quit() It works fine if I leave the FileFormat argument out. However, when I add the FileFormat argument as shown above, I get Traceback (most recent call last): File "d:\python20\pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\...\OpenApp.py", line 7, in ? WordDoc.SaveAs(FileName='C:\\TextTest2.txt',FileFormat='wdFormatDOSText') File "d:\python20\win32com\gen_py\00020905-0000-0000-C000-000000000046x0x8x1.py", line 13959, in SaveAs return self._oleobj_.InvokeTypes(0x66, LCID, 1, (24, 0), ((16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17), (16396, 17)),FileName, FileFormat, LockComments, Password, AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter) com_error: (-2147352571, 'Type mismatch.', None, 2) I have tried several variants (including specifying a value for all possible args and at best I get no error, but no DOS encoding either. Any suggestions would be greatly appreciated. Mark From grey at despair.rpglink.com Tue Apr 17 23:49:16 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 18 Apr 2001 03:49:16 -0000 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> Message-ID: I's like an effing trainwreck. On 17 Apr 2001 20:36:59 -0400, Douglas Alan wrote: >I can't make "judicious use of procedural macros" if I don't *have* >procedural macros. Thus, without procedural macros, some avenues >opened up to me for making my code more readable are lost. As are LOTS of avenues for making your code unreadable. >You seem to be claiming that "judicious use of procedural macros" >could not *possibly* make my code more readable. If that is what you >are claiming, I have much real world experience that says you are wrong. No, I am claiming that the judicious use of anything programming related seems to be inversely perportional to multitude of ways one can complete the task. Put another way, programmers, like drivers, like to think they are above average. Experience, not to mention mathematics, show that programmers, just like drivers, aren't all above average. Food for though, |>0L|G? >> >Yes, a good argument against Perl. Not a good argument against >> >procedural macros. >> Incorrect, it is a good argument against both. >You are wrong for two reasons: (1) My problems with Perl run far, far >deeper than that it gives you too many ways to do the same thing. And? This doesn't discount that macros are a large... well, several large leaps in that direction. >(2) Yes, procedural macros *can* be used by the novice to just give you >yet another way to do something that you can do easily enough using a >built-in, but that is not where their strengths lie. Their strength >lie in allowing the user to make a wholesale extension to the language >that greatly simplifies a complex task. Can this be misused? Most >definitely. Have they proven themselves to also allow incredible >gains? Absolutely. I'll have to keep that in mind. "Make a wholesale extension to the language." >For instance, procedural macros allowed Lisp to turn itself from a >procedural language to an OO language without changing the language at >all. A very capable OO extention (one that supported multimethods and >a meta-object protocol) could be added to the language using only >macros. The language was able to *grow* without any centralized >control. Hmmm-mmmm, what was that I was mentioning about dialects? >I don't want to be able to so the same thing multiple ways. I want to >be able to add extensions to the language, and to be able to reduce >redundant code by being able to parameterize such code using macros. IE, make your own dialect. >> Perl has that, hence you are aspiring to Perl, which you dispise. >> Kinda like that whole homophobes are closet gays. You're a closet >> Perl zealot. >You get nowhere with such reasoning, except to make me think that you >are ignorant about procedural macros and wish to remain that way. And you're proving to me that you're the very zealot I mentioned who is more interested in whining about not having his favorite constructs than working with what is presented. I still think you're a closet Perl Zealot, too. >> > You speak using armchair logic and not from real-world experience. >> I speak using real-world experience. >You do? Have you ever programmed in Lisp using procedural macros? I speak of having to maintain an extremely large codebase of TIMTOWTDI code and shudder at the thought of having to deal with the "wholesale extension to the language" to the extend of taking a procedural and turning it into OO at the whimes of the dozens of programmers who have worked on this code base. I have enough trouble as it /is/ without the language itself being (more of) a moving target! >This is a straw man. The "benefit" you mention is not the benefit I >care about. Whoop-di-do, it is a benefit mention in conjuction with what you are advocating. It /IS/ something that is going to happen so you had best be ready to defend it. >I'm not speaking from theory -- I am speaking from direct experience. >I have used Lisp extensively and I *know* what benefits and pitfals >procedure macros entail. Clearly not. >> > You speak in non-sequitors. I don't want Python to be *anything* >> > like Perl. >> Yes, you do. You want to be able to provide multiple ways to do the >> same thing. >Straw man. Deal with it. >> > A language without procedural macros is clearly less expressive >> > than one that has them. >> A language without procedural macros is clearly easier to maintain. To >> me, that is power. >Untrue. As I said before, I speak from direct experience that >procedural macros typically make programs easier to maintain, not more >difficult. Pardon me if I don't take your word on it. >> Except for those who have to touch your code and then wonder why the >> language doesn't work like they learned it. >The language will still work exactly the way that they learned it. It >will just be the case that there will be a new syntactic form. The >new syntactic form will be no more difficult to understand than if I >defined a new function and used it. Whoops, let's think about this. "Wholesale extension to the language" and turning a procedural language into something similar to OO. Those do not jive with "The language will still work exactly the way they have learned it." Sorry, I do not believe you when you are touting a pseudo-OO from a non-OO language as "exactly the same". If it operated "exactly the same" then you wouldn't have a NEED for the macros since, well, it isn't modifying anything is it. If it were, then it wouldn't be EXACTLY the same! >> They then need to learn your particular dialect of the language. >By your definition, they need to learn a "new dialect" every time I >define a new function. No, they do not. Since the functions are written in the language and are a part of the language they don't need to learn anything new to understand the language. They only need to reed the narrative that is there. A new dialect... Wait, let's pause for a minute. Clearly you are having trouble with the big words and didn't take my advice. From m-w.com... a regional variety of language distinguished by features of vocabulary, grammar, and pronunciation from other regional varieties and constituting together with them a single language Distinguised by features of vocabulary, grammer and pronunciation. I chose that word because with macros you are changing how the language reacts and acts. Unlike with just defining a new function which is using existing behaviors, IE, "vocabulary, grammer and pronunciation", to get the end result. That is why in one dialect of English "Put that fag out!" means to extinguish a cigarette and in another it might mean to remove a gay individual from a building or to knock them out with physical violence. Just as in natural languages where different DIALECTS alter the meaning and understanding of the individual sentences macros would do the same for computer languages. Functions do not because they use the existing langauge to create new things, not alter the language to create new things. READ THAT SENTENCE AGAIN, USE THE WEB SITE FOR THE BIG WORDS. There is a difference there and if you're too dense to figure it out, your own tough luck. You're the one trying to sell the notion that macros which can effect a "wholesale extenstion to the language" and even alter the behavior of the base language (Lisp procedural to pseudo-OO) is even on the same remote scale as a common function definition! >If you want to use Perl go ahead. I'd much rather not to. However, it pays the bills. >I just want *nothing* to do with Perl, okay? I don't talk down to people who >ask me *Python* questions, or *Lisp* questions, or *C++* questions, or *Java* >questions, if the questioner does so with even the slightest amount of >respect in their tone. But you talk down to people who ask Perl questions, clearly. I don't talk down to anyone asking honest questions. Only to yahoos (that's a technical term for |>00|> |>oUgsL3R, btw) who is saying one thing out of the left side of his mouth (The language acts the same!!!) and something entirely different out the other (The language has evolved, wholesale extensions, morphing from one style of programming to another). Sorry, Doug, one or the other, can't have both so stop trying. >So? It still allows programmers to define new terms that you have to >do some work to understand. Written in the language we know, not redefining the language. There is a difference. Try this since you're so dense on the difference. Ever wonder why Legalese, while nominally English (well, in this country) is so hard for the layman to read now? 1/2 the reason is because they like to redefine a word for the scope of the document. Taking existing words and putting them together in new ways = same language = functions. Taking existing words, redefining them for only a short timeframe = different DIALECT = macros. >If procedural macros were added to the language, then they'd be part of the >language too, would they not? No, see above. >Procedural macros don't allow you to "redefine the very semantics and >syntax of the language". Not according to "Wholesale extenstion to the language" OO-outta-procedural Douglas Alan. Maybe you've heard of, oh wait, you're him. Read the top of this message to see the appropriate quotes. I'd call making OO out of non-OO redefining the very semantics and syntax of the language. Call me crazy, but C and C++, by most people, are considered two different languages with the mane difference being... Well, one is functional, the other OO. Wacky that, eh? >They only allow you to add new terms to the language, just as defining >functions and objects allows you to add new terms. If that is all they did then why do we need them if we have that now with fuctions. Clearly that isn't all they do. Call me crazy but maybe that Douglas Alan guy, er, you, nailed it with "wholesale extensions to the language". Call me crazy but I don't consider programs written in the language as wholesale extensions to the language. I call them, well, programs written *IN* the language as opposed to *ALTERING* the language. And please, no more BS about "it doesn't alter the language" ok? "Wholesale extension of the language" and making OO out of non-OO is altering the language, period. >The type of term you can add to Python with a function is somewhat limited >compared to what you could add with procedural macros. Sometimes a more >powerful term-adding capability is incredibly useful and allows you to make >programs that are more elegant and easier to maintain. More elegant and easier to maintain... ...to the original author since he is the one who wrote the dialect in the first place. For everyone else, it is a major pain in the rear since they now have to /LEARN/ the "wholesale extension to the language". You, uh, forgot that part, didn't you. You are aware other people are going to have to maintain your code. And remember, in spite of what you may think, there is a 50/50 chance you're a below average programmer. >> If the big words are hard for you to understand visit >> . >%#@% you too. To me it is deserved. You know why? I'm a out-and-out prick. I don't suffer liars lightly and anyone, I do mean ANYONE who is trying to sell the tripe your selling of altering a language without ever altering the language is either trolling, smoking crack, or lying. So %#@% (Hash, comment, array, hasH?) me all you want. But when it comes to Alex I best suggest a few things, in order. Sit down. Shut up. Read. Learn. Alex has been uniformly polite and entirely too verbose in his/her (er, sorry Alex) explinations of not only how certain things work but why they work, why they were made to work that way and why alternatives have not been implemented. I have found Alex to be the single largest help on my transition into Python and Pythonic thinking and have YET to find fault with his/her (er, sorry Alex) reasoning. So the next time you even think Alex is being rude, read this reply to remind yourself of what rude (and correct) is. Then follow the above 4 steps. Sit down. Shut up. Read. 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 alan.gauld at bt.com Thu Apr 12 11:17:58 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Thu, 12 Apr 2001 16:17:58 +0100 Subject: Classes, OOP, Tkinter general comments and detailed questions... References: <3ACBADAC.C7843F96@earthlink.net> <3AD1DB5C.E75D0930@bt.com> <9atag601qa6@news1.newsguy.com> Message-ID: <3AD5C725.33693D16@bt.com> Alex Martelli wrote: > "Alan Gauld" wrote in message > > as being like interriupt driven in assembler... an event > > arrives somewhat like a hardware interrupt and causes an > Hmmm -- not quite that bad, I would say: interrupts are particularly > pesky because they are asynchronous, and may arrive at any time, > _interrupting_ whatever you're doing True within the context of a method/event handling function. > for the next one -- that (in my experience) makes event-driven > processing nowhere as hard to learn, master _and_ use productively > as interrupt-driven programming Yes, but if you know interrupt programming - as an assembler programmer might - then event driven is a piece of cake once you realize its the same conceptual model :-) > you are still thinking about ONE path > of execution, albeit split up into not-too-big chunks. Only within an event handler, the flow of control across a use-case say is still fragmented and several use-cases may be executing simultaneously. Thus all of the context saving issues still apply - and for that OO makes it sooooo much easier :-) Alan G From scarblac at pino.selwerd.nl Wed Apr 4 13:58:18 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Apr 2001 17:58:18 GMT Subject: def () syntax ? References: <20010404.095211.716334471.21458@mead.troikanetworks.com> Message-ID: Bruce Edge wrote in comp.lang.python: > Can the follwoing be accomplished in Python? > > I want to create a func named "abc": > > >>> name="abc" > > >>> eval ("name") > 'abc' > > >>> def eval ("name") (): > File "", line 1 > def eval ("name") (): > ^ > SyntaxError: invalid syntax Well, deff tempfunc(): print whee exec(name+" = tempfunc") del tempfunc Works. But how would you use the function? Maybe it's easier to use some dictionary, ie def tempfunc(): print whee function_dict = {name: tempfunc} del tempfunc # Run it function_dict[name]() If you want the function to be in some module, you can use setattr() to make it. import somemodule def tempfunc(): print whee setattr(somemodule, name, tempfunc) del tempfunc # Run it getattr(somemodule, name)() But somehow I feel you don't need it anyway. Are you sure you're not trying to port some idea from another language too literally? In Python you usually don't care about the name of the function when passing it to other things, as you can just pass the function itself... -- Remco Gerlich From p.g at figu.no Tue Apr 3 06:56:02 2001 From: p.g at figu.no (Per Gummedal) Date: Tue, 3 Apr 2001 12:56:02 +0200 Subject: Python on the AS/400? In-Reply-To: References: Message-ID: <128266789863.20010403125602@figu.no> 03.04.2001, 04:12, you wrote: > I have a Python program I'd like to run on an AS/400. > > - does the AS/400 CPython port have select.select? Does it have any > kind of reasonable performance? The python port does not support select.select(OS400 does not have popen). It does support sockets and threads. The performance is not great but ok. > - how stable is the AS/400 CPython port? It is beta and it don't run all the test cases. regards Per From a-steinhoff at web.de Tue Apr 3 04:13:31 2001 From: a-steinhoff at web.de (Armin Steinhoff) Date: 3 Apr 2001 01:13:31 -0700 Subject: stupid questions ... Message-ID: <9ac0nb01j4t@drn.newsguy.com> After reading that ... I have some questions about ActiveState. >From the ActiveState home page: ------------------------------------------------------------------------------- ActiveState and Microsoft Form a Perl of Relationship, William Peterson, IDC Flash, June 1999 Summary: What effect will Microsoft and ActiveState's ActivePerl agreement have on the Open Source community? ActiveState Corp. and Microsoft have signed an agreement to further integrate Perl (practical extraction and report language) with the Windows operating system. IDC wonders what effect this agreement will have on Open Source developers working on Perl. Additionally, IDC wonders if this type of agreement between an Open Source development company and Microsoft is the beginning of a larger Open Source strategy by Microsoft. ------------------------------------------------------------------------------- [Q]: - Is ActiveState (still?) financially independent from MS ?? - what is the real 'open source' strategy of MS regarding Perl + Python ? - after reading ActiveState statements like "blowing the others (OS) away" .. what is the strategy of ActiveState against(?) non MS operating systems ?? Armin From cobrien at Radix.Net Tue Apr 3 15:04:01 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 3 Apr 2001 15:04:01 -0400 Subject: Why not Tcl/Tk? References: <4211ctgvusgcma0c6ok1cpmjou98lv9714@4ax.com> <8J2w6.3336$SB2.606281@ruti.visi.com> Message-ID: <9ad6r1$nt0$1@saltmine.radix.net> In article <8J2w6.3336$SB2.606281 at ruti.visi.com>, Grant Edwards wrote: >In article <4211ctgvusgcma0c6ok1cpmjou98lv9714 at 4ax.com>, Alexander Kluge wrote: >>-How would you describe the major strengths and flaws of Tcl vs. Python? [snip] > >Tcl > Flaws: > Only one data type: string > Incomprehensible quoting semantics > Roll-your-own control flow > No OO support can be Slow not so good debugging > Strengths: > Tk integration > Lots of code out there > Roll-your-own control flow Event driven programming model. Makes some network programming much easier. Some libraries higher level (i.e. scotty/tnm) and sometimes more portable between platforms. > >Python: > Flaws: > No roll-your-own control flow > Lots of GUI options > Strengths: > No roll-your-own control flow > Good OO support > Lots of GUI options > Simple syntax and semantics > Library modules > >>-Why do you prefer the one you use over the other? > I still use Tcl if I am in a hurry to get something working, but that is changing. -- c From footech at get2net.dk Thu Apr 19 18:30:02 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 20 Apr 2001 00:30:02 +0200 Subject: Any Neural Net code in Python? I want to filter out spam email References: <9bm3pv02qq6@news1.newsguy.com> Message-ID: Remco Gerlich wrote in message news:slrn9dtfs6.nbc.scarblac at pino.selwerd.nl... > Alex Martelli wrote in comp.lang.python: > > There may not exist a vector of feature weights that performs > > perfectly, of course. What one generally wants is a vector of > > feature weights that _optimizes_ some performance score. > > Or a set of vectors. Probably a set of vectors that optimize some score. > Something is spam if one|enough of the vectors trigger (pick your favorite). > > "A learning approach to personalized information filtering" by Beerud Dilip > Sheth () is his MSc thesis > where he uses genetic algorithms to optimize a set of vectors for > information filtering. > The thesis is available at: http://agents.www.media.mit.edu/groups/agents/publications/sheth-thesis.pdf There about the author here: http://www.dfki.de/~allen/People/Stu/Sheth/ Mikkel Rasmussen From alex at server01.shindich.com Sun Apr 1 19:29:54 2001 From: alex at server01.shindich.com (Alex Shindich) Date: Sun, 1 Apr 2001 16:29:54 -0700 (PDT) Subject: PEP 245 In-Reply-To: <5.0.2.1.0.20010401125214.02295330@mail.inet.com.br> Message-ID: On Sun, 1 Apr 2001, Carlos Alberto Reis Ribeiro wrote: > I'm not the best person to answer you, but that's my take. Interfaces allow > for some very powerful forms of OO abstraction to be implemented. You > aren't forced to use inheritance for everything. This frees the class > hierarchies, making it possible to have a "mesh" of classes instead of a > very rigid tree structure. It also tends to minimize the use of multiple > inheritance, when all that you want is to support multiple interfaces. All > of this is possible even without static typing. As for your concern with > the semantics, no strongly typed language can enforce it - you have just to > hope that the function being called behaves as documented. > I do not want to restart the whole discussion on the difference between base classes and interfaces, but I am of the opinion that they both represent an is-a relationship. > >2. At what point will the compliance with the interface definition be > >done, at compile time, or at run time? > > Don't know what the dev guys are thinking. I would prefer *not* to > explicitly check interface compliance at any time. You said that you > supported a interface, it's your job to write the methods for it. If you > don't do so, you get an exception. > Arguably, this behavior is already available through runtime method binding. > But I think that is reasonable for > any language developer to borrow stuff from other languages. People has > been doing this for a long time anyway . I agree that borrowing best practices from other languages is a great idea. In fact, interfaces make Java very powerful. I just don't think that interfaces will be as useful for Python. > Also note that, by > supporting a runtime (on-demand) approach to interface checking, we are > keeping with Python tradition. This makes interfaces to be as good as doc strings... -- Alex Shindich mailto:alex at shindich.com Visit http://www.shindich.com/ From shindich at itginc.com Tue Apr 3 22:38:27 2001 From: shindich at itginc.com (Alex Shindich) Date: Tue, 3 Apr 2001 19:38:27 -0700 Subject: PEP 245 Message-ID: >Exactly. In particular, '__' name mangling does not apply to inheritance. OK, we are agreeing on something... "sigh of relief" >Yes: C++ sort-of-confuses "I implement an interface" and "I conveniently >use [some part of] a class in my own implementation" under the single >rubric of 'inheritance' -- pretty bad in itself, and the distinction >between public and private inheritance is a helpful band-aid given this >confusion. Better, of course, not to have the confusion at all. In >Python, we also lack the band-aid, so it's _particularly_ important to >avoid confusing these two concepts -- both important, but quite distinct. I personally rarely use inheritance in Python for anything else but to describe interface-like behavior. For code reuse I prefer containment... But that is just me... >COM does not mandate that a C++ compiler is used, nor does it have >anything to say regarding HOW such a compiler (or one for another >language, such as Eiffel) be used to implement COM objects -- as >long as certain binary layouts are obtained, and various semantics >rules are respected, COM couldn't care less about HOW this is >brought about, nor WHEN (COM has *NO* concept of "compile time"). OK!!!!!!!!!!!!!!!!! COM was a stupid example!!!!!!!!!!! Yes it only cares about the memory layout of the virtual tables. And YES, COM components can be written using anything that is capable of creating C++-compatible virtual tables. It is just that I happened to write COM code using C++ on a very frequent basis (and no, I do not use Wizards...), and for the most part I implement multiple interfaces using multiple inheritance. Not that it is the only way of doing it. And why don't we stop the whole COM nonsense here! I love COM, I write COM code all the time. And YES, I used it as a bad example. Let it rest already. If you know so much about COM and you feel like arguing, we can find another forum for that. It still has nothing to do with the original point, what is the value of adding interface support to Python. >There are more things in heaven and earth, Mr Shindich, >Than are dreamt of in your philosophy. I sense a lot of anger in you... >_I_ (and the designers of COM) :))) >see identity constraints as highly >pragmatical issues that ensure certain proxying and marshaling >strategies (and, more generally, certain client-side choices for >access and usage) will work -- constraints on object implementers >for the benefit of optimizations in the COM infrastructure (and, >to a lesser degree of importance, for the benefit of client-side >coders; Huh? "lesser degree of importance, for the benefit of client-side coders"? That is a very one-sided approach to the problem. Interface identity is being used for marshaling, but there is more to it. I see identity constraints as being useful because they enable the client coders to rely on the particular semantics associated with the particular version of the interface. >e.g., the "reflexivity" of QI ensures client-code can >choose to hold a single pointer to a certain interface on a given >object, and will always be able to QI back to other interfaces at >need, rather than needing to use some specific 'privileged itf' >for such purposes). Different sets of constraints might also work, >enabling different strategies from client-side, implementer-side, >and infrastructure, with different performance tradeoffs, but it >is important to have SOME set of very precise ground-rules for >"object identity", so that client-code, implementation-code, and >infrastructure-code, each written in very diverse languages, can >all work together in harmony (I happen to believe that the very >set chosen by the COM designers is the ideal one for the use >cases _they_ were considering -- local, in-process, and fast- >response-LAN client/server usage -- but, change the use cases, >and the tradeoffs shift... and so does the optimal definition >of object-identity rules, cfr. for example the .NET choices). I am sorry, at what point in time did I ask for a COM interface rules lecture? WHAT DOES IT HAVE TO DO WITH THE DISCUSSION ON HANDS? > To me an interface means > a contract by wich both a component and the client code live. All I am >add any kind of co-variance, which both Point well taken. That is true. >A _pragmatical_ person, on the other hand, takes into due >account these limitations _and still documents these kinds >of constraints_ as formally as feasible given whatever >technology is at hand. I use the technological marvel called text editor to document my code. >> Oh, Lord! Leave the COM alone. Why don't you talk about similarities with >> Java? >Because YOU mentioned COM -- a very interesting and hugely successful >design for a cross-language object-model, which succeeds in good part >by doing the very OPPOSITE of what you SAID it was doing [the idea of >taking COM as an EXAMPLE of "compile-time" was particularly hilarious >to a COM expert, and I wanted to share the mirth:-)... and possibly >help dispell some misconceptions]. >is used instead of an array, and *THAT* is *OBVIOUSLY* not compile-time >type-safe since ANY object can be stuffed into it -- it doesn't take >much Java knowledge to point this out:-). Wait till Java generics become available... >And whoever thinks that a good design is less valuable when a dynamically-typed language, rather than a >statically-typed one, is to be used for the coding, needs far more >reprogramming than I can supply:-). When did I say about good design being only needed for statically types languages? I think you are hallucinating... What I SAID, is that Python has it's own SET OF INTROSPECTION-BASED PATTERNS that generally allow you to accomplish same things as patterns that are more INTERFACE BASED! >If you include C-coded extensions among the "existing language >constructs" of Python, then, yes, I cannot think of ANYTHING >that cannot be _implemented_ using them. There may be no clear >way of _expressing_ what is going on in Python, when enough of >the crucial stuff is hidden in a C-coded extension (have you >*studied* the current [and excellent] implementation of the COM >support, on both the C-coded and Python-coded sides...?!-). Not that it is something that I have achieved, but I believe I looked at the first underpins of the Python-COM framework before Mark Hammond had a chance to see it... But then again I was lucky to work with someone who first wrote the COM support for Python. IN ALL HONESTY, I WOULD LIKE TO DISCONTINUE THE COM DISCUSSION!!! If you have something you would like to argue with me about, please mail me directly. YOU MADE YOUR POINT EXPLAINING THAT COM IS NOT LANGUAGE-SPECIFIC, AND THAT COMPILE TIME CHECKING IS PROVIDED BY THE USE OF C++ AND NOT COM TECHNOLOGY ITSELF. BUT PLEASE, STOP COM LECTURES!!!! THIS IS A PYTHON NEWSGROUP!!!! From fredrik at pythonware.com Wed Apr 18 15:03:58 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 18 Apr 2001 19:03:58 GMT Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> <9bk0ce026c6@news1.newsguy.com> <3d1yqqf5pp.fsf@ute.cnri.reston.va.us> Message-ID: Paul Prescod wrote: > I don't really believe that. I tihnk that hygenic macros could and > should be used for: > > 1. experimentation > > 2. domain specific "little languages" based on Python like ptml or > pyslt or pymake or ... which means that you don't have to modify the language at all: just use a custom importer... Cheers /F From dalke at acm.org Sat Apr 14 03:44:17 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 14 Apr 2001 01:44:17 -0600 Subject: ANNOUNCE: A Python 2.1 release candidate! References: <3AD7E7A0.C6D46914@home.com> Message-ID: <9b8v56$9u2$1@slb5.atl.mindspring.net> Don O'Donnell wrote: > if __debug__: print "function bleep entered with arg: %s" % arg >thus all debugging is under control of a single variable. That's an expected use of the __debug__ variable. Indeed, the docs say that code will be ignored when generating bytecode under the -O option. >I find it very useful to be able to assign to __debug__. There are at >least two situations where I use it regularly: > >1. As a run-time debugging switch. By providing an interactive user >option switch which sets __debug__ to 0 or 1 dynamically at run time >through user input (menu or command prompt). This allows me to easily >turn off debugging when it's not needed and turn it back on when it is. >This can save me a lot of time in not having to watch thousands of lines >of unneeded debugging information scroll up my screen. Especially true >in early stages of testing, where I just want the compiler diagnostics >and run-time exception handler to do my first level checking. As compared to using some other variable, like "DEBUG = 1" ? It you are concerned about performance and want the -O to not compile the debug code, and allow toggling of debug status information when not using -O, then this works fine. if __debug__: if DEBUG: print "Here I am!" (I believe you have to nest the statements like this since the compiler isn't clever enough to check for "__debug__ and DEBUG". No constant subexpression analysis in the compiler.) This is at the cost of 1 more line. If that's too much, you can write things like: def debug(*args): print string.join(map(str, args)) + "\n" if __debug__: debug("I am here with val=", val) >2. To selectively turn off debugging for sections of code or functions >which have been tested, and turn it on for code sections under test. What's wrong with a DEBUG variable in the module? Otherwise you are overriding a builtin variable with a module variable. Also, many people use debug levels, which you can't get out of the __debug__ variable. Or do you start wanting to assign numbers to it besides 0 and 1? >Can anyone explain to me why this change, to make __debug__ read only, >is necessary or beneficial in some way? Or am I misinterpreting GvR's >statement that "assignment to __debug__ ... will become illegal in 2.2." It is not a misinterpretation if my reading of python-dev is correct. The thing is that __debug__ changes the compile-time semantics so that a run-time change in its value, like ====== import os if os.environ.get("DEBUG") == "1": __debug__ = 1 else: __debug__ = 0 if __debug__: print "Importing this module" === will not work as expected if run under -O. If it is a read-only value then there can be no confusion. Andrew dalke at acm.org From missive at frontiernet.net Tue Apr 17 21:02:23 2001 From: missive at frontiernet.net (Lee Harr) Date: 18 Apr 2001 01:02:23 GMT Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: Message-ID: <9bip2v$kge$1@node17.cwnet.frontiernet.net> On 17 Apr 2001 03:14:32 GMT, Mark 'Kamikaze' Hughes wrote: > Umbra is a computer role-playing game written in Python, similar to >Alternate Reality and Bard's Tale, with influences from roguelike games >and console RPGs, and set in a universe of Lovecraftian elder gods. > > > I got an error saying that -o is not a valid option, but was able to work around this by 'touch'ing all of the .py files corresponding to your .pyc files (ie, 'touch Entity.py' 'touch Equip.py' etc) now I get a no module named zlib error... grumble... I will look around for that later... From mertz at gnosis.cx Fri Apr 6 14:06:40 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Fri, 06 Apr 2001 14:06:40 -0400 Subject: Anyone able to compare the commercial IDEs available? (fwd) Message-ID: Just between us :-), I've also written an installment of _Charming Python_ on this topic. But IBM developerWorks will be the "official" publisher, so don't add this link to too many lists: Charming Python #17: Review of Python IDEs http://gnosis.cx/publish/programming/charming_python_17.html Yours, David... From robin at jessikat.fsnet.co.uk Fri Apr 13 05:50:15 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 13 Apr 2001 10:50:15 +0100 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> <3AD5C5B1.98ACEFB3@metaslash.com> Message-ID: <9otuNLAXvs16EwcK@jessikat.fsnet.co.uk> In article <3AD5C5B1.98ACEFB3 at metaslash.com>, Neal Norwitz writes >Robin Becker wrote: > ... >If you send me the code (preferabbly a small test case), I'll take a look >and try to fix. OK I have the following dummy things #b.py '' class B: 'base class' member = 0 def __init__(self): self.x=1 #a.py '' from b import B class A(B): 'derived class' member = 1 checker on a.py produces C:\Python\pyChecker>python checker.py a.py Processing a... Warnings... b.py:0 No __init__() in subclass (A) C:\Python\pyChecker> -- Robin Becker From wolfson at uchicago.edu Fri Apr 13 14:25:14 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Fri, 13 Apr 2001 13:25:14 -0500 Subject: idioms for abstract base classes References: <9b6qtv02h2i@news2.newsguy.com> Message-ID: In article , "Carlos Ribeiro" wrote: > In Delphi, there is a "abstract" keyword that can be used as syntactic > sugar as in the example below: > > class B: > def __init__(self): abstract > def dosomething(self): abstract > > ...where "abstract" will raise a "abstract method exception". Do anyone > smells a PEP here ? You can already do: class B: def __init__(self): raise NotImplementedError def dosomething(self): raise NotImplementedError or even: def _abstract(): raise NotImplementedError class B: def __init__(self): _abstract() -- Barnabas T. Rumjuggler Betty Botter bought an ice-cream sandwich. "But", said she, "This ice-cream sandwich's messy! If I put it in my pocket, it will make my pocket messy!" From jepler at inetnebr.com Tue Apr 3 09:03:10 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Tue, 03 Apr 2001 13:03:10 GMT Subject: cgi security References: Message-ID: On Tue, 3 Apr 2001 08:59:09 +0100, Robin Becker wrote: >Are there any possible break ins in lib/cgi.py that someone malicious >could exploit? The classic exploits seem quite hard to find in python >code unless people start using fixed length buffers etc, but are there >other opportunities (perhaps more pythonic)? There are no known problems in cgi.py itself (at any rate, none *I* know about, and none listed obviously in the update messages for cgi.py at least since Python 1.4), but cgi.py can be used poorly --- for instance, x = cgi.FieldStorage() system("echo %s" % x['something'].value) is insecure when someone uses a url like http://....../cgi-bin/bad.py?something=owned%3brm+-rf+/ (In this example, Perl has a slight advantage because "taint checks" can flag this sort of thing) There are plenty of other examples of this sort of thing. Jeff From aleaxit at yahoo.com Thu Apr 19 03:57:41 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Apr 2001 09:57:41 +0200 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9blhdb$619$1@nntp9.atl.mindspring.net> Message-ID: <9bm5pj02t9j@news1.newsguy.com> "Douglas Alan" wrote in message news:lcpue9sh4c.fsf at gaffa.mit.edu... [snip] > procedures and strings. (Is there a way in Python of finding local > variables by name on the Python stack so that a procedure can get and > set variables in the caller's environment? If so, you could do it, > but it would be pretty ugly.) _Examining_ local variables of the caller is possible (albeit arguably not pretty), but _rebinding_ them (or binding new ones) isn't (it might accidentally work in some implementation, but the language reserves the right for the optimizer to change the implementation of a function's local variables in any way whatsoever). In Python 2.1, I believe the canonical way to examine the caller's local namespace has become sys._getframe(1).f_locals which is said to be a "readonly dictionary" with the name->value correspondences. _getframe, by the way, is documented as "This function should be used for internal and specialized purposes only". Alex From emile at fenx.com Fri Apr 13 10:06:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 13 Apr 2001 07:06:23 -0700 Subject: list comprehensions whats happening here References: Message-ID: <9b71c7$7sse3$1@ID-11957.news.dfncis.de> I suspect the answer lies somewhere in the comma converting the parts of the list comprehension into a list itself, much as the comma is used in normal iteration idiom: for i in 1,2 -- Emile van Sebille emile at fenx.com From marcel.lanz at dkmp.org Sun Apr 29 11:17:36 2001 From: marcel.lanz at dkmp.org (Marcel Lanz) Date: Sun, 29 Apr 2001 17:17:36 +0200 Subject: regexp pattern in _isrealfromline in class UnixMailbox Message-ID: Hi all, I use the class UnixMailbox in Python 2.0 from the mailbox.py module to parse mailboxes but never got some messages. I found that the regexp in the method _isrealfromline in class UnixMailbox doesn't match with my 'From' lines I have in my files. All 'From' lines in the file looks like this one: >From lanzm at dkmp.org Thu Mar 1 10:55:15 2001 +0100 but the pattern in _isrealfromline doesn't match: _fromlinepattern = r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+" \ r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*$" There might be a problem with the + in the time zone shift: +0100 which is the reason why the pattern doesn't match: After I changed the pattern to: _fromlinepattern = r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+" \ r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+[+-]?\d\d\d\d\s*$" ^^^^^ I can parse mailbox files for hours ... Best regards Marcel -- Marcel Lanz http://www.ds9.ch/lanz/ marcel.lanz at dkmp.org | marcel.lanz at computer.org GnuPG: F975 C6F7 04C8 642B 6DF4 4DF4 2945 F02A 797E 7DAB From d_cortesi at yahoo.com Sun Apr 15 16:00:12 2001 From: d_cortesi at yahoo.com (David Cortesi) Date: Sun, 15 Apr 2001 13:00:12 -0700 Subject: two newbie mac-python questions Message-ID: Surely these are easy to the point of dumb: When the Mac IDE or interpreter terminates (and this includes normal termination of the installed EditPythonPrefs applet), it puts up an empty window with the string "" in the title bar, and won't go away until cmd-Q is typed a second time. I've sung "how can I miss you if you won't go away" to it, but it didn't help. How can this annoying behavior be stomped? I can't get the IDE to display its Debugger window by any means except clicking the [Post mortem..] button in the Traceback window which appears when a Run program terminates. And when the Debugger window is invoked in this way, the only one of its buttons that is active is [Kill]. The Run/Stop/Step etc buttons are grayed-out. How can the Debugger window be opened and used to start, stop, and step a program interactively? Thanks, Dave Cortesi -- David Cortesi - d_cortesi at yahoo dot com From d98aron at dtek.chalmers.se Sun Apr 1 22:24:18 2001 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 2 Apr 2001 02:24:18 GMT Subject: I want to learn PYTHON! References: <1iqx6.3744$aD4.234302@news2.atl> Message-ID: <9a8nsi$qt5$1@nyheter.chalmers.se> On http://www.python.org/doc/Intros.html in the section "Introductions to Python programming for non-programmers" there is a couple of links, perhaps some of them would help. Learning to program is an interesting problem, perhaps you could post your experience later on. What was hard to understand?, was there any documents that you can recommend to other non-programmers?, what did take long time to figure out, what questions were hard to find an answer to and so on... The following links are very good if you have a what, how or why question... http://www.python.org/doc/FAQ.html (a lot of answers to common questions) http://python.faqts.com (collected questions and answers from comp.lang.python) http://pythoncookbook.activestate.com/ (tips and how to:s from experienced python programmers ) Good luck learning! /Fredrik In article <1iqx6.3744$aD4.234302 at news2.atl>, "KEVIN" writes: > Where do I start. > > I am not a programmer but have an intermediate level of computer knowledge > in Windows only. > > -- > KEVIN > > "Si hoc legere scis, nimis eruditionis habes." > ----------------------------------------------------------------- > Please repond in the newsgroup. > My email address is altered for anti-spam > Just change .nOt to .net > > -- From phrxy at csv.warwick.ac.uk Tue Apr 24 20:00:52 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 25 Apr 2001 01:00:52 +0100 Subject: idioms for abstract base classes In-Reply-To: References: Message-ID: On Tue, 24 Apr 2001 zooko at zooko.com wrote: [...] > It turned out that in addition to wasting my time implementing a > feature that we never needed, I also made the resulting code hard for > my fellow hackers to follow. Due to the polymorphism and due to the > common "parallel inheritance hierarchy" problem, it was very difficult > even for *me* to understand how control flowed through the classes, > which became a serious problem when I came back to them six months > later in order to evolve and debug them. [...] What do you mean by "parallel inheritance hierarchy" problem? John From seward.dont.spam.me at nospam.ieee.org Thu Apr 5 14:52:22 2001 From: seward.dont.spam.me at nospam.ieee.org (Anthony Seward) Date: 5 Apr 2001 18:52:22 GMT Subject: execfile: NameError exception thrown for things in locals() Message-ID: I'm missing something subtle about the use of execfile. All that I want to do is something like execfile(fn) spam = Spam() where 'fn' is the name of a file that has a definition of the class Spam. It doesn't seem to work because a NameError gets thrown. The class definition of Spam is in the local dictionary, however. Everything works OK if I read the file and hand a string representing the file data to 'exec'. I've appended a python script that demonstrates what is happening. Could someone please explain to me what is happening. Thanks, Tony ----------- #!/usr/bin/python import os import tempfile def test_execfile(fn): """ Try to use 'execfile' to load a class definition """ execfile(fn) print ' %s' % str(locals()) if 'Spam' in locals().keys(): # __ 'Spam' is in locals() so why does this produce a NameError spam = Spam() def test_exec(string): """ Try to use 'exec' to load a class definition """ exec string print ' %s' % str(locals()) spam = Spam() def test_homemade_execfile(fn): """ Try to use a homemade version of execfile to load a class definition """ file = open(fn) string = file.readlines()[0] file.close() exec string del file del string print ' %s' % str(locals()) spam = Spam() if __name__ == '__main__': string = 'class Spam:pass\n' fn = tempfile.mktemp('Spam.py') file = open(fn, 'w') file.write(string) file.close() try: print 'Trying execfile:' test_execfile(fn) except NameError, msg: print ' NameError:', msg else: print " 'execfile' worked" try: print 'Trying exec:' test_exec(string) except NameError, msg: print ' NameError:', msg else: print " 'exec' worked" try: print 'Homemade execfile:' test_homemade_execfile(fn) except NameError, msg: print ' NameError:', msg else: print " Homemade execfile worked" os.remove(fn) From aleaxit at yahoo.com Wed Apr 25 05:48:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Apr 2001 11:48:01 +0200 Subject: How to write List Object to a File?? References: Message-ID: <9c6ibd02295@news2.newsguy.com> wrote in message news:mailman.988151437.3004.python-list at python.org... > I currently have a list and woulr like to store the contents into a > text fiel whihc I can read back ... > > For example: > a = ['a','b','c','d'] It's a list of strings, then? Without newline characters at the end? And you want to write one per line? > #do something like > fd = open('txt.txt','w') > fd.write(a) > Traceback (innermost last): > File "", line 1, in ? > TypeError: read-only buffer, list > > What to do?? Maybe simplest fd.writelines([x+'\n' for x in a]) for some definition of "simplest". You may expand the loops differently of course, e.g.: for x in a fd.write(x+'\n') If a is not a list of strings, you'll want to use str(x) rather than x in either of the above examples. > And I can't use pickle ... > > later on I would like to read it back... > > fd = open('txt.txt','r') > > iniInfo = fd.readlines() > b=[] > b = iniInfo[0] > # copy list contents into c > map(c.append,b) > > I think this also not work right I think it will separately append each character of the first line, though I haven't checked. > ? > Can someone kindly tell me how to do write and read a list to a file? fd.readlines() gives you a list -- but each string does have a trailing newline character of course. You can take it out in many ways, e.g. c.extend([x[:-1] for x in iniInfo]) Alex From gerhard.nospam at bigfoot.de Sat Apr 14 18:32:53 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 15 Apr 2001 00:32:53 +0200 Subject: [ANNOUNCE] pyAda release 2001-04-15 Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'd like to announce a new release of pyAda. pyAda is an Ada 95 binding to the Python interpreter. With pyAda, you can write Python extensions in Ada 95, and, much more important, you can also embed a Python interpreter in your Ada applications. With the current release, the project has stabilized a little more: - - all compiler warnings were fixed - - bindings not needed were removed - - minor bugfixes In addition to Linux and FreeBSD, pyAda now supports building on Windows and Solaris. website: http://pyada.sourceforge.net release: http://prdownloads.sourceforge.net/pyada/pyAda-2001-04-15.tar.gz docs: docs + examples included in release The focus of the next release will be on documentation improvements and updating to the soon-to-be-released Python 2.1. pyAda currently depends on GNU make, GNAT 3.13p and Python 2.0 (and DocBook SGML for doc creation). The license is a BSD variant. Gerhard - -- mail: gerhard bigfoot de web: http://highqualdev.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE62OGneyJldYarQ8ARAktxAJ4+hSnibu6Uk0FooQX8IwGeYAZBmwCfUFYU 4v14e7jJPph9gJ6IHBR2p4U= =g+3v -----END PGP SIGNATURE----- From aleaxit at yahoo.com Sat Apr 14 03:51:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 14 Apr 2001 09:51:33 +0200 Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <9b7iaq0dep@news2.newsguy.com> <9b814u$39p$1@slb4.atl.mindspring.net> Message-ID: <9b8vfr13gs@news1.newsguy.com> "Andrew Dalke" wrote in message news:9b814u$39p$1 at slb4.atl.mindspring.net... > Alex-bot: > > the answer is: "because, in a well-designed language, there > >is no situation in which ``nothing else will do as well''":-). > > I've just been rereading some of Knuth's "The Art of Computer > Programming." I don't do it very often because I get a > headache trying to understand his use of gotos, which aren't > simply nested (directly convertable to structured loops) > and which aren't error-handling-like (convertable to exceptions). > > So Python is not a well-designed language for direct > translation of MIX code because it doesn't have gotos. Indeed, such direct translation is not among Python's design targets. In general, reverse engineering low level code back up to high levels is rather a nightmare anyway. It's better to design and code at the higher level from the start... > No need to followup - just wanted to complain about MIX (again :) Since when did lack of need stop me?-) Alex From nessus at mit.edu Mon Apr 16 19:53:18 2001 From: nessus at mit.edu (Douglas Alan) Date: 16 Apr 2001 19:53:18 -0400 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Douglas Alan" wrote in message > > "Alex Martelli" writes: > > > Exact syntax sugar could be endlessly (and fruitlessly) debated, but > > > the general idea might be: > > Python should have procedural macros like Lisp. Then whenever anyone > > asks a question about why Python doesn't have syntactic feature xyzzy, > > the answer can always be, "You can already do what you want by loading > > the following macro...." > Yes, 'hygienic macros' WOULD help cut these discussions short. Pity > this benefit (basically restricted to c.l.p) would be balanced by > the productivity loss engendered by the actual existence of such > macros in the language -- a language which may have ANY 'syntactic > feature' ensures any given program is impossible to understand > unless you first study the exact set of macros used by its > author:-). What happened to giving programmers enough rope to hang themselves? What happened to the desire for flexibility and expressive power? Sure, macros are a long rope, but some tasks require a long rope. Take a look at Guy Steele's maxim that a large language is impossible to design well, but a small language is doomed to die. A language needs to be able to grow over time. Procedural macros in Lisp allowed Lisp to continue to evolve over time, so that even though it was invented in the '50's, it remains today one of the most modern of languages. It was able to do this, in part, by allowing every user to experiment with adding language features, not just the language Illuminati. And macros don't ensure that *any* given program is impossible to understand -- it only helps nutty programmers make programs that are impossible to understand. Conversely, macros can help wise programmers in making programs that are shorter, easier to understand, easier to code, and easier to maintain. |>oug From shindich at itginc.com Wed Apr 4 19:57:10 2001 From: shindich at itginc.com (Alex Shindich) Date: Wed, 4 Apr 2001 16:57:10 -0700 Subject: PEP 245 In-Reply-To: Message-ID: Sure. Except that PEP 246 is meant to operate on anything at all, which happens to include the interfaces. In fact, as it was pointed out to me by Clark Evans, the PEP suggests an implementation for a bi-directional adapter pattern. (Although I did point out in the past that it looks very similar to QueryInterface with very vague definition of the interface. The subject of the relationship between PEP 245 and QueryInterface is discussed in PEP's text.) PEP 246 does not guarantee the symmetric behavior, which I think is required for going back and forth between object's interfaces. Although the PEP says that such behavior may be added. (See PEP's text) But all in all, PEP 246 can be implemented in such way that it satisfies '__getinterfacereference__' requirements. But that needs to be the default behavior for '__adapt__'. -----Original Message----- From: Clark C. Evans [mailto:cce at clarkevans.com] Sent: Wednesday, April 04, 2001 4:37 PM To: Alex Shindich Cc: python-list at python.org Subject: Re: Re: PEP 245 On Wed, 4 Apr 2001, Alex Shindich wrote: > I see your point. But I think that proposed interface behavior is > missing a very important attribute -- an explicit facility for > acquiring interface references. This can be done with PEP 246 Clark From jasonic at nomadicsltd.com Wed Apr 11 06:20:21 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 11 Apr 2001 06:20:21 -0400 Subject: converting string to dict ? Message-ID: A web input form passes {'name':'Cleopatra'} as a string. Please, is there a nice clean function to convert this string to a dict? thanks - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From pulsar at qks.com Wed Apr 25 23:50:11 2001 From: pulsar at qks.com (David Simmons) Date: Thu, 26 Apr 2001 03:50:11 GMT Subject: Integer micro-benchmarks References: <5MLF6.98590$166.1840160@news1.rdc1.bc.home.com> Message-ID: "Steve Wart" wrote in message news:5MLF6.98590$166.1840160 at news1.rdc1.bc.home.com... > Here is some more silliness. > > If you take the #triangle method and turn it into a block closure, as below, > in VW it takes almost 10 seconds (on my 333 PII) Really! 10 seconds versus 7 seconds? SIDEBAR: Man squeak sucks idle/cpu cycles. I just downloaded squeak. I left it open and tried to run a benchmark in something else. It skewed the benchmark by 25%. Hmm. Ok, I quit squeak. The execution time difference for SmallScript was around 4% relative to having the variable be local to the block. Internally the difference is the direct result of the JIT not making the extra effort to avoid redundant load/store access on an multi-level indirection of a shared variable. I guess that's not so surprising. Over the years I've been very aggressive in having both the Smalltalk compiler and the VM optimize closures/continuations, and related exception/curtailing scenarios. Good goobley goo. I just ran it on VW and got the times: 1784ms for 9,000,000 loops using local to the block. 4102ms for 9,000,000 loops using as a method temp (shared with the block). The same runs on SmallScript were: 1313ms vs 1380ms respectively NOTE: This is the exact same hardware on ran the previously posted tests on. -- Dave S. > > "c.l.s. benchmark" > |sum time triangle result | > sum := 0. > triangle := [ :int| > result := 0. > 1 to: int do: [ :i | result := result + i]. > result ]. > > time := Time millisecondsToRun: [ > 10000000 timesRepeat: [ > sum := sum + (triangle value: 10)]]. > ^Array with: sum with: time. > > If you modify the above code so that the "result" instance variable is a > block temp, i.e. > > triangle := [ :int| | result | > result := 0. > 1 to: int do: [ :i | result := result + i]. > result ]. > > It executes in under 7 seconds (same as if #triangle were a method on > Integer). > > Something to do with the reification of the block temp I suppose [I only > know about this from reading a post by Allen Wirfs-Brock on the Squeak list > this am] :) Smalltalk MT does not allow block temps. > > Does python have closures? That would be interesting to see. > > Cheers, > Steve From dan at www.cgsoftware.com Wed Apr 25 09:27:01 2001 From: dan at www.cgsoftware.com (Daniel Berlin) Date: Wed, 25 Apr 2001 09:27:01 -0400 (EDT) Subject: Integer micro-benchmarks [Smalltalk Multi-Precision Numerics vis-a-vis Highly Optimized Fixed Size Integer C++ Numerics] In-Reply-To: Message-ID: On Wed, 25 Apr 2001, John S. Yates, Jr wrote: > On Tue, 24 Apr 2001 19:32:32 -0400 (EDT), Daniel Berlin wrote: > > >Errr, this is pretty basic PRE and loop hoisting. > > > >In other words, it's done by anyone taking a college compiler optimization > >course. > >--Dan > > Two cents from an erstwhile professional compiler-writer. > > Loop hoisting is indeed well known and widely practiced > (especially if all that is being hoisted is side-effect > free expression evaluation operations). > > PRE (Partial Redundancy Elimination) is much less widely > known or implemented. In fact I would be VERY suprised if > MS has implemented it since on average it has relatively > little payoff and tends to increase code size. What? Are you joking? I haven't seen the source to a compiler without PRE in many years. Most recent ones i've seen use SSA based PRE, which is even a more complex implementation of PRE. And claiming it has little payoff? That's just funny. I'll put money it's the main speed increasing code transform in most compilers. Especially if it includes invariant code motion. Please do a google search on "Partial redundancy compiler course" If you really believe the above, I have a hard time believing you are any kind of compiler professional. --Dan From akuchlin at mems-exchange.org Thu Apr 12 17:22:26 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 12 Apr 2001 17:22:26 -0400 Subject: PCB Gerber files References: Message-ID: <3dbsq1g6el.fsf@ute.cnri.reston.va.us> zzzzz writes: > Another Python project that I'm currently working on is processing of > Gerber files which are used to define data on PCBs (printed circuit > boards). As part of my project, I need to construct a list of closed You might want to talk to Michael McLay, . He's working on an effort at NIST for an XML-based PCB standard, and may have written conversion software from Gerber to the new format. --amk From brian at sweetapp.com Wed Apr 11 23:14:22 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Wed, 11 Apr 2001 20:14:22 -0700 Subject: Komodo in violation of Mozilla Public License? In-Reply-To: <3AD51590.C2B698DD@cosc.canterbury.ac.nz> Message-ID: Komodo does not offer any code generation or GUI building features that would make switching IDEs a problem. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Greg Ewing Sent: Wednesday, April 11, 2001 7:40 PM To: python-list at python.org Subject: Re: Komodo in violation of Mozilla Public License? David Ascher wrote: > > phil hunt wrote: > > > > If i write some Python programs in Komodo, and then wish to modify > > them in a system that doesn't include Komodo, will I have any problems? > > No! Komodo doesn't "own" the code written with it. It's just an IDE! > Even Emacs doesn't spread the GPL to code written with Emacs =). I think Phil was asking whether it's *feasible* to hand-edit the code produced by Komodo, not whether he's *allowed* to do that. In other words, does it produce code that is easy to read and modify? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list From max at alcyone.com Wed Apr 11 12:15:38 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 11 Apr 2001 09:15:38 -0700 Subject: Curl, the language/environment/markup language...(Spanish Civil War)... References: <3ACBB03A.C9ADDEC5@earthlink.net> <3ACDCD02.4A882784@one.net.au> <3ACDEC08.F850EA3F@alcyone.com> Message-ID: <3AD4832A.5130C840@alcyone.com> "Fernando Rodr?guez" wrote: > Erik Max Francis wrote: > > > That is so retarded I actually had to check the page myself to make > > sure > > you weren't pulling a gag. It really _does_ say that. > > Unbelievable. > > Why do you think it's SO wrong? It's a horribly bad idea if they actually expect the language to become widely used commercially. With such licensing they are guaranteed to drive companies away from using it. No one wants to start using a for-the-Web language where they have to pay _per hit_. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Defeat is a school in which truth always grows strong. \__/ Henry Ward Beecher Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From sholden at holdenweb.com Fri Apr 13 17:03:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Apr 2001 17:03:11 -0400 Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <2XHB6.173259$5H6.6113374@e420r-atl2.usenetserver.com> <3AD61342.79761F3B@earthlink.net> Message-ID: "Ron Stephens" wrote ... > Steve offered me this good code: > > choice = raw_input("Option: ") > if choice == 1: > # code for case 1 > elif choice == 2: > # code for case 2 > elif choice == 3: > : > : > else: > print "Invalid choice" > > Steve, thanks. I guess in this case, when the code for a choice finishes > executing, program flow would go to (Alex: sorry about that particular choice of > words;-))) the end, or right after the print "invalid choice " statement...? > After the particular case selected has executed control "drops off the bottom" to whatever follows. Of course you are at liberty to include in it a loop. By the way, those integers I used should really be strings. So you could do something like: while 1: # loop forever choice = raw_input("Operation:") if choice == "this": # or maybe "1" # do this elif choice == "that": # or maybe "2", etc... # do that elif ... : elif choice == "quit": break # exit from infinite loop else: print "Invalid operation" This will loop, peforming the selected operations, until the user enters "quit", or some exception terminates the run. regards Steve From dalke at acm.org Tue Apr 10 23:59:10 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 10 Apr 2001 21:59:10 -0600 Subject: Newbie Q: var params References: Message-ID: <9b0l1f$ror$1@slb4.atl.mindspring.net> zzzzz wrote: >It looks like "parameter=[2,4,6,8]" creates a new local variable that >overrides the passed parameter. How do I do this properly so that the >passed parameter changes in all parameter type cases? You don't have the right internal model for how Python passes information about. Everything is "by reference" so when you say: >>> def paramtest(parameter): you are creating a new local variable which is a reference to the data passed in to it. Later on when you say parameter=[2,4,6,8] you use the same local variable, but this time it's a reference to a new object. To do what you want it to do you would have to tell the original object (passed in by reference) to update itself with new data. That will differ depending on the object - and some objects are immutable, meaning they cannot be changed. For lists this is done as parameter[:] = [2,4,6,8] which says to replace the complete list ([:] means "starting from the beginning and going to the end") with the values in [2,4,6,8]. Andrew dalke at acm.org From sholden at holdenweb.com Thu Apr 19 08:27:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 19 Apr 2001 08:27:29 -0400 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247><9bjl2901ifj@news1.newsguy.com><9bkc0t02sac@news1.newsguy.com><9bkvi30uf8@news1.newsguy.com> Message-ID: "Jeremy Hylton" wrote in message news:mailman.987654387.28996.python-list at python.org... > >>>>> "RD" == Rainer Deyke writes: > > RD> def f(): > RD> class C: > RD> pass > RD> C() > > RD> This is, incidentially, the idiom I had to use extensively to > RD> deal with the lack of nested scoping in Python. More generally, > RD> you write a class for which subclasses don't make sense. > > It's former lack of nested scopes, I believe ;-). > Perhaps you meant "before its implementation of nested scopes in the __future__"? regards Steve From tim.one at home.com Tue Apr 17 02:16:49 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 17 Apr 2001 02:16:49 -0400 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! In-Reply-To: Message-ID: [Don Tuttle] > ... > Tim, you're the one who taught me what a pain in the ass it is to > release a new version of Python. The pain of making a release is proportional to some power of the number of changes made since the last release, and that means changes in both the Python codebase and in the platforms people are running on. Between 2.1c1 and 2.1c2, only a handful of changes were made to the Python codebase, and AFAIK nobody popped up with a popular new incompatible flavor of Unix between Friday and Sunday . So releases are not *uniformly* painful. Cutting these rapid releases at the end has been easy. > If you and the dev team felt that 2.1 was ready to be released last > Friday (the 13th), it would have been fine with me. But you didn't. > Instead you went to the trouble to build another release. Actually three times since Friday: 2.1c1 then, 2.1c2 Sunday, and will be 2.1 Tuesday morning. Since all the *hard* work has been done, and the rate of change has slowed to a drip, we could cut half a dozen new release candidates every day now, if that seemed of use (but it doesn't -- if you're complaining that 4 days isn't enough to download it and try it, I can't imagine you'd be happier with 4 hours ). > It's the fact that you went to all this trouble, The 2.1c series has been easy. > but only allowed 4 days of use, that brought me into this discussion. > This seems rushed. Why go to all this trouble if you're not going to > give users the time to test on all these different platforms? I've already answered this: people have been testing for months. There's no rush. Neither is there any point to extending the prerelease period beyond its usefulness. The people keen to test are already testing, and others can't be persuaded to try -- waiting even months won't change that, and delaying releases artificially is as silly as pushing them out early. The major point of the rc series was to get a close-to-2.1-final-as-possible prerelease package into the hands of people who reported new glitches over the last few weeks, to make sure the fixes really fix their problems on their platforms, and don't create gross new problems for others. The former people certainly are trying the packages, and they're primarily who we made the packages for. That at least hundreds of other people give them a try too is gravy. >... > It seems this is being done simply to meet some arbitrary > deadline It's being done because the release is ready on technical grounds. The release candidates aren't a sign of haste on Guido's part, but of caution: asking people to test fixes from a prerelease package is more reliable than asking people to test from their own private copy of the CVS tree, and also much more convenient for them (which greatly increases our chances that they *will* try it). Alas, history tells us there's no way to get *huge* numbers before a final release is out the door. In that sense, and like it or not, putting out 2.1 final is the only way we have to get the only kind of broad 2.1 field testing you seem to think is worth the effort (and on that we definitely disagree -- rc1 and rc2 were certainly worth the (marginal!) effort of putting together, rc1 because people did report last-second brainos in it, and rc2 because they haven't reported more). Now my best guess is that within 3 years, we'll have millions of people paying us $30 each just to get their hands on a Python alpha release. It works for Bill Gates, and Guido's smarter than him . until-then-we-gratefully-take-whatever-people-freely-give-but- can't-get-more-than-that-ly y'rs - tim From jafo at tummy.com Sun Apr 15 20:41:21 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sun, 15 Apr 2001 18:41:21 -0600 Subject: 2.1c1 RPMs (was: Re: ANNOUNCE: A Python 2.1 release candidate!) In-Reply-To: <200104132218.RAA10759@cj20424-a.reston1.va.home.com>; from guido@python.org on Fri, Apr 13, 2001 at 05:18:40PM -0500 References: <200104132218.RAA10759@cj20424-a.reston1.va.home.com> Message-ID: <20010415184121.A15535@tummy.com> On Fri, Apr 13, 2001 at 05:18:40PM -0500, Guido van Rossum wrote: >Python 2.1 is almost ready. We've built a release candidate -- a >version that should become the final version, barring any last-minute I've built a set of RPMs against 2.1c1, they're available at the same bat-place: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS/python2-2.1c1-1tummy.src.rpm and binaries for RedHat/KRUD 7.0 under: ftp://ftp.tummy.com/pub/tummy/RPMS/binaries-KRUD-7.0-i386 python2-2.1c1-1tummy.i386.rpm python2-devel-2.1c1-1tummy.i386.rpm python2-tkinter-2.1c1-1tummy.i386.rpm Enjoy, Sean -- Program *INTO* a language, not *IN* it. -- David Gries Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From robin at jessikat.fsnet.co.uk Mon Apr 2 05:29:44 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 2 Apr 2001 10:29:44 +0100 Subject: PEP: Use site-packages on all platforms References: Message-ID: In article , Moore, Paul writes ... If we're going to standardize locations I think it would be better for win32 platforms to use a single dlls directory either the current DLLs or lib/site-packages. That way the commonly used dlls (like libz.dll) could be placed in one standard location and then _imaging.pyd, zlib.pyd etc could refer to them. I'm not sure that this would work so well if there were two standard locations say DLLs for python only and lib/site-packages for everything else. Others have argued elsewhere that python20.dll needs to be in a common system wide location (ie winnt\system32 for similar reasons). -- Robin Becker From sholden at holdenweb.com Wed Apr 4 12:15:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 4 Apr 2001 12:15:00 -0400 Subject: Smtplib... References: Message-ID: "Vincent A. Primavera" wrote in message news:mailman.986388186.764.python-list at python.org... > Hello, > When sending mail with smtplib, how would you attach a file? > Here's some code which shows you how to use MimeWriter to build multipart messages. The graphic is encoded in Base64. regards Steve import MimeWriter, base64 # # Writes a multipart mail message: text plus associated graphic # mfile = "multimsg.eml" f = open(mfile, "w") # Create a MimeWriter mail = MimeWriter.MimeWriter(f) mail.addheader("From", "Steve Holden , Steve Holden """) mail.addheader("Subject", "The Python You Wanted") mail.addheader("Received", """from thinker [64.134.121.94] by mail.holdenweb.com (SMTPD32-6.04) id A244C78500BA; Fri, 09 Mar 2001 07:33:38 -0500""") # Mail will be multi-part: First part explains format part1 = mail.startmultipartbody ("mixed") part1.write("This is a MIME-encoded message, with attachments. " "If you are seeing this message your mail program probably cannot " "show you the attachments. Please try another program, or read 'Web " "Programming in Python' to see the attached picture." """ Sorry ... Steve Holden """) # Second part is intended to be read part2 = mail.nextpart() f = part2.startbody("text/plain") f.write("Here we have a multipart message. This " "means that the message body must be processed " "as MIME-encoded content where possible [which " "it clearly is in Outlook Express]." """ regards Your Humble Author """) # Third part is a graphic, which we encode in base64 part3 = mail.nextpart() part3.addheader("Content-Transfer-Encoding", "base64") f = part3.startbody("graphic/gif", [["Name", "python.gif"]]) b64 = base64.encodestring(open("pythonwin.gif", "rb").read()) f.write(b64) # Never forget to call lastpart! mail.lastpart() From tim.one at home.com Wed Apr 25 20:53:42 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Apr 2001 20:53:42 -0400 Subject: difflib In-Reply-To: <018401c0cb96$d87edea0$0301a8c0@josiah> Message-ID: [Tim] >> That's because you're trying to outguess nature, but SequenceMatcher is >> trying to outguess people: the latter doesn't care about the most >> efficient way to change X into Y, it wants to guess what a *person* >> probably did when changing X into Y by hand. [Andrew Dalke] > I think you might be surprised. Not a chance . > There are "optimal" sequence alignment programs but people will > modify the results by hand to make it look like what they expect. > The problem is that there is no true optimal solution, ending up > with sequence alignment programs which a lot of tunable parameters > and with humans modifying the results. Not surprised yet ... WRT your comments on my examples, yes, because "the usual" run of sequence alignment algorithms *does* have "a lot of tunable parameters", I'd be surprised if you *couldn't* usually get the same effect on specific examples via fiddling enough free parameters. ndiff has no free parameters, though, apart from a user-definable notion of what's uninteresting as a synch point. A more fundamental difference is that ndiff has an extremely strong notion of locality, which you'll *think* of as it effectively setting the cost for matching on junk to +infinity -- but that's just a way of trying to force it into a mold it didn't come from. It's really not trying to minimize a global cost function (although I could dervive a global cost function it *does* minimize, that would be quite a strain). > ... > Biological sequence alignment programs don't like breaking up > regions into lots of parts because it's more likely to destroy a > coding region, or break an important structure. So they introduce > gaps and penalities associated with different types of gaps (creating > a gap, increasing the size of a gap, adding to the beginning or end). > These usually turn out to make this more like what people expect. I could repeat that you're trying to outguess nature and ndiff isn't, but somehow I don't think that would help . > And you haven't seen the *hours* people will spend to align sequences > by hand. I know at least one case where someone became a coauthor > on a paper because the hand aligment he did proved very insightful. > (This was for a multiple sequence alignment which is an NP problem > and can't be solved optimally for more than about a dozen sequences.) I've seen the hours people spend aligning sequences by hand in speech recognition work, and at several levels (like aligning hypothesized phoneme sequences to signal features, then aligning hypothesized word sequences to phoneme sequences, etc). People learn a lot from doing that by hand, although doing it by hand hasn't been very practical in products . nidff's algorithms isn't suitable for any phase of that either, btw. > ... > We've got nothing that could be used for this any time soon, and > anything we're likely to do will be optimized for aligning letters, > not words or lines. I was just surprised not to have heard of the > alignment method before. You shouldn't be! Last I looked, there were over 100 distinct algorithms in the literature just for finding out where one string starts in another string. Many people have heard of Boyer-Moore and Knuth-Morris-Pratt, but they're just a drop in that bucket. Keeping up with *everything* that's out there is simply impossible. BTW, most people never heard of the sort algorithm Python uses either. the-history-bins-overflow-with-discarded-diamonds-ly y'rs - tim From jepler at inetnebr.com Tue Apr 24 16:24:37 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Tue, 24 Apr 2001 20:24:37 GMT Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> Message-ID: On 22 Apr 2001 15:52:23 -0400, Douglas Alan wrote: > jepler at inetnebr.com (Jeff Epler) writes: > >> This particular example can be done with very nearly the same syntax in >> standard Python---a dot instead of whitespace between let/set and the >> variable in question. > >> >>> import letset, __main__; letset.setup(__main__) >> >>> let.x = 3 >> >>> x >> 3 >> >>> let.x = 4 >> Traceback (most recent call last): > > Thanks for the ideas. I think my coworkers might kill me if I > programmed this way, though. > > How do I use this for local variables? Like so? [snip] I might write (all this is off the top of my head) import letset class NS: def __init__(self, **kw): self.__dict__.extend(kw) letset.setup(self) def add10(x): l = NS(locals()) l.let.y = 10 return l.x + l.y which eliminates one line of boilerplate, and gets the arguments into `l'. You could also do def ns(dict): x = NS(dict) return x.let, x.set, x def add10(x): let, set, get = ns(locals()) let.y = 10 return get.x + get.y A package like bytecodehacks plus custom importhooks might permit you to automatically insert the line of boilerplate. By the way, this is also a great way to get static function variables: def add10(x, static=NS(y=10)): return x + static.y From nessus at mit.edu Mon Apr 2 20:16:35 2001 From: nessus at mit.edu (Douglas Alan) Date: 02 Apr 2001 20:16:35 -0400 Subject: "Fastest growing programming language" References: <4b8y6.1297$bv.292187@typhoon2.ba-dsg.net> Message-ID: "David Allen" writes: > > What's the source for Python being the "fastest growing programming > > language"? Just curious. > Well, I don't want to disappoint you, but essentially there isn't > anything behind that statement. Nothing at all? It *is* now being prominently reported on www.python.org. > Whenever people speak in vague absolutes like "fastest", "best", > "most flexible", "best documented", etc, they're either lying to > you, or they're in marketing. True enough. But sometimes it is interesting to look at the data that they use to support their claims. Not because I want to be convinced of the claim, but just because the data is interesting in and of itself. |>oug From cribeiro at mail.inet.com.br Thu Apr 19 23:59:35 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Fri, 20 Apr 2001 00:59:35 -0300 Subject: With or Using In-Reply-To: <3addbc5a.680231093@news.okstate.edu> References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> <2b95c26c4a%tim@worthy.demon.co.uk> Message-ID: <5.0.2.1.0.20010420002753.0234c130@mail.inet.com.br> At 16:11 18/04/01 +0000, David C. Ullrich wrote: >It's in Delphi all right. Now find five Delphi experts and ask them >whether they think it's a good idea. I dont know if the expression "Delphi expert" applies to myself; however, I did happen to be a beta tester of Delphi 1 (when it was distributed in floppies :-). In Delphi, "with" is a good idea, but not so in Python. Why it is different? Because both languages have different type models. Delphi uses static types. So it is possible to know, in a unambiguous way, what member is being assigned in a "with" clause. This is important for both the compiler *and* the programmer. In fact, some Delphi experts may argue that the "with" construct should be avoided. I believe it is a matter of personal taste, because a careful read will always reveal wich variable (or member of) is getting assigned. Python uses dynamic types. It is impossible to know in advance which attribute will be referenced at runtime. Member attributes may be added or removed from objects on the fly. This would make it impossible to know, from a simple reading, what attribute is being read - a local one, a global one, or a member attribute. The same argument also applies to the use of self, that is mandatory on Python, but not on Delphi. In Delphi all you have is a implicit "with" clause on self on the beginning of every method implementation. Carlos Ribeiro From stephen_purcell at yahoo.com Tue Apr 10 06:59:35 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 10 Apr 2001 12:59:35 +0200 Subject: other python ideas In-Reply-To: <3AD2773F.599A4E5E@cosc.canterbury.ac.nz>; from greg@cosc.canterbury.ac.nz on Tue, Apr 10, 2001 at 03:00:15PM +1200 References: <3AD2773F.599A4E5E@cosc.canterbury.ac.nz> Message-ID: <20010410125935.A3975@freedom.puma-ag.com> Greg Ewing wrote: > We'd lose some of the WYWIWYG (What You Write Is What > You Get) nature of Python. (Readers please note that this acronym can most easily be pronounced with a mouth full of toothpaste.) -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From piet at cs.uu.nl Sat Apr 28 14:15:58 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 28 Apr 2001 20:15:58 +0200 Subject: catching the output of system() References: <3AE7C913.E422DA70@wipro.com> Message-ID: >>>>> Praveen Pathiyil (PP) writes: PP> If any one has any ideas on this or any more elegant methods of doing this, PP> please help me out. Use popen. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From tim.one at home.com Thu Apr 12 02:05:15 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 12 Apr 2001 02:05:15 -0400 Subject: I come to praise .join, not to bury it... In-Reply-To: <15061.3923.391858.6606@anthem.wooz.org> Message-ID: [Barry A. Warsaw] > ... > When phrased as: > > SPACE = ' ' > SPACE.join(somelist) > > it did, and still does, read very nicely to me, Same here! > so I included it in the string methods patch. Guido at least didn't > hate it, so it made it in. Your memory is correct here, but won't match Guido's. In Guido's mind, he *first* said: Funny, but it does seem right! Barry, go for it... (on Mon Jun 14 10:46:37 1999). Your msg saying it was in the string methods branch didn't get sent until Mon Jun 14 14:47:37 1999, and I'm sure Guido can't imagine why it took you 4 hours to comply . > ... > As a function in the string module, the name `join' gives no clue > as to whether the sequence comes first and the joining string > comes second, or vice versa. I often got it wrong, or had to look > it up. To me, that's a pretty big Pythonic sin, and I don't like > it. I don't think that's a coincidence: join was alone among the string module functions in not taking a string argument *first* (similarly the re module functions take "the regexp" first, etc). Since functions in the string module were *conceptually* methods on strings, there was no choice but to turn string.join(seq, sep) into sep.join(seq) <0.9 wink>. "-".join("some random signoff string ly".split())+" y'rs - tim" From moshez at zadka.site.co.il Sat Apr 7 01:49:34 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 07 Apr 2001 07:49:34 +0200 Subject: Anyone able to compare the commercial IDEs available? In-Reply-To: <9akseh$ncs$1@newsreaderm1.core.theplanet.net> References: <9akseh$ncs$1@newsreaderm1.core.theplanet.net> Message-ID: On Fri, 6 Apr 2001, "Franz GEIGER" wrote: > I'm aware of three commercial IDEs for Python: > -- PythonWare > -- BlackAdder > -- Komodo I'm not sure what you mean by "commercial". Komodo is Open Source, so why didn't you list IDLE and PythonWin too? In any case, there's also WingIDE. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From cribeiro at mail.inet.com.br Wed Apr 18 08:00:31 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Wed, 18 Apr 2001 09:00:31 -0300 Subject: High idle load under winsdows In-Reply-To: <9bjrhd$2ps4p$1@hades.rz.uni-sb.de> Message-ID: <5.0.2.1.0.20010418084145.0212a8d0@mail.inet.com.br> At 10:50 18/04/01 +0000, Mario Premke wrote: >Hi, I have a python application running under windows which takes >half of the CPU time when being idle. The idle main-loop does a >self.ProcessIdle ... Is it possible that this function consumes so >much CPU power ? There are no other processes in the background >and the application is definetely doing 'nothing' !! Idle loops may consume a lot of CPU time, specially if you don't cooperate with Windows. You have to use some (and preferably many) of the techniques below to make sure that your program does not burn all available CPU time running in circles: a) even if your application is very simple (its not a "true" windows application), it is a good idea to call pythoncom.PumpWaitingMessages() inside the busy loop. This call will give back control to Windows, giving the other applications a chance to run. In some programs of mine, I have some big files to read and process line-by-line. One time at every 1000 lines I make such a call. The program runs a bit slower, but the overall behavior of the OS is much better. It also makes it easier to debug, because it is easier for the debugger to interrupt into the running code (the debugger needs to get its events also :-) b) it your program does not use the Windows message queue, AND if you are explicitly waiting for input (for instance, reading a line character by character), you should call pythoncom.PumpWaitingMessages() inside the loop, at *every* iteration. c) in some cases, your application may "sleep" for a given period of time. There are some practical ways to make it: using the select call; using a timer; using the sleep call; etc. (i'm surre you can discover other ways to do the same). If you are waiting for some data to arrive on a file-like object, select is a nice way to make it. If you application is completely event-driven, a combination of the techniques above will spend *insignificant* time on the main loop. Carlos Ribeiro From dbrueck at edgix.com Wed Apr 11 11:21:28 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Wed, 11 Apr 2001 09:21:28 -0600 Subject: ActiveState going the wrong way Message-ID: <0a6f01c0c29b$20e6f420$450514ac@PRODUT2KDAVE> "Maniac" wrote in message news:45m0b9.fem.ln at alltel.net... >> Lack of autocompletion tends to _encourage_ laziness and _lower_ >> productivity. >I strongly disagree lack of autocompletion will in the short run (in your >words lower productivity) but will also increase the skill of the >programmer by forcing you to look up functions and other such stuff that >you accidently store in your brain and you are EGAD "forced" to learn >something that the next time you're coding you happen to remember the >function. Huh? Having to look it up doesn't make you learn anything - I've watched people load up the same man page over and over and over again. I guess it might develop your librarian skills but beyond that... Whether or not I learn or remember something after looking it up is completely dependent on me and independent of the presence or absence of autocompletion. >I have yet to find a "useless" comment. Any documentation in source code >helps Nope. Here's an unmodified snippet of code I came across not too long ago: lpPool->iFlags=aFlags; /* set flags */ lpPool->iSize=aElementSize; /* set size */ Do these help? No, these comments add no value. Worse, because they are present, as you scan through the code you end up reading them just because they are there. It slows you down and clutters the code. So the original programmer wasted time putting them there and everyone else who reads the code wastes time reading them. In Python, beyond docstrings and some level-of-intent comments near blocks of code whose purpose/function is not instantly clear, you don't need much else. (and if the code's purpose/function isn't instantly clear, it's often because the code is sloppy and needs to be rewritten). >Yes it might be redundant now but starting another project and then >returning to the "old" code base (when you now have a whole new mindset) >w/o documentation (I don't care how "descriptive" function names you use) >still requires a re-learning curve and the comment might trigger something >that your all-encompassing descriptive function name wouldn't. I'm not against well-placed level-of-intent comments, but comments that exist because the programmer was too lazy/dumb to choose descriptive names. Another common example I've seen: int i,j,k; // i is the page index, j is the paragraph index, and k is the word index Bleh. You're fired. :) -Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian at sweetapp.com Sun Apr 15 04:11:45 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 15 Apr 2001 01:11:45 -0700 Subject: how to import from variable source In-Reply-To: <987276923.21232.0.camel@ZOOstation.cc> Message-ID: There is probably a better strategy but it is hard to guess what that would be based on the information given. That said, there is a built-in function named "__import__" that does what you want: >>> print __import__.__doc__ __import__(name, globals, locals, fromlist) -> module Import a module. The globals are only used to determine the context; they are not modified. The locals are currently unused. The fromlist should be a list of names to emulate ``from name import ...'', or an empty list to emulate ``import name''. When importing a module from a package, note that __import__('A.B', ...) returns package A when fromlist is empty, but its submodule B when fromlist is not empty. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Rob Brown-Bayliss Sent: Saturday, April 14, 2001 12:35 PM To: python-list at python.org Cc: python-list at python.org Subject: how to import from variable source Hello I am building a shell type app that imports modules depending on the users actions. I do not want to have the import routines hard coded, rather I would like to import from a variable like so: module = 'mymod' import module Only, as I found out I get an error stating that there is not module called module. Is this possible in python? Is there a better way perhapse? Thanks, -- Rob Brown-Bayliss ---======o======--- www.ZOOstation.cc -- http://mail.python.org/mailman/listinfo/python-list From paul.moore at atosorigin.com Fri Apr 20 10:57:26 2001 From: paul.moore at atosorigin.com (Paul Moore) Date: Fri, 20 Apr 2001 16:57:26 +0200 Subject: ActivePython 2.1 (build 210) References: <31575A892FF6D1118F5800600846864D78BB05@intrepid> Message-ID: <7l0fmx9s.fsf@atosorigin.com> Paul Prescod writes: > There are more changes in the win32 extensions, including many bug fixes > and support for "Universal COM Gateways". The release notes say that ActivePython 210 comes with win32all build 135. This comment implies that it comes with build 139. I *hope* it's 139 - it seems silly that I should have to install win32all on top of ActivePython... Can you confirm that build 139 is the one included? How could I check? Paul. From francois.granger at free.fr Sun Apr 8 15:49:28 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sun, 08 Apr 2001 19:49:28 GMT Subject: (begginer) issue with pickling class objects Message-ID: <1erkb15.lyucf01q71a0dN%francois.granger@free.fr> I send below a simplified version of the code I am writing. When I run it I get the following error message: 'Failed to import class B from module __main__' I tired an alternative wich is commented out (line 44-51 , 61 and 65) but the error message is similar with a reference to class A. I am guessing that this is an issue with namespace that I don't really understand. On a similar track, I would be happy to see a more general algorithm to implement persistence of complexe objects between runs. TIA ======================================================== # python """ Simple test of pickling complex objects """ import pickle class A: """ """ id = 0 def __init__(self): A.id += 1 self.value = 0.0 self.id = A.id def __repr__(self): return str(self.__dict__) + '\n\n' def activate(self): self.value += 1.0 class B: """ """ def __init__(self, ninput = 10, noutput = 10): self.ninput = ninput self.noutput = noutput self.input = {} for i in range(self.ninput): self.input[A.id] = A() self.output = {} for i in range(self.noutput): self.output[A.id] = A() def transmit(self): for i in self.input.keys(): self.input[i].activate() for i in self.output.keys(): self.output[i].activate() """ def save_NN(self, fp): pickle.dump((self.input, self.output), fp) pass def load_NN(self, fp): #set neuron.id to max id ? self.input, self.layer, self.output = pickle.load(fp) pass """ if __name__ == '__main__': inp = 10 out = 10 N = B(inp, out) for i in range(5): N.transmit() fp = open('neuronet.txt', 'w') #N.save_NN(fp) pickle.dump(N, fp) fp.close() fp = open('neuronet.txt', 'r') #N.load_NN(fp) N = pickle.load(fp) fp.close() pass ======================================================== -- [fr, en, es, ia] Information sur la hi?rarchie usenet europa.* : http://europa.usenet.eu.org From hbl at st-andrews.ac.uk Thu Apr 19 04:24:10 2001 From: hbl at st-andrews.ac.uk (Hamish Lawson) Date: Thu, 19 Apr 2001 09:24:10 +0100 Subject: Zope wins Jolt Productivity Award Message-ID: <022501c0c8aa$67fe79e0$0885fb8a@stand.ac.uk> Zope has won a Productivity Award in Software Development magazine's annual Jolt Awards. http://www.sdmagazine.com/features/jolts/ Hamish Lawson From benjamin.altman at noaa.gov Tue Apr 17 10:15:06 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Tue, 17 Apr 2001 10:15:06 -0400 Subject: do...until wisdom needed... References: Message-ID: <3ADC4FEA.2664FDF7@noaa.gov> While I wouldn't care either way for a loop.. until construct, I don't quite see how it is so complicated. Even the c equivalent isn't that complicated - it is almost intuative. Someone in this thread mentioned that they needed to go back to k&h to recall it and I can't quite understand why (even though you might say that recollection and simplicity are mutually exclusive). Ben. Steve Lamb wrote: > On Mon, 16 Apr 2001 23:05:10 -0700, Ken Peek wrote: > >Thanks to all for all of the great suggestions! > > > >To the "others", I say: > >"If the only tool you have is a hammer, then every problem looks like a > >nail."-- Happy nailing! > > It seems you me you're the one with a lot of wood for do..until even > though it has been explained why it is a bad thing. > > -- > Steve C. Lamb | I'm your priest, I'm your shrink, I'm your > ICQ: 5107343 | main connection to the switchboard of souls. > -------------------------------+--------------------------------------------- From bww00 at amdahl.com Tue Apr 3 17:58:47 2001 From: bww00 at amdahl.com (Bryan Webb) Date: 03 Apr 2001 21:58:47 GMT Subject: LZW routines in python Message-ID: <9adh2n$cfh@dispatch.concentric.net> Hi, I'm looking for LZW compress/decompress routines written in python. Thanks Bryan Webb fujitsu technoloy From fredrik at pythonware.com Sat Apr 7 08:26:51 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 07 Apr 2001 12:26:51 GMT Subject: Import confusion References: Message-ID: Kristian Ovaska wrote: > Now, this prints 10. I'm confused. Could someone explain what's going > on? http://effbot.org/guides/import-confusion.htm Cheers /F From shawkins at imsconsultants.com Sun Apr 29 23:20:50 2001 From: shawkins at imsconsultants.com (Steve Hawkins) Date: Mon, 30 Apr 2001 03:20:50 GMT Subject: Using wxPython Resource Utilities Message-ID: I would like to make use of one of the wxWindows resource editors with Python. As near as I can tell, there currently 2 available. There's the wxWindows Dialog Editor that comes with the wxWindows distribution (at least the Win32 one) and there's a commercial product called wxDesigner. Can anyone recommend one over another? Also, after reading through the documentation, I have not found a sample of how to use a dialog editor resource file (.wxr) in a Python script (although there's a good example of using one in a C++ program). Any help would be appreciated. Steve Hawkins From aleaxit at yahoo.com Thu Apr 26 11:59:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Apr 2001 17:59:33 +0200 Subject: how to explain this memory usage References: <3dpudzu4ij.fsf@ute.cnri.reston.va.us> Message-ID: <9c9gl602dbh@news2.newsguy.com> "Andrew Kuchling" wrote in message news:3dpudzu4ij.fsf at ute.cnri.reston.va.us... > javalist writes: > > also the interpreter has 20M in memory,but seems python knows they are > > pointing nothing and reuse these 20M when I try again allocating more > > object in python,it didn't increase memory until the first 20M is > > occupied by the new allocated object > > This is also dependent on your platform's malloc. The malloc used on > Linux, for example, uses mmap() for allocations above a given size, > and on freeing an mmap()'ed area, the process size drops. For > example, I just tried creating a 20Mb string, watched the process size > jumped appropriately, then deleted it and watched the process go back > to around 2Mb. I just tried and confirmed Python 2.0 works this way on Windows NT, too. As you say, it does depend on the platform library. > 20Mb of smaller objects probably won't have this > pleasant predictability. I'm not sure how enabling pymalloc would > change this picture. On NT, >>> x=[str(i) for i in range(100000)] makes python.exe's VM Size stat in the Task Manager jump up to over 7000K, and a "del x" now makes it jump back down to 2200K (was below 1000K before). Repeating this a few time confirms identical numbers (nothing's being leaked here). Alex From colinmeeks at home.com Fri Apr 27 15:17:40 2001 From: colinmeeks at home.com (Colin Meeks) Date: Fri, 27 Apr 2001 19:17:40 GMT Subject: Call a function using a variable Message-ID: Does anybody know if it's possible to do something along the following lines : myfunction="test" x=myfunction Basically what I want is when the x variable gets declared it get's it's data from the function test() I used to do this all the time in Clipper doing the following myfunction="test" x=&myFunction() Thanks. Colin From a-steinhoff at web.de Mon Apr 2 12:37:10 2001 From: a-steinhoff at web.de (a-steinhoff at web.de) Date: 2 Apr 2001 09:37:10 -0700 Subject: Why Parrot? References: Message-ID: <9aa9rm02bj0@drn.newsguy.com> In article , "szhao" says... > >After reading GvR's article and others, I can not figure out a strong reason >why Python 3000 ---> Parrot?, which introduces weird syntax (at least to >me). I am afraid that Parrot may hurt Python community. Hmm ... ActiveState is 'collecting' today the innovators of Perl, Python, PHP (and other languages ?). Python.NET? Perl.NET? PHP.NET? .... could it be that someone is trying to get control over these open source languages?? >From the ActiveState homepage: Upcoming Releases Microsoft Visual Studio plugins: Visual Perl and Visual Python Program on the .NET platform: Perl .NET and Python .NET Armin From fredrik at pythonware.com Thu Apr 5 04:09:39 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 05 Apr 2001 08:09:39 GMT Subject: PEP 245 References: Message-ID: <7LVy6.5454$4N4.1160812@newsc.telia.net> Remco wrote: > I just woke up and wrote something that looks too much like FUD. Never > mind, I don't really know what I'm talking about, just typing up a first feeling > about something, move along, nothing to see... umm. most of it sure made sense to me... > I'll try to wake up and do some investigating first... I'll go a get myself another cup of coffee... Cheers /F From fdrake at beowolf.digicool.com Sun Apr 22 02:08:22 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Sun, 22 Apr 2001 02:08:22 -0400 (EDT) Subject: [maintenance doc updates] Message-ID: <20010422060822.A3E4428A0B@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/maint-docs/ First attempt to push maintenance docs to the SourceForge site. From steven at haryan.to Fri Apr 13 04:44:10 2001 From: steven at haryan.to (Steven Haryanto) Date: Fri, 13 Apr 2001 15:44:10 +0700 Subject: calling superclass' method with list positional arg Message-ID: <4.3.2.7.2.20010413152500.02730960@202.53.255.51> My Bag's constructor accepts a list positional args to fill the object with initial data, so I can conveniently create a bag initially filled with stuff like this: mybag = Bag("apples", "oranges", "money") BagOTricks is a subclass of Bag, and it needs to do something else but let the superclass do the actual data filling. Currently I do it like this: class Bag: def __init__(self, *items): self._items = list(items) def add(self, item): self._items.append(item) class BagOTricks(Bag): def __init__(*args): self = args_[0] # do something else first... # then pass the items to superclass' constructor apply(Bag.__init__, args_) Is there an elegant way to do this so I can still declare Bag's __init__ as 'def __init__(self, *items)', but I don't need to create a temporary list like below? class BagOTricks(Bag): def __init__(self, *items): # do something else first... # then pass the items to superclass' constructor args = list(items) args.insert(0, self) apply(Bag.__init__, args) Thanks, Steve From s713221 at student.gu.edu.au Sun Apr 15 11:03:41 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Mon, 16 Apr 2001 01:03:41 +1000 Subject: Newbie needs book advice References: <3ad95301.6165759@news.prodigy.net> Message-ID: <3AD9B84D.A30BA5C5@student.gu.edu.au> throw_away_fish wrote: > > The O'Reilly book is phenom. Mucho-good-O. There are actually two > authors - they crack me up. Yes, they definatly have a wierd sense of humour. Must be Monty Python fans as well. *grins* From-a-Monty-Python-fan-as-well-'ly Joal Heagney/AncientHart From bkline at rksystems.com Wed Apr 25 08:27:11 2001 From: bkline at rksystems.com (Bob Kline) Date: Wed, 25 Apr 2001 08:27:11 -0400 (EDT) Subject: MySQSLdb: just guessing In-Reply-To: Message-ID: On Tue, 24 Apr 2001, Albert Wagner wrote: > I can find no docs for MySQLdb, so I am just guessing how to get going. Really? What about the docs that come with the distribution? What about the online docs? >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> import _mysql >>> print _mysql.__doc__ _mysql: an adaptation of the MySQL C API (mostly) You probably are better off using MySQLdb instead of using this module directly. In general, renaming goes from mysql_* to _mysql.*. _mysql.connect() returns a connection object (MYSQL). Functions which expect MYSQL * as an argument are now methods of the connection object. A number of things return result objects (MYSQL_RES). Functions which expect MYSQL_RES * as an argument are now methods of the result object. The mysql_real_* functions are the ones used in place of not-real ones. The various FLAG_*, CLIENT_*, FIELD_TYPE_*, etc. constants are renamed to FLAG.*, CLIENT.*, FIELD_TYPE.*, etc. Deprecated functions are NOT implemented. type_conv is a dictionary which maps FIELD_TYPE.* to Python functions which convert a string to some value. This is used by the fetch_row method. Types not mapped are returned as strings. Numbers are all converted reasonably, except DECIMAL. result.describe() produces a DB API description of the rows. escape_sequence() accepts a sequence of items and a type conversion dictionary. Using the type of the item, it gets a converter function from the dictionary (uses the string type if the item type is not found) and applies this to the item. the result should be converted to strings with all the necessary quoting. mysql_escape_string() on them, and returns them as a tuple. result.field_flags() returns the field flags for the result. result.fetch_row([n=0[, how=1]]) fetches up to n rows (default: n=1) as a tuple of tuples (default: how=0) or dictionaries (how=1). MySQL returns strings, but fetch_row() does data conversion according to type_conv. For everything else, check the MySQL docs. >>> import MySQLdb >>> print MySQLdb.__doc__ MySQLdb - A DB API v2.0 compatible interface to MySQL. This module is a thin wrapper around _mysql, which mostly implements the MySQL C API. All symbols from that module are imported. connect() -- connects to server type_conv -- dictionary mapping SQL types to Python functions, which convert a string into an appropriate data type. Reasonable defaults are set for most items, and you can add your own. See the API specification and the MySQL documentation for more info on other items. This module uses the mxDateTime package for handling date/time types. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > I need to know the args to connect(). >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> print MySQLdb.connect.__doc__ Connection(host=NULL, user=NULL, passwd=NULL, db=NULL, port=, unix_socket=NULL, client_flag=0) Note: This interface uses keyword arguments exclusively. host -- string, host to connect to or NULL pointer (localhost) user -- string, user to connect as or NULL (your username) passwd -- string, password to use or NULL (no password) db -- string, database to use or NULL (no DB selected) port -- integer, TCP/IP port to connect to or default MySQL port unix_socket -- string, location of unix_socket to use or use TCP client_flags -- integer, flags to use or 0 (see MySQL docs) conv -- dictionary, maps MySQL FIELD_TYPE.* to Python functions which convert a string to the appropriate Python type Returns a Connection object. Useful attributes and methods: db -- connection object from _mysql. Good for accessing some of the MySQL-specific calls. close -- close the connection. cursor -- create a cursor (emulated) for executing queries. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Doesn't look to me as if Dustman was stingy on the documentation. > Anything at all will be really helpful. Thanks ahead for any > advice. No problem. Thank Andy for doing such a good job of documenting his module. :->} -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com From aahz at panix.com Wed Apr 11 19:28:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Apr 2001 16:28:39 -0700 Subject: converting string to dict ? References: Message-ID: <9b2pb7$aq$1@panix6.panix.com> In article , Jason Cunliffe wrote: > >A web input form passes {'name':'Cleopatra'} as a string. >Please, is there a nice clean function to convert this string to a dict? Redesign your web form. Seriously. At the very least, change this to use a single delimiter between key and value, such as name/Cleopatra More conversion work (slightly), but much, much, much safer. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From sam.at.ddmweb.dot.com at classicrock.ddmweb.com Fri Apr 27 12:35:15 2001 From: sam.at.ddmweb.dot.com at classicrock.ddmweb.com (Sam Penrose) Date: Fri, 27 Apr 2001 09:35:15 -0700 Subject: pyapache anyone Message-ID: <01042709441802.05818@frock.ddmweb.com> Nell'articolo , "Sam Penrose" ha scritto: > PyApache 4.19 was broken with a memory leak that appeared after on the > order of 100,000 dynamic requests on our site (RedHat 6.1 on Intel, > Apache1.3.9 Red-Hat-Secure/3.1 mod_ssl/2.4.10 OpenSSL/0.9.4) . I sent > Lele a bug report at the address listed in the docs a year ago; the > address he gave at that time (lele at integra.it) failed with a "too many > hops" message. There was also a mailing list that didn't work. I finally > posted to comp.lang.python and got confirmation from another user. > > Lele, did you ever get wind of such a leak? > Lele ha scritto: > No, I wasn't aware of it. Do you have any simple/self-contained script > that triggers the problem? Nope. We used it for months in preproduction, then went live and the site was a lot busier than anyone expected. The failure was catastrophic, and all we were interested in was making the site work again. We've since gone to a cluster. Coincidentally, google just restored Deja's Usenet archive, so you can see the thread I spawned and the confirmation I got at the end of it from "seant at iname.com": "I've just completed a couple of overnight thrashing tests. Serving 400,000 pages or so appears to leak about 400MB of memory. This amounts to about 1kb per page invocation. Each page was served by PyApache. The system tracking tool on Linux showed the 10 or so httpd processes that had been spawned as having grown to about 40MB each." (or search for PyApache in comp.lang.python in April of last year). From sholden at holdenweb.com Wed Apr 18 19:40:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Apr 2001 19:40:40 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: "Douglas Alan" wrote in message news:lcvgo2hzfk.fsf at gaffa.mit.edu... > "Steve Holden" writes: > > >>>> [|>oug:] $#@# you too. > > > Woops! > > >>>> [|>oug:] You are very rude. > > > No problems here. > > > As you might now guess, I wasn't complaining about you calling him rude ... > > You mean you are upset that I said to Alex, > > Love you too. > > And then blotted out the "love", lest anyone be offended by > homoeroticism? > Absolutely right. Nice to see your sense of humor re-emerging. regards Steve From dougfort at downright.com Sun Apr 15 16:38:17 2001 From: dougfort at downright.com (Doug Fort) Date: Sun, 15 Apr 2001 16:38:17 -0400 Subject: Python Performance vs. C++ in a Complex System References: Message-ID: <3ADA06B9.A2292921@downright.com> Our website load testing system system, http://www.stressmy.com is very much like an agent-based simulation. My experience in running on Linux is that the system bogs down on a few hundred threads. (This is the 2.2 kernel, 2.4 is supposed to be better). We recently started using select() in a single threaded model for this reason. What platform are you running on? How many threads did your prototype manage? Courageous wrote: > I've been recently working on a agent-based simulation system which is > intended to run with massive numbers of threads in the 15,000-30,000 range. > > In my initial prototype of the system, I selected Python with Continuations > as a base, and crafted the simulation core in about two man-weeks. This > core performed well enough at the time, but certain that I could do better, > I decided to use the Python core as a proof-of-concept, and rewrote the > core in C++. This took approximately eight man-weeks of my time and was > quite labor intensive. > > Having completed both cores, and with the C++ core HIGHLY OPTIMIZED, > I was finally able to perform a performance test of the the C++ system > versus the Python system. To my surprise, the C++ core only beat Python > by about 30%. Given the obvious inequities in coding time in both efforts, > plus whatever future coding time inequities I might project onto users of > either core by implication of the programming language, I was quite > surprised by these results. > > In retrospect, it's the lack of a true continuation model in C++ which is to > blame. The C++ implementation suffers from extensive context-switching > burden, having to frequently swap out all the registers and manage the > stacks for all the threads, whereas Python-with-Continuations does not. > > This was an interesting outcome, which I'm still exploring. > > It may very well be that the C++ system shows better gains when the > performance tests involve non-trivial code in the threads. > > However, it's still remarkable that a Python implementation of a relatively > complex system like this one (an massively-parallel agent simulator), > could come as close to C++ so easily. > > One caveat: to those who know simulation engines, the priority heap > at the heart of the Python system was an optimized C-extension. > > Joe Kraska > BBN Technologies > San Diego CA -- Doug Fort Senior Meat Manager Downright Software LLC -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkraska1 at san.rr.com Sun Apr 22 12:39:41 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 22 Apr 2001 16:39:41 GMT Subject: memberfunctions References: <9bv0vn$nr$06$1@news.t-online.com> Message-ID: >I've read the tutorial about adding new types with Python/C, but how to add >memberfunctions and membervariables ? Get a python source distribution. In the objects/ directory you will find a file: XXOBJECT.C. This is an example of how to create what you want. You should also read the "Extending & Embedding" section at http://www.python.org. The book __Essential Python Reference__ has the best section on extending and embedding I've seen so far. When you first look at the object-creation stuff, you may think it looks a bit hard. It's not really. It's just verbose, and very formulaic. The good news is, once you've learned one object, you've pretty much learned them all. There's little variation between objects, except with regards to the choice of interfaces (list, et al) you make. You may eventually want to read the code for Python's dictionary and list: LISTOBJECT.C and DICTOBJECT.C. Python's own containers are written in the very same code one uses to create a custom user object. Pay careful attention to reference counting. The smallest error in this respect will either cause the interpreter to crash or assure that your object is NEVER freed (during the life of the interpreter, anyway). C// From robin at stop.spam.alldunn.com Tue Apr 24 15:46:15 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Tue, 24 Apr 2001 12:46:15 -0700 Subject: Making a python extension in c++ References: <988067008.220977@db.lineo.com> <3ae58431@news.iprimus.com.au> <988130036.370566@db.lineo.com> Message-ID: <5JkF6.379$GdX.58261692@news.randori.com> > Hmmm. This is true, but I am thinking this is a failure of the > Makefile.pre.in script to handle the extension ".cc" > Try it with distutils instead. In most cases it handles building C++ extension modules with no problems. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From sholden at holdenweb.com Thu Apr 26 11:20:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Apr 2001 15:20:59 GMT Subject: Python IMAP Server Code? Message-ID: Does anybody have any IMAP server code I could lift? This is because I have finally given up on reverse-engineering Outlook Express' bizarre mail folder format, and am now taking an alternative approach. This will use a localhost-only IMAP server on the same host as the mail client to allow transfer of mail messages into a more sensible repository. Any help gratefully received. regards Steve From dalke at acm.org Tue Apr 10 11:28:14 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 10 Apr 2001 09:28:14 -0600 Subject: 'mapping' in weakrefs unneeded? References: <9amdk2$82i$1@slb0.atl.mindspring.net> <9atmoq$dji$1@nntp9.atl.mindspring.net> Message-ID: <9av9ch$la0$1@slb7.atl.mindspring.net> Michael Hudson: >You could try just emailing Fred Drake, as weak refs are his baby to >some extent. Doing after 2.1 is released might work better... I did. He asked I bring it up on python-dev, which got no response so I tried here in c.l.py. I would prefer pre-2.1 since removing a function (which is used in the docs as an example of how to use weakrefs) after release will be met with "removing a function breaks existing code" arguments. Andrew dalke at acm.org From bos at hack.org Thu Apr 19 22:46:55 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 20 Apr 2001 04:46:55 +0200 Subject: Newbie Quest. KSpread/Python References: <3add511c$0$25491$7f31c96c@news01.syd.optusnet.com.au> Message-ID: <3ADFA31F.A5795C2@hack.org> James Park wrote: > I know that the answer is in front of me but could someone please point me > in the right direction ?? http://www.kde.org/kdeslides/Usenix1998/tsld029.htm -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From phrxy at csv.warwick.ac.uk Thu Apr 12 21:11:42 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 13 Apr 2001 02:11:42 +0100 Subject: OT - Closing Off An Open-Source Product In-Reply-To: References: <20010411183525.P754-100000@open-systems.net> <3AD4F4FB.3D13F205@ActiveState.com> Message-ID: On Wed, 11 Apr 2001, Chris Gonnerman wrote: [...] > that the "hacker ethic" is the real protection here anyway, because if > a "big guy" steals a major piece of, oh, say, Apache and incorporates it > in a closed source program, it's darn hard to prove. [...] If you suspected it was happening, you could look for the bugs. There are many different ways to have bugs in your programs, as many of us have discovered, so a relatively small bug collection is a good fingerprint. John From thomas at xs4all.net Thu Apr 5 21:10:14 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 6 Apr 2001 03:10:14 +0200 Subject: list vs tuple In-Reply-To: <7Oiy6.1311$p5.4876@news1.rivrw1.nsw.optushome.com.au>; from root@smtp6.xs4all.nl on Tue, Apr 03, 2001 at 11:50:27AM +0000 References: , <3AC20CD3.265A2D94@alcyone.com><71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com><7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> <4Lrx6.1055$p5.4170@news1.rivrw1.nsw.optushome.com.au> <7Oiy6.1311$p5.4876@news1.rivrw1.nsw.optushome.com.au> Message-ID: <20010406031014.F2820@xs4all.nl> On Tue, Apr 03, 2001 at 11:50:27AM +0000, deadmeat wrote: > I'm so used to treating bytes (or char's) as 8 (or 7) bits alone. Having a > high level language such as Python automagically wrap basic data types into > objects without me having to do it seems unnatural, given my background. Sorry, but this boggles me. You choose for a high level language (in fact, for a *very* high level language) but you *don't* want it to do highlevel stuff for you. That's.... inconsistent. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From neelk at alum.mit.edu Thu Apr 19 20:22:04 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 20 Apr 2001 00:22:04 GMT Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bk75c02j95@news1.newsguy.com> Message-ID: On Wed, 18 Apr 2001 16:07:29 +0200, Alex Martelli wrote: >"Neelakantan Krishnaswami" wrote in message >news:slrn9dpnnd.hs0.neelk at alum.mit.edu... >> On Tue, 17 Apr 2001 00:03:38 +0200, Alex Martelli >wrote: >> > >> > Yes, 'hygienic macros' WOULD help cut these discussions short. Pity >> > this benefit (basically restricted to c.l.p) would be balanced by >> > the productivity loss engendered by the actual existence of such >> > macros in the language -- a language which may have ANY 'syntactic >> > feature' ensures any given program is impossible to understand >> > unless you first study the exact set of macros used by its >> > author:-). >> >> I note that precisely the same argument can be made about adding >> functions to a language. > > Reality easily proves that your "note" is a falsehood: despite the > existence of functions in Python, Usenet STILL buzzes with long > discussions by people who whine about Python not having their > favourite doodad. Their existence doesn't cut these discussions > short. So, how can you make this statement? Perhaps because you misunderstood what I actually wrote? That means I've not been clear, so I'll try again. > If the difference in power between functions and macros is not clear > to you, maybe a refresher in first-order versus higher- order logic > might help. This power applies to both discussion- cutting > abilities and confusion-generation potential. No, the difference between functions and macros is not at all clear. This is because the macro systems I am used to are all Turing complete. Likewise, having first-class functions makes the sublanguage with only lambda and function application Turing-complete. Specifically, consider the untyped call-by-name lambda calculus. In this system, a function application is equivalent to rewriting all of the bound variable references of the function with the term passed as an argument to the function. Simple enough. Now, imagine that we add a hygienic macro system to this language, in which we can describe a syntactic form and what it is rewritten into. So the order of evaluation of this language is: 1. Expand the macros, avoiding variable capture through hygiene. 2. Evaluate the function applications, avoiding variable capture through lexical scoping. Now, observe that in the pure call-by-name lambda calculus, the order of evaluation of the terms does not matter. All you have done by introducing a macro system is to add a synonym for lambdas and function application. This property is called confluence, and the proof is called the Church-Rosser theorem. I'm sure you know this, of course, but somewhere out there there's a college student out there who is being shocked that CS is actually turning out to be relevant, for sufficiently small values of relevance. :) This is what I mean by "precisely the same argument can be made about adding functions to an imperative language." If you find this unconvincing, let me point out that the precisely the same difficulties are encountered marrying dynamic linking with either of inline functions or macros. Furthermore, it's a very common style in Scheme to write a higher-order function and then provide a macro as syntactic sugar for it, relying on the compiler to eliminate the unneccessary closure allocation. Theory, compiler engineering, and programming practice all coincide here; I don't know of any more convincing argument that the presence or absence of a macro system is a matter of engineering and user interface design, not of any fundamental semantic differences. The engineering considerations are vitally important, of course. I know a number of people that won't consider moving from Lisp because they can't meet their performance targets without the ability to specify to the compiler the transformations needed to make the clear and maintainable version of their program run with acceptable speeds. The same thing is even true with C++ -- there are a lot of people who are absolutely dependent on template metaprogramming to enable the maintainable versions of their programs to perform acceptably. I'm really surprised you consider any of this controversial. Neel From aleaxit at yahoo.com Sun Apr 22 17:55:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 22 Apr 2001 23:55:44 +0200 Subject: Python-2.1 Debug libs zip is missing tcl &tk debug libs References: Message-ID: <9bvk0o01hgt@news2.newsguy.com> "Kevin Rodgers" wrote in message news:ASHE6.43930$EN.1398920 at news1.rdc1.sdca.home.com... [snip] > I'm working on embedding Python on Win32, and I just use the binary > installer for Python. But I don't use the Windows "debug" mode anyway; I'd > have to build debug versions of Numeric, Tkinter, Tcl/Tk, BLT, ad nauseam. Seconded!!! Further, any OTHER library you might be using in your app, even ones totally unrelated to Python, should also be rebuilt in 'debug mode' (specifically: so it uses the "Debug multithreaded DLL", MSVCRTD.DLL, as its C Runtime). A major bother. > Instead, I use the "release" project and change the settings so that it > generates full debug information. Since the errors I find during debugging > are invariably in my code, not Python's, I don't need to trace into Python > anyway. ...nor presumably in Microsoft's C Runtime (which is the real purpose of MSVCRTD.DLL -- it also provides slightly better diagnostics for some pointers overwritings and memory leaks, but not really good ones anyway -- numega's boundschecker, devpartner, or however they're calling it this week is advisable if you DO need help for the diagnosis of such issues). > real-programmers-debug-using-print-statements-ly yr's-kevin ...or the Windows equivalent, the OutputDebugString API -- you can also call it in Python, with win32all extensions. With the help of some auxiliary utility or system-level debugger, it lets you see messages from your code *no matter how* it may be running -- as a COM server, NT service, or any other situation where using something as invasive as an interactive debugger is out of the question (and you typically don't have stdout or stderr pointing to anything usable -- besides, with OutputDebugString you can see messages from various languages correctly intermixed in the order in which they were sent, etc). The skill a typical "real programmer" develops to put in just the right amount of debug-calls with just the right amount of information in each then really comes in handy, of course!-) Alex From news at myNOSPAM.org Fri Apr 13 21:37:42 2001 From: news at myNOSPAM.org (Ixokai) Date: Fri, 13 Apr 2001 18:37:42 -0700 Subject: Reasoning on no __debug__ =1 ? Message-ID: <3ad7a7f0_4@goliath2.newsfeeds.com> I'm just curious on the reasoning for it. I've done it in the past when I wished to turn my debugging output on or off during the course of a long-running program for .. debugging .. purposes. It's not a big deal, I'll just 'if debug:' for now on in that situation... I just don't see the value of not letting us override the -O flag if situation warrents... seems unPythonic since Python has a tendency to let us do all sorts of absurd and nasty things if we misbehave. *grin* *runs* --Stephen (replace 'NOSPAM' with 'seraph' to respond in email) -----= 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 bkline at rksystems.com Tue Apr 3 09:03:24 2001 From: bkline at rksystems.com (Bob Kline) Date: Tue, 3 Apr 2001 09:03:24 -0400 (EDT) Subject: Python and Java Compared? (fwd) Message-ID: Forwarding this to the list, for the benefit of the original poster asking for this information. -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com ---------- Forwarded message ---------- Date: Tue, 03 Apr 2001 18:27:29 +0700 From: Steven Haryanto To: Bob Kline Subject: Re: Python and Java Compared? At 4/2/2001 11:09 PM, you wrote: >For straight CGI I find Python easier to get things up and running >quickly. Both have solutions (see Zope and JSP) which don't require >launching a new process for each request if you need this for >performance. Don't forget mod_python/mod_snake, WebWare, Quixote, PCGI/FastCGI, etc. I think Python offers more choices in the area of server-side scripting. Steve From tjg at exceptionalminds.com Thu Apr 12 14:29:54 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 12 Apr 2001 11:29:54 -0700 Subject: Escaping strings to be used in shell commands? In-Reply-To: <9b4psl$3uh$1@laurel.tc.umn.edu>; from brian@brian.cbs.umn.edu on Thu, Apr 12, 2001 at 05:50:13PM +0000 References: <9b4g2j$2tm$1@laurel.tc.umn.edu> <9b4psl$3uh$1@laurel.tc.umn.edu> Message-ID: <20010412112954.R17435@trufflehunter.avalongroup.net> On Thu, Apr 12, 2001 at 05:50:13PM +0000, Brian Langenberger wrote: > Timothy Grant wrote: > > > > :> Try checking into the crypt or md5 modules and try encrypting the > :> password from within python. Someone might actually want their > :> password to be ";rm -rf *", which is harmless to pass to crypt() > :> but undesirable to send to os.system(). > > : Even given this caveat, the md5crypt module will generate > : strings that can't be passed directly to os.system()--the > : dollar signs must be escaped. Having just been through this a > : couple of weeks ago, the following regex solved the problem. > > : re.sub(r'\$', '\$', password.) > > That's better, of course, but I'm all in favor of not putting > passwords, hashed or otherwise, through os.system() whatsoever. > Any command-line arguments can show up in "ps", and having that > sort of info flying around can't be a good idea. > > I figure, if you need to update passwords from a Python app, just > build the app to update the requisite /etc files itself. > As flat text, Python should gobble them up without a hitch. I've been having all sorts of fun with Python and the pwd and grp modules recently. I'll probably have a complete password user/group/password management system done fairly soon. But in the meantime os.system has had to suffice. However, I am curious why there is more a problem with an app calling the useradd command, than there is with an admin issuing a useradd from the command line? -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 15 days 20:37 hours ago<< From greg at cosc.canterbury.ac.nz Fri Apr 6 00:14:27 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 06 Apr 2001 16:14:27 +1200 Subject: "not x in" vs. "x not in" References: Message-ID: <3ACD42A3.DFE40255@cosc.canterbury.ac.nz> Kristian Ovaska wrote: > > Why is there a "not in" operator? For clarity? Speed? x not in y is one operation, not (x in y) is two. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From nperkins7 at home.com Tue Apr 24 23:55:09 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 25 Apr 2001 03:55:09 GMT Subject: Crystal Space 3D Library References: Message-ID: Apparently, Python can be used with the Crystal Space cross-platform 3D library, which works very well. http://crystal.sourceforge.net It seems also to use Python for config files. That's all i know about it. I would like to hear from someone who has used Python with Crytal Space. From erno-news at erno.iki.fi Sun Apr 22 09:44:16 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 22 Apr 2001 16:44:16 +0300 Subject: GetTickCount vs. clock for msec resolution References: <8f7vdtk3ukd35mbr15bass72mg2erf95ks@4ax.com> <3ADFCB0C.6040706@ActiveState.com> Message-ID: In article <3ADFCB0C.6040706 at ActiveState.com>, Mark Hammond writes: | I believe that in general, if better timers for a platform become known | they will be used in time.clock() so the profiler sees better | resolution. Therefore this is probably the safest function to use. at least on linux, clock() has very poor (timer interrupt, 100hz on x86) resolution and time.time() has ~1 microsecond resolution. -- erno From tim.one at home.com Fri Apr 20 21:35:42 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 20 Apr 2001 21:35:42 -0400 Subject: Cygwin Python Distribution (was ANNOUNCE: Python 2.1 final release) In-Reply-To: Message-ID: [Clark C. Evans] > This is interesting. From what I understand, if you link > against cygwin.dll, the software must be released under > the GPL. http://www.cygwin.com/licensing.html appears to go out of its way to say "nope" to that. From tim.one at home.com Sat Apr 14 04:06:24 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Apr 2001 04:06:24 -0400 Subject: still wondering (was Re: Pep 245) In-Reply-To: <20010413222646.L2820@xs4all.nl> Message-ID: [Thomas Wouters] > Well, *I* claim Aahz met Tim, and I met Tim (and Aahz). > In fact, we were sitting at the same table as Tim while he was > packing away something that looked like a hamburger, but 5 times > the size and with 10 times as much green stuff as they normally > get. Come to think of it, that can't have been real.... so what > does that make Tim ? Unless I'm mistaken, you were in California at the time. As is well known in the States, *nothing* is real in California. If that had really been me, I'm sure I would have agreed that was no hamburger! And the faux hamburger would have thought the same of me. All in all, you were lucky to get out alive. since-aahz-lives-in-california-he's-doubly-unreal-ly y'rs - tim From cribeiro at mail.inet.com.br Sat Apr 14 10:06:46 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 14 Apr 2001 11:06:46 -0300 Subject: list comprehensions whats happening here In-Reply-To: <9b8bcv$lbl$1@news.udel.edu> References: Message-ID: <5.0.2.1.0.20010414110345.022dbec0@mail.inet.com.br> At 22:14 13/04/01 -0400, Terry Reedy wrote: >[[0,j] for j in ('a','b','c')] is much cleaner and faster. Methinks >turning a constant into a pseudovariable is the wrong way to go. Ouch. I really messed up with this one. I apologize for wasting bandwidth when a *much* better idiom is already available. Please erase all that I said before :-) I assumed (wrongly) that I could not put a constant value on the list constructor - however, I forgot that constants are objects in Python as any other value . Coming from a C/Pascal background this is easily explained... Carlos Ribeiro From mwh21 at cam.ac.uk Tue Apr 3 04:06:44 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Apr 2001 09:06:44 +0100 Subject: #include equivalent References: <017y6.19560$BC6.5586474@e3500-chi1.usenetserver.com> Message-ID: kragen at dnaco.net (Kragen Sitaker) writes: > Yeah, but there are problems with execfile(): > - it puts all the stuff in that file in *your* namespace (not a separate one) > - circular execfile()s will hang your program and eventually crash ... > - execfile()ing the same file from two different modules generates two ... > - It takes more time (potentially *much* more time) > - it takes more space (potentially *much* more space) > - it breaks objects that try to determine whether other objects are ... > - and it breaks any modules that try to maintain module state (like ... So much more like #include then! > So don't use execfile() instead of import. Well, no, but that not really what was being proposed, was it? Someone asked for an #include equivalent, and while import is probably want they wanted, execfile is closer. Different things. Cheers, M. -- I'm not particularly fond of singing GSTQ because she stands for some things I don't, but it's not really worth letting politics getting in the way of a good bawling. -- Dan Sheppard, ucam.chat From akuchlin at mems-exchange.org Thu Apr 26 10:20:20 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Apr 2001 10:20:20 -0400 Subject: how to explain this memory usage References: Message-ID: <3dpudzu4ij.fsf@ute.cnri.reston.va.us> javalist writes: > also the interpreter has 20M in memory,but seems python knows they are > pointing nothing and reuse these 20M when I try again allocating more > object in python,it didn't increase memory until the first 20M is > occupied by the new allocated object This is also dependent on your platform's malloc. The malloc used on Linux, for example, uses mmap() for allocations above a given size, and on freeing an mmap()'ed area, the process size drops. For example, I just tried creating a 20Mb string, watched the process size jumped appropriately, then deleted it and watched the process go back to around 2Mb. 20Mb of smaller objects probably won't have this pleasant predictability. I'm not sure how enabling pymalloc would change this picture. --amk From edwardt at trillium.com Thu Apr 19 18:47:49 2001 From: edwardt at trillium.com (EdwardT) Date: Thu, 19 Apr 2001 15:47:49 -0700 Subject: How to extract the file names??? References: <9bnom3$g9a@news.or.intel.com> Message-ID: <9bnpum$h2c@news.or.intel.com> -----Original Message----- From: Jake Baker [mailto:jbaker at ummelec.com] Sent: Thursday, April 19, 2001 3:33 PM To: e_tsang at trillium.com Subject: RE: why radiobutton does not deselect itself?? Use the os.path.basename function. (The os.path module has a lot of useful functions like this!) import os.path inputName = askopenfilename(filetypes=["{Test Log Files} {*}"]) inputName = os.path.basename(inputName) Yours, - Jake >>> "Tsang, Edward1" 04/19/01 05:27PM >>> thanks for you reply. and just wonder if you also know the following ... Hi currently I have the following code that asks the user for input file names, but it returns the filesname with the full path attaching to it. ButI just want the filenames without the fullpath how can i do it?? I amusing TkInter. inputName = askopenfilename(filetypes=["{Test Log Files} {*}"]) e.g it will gives me: /vobs/qa/stf/ctf/src/sample/tpu/log/tpTcCTFTEST7/tp_acc.1 But I just want tp_acc.1 . what should I do?? The file name and the ful path are not known until run time. Ps as you notice askopenfilename also display the filename with the full path which is very long.. ho can cut it back also? Thanks -----Original Message----- From: Jake Baker [mailto:jbaker at ummelec.com] Sent: Thursday, April 19, 2001 1:45 PM To: edwardt at trillium.com Subject: Re: why radiobutton does not deselect itself?? Edward, Sounds like you want a Checkbutton instead. Some rules for widget use: Use a checkbutton when a value can be either on or off independant of other settings. Use a group of Radiobuttons when only one of a group of selections can be selected at one time. Note that it makes no sense to use a single Radiobutton; Radiobuttons select one from a multiple of options, one of which has to be selected. Hence, only having one Radiobutton would mean that lone Radiobutton is always selected. Hope this help! - Jake "EdwardT" wrote in message news:9bnom3$g9a at news.or.intel.com... > Hi currently I have the following code that asks the user for input file > names, but it returns the filesname with the full path attaching to it. ButI > just want the filenames without the fullpath how can i do it?? > > inputName = askopenfilename(filetypes=["{Test Log Files} {*}"]) > > e.g it will gives me: > /vobs/qa/stf/ctf/src/sample/tpu/log/tpTcCTFTEST7/tp_acc.1 > > But I just want tp_acc.1 . what should I do?? > The file name and the ful path are not known until run time. > Ps as you notice askopenfilename also display the filename with the full > path which is very long.. ho can cut it back also? > > Thanks > > > From pulsar at qks.com Thu Apr 26 02:48:09 2001 From: pulsar at qks.com (David Simmons) Date: Thu, 26 Apr 2001 06:48:09 GMT Subject: Integer micro-benchmarks References: <5MLF6.98590$166.1840160@news1.rdc1.bc.home.com> Message-ID: "Steve Wart" wrote in message news:UKNF6.98935$166.1860248 at news1.rdc1.bc.home.com... > 1.2GHz Athlon, Win2K SP2, 512Mb RAM -> David > 333 PII, Win2K SP1, 192Mb RAM -> Steve > [I gotta get in Redmond's good books :)] That's not how I got the machine if that's what you're thinking. As I mentioned in some other posts, you can build my exact machine configuration for under $2,000 (which is amazing to me). Actually, you can build a better machine now for that money. I built my machine a few months ago for under $2000. My brother is in the process of building two new machines (w/slight variances between them), each for under $2000 with the spifiest graphics cards for games, DVD, sound system, ATA 100 raided 7200 RPM drives, 512MB memory, and 1.3GHz Duron with the 266Mhz FSB. Earlier today, someone told me you can buy the 1.7GHz Pentium processor for $350 now -- unbelievable... As to the Win2K SP2, you just have to pay the annual MSDN fees of ~$600 for professional subscription, or $2000 for universal subscription. Which is basically on par with Apple's ADC fees for being a developer -- actually its the model Microsoft copied and improved upon. > > "David Simmons" wrote ... > > "Steve Wart" wrote ... > > > Here is some more silliness. > > > > > > If you take the #triangle method and turn it into a block closure, as > below, > > > in VW it takes almost 10 seconds (on my 333 PII) > > > > Really! 10 seconds versus 7 seconds? > > > > Good goobley goo. I just ran it on VW and got the times: > > > > 1784ms for 9,000,000 loops using local to the block. > > > > 4102ms for 9,000,000 loops using as a method temp (shared with > the block). > > > How come I have about a 30% difference and yours is over 100%? Is this a CPU > caching thing? I don't know. I've re-checked the runs though because this stands out as weird. We should look further into this anomaly to understand it because it makes the benchmarking numbers hard to properly assess. Maybe Eliot could answer this one? My only guess is that using a method temp is resulting in some kind of context being allocated every time the block is evaluated. If so, it might be a bug in the copying-block analyzer of the compiler? > > > The same runs on SmallScript were: > > 1313ms vs 1380ms respectively By the way, the Squeak (latest non-alpha version) runs on my box yielded: 20,940ms and 18,827ms respectively. > > This is the AOS VM? Yes. > I wonder how it would do on the .NET VM? If you are not > at liberty to say, tap twice :) Hmm, well, sorta. Tap once: Let's just say its markedly slower. > > Does SmallScript come with AOS? Yes. Both the SmallScript compiler and a corresponding execution engine (the core AOS Platform VM) will be free. The SmallScript compiler and scripting/dynamic language support libraries for the Microsoft.NET Platform will not be free. As to other frameworks, tools, etc -- that will be determined on a case by case basis. The AOS Platform is a quasi language independent object-model/virtual-machine which is now in its 4th major generation since I first designed it back at the end of 1990. That design was derived (extensively influenced) from work I did on C based (vm) object systems beginning back in 1986. SmallScript began its life in 1998 as a new language that is derived from my work in creating and evolving QKS Smalltalk from 1991 to 1998. SmallScript includes all of the smalltalk "language" (not the ANSI Smalltalk frameworks or Smalltalk-80 stuff) plus many other extensions. -- Dave S. > > Steve From jwbaxter at olympus.net Sun Apr 22 15:19:00 2001 From: jwbaxter at olympus.net (John W. Baxter) Date: Sun, 22 Apr 2001 12:19:00 -0700 Subject: Python 2.1 running on Mac OS X 10.0.1 here Message-ID: <220420011219006651%jwbaxter@olympus.net> I built Python 2.1 as a Mac OS X admin user, using: ./configure --with-suffix=.exe --with-dyld" make Then in make test, I saw the following error test_re make: *** [test] Segmentation fault I disabled test_re.py (and test_largefile.py: it takes a while and passed four times...it should keep passing). Then in make test, I saw: test_sre make: *** [test] Segmentation fault (which suggests that the error in test_re.py is really in the underlying sre module). After I disabled test_sre.py, the make test ran to completion, reporting: 112 tests OK. 22 tests skipped: test_al test_cd test_cl test_dl test_fcntl test_gdbm test_gl test_gzip test_imgfile test_linuxaudiodev test_locale test_minidom test_nis test_poll test_pty test_pyexpat test_sax test_sunaudiodev test_winreg test_winsound test_zipfile test_zlib (The make install required using sudo, not surprisingly.) Really simple uses of the re module succeed (leaving out blunders): Python 2.1 (#1, 04/22/01, 11:06:25) [GCC Apple DevKit-based CPP 6.0alpha] on darwin1 Type "copyright", "credits" or "license" for more information. >>> import re >>> r = re.compile('fubsy') >>> r >>> r.match('I am fubsy') >>> x = r.match('I am fubsy') >>> x >>> x = r.match('fubsy are us') >>> x ... >>> x.string 'fubsy are us' >>> x.group(0) 'fubsy' >>> x = r.search('nuts') >>> x >>> x = r.search('it is nice to be fubsy') >>> x.group(0) 'fubsy' >>> x.start(0) 17 >>> x.end(0) 22 ... >>> x.string[17:22] 'fubsy' >>> So I have a working Python 2.1 in Mac OS X (10.0.1), but I have to be "gentle" with the re module for a while. --John From SBrunning at trisystems.co.uk Tue Apr 3 04:48:20 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 3 Apr 2001 09:48:20 +0100 Subject: "Fastest growing programming language" Message-ID: <31575A892FF6D1118F5800600846864D78BA62@intrepid> > From: bowman [SMTP:bowman at montana.com] > The assertion for COBOL is that it already is the most widely used > language. > With suitable conditionals, it could be said RPG is the most used > scripting > language. I actually saw a page today expounding the virtues of RPG for > producing AS400 web pages. And here I though that beast (RPG, not AS400) > died in 1978 . RPG is not dead. It just *smells* like it's been dead for a while. After catching up on c.l.py, I'll have to go back to debugging RPGIII programs. Well, we all have to earn a living... BTW, RPG is fairly low level (in term of data structures, if not RDBMS access), and compiled rather than interpreted. I know that 'scripting language' is a fairly nebulous term, but I don't think that it will stretch to cover RPG. OK, time to find out where all those GOTOs go... Trying-to-drag-his-company-kicking-and-screaming-into-the-eighties-ly yrs, Simon Brunning. ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From chris.gonnerman at usa.net Sun Apr 15 09:47:45 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 15 Apr 2001 08:47:45 -0500 Subject: why does activestate (win98) python not support globbing References: <9b4of1$j16$1@bmerhc5e.ca.nortel.com> Message-ID: <004f01c0c5b2$aa702260$a100000a@local> ----- Original Message ----- From: "Marcin 'Qrczak' Kowalczyk" Subject: Re: why does activestate (win98) python not support globbing > Fri, 13 Apr 2001 15:31:23 GMT, Robert Amesz pisze: > > > Why nasty? This is one instance were I think UNIX has got it wrong. > > It's much better to leave commandline parameters alone than to try and > > interpret them in a particular way. Explicit is better than implicit. > > This would mean that in a statement like > self.write(PERSID + str(pid) + '\n') > the write function should perform the parsing of the expression > "PERSID + str(pid) + '\n'", while for me it's obvious that it only > gets its result and can't recover the spelling of the expression > used to compute it. > > It's similar for commandline arguments. The list of files doesn't need > to be written explicitly: it can come from expanding variables, from > globbing patterns, from substitution of output of some other command, > from arithmetic computation etc. You can't expect applications to do > all this. This is the job of whoever calls your program to generate > arguments, e.g. the shell. The user just tells the shell how to > generate them using the shell's language, which includes variables, > wildcards etc. I have been on both sides of this for a long time... and I feel the Unix way is better. There are many cases in the Unix docs where special steps have to be taken to protect special characters from the shell, but these cases of "extra work" IMHO are better than the alternative: inconsistent command-line syntax. Live in stupid DOS for a while, where each command has to decide for itself whether or not to glob. Globbing is consistent for most core DOS commands because the "cathedral" was built to a plan, but most add-on's have different rules, and when it comes to Win32 console commands it just gets worse. BTW Robert, the Unix way *is* explicit, because (if you learn in a class or from most of the books I've read) you learn the shell first. Knowing its' rules covers virtually all cases, where in DOS there are no such consistent rules. From dalke at acm.org Fri Apr 13 19:11:57 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 13 Apr 2001 17:11:57 -0600 Subject: In the Absence of a GoTo Statement: Newbie needs menu-launcher to choose amongst sub-programs References: <3AD5EEEF.C4CB8AF2@earthlink.net> <9b7iaq0dep@news2.newsguy.com> Message-ID: <9b814u$39p$1@slb4.atl.mindspring.net> Alex-bot: > the answer is: "because, in a well-designed language, there >is no situation in which ``nothing else will do as well''":-). I've just been rereading some of Knuth's "The Art of Computer Programming." I don't do it very often because I get a headache trying to understand his use of gotos, which aren't simply nested (directly convertable to structured loops) and which aren't error-handling-like (convertable to exceptions). So Python is not a well-designed language for direct translation of MIX code because it doesn't have gotos. No need to followup - just wanted to complain about MIX (again :) Andrew dalke at acm.org From grante at visi.com Sat Apr 7 23:20:18 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 08 Apr 2001 03:20:18 GMT Subject: UNIX domain sockets problem References: Message-ID: On Sat, 7 Apr 2001 16:30:00 -0400, Steven D. Arnold wrote: >I'm trying to create a server that uses UNIX domain sockets. I >am using the code below: > > from socket import * > from os import unlink > > SERVER = socket(AF_UNIX, SOCK_DGRAM, 0) > unlink("/home/stevena/socket") > SERVER.bind("/home/stevena/socket") > SERVER.listen(3) You can't listen() for connections on a connectionless protocol. The listen() operation is only valid for connection-oriented protocols, and not for datagram protocols. To accept connections, a socket is first created with socket(2), a willingness to accept incoming connections and a queue limit for incoming connections are specified with listen, and then the connections are accepted with accept(2). The listen call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET. >This is on a machine running Linux-PPC, using python 1.5.1. >I'll try it on regular RedHat Linux tomorrow, but surely >listen() would be supported on Linux-PPC? Anyone have a clue >what's going on? Skip the listen() call and just call recv(). -- Grant Edwards grante Yow! Youth of today! Join at me in a mass rally visi.com for traditional mental attitudes! From vsl6 at paradise.net.nz Sat Apr 21 17:26:39 2001 From: vsl6 at paradise.net.nz (Mick) Date: Sun, 22 Apr 2001 09:26:39 +1200 Subject: How best to write this if-else? In-Reply-To: Message-ID: you could try bound methods The following is probably not the nicest of ways but it shows you how to keep the abstraction in the loop. import re def printRes1(m): print m.group(1) def printRes2(m): print m.group(1) print m.group(2) re1 = (re.compile("demo.*"),printRes1) re2 = (re.compile("testing(.*)for(.*)"),printRes2) all = [re1,re2] str = "testing things for now" for i in all: ma = i[0].match(str) if ma: i[1](ma) Mick -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Roy Smith Sent: Sunday, April 22, 2001 9:02 AM To: python-list at python.org Subject: Re: How best to write this if-else? "Ingo Wilken" wrote: > for e in [e1, e2, e3]: > m = e.match(line) > if m: > text = m.group(1) > break > else: > no match found OK, that's pretty neat, but I realize now that my example was unintentionally misleading. The problem is not quite as regular as I made it out to be. What if I want to execute different code depending on which expression I matched? Something along the lines of (pseudocode): if (m = e1.match(line)): text1 = m.group(1) do_complicated_processing (text1) elif (m = e2.match(line)): text1 = m.group(1) text2 = m.group(2) print text1, text2 elif (m = e3.match(line)): return -- http://mail.python.org/mailman/listinfo/python-list From sholden at holdenweb.com Wed Apr 11 21:21:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 11 Apr 2001 21:21:57 -0400 Subject: IndexError: string index out of range References: Message-ID: "michael" wrote in message news:mailman.987034096.12363.python-list at python.org... > #!/usr/bin/python > > import sys > > FILENAME = "./testfile" > EXCLUDE='#' #Lines beginning with this should not be printed. > > def get_line() : > buf = f.readline() > if (buf[0] == EXCLUDE): > return 0 > else: > return buf > The problem here is that you are testing for the line beginning with a "#" before you know whether you have encountered the end of the file. That's why you get an error at EOF. > f = open(FILENAME, "r") > Also note that you set f here, but use it (as a global) int he function. While this is possible, it's generally better practice (and more flexible) to pass it in to your function as an argument. I wouldn;t worry too much about that just now, though. > while 1: > buf = get_line() > if (buf == ''): > break Here you correctly test for EOF before testing for a comment line, but it's too late, the damage was done in get_line()! > if (buf == 0): # If 0 is returned then the line read on this loop > begins with > continue # the EXCLUDE char and is not to be printed > else: > sys.stdout.write(buf) > The above logic might be more succinctly expressed as if buf: # zero tests false. None might be better? sys.stdout.write(buf) > f.close() > > ############# END OF PROGRAM ############## > > Im new to Python.This is my prgram. It reads the contents of testfile > line by line and prints it out unless the line begins with a #. I know > that it might be pointless to use a function for this but it is for > learning purposes. This program works fine until it gets to the last > line in the testfile and I get this error. > > Traceback (innermost last): > File "./test3.py", line 18, in ? > buf = get_line() > File "./test3.py", line 10, in get_line > if (buf[0] == EXCLUDE): > IndexError: string index out of range > > Can someone please tell me what I'm doing wrong? I've looked all over > the net and in several books for a solution. > You didn't go too far wrong, just a simple sequencing error. In this case, would it actually be better to have the read routine keep going until it either hits EOF or finds a line which needs processing? The following code is untested, just to give you the idea... def get_line(): # return a non-comment line or EOF l = f.readline() if not f: # empty strings also test false return f if f[0] == "#": return get_line() This recursive solution removes the comments before they have time to get troublesome. If you don;t like recursion (a function calling itself) then you could equivalently write: def get_line(): # return a non-comment line or EOF while 1: l = f.readline() if not f: return f if f[0] != "#": return l This simplifies your main program, because now it never sees the comment lines and so only needs to worry about end of file. Does this help? regards Steve From cg at schlund.de Wed Apr 25 04:02:55 2001 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 25 Apr 2001 10:02:55 +0200 Subject: MySQSLdb: just guessing References: Message-ID: <3AE684AE.173EB8B9@schlund.de> Albert Wagner wrote: > > I can find no docs for MySQLdb, so I am just guessing how to get going. I > got this far by trial and error: > > >>> import _mysql > >>> from _mysql import * > >>> connection = connect('myhostname', 'mypassword') > >>> > MySQLdb is very poorly documented. But if you browse through the dbtrainer files in the doc/ directory you'll come across something like this: import MySQLdb # Establish a connection: db=MySQLdb.connect(host='myhost',db='mydatabase',user='itsme',passwd='wonttellyou') # Fetch a table list c = db.cursor() c.execute('show tables') print c.fetchall() # fetchall() is bad for huge results. # use fetchmany() or fetchone() c.execute('select * from a_huge_table') while 1: rows = c.fetchmany(10) if not rows: break for row in rows: print row db.close() cg. From news at myNOSPAM.org Mon Apr 16 01:18:23 2001 From: news at myNOSPAM.org (Ixokai) Date: Sun, 15 Apr 2001 22:18:23 -0700 Subject: do...until wisdom needed... References: Message-ID: <3ada7eb9$1_5@goliath2.newsfeeds.com> The standard Python Idiom (tm of someone, I'm sure :)) for a do-while construct is: while 1: statements if condition: break Its in-elegant, and even ugly, IMHO. I think there's a reason that there is no do-while construct, otherwise I can't fathom why they wouldn't have put it in yet.. this is something that comes up frequently. --Stephen (replace 'NOSPAM' with 'myseraph' to respond in email) "Ken Peek" wrote in message news:tdku4kqlqjquf2 at corp.supernews.com... > Sometimes, when writing code, I find it would be nice if there were a > "do...until" construct in Python. This would be preferable to using a "while" > construct if you wanted to make sure the loop will execute at least once. You > CAN do this with a "while" construct, but it requires fiddling with the loop > condition before the "while" construct, which is "messy". An example: > > condition = TRUE # make sure loop runs at least once > while (condition): > # do some stuff > # do some more stuff > condition = whatever_stops_the _loop > > Here is my question-- If Python WERE to have a "do...until" construct, what > would be the best way to implement the syntactical rules? > > For example: > > do: > # some stuff > # some more stuff > until (condition == TRUE) # ("until" must be last statement or there is an > error) > > OR: > > do: > # some stuff > # some more stuff > until (condition == TRUE) > > OR: ??? > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From tim.one at home.com Thu Apr 12 21:55:43 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 12 Apr 2001 21:55:43 -0400 Subject: why does activestate (win98) python not support globbing In-Reply-To: Message-ID: [/F] > to be precise, it's a linking issue. to get globbing behaviour, just > link the executable with setargv.obj (provided with visual C). > > for some reason, GvR didn't want this as a default. cannot recall > his arguments, though... Mark Hammond and I threatened to eviscerate him if he did: C:\>dir *1 Volume in drive C has no label Volume Serial Number is 2637-18E7 Directory of C:\ MYDOCU~1 11-06-00 7:39p My Documents PROGRA~1 11-06-00 7:39p Program Files WINDOW~1 11-11-00 3:01p Windows Update Setup Files WEP1 11-13-00 4:06p WEP1 0 file(s) 0 bytes 4 dir(s) 13,313.16 MB free C:\> Note that the "*1" also matches the (generated!) "short" names. You don't have to do del *1 and watch most of your "files with long names" disappear as a result twice to be convinced that MS's idea of globbing should *never* be used by default (to be clear, linking with setargv.obj gives your C program the same behavior as the builtin-dir example above; using dir was just easier than showing C source). From ps54713 at swt.edu Sat Apr 21 19:11:20 2001 From: ps54713 at swt.edu (ps54713) Date: Sat, 21 Apr 2001 18:11:20 -0500 Subject: a newbie Question?? Message-ID: <3AE21398.902AFD21@swt.edu> Is there a way to encrypt a text box field, coz i need to do this for the password field. I shall really appreacite it. Praveen From fgeiger at datec.at Fri Apr 6 12:40:05 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 6 Apr 2001 18:40:05 +0200 Subject: Anyone able to compare the commercial IDEs available? Message-ID: <9akseh$ncs$1@newsreaderm1.core.theplanet.net> I'm aware of three commercial IDEs for Python: -- PythonWare -- BlackAdder -- Komodo Komodo is somewhat appealing because it supports more than one language. But the betas were pretty slow on my WinNT box and AS doesn't seem to offer evals of its new release. I'll have to check the other vendors for an eval. But anyway: I wonder if there is anyone already owning more than one of the above and is willing to compare them against each other. Thanks in advance and best regards Franz GEIGER From aleaxit at yahoo.com Fri Apr 27 03:59:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Apr 2001 09:59:16 +0200 Subject: problems with eval() References: Message-ID: <9cb9bp12is@news1.newsguy.com> "Brian Forney" wrote in message news:mailman.988347820.9039.python-list at python.org... > Hi, > > I am trying to use eval in Python 2.0. I am trying to use reo.sub() and a [snip] > error = results/cache/ path);> > > -------------------- > > Notice the embedded Python code in test.txt. It looks to me as if these are *STATEMENTS*, while eval() handles an *EXPRESSION*. Maybe you want to exec rather than eval()...? Alex From mhyoung at valdosta.edu Wed Apr 18 14:34:28 2001 From: mhyoung at valdosta.edu (michael) Date: Wed, 18 Apr 2001 14:34:28 -0400 Subject: Something keeps nibbling on my list Message-ID: <3ADDDE34.CFAB2310@valdosta.edu> My program reads a file and copies it into a list, line by line. Then writes the list to another file. for some reason the first 2 lines from the first file are missing from the second file. i know that they are being read into the list because i print the whole list out and they are there. Can someone please help? The entire program is below. TIA Michael ################ Start program ####################### #!/usr/local/bin/python #This program reads the hosts.deny file, removes duplicate entries and #sorts them. It then sends the output to another file. #This program requires Python 2.0. import sys import string FILENAME = "/etc/hosts.deny" #The file the input is read from. TEMPFILE = "./hosts.deny.test" #The file the output is written to. EXCLUDE='' #Lines beginning with this should not be printed. def get_line() : buf = f.readline() if (buf and buf[0] == EXCLUDE): return 0 else: return buf def is_this_a_dup(buf, l) : if (l and buf): results = l.count(buf) if (results > 0): return l else: l.append(buf) return l else: l = buf return l f = open(FILENAME, "r") l = ["1"] #This is just to avoid the "NameError: There is no # variable named 'l'". It can be taken care of later. while 1: buf = get_line() if (buf == ''): break if (buf == 0): # If 0 is returned then the line read on this loop begins continue # with the EXCLUDE char and is not to be used. else: # sys.stdout.write(buf) l = is_this_a_dup(buf, l) print l l.remove("1") #Removes the 1 that we put into the list at the beginning of # the program. l.sort() for i in l: sys.stdout.write(i) g = open(TEMPFILE, "w") g.writelines(l) g.close() f.close() From floods at netplus.net Tue Apr 17 21:39:08 2001 From: floods at netplus.net (Luke) Date: Tue, 17 Apr 2001 20:39:08 -0500 Subject: Python compiler? References: Message-ID: <3ADCF03C.EC1EF1B8@netplus.net> To compile a language, you need to know types explicitly so memory 'boundaries' are known. When you can say x = 1; x = []; x = {} that poses a major problem. There is no 1 type. I think there is a tool called freeze (my memory is very sketchy) that will make a self contained exe. I know! Guido can add typing to the language! It'll be great. list x = []; dict y = {} 1 dog + 4 legs = octapus Luke From thomas.heller at ion-tof.com Wed Apr 25 03:28:25 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 25 Apr 2001 09:28:25 +0200 Subject: [Python-Dev] Class Methods References: <9c1dhr$bj0d7$1@ID-59885.news.dfncis.de> Message-ID: <9c5ua9$c137r$1@ID-59885.news.dfncis.de> > > [...] The problem is that normally > > metaclasses are implemented in C (it seems a python > > implementation is way to slow for most uses). On the > > other hand this is a lot of work, you have to completely > > duplicate the whole class/instance/method behaviour > > from standard python. > But I can use the functions that Python would use to build one of > its classes, just add an additional initialization call > after that.... How that? I didn't succeed to use new.instancemethod() on a metaclass instead of MetaMethodWrapper (from demo/metaclasses/meta.). > > Furthermore, speed seems not fundamental for meta classes. > When is a meta class used? To create a class. > One does not tend to do that too often.... It's also used to implement additional behaviour for the instances. Just did a little test (also using demo/metaclasses/meta.py here): Calling 'print x' when x is an instance of 'class C(Meta): pass' seems to be slower by a factor of about 50 (!) compared to an instance of a 'normal' python class. This will become much worse if there is a deep inheritance relation. Thomas From qrczak at knm.org.pl Fri Apr 20 18:34:40 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 20 Apr 2001 22:34:40 GMT Subject: Jython: Upper-ASCII characters '\351' from chr(233) References: <3AE08EC7.C03FEA39@clara.net> Message-ID: Fri, 20 Apr 2001 20:32:23 +0100, Maurice Bauhahn pisze: > >>>chr(233) > '\351' > Any suggestions on how to get around this? This is correct. '\351' means a character whose octal value is 0351, i.e. 233. Note that Python 2.1 will display it in hex as '\xe9' but it's still the same character. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From michaell.taylor at reis.com Sun Apr 1 10:11:09 2001 From: michaell.taylor at reis.com (Michaell Taylor) Date: Sun, 1 Apr 2001 09:11:09 -0500 Subject: Basic Answer to very basic, how do you find square roots? In-Reply-To: References: Message-ID: <0104011011090F.01103@penguin> Umm. Why not just x**.5 to find sqrt of x. Message: 4 Message-ID: <004201c0b9c1$f0b38f20$020000c3 at node02> From: "Sandipan Gangopadhyay" To: "johnston112" Cc: References: <9a408a$1mpp$1 at raewyn.paradise.net.nz> Subject: Re: very basic, how do you find square roots? Date: Sat, 31 Mar 2001 14:36:56 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Sender: python-list-admin at python.org Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: >>> import math >>> math.pow(2,4) 16.0 >>> math.pow(2, .5) 1.41421356237 Regards, Sandipan ----- Original Message ----- From: "johnston112" Newsgroups: comp.lang.python To: Sent: Saturday, March 31, 2001 12:35 PM Subject: very basic, how do you find square roots? > Yes, that is my question :) > I am trying to make a program that dose the quadratic equation. > > johnston112 > > > -- > http://mail.python.org/mailman/listinfo/python-list > From chega_ at yahoo.com Wed Apr 18 04:47:29 2001 From: chega_ at yahoo.com (Vadim Chugunov) Date: Wed, 18 Apr 2001 08:47:29 GMT Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> Message-ID: "Dave LeBlanc" wrote in message news:9bji5k$417$0 at 216.39.170.247... > Since self is used for every method of every class, isn't it a bit > redundant? I don't know of another OO language that makes you manually > carry around the "this"/"self" pointer/reference... Sure, we could get rid of 'self'. ...and then immediately invent coding convention that allows people to distinguish class variables from globals and locals. Like 'm_spam'. When 'self' seems to be too much typing I shorten it to 's'. From James_Althoff at i2.com Mon Apr 30 15:47:16 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 30 Apr 2001 12:47:16 -0700 Subject: what's in a name (was Re: using lambda to print everything in a list) Message-ID: >Alex writes: > >_In the context of Python_ (as opposed to, say, Haskell), I don't >find myself "composing functions" with wild abandon. I do pass >functions to other functions, etc, but in recent times I find >myself using named local functions instead of unnamed lambdas for >that, more and more -- lately, I would say, exclusively. And I >don't miss the lambdas at all... > > >Alex Just to (re)state one case for the minority -- apparently 3 of us out of the approximately 17 million or so Python programmers -- who do miss the "fully functional, fully integrated, and conveniently "syntaxed" lambda that never existed in Python, I still would like to see (dream, dream, dream) an alternative way of specifying a code block for the following kind of thing -- which I often encounter in code in my neck of the woods: savedCursor = window.getCurrentCursor() window.showWaitCursor() try: line1-of-code line2-of-code . . . lineN-of-code finally: window.showCursor(savedCursor) Because I think: def doSomeLinesOfCode(): line1-of-code line2-of-code . . . lineN-of-code window.showWaitCursorDuring(doSomeLinesOfCode) is really a preferred idiom. In practice, I don't see folks around my block do the latter much, although there is nothing in today's Python that prevents it. I do believe I would see this idiom used much more frequently (in my building anyway) were there something akin to: window.showWaitCursorDuring: line1-of-code line2-of-code . . . lineN-of-code By comparison, one does see this idiom used frequently in Smalltalk (and apparently from a recent post, in Ruby as well). I suspect that there is something in the combination of 1) pick a temp-code-block name, 2) construct the nested function _before_ its usage (i.e., use a "prefix" ordering where many folks are used to a "postfix" ordering -- due, more likely than not, to the old-worn-in-shoes-type comfort of for loops and conditional statements), and 3) use a nested function definition while you are at it that provides just enough straws to send serious soreness to the camel's back (in spite of how admittedly easy it is to name a code block in current Python). jim From andy at reportlab.com Fri Apr 6 19:10:11 2001 From: andy at reportlab.com (Andy Robinson) Date: Sat, 07 Apr 2001 00:10:11 +0100 Subject: CRACKER, the premier code obfuscation utility for Python... (WAS: RE: POLLY: An IDE for Parrot) References: <3ac97549.80687872@news.is.co.za> <4q0ncto9pomo23q9bhdob8qll8kv5ihni7@4ax.com> <9aionm$9mm$2@newshost.accu.uu.nl> Message-ID: >> Sorry, it's taken. ReportLab has a subpackage >> "Page LAyout and TYPography Using Scripts" (PLATYPUS) >> and if anyone puts that on a book cover before us, we'll >> send round some wide boys from the east end of London. >> Much cheaper than patent lawyers :-) > >But I learned the basics of object oriented programming from the >Platypus book! Here's the URL (second edition): > >ftp://ftp.cs.orst.edu/pub/budd/oopintro/2ndEdition/info.html > >Regards, > >Martijn Damn and blast! and it's a Java book too! Still, I think I prefer O'Reilly's style of animal drawings. - Andy From phbrown at acm.org Mon Apr 23 16:50:50 2001 From: phbrown at acm.org (Peter Brown) Date: Mon, 23 Apr 2001 20:50:50 GMT Subject: BLT installation woes under W98 (Python 2.1) Message-ID: I'm new to Python, and am trying to install Pmw and BLT under Windows 98. Pmw appears to install OK. BLT is another story, however. As others have noted before in this group, the Tcl directory structure under Python is different from the Tcl directory structure under Tcl, with consequent problems installing extension-like animals (well, I've seen people ask about BLT, anyway). Is there a known way to install BLT into the Tcl directory structure under C:\Python21? Should I be compiling BLT and/or Tcl from scratch? If so, how would I tell Python to use the Tcl I just made, not the Tcl it came with? Glancing back through the newsgroup archives shows that this question seems to come up every month or two (candidate for a FAQ/howto?). I've only seen one answer, though, from Norman Charnley--I tried what he suggested (or what I *thought* he was suggesting, anyway), and it didn't work for me. OTOH, others seem to post (with about the same frequency) saying, "I installed BLT, but now I have this other problem...", so obviously *some* folks are figuring this out. I'll be happy to post an answer, if I can get one that works :-). Peace, --Peter From vincent_a_primavera at netzero.net Wed Apr 4 07:44:35 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Wed, 4 Apr 2001 07:44:35 -0400 Subject: Smtplib... Message-ID: <01040407443500.00574@tos1> Hello, When sending mail with smtplib, how would you attach a file? Thank You, Vincent A. Primavera From alan.gauld at bt.com Mon Apr 9 12:00:49 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 09 Apr 2001 17:00:49 +0100 Subject: wxPython: Procedural or OOPS? installation woes etc... References: <3ACC27AB.1A13151@earthlink.net> Message-ID: <3AD1DCB1.EA5895B5@bt.com> Ron Stephens wrote: > Can anyone tell me whether wxPython uses a procedural approach > to event driven gui programming, or an object oriented one > like Tkinter does??? Actually Tkinter doesn't force an OO approach - wxPython does! You can use Tkinter objects in a procedural manner, but you still need to work with events.... FWIW My gui topic has a sample of wxPython to compare with identical Tkinter code, that might help. http://www.crosswinds.net/~agauld/tutgui.htm Alan G. From roy at panix.com Sat Apr 21 17:01:35 2001 From: roy at panix.com (Roy Smith) Date: Sat, 21 Apr 2001 17:01:35 -0400 Subject: How best to write this if-else? References: <9bsrpj$3gj@news.Informatik.Uni-Oldenburg.DE> Message-ID: "Ingo Wilken" wrote: > for e in [e1, e2, e3]: > m = e.match(line) > if m: > text = m.group(1) > break > else: > no match found OK, that's pretty neat, but I realize now that my example was unintentionally misleading. The problem is not quite as regular as I made it out to be. What if I want to execute different code depending on which expression I matched? Something along the lines of (pseudocode): if (m = e1.match(line)): text1 = m.group(1) do_complicated_processing (text1) elif (m = e2.match(line)): text1 = m.group(1) text2 = m.group(2) print text1, text2 elif (m = e3.match(line)): return From aleaxit at yahoo.com Thu Apr 26 12:01:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Apr 2001 18:01:35 +0200 Subject: Graduate thesis on Python-related subject References: <9c7ido010gd@news2.newsguy.com> <9c99r4$cfd@dispatch.concentric.net> Message-ID: <9c9gp002dl8@news2.newsguy.com> "Phlip" wrote in message news:9c99r4$cfd at dispatch.concentric.net... > Proclaimed Alex Martelli from the mountaintops: > > > Yep, Finland is in the European Union, and Nokia is one of the largest > > European firms in the fields of informatics and communications, so its > > Europeanness is rather relevant to people interested in computers, > > networking, telecom &c. > > If I work there, am I allowed to not breathe cigarette smoke? No idea. I had the impression smoking was widespread in _southern_ Europe (Greece holding the record of per-person cigarette consumption), and that Finland is rather northern, but I'm going on hearsay on each of these two issues. Alex From barry at digicool.com Mon Apr 16 13:56:06 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 16 Apr 2001 13:56:06 -0400 Subject: [Python-Dev] Python 2.1 RC1 - PyCheckered Tools References: <3ADB04D0.87576CE4@metaslash.com> Message-ID: <15067.12854.219081.458580@anthem.wooz.org> >>>>> "NN" == Neal Norwitz writes: | pynche/ListViewer.py:165 Local variable (height) not used | pynche/StripViewer.py:294 Local variable (tclcmd) not used | pynche/StripViewer.py:405 No attribute (_StripViewer__gentypevar) found | (member commented out) | pynche/TextViewer.py:104 Local variable (val) not used Thanks. I've fixed these in my working copy but won't check them in until Python 2.1 final is out the door. -Barry From tim.one at home.com Wed Apr 4 16:56:52 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 4 Apr 2001 16:56:52 -0400 Subject: A couple garbage collector questions In-Reply-To: Message-ID: [Douglas Alan] > ... > Another question: Why didn't Python just include Bohm's conservative > GC package to implement Python's cycle detection? Try it yourself, and you'll discover the answer. or-at-least-today's-answer-ly y'rs - tim From brian at sweetapp.com Sun Apr 1 06:44:27 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 1 Apr 2001 03:44:27 -0700 Subject: equivalent of pascal's poitners in python In-Reply-To: Message-ID: # I'm not sure that I am the right person to help you with your object # point since I wouldn't use objects in this case. BTW, are you trying # to use method overloading? example = \ """ For Huffman coding you create a binary tree which stores individual characters at the leaf nodes, and an integer (for frequency) at both leaf and internal nodes. I am new to Python, too, so this code may not be quite right. Maybe it will be enough for someone else to fix up. class HuffmanNode(): def __init__(self, ch, freq): self.ch=ch self.freq=freq self.left=None self.right=None def __init__(self, node1, node2): self.ch=None self.freq = node1.freq + node2.freq self.left=node1 self.right=node2 The point is, like java, there is no such thing as a pointer because any number of variables can represent the same object, just as if they were pointers to the same object. Perhaps someone else could also sketch out the tree-building proceedure: 1) create a node for each character in the source text with it's frequency of occurrence, and store in a collection 2) remove the 2 least-frequent nodes from the collection, and join them with a new common parent. 3) put the new parent node back in the collection 4) repeat steps 2,3 until all nodes form a single tree I think this could be done in very few lines of code, but as I said, I just started looking python, too. """ def prettyTree( tree, depth = 0 ): # Too lazy to import types, which would lead to MUCH nicer style if type( tree[1] ) in [type( () ),type( 5 )]: print ' ' * depth + str( tree[1] ) elif type( tree[1] ): prettyTree( tree[1], depth + 1 ) if type( tree[0] ) == type( () ): print ' ' * depth + str( tree[0] ) else: prettyTree( tree[0], depth + 1 ) d = {} for i in example: d[i] = d.get( i, 0 ) + 1 freqs = d.items( ) freqs.sort( lambda x,y: cmp( x[1], y[1] ) ) while len( freqs ) > 2: freqs = [[freqs[0:2],freqs[0][1] + freqs[1][1]]] + freqs[2:] # I should be shot for not using a bubble sort here. freqs.sort( lambda x,y: cmp( x[1], y[1] ) ) prettyTree( freqs ) From fredrik at pythonware.com Sat Apr 7 04:16:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 07 Apr 2001 08:16:53 GMT Subject: Anyone able to compare the commercial IDEs available? References: <9akseh$ncs$1@newsreaderm1.core.theplanet.net> Message-ID: Moshe Zadka wrote: > I'm not sure what you mean by "commercial". Komodo is Open Source, open source as in $295-$495 per seat for professional users, that is. Cheers /F From dagoni at adminlaw.eu.org Sun Apr 1 12:33:04 2001 From: dagoni at adminlaw.eu.org (Vincenzo Dagoni) Date: Sun, 01 Apr 2001 16:33:04 GMT Subject: searching for simple .ht files editor for ht2html Message-ID: <4LIx6.8933$Oz4.220863@news2.tin.it> Searching for languages web sites I have found open source software named "ht2html". It would be very interesting but I have no practice in editing .ht files ( and in python too) Could you help me? Is there a simmple such .ht files editor that I can use? From akuchlin at mems-exchange.org Wed Apr 4 10:40:36 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 04 Apr 2001 10:40:36 -0400 Subject: cgi security References: Message-ID: <3dlmpgvicb.fsf@ute.cnri.reston.va.us> Moshe Zadka writes: > No it isn't. Neither important, not possible in general. Well, it is possible > but the best regex people have come up with is ~10k characters and still > doesn't deal with the corner cases. > You want to make sure you got a valid addy? Send mail to it. It might be worth removing newlines from the submitted address though; if the CGI is doing ('From: %s' % addr), someone could be adding additional headers to the message such as CC:. In theory you could abuse this to spam through a script. --amk From drbaker at softhome.net Fri Apr 20 13:01:57 2001 From: drbaker at softhome.net (Dennis Baker) Date: Fri, 20 Apr 2001 10:01:57 -0700 Subject: Beginner's Question (or bug in python?) In-Reply-To: <9bpi39$ae6$1@news.sns-felb.debis.de> References: <9bpi39$ae6$1@news.sns-felb.debis.de> Message-ID: <20010420100157.064839c3.drbaker@softhome.net> On Fri, 20 Apr 2001 16:47:52 +0200 Rolf Magnus wrote: I Think what you want to do is below... Your problem with the naming (Fred vs Hans) is probably due to running the application in the IDE, most of the Python IDEs do not clear out the namespace when you rerun a script so it was probably just due to a poluted namespace... Incidentally, I'm pretty green so you might want to review the Tutorial: http://python.org/doc/current/tut/node11.html#SECTION0011310000000000000000 ) class Fred: ) ) def __init__(self): ) print('initializing fred') ) ) def __del__(self): ) print('deleting fred') ) ) def test(self): ) print('Hello world') ) ) ) class Foo(Fred): I think you just wanted to create a new class (No inheritance from Fred) so it would be thus: class Foo: ) ) def __init__(self): ) Fred.__init__(self) To create a new instance of Fred you would do this: self.f = Fred() The __init__ and __del__ methods are called implicitly in the declaration of the class you don't need to call them. Also, you would never pass self to a class (Unless you wanted to pass the current instance of the current class) ) print ('initializing foo') ) ) def __del__(self): ) print('deleting foo'); ) Fred.__del__(self) The self.f instance of Fred will be deleted implicitly when you delete this instance of Foo. However if you wanted to explicitly delete it you would do it like this : del self.f ) This line will now create a new instance x of the class Foo. ) x = Foo() The __init__ function will implicitly create an instance (self.f) of class Fred which can be referenced so: x.f.test() and deleted so: del x When you execute this it will always output : initializing fred initializing foo Hello world deleting foo deleting fred A completely rewritten version would look like this: class Fred: def __init__(self): print('initializing fred') def __del__(self): print('deleting fred') def test(self): print('Hello world') class Foo: def __init__(self): self.f = Fred() print ('initializing foo') def __del__(self): print('deleting foo'); # instance of Fred will be deleted inherantly x = Foo() x.f.test() del x -- Dennis From be at mek.dtu.dk Thu Apr 5 03:41:51 2001 From: be at mek.dtu.dk (Brian Elmegaard) Date: Thu, 05 Apr 2001 09:41:51 +0200 Subject: Changing global variables in tkinter/pmw callback Message-ID: <3ACC21BF.14E708B7@mek.dtu.dk> Hi, I think I am running into a problem with scope, but I am not sure. I have a global variable CurrentCanvasSetting. This is set to first set to 'init'. I then have two class instances, one for a toolbar and one for a canvas. In the in __init__ of the toolbar I set the callback of the buttons as: button.configure(command = lambda self=self, button=button, buttons=self.buttons, setting=CurrentCanvasSetting: self.apply(button,buttons,setting)) In apply I do: def apply(self,button,buttons,setting): setting= button.cget('text') and in here I can then print setting and see it holds the name of the button. However, this is not passed to the global CurrentCanvasSetting as seen when I try to use it in the sheet class: self.sc.component('canvas').bind('<1>', lambda event, self=self, setting=CurrentCanvasSetting: self.addit(setting,event)) where addit is: def addit(self,setting,event): print setting but always prints 'init'. How can I change CurrentCanvasSetting from toolbar.apply and make sheet.addit see the change? -- Brian http://www.et.dtu.dk/energysystems http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From aleaxit at yahoo.com Fri Apr 27 07:26:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Apr 2001 13:26:58 +0200 Subject: xml parsing with sax References: Message-ID: <9cbl2q0kca@news1.newsguy.com> "Harald Kirsch" wrote in message news:yv28zkm63gi.fsf at lionsp093.lion-ag.de... [snip] > it possible to push a pseudo root element in front of a stream parsed > with > > xml.sax.parse(sys.stdin, ...) If the stream fits in memory, it's clearly easy: import xml.sax, xml.sax.handler, sys, cStringIO class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): print "Element",name def wrapWith(tag, fileob): result = cStringIO.StringIO() result.write("<%s>\n"%tag) result.write(fileob.read()) result.write("\n"%tag) result.seek(0) return result xml.sax.parse(wrapWith("fakedoc",sys.stdin), Handler()) If you have to cater for large streams, such that fileob.read() could blow up, then wrapWith() will need to become a factory callable for an appropriate object -- not quite as easy but of course still OK; somewhat in the same spirit as cookbook recipe http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52295 we could have: import xml.sax, xml.sax.handler, sys, cStringIO class Handler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): print "Element",name class FileWrappedWithTag: def __init__(self, tagname, file): self.tagname = tagname self.file = file self.state = 0 def __getattr__(self, attr): return getattr(self.file, attr) def read(self, size=-1): if size<0: self.state = 2 return "<%s>\n%s\n" % ( self.tagname, self.file.read(), self.tagname) elif self.state == 0: self.state = 1 return "<%s>\n%s" % ( self.tagname, self.file.read(size-len(self.tagname)-3)) elif self.state == 1: result = self.file.read(size) if result: return result self.state = 2 return "\n" % self.tagname elif self.state == 2: return "" def wrapWith(tag, fileob): return FileWrappedWithTag(tag, fileob) xml.sax.parse(wrapWith("fakedoc",sys.stdin), Handler()) Fortunately, the parser just calls .read(N) on its file-object argument -- it does *NOT* type-test, and a GOOD thing it is that it doesn't! -- so that Python's typical signature-based polymorphism lets us do the job in a reasonably clean and easy way. Alex From jimhill at meldrick.swcp.com Sun Apr 15 13:11:58 2001 From: jimhill at meldrick.swcp.com (Jim Hill) Date: 15 Apr 2001 17:11:58 GMT Subject: Newbie needs book advice References: Message-ID: In , Christopher W. Boerger wrote: >Ultimately, after I learn how to use Python well, I hope to create a >free astronomical ephemeris program. Yeah, that's the usual next step for people new to Python. Jim, who has no idea what "astronomical ephemeris" means -- jimhill at swcp.com http://www.swcp.com/~jimhill/ "Let me preface my remarks by saying that I have absolutely no love for Barry Manilow in my heart." -- Jason Lempka From tuttledon at hotmail.com Fri Apr 20 11:42:23 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 20 Apr 2001 15:42:23 GMT Subject: Create/Edit Win32 Shortcuts? References: <3ADDF0DB.B6E7D7A1@bigfoot.de> <3ADFA41A.C8138671@bigfoot.de> Message-ID: [Gerhard H?ring] > > I'll think about polishing it, but for now I have only had a quick > glance over it and put some comments here and there. You can download it > here (source and binary prebuilt for Python 2.1): > http://home.t-online.de/home/err666/VitaminP/index.html > > You can use it like this: > > import WinSetupUtil > > shortcut = WinSetupUtil.Shortcut() > shortcut.setShortcutName( "c:/tmp/TestShortcut.lnk" ) > shortcut.setLinkSource( "c:/WINNT/Notepad.exe" ) > shortcut.setIconFileName( "c:/WINNT/Explorer.exe" ) > shortcut.setIconNumber( 0 ) > shortcut.save() Nice! I really like where you're headed with this. I'm sending you some additional info you might find helpful in expanding it's functionality. > PS: I really don't think it belongs in the library's os module. A > separate module like _winshortcut would perhaps have a chance to get in, > like the _winreg we already have. Noted. Don From sheila at spamcop.net Mon Apr 2 11:02:07 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 02 Apr 2001 15:02:07 GMT Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> Message-ID: On Mon, 2 Apr 2001 10:27:37 +0000 (UTC), duncan at rcp.co.uk (Duncan Booth) wrote in comp.lang.python in article : : :Please don't do this, as it doesn't do what you think. : :>>> a = 0 :>>> b = -5 :>>> (a > b) and a or b :-5 : :and consider that one of the common uses for a max function is to set a :lower bound of 0 on a calculation. The reference I sited in the post you are replying to: http://diveintopython.org/apihelper_andor.html goes over that difficulty and how to get around it. Still, I personally wouldn't use this method. if-else seems fine to me? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dsh8290 at rit.edu Wed Apr 18 17:27:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 18 Apr 2001 17:27:36 -0400 Subject: What can you do with python? In-Reply-To: ; from icecap85@hotmail_NOSPAM_.com on Wed, Apr 18, 2001 at 01:07:50PM -0400 References: Message-ID: <20010418172736.E20005@harmony.cs.rit.edu> On Wed, Apr 18, 2001 at 01:07:50PM -0400, Ice Cap wrote: | Well I made small samples and they run in dos. But I was thinking thats how | all python programs run, in dos. Can you make a gui for python porograms? You can make many different kinds of guis. Just to name a few : PyGTK wxPython PyQt Tkinter Someone already posted a link to a list of gui toolkits available for python. Also, your comment sounds like you aren't very familiar with good command line ('dos' in your words) tools. I just want to let you know that there are some very good tools that don't have any gui at all, but I don't know of any that are natural on windows (cygwin not being considered "natural" here). -D From jafo at tummy.com Sat Apr 21 21:28:56 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 21 Apr 2001 19:28:56 -0600 Subject: ANNOUNCE: Newer 2.1 RPMs. In-Reply-To: <20010421110238.A20227@tummy.com> Message-ID: <20010421192856.A10208@tummy.com> Not only did the last announcement contain errors, so did the package. Here an updated announcement, use these ones instead of the 2.1-3 version. IDLE now works as well. If anyone wants to contribute to this project, I have a few ideas on how to make an RPM verification tool. ;-) Sean =========================== Through a quirk in RPM, the 2.1-2 RPMs still had pymalloc enabled. I've added some work-arounds to resolve this. Thanks to Ron Bickers for pointing it out (and to Kevin Fenzi for the GHz Athlon box on which I did a few dozen builds to come up with the work-around ;-). Also new in this version is the "tools" sub-package, including the contents of the "Tools" directory, and IDLE can be run via "/usr/bin/idle". Thanks to Jason R. Mastaler for the -tools suggestion. You can find the SRPM at: ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS/python2-2.1-4.src.rpm And binaries for RedHat/KRUD 7.0 at: ftp://ftp.tummy.com/pub/tummy/RPMS/binaries-KRUD-7.0-i386/ where you'll find the packages: python2-2.1-4.i386.rpm python2-devel-2.1-4.i386.rpm python2-tkinter-2.1-4.i386.rpm python2-tools-2.1-4.i386.rpm NOTE: There are also "python-*" versions of these packages, which are configured to install "/usr/bin/python" instead of "/usr/bin/python2". Only pick up one of the "python2-*" or "python-*" package sets. Sean -- Examine what is said, not who speaks. (Arabian Proverb) Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From kamikaze at kuoi.asui.uidaho.edu Wed Apr 18 18:42:26 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 18 Apr 2001 22:42:26 GMT Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: <9bl36b$ab5$1@panix2.panix.com> Message-ID: 18 Apr 2001 15:07:07 -0700 in <9bl36b$ab5$1 at panix2.panix.com>, Aahz Maruch spake: >> >Looks decent so far, but it's pretty dinky at 1280x1024 on a 19" >monitor. ;-) I'd suggest making object manipulation your next task, >so it's not just wandering around. There's already items in the world, though the world generator doesn't make them yet. There's two demo items up in the fortress to the west of the starting street. Let me know if the interface for dealing with them makes sense... -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From chris at voodooland.net Thu Apr 12 23:29:01 2001 From: chris at voodooland.net (Chris Watson) Date: Thu, 12 Apr 2001 22:29:01 -0500 (CDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: Message-ID: <20010412222829.H7185-100000@open-systems.net> > If you suspected it was happening, you could look for the bugs. There are > many different ways to have bugs in your programs, as many of us have > discovered, so a relatively small bug collection is a good fingerprint. You can also "string" the binary which usually turns up evidence unless they are really clever. ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From shippy at nmt.edu Fri Apr 27 00:04:28 2001 From: shippy at nmt.edu (Jeff Shipman) Date: Thu, 26 Apr 2001 22:04:28 -0600 Subject: for loop troubles Message-ID: <3AE8EFCC.CEFCF61F@nmt.edu> I've used this method before to do funky for loop stuff, but for some reason, I'm getting a line skipped this time. What I'm trying to do is convert items that have one or more tabs at the beginning of a line followed by a * into unordered list HTML. If I ever hit more tabs than I'm currently at, I must be in a sublist so I call this function recursively. It all works great except when I come out of the recursive call, it seems to skip the line right after (the first previous-level element). Here's a code snippet with the results --- #!/usr/bin/python import sys, re def print_list(linelist, depth): if re.match('^\t+\*', linelist[0]): # Unordered list level = len(re.match('^(\t+)\*', linelist[0]).group(1)) print 3*depth*' '+'
    ' for line in linelist: matchob = re.match('^(\t+)\*', line) if matchob and len(matchob.group(1)) > level: # Uh oh, sublist! newlist = [] j = linelist.index(line) while not matchob or (matchob and len(matchob.group(1))) > level: newlist.append(linelist[j]) linelist.pop(j) matchob = re.match('^(\t+)\*', linelist[j]) print_list(newlist, depth+1) newlist = [] elif not matchob: print 3*(depth+1)*' '+line, else: print 3*(depth+1)*' '+'
  • '+line[depth+1:], print 3*depth*' '+'
' lines = [ '\t* First level list\n', '\t* Another element\n', '\t\t* A second level element\n', 'Continuation of second level element\n', '\t* I\'ll never appear!\n', 'Continuation if final element\n' ] print_list(lines, 1) -- This results in:
  • First level list
  • Another element
    • A second level element Continuation of second level element
    Continuation if final element
-- Sure enough, the line that says it'll never appear doesn't. I'm assuming it must have something to do with my linelist.pop(j), but I do something similar to this in several other locations in the program and I've done it in other programs with no odd problems. Basically, I'm doing that to get rid of all the lines I'm passing to the recursive call. It all seems to work great! Even if I have it print out my linelist through every iteration, I always see that mysterious line, but for some reason it just gets skipped. I have no clue why. If someone could please shed some light on my problem with a possible fix or another way of doing what I want to do, I'd greatly appreciate it (like, a whole bunch!). I've been looking at this for a couple hours now trying to figure out what I'm doing wrong, and my eyes are feeling heavy..... Thanks in advance! -- Jeff "Shippy" Shipman E-Mail: shippy at nmt.edu Computer Science Major ICQ: 1786493 New Mexico Institute of Mining and Technology Homepage: http://www.nmt.edu/~shippy From haaserd at yahoo.com Thu Apr 19 19:44:03 2001 From: haaserd at yahoo.com (haaserd) Date: Thu, 19 Apr 2001 16:44:03 -0700 Subject: Ann: ActivePython 2.1 (build 210) References: Message-ID: <3ADF7843.42C686AD@yahoo.com> I am confused about the different Python distributions and how they fit (or don't fit) together. I have been using BeOPen Python 2.0 for awhile and recently downloaded ActiveState Komodo. Komodo seems to come with it's own Python 2.0, but doesn't appear to have the doc folder or Idle (I am a Windows user). Even more confusing, Komodo appears to be using the BeOpen Python because I added PIL to it. I haven't located PIL in Komodo's Python, but I can access the PIL module. And most recently, I have just started tinkering with Zope, which appears to have its own Python 1.5. So how does ActivePython fit into this scheme? Will I be able to eliminate the BeOpen and the Komodo Pythons (and continue to use Komodo and Idle)? Roger Haase Paul Prescod wrote: > We are pleased to announce ActivePython 2.1 (build 210), a distribution > of Python 2.1. > > http://www.activestate.com/ASPN/Downloads/ActivePython/ > > ActivePython contains a superset of the functionality available in the > reference distribution of Python. It has been tested on a variety of > platforms including various variants of Windows 9X, NT and 2000, Red Hat > and Debian. > > Highlights of ActivePython 2.1: > > On all platforms: > > * full Python 2.1 support (100% compatible) > * rebuilt package repository including Numeric, PIL, PyXML, etc. > * bundled XML parser and zlib compression library > > On Win32: > > * interactive win32 module browser > * bundled Tk > * enhanced version of the bundled Pythonwin environment > * upgraded win32 extensions > > ActivePython 2.1 also supports all of the new features of Python 2.1, > including: > > * "weak references" facility for implementing caches and other similar > data structures. > * richer comparison mechanism > * warning framework > * new module documentation extraction facility > * ability to refer to variables from any containing scope. > * unit testing features > * faster line by line file reading > > We at ActiveState are proud to provide ActivePython to the Python > community! > > Paul Prescod > ActivePython Technical Lead > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook From vincent_a_primavera at netzero.net Tue Apr 3 12:19:21 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Tue, 3 Apr 2001 12:19:21 -0400 Subject: Time... Message-ID: <01040312192105.00574@tos1> Hello, Does anybody have an example of how to use a simple time object to show the system date and time in detail? Thank You, Vincent A. Primavera From aleaxit at yahoo.com Tue Apr 3 15:20:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 3 Apr 2001 21:20:43 +0200 Subject: Python and Java Compared? References: <3ac6f744_1@news4.newsfeeds.com> <3aca143c_2@news4.newsfeeds.com> Message-ID: <9ad7o40a4p@news1.newsguy.com> "Dry Ice" wrote in message news:3aca143c_2 at news4.newsfeeds.com... > [...] > > Observations greatly appreciated. > > > If you need/want to run in browsers, use jython to generate Java > > bytecodes from your Python source and pack it up in a jar. > > > > How about applet production? Possible with Jython? Piece of cake -- see http://www.jython.org/applets/index.html. Alas, there _is_ a 200K library to be downloaded -- which may make it impractical if you're targeting users with moderately slow modem connections and/or short attention spans -- but, in exchange, a 'hello world' applet source is as small as: from java.applet import Applet class HelloWorld(Applet): def paint(self, g): g.drawString("Hello from Jython!" 20, 30) Alex From phrxy at csv.warwick.ac.uk Mon Apr 9 19:06:26 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 10 Apr 2001 00:06:26 +0100 Subject: linux & users' python-extensions In-Reply-To: References: Message-ID: On 9 Apr 2001, [iso-8859-2] Pawe? Sto?owski wrote: > I've installed Python into /usr/local/bin and /usr/local/lib/Python2.0. > Now I'd like to allow an ordinary user to maintain his own python-extensions > modules (written in C/C++). So, each user's python programs should see > the global modules hierarchy, but also allow the user to import his own > modules and link coresponding C/C++ modules, when needed. Is it possible > without cluttering global Python-configuration each time an user needs > to play with his new extension-module? I'm new to Python, so any help [...] There's no problem with that -- your users just have to set their PYTHONPATH. You can guess what that does from the name! :) Although documentation is sketchy ATM, Distutils does make things easier with building extensions. John From stephen_purcell at yahoo.com Wed Apr 18 12:26:02 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 18 Apr 2001 18:26:02 +0200 Subject: Deprecate self In-Reply-To: <20010418120047.F17128@harmony.cs.rit.edu>; from dsh8290@rit.edu on Wed, Apr 18, 2001 at 12:00:47PM -0400 References: <9bji5k$417$0@216.39.170.247> <"from <20010418171043.A12300@freedom.puma-ag.com> <20010418120047.F17128@harmony.cs.rit.edu> Message-ID: <20010418182602.A12629@freedom.puma-ag.com> D-Man wrote: > It doesn't work quite as nicely with inner classes though : Probably the following will work: Bar.this.doSomething() ; instead of this.doSomething() ; Anyway, Jikes isn't the most reliable java compiler when it comes to inner classes. Your example will probably work fine with javac. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From sholden at cox.rr.com Mon Apr 23 16:06:08 2001 From: sholden at cox.rr.com (Steve Holden) Date: Mon, 23 Apr 2001 20:06:08 GMT Subject: Does Python seem appropriate for me? References: <9c20i5$qhc$1@solaria.cc.gatech.edu> Message-ID: "Holland King" wrote in message news:9c20i5$qhc$1 at solaria.cc.gatech.edu... > Tim Peters wrote: > : the littlest things will drive you mad. Trivial example: say you use > > : dir/s *.py > > : today to find all the .py files in the subtree rooted at the current > : directory. You're not going to *believe* the hoops you have to jump through > : to get that done under a Unix shell instead. If you have someone around to > > how about: > find . | grep *.py > You'd want quotes around the pattern, and to make sure that the ".py" was at the end of the filename. Probably simpler just to use a -name argument as already suggested. regards Steve From sholden at holdenweb.com Wed Apr 25 15:05:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 25 Apr 2001 19:05:43 GMT Subject: Named code blockes References: Message-ID: "Tim Peters" wrote in ... > >> I count four ways ('import', 'def', '=', and augmented assignment), not > >> counting 'globals().set' and similar tricks. > > > Then there's class. I count five ways ... > > Plus implicit assignment to formal parameter names upon function entry, > explicit assignment due to appearance as a for-loop target, and conditional > assignment in the (optional) second position of an "except" clause. There! > Now you're done. > > > nobody-expects-the-spanish-inquisition-ly y'rs - steve > > they-would-if-they-read-the-reference-manual-ly y'rs - tim > I wouldn't dare disagree. I suppose you *do* realise you've just reduced a feeble long-running thread to a single post? regards StevE From objectway at divalsim.it Wed Apr 4 07:58:13 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Wed, 04 Apr 2001 13:58:13 +0200 Subject: Python Books for 2002 References: Message-ID: <3ACB0C55.460D3ED8@divalsim.it> Simon Brunning wrote: [...] > Is it just me that finds it ironic that Alex is writing 'Python in a > Nutshell'? A couple of apter titles just came to my mind: "Encyclopaedia Pythonica" and "The Art of Python Programming". Best regards, Nicola Musatti From brey at ductape.net Tue Apr 3 14:21:22 2001 From: brey at ductape.net (brey at ductape.net) Date: 3 Apr 2001 18:21:22 GMT Subject: Outputting References: Formatting RFC 822 date Message-ID: <9ad4b2$soo$1@news.netmar.com> I'm using smtplib to send an email message, and I'd like to put a Date: line in the header. However, formatting the timezone portion of the date line correctly seems to be a real highly non-trivial. time.strftime only outputs the time zone as a string, and none of the variables in the time module are easy to convert to the -600 style format. Ironically, there is rfc822.parsedate, which does the opposite of what I need (and is probably much harder to write). Is there a module that I'm missing that will take a time tuple and output the proper RFC 822 date string? Thanks in advance, Ed ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web ----- http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups NewsOne.Net prohibits users from posting spam. If this or other posts made through NewsOne.Net violate posting guidelines, email abuse at newsone.net From fredrik at pythonware.com Tue Apr 10 02:46:22 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 10 Apr 2001 06:46:22 GMT Subject: local variable not destructed if the function raised a exception References: Message-ID: <2%xA6.6436$4N4.1387943@newsc.telia.net> "javalist" wrote: > in f(),c1i is constructed correctly but after raise the exception(any exception),python > didn't call c1i's destructor,in f1(),the behavior is just normal,destructor is called after > f1() returns.anyone tell me why this happen,is this a bug or just a feature? feature. the traceback object (sys.exc_traceback) contains a reference to the execution frame, which contains references to all local variables. under normal use, the traceback is destroyed (and all locals released) on the next return or raise. for more info, see sections 7.4 and 3.2 in the language reference. Cheers /F From Haris_member at newsranger.com Mon Apr 2 13:28:22 2001 From: Haris_member at newsranger.com (Haris Lekatsas) Date: Mon, 02 Apr 2001 17:28:22 GMT Subject: locking files on freebsd Message-ID: Hello, I have a problem with locking files. The following code will work on several OS but it seems to fail on FreeBSD giving an IOError. Any ideas? f = open('filename', 'w') fd = f.fileno() flock = struct.pack('2h8l', FCNTL.F_WRLCK, 0, 0, 0, 0, 0, 0, 0, 0, 0) fcntl.fcntl(fd, FCNTL.F_SETLKW, flock) Thanks Haris Lekatsas From tim.one at home.com Thu Apr 5 01:47:28 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 5 Apr 2001 01:47:28 -0400 Subject: A couple garbage collector questions In-Reply-To: <20010404194644.A15906@glacier.fnational.com> Message-ID: [Neil Schemenauer] > I also had to disable the integer, float, and method object > freelists [in order to give the BDW collector a fair trial] [and later] > To be fair I re-ran pystone with the freelists disabled for the > referencing counting interpreter (source from CVS): That's a false fairness, though. As Boehm would tell you (in fact, I think he *did* just a few months ago ), the BDW scheme *should* work best without Python managing its own freelists. But Python's refcount scheme works best with managing its own freelists (indeed, that's why they're there!). Fairness consists of doing the best thing for each scheme, even when they differ (comparing BDW to a castrated version of Python's current scheme neither measures reality nor gives BDW a worthy target to shoot for ). Disabling the freelists would be a more interesting experiment when using Vladimir's pymalloc allocator, because (a) pymalloc was designed to favor small allocations; and (b) the platform malloc often sucks. Python uses freelists primarily because the effect of #b is so damning across platforms ("malloc sucks on yet another platform? OK, let's try not using malloc at all ..."). getting-to-reuse-trash-instantly-is-the-norm-under-python-rc- not-the-exception-ly y'rs - tim From schaffer at optonline.net Mon Apr 23 20:45:20 2001 From: schaffer at optonline.net (Les Schaffer) Date: Tue, 24 Apr 2001 00:45:20 GMT Subject: GetTickCount vs. clock for msec resolution References: <8f7vdtk3ukd35mbr15bass72mg2erf95ks@4ax.com> Message-ID: <0pi9et8ajau3qo9bgofij2mf0jiqp7irih@4ax.com> On Fri, 20 Apr 2001 01:38:25 -0400, "Tim Peters" wrote: >In any case, don't mistake resolution for accuracy. You didn't ask about >accuracy <0.5 wink>. accuracy not an issue for me at all at this point on this project. based on what i read on this thread, if accuracy or smaller resolution were important to me, i'd put the timing junk and the serial reads down in a C extension. i am just about finished rewriting a C++ serial communications module, for a test instrument i am working on, into Python code. its just _incredible_ how much more understandable and sane the python code is over the C++ stuff. doing the re-write even helped me find bugs in the C++ serial port code that were hard to track down before. so even if i never use the Python version, it was still worth doing. virtual fefactoring, i guess. les schaffer From claird at starbase.neosoft.com Thu Apr 5 15:08:50 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 5 Apr 2001 14:08:50 -0500 Subject: Python Books for 2002 References: Message-ID: <640EB1AA17E67611.2AFAC885441E145D.64EA9B315A8920A6@lp.airnews.net> In article , Kemp Randy-W18971 wrote: >So why not a Python for Dummies or a Perl for Idiots book? . . . I take it you're not familiar with ? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From spahievi at vega.bg Wed Apr 25 16:07:06 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Wed, 25 Apr 2001 23:07:06 +0300 Subject: COM server with [in,out] args how? Message-ID: <204840388.20010425230706@vega.bg> Hello, is it possible to implement in python COM server interface like this: spam( [in] short a, [in,out] short * b, [out,retval] BSTR * c ) all except [in,out] arg works ok. -- Best regards, Niki Spahiev From P.FREMY at OBERTHURCS.com Fri Apr 27 10:43:34 2001 From: P.FREMY at OBERTHURCS.com (Philippe FREMY) Date: Fri, 27 Apr 2001 16:43:34 +0200 Subject: how to distribute a python application Message-ID: <191CBBF91062D411855D00D0B76F1C30550486@PROXIMA> Hi, I hope this is the right mailing list for this. I have developed a small application in python with PyQt (klotski at http://klotski.berlios.de/klotski) and was faced with the problem of distributing and installing it. I was pointed to distutils but it didn't answer my needs. Distutils is pretty efficient for distributing python modules but doesn't handle the specific needs of application installing. My requirements are: 1. Find a standard place to store application data 2. Find a standard way to run my app (loader, wrapper, just type "python myapp.py" ?) 3. Find a standard way to load my installed data at runtime 4. Install my application in the Gui menus (Kde, Gnome, Windows, Mac, ...). Although it was originally stated in the distutils introduction that application installation was one of the goals, it doesn't look like it is one target anymore. Or nobody is working on it, which is pretty the same. Python is now becoming really popular and with lot of graphical toolkits available (PyQt, PyGtk, PyGnome, PyWxwindos, TkInter to name a few) and recent development in Desktop Environments, we can expect more and more applications being developed. But when faced with distribution, developers are forced to use their own installation method which are very likely to be non portable and non standard. This is not the way it should be done, and was one of the reasons the distutils-sig was started. I think a new SIG is needed to address this specific problem. I don't think there is too much work to be done. Distutils has already prepared the road. What is needed is: 1. define where to install application data and how to load them 2. define how to run a python application 3. provide a set of scripts to install python on various environments: gnome, kde, windows, mac, etc. It shouldn't be that hard to do given that a lot of c and c++ application already do it. 4. provide a unified interface, or universal installer that let you define meta-data for your installation and then let the installer choose what and how to install. Something like a meta InstallShield for all supported python platform My hope, by writing this message, is that this concern will be understood and that someone or even a group of someone will step forward to do the job. Okey, I am perhaps dreaming a little bit too much here, but there is really a great need in this area. I hope this is the right mailing list for posting this. I was looking for a python-devel mailing list but couldn't find it. If such a mailing list exists, please tell me or forward them my message. I am not subscribed here, so please CC me any answer. Best regards, Philippe Fremy From bbollenbach at homenospam.com Sun Apr 15 17:13:36 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sun, 15 Apr 2001 21:13:36 GMT Subject: Newbie Question References: <3ADA012D.E7B28E9B@voicenet.com> Message-ID: <4aoC6.1515$4I5.227395@news1.rdc1.mb.home.com> "Gregory T. Weber" wrote in message news:3ADA012D.E7B28E9B at voicenet.com... [snip] > I suspect that the installation is at fault [snip] Nope, it appears that the operator is. :) [snip] > After making first.py executable I figured I could do this > > >first.py [snip] And you can, but if "." (aka, the current directory) isn't part of your path how would the shell find it? You probably meant to type "./first.py". HTH, Brad From sdm7g at Virginia.EDU Wed Apr 11 17:27:08 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 11 Apr 2001 17:27:08 -0400 (EDT) Subject: other python ideas In-Reply-To: Message-ID: On 11 Apr 2001, Nonexistence wrote: > "Andrew Dalke" writes: > > > Douglas Alan: > > [snipped...] > > > > Unfortunately, the Common Lisp module system is unbearably > > > complex. > > For most purposes, all you need to know about Common Lisp's module > (package) system are DEFPACKAGE, IN-PACKAGE, and the ":" "::" referencing > convention; I can't see how that is more complex than what is available in > Python. Its spec is lengthy because it is well thought out, and addressed > most issues that have been discussed so far, and then some. IMHO, Common > Lisp's package system is no more complex than warranted, given the scope > and complexity of the problem it solved, and it is certainly not too > complicated to use for simpler purposes. > I know Lisp. I use Lisp (in Biology, even!). And that doesn't sound like the Common Lisp package system I know! As soon as you try to do something non-trivial using CL Packages, you will run into symbol clashes, you will have to figure out how to unintern and shadow symbols, when you do hit a name clash that causes USE-PACKAGE to fail, you will not be sure exactly what state you're left in, what symbols are defined and what aren't, and where they're coming from unless you wrap everything in some exception handling code, and none of the Lisp books (except the Common Lisp spec.) go very far into describing how to build packages, as opposed to how to use them. When I sought some answers on Comp.lang.lisp, I got some very helpful answers and tips. Among them were the admission that, yes, Packages are one of the dark and hairy corners of Common Lisp and they aren't explained very well in any of the common texts. Also, several people pointed out, that CL Packages are a package system, not a Module system: they are intended to be rather less used and larger that Python modules ( You might typically have 3 or 4 packages in a large Common Lisp app, as opposed to dozens or more Modules in a Python app. ), and they really weren't designed to do the sort of stuff you typically use Modules for in Python. I'm a fan and user of both Lisp and Python, and Python's module system is MUCH simpler, easier to use, and easier to comprehend than Common Lisp packages. -- Steve Majewski -- Univ. of Virgina Dept of Molecular Physiology and Biological Physics From chris.gonnerman at usa.net Thu Apr 19 23:53:18 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 19 Apr 2001 22:53:18 -0500 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: <9blulk$dtj$1@panix6.panix.com> Message-ID: <00dd01c0c94d$72164220$a100000a@local> ----- Original Message ----- From: "Mark 'Kamikaze' Hughes" Subject: Re: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha > There are two reasons not to: the practical, and the philosophical. > > The practical side is that people would have the urge to start > fiddling with the source, and I *really* can't spare the time to even > hear about their diffs, let alone use them, especially since I refactor > mercilessly so the code base changes rapidly. And they would start > fiddling with the source, because the only people who are likely to run > it at this point are Python programmers. I won't be. I don't even run the same version of Python on all my computers (upgrading them all is a lot of work). If I had source, yeah, I'd play with it... probably find a few bugs. If you don't want to deal with the diffs, ignore them, but you may be ignoring real bug reports. Refactoring doesn't excise all the old code, after all, not to mention the old bugs. (BTW why do people talk about refactoring like it's a new thing? I've been doing it for years, but didn't have a cool name for it...) > I'd rather hear high-level suggestions; "stories" in Extreme > Programming terms. > The philosophical side is that it's my code. Yes, I believe in code > ownership. If I *choose* to give people access to my source, then > that's fine but if I choose not to, then that's also fine. True. No argument there. > Now, when it > gets to a stable, basically finished state, I do plan to release it as > open source and start working on a multiplayer, server-side, > browser-client version. That's likely to be a year or so in the future, > though. Until then, it's going to be distributed as .pyo files (and I > will take a very, VERY dim view of anyone decompiling them and > distributing the source, as that is a copyright violation and I can and > will take action; think how cranky I normally am, and then multipy that > by a factor of 10). Don't know you personally, so can't evaluate. Compiled Python files are inefficient, though, since the bytecode changes with each version. > That I even have to *state* that indicates that a certain group of > people have really done a job of poisoning the well of software > development. I loathe and despise the communist types like St*llm*n who > want to prevent anyone from owning their own software. Don't go there. I've been in this argument already once this week, so I won't visit it again. If Stallman is Communist, I must be a Socialist, but frankly I am more like a Libertarian. > Not that I'm suggesting that you had that in mind, but those are the > consequences of "just use source". I'm not sure how it's a consequence. Your copyright protects you exactly as much with or without the source code. Ignoring patches/diffs is about as hard as ignoring spam (which I'm sure you do every day, just like me). On the other hand, available source means possibly useful bug reports, more meaningful feature suggestions, and less hassle from people with varying Python versions. From aahz at panix.com Fri Apr 20 10:40:05 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Apr 2001 07:40:05 -0700 Subject: do...until wisdom needed... References: Message-ID: <9bpho5$7j8$1@panix2.panix.com> In article , Neelakantan Krishnaswami wrote: > >My personal suspicion (and this is just a guess) is that if >syntactically lightweight generators and coroutines were added to >Python, then the pressure for new features would fade. Generators (called "iterators") are going to be 2.2. They'll be more powerful that Icon's generators; it's not clear whether they'll be a full-fledged substitute for coroutines. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Beware of companies that claim to be like a family. They might not be lying." --Jill Lundquist From owen at astrono.junkwashington.emu Fri Apr 13 11:57:41 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Fri, 13 Apr 2001 08:57:41 -0700 Subject: I come to praise .join, not to bury it... References: <98qeco02hn7@news1.newsguy.com> <98rmod$c8p$1@animus.fel.iae.nl> <98tacr0q5s@news1.newsguy.com> <9b4nen$ka2$1@nntp6.u.washington.edu> <9b6v8702lsj@news2.newsguy.com> Message-ID: <9b77ln$pbe$1@nntp6.u.washington.edu> >It would take little to write a collection class, but making >_types_ (as opposed to _classes_) "inherit" from a class would >require major surgery to Python. As things stand, types just do >not "inherit". Lists, strings, Unicode strings, tuples, >dictionaries and arrays (in standard module array) are all >types. Thanks. I realized that later when thinking more about it. Thanks for the helpful reference (elided; read Alex's message) to PEP 246. It sounds very helpful in this context. >> - the % operator could work on any kind of collection; I occasionally >> try to use a list instead of a tuple > >That would break existing code: > >>>> print "ba%sbo"%range(2) >ba[0, 1]bo Fascinating. I thought this was deprecated if not already illegal, as remember reading a threat to insist that % always have a tuple (or dict) to the right of it. Has that been rescinded? (Did I misread something?). I'd already reluctantly changed my coding style to accomodate the change. It's certainly tempting to leave out the (,) when one has a single item to print, and if this is Approved Style then I'm not going to cry over lists and list-like items needing a tuple() around them to act as tuples. -- Russell From aleaxit at yahoo.com Thu Apr 12 04:52:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Apr 2001 10:52:48 +0200 Subject: Chocolate [was Re: Python Books for 2002] References: <3AD3C751.CF669272@cosc.canterbury.ac.nz> <5eRA6.411$C4.21656@uchinews> <3AD50BB3.E71891A2@cosc.canterbury.ac.nz> Message-ID: <9b3qdh02o0o@news1.newsguy.com> "Greg Ewing" wrote in message news:3AD50BB3.E71891A2 at cosc.canterbury.ac.nz... > Ben Wolfson wrote: > > > > from Animals.Mammals import Human > > > > hungry_person = Human() > > > > So that the hungry_person can .consume() the comestibles. > > But the method of consumption depends on the class > of the substance, so dispatching on it seems > appropriate. Perhaps > > substance.be_consumed_by(person) We really need multiple-dispatch, because many substances may be differently consumed by instances of different concrete subclasses of Animal -- e.g., milk will be lapped up from a saucer by an instance of Cat, but an instance of Human is unlikely to .consume() it that way. As is all too usual when multiple-dispatch is really what's underlying our efforts (very often the details of interactions between objects X and Y depends on the concrete-classes of both objects!), no single-dispatch solution is fully, 100% satisfactory. Are we more likely to add different concrete subclasses of Consumable in the future, or different concrete subclasses of Consumer? I suspect the former is more likely -- new kinds of chewables, drinkables, smokeables, etc, are likelier to get developed and marketed than new kinds of Animal. So, we should assume that a Substance (Consumable) "knows about" all of its possible Consumer kinds when the code for its methods is written, rather than vice-versa. Of course we should still factor common code out to appropriate mixin classes, but the dispatch on Substance still looks like the right architecture. Note that the architectural choice is determined by a survey of likely foreseen use-cases, not by vague aesthetic considerations:-). Our predictions can be wrong. If a starship lands tomorrow, full of alien life-forms that are interested in .consume()'ing our varieties of Substance, we'll need to refactor... oh well! Alex From glenfant.nospam at bigfoot.com Fri Apr 6 08:32:33 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Fri, 6 Apr 2001 14:32:33 +0200 Subject: Python Sound References: <3ACD3362.14AF675F@2bitunix.com> Message-ID: <9akcop$154$1@news5.isdnet.net> 100% pythonic, compact and portable... |-)) >>> print '\a' "Michael D. Risser" a ?crit dans le message news: 3ACD3362.14AF675F at 2bitunix.com... > Does anyone know of system independant way to access the built-in > speaker? > > > Posted Via Usenet.com Premium Usenet Newsgroup Services > ---------------------------------------------------------- > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** > ---------------------------------------------------------- > http://www.usenet.com From chapman at bioreason.com Thu Apr 12 20:01:43 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Thu, 12 Apr 2001 18:01:43 -0600 Subject: Tangents and the like... References: <3ad64110$1@news.actrix.gen.nz> Message-ID: <3AD641E7.68CC0A99@bioreason.com> Mark Rowe wrote: > Just been reading through the Math modules documentation and i can't see any > way to find the inverse tangent of a number.... I know that this is > possible, but how? >>> import math >>> math.pi/4.0 0.785398163397 >>> math.atan(1.0) 0.785398163397 >>> math.atan2(1.0, 1.0) 0.785398163397 -- Mitch chapman at bioreason.com From wolfson at uchicago.edu Fri Apr 6 12:47:34 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Fri, 06 Apr 2001 11:47:34 -0500 Subject: operator on functions References: <9akpvh$74k$1@news.mathworks.com> Message-ID: <20010406.114734.1244316437.1276@bur-jud-175-024.rh.uchicago.edu> In article <9akpvh$74k$1 at news.mathworks.com>, "Joshua Marshall" wrote: > Szalay Zoltan wrote: >> Hi everybody out there! > >> It would be a nice feature of Python syntax providing an operator to >> compose a function from another two: >> h=f*g . I mean (f*g)(x)=f(g(x). > > Though maybe a little thought needs to go into multiple arguments (to > f): > > (f*g)(x) => f(g(x)) > > -vs- > > apply(f*g, x) => apply(f, apply(g, x)) > > or some hybrid. This seems to work: from __future__ import nested_scopes class Function: def __init__(self, f): self.f=f def __call__(self, *a, **k): return self.f(*a, **k) def __mul__(self, o): return _compose(self, o) def __rmul__(self, o): return _compose(o, self) def compose(f, g): def composed(*a, **k): result = g(*a, **k) if type(result) is not type(()): result = (result,) return f(*result) return composed >>> import compose >>> g = compose.Function(lambda a,b: (a+b, a*b, a-b) >>> f = lambda a,b,c: ((a+b)*c, (a-b)/c) >>> (f*g)(1,2) (-5, -1) >>> (g*f)(1,2,3) (8, -9, 10) >>> h = compose.Function(lambda a,b: a+b) >>> i = lambda a: (-a, a+4) >>> (h*i)(2) 4 >>> (i*h)(2,4) (-6, 10) -- Barnabas T. Rumjuggler The women come and go, Speaking of the Regis Philbin Show -- Joe Frank From jcollin at exis.net Wed Apr 4 20:20:18 2001 From: jcollin at exis.net (Jay Collins) Date: Wed, 4 Apr 2001 20:20:18 -0400 Subject: del()? Message-ID: does del() free the ram used by string? like a = "my string" del(a) will I get my ram back? Should I even worry about this since gc takes care of this? From mwh21 at cam.ac.uk Tue Apr 24 07:40:48 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Apr 2001 12:40:48 +0100 Subject: PyArg_Parse weirds References: Message-ID: Robin Becker writes: > I just get 0 back from the PyArg_Parse so have to assume it didn't work > and as the value printed out suggests it hasn't put anything into r. If it's returned 0 and not set an exception, that's a bug. If it's set an exception, then that might give clues as to what's going on. There's always the C debugger for things like this, too. Cheers, M. -- If a train station is a place where a train stops, what's a workstation? -- unknown (to me, at least) From mal at lemburg.com Fri Apr 20 11:24:29 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 20 Apr 2001 17:24:29 +0200 Subject: [Python-Dev] Class Methods References: <027401c0c9ab$5e3c88f0$e000a8c0@thomasnotebook> <15072.21064.298318.393753@slothrop.digicool.com> Message-ID: <3AE054AD.9A8D07D@lemburg.com> Jeremy Hylton wrote: > > >>>>> "TH" == Thomas Heller writes: > > TH> There are some signs :-) that Python's object model is going to > TH> be revised even _before_ Python 3000. > > TH> Is someone willing to join me fighting for class methods (I mean > TH> 'real' class-methods in the Smalltalk style here, _not_ static > TH> methods like in Java or C++). > > The idea sounds good in the abstract. Class are objects and objects > ought to have methods that implement their behavior. How does that > very vague idea turn into something real? No clue. You start > fighting and let's see where it goes :-). Here's something to start the fight ;-) ... 1) What would you do with class methods that you cannot do with e.g. globals and functions ? 2) How would you determine which methods are class-only methods and which are one usable by instances ? 3) If you don't like globals (see 1), wouldn't it be possible to store the state you want to manipulate using class methods in some other context object ? My impression is that class methods are not really needed and would only make optimizing Python harder... but that's maybe just me ;-) -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From rob at ZOOstation.cc Sun Apr 15 15:25:13 2001 From: rob at ZOOstation.cc (Rob Brown-Bayliss) Date: 16 Apr 2001 07:25:13 +1200 Subject: how to import from variable source In-Reply-To: References: Message-ID: <987362713.2920.0.camel@ZOOstation.cc> On 15 Apr 2001 01:11:45 -0700, Brian Quinlan wrote: > There is probably a better strategy but it is hard to guess what that would > be based on the information given. Thank's this looks good... What I am trying to do is create a pluing system, my app is really just a plugin manager for the sub modules. All (95%) functionality will come from the imported modules -- Rob Brown-Bayliss ---======o======--- www.ZOOstation.cc From tim.one at home.com Sun Apr 8 19:00:02 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 8 Apr 2001 19:00:02 -0400 Subject: Which happens first? In-Reply-To: <5.0.2.1.0.20010408181054.02287800@mail.inet.com.br> Message-ID: [Carlos Alberto Reis Ribeiro] > Just curious, but is it so hard to change the grammar to detect > negative integer literals? I never took the time to look, and probably never will: > ... > On the other hand, I can see that this is not a big issue the vast > majority of time (it would save only a few bytes of bytecode, and > almost nothing on time...) Bingo. If it interests *you*, we're not hiding the source code . The only real reason in my mind to pursue it would be to stop this old (but rare) surprise, here using Python on a box with 32-bit ints: >>> int("-2147483648") # string->int accepts one literal ... -2147483648 >>> eval("-2147483648") # ... that the compiler can't handle Traceback (most recent call last): File "", line 1, in ? OverflowError: integer literal too large >>> > ... > Ok. So let's change my conclusion as follows: 'Avoid any calculation > on literals inside loops in Python, as the compiler will not optimize > anything. Put explicitly out of the loop everything that you can. It's not a rule I follow, because it rarely makes a difference worth the bother. It's good advice for loops whose speed you care about a lot, but identifying those is best ignored until after profiling reveals hot spots. For example, this appears inside a doubly-nested loop in a program I happened to be working on yesterday: lnbot = ln(bot) diff = bot - (top * below) % bot if diff: lg2 = (ln(diff) - lnbot)/_log(2) if lg2 <= smallest_lg: k = ((top * b2nshow * below)>>1) / bot % (b2nshow * b2) k = tostr(k, b2) k = '0' * (NSHOW + 1 - len(k)) + k k = k[0] + "." + k[1:] msg(" below", tostr_exp(below, b1, e), round(lg2 ,2), k) if lg2 < smallest_lg: smallest_lg = lg2 smallest_e2 = e2 msg("^" * 60) diff = (top * above) % bot if diff: lg2 = (ln(diff) - lnbot)/_log(2) if lg2 <= smallest_lg: k = ((top * b2nshow * above)>>1) / bot % (b2nshow * b2) ... much the same as the above ... These are mostly long (unbounded) int operations, so repeating computations like "top * b2nshow" and "b2nshow * b2" can be very expensive, and I could pee away a lot of time factoring them out by hand. But profiling showed that less than 1% of 1% of the runtime was being spent in these two sections: almost all of it was being consumed by the call before it: below, above = modmin(top, 0, bot, thislow, thishigh) Replacing a key algorithm in the guts of modmin with a better approach took about 15 minutes and slashed the total runtime by a factor of 3; making 10 ugly changes to the rest of the loop code could have consumed an hour of my time and *would* have bought nothing worth getting even it came for free. BTW, it was a *surprise* to me that these sections weren't accounting for much more of the runtime than they did, so if I had gone with "my intuition" I would have wasted time spiffing them up. As is, I no longer like the approach here at all, and will throw it away. > This kind of code is optimized in some other languages/compilers, > such as C or Pascal, but not in Python." Curiously, in my experience the percentage of time I spend optimizing a program "by hand" is lower in Python than in C (etc), and I get better speedups despite spending less time on it. A prime reason is that you're *never* going to wring low-level machine-limit efficiency out of Python code, so you spend more of your time dreaming up better *algorithms* than in endlessly tweaking a poor algorithm that's gotten too complicated to throw away because of all the obscure tweaking you've already done <0.7 wink>. > ... > In my case, I tend to use lots of small Python scripts to parse log > files, some of them in binary format. So I end up coding stuff like > this sometimes, to quickly get some information from inside complex > records or structures. "Quickly get" is ambiguous: are you primarily interested in minimizing the time it takes *you* to paste together code sufficient to extract the info of interest, or in minimizing the time it takes the *computer* to run your code? If the former, Python is an excellent choice; if the latter, it may or may not be sufficient for your needs. Over time, I expect you'll find yourself organizing those "lots of small Python scripts" into reusable classes and modules, and then reorganizing *those* over and over again as your ambitions grow. Such continual refactoring is par for the course in Python, unlike as in C or Pascal, because it's relatively *easy* in Python. In the end, one of two things often happens: your ambitions stop growing, and with a now-solid design you can *start* worrying about speed (if indeed that's still "an issue" -- often it's not); or you lose interest in the whole area, and then it's a lot easier on the soul to throw away 500 lines of Python than 10,000 lines of C. There's a danger here: "optimizing" code by hand *before* you've endured those dozen rounds of refactoring makes rethinking your approach harder to implement, which in turn makes it more likely you'll fall back to C-mode endless tweaking of (what very often is) a poor initial approach. In the end, your code will be better and also usually faster, if you delight in Python's expressivity rather than worry over low-level tricks. As a hypothetical and possibly senseless example, let's say it finally occurs to you that you could design a pleasant little language for *describing* the structure of all those log files you're interested in, and a language for identifying the parts you care about. Then maybe you'll write very general and pig-slow "interpreters" for those little languages, just to see how it works. Say it works great. Then you may want to redesign your compiler to spit out a Python program (as a giant string to be exec'ed) tailored for each log file type. Since at this point you haven't wasted any of your time optimizing, tweaking or fiddling the now-doomed interpreter, you *get* to this point a lot sooner. Say the machine-generated Python programs run a lot faster, but still not fast enough (both quite possible). Then you look at what they're doing, and rethink the problem again. Perhaps you'll care to generate C code instead, or perhaps you'll identify some key string-processing tasks you simply can't do quickly enough in pure Python and a write a C extension module for those parts. Whatever, again because you haven't burned time optimizing, you again get to this point much quicker. In the end you come up with a perfectly general solution that runs 100x faster than anything else on the market, you sell it to Oracle for 500 million dollars, and retire. Or maybe in the end you decide it was a fool's errand, and just live with the pig-slow interpreters. See? It's win-win . treat-python-like-c-and-you'll-bring-c's-problems-with-you-ly y'rs - tim From sgendler at akamai.com Fri Apr 13 00:35:59 2001 From: sgendler at akamai.com (Samuel D. Gendler) Date: Thu, 12 Apr 2001 21:35:59 -0700 Subject: embedding python without dynamically lodaed code in Message-ID: <3AD6822F.C19CF0A7@akamai.com> I am using libpython.a (2.0, if you must know) in order to gain access to all of the nifty Python data structures. Currently, we use ONLY the C api. The application gets distributed to several thousand servers around the planet, none of which have any version of python installed, let alone 2.0, and we really have no interest in doing a python install to several thousand servers. When I call PyInitialize() on a machine that does not have python2.0 installed, it complains like so: Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import site' failed; use -v for traceback I don't really care that the import fails (assuming that the PyInitialize still succeeds. I haven't checked the source yet), but it would be really nice to be able to supress these error messages, especially if they are having a negative impact on PyInitialize. Any suggestions would be much appreciated. Please respond to my email as well as any public forum that this might arrive at. --sam From cce at clarkevans.com Thu Apr 5 08:38:30 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Thu, 5 Apr 2001 07:38:30 -0500 (EST) Subject: PEP 245 In-Reply-To: <9ah6rf02352@news2.newsguy.com> Message-ID: On Thu, 5 Apr 2001, Alex Martelli wrote: > Bingo! A "contract" -- including some promises > on the existence and signature of methods, some > on functionality (pre/post conditions), even, > maybe, some on performance. Austern's "Generic > Programming and the STL" focuses on "a set of > abstract _concepts_ ... a type conforms to one > of those concepts if it satisfies a certain set > of requirements ... this hierarchy of concepts is > the conceptual structure ... the most important > part ... what makes reuse and interoperability > possible ... the essence of generic programming". I _really_ like the word "contract". Interface brings into my mind all kinds of hoops that I have to jump in order to connect two components. What I like about Python thus far is that it assumes the programmer is right... and marches along, not being too smart, until it can't go further. This is a very nice property of the language and I can see people balking if "java-style interfaces" are added. Michel, It may be too late, but how about ammending 245 to use the word "contract" instead of "interface". Just thinking. Words bring with them meaning, and your proposal isn't anywhere near as strict as Java or COM interfaces... But, perhaps I'm being stupid here. And I whole-heartedly agree with Alex below. > Focusing on the amount of compile-time, or even > run-time, _checking_, that a certain language can > offer, is missing the point -- _expressiveness_ > is what we need to ask, so the "abstract concepts" > can be *stated* formally. ... > No problem! Letting the programmer express his > or her _design intent_ clearly in the language > will be a big help anyway. The very least we can > ask is being able to _state_ "this thingy, here, > conforms to the 'ReadableForwardOnlyStream' abstract > concept" (call it protocol, interface, concept -- > the choice of name is a secondary issue); even > better, by PEP 246, being able to ask for some > 'adaptation' of object-to-concept if feasible. > > Whatever subset of the concept can be expressed > in the language will further help, and a further > small help may come if some checking can also be > automatically performed (the earlier the better), > but *all of this is secondary* -- the *primary* > need is for direct support of the primitive > notion of 'protocol' (aka 'interface', etc, etc), > as (e.g.) per PEP 245, and the most useful single > step beyond that is the notion of adaptation (as > per PEP 246). From jj at void.si Tue Apr 24 06:26:16 2001 From: jj at void.si (jj) Date: Tue, 24 Apr 2001 12:26:16 +0200 Subject: Python + Borland - msvcrt = grr. References: Message-ID: Hm, I posted the same stuff a month ago. I hope you fixed -D_DEBUG issue. JJ On Mon, 23 Apr 2001 07:06:02 GMT, "Stephen" wrote: >Howdy, > > I just sent in the patch to fix up all the Python sources to let it >compile from the Borland free compiler or C++Builder. This leaves two issues >remaining before I put up the projects/makefiles somewhere: > > #1) BCC is giving off the STRANGEST warnings. They make no sense-at-all, >it seems to me that the compiler doesn't comprehend that a variable that >only gets modified by macros is actually being modified, so it complains a >LOT about 'variable is assigned a value but never used' etc. Anyways, I'm >looking to the C++Builder for a fix on this :) > > #2) 'msvcrt'. That's the only barrier to actually having the sources >compile if my patch is added in. I havn't yet actually looked at how much >can be salvaged/#ifdef'd around to duplicate the functionality for >borland... but I have a question: > > Why the heck is it called _msvcrt_? Half of it will work right now -- I >know Borland supports putch/getch, for instance. The other half will likely >just need some minor fixes. The module *really* should be called >'winconsole' or something. > >Anyways. :) > >--Stephen >(replace 'NOSPAM' with 'seraph' to respond in email) > From luthi at vaw.baug.nospam.ethz.ch Wed Apr 11 02:49:00 2001 From: luthi at vaw.baug.nospam.ethz.ch (luthi at vaw.baug.nospam.ethz.ch) Date: 11 Apr 2001 08:49:00 +0200 Subject: python 2 latex Message-ID: Try the listings package included in the standart TeTeX distribution. It will pretty print your code in any language (Python included). Through format options it should be easy to color the output. Cheers Martin From grante at visi.com Sun Apr 8 21:45:15 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 09 Apr 2001 01:45:15 GMT Subject: UNIX domain sockets problem References: Message-ID: On Mon, 09 Apr 2001 01:37:16 GMT, Dan Maas wrote: >>> SERVER = socket(AF_UNIX, SOCK_DGRAM, 0) > >Change SOCK_DGRAM to SOCK_STREAM Bad idea if he really wants a datagram service and not a stream service. -- Grant Edwards grante Yow! Do I hear th' at SPINNING of various visi.com WHIRRING, ROUND, and WARM WHIRLOMATICS?! From maxm at normik.dk Thu Apr 26 05:55:38 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Thu, 26 Apr 2001 11:55:38 +0200 Subject: function pointers Message-ID: <7BD10B680501D411B9DF009027E06F32197CD2@exchange> > From: Brandon J. Van Every [mailto:vanevery at 3DProgrammer.com] > I get the feeling that Python doesn't have anything > resembling a function > pointer? i.e. no way to call a specific function according > to the value a > variable is set to? Might this be what you are looking for? def hello(): return 'hello' def world(): return 'world' functions = {} functions['hll'] = hello functions['wrld'] = world print functions['hll']() print functions['wrld']() regards Max M From michael at stroeder.com Tue Apr 10 10:53:03 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 10 Apr 2001 16:53:03 +0200 Subject: Clean-up of threaded server References: <3AD1D149.DBAFA7AF@stroeder.com> Message-ID: <3AD31E4F.28A3B249@stroeder.com> David Bolen wrote: > > Michael Stroeder writes: > > > I have two problems: > > > > 1. The server process does not detach from the console anymore (fork > > is used for that). This seems to work without the separate helper > > thread. > > > I'm not sure about (1) (perhaps depending on environment, the other > thread has its own reference to file handles that you normally close > before detaching, and you could try closing them before starting up > the thread?) It seems that I have some problems with file handles. Hmm, but the helper thread does not use file handles at all. Is there a way to determine which and/or how many file handles are used by a process/thread? > > 2. For testing purposes the server process can be started > > non-detached. In this case KeyboardInterrupt is catched by the main > > thread to shut down the process. This does not work with the helper > > thread but works without it. > > But for (2) if you have multiple threads around, then Python is going > to wait for those other threads to terminate when you try to exit > (it's basically the same as you doing a join() on each thread). So to > properly exit, you would want to write your helper threads to look for > some sort of sentinel or receive a message to tell them to exit when > you want the script to exit. I think that's what I have to do. Thanks for answering. > Alternatively, threads can be marked as a "daemon" via the threading > module setDaemon method, and those threads are permitted to still be > executing when the script exits. isDaemon() of the helper Thread object returns 0. Ciao, Michael. From rossi at earthling.net Sun Apr 15 16:42:19 2001 From: rossi at earthling.net (Thorsten Roskowetz) Date: Sun, 15 Apr 2001 22:42:19 +0200 Subject: OT - Closing Off An Open-Source Product References: Message-ID: <9bd11s$rqt$00$1@news.t-online.com> "phil hunt" schrieb > Firstly, you can't "relicense" someone else's code, although you > can attach it to your own code insuch a way that the > conglomeration is GPL'd. But how does one distinguish by looking at the conglomerated Code that is now under the GPL as a whole which parts are also/still available under the original and less restrictive license? Thorsten From fredrik at pythonware.com Wed Apr 11 14:42:01 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 11 Apr 2001 18:42:01 GMT Subject: Komodo in violation of Mozilla Public License? References: Message-ID: David Ascher wrote > Likable, probably -- but also, very possibly, out of business. We > (ActiveState) are in the fairly unusual position of trying to be both > valued community members and a successful business at the same > time. not that unusual in the python universe, though -- cannot think of any Python tools provider that doesn't also do open source stuff... Secret Labs, the WingIDE guys, theKompany, eGenix... (etc) Cheers /F From a-steinhoff at web.de Tue Apr 3 08:18:44 2001 From: a-steinhoff at web.de (Armin Steinhoff) Date: 3 Apr 2001 05:18:44 -0700 Subject: What an April Fool =:-) Message-ID: <9acf3402mi8@drn.newsguy.com> see the announcements at http://www.python.org about PARROT :-) Puuhhh ... it was only an April joke :-) Armin From chris at voodooland.net Fri Apr 13 15:32:28 2001 From: chris at voodooland.net (Chris Watson) Date: Fri, 13 Apr 2001 14:32:28 -0500 (CDT) Subject: OT - Closing Off An Open-Source Product In-Reply-To: <20010413185632.A22399@qrnik.zagroda> Message-ID: <20010413135117.J1240-100000@open-systems.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > A code is always tainted with its license. It's impossible to say > what one can do with a code without considering its license. > > A BSDL licensed code is not totally free: it cannot be linked with > GPL code. How is that not free? Because I dont let you GPL infect my code? How does the place restrictions on the code? What use am I keeping you from using my code for? Binary only distros? nope. Source only distros? nope. Either one? nope. What restrictions are in place on the code that prevent you from using the *code* anyway you chose? READ NONE. If you want to argue that it isn't free because I refuse to let you infest my code with that virus, the GPL license yes I will completely agree to that. It's my code, my copyright, my license terms. And *you* are not allowed to change those. But the code is still *completely free* in any sense of the word. You can use it for *any* purpose you so choose without restrictions. The license just makes it clear you cant alter the license. But since it is *my license and my code* you obviously realize you have no right to. > Similarly as GPL is enforcing that the code will be free. The > difference is that GPL is talking about the source, and you are > talking about either source or binary. The GPL doesnt ensure squat about freedom. Ive said this 4 times now. If you release a piece of code into the public. It is forever free. period. It doesnt magically get up and dissapear. It isnt swept into some big black hole of free code. So that point is a red herring. The GPL is a license with an agenda to take away freedom, not enforce it. Nothing you can say can change that fact. It would be fine for the GPL to say: This code is under the GPL. This code is to remain under the GPL and no other restrictions, or terms may be used on *this* code. But no, this is not what the GPL does. It inflicts the GPL on OTHER peoples code. Simply for being used. There is nothing free about that. It has an agenda to destroy the works of others to fall under the term's of the GPL. Clause 2 clearly shows this. It doesnt try and protect GPL code. It tries to enslave the *entire* code base of other work as a GPL work, simply for using GPL code. It isnt protecting *jack squat*. It is simply trying to use force to destory IP, kill commercial software, and nuke software development back into the stoneage. > > So basically your back to BSDL vs GPL which is truly free? The BSDL doesnt > > put restrictions on code use, the GPL does. > > GPL puts restrictions: it forbids putting restriction about > availability of the source. It also puts the restriction I have to contaminate my entire code base under the GPL if I want to use you're code. > BSDL also puts restrictions: it forbids putting restrictions which > would forbid putting restrictions about availability of the source. What in the he** are you talking about??? Where does the BSD license say: "we forbid you putting restrictions on this code" ??????????? You are seeing things that are not there. Switch medications. If it walks like a duck, and talks like a duck... If you are not interested in people using you're code, fine. DONT RELEASE IT! But stop screaming its free software when you refuse to let people use it however they see fit. Thats just insane. > Disallowing putting a restriction is always a restriction itself! That is abosolute nonsense. I dare you to show me where in the BSDL it says you cannot place further restrictions on it? Prove it. I dare you. > In some sense BSDL gives more freedom: it forbids putting a > restriction. In the same sense GPL gives more freedom: it forbids > putting a restriction. Not in *some* sense in all senses it *is free*. You're boat is sinking you have to do better then that if you want to survive. You're argument isnt even based in reality. > In another sense BSDL takes away freedom: it introduces a restriction > (which forbids putting other restrictions). Same for GPL: it introduces > a restriction (which forbids putting other restrictions). Earth to wherever you are. Prove to me where the BSDL restricts anything. Just one example in the license that restricts use in any way shape or form. The GPL also taints other works. But you keep failing to mention that. > I could introduce SuperGPL which is related to BSDL as BSDL is > related to GPL. It would say that you cannot put restrictions which > would disallow putting restrictions which would ensure that the code > remains free. It's incompatible with BSDL but compatible with GPL. > Of course you could respond with SuperBSDL etc. > > You can't say where in this infinite sequence lives most freedom, > because freedom is not monotonic. Giving more freedom means that other > people are allowed to take away more freedom. OTOH ensuring that other > people can't take away freedom is taking away some freedom yourself. Given that webster defines Freedom as: Freedom \Free"dom\ (fr[=e]"d[u^]m), n. [AS. fre['o]d[=o]m; fre['o]free + -dom. See {Free}, and {-dom}.] 1. The state of being free; exemption from the power and control of another; liberty; independence. The GPL is completely anti-freedom. It puts me under the control of the GPL/FSF, it does not give me the liberty to use my code as I see fit, it takes away my independence. Strike 1, 2 and 3. You're out. > Stating what restrictions other people can put is in a contravariant > position. The more freedom you want to ensure, the more you have to > restrict, and vice versa. More nonsensical babble. > There is no point of infinite freedom. Well, in some sense it's the > beginning of the sequence: public domain code. But it doesn't disallow > other people from introducing restrictions on the availability of the > source, because it doesn't disallow anything - this is what "totally > free" means. You can disallow that, and you have GPL. You don't like > it, so you can disallow putting that restriction, and you have BSDL. > I don't like that, so I can disallow putting that restriction, and > we have SuperGPL. Et caetera. You're trying to somehow show that the GPL's violation of freedom is in anyway related to BSDL. Anyone who read's the two licenses will no what a fraud you're statements are. > You replaced evil GPL restrictions with evil BSDL restrictions. No I did not. I do not *taint other peopls code to fall under my license*, I *do not force people to distribute source code*. The GPL does. The BSDL does not. You need to read both licenses again. Because its clear you have not done so. ============================================================================= - -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: Made with pgp4pine 1.75-6 iD8DBQE611RRoTcdKVapx58RAqbqAJ91QTXFGVYuHZvClO1R/xQYhhTHsQCgiwHb rEmCHIMo7/yStgP8GGF/k1k= =CVFK -----END PGP SIGNATURE----- From nessus at mit.edu Mon Apr 2 18:55:17 2001 From: nessus at mit.edu (Douglas Alan) Date: 02 Apr 2001 18:55:17 -0400 Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> <7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> <4Lrx6.1055$p5.4170@news1.rivrw1.nsw.optushome.com.au> Message-ID: "deadmeat" writes: > Integers being objects unto themselves is.. just.. weird. It's not really weird at all -- this is how OO languages have behaved since their nascent arival with LISP in the late 50's. It's just a matter of perspective. If you had been programming in LISP for the last 40 years and then switched to Pascal, you would think that the way that Pascal does things is very strange. The object-sharing model of variable binding makes complete sense once you are used to it. |>oug From alf at leo.logilab.fr Fri Apr 20 10:44:57 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Fri, 20 Apr 2001 14:44:57 +0000 (UTC) Subject: bug with Queue in Python 1.5.2 Message-ID: Hello, I think I encountered a bug in Queue using python 1.5.2, and I was wondering if it was still around in python 2.x. I have a Queue with infinite size that sometimes raises QueueFull exceptions when I use put_nowait. The reason is that the fsema lock is acquired before the mutex lock, and it is possible for instance with 2 threads to have the first one take fsema and mutex, and then the second one trying to acquire fsema, and failing immediately (because it's in nowait mode), which causes a Full Queue exception. Is this still the case with later releases of Python? TIA Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From scarblac at pino.selwerd.nl Mon Apr 16 13:27:22 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 16 Apr 2001 17:27:22 GMT Subject: Strange error with unbound method References: Message-ID: Remco Gerlich wrote in comp.lang.python: > In the first case you call a method on a class. That's not possible. Argh. As Robin Thomas pointed out in an email, and as I actually knew, this is of course perfectly o.k. when the first argument given is the instance... I'll shut up for a while again. Making too many mistakes in quick mindless Usenet posts. -- Remco Gerlich From info at webb2e.com Mon Apr 9 14:35:10 2001 From: info at webb2e.com (info at webb2e.com) Date: Mon, 9 Apr 2001 11:35:10 -0700 Subject: Free register of online company's profile Message-ID: <051201135180941MAIL@mail3.chinainfoland.com> How much are you paying to advertise your business to the world? Expose Your service to the world with bold register of online business profile. Sign up today! Introducing WebB2E.com -- your direct link to global information; source of business, products, education/research, social/culture, entertainment and travel... Additionally you can BUY, SELL or PROMOTE your products and services At www.webb2e.com you'll get: --Message center (open to the public). --Employment center. --Sponsorship center. --Bulletin board (business and service issue). --Flexible Online Office (Business Online Report). --Economic news. --View thousands of trade leads. --Post business propositions. --Merchandise marketing (Vast advertising at a low cost). --World shopping center. .. and much more. Please visit www.webb2e.com If you do not want to recieve any more e-mails from WebB2E.com and wish to be removed from e-mail list please click here . -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew at one.net.au Fri Apr 6 10:04:50 2001 From: andrew at one.net.au (Andrew Maizels) Date: Sat, 07 Apr 2001 00:04:50 +1000 Subject: Curl, the language/environment/markup language...(Spanish Civil War)... References: <3ACBB03A.C9ADDEC5@earthlink.net> Message-ID: <3ACDCD02.4A882784@one.net.au> Ron Stephens wrote: > www.curl.com is the new website that I think just went up last Friday. > Curl Corporation is a new MIT inspired outfit whose owners includes Tim > Berners-Lee and Michael Dertoutzos (sp??) . I went there and I find it > interesting, I wonder if anyone else has checked it out. If so, what do > you think??? I think Microsoft has a new competitor in the dumb stunt competition. Check out their (Curl's) pricing structure: -------------------------------------------------------------------------- We charge commercial customers based on the total volume of Curl content executed. This allows for pay-as-you-go billing. The total cost to commercial customers is determined by: Baseline Price Customers pay Curl Corporation based on the volume of Curl content executed by their end users, as determined by a baseline price discounted for annual volume commitments. The baseline price may be increased for later versions of Curl products, but once established for a specific version of a Curl product, it cannot be increased. Volume Commitment Customers commit to an annual volume of between $12,000 and $600,000, payable in equal monthly installments, with a minimum of $1,000 per month. Customers can change their volume commitment level at any time, although they are committed to the associated monthly fee. The volume of content executed in excess of the monthly commitment fee is billed at the current discounted price. [And here's the kicker:] Price per Volume (by characters) Curl Corporation's usage-based software compiles information from end-user plug-ins that encounter Curl content. Included in this information is the number of characters of Curl content that are executed by the plug-ins. Curl Corporation's fees are derived from the total volume of Curl content executed by the plug-ins together with a price per one billion characters as determined by the customer's annual minimum fee commitment. ------------------------------------------------------------------------- Excuse me? You're going to do *what*?! They're dead already, they just don't know it yet. Andrew. -- There's only one game in town. You can't win. You can't break even. You can't quit the game. -- The four laws of thermodynamics. From The_Polymorph at rocketmail.com Thu Apr 5 01:06:26 2001 From: The_Polymorph at rocketmail.com (The_Polymorph at rocketmail.com) Date: Thu, 05 Apr 2001 05:06:26 -0000 Subject: Python coding problem. Message-ID: <9agugi+es60@eGroups.com> Hi all. I am just learning python and I have a question. I bought 'Core Python Programming' by Wesley Chun. If anyone has it, on page 575 ( networking ) I am usin the following: data = tcpCliSock.recv(BUFSIZ) The error is 'Attribute error:'int' object has no attribute 'recv'. If need be I can post the code or you can view it from: http://starship.python.net/crew/wesc/cpp It is under the errata section ( at the bottom under code ) Chapt.16 I am using a win32 machine with python 2.0 Thanks, Katie. From dhumphrey at pdqdot.net Wed Apr 11 11:01:52 2001 From: dhumphrey at pdqdot.net (David Humphrey) Date: Wed, 11 Apr 2001 10:01:52 -0500 Subject: What is a .pyd file Message-ID: <34E36CB1EDA21DD1.1102B4E7FC31643E.F5EC0C27FD685BB3@lp.airnews.net> I understand .py, .pyw, .pyc and .dll files. However, I see .pyd files in the ActiveState Python 2.0.203 tree, e.g., multiarray.pyd in the Numeric directory; also much of the win32 extensions. multiarray.pyd looks like a Windows DLL and dumpbin seems to agree. Is it built as a DLL and then renamed? If so, why? Regards, David L Humphrey Manager, Software Development Bell Geospace, Inc From stephen_purcell at yahoo.com Mon Apr 23 06:51:58 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 23 Apr 2001 12:51:58 +0200 Subject: AIX ./configure for Python 2.1 to use gcc instead of cc_r ? In-Reply-To: ; from Eugene.Leitl@lrz.uni-muenchen.de on Mon, Apr 23, 2001 at 12:01:18PM +0200 References: Message-ID: <20010423125158.A695@freedom.puma-ag.com> Eugene Leitl wrote: > > Any off-cuff ideas how to make Python 2.1 configure use gcc instead of > cc_r under AIX? I've tried substituting gcc instead of cc_r manually in > the Makefile, but it didn't build. Try the following: ./configure --with-gcc -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From qrczak at knm.org.pl Sun Apr 22 10:51:26 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Apr 2001 14:51:26 GMT Subject: Does Python seem appropriate for me? References: Message-ID: Sun, 22 Apr 2001 14:09:07 GMT, Rick Pasotto pisze: > > like "ls **/*.py"? (zsh) > > Sorry. That doesn't recurse and it doesn't get files in the current > directory. It does both. This is what ** means in zsh. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From paulp at ActiveState.com Mon Apr 2 00:21:46 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 01 Apr 2001 21:21:46 -0700 Subject: list vs tuple References: <3AC6805F.7E26327A@san.rr.com> <3AC70676.A5C5FECF@hack.org> Message-ID: <3AC7FE5A.1E6F9ECE@ActiveState.com> deadmeat wrote: > > > Reset your brain. > > Anyone who thinks a programmer can do this is quite insane. I've been > programming since I was 7 or 8, and did advanced mathematics throughout > highschool. Forgetting such basic principles is not possible, esp. not with > the given documentation which gives nothing to fill that void until later. This thread could have gone better but let's see if we can retrieve something useful from it. In my experience, deadmeat is totally right that reference semantics are one of the hardest things to learn in Python. In fact, they are one of the hardest things to learn in any language. Whenever I learn a new language I go directly to learn its reference/parameter semantics because I'm not going to really understand the language until I understand those. That said, it is somewhat of a problem that the tutorial says so little about it. It also starts talking about it pretty late. There should probably be a full chapter on it. Deadmeat: you could take all of the energy that you've used posting to this thread to write a tutorial chapter based on the content in this thread and Fredrik's excellent summary of the issues here: http://w1.132.telia.com/~u13208596/guides/python-objects.htm -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From AndreaF at UrkaDVD.it Fri Apr 27 12:30:33 2001 From: AndreaF at UrkaDVD.it (Andrea Ferro) Date: Fri, 27 Apr 2001 18:30:33 +0200 Subject: Integer micro-benchmarks [Smalltalk Multi-Precision Numerics vis-a-vis Highly Optimized Fixed Size Integer C++ Numerics] References: <9c4sjf$qo$1@serv1.iunet.it> <9caaru$75k$1@serv1.iunet.it> Message-ID: <9ccjcp$m44$1@serv1.iunet.it> "Ian Upright" wrote in message news:vifheto0jmk2ermdgk4s19dre8s8il93da at 4ax.com... > "Andrea Ferro" wrote: > > >hmmmm I'm still to keep up with Smalltalk "news". I'll take self some time in > >the future. I told you, no matter how much I like this sort of languages I > >couldn't yet "sell" their use here in Italy. But maybe that's because I'm doing > >too much embedded stuff! > > So are you implying that you likely couldn't sell the use of .NET either? For the embedded stuff surely not. For the platform in general I'm beginning to talk to people of where MS is heading (actually presenting it not as a MS imposition of sort but as MS way of attacking a more general direction of evolution and talking of IBM research on WebServices and their acceptance of SOAP and so on). The reaction is IMO fear-driven conservactionism. They say it is useless. They say they already can have two programs talk with sokets. They say all sort of things you can expect from somenone not seing the picture. They do not perceive it as an anabling technology that could (if the promises are met) make the Internet change from a network for umans to a network for computers. When Java came people was just beginning to understand HTML. Pages were static. Java won it's place here for animations and special effects. There's almost no "system with a web interface". They started doing that a couple of years ago when some finantial services (Banks mostly) started enabling account balance checking on the internet. Systems are mostly non internet enabled. There's practically no case of two companies managing order-ship-account and stuff electronically: everithing is on paper (that's a legal concern too). It is my opinion that no SW shop will be able to "sell" .NET here. But MS will. And we'll use .NET because it's there. VC7 is better than VC6. VB.NET and ASP.NET are cool to play with. They'll use them for that reason, not for technical resons. Most companies are not internet. They have a Win95 machine with dialup everibody uses to check e-mails. The web site is on a ISP machine and changes once in two years. It's there because it must be, not because it gives a service. Large companies do business on AS400. Those having NT do because they have a SW not supported on Win98. I even know of a SW shop doing C++ development with 20 developers working there ... and at an interview, when I asked what design methodology they used ... it came out they do not even write /* */ comments in the sources "because that's not needed". I almost falled out of the chair. Then of course they allocate 3-4 weeks to change the app so that configuration is stored on SQL DB instead of .ini files. That's the mainstream. Then, of course, there are the exceptions. Agusta does elicopters (not only civil ones) and have state of the art SW labs. In ADA. And many others too. There's some very good SW developed here too. Even commercial or business. But the mainstream culture is pretty low. Many developers are good. Many could be good in a good environment. Smalltalk? .NET? Well, someone is using them or will. But most SW shops management knows nothing of those and if the management does not know the programmers should not use. Dilbert rules. -- Andrea Ferro --------- Brainbench C++ Master. Scored higher than 97% of previous takers Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0 More info http://www.brainbench.com/transcript.jsp?pid=2522556 From f8dy at yahoo.com Tue Apr 17 15:45:00 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Tue, 17 Apr 2001 15:45:00 -0400 Subject: syntax from diveintopython References: Message-ID: <9bi6b4$9d5g1$1@ID-77331.news.dfncis.de> "Fredrik Lundh" wrote in message news:nc%C6.5081$sk3.1501293 at newsb.telia.net... > > def unknown_starttag(self, tag, attrs): > > strattrs = "".join([' %(key)s="%(value)s"' % locals() for key, value in attrs]) > > self.parts.append("<%(tag)s%(strattrs)s>" % locals()) > > whoever wrote the original code should have their python license > revoked. Well, you wouldn't be the first person to tell me that. <0.5 wink> For those not familiar with how SGMLParser works, it will call this method with an HTML tag ("tag", a string) and the attributes of the tag ("attrs", a list of (key,value) tuples). This code reconstructs the original tag and appends it to the list self.parts. - Suppose the original tag is '' - The method will be called with tag='a' and attrs=[('href', 'index.html'), ('title', 'Go to home page')] - The list comprehension will produce a list of 2 elements: [' href="index.html"', ' title="Go to home page"'] - strattrs will be ' href="index.html" title="Go to home page"' - The string appended to self.parts will be '', which is what we want. Other than using string.join(..., "") instead of "".join(...) -- a topic which has been beaten to death recently on this newsgroup and which I address explicitly in my book (http://diveintopython.org/odbchelper_join.html) -- how would you rewrite this? -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ Now in Chinese! http://diveintopython.org/cn/ From David.Browne at sdrc.com Wed Apr 18 13:08:01 2001 From: David.Browne at sdrc.com (David C. Browne) Date: Wed, 18 Apr 2001 10:08:01 -0700 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <9bkfp1$es3$1@216.39.170.247> Message-ID: <3ADDC9F1.6114A904@sdrc.com> How about checking the URL he furnished you? Dave LeBlanc wrote: > Said reasons being? > > Sending me money turns out to be very useful for a variety of > reasons... convinced? > > Dave LeBlanc > > On Wed, 18 Apr 2001 15:18:57 GMT, "Fredrik Lundh" > wrote: > > >Dave LeBlanc wrote: > >> Since self is used for every method of every class, isn't it a bit > >> redundant? I don't know of another OO language that makes you manually > >> carry around the "this"/"self" pointer/reference... > >> > >> Of course being new around here, i'm unaware if this has been hissed > >> over in depth previously :-) > > > >http://www.python.org/doc/FAQ.html#6.7 > > > > Q. Why must 'self' be declared and used explicitly in > > method definitions and calls? > > > > A. So, is your current programming language C++ or > > Java? :-) /.../ The idea was borrowed from Modula-3. > > It turns out to be very useful, for a variety of reasons > > /.../ > > > >Cheers /F > > > > -- David Browne David.Browne at sdrc.com Eugene, OR "The ignorant are ignorant of their ignorance." From zenchm at usa.net Fri Apr 6 18:42:40 2001 From: zenchm at usa.net (zc) Date: Fri, 06 Apr 2001 22:42:40 GMT Subject: Install MySQL + Python + Win2K Message-ID: Hi, I am just starting to Learn Python. Can you help mwith my MySQL setup problem? This is what I get when: pythin setup.py install I've modified the setup.py to point to c:\sys\mysql: elif sys.platform == "win32": include_dirs = [r'c:\opt\mysql\include'] library_dirs = [r'c:\sys\mysql\lib\opt'] libraries = [mysqlclient, 'zlib', 'msvcrt', 'libcmt','wsock32', 'advapi32'] runtime_library_dirs = [] extra_objects = [r'c:\sys\mysql\lib\opt\mysqlclient.lib'] I have no idea where to go from here. Thanks for any tips you may choose to provide. Zenon C:\sys\python\mysql>python setup.py install not copying build\lib.win32-2.0\_mysql_const\CLIENT.py (output up-to-date) not copying build\lib.win32-2.0\_mysql.pyd (output up-to-date) byte-compiling C:\sys\python\MySQLdb.py to MySQLdb.pyc Traceback (most recent call last): File "setup.py", line 101, in ? extra_objects=extra_objects, File "c:\sys\python\lib\distutils\core.py", line 138, in setup dist.run_commands() File "c:\sys\python\lib\distutils\dist.py", line 829, in run_commands self.run_command(cmd) File "c:\sys\python\lib\distutils\dist.py", line 849, in run_command cmd_obj.run() File "c:\sys\python\lib\distutils\command\install.py", line 483, in run self.run_command(cmd_name) File "c:\sys\python\lib\distutils\cmd.py", line 328, in run_command self.distribution.run_command(command) File "c:\sys\python\lib\distutils\dist.py", line 849, in run_command cmd_obj.run() File "c:\sys\python\lib\distutils\command\install_lib.py", line 93, in run self.byte_compile(outfiles) File "c:\sys\python\lib\distutils\command\install_lib.py", line 130, in byte_compile verbose=self.verbose, dry_run=self.dry_run) File "c:\sys\python\lib\distutils\util.py", line 423, in byte_compile compile(file, cfile, dfile) File "c:\sys\python\lib\py_compile.py", line 60, in compile codeobject = __builtin__.compile(codestring, dfile or file, 'exec') TypeError: compile, argument 1: expected string without null bytes, string found C:\sys\python\mysql> From iddwb at imap1.asu.edu Thu Apr 26 18:14:46 2001 From: iddwb at imap1.asu.edu (iddwb) Date: Thu, 26 Apr 2001 22:14:46 +0000 Subject: totally confused on sgmllib Message-ID: Now I feeling really stupid about how I understood this language. The attachment does almost what I want. The problem is all the other html tags to not get written back to the result as I thought ..self.result = self.result + fulltag would do. Only the tag enclosing the body part of the html is written to the result. The purpose of this script was to extract only the body portion of an html file -- retaining all the tags within. Well, its doing partly that -- but I can figure out why its ignoring all the valid tags.. Any advice? #!/usr/local/bin/python # from python recepes import sys, string, sgmllib class htmlExtractor(sgmllib.SGMLParser): # htmlentitydefs has html tags defined from htmlentitydefs import entitydefs # what tags do I want to retain valid_tags = ('body', 'a', 'i', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'ol', 'ul' ) def __init__(self): sgmllib.SGMLParser.__init__(self) self.result = "" self.TagList = [] def handle_data(self, data): if data: self.result = self.result + data def handle_charref(self, data): self.result = "%s&#%s;" % (self.result, name) def handle_entityref(self, name): if self.entityedefs.has_key(name): x = ';' else: x = '' self.result = "%s&%s%s" % (self.result, name, x) def unknown_starttag(self, tag, attrs): fulltag = "" if tag in self.valid_tags: for i, j in attrs: fulltag=fulltag+i+"="+j+" " fulltag="<"+tag+" "+fulltag+">" self.TagList.append(fulltag) self.result = self.result + fulltag def unknown_endtag(self, tag): fulltag = "" if tag in self.valid_tags: fulltag = "" self.TagList.append(fulltag) self.result = "%s" % (self.result, tag) def cleanup(self): """ why? where would I have lost a close tag? """ def getBody(bf): """ take a string buffer and return a string buffer with only the html body part """ bd = htmlExtractor() bd.feed(bf) bd.close() print bd.TagList return bd.result if __name__=='__main__': fn = 'test.html' rawbuff = '' mybody = '' try: fd = open(fn, 'r') except: print "Error in main, could not open %s", filename exit(1) rawbuff = fd.read() fd.close() mybody = getBody(rawbuff) # print mybody David Bear College of Public Programs/ASU From s713221 at student.gu.edu.au Fri Apr 20 19:54:02 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Fri, 20 Apr 2001 23:54:02 +0000 Subject: Install Module References: Message-ID: <3AE0CC1A.F262EFE@student.gu.edu.au> > ?i???q wrote: > > Hi, all > > Where should I install module on Python 2.1 ?? Site-packages > disapeared ?? > > -- > Best Regards, > > Winson Chang In my install, site-packages the directory is still there, but there's nothing in it. All shipped packages have been moved elsewhere. However, I immediatly dropped a whole load of packages into site-packages, and they worked no worries. (Except for Numeric, which I think is a compile problem, and which I've sent a bug report to sourceforge about.) Joal Heagney/AncientHart From thomas.paviot at wanadoo.fr Tue Apr 24 14:38:58 2001 From: thomas.paviot at wanadoo.fr (Thomas Paviot) Date: Tue, 24 Apr 2001 20:38:58 +0200 Subject: Problems using Py2exe and pyOpenGL Message-ID: <9c911s$jtg$1@wanadoo.fr> Hello, I'm trying to freeze wiht Py2exe 0.2.5 a program using wxPython and PyOpenGL. Although it works fine with wxPython, py2exe doesn't freeze pyopengl. The opengll dll's and pyopengl .pyd are not copied in the DIST directory and the lauch of .exe file produces an error message like: >File "imputil.pyo", line 294, in _load_tail > ImportError: No module named OpenGL.dynload._opengl I tried to modify my sys.path, sys.modules, and the command line of the py2exe script but it doesn't work. Thanks for any help ___________________________________________ Thomas Paviot From stepheb at comm.mot.com Fri Apr 20 11:39:32 2001 From: stepheb at comm.mot.com (Stephen Boulet) Date: Fri, 20 Apr 2001 10:39:32 -0500 Subject: Error with string.strip Message-ID: <3AE05834.93331DA5@comm.mot.com> Can someone tell me why this doesn't work? Thanks. >>> import string >>> string.strip("all's well as ends well ") "all's well as ends well" >>> string.strip(" 15157 ? 0:01 ttsession\012") File "", line 1 string.strip(' 15157 ? 0:01 ttsession\012') ^ SyntaxError: invalid syntax From karsaig at home.com Sat Apr 21 23:37:28 2001 From: karsaig at home.com (G K) Date: Sun, 22 Apr 2001 03:37:28 GMT Subject: wxPython built for 2.1? Message-ID: Subject says it all. -- Gabor From spamers at must.die Mon Apr 16 16:05:51 2001 From: spamers at must.die (Fernando Rodríguez) Date: Mon, 16 Apr 2001 22:05:51 +0200 Subject: Strange error with unbound method References: Message-ID: On Mon, 16 Apr 2001 13:20:57 -0400, Robin Thomas wrote: >I asked Fernando (privately) whether his BaseObject base class was doing >metaclass weirdness. It's either metaclass weirdness, or that paraStyles >actually contains a non-instance-of-ParaStyle, that could cause his problem. Aaaaaarrrrrrrrgggg!!!!! Yes, that's it!! :-) Thank you. paraStyles contains 1 instance of a non ParaStyle class. I didn't noticied it. O:-) The problem is that this other class also has a makeBlackAndWhite method, so that's why it worked with the for, but not the map. Shouldn't the error message be a bit clearer? O:-) //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From bob at staff.cs.usyd.edu.au Sat Apr 21 08:59:59 2001 From: bob at staff.cs.usyd.edu.au (Bob Kummerfeld) Date: 21 Apr 2001 22:59:59 +1000 Subject: "nest" vs "stack" References: Message-ID: <9bs08f$sai@staff.cs.usyd.edu.au> One of the first machines I worked on (KDF9) had a "nesting store", a 16 register stack. The machine was installed in 1964 and I worked on it in 1969 (I was a child prodigy :-) Bob Kummerfeld. -- From tim.one at home.com Sun Apr 22 20:33:17 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Apr 2001 20:33:17 -0400 Subject: Python Interpreter Reentrancy? In-Reply-To: <3AE36437.8090901@ActiveState.com> Message-ID: [Mark Hammond] > ... > The problem you will strike is the lack of portable thread-local- > storage. However, see the CEnterLeavePython class in pywintypes.h > for an implementation using MS TLS and pyxpcom.h that uses > Netscape Portable Runtime (NSPR) abstractions from Mozilla for TLS. > > Python can only provide this level of support if it moves the thread > barrier that little bit higher. Many people believe that most modern > threading libraries are capable, but requiring all python platforms > provide TLS and other more advanced threading concepts before they can > use threads is a fair bit of work. I expect Guido is dead tired of this, not least because I am and I can poison his mind at times without him realizing it . We've bounced this idea back and forth a few times: PythonLabs supports threads on standard POSIX pthreads systems and Windows boxes, and that's it. Support on any other platform requires an expert from that platform to step up and volunteer the ongoing work it needs to keep it healthy, but the Python distribution doesn't guarantee anything about it. Lose the platform expert, and bugs will be closed with "sorry, your platform is no longer loved". This is very cruel, eh? I'm afraid it's also very practical: since threads are not-- and never will be --part of standard C, making them work slick across platforms is a bloody nightmare. For years, Python's thread story has been choked down to the feeblest of all platforms anyone ever contributed a half-baked thread implementation for. > Actually, I wonder if the NSPR could help out here? For more obscure > platforms, we could provide an option that allows Python to use the > NSPR for it's thread support. PythonLabs doesn't have the bandwidth to play with yet another unique thread package, but if someone else can volunteer to whip that into shape, it's better than telling oddball-platform users "screw you" . raging-against-the-threads-ly y'rs - tim From aleaxit at yahoo.com Sun Apr 15 12:55:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Apr 2001 18:55:40 +0200 Subject: Class Variable Question References: <9at1ul010vn@news1.newsguy.com> <3ad2a7dd$0$47987$e2e8da3@nntp.cts.com> <9aush501oro@news2.newsguy.com> Message-ID: <9bcjpp01t9n@news2.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9diqh0.lut.qrczak at qrnik.zagroda... [snip] > > Your C++ compiler doesn't catch all the typos you can make where you > > type '+' while meaning to type '-', or '>' intending '<', etc, for > > example. > > Of course. No language catches such typos. > > It doesn't imply that catching detectable typos (e.g. using names > which are not defined) is worthless! No, it just puts that worth in perspective. It's worth _something_, sure -- but not very much. > I'm seeing again this poor argument: some mechanism doesn't solve > all problems, so it's worse than having nothing... If there was *NO* price to be paid for the 'mechanism', that would be a poor argument indeed. Since, in this case, there *would* be a substantial price to pay to catch this specific subset of typos, it becomes very important to put the gain in perspective, rather than idolize this typo-catching as something precious and worth paying a lot for just because some languages perform it. As you note in the snipped part, lint-like approaches, for example, can catch such typos WITHOUT requiring alterations to the Python language. Like the previously separate function of tabnanny was eventually put in the Python interpreter with the -t option, so can others (indeed, it would not be hard to modify interpreter sources to give a general escape mechanism for such checking). Proposing to mutilate the language's power instead of making tools better is inane. Alex From matthewm at ihug.co.nz Wed Apr 4 17:58:05 2001 From: matthewm at ihug.co.nz (Matthew) Date: Thu, 05 Apr 2001 09:58:05 +1200 Subject: Rounding error Message-ID: <3ACB98ED.1F239885@ihug.co.nz> Hi, I'm calculating a bunch of co-ordinates as below. I'm using Round(,2) but as you can see rounding errors are happening... Digit: 1 = [123.53, 335.29000000000002, 358.81999999999999, 358.81999999999999, 382.35000000000002, 405.88, 429.41000000000003, 452.94, 476.47000000000003, 500.0] How do I overcome this? I'm using ActivePython Build203. Thanks for any help. matthew From dalke at acm.org Wed Apr 18 21:58:11 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 18 Apr 2001 19:58:11 -0600 Subject: python on the smalltalk VM Message-ID: <9blgnh$2ro$1@nntp9.atl.mindspring.net> Caught this following the link on Slashdot concerning a trip report about the last Smalltalk conference: http://www.smalltalkconsulting.com/html/SmalltalkSolutions2001%232.html > Python is a big part for the execution engine, this is a new > area. The Smalltalk VM runs Python 10 to 100x faster. Anyone here have any comments on that project? Then again, the next line is: > {JMM I should point out the Perl and Python folks are working > toward having/wanting/needing a universal VM} Umm, did the Parrot joke go a bit too far or is there something else I don't know about. (Seems like a plague of that these days :) Andrew dalke at acm.org From Peek at LVCM.comNOSPAM Tue Apr 17 11:38:43 2001 From: Peek at LVCM.comNOSPAM (Ken Peek) Date: Tue, 17 Apr 2001 08:38:43 -0700 Subject: do...until wisdom found... References: <9bh5e502rf3@news1.newsguy.com> Message-ID: heh heh-- maybe "Medusa"? "Alex Martelli" wrote in message news:9bh5e502rf3 at news1.newsguy.com... > "Ken Peek" wrote in message > news:tdnn3dfi4h0m98 at corp.supernews.com... > [snip] > > while(1): > > Note that these parentheses are totally redundant. > > > Some people have suggested that "loop:" is a much better keyword than > "do:". > > Now I am wondering if they are right-- maybe so. I will have to think > about > > that some more-- maybe "loop:" IS more readable (by a programming newbie) > than > > "do:"... hmmm.... > > It's not an issue of "readable" -- any short English word is readable, > but does it suggest what's going on when one does read it? "DO" is just > about the least informative verb in the English language ("BE" is often > DIS-informative, cfr Korzybski, but that's another issue). "LOOP" is > very clear and informative. What's that gotta do with newbieness?! > > > > Can anybody think of a good name for a "Python-like" new language for > small > > embedded processors? > > Let's see-- "tinyPython"? nope-- has "Python" in it-- might make Guido > mad. > > It would be silly to add the adjective "tiny" for a language which > aims to be fatter (e.g. by adding multiple redundant loop forms). > > > Hmmm, maybe "Dragon"? Probably used by someone else? Hmmm... maybe ??? > > http://www.thesaurus.com/roget/IV/513.html: > """ > [Nouns] oracle; prophet, seer, soothsayer, augur, fortune teller, witch, > geomancer, > aruspex; aruspice, haruspice; haruspex; Sibyl; Python, Pythoness; Pythia; > Pythian > oracle, Delphian oracle; Monitor, Sphinx, Tiresias, Cassandra, Sibylline > leaves; > Zadkiel, Old Moore; sorcerer [more]; interpreter [more]. > """ > > My favourite suggestions out of this list are Soothsayer, Haruspice > and Zadkiel. "Prognosticator" is another similar suggestion. > > If you prefer the reptilian fold rather than the prophethical one, > suitably obscure names could be Woma, Chondro, Liasis, Dumeril, > Chandoia, Charina, Corallus, Epicrates, Lichanura, Tropidophis > (I'm not 100% sure of the spellings -- checking is advised!). > > If you prefer the British TV Comedy fold (which is the one Python > actually happens to come from), "Fawlty Towers" is one possibility. > But I'll leave this part to people more familiar than me with > recent British TV Comedy. Let's just note that "Mr Bean" should > not be used here, since it's such a natural for some Jython > Javabean related framework! > > > Alex > > > From tim.one at home.com Sat Apr 14 17:10:41 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Apr 2001 17:10:41 -0400 Subject: thread conditional code In-Reply-To: <2AVsHJA7kE26EwmR@jessikat.fsnet.co.uk> Message-ID: [Robin Becker] > if only one (the main) thread exists at the beginning of my critical > section and I'm not creating any threads how could one pop into > existence? It depends on the context of your Python code, which I can't guess. It's quite possible for a foreign thread to call into Python, where "foreign" == an OS thread not created via Python's thread module. This is probably unusual under Linux, but common for some *kinds* of Python apps on Windows. I don't know enough about what you're doing to guess. But if you have total control over all threads that may pop up in your app, I couldn't guess why you were looking for low-level hooks either: if you have total control over threads, you have (or can have) total knowledge of the thread situation too. > If python threads aren't initialised and I don't do the initialisation > who else can do it? Any thread whatsoever, known to Python or not, known to you or not, depending on the context of your app. If your app doesn't support any form of threaded callback, this probably isn't an issue for your app. > What I'm really asking is how to avoid initialising the threading > checks without losing the possibility of locking. What are "threading checks"? > I assumed probably wrongly that there is an overhead to running > multiple threads because of the ceval thread switch tests; after > scanning the source code I suspect you have the thread switch > overhead whether or not the thread stuff is initialized and then > it makes no sense to avoid using it. The periodic eval-loop "ticker checks" occur even if you compile Python without thread support. So there is no way to avoid *that* "overhead". Fiddling with the global interpreter lock is just one of the things done inside the ticker-check block. But when Python starts running, ceval.c's static interpreter_lock pointer is NULL, and the thread-switching code is skipped so long as it remains NULL. The only way it can become non-NULL is if PyEval_InitThreads() gets called. Python calls that itself when starting a new thread, and calling it is part of the dance foreign threads have to do if they want to call a Python C API function. That's it. Importing the thread or threading modules does *not* make it non-NULL, and neither does, e.g., allocating or even using (.release(), .acquire()) thread locks. So the thread-switch jitterbug does not occur until Python knows that at least two threads exist. From quinn at retch.ugcs.caltech.edu Sun Apr 8 18:54:09 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 8 Apr 2001 22:54:09 GMT Subject: how to enable error message in exec?? References: Message-ID: On Sun, 08 Apr 2001 17:00:13 -0000, ed_tsang at yahoo.com wrote: >My current script, say script A, need to execute some python code in >other file, say script B, by using exec() function. But if there is >any syntax error in script B, the exec() returns, but I would not >know what kind of syntax error is that. How can I enable this kind of >execution gives the same level of error reporting capability as if >the python code is run thorugh in the same file? > > >Code fragment: > >execCmd = "guiCb.pixitObj." + eventHandler[0] > >exec(execCmd) > >where execCmd is just a string containing the full execution python >code. eventHandler[0] is a python code read from script B. Firstly, exec isn't a function, it's a statement. So it has no return value and doesn't need parens. If eventHandler[0] is really python code (say, "print 'hi there'") , your program will try to run guiCb.pixitOjb.print 'hi there' which is probably not what you meant. I'm not sure what that 'guiCb.pixitObj' is even supposed to do. But in any case, execed code will throw exceptions like any other code try: exec eventHandler[0] execpt: exc = sys.exc_info()[0] print exc # ... I can't say if 'exec' is a good solution here, but it's probably not :) If you're writing event handlers, you probably want to call methods on a dynamically obtained object (like "get_handler(event).handle(event)"). If you want to load code from disk, you can load pickled objects or marshalled bytecode. From fredrik at pythonware.com Sat Apr 28 06:41:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 28 Apr 2001 10:41:44 GMT Subject: Which Tkinter widget can show jpegs/gifs? References: <988404866.1635211513@news.t-online.de> Message-ID: > Which Tkinter widget can show jpegs/gifs? Tkinter provides a photoimage object, which can be used with labels, buttons, text widgets, canvas widgets, etc. from Tkinter import * root = Tk() im = PhotoImage(file="someimage.gif") w = Label(root, image=im) w.pack() mainloop() the standard photoimage implementation supports GIF and PPM images. for some 30 other formats, you can use PIL's ImageTk module: http://www.pythonware.com/products/pil Cheers /F From nessus at mit.edu Wed Apr 18 18:11:12 2001 From: nessus at mit.edu (Douglas Alan) Date: 18 Apr 2001 18:11:12 -0400 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> <9bk0ce026c6@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > > I know one thing for sure: I know more about programming languages and > > programming language design than you do or ever will with your > > attitude. Regarding listening to Alex, I'd listen to him if he > > weren't also a prick. > Possibly. On the other hand, I seem to be slightly more refined > than you at Usenet flamewars, judging for example from the styles > used to insult -- rude, direct name-calling on one side, subtler > indirect venom on the other. I didn't come here for a flame war. I came here for an intelligent discussion, but if you're going to be an asshole trolling for a flame war for no good reason, then I am going to call you on it. > > I'll tell you who I've listened to quite carefully: Guido, who has > > a lot of good ideas, and the designers of Lisp (eg, Dave Moon, > > John McArthy, Guy Steele, all of whom I've met > You may have been so busy _listening_ that you never cared > enough to *read* anything by or about the second one of these > guys I read the Lisp 1.5 manual, among other things. > -- pretty hard, otherwise, to understand how such an outstandingly > brilliant individual as you could possibly have so laughingly failed > in such a simple spelling task. I have dyslexia. Are you going to pick on gimps as an encore? Btw, I did look up the spelling, and the source I found had it mispelled. It didn't look right to me, but that's what life is like when you're dyslexic. Sometimes the word "the" doesn't look right. > Spelling flames are tacky, Yes they are, as are you, in general. > In particular, I wonder if you have read his 1980 paper he still > holds up (as of Jan 2001) as representing his current thinking > on LISP. His comments there on POP2 succintly express his belief > that 'algol-ish' syntax (Python's is similar) is inappropriate > for a language where as in LISP "anyone can make his own fancy > macro recognizer and expander". No, I haven't read that paper, but I do know that Lisp 1.5 had an "algol-ish" syntax, so he didn't necessarily always think this way. > Also the note that even in LISP "certain macro expansion systems" > lead to "over complicated systems when generalized" (although they > "always work very nicely on simple examples") is interestingly > topical. Fancy seeing you quote the guy (albeit in a mis-spelled > way) and asserting you have "listened carefully" while apparently > ignoring his words. One might wonder if the LISTENING has resulted > in any amount at all of UNDERSTANDING. Are you trying to say that McCarthy is opposed to procedural macros? Or is he only warning that every coin has two sides? I note the word "certain" in your quote, rather than "all". Neither "listening", nor "understanding", by the way, mean "agreeing whole hog". I refer you to any dictionary. And I would be extremely surprised if Dave Moon turned out to be opposed to procedural macros. This is what I do understand from what I've heard, from what I've read, and from my own thoughts: Every feature you add to a language has its pitfalls and so should be considered carefully. Conversely, many times if you take something away from a language in the name of simplicity, you merely transfer the complexity onto programs written in the language. If a language is too simple then some problems need to be solved over and over again by the users of the language, and it's sometimes best to solve the problem once and for all and put the solution into the language. Counter to what you seem to think, your ideas, Mr. Martelli, are not the word of god. Many different points of view can be reasonably held by different people -- on language design in general, and on Python, in specific. > Of course, the designers of _Dylan_ (who can hardly be accused of > being LISP-ignorant:-) disagree with this stance -- they built a > powerful language with algol-ish syntax and macros (as we as truly > powerful underlying semantics, multi-methods first and foremost) and > with it they've been trying to take over the world for quite a bit > longer than Python has. Reflecting on the similarities and > differences, and the different amount of success that has so far > (the first 12 years or so...) smiled on both endeavours, might > perhaps (to a person of refined perception) prove more fruitful than > _just_ reading about theories. Languages succeed and fail for all sorts of reaons other than on their strict merits as a language. > It appears to me that the crucial design-goal that > Python and Dylan did not share was *SIMPLICITY*. I beg to differ. Dylan is a relatively simple language as far as languages go. Also, I am currently working with a language called Proto that is far simpler than Python, and yet it has both multimethods and procedural macros. > > personally), who are far smartter than you, me, or Alex will ever be. > There is (fortunately, I think) no single axis along which > "smartness" is measured (cfr. Gould, "The Mismeasure of Man", IMHO > still his masterpiece, for a very well written and deep examination > of pseudo-scientific attempts to establish such an axis, all the way > up to that fraud named "the IQ"). You preach to the choir. I'm not aware of Howard Gardner including an "obnoxious wise-ass" category to his list of multiple intelligences, and I can't find it in the index to Minsky's *Society of Mind*, but if such a category were to be recognized, you would certainly be near the top. > An interesting, if idle, pastime, is to wonder whether the variety > of human endeavours can possibly be so vast that at some of them > even _YOU_ might be called 'smart'... sure, the mind boggles, and > yet... Oh, my, Mr. Martelli, you are just so clever. I wonder if I might *ever* aspire to such incredible wit and cunning. |>oug From floods at netplus.net Wed Apr 18 13:42:25 2001 From: floods at netplus.net (Luke) Date: Wed, 18 Apr 2001 12:42:25 -0500 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <3ADDBDFE.4403459A@netplus.net> Message-ID: <3ADDD201.BA7223C7@netplus.net> > looks like you haven't studied Python's class model close enough > to actually know what you're talking about here... > > (hint: how do you declare class members in Python?) > > Cheers /F That's my point exactly. You don't need it. From stephen_purcell at yahoo.com Wed Apr 18 03:02:33 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 18 Apr 2001 09:02:33 +0200 Subject: Idiom gone, or did it really ever exist? () is () In-Reply-To: ; from tdelaney@avaya.com on Wed, Apr 18, 2001 at 04:34:59PM +1000 References: Message-ID: <20010418090232.E727@freedom.puma-ag.com> Delaney, Timothy wrote: > > The convention is to use 'None' for this purpose. 'None' > > never changes, so > > 'argument is None' will work correctly for you. > > This will not actually work for the purpose though. The idea is to > distinguish between whether a parameter was passed, or whether the default > parameter is being used. Note: I've never tried this myself ... > > If you have a default of None, it is impossible to determine this if the > user passes None - because it will be the same instance of None in almost > all cases. Agreed. I'm just saying that this *is* the convention, not that replacing the magic tuple values with None will work without further changes. Given def foo(bar=None): ... I think it's reasonable that foo() and foo(None) do the same thing. Why prevent people from explicitly calling your function in the default way? -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From echapin at sympatico.ca Wed Apr 25 11:49:57 2001 From: echapin at sympatico.ca (Elliott Chapin) Date: Wed, 25 Apr 2001 15:49:57 GMT Subject: bell() trick :) Message-ID: I had asked about a way to get the functionality of bell() outside its normal context. Although I'm not running any dialogs (yet) in my current (really first) project, I just verified that I can borrow it from a Pmw EntryField. Suggestions like "print chr(7)" don't work. -- --------------------------------------------------------------- Elliott Chapin http:// www3.sympatico.ca/echapin From Laura_01 at MailAndNews.com Fri Apr 13 15:39:47 2001 From: Laura_01 at MailAndNews.com (Laura Lewin) Date: Fri, 13 Apr 2001 15:39:47 -0400 Subject: why does activestate (win98) python not support globbing Message-ID: <3AF7F931@MailAndNews.com> Hi, I just wanted to clarify a point about the book Programming Python: I'm fairly certain that the comments here refer to the 1st edition of Programming Python, not the 2nd (current edition)! Example 4.1 in the 1st edition does indeed assume a unix-like command line, and page 113 in that edition is where globbing shows up. So I would just point you towards the 2nd edition, which covers directory tools. The 1st edition was very Unix-biased, but the 2nd is not. Hope this helps. Laura LLewin at oreilly.com >===== Original Message From tim at vegeta.ath.cx (Tim Hammerquist) ===== >Palmer, Dan [SKY:1G21:EXCH] wrote: >> I was working through Programing python by Mark Lutz, and I can get Example >> 4-1 working under unix (from the 2.0 tar.gz), but when I tried to run this >> under windows (win98 or win2000) it generates an error. The following error >> is generated. >> >> In unix it expands the *.py to all the associated files. In windows it does >> not. Why the difference. > >I remember these examples from the (disappointing) book, and remember that >they were rather Unix-oriented, despite his frequent mention of Windoze. > >But I also thought I remembered Mark addressing this in a footnote or box >somewhere, but couldn't find anything regarding the differences between >globbing on *nix and DOS/Win32. > >I was further disappointed. > >However, later in the chapter (p113 or p115?) he describes how to go about >using Python's built-in globbing, which is, of course, more >platform-independent. > >So yeah, Mr. Lutz stiffed Win32 users. This concept should have been >covered in the book, even if 80% of the book was devoted to Tkinter. > >HTH >-- >-Tim Hammerquist > >Any emotion, if it is sincere, is involuntary. > -- Mark Twain From thomas.heller at ion-tof.com Thu Apr 19 09:04:11 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 19 Apr 2001 15:04:11 +0200 Subject: zipfile (Python 2.0) incompatible with InfoZip 2.3? References: Message-ID: <9bmno1$a1rc8$1@ID-59885.news.dfncis.de> Jim Ahlstrom posted the following message to python-dev some days ago: > The zipfile module seems to have been well received, and > I have the impression that many people are using it. But > I have been getting complaints that it won't read ZIP files > created by InfoZip. At first I thought this was a problem > with incompatible zlib compression versions, but now I have > found the problem. > > It turns out that InfoZip's Wiz version 5.02 (and maybe other > InfoZip versions) creates ZIP files with an incorrect value > for "extra data length" in the central directory, but the correct > value in the file header. The "extra data" is before the compressed > file data, and so this causes the file data offset to be off slightly > thus causing complaints from the zlib decompressor. I changed > zipfile.py to use the file header value, and it fixes the problem. > > I also added a new method restore(self, name, fileobject) which > was suggested some time ago by MAL. It writes to an open file > or any other object with a write() method. It avoids the need > to read the whole file into memory. > > I also changed the "raise" statements to use the "zipfile.error" > exception. This agrees with the documentation, but previously > zipfile raised a variety of exceptions. This also fixes the > complaint that "BadZipfile" should be spelled "BadZipFile". > > The new changed zipfile.py is available from > ftp://ftp.interet.com/pub/zipfile.py > and is currently being tested by a user. Please take a look. > > JimA > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev From tebeka at lycosmail.com Tue Apr 17 03:40:13 2001 From: tebeka at lycosmail.com (Miki Tebeka) Date: Tue, 17 Apr 2001 10:40:13 +0300 Subject: Howto: testall not in verbose mode Message-ID: <9bgs11$1vg@news.or.intel.com> Hello All, To check python I run python -c "import test.testall". Everything works fine but I get the message: CAUTION: stdout isn't compared in verbose mode: a test that passes in verbose mode may fail without it. How do I run the same tests not in verbose mode? -- Bye. ---------------------------------------------------------------------------- -- Smile, damn it, smile. lambda msg: 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From SBrunning at trisystems.co.uk Thu Apr 5 05:27:28 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 5 Apr 2001 10:27:28 +0100 Subject: CRACKER, the premier code obfuscation utility for Python... ( WAS: RE: POLLY: An IDE for Parrot) Message-ID: <31575A892FF6D1118F5800600846864D78BA81@intrepid> > From: nomad***@***freemail.absa.co.za > [SMTP:nomad***@***freemail.absa.co.za] > >>I always thought Platypus was fairly good - a totally different > >>animal, even as animals go.... > > > >Sorry, it's taken. ReportLab has a subpackage > >"Page LAyout and TYPography Using Scripts" (PLATYPUS) > >and if anyone puts that on a book cover before us, we'll > >send round some wide boys from the east end of London. > >Much cheaper than patent lawyers :-) > > > >Andy Robinson, ReportLab > I might be wrong, but I think O'Reilly have already put one on a book > cover. Wiff those east-enders going over, I wouldn't want to be in > O'Reilly's shoes... The should be OK. A single blow from 'Programming Python, 2nd edition' would be enough to lay *anyone* out. 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 djc at object-craft.com.au Fri Apr 20 08:26:05 2001 From: djc at object-craft.com.au (Dave Cole) Date: 20 Apr 2001 22:26:05 +1000 Subject: Sybase module 0.13 (Chad Lester release) released Message-ID: What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. Changes: - A refcount leak in the exception code was found and fixed by Chad Lester Where can you get it: http://www.object-craft.com.au/projects/sybase/ - Dave -- http://www.object-craft.com.au From tim.one at home.com Wed Apr 25 19:57:20 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 25 Apr 2001 19:57:20 -0400 Subject: Can't run "Python-2.1.exe" under NT... In-Reply-To: Message-ID: [David Bolen] > ... > But I may poke to see about replicating current behavior with ISX - is > there an old Wise help file or something else to help decoding the wse > file? A lot of it is obvious, but some of the flags and what not > aren't. It's completely undocumented, AFAIK. The .wse file is machine-generated: when you're building a Wise installer, you write it in a funky Wise script language from within a Wise GUI app. The .wse file is akin to a Python .pyc file, i.e. it's some internal, "lightly compiled" but invertible representation of your script. Given an unbounded amount of time to play with it, I'm sure we could figure out which checkboxes (etc) in the GUI corresponded to which .wse flag bits (etc) -- but it would go faster in the end to write our own installer from scratch. Would also be a lot more fun. From cce at clarkevans.com Fri Apr 6 21:07:33 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Fri, 6 Apr 2001 20:07:33 -0500 (EST) Subject: Conditional operator in Python? In-Reply-To: <3ACA8E6F.706B0E9F@destiny.com> Message-ID: On Tue, 3 Apr 2001, Michael Chermside wrote: > > (x and [a] or [b])[0] > > I use > > def cond(test, trueval, falseval): > if test: > return trueval > else: > return falseval > > a bit. But it'd be more convenient if there were a true, > short-circuiting version available. Are there any good reasons > NOT do do so? (The uglyness of "?:" is not a valid reason... I > KNOW the Python community can find a cleaner syntax.) One obvious > reason is that it adds yet one more control structure to the > language (which we want to keep small), but are there any other > reasons you can think of? This works as long as trueval and falseval do not have side-effects. As you point out, this doesn't short-circut. >>> def x(): ... print "x" ... return "x" ... >>> def y(): ... print "y" ... return "y" ... >>> def cond(test,tv,fv): ... if test: ... return tv ... else: ... return fv ... >>> cond(0,x(),y()) x y 'y' >>> (0 and [x()] or [y()])[0] y 'y' From BPettersen at NAREX.com Thu Apr 19 21:42:19 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 19 Apr 2001 19:42:19 -0600 Subject: ActivePython 2.1 (build 210) Message-ID: Hi Paul, First, thanks for putting this together (it's amazing how much easier it is to get someone to install Python when they don't have to separately install the win32 extensions :-) Second, I must apologize for what is probably a stupid question.... You mention a rebuilt package repository with Numeric etc., but I can't find them. I have a downloads directory with Insall.Numeric and Install.PIL files but they only contain an empty string (''). Help? -- bjorn -----Original Message----- From: Paul Prescod [mailto:paulp at ActiveState.com] Sent: Thursday, April 19, 2001 3:51 PM To: python-list at python.org Subject: Ann: ActivePython 2.1 (build 210) We are pleased to announce ActivePython 2.1 (build 210), a distribution of Python 2.1. http://www.activestate.com/ASPN/Downloads/ActivePython/ ActivePython contains a superset of the functionality available in the reference distribution of Python. It has been tested on a variety of platforms including various variants of Windows 9X, NT and 2000, Red Hat and Debian. Highlights of ActivePython 2.1: On all platforms: * full Python 2.1 support (100% compatible) * rebuilt package repository including Numeric, PIL, PyXML, etc. * bundled XML parser and zlib compression library On Win32: * interactive win32 module browser * bundled Tk * enhanced version of the bundled Pythonwin environment * upgraded win32 extensions ActivePython 2.1 also supports all of the new features of Python 2.1, including: * "weak references" facility for implementing caches and other similar data structures. * richer comparison mechanism * warning framework * new module documentation extraction facility * ability to refer to variables from any containing scope. * unit testing features * faster line by line file reading We at ActiveState are proud to provide ActivePython to the Python community! Paul Prescod ActivePython Technical Lead -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook -- http://mail.python.org/mailman/listinfo/python-list From zope at thewebsons.com Fri Apr 27 16:02:51 2001 From: zope at thewebsons.com (Ben Ocean) Date: Fri, 27 Apr 2001 13:02:51 -0700 Subject: Please Help with CGI Script! Message-ID: <5.0.2.1.0.20010427125704.0229fd80@thewebsons.com> Hi, I'm trying to cobble together my first CGI script and running into problems. Here's the deal: **an alien URL (around which I frame) will send me an HTTP_POST stream. **I need to capture the stream **I need to get the information to the client How do I configure the URL the stream will come to? Easy enough on the alien host's page. Let's say he posts to rightHere.html. What do I do: build some kind of shell called by the same name? How do I hook it to the cgi script? Once I get it, how do I get the info to the client? I was thinking of parsing it and reconfiguring it the way I want, then putting up a page named according to the datestamp so that I could load up as many as the client needed, then write a cron script to take them down after so long a time. Probably just easier to send an email. How do? TIA, BenO Script follows: #!/usr/bin/python import sys # just for debugging purposes import cgi import time import string import os form = cgi.FieldStorage() print 'Content-type: text/html\n\n' # specify the filename of the page to send the dealership Report = repr(time.time()) + ".html" # read the entire file as a string def main(): start = "\nHere's the data a potential customer requested from the Kelley Blue Book link on your Web site:
 
\n" FormData = open("/apache/vhosts/bladechevy/cgi-bin/kelleyblue.html","r") formstuff = "" while FormData.readline(): safe = string.maketrans("`|~!@#$%^&*()_+=:;{}[]", "----------------------") line = string.replace(string.replace(string.replace(string.translate(FormData.readline(), safe), "
\n") formstuff = string.join([formstuff,line]) end = "\n" all = string.join([start,formstuff,end]) FormData.close() # close the file if (__name__ == "__main__"): main() From aleaxit at yahoo.com Fri Apr 20 17:36:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Apr 2001 23:36:35 +0200 Subject: Is there a way to save the state of a class?? References: <9bpra9$q0l@news.or.intel.com> Message-ID: <9bqa6101nlf@news1.newsguy.com> "EdwardT" wrote in message news:9bpra9$q0l at news.or.intel.com... > Hello, I current have a script that do certain processing on files, and > requires user to enter certain info such as: > 1. inputfile name > 2. output file name > 3. whether it would like process all files recusively or just one (stored as > a Int instance in class, value got from CheckButton widget in runtime ) > 4. a string that supplies the protocol stack it is building. (stored as a > string instance in class) By "in class" I guess you mean, as an attribute in an instance of some class? > > Instead of writing some code to save all these some sort of text file; and > re-read the next time ithe script got invoked. Does python offer the option > to save the state of the whole script, as some kind of persistence objects? "The state of the whole script" would be more of a problem -- isn't it enough to save the state of an instance, as you ask before and in the subject (assuming that's what you mean by 'state of a class')? Standard module pickle does that (and cPickle does it, too, but faster). Here's a simple example -- assume the following is scriptfile flup.py: import sys, cPickle class Words: def __init__(self, *words): self.words = words if len(sys.argv)>1: # build and persist an object obj = Words(*sys.argv[1:]) cPickle.dump(obj, open("flup.dat","wb")) else: # depersist and display an object obj = cPickle.load(open("flup.dat","rb")) for word in obj.words: print word, print An example usage might be: D:\ian>python flup.py be bop blippo D:\ian>python flup.py be bop blippo D:\ian> Lots more info, and examples of more advanced usage, are in the standard Python library reference manual. Alex From sholden at holdenweb.com Wed Apr 18 10:37:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 18 Apr 2001 10:37:53 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> Message-ID: "Douglas Alan" wrote in message news:lcoftuewyz.fsf at gaffa.mit.edu... > "Steve Holden" writes: > > > "Douglas Alan" wrote in message > > > > $#@# you too. <<<<<<<<<<<<<<<<<<< Woops! > > > You are very rude. No problems here. > > > Rude, perhaps, but not usually abusive. *Please* resist the temptation to > > post in this vein in future. > > I find the quote from Alex above to be utterly abusive, and he was > abusive to me in a previous post. Calling him rude is what he > deserves, because it is what he is. > > |>oug As you might now guess, I wasn't complaining about you calling him rude ... regards Steve From robin at illusionsexeculink.com Wed Apr 4 12:08:35 2001 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Wed, 04 Apr 2001 12:08:35 -0400 Subject: Didn't I see HTML embedded Python? (Not Zope?) References: <3ACA168A.13850B09@do.not.use> Message-ID: Russell Turpin wrote: >I seem to remember seeing something recently about support >for HTML embedded Python. Not Zope, but something simpler. >But I could be confused -- that corner of my cranium seems >to have cobwebs. Can anyone give me a pointer? If you have cobwebs you may need Wasp. Wasp is an platform-independent open-source HTML preprocessor written in Python which provides an organised way of designing and programming a web application. Template files containing powerful Wasp tags may be easily customized through plug-in Python modules. It's just been updated with a cookie and session module, so you can now easily write web apps that maintain state. I haven't got around to announcing that yet, though I guess I just did. Wasp is available at: http://www.execulink.com/~robin/wasp/readme.html Of course there are lots of alternatives since Python makes it (relatively) easy to write such tools. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Isolation tank paves way to execute an attack. From qrczak at knm.org.pl Sun Apr 8 10:39:31 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 8 Apr 2001 14:39:31 GMT Subject: Boolean Values References: Message-ID: Tue, 03 Apr 2001 21:59:32 +0200, Moshe Zadka pisze: > For all those crying for boolean values, here's a simple module > that will hopefully solve all your needs: It doesn't make 0<1 return true, and thus (0<1)+2 is not an error as I would like. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sholden at holdenweb.com Fri Apr 6 00:25:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 6 Apr 2001 00:25:07 -0400 Subject: A couple garbage collector questions References: <3AC94B6B.F1F4DDEB@cosc.canterbury.ac.nz> <9ahr7g$3ar$1@c3po.schlund.de> Message-ID: "David Bolen" wrote in message news:ulmpeoewi.fsf at ctwd0143.fitlinxx.com... > Skip Montanaro writes: > > > >>> Reference-counting exacts very heavy performance costs, no matter > > >>> what you back it up with. > > > > Hannah> Correct. *Except* if the compiler does heavy optimization of > > Hannah> reference count updates (i.e. if you can prove that some basic > > Hannah> block just increases the RC, later decreases it, having a net > > Hannah> effect of +- 0, you can drop both RC updates, and so on). > > > > This is unlikely to happen in practice. A basic block consists of a > > straightline piece of code containing no branches. There's no reason to > > increment a reference count and decrement it within the same basic block, > > since the object's reference count can't be decremented to zero by some > > other piece of code. > > Not only that, but the basic block has to be atomic in a > multi-threaded environment. Otherwise, some other thread may gain > control and release the last reference to an object that is being used > within the "basic block" but wasn't marked as such, and the object may > be reclaimed before the original block gets control again. > Unless, of course, you set a lock or otherwise ensure mutual exclusion. Which is, I believe, where we came in, the original enquirer wondering whether reference count maintenance wasn't too heavyweight. Perhaps the salient point is that something as complex as a language interpreter can't afford to make too many assumptions about the environment, since the universe will almost always prove simplistic assumptions wrong. This is not a good way to reduce one's support load ;-) regards Steve From jimd at vega.starshine.org Sat Apr 14 04:59:55 2001 From: jimd at vega.starshine.org (Jim Dennis) Date: 14 Apr 2001 08:59:55 GMT Subject: Setting sleep interval less than 10 mS on a Linux PC? References: <3AC22D31.FD4644B1@spammyraqia.com> Message-ID: <9b93ib$1etc$1@news.idiom.com> In article , Dan Maas wrote: >In article <3AC22D31.FD4644B1 at spammyraqia.com>, "David Lees" > wrote: >> I suspect this is a system question, but I will ask anyway. I am using >> the Python sleep method (time.sleep) and on a PC running RedHat 7.0 >> Linux, it has a 10 millisecond lower limit. Below that it still wakes >> up every 10 milliseconds, regardless of the argument. >This is a nasty problem - time.sleep() uses select() internally, and on >Linux select() cannot sleep for less than 10ms. >Easy way out - just use a busy loop: >start_time = time.time() >while (time.time() - start) < 0.001: > pass >time.time() has microsecond accuracy so you will get very close to the >desired delay. Of course this burns CPU time, but with a 1ms polling >interval I assume you're not too worried about that. >Hard way out: find or write a python module that uses nanosleep() >internally; I *think* nanosleep() can give you <10ms delays without >busy-waiting. (you may need a kernel patch though :[...) >Regards, >Dan The Linux kernel uses a 10ms pre-emption (scheduling) interval. So, every 10ms the Kernel gets a timer interrupt shifting each processor out of userspace into the interrupt handler which checks the scheduler, and the run_queue and a few resource limits for the current process (processes on SMP), updates a few counters, etc. At that time the kernel determines whether it will give the current process on a given CPU another time slice, or perform a context switch to another process (or thread). Obviously you won't be able to sustain any processing at less then 10ms resolution for an sustained period of time. You could hack your kernel to lower its pre-emption interval (increasing the frequency and increasing the kernel's overall overhead vs. userspace processing). However, it seems like you'd prefer to have access some real-time features. Off hand I wouldn't know how Python interfaces to any of the several Linux real-time extensions and patches. There are the RTLinux (MURT like) patches from FSMLabs, the RTAI patches as used by Lineo, the Timesys patches, the KURT (Kansas Univ. Real-Time), and the Monta Vista configurable RTS (RT Sched) from Monta Vista. Those are just some of the Linux real-time alternatives (including hard, soft and hybrid features). Unfortunately these various approaches to RT under Linux are in fierce competition. The represent a blurry herd of racing zebras to Guido, Larry, and Mr. Gosling: which set of libraries and APIs should/could be implemented for use within Python, Perl, Java, etc? I certainly don't know the answer to that question. From dbrueck at edgix.com Fri Apr 27 15:19:49 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 27 Apr 2001 13:19:49 -0600 Subject: ANN: mxNumber -- Experimental Number Types, Version 0.2.0 References: <5.0.2.1.0.20010426145150.02335ec0@mail.inet.com.br> <3AE9C0E2.64A87C9A@bioreason.com> Message-ID: <00b301c0cf4f$13ba33f0$450514ac@PRODUT2KDAVE> > I have taken the opportunity to expose a couple of Integer methods > > Integer.popcount() - number of bits set > Integer.setbit(bit) - set the bit indicated by bit > Integer.clrbit(bit) - set the bit indicated by bit > > These are very useful for Aritificial Intelligence/feature vector algorithms. Is > there any other desire to see these types of functions exposed? I would be happy to > send a patch although it's only 3 minutes of work to do... The set/clr bit stuff would be useful for encryption routines (e.g. DES) where you spend most of your time swapping bits around. From sholden at holdenweb.com Fri Apr 27 07:41:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Apr 2001 11:41:22 GMT Subject: using lambda to print everything in a list References: Message-ID: "Duncan Booth" wrote in ... [ ... ] > > [bottom quote snipped - please don't bottom quote your messages] > You shouldn't message quote your bottom, either. regards Steve From sholden at holdenweb.com Tue Apr 24 14:45:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 24 Apr 2001 18:45:09 GMT Subject: Named code blockes References: <0P5F6.85546$J%5.30205213@news2.rdc2.tx.home.com> <9c45qg01sui@news1.newsguy.com> Message-ID: "Rainer Deyke" wrote in ... > "Alex Martelli" wrote ... > > "Rainer Deyke" wrote ... > > > In Python, unnamed objects have an additional benefit: there is a single > > > consistent way of naming them. Consider: > > > > > > a = 5 > > > b = lambda: None > > > def c(): > > > pass > > > > > > These are three assignments, but only two look like assingments. The > > > > They are three ways to bind (or re-bind) names, but only two of them > > ARE "assignments" -- Python's syntax defines assignments, plain and > > augmented, rather precisely, and there is no 'def' keyword there:-). > > I count four ways ('import', 'def', '=', and augmented assignment), not > counting 'globals().set' and similar tricks. > Then there's class. I count five ways ... nobody-expects-the-spanish-inquisition-ly y'rs - steve From tim.one at home.com Mon Apr 2 19:47:38 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 2 Apr 2001 19:47:38 -0400 Subject: "Fastest growing programming language" In-Reply-To: Message-ID: [Douglas Alan] > What's the source for Python being the "fastest growing programming > language"? Just curious. Who said it? I'd ask them. the-windows-installer-is-sure-growing-by-leaps-and-bounds-ly y'rs - tim From not.this at seebelow.org Mon Apr 9 22:42:16 2001 From: not.this at seebelow.org (Grant Griffin) Date: Mon, 09 Apr 2001 21:42:16 -0500 Subject: After Parrot, what next? References: Message-ID: <3AD27308.F613A4E6@seebelow.org> Roy Smith wrote: > > A bunch of us were discussing the new Parrot syntax (i.e things like > "left_angle_bracket_right_angle_bracket") today and came up with a great > idea for a new language syntax, which mixes the best ideas of Parrot and > XML. Instead of: > > for line in sys.stdin.getlines(): > print line > > or > > while (<>) { > print; > } > > you'd do: > > > line > getlines > > > line > > > > > So, what'ya think? For the benefit of Ruby fans, I think you should replace "/" with "end ". and-let's-call-it-"Ruby-Red-Budgie"--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 johngrayson at home.com Fri Apr 13 19:14:55 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Fri, 13 Apr 2001 23:14:55 -0000 Subject: Fwd: Re: Tkinter App Wanted Message-ID: <9b819f+g478@eGroups.com> --- In python-list at y..., "Steve Holden" wrote: > Now, hang on [... ferkles about in John Grayson's Python stuff...] > ah yes, menu.py from chapter 4. Hope he won't mind, it's freealy > available from his web site (I think). > > If you haven't read John Grayson's "Python and Tkinter Programming" > it's well worth a read. Source code at the foot of the message. > > regards > Steve Thanks for the plug! Now, don't anybody tell my publisher! http://www.manning.com/Grayson/Source.html 2 example chapters: http://www.manning.com/Grayson/Chapters.html John Grayson From fredrik at pythonware.com Fri Apr 6 04:04:38 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 06 Apr 2001 08:04:38 GMT Subject: special case (inf,-inf,nan) float problems. References: <3ACD757C.F3201BC5@cycletime.com> Message-ID: Jeremy R Van Haren wrote: > I've worked around both of these issues, but I think they are both > problems. Does anybody know if this has been taken care of in 2.0? Tim will most likely give you the full story within seconds, but basically, like the C it's written in, Python doesn't define how to deal with INF and NAN... Python will get better at this the day we can start trusting the C compilers... Cheers /F From neilh at scintilla.org Sun Apr 15 23:45:13 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 16 Apr 2001 03:45:13 GMT Subject: .py to HTML: indentation problems References: <3AD916E0.EB9C748F@earthlink.net> Message-ID: Ron Stephens: > A stupid little problem, irritating nonetheless. I have polished my > program and now am attempting to load it on my website as an HTML file. > Using Netscape Composer, I cut the code from pythonWin, paste it into > Netscape Composer, and then upload the HTML file from Composer to my > website. > > Problem is that the lines sometimes wrap in a wierd way that destroys > the indentation of the code. There are several programs for converting Python code to HTML. My SciTE editor http://www.scintilla.org/SciTE.html has an Export as HTML command. The generated HTML does not wrap in the browsers I have checked with. Neil From greybria at direct.ca Sun Apr 15 11:56:47 2001 From: greybria at direct.ca (Brian & Colleen) Date: Sun, 15 Apr 2001 08:56:47 -0700 Subject: Tkinter App Wanted References: <3AD7647B.6A4B555B@direct.ca> Message-ID: <3AD9C4BE.C4588066@direct.ca> Thanks Kevin, The self-references seem to be giving me a lot of problems. I've checked out the "Programming Python" again from the library and am working through some of the examples in there. -- Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From ben.hutchings at roundpoint.com Thu Apr 5 20:49:38 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 05 Apr 2001 17:49:38 -0700 Subject: Formatting RFC 822 date References: <9ad4j9$t59$1@news.netmar.com> <87wv917zww.fsf@psyche.dnsalias.org> Message-ID: Carey Evans writes: > brey at ductape.net writes: > > > I'm using smtplib to send an email message, and I'd like to put a > > Date: line in the header. However, formatting the timezone > > portion of the date line correctly seems to be a real highly > > non-trivial. time.strftime only outputs the time zone as a > > string, and none of the variables in the time module are easy to > > convert to the -600 style format. > def zone822(dst): > if dst == -1: > return '-0000' > else: > offs = (time.timezone, time.altzone)[dst] > return '%+05d' % (offs / -36) The minute digits of the time offset weren't included just for fun; there really are zones that aren't offset by a whole number of hours. How about this instead: def zone822(dst): offs = (0, time.timezone, time.altzone)[1 + dst] return '%s%02d%02d' % ("+-"[offs >= 0], abs(offs) / 3600, (abs(offs) / 60) % 60) -- Any opinions expressed are my own and not necessarily those of Roundpoint. From andmalc-ng at DONTSPAMmalcolmson.ca Sun Apr 29 07:49:41 2001 From: andmalc-ng at DONTSPAMmalcolmson.ca (Andrew Malcolmson) Date: Sun, 29 Apr 2001 07:49:41 -0400 Subject: Python & ODBC problems References: <3ae9800f$1@news.dbtech.net> Message-ID: Perhaps this will help: http://www.python.org/windows/OdbcHints.html "Larry Bates" wrote in message news:3ae9800f$1 at news.dbtech.net... > I have been trying off and on for the last couple of weeks to get connected > to ODBC from a Python application. I have tried ODBC and mxODBC with no > success. When I try to connect to DSN the CPU utilization on my machine > goes to 100% and the application never finishes. Can anyone help a newbie > get past this seemingly insurmountable hurdle? I have a lot of projects > that I want to do, but access to ODBC data source is going to be a > requirement for most of them. > > Thanks in advance, > Larry Bates > > > Config: > > Windows 98 (w/all patches applied from Windows Update) > 128Mb > ActiveState Python 2.0, build 203 > > > From sholden at holdenweb.com Thu Apr 26 09:16:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Apr 2001 13:16:22 GMT Subject: ANN: Experimental Number Types (Integer, Rational, Floats) References: <3AE6A369.ABB2692E@lemburg.com>, Message-ID: [posted and mailed] "Moshe Zadka" wrote ... > On Wed, 25 Apr 2001 12:14:01 +0200, "M.-A. Lemburg" wrote: > > > Still, you have valid points here and I think Moshe should consider > > these in his PEP (that's why I put him on CC -- hi Moshe ;-) > > Thanks. I try to read c.l.py, but I sometimes miss out. > I'll try to put some more words under "Open Issues". Basically, > I'm not sure if I want to make the string matcher that complicated -- > also recognize "1.0 1/2"? "3/1 5/7"? "4/2 3/4" etc.... > And anyway, my PEP is behind the implementation -- this *will* be fixed, > but anyone who is really interested in the future of my PEP should > definitely checkout the implementation. Currently, the implementation > recognizes these types strings -- > > 1. "105" > 2. "105.7" > 3. "105.7e1" > 4. "105/7" > 5. "105.7/8.3" > 6. "105.7e1/8.3e-2" > 5 seems a bit odd, and 6 seems way bizarre to my little brain. Surely the "ratio" in "rational" refers to the ration of two *integers*, not two reals. Isn't the point of implementing rationals to move away from floating-point representation, allowing us to work within specified error limits yet not be confused by literal representations with insufficient precision to be as accurate as we would like? Note I have not checked your implementation, so if you are elevating everything to integer before reducing to rational, and not using f-p at all, I apologize in advance. It's a *long* time since my numerical analysis classes... PEPs themselves are a lot for me to keep up with right now. but-of-course-you-built-the-tests-first-didn't-you-ly y'rs - steve From chris.gonnerman at usa.net Thu Apr 12 23:01:12 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 12 Apr 2001 22:01:12 -0500 Subject: tars and zips References: <3AD5F88E.13C645D5@packeteer.com> <3AD6E175.17AAC523@student.gu.edu.au> Message-ID: <00ee01c0c3c6$01e80e20$a100000a@local> ----- Original Message ----- From: Subject: Re: tars and zips > "zlib1.0.4.tar.gz contains C source code for a data compression > library, compatible with gzip, and a Python interface to the zlib data > compression library is in the python/ subdirectory." > > On a vanilla python build > >>> import zlib > >>> Unfortunately for Bob, zlib provides only compression services, not archiving. The zipfile module uses zlib to support compression and adds the archiving support, but "real" zipfiles use several different compression formats. Generally, InfoZip can read zipfiles made by the zipfile module, but the reverse is not necessarily true. WinZip sometimes can and sometimes can't handle those zipfiles also. Bob, if you have a working C compiler you should be able to port the InfoZip sources to pSOS... or is the environment really that restricted. From p.agapow at ic.ac.uk Fri Apr 6 03:59:40 2001 From: p.agapow at ic.ac.uk (Paul-Michael Agapow) Date: Fri, 6 Apr 2001 08:59:40 +0100 Subject: HTMLizing a script Message-ID: <1erfq5c.ff88lublx73kN%p.agapow@ic.ac.uk> What are people using these days to format a python script as appropriate HTML, for putting on the web? I've given py2html a (very) quick lookover and it's output looks very nice, but there seems to be some problems running it. Firstly it uses regex and secondly on my setup (Macintosh, Python 2) it refuses to colour the syntax. Any ideas? -- Paul-Michael Agapow (p.agapow at ic.ac.uk), Biology, Imperial College "Pikachu's special power is that he is monophyletic with lagomorphs ..." From neilh at scintilla.org Tue Apr 17 19:51:18 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 17 Apr 2001 23:51:18 GMT Subject: Hygienic macros (was: do...until wisdom needed...) Message-ID: The right way forward for hygienic macros seems to me to be to do a proof of concept implementation on top of standard Python so we can play with it and find if there is anything that really needs it. If there are no strong examples of benefits then the 'avoid extra rope' opinion will win. This looks analogous to the ability to muck with Python's object/class model which could have, but hasn't, resulted in unreadably weird code. do .. until is IMHO insufficiently better to justify hygienic macros. Neil From rcameszREMOVETHIS at dds.removethistoo.nl Sat Apr 21 17:41:34 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sat, 21 Apr 2001 21:41:34 GMT Subject: how to write file with configparser References: <3ae15ddc.7279927@news.xs4all.nl> Message-ID: hlt2000 at hotmail.com wrote: > I,m using the ConfigParser module to read my ini file. After my > program has ran I want to update the ini file. With configdict.set I > modify an option to a new value. > > How do I write this back onto my file system? > > cfgfile=open('config.ini',' rw') > ... > cfgdict.set(....) > ... > cfgdict.write(cfgfile) > > This gives an IOerror: (0,Error) > > What is the right way to do this? It is imperative that you open the file the right way, the mode must be either 'w' or 'w+'. If you use 'r+' the file isn't trunctated, and junk could be left at the end of the file. (It might be some time before a bug like that manifests itself.) Also note there's no mode called ' rw' (sic). There isn't even a mode called 'rw': There's 'r', 'w' and 'a'. You can add a '+' and/or a 'b' to that, but that's it. The configparser is nice, but the write-method needs a bit of an overhaul. It really should accept a filename as a parameter to be consistent *and* avoid errors like the one above Furthermore, it should preserve as much of the original formatting of the file as possible, including things like comments and the order of the sections and options. In its present form it is inconvenient for files which are hand-edited as well as machine-updated. Robert Amesz From paulp at ActiveState.com Sat Apr 21 01:05:34 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 20 Apr 2001 22:05:34 -0700 Subject: ActiveState PPM probs References: <9bq8h1$h5q$1@flood.weeg.uiowa.edu> <%o3E6.1759$LK1.328611972@newssvr16.news.prodigy.com> Message-ID: <3AE1151E.1E67CCF5@ActiveState.com> Tim H wrote: > > Yeah PIL doesn't seem to be there at all now. If you do a search with no > parameters it shows a list of packages. PIL is in the 2.1 repository now. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From zamurai at gmx.net Fri Apr 27 16:54:26 2001 From: zamurai at gmx.net (Zamurai) Date: Fri, 27 Apr 2001 22:54:26 +0200 Subject: Which Tkinter widget can show jpegs/gifs? Message-ID: <988404866.1635211513@news.t-online.de> - From root at rainerdeyke.com Thu Apr 12 13:07:44 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 12 Apr 2001 17:07:44 GMT Subject: OT - Closing Off An Open-Source Product References: <20010411183525.P754-100000@open-systems.net><3AD4F4FB.3D13F205@ActiveState.com><0l9B6.147943$m04.6141182@e420r-atl1.usenetserver.com> Message-ID: "Barry A. Warsaw" wrote in message news:mailman.987052877.18229.python-list at python.org... > And you wonder why there's such mass marketed crap on the radio and > MTV? Personally, I say boycott the labels, go out and see a good > local band in your neighborhood bar, and support them by buying their > CD. Or buy stuff directly from the band by visiting their web-sites, > like, say www.cravindogs.com. :) I would say "boycott the *major* labels" instead. Independent labels are generally not doing it for the money, but for the love of the music. And there's so much great stuff on independent labels that I can't afford to boycott them. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mcfletch at home.com Mon Apr 2 12:50:31 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Mon, 2 Apr 2001 12:50:31 -0400 Subject: wxPython crashing Win2K In-Reply-To: <2p3aa9.976.ln@demonseed.net> Message-ID: <000101c0bb95$0841b8e0$a9807018@cr706570a> Following assumes a TNT/GeForce card: In your card's advanced OpenGL settings, go to "Troubleshooting" and set the acceleration to "None", if that solves the problem, you've got a buggy OpenGL driver. I'd suggest getting the official 5.12.01.0650 drivers if you've got that card. They aren't entirely stable, but they seem to work for most things (I can run Quake III on them, but Cosmo Player still fails). HTH, Mike -----Original Message----- From: jason petrone [mailto:jp at NOSPAMdemonseed.net] Sent: Monday, April 02, 2001 10:53 AM To: python-list at python.org Subject: Re: wxPython crashing Win2K Achim Domma wrote: > I have just installed wxPython on my Win2K but the demo > is crashing my system (Bluescreen -> Reboot everytime I try) > I only found hints about Win95 but nobody seems to have problems > on Win2K. Does anybody has a hint about this problem ? My guess is that it is somehow related to the OpenGL widget. Try disabling it. -jason -- http://mail.python.org/mailman/listinfo/python-list From lkcl at angua.rince.de Mon Apr 2 11:31:27 2001 From: lkcl at angua.rince.de (Luke Kenneth Casson Leighton) Date: Mon, 2 Apr 2001 17:31:27 +0200 Subject: HOWTO restrict multiply inherited class to on sub-class In-Reply-To: ; from mwh21@cam.ac.uk on Mon, Apr 02, 2001 at 04:18:46PM +0100 References: Message-ID: <20010402173127.F13797@angua.rince.de> On Mon, Apr 02, 2001 at 04:18:46PM +0100, Michael Hudson wrote: > > x = new Inherited(); > > > > y = (Base1*)x; > > ^^^^^^^ > > > > how do you do _this_ in python? > > Don't. What does it buy you? data hiding. > Python doesn't really do data hiding. ahh... :) > > i.e. i have a Database-access class that inherits from about > > six separate sub-database classes. > > > > i want another class to have access to only ONE of the subsets > > of functionality. > > Why? there are scores of database functions available: i don't want one object to have access to any more database functions than it strictly needs. [example code / explanation cut] > I hope you reconsider your need to do this, but if you don't, HTH. python is very simple and clear. to add obscurity for the sake of a language limitation is not, imo, worth the hassle. thanks for the feedback. luke From emile at fenx.com Sat Apr 14 02:37:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 13 Apr 2001 23:37:54 -0700 Subject: sending mail attachements via python & smtplib References: <9b8jrr$86f9m$1@ID-82539.news.dfncis.de> Message-ID: <9b8rf7$892s5$1@ID-11957.news.dfncis.de> """ I was looking to do this recently and found this. Use by invoking mailFileToUser(user at company.com, fullyQualifiedFileName) HTH, -- Emile van Sebille emile at fenx.com """ import string import MimeWriter import mimify import StringIO from smtplib import SMTP import base64 # Mails a file to the user in MIME format # Based upon code by GVR def mailFileToUser(_userName, _fileName): # We are using a string as a temporary file outputfp = StringIO.StringIO() # Create a MimeWriter object w = MimeWriter.MimeWriter(outputfp) w.addheader("subject", "Current Invoice Copies") w.addheader("MIME-Version", "1.0") w.flushheaders() # Now we create a plain text segment and write the instructions file into it w.startmultipartbody("mixed") instructions = w.nextpart() instFile = instructions.startbody("text/plain") instructions.flushheaders() ###instFile.write(open("./instructions.txt", "r").read()) # Now we create a base64 encoded segment and write the diary file into it # as an attachment subwriter = w.nextpart() subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", 'attachment; filename="%s"' % _fileName) f = subwriter.startbody('application/octet-stream; name="%s"' % _fileName) subwriter.flushheaders() base64.encode(open('%s' % _fileName, 'r'), f) w.lastpart() # Next we have to email the mail message to the user # the outputfp.getvalue retrieves all the stuff written to the StringIO file object s = SMTP('172.20.7.10') s.sendmail("SenderName at sendingCompany.com", _userName, outputfp.getvalue()) s.close() """ --------- "Rajarshi Guha" wrote in message news:9b8jrr$86f9m$1 at ID-82539.news.dfncis.de... > Hi, > using the smtplib module I'm able to send mails froma Python script. > However I need to send attachements with the mail. I think I have to mimefy > the attachement, but I'm not too sure about how to go about it. After > mimefication how do I add it to the mail? > > Could give me a general idea of how to go about this? > > TIA, > > Rajarshi Guha > mailto:rajarshi at presidency.com > > """ From scarblac at pino.selwerd.nl Tue Apr 3 05:24:44 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 3 Apr 2001 09:24:44 GMT Subject: CGI script to count downloads References: <3AC95ECE.B8F5E93E@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote in comp.lang.python: > I'm trying to write a script that will keep a count > of the number of times a file is downloaded. So far, > the script just takes the name of the required file, > opens the file, and passes on its contents. > > It works fine, except for one annoying thing: > When Netscape pops up the box requesting a file > name for saving, the default filename seems to be > constructed in a screwy way from parts of the > URL. For instance, if the URL used to retrieve the > file is > > download.py?file=download/akaroa2.6.1doc.tar.gz > > then the default filename that Netscape gives me > is > > akaroa2.6.1doc.tar.py > > So, my question is, can I put anything in the > headers of the response to give the browser a > hint as to what name the file should be saved > under? This is a CGI question! ;) According to the CGI faq at http://www.htmlhelp.com/faq/cgifaq.html , chapter 4 question 22, you can use the URL download.py/filename?options=anyextraoptions And the filename should be in "PATH_INFO" (env var, I suppose). Weeding through some other CGI scripts that Google dug up... Content-type: compressed/gzip; name=%s might work. Another CGI script I found uses the header Content-disposition: inline; filename=%s And notes that it probably only works on Netscape. Seen enough Perl for today now... > Or is there a better way of going about this > whole counting business? Maybe analyze logs? > This is the script I'm using: > > #!/usr/local/cosc/bin/python > print "Content-Type: compressed/gzip" > print > import cgi, sys > form = cgi.FieldStorage() > path = form["file"].value > f = open(path) > sys.stdout.write(f.read()) > f.close() That needs a whole lot of extra checking on the filename of course... -- Remco Gerlich From lkcl at angua.rince.de Mon Apr 2 09:38:49 2001 From: lkcl at angua.rince.de (Luke Kenneth Casson Leighton) Date: Mon, 2 Apr 2001 15:38:49 +0200 (CEST) Subject: HOWTO restrict multiply inherited class to on sub-class Message-ID: <20010402133849.145E42A41F@angua.rince.de> please reply direct and to list, will check via web interface as email is stuffed right now. okay. c++ time. class Base { }; okay, i've forgotten my c++. c++ pseudo-code time :) class Base1 { }; class Inherited: public Base1, public Base { }; x = new Inherited(); y = (Base1*)x; ^^^^^^^ how do you do _this_ in python? i.e. i have a Database-access class that inherits from about six separate sub-database classes. i want another class to have access to only ONE of the subsets of functionality. but there's no way i am going to create redirector functions, one for each and every function i continue to add to the database sub-classes. *grumble* i suppose i could do this automatically *grumble*. search for all functions in one sub-class and exec some code that redirects *grumble*. that's a lot of work, relative to a simple type-cast down to a sub-class! y = Base1.x? class Base: def __init__(self): blah class Base1: .. class Inherited(Base, Base1) x = Inherited() y = x.Base1 ??? y = x.getattr(Base1) ??? y = Base1(x) ??? any one of these is a candidate for possible typecast-equivalence, compared to c++, neh? yes, _i know_: writing this took longer than it would to actually do the for-generate-function-redirects-exec *grumble* but this bothers me :) any clues, anyone? if this doesn't exist, if there's no work-around - _reasonable_ workaround, perhaps i'll write a PEP. luke (currently without an email home :) From fredrik at pythonware.com Thu Apr 12 04:08:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 12 Apr 2001 08:08:57 GMT Subject: converting string to dict ? References: <9b3go7$15l$1@news-int.gatech.edu> Message-ID: Richard Scott Glazerman wrote: > what about exec?? (somebody please let me know if there is something wrong > with using exec this way, I've used it many times for just that purpose.) > > >>> a = "{'Name':'Cleopatra'}" > >>> exec 'a = %s' % a > >>> a > {'Name': 'Cleopatra'} a = "__import__('os').system('rm -rf ~')" see my earlier reply to this thread, and the followups to that post. Cheers /F From shaleh at valinux.com Wed Apr 11 17:03:58 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 11 Apr 2001 14:03:58 -0700 (PDT) Subject: Easy question In-Reply-To: <9b2fdh$3ph$1@news7.svr.pol.co.uk> Message-ID: On 11-Apr-2001 Duncan Smith wrote: > I need to read some data from a file. Each (tab delimited) row corresponds > to an array index eg. > > 0 0 0 0 0 0 > 0 1 0 0 0 0 > 0 0 1 0 0 0 > ... > > And I need something like, > > [[0,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], ...] > > What's the best way of doing this? Cheers in advance. > look at string.split(). From edwardt at trillium.com Mon Apr 16 19:41:13 2001 From: edwardt at trillium.com (EdwardT) Date: Mon, 16 Apr 2001 16:41:13 -0700 Subject: How to search for and display files in a bunchof subdirectory?? Message-ID: <9bfvur$ces@news.or.intel.com> Hi I am trying to write gui that can search and display all the files in subdirectories... Let say I invoke the script in directory d, but I have abunch of subdirectories under d. tpTcCTFTEST10/ tpTcCTFTESTTIGHT02/ tpTcTNLC14_2/ tpTcTNLC6_5/ tpTcCTFTEST11/ tpTcCTFTESTTIGHT03/ tpTcTNLC15_1/ tpTcTNLC6_6/ tpTcCTFTEST12/ tpTcCTFTESTTIGHT04/ tpTcTNLC16_1/ tpTcTNLC6_7/ tpTcCTFTEST13/ tpTcCTFTESTTIGHT05/ tpTcTNLC16_2/ tpTcTNLC6_8/ tpTcCTFTEST14/ tpTcCTFTESTTIGHT06/ tpTcTNLC17_1/ tpTcTNLC7_1/ tpTcCTFTEST16/ tpTcCTFTESTTIGHT07/ tpTcTNLC1_1/ tpTcTNLC8_1/ tpTcCTFTEST17/ tpTcCTFTESTTIGHT08/ tpTcTNLC1_2/ tpTcTNLC8_2/ tpTcCTFTEST18/ tpTcCTFTESTTIGHT0811/ tpTcTNLC2_1/ tpTcTNLC8_3/ tpTcCTFTEST19/ tpTcCTFTESTTIGHT09/ tpTcTNLC2_2/ tpTcTNLC9_1/ tpTcCTFTEST7/ tpTcCTFTESTTIGHT12/ tpTcTNLC4_1/ tpTcTNLC9_2/ tpTcCTFTEST8/ tpTcTNLC10_2/ tpTcTNLC6_1/ tpTcTNLC9_3/ tpTcCTFTEST9/ tpTcTNLC11_1/ tpTcTNLC6_2/ tpTcTNLC9_4/ tpTcCTFTESTTIGHT01/ tpTcTNLC11_2/ tpTcTNLC6_3/ tpTcCTFTESTTIGHT010/ tpTcTNLC14_1/ tpTcTNLC6_4/ and each subdirectory contains a file tp_acc.1. I want to do some processing to this file, but asking the user to click each folder and input the file name is just too much work for them, how can I just display the files in the subdirectories. If the user want the same processing to be done on all of the files , he can just click on the options to process it all. If they want to process part of the sub directory, user also allowed to do so? Thanks From jp at NOSPAMdemonseed.net Tue Apr 24 10:24:59 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Tue, 24 Apr 2001 14:24:59 +0000 Subject: Broken configure script for solaris in 2.1? Message-ID: I noticed some old threads about problems compiling python2.1 on solaris. My trial license for the Sun Workshop Compiler ran out, so I had to compile python with gcc and had the same problems. It seems to me that the error is around line 583 of configure.in: SunOS/5*) if test "$GCC" = "yes" then LDSHARED='$(CC) -shared' else LDSHARED="ld -G"; fi ;; `gcc -shared` doesn't seem to work, but using `gcc -G` or `ld -G` works fine. I assumed that gcc used whatever linker was available on the system, but now I'm wondering if it doesn't do linking itself. If it does, then it would make sense that this doesn't work, since it shouldn't be able to link archives built with non-gnu ar and ranlib. Hope someone knows the right thing to do. It really would be nice for python to compile out of the box on solaris/gcc. -jason From sholden at holdenweb.com Thu Apr 12 14:24:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Apr 2001 14:24:12 -0400 Subject: Threading question References: Message-ID: "Jared Lee Peterson" wrote in message news:mailman.987097937.1958.python-list at python.org... > I have a question regarding threading in python. Let me start by saying > I am on a RedHat Linux 6.2 box with the standard python 1.5.2 that ships > with it. I am writing a test script that I need to spawn various > threads. I could probably do this without threads but I was curious to > see how they work in python so I am trying to get them working. > Basically I need to spawn a thread that is just making a system call > (os.system()) to another script. However when I create the thread with > the target set it seems to call the other script just fine but the > thread blocks execution and does it does not resume in the first script > while that the other thread does it thing. This is how I am spawning > the thread ... > > tmp = Thread(target=os.system(other_script.py)) > > Ideally I want to be able to loop over a list of scripts and spawn > threads for each one and monitor their exectuion. I have tried to look > online for docs on python threading and there are none so if someone > could help me out here that would be great. It is probably obvious just > by my email that I am not the threading master for sure. Thanks a lot > I don't use threads much myself, but the docs suggest the statement you quote only *creates* a thread, and that you will have to call its run() method to start it executing. This would, I presume, require tmp.run() """ run () Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively. """ (Library Manual, 7.5.6) regards Steve From nathan at cjhunter.com Mon Apr 23 13:41:30 2001 From: nathan at cjhunter.com (Nathan Cassano) Date: Mon, 23 Apr 2001 10:41:30 -0700 Subject: Muliplexing Socket Connections Message-ID: <3AE4694A.D7D3F24B@cjhunter.com> Hello Pythoneers, I'm developing a socket server that needs to bind to and multiplex multiple ports. I'm using the select module and sockets to do this. The problem is I cannot get the select function to return a file descriptor from it's return read list. Does anyone have a simple example of socket multiplexing or some pointers? import socket, select sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) print select.select([sock],[sock] ,[] , 0) ... This is the output that follows ([], [], []) From sholden at holdenweb.com Sat Apr 28 14:03:38 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 28 Apr 2001 18:03:38 GMT Subject: variable naming... References: <3ae934d3.2582143@news.newsguy.com> <9ccqe602g02@news1.newsguy.com> <3aea4604.851346@news.newsguy.com> <3AEAFB68.40187478@home.com> Message-ID: <_BDG6.35526$qc2.9285495@typhoon.southeast.rr.com> "Bruce Elrick" wrote ... > > Steve Holden wrote: > > > > "Owen F. Ransen" wrote in ... > > > Ah...a good reason at last...none of the "Microsoft > > > does it so we don't!" objections. :) > > > > > That's usually a knee-jerk reaction, but not always a safe one. We should > > remember that Microsoft have done some good things (ODBC and DHCP spring > > readily to mind), and that we might be in similar trouble if *we* ran the > > largest software company in the world. > > DHCP? Looking at RFC 1531, 1541, and 2131, I'd say we have Bucknell > University to thank for DHCP :-) (Maybe I'm ignorant of some history > before that) > An alternative, and equally likely, explanation is that I'm wrong. OK then, there's at least ONE thing we have Microsoft to thank for... wondering-when-the-spanish-inquisition-will-tell-me-ODBC-wasn't-microsoft-ly y'rs - sTevE From ullrich at math.okstate.edu Wed Apr 18 12:11:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 18 Apr 2001 16:11:13 GMT Subject: With or Using References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> <2b95c26c4a%tim@worthy.demon.co.uk> Message-ID: <3addbc5a.680231093@news.okstate.edu> On Tue, 17 Apr 2001 19:58:34 +0100, Tim Howarth wrote: >In message <3ADC5AE1.53C3C4FE at alcyone.com> > Erik Max Francis wrote: > >> Tim Howarth wrote: >> >> > Being lazy, I wondered if something like the following was possible in >> > Python? >> >> Hopefully not. In every language that kind of syntax has been >> introduced, it has only led to trouble. > >I've met it in Delphi and assumed it was the norm for object properties. It's in Delphi all right. Now find five Delphi experts and ask them whether they think it's a good idea. >> It saves a small amount of typing (and not very much) at the expense of >> a lack of clarity and the addition of ambiguity. > >I thought with Python's block indenting it would be pretty clear what >was being referred to. > >-- >___ > |im ---- ARM Powered ---- From scarblac at pino.selwerd.nl Tue Apr 3 03:01:49 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 3 Apr 2001 07:01:49 GMT Subject: excluding unit test code References: Message-ID: Steven Haryanto wrote in comp.lang.python: > Since an XP-faithful coder can write lots of test suites, > is there a simple way to exclude these code in a module > from the production code? A simple idiom is if __name__ == '__main__': # tests here That way the scripts are run when the module is run by itself, but not when it is imported. Also, __debug__ is usually 1, but 0 when the -O (optimize) command line switch is used. -O also removes assert commands. -O -O discards doc strings as well. So you could put your tests under if __debug__: # tests here And use your production code with the -O command line option. -- Remco Gerlich From skidrow at nownuri.net Sun Apr 8 08:18:40 2001 From: skidrow at nownuri.net (Seo ji won) Date: Sun, 8 Apr 2001 21:18:40 +0900 Subject: how to debug python-program..? Message-ID: <9apkc7$oo2$1@news1.kornet.net> I want to debug python-program like the way gdb/jdb does.. How can I do it?.. Thanks in advance From nessus at mit.edu Thu Apr 19 17:58:40 2001 From: nessus at mit.edu (Douglas Alan) Date: 19 Apr 2001 17:58:40 -0400 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9bjtbr02108@news1.newsguy.com> <9bl6i701e09@news1.newsguy.com> <9bmgid081b@news1.newsguy.com> <9bng2l019nb@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > > Surely a man of your intelligence, Alex, knows that outright insults are > > not the only way to be abusive? > "Invective", sure; that is what a (well-constructed) flamewar is. > Merriam-Webster clarifies usage by noting that "invective" "suggests > greater verbal and rhetorical skill and may apply to a public > denunciation", while "abuse" "stresses the harshness of the > language" -- seems a well-drawn explanation to me. My dictionaries disagree with your dictionary. My Webster says that abuse "stresses harshness and unfairness of verbal attack". It is the *attack* that must be "harsh" for words to be "abusive" -- the words themselves do not need to be harsh. My American Heritage says "to assail with contemptuous, coarse, or insulting words". Notice the word "or" in this definition; the words do not need to be "coarse" to be "abusive" -- "contemptuous" or "insulting" will do. "Abuse" and "invective" are not mutually exclusive terms. "Invective" is more specific, while "abuse" is more inclusive. |>oug From nils.hensel at online.de Sat Apr 7 05:40:19 2001 From: nils.hensel at online.de (Nils Hensel) Date: Sat, 7 Apr 2001 11:40:19 +0200 Subject: How do I launch 'somewhere/Sweety.py' without 'somewhere/'? References: <3acfd343.1841976@news.muenster.de> Message-ID: <9amn7s$e9f$1@news.online.de> cd c:\really\long\path python Sweety.py HTH, Nils "Martin Bless" schrieb im Newsbeitrag news:3acfd343.1841976 at news.muenster.de... > Working in dos boxes of win - but probably independent of this here's > my question: > > ok, PYTHON starts Python > ok, PYTHON c:\really\long\path\somewhere\Sweety.py > executes my beloved script Sweety.py. > > How can I start Sweety.py without having to specify that awful > long path? > > Martin From Cayce at actzero.com Mon Apr 23 17:42:45 2001 From: Cayce at actzero.com (Cayce Ullman) Date: Mon, 23 Apr 2001 14:42:45 -0700 Subject: ANN: SOAP.py 0.8 Message-ID: The latest version of SOAP.py (a SOAP implementation in written in Python), was released today. Check out it's interop matrix : http://www.actzero.com/soap/interop.html or download it : http://www.actzero.com/soap/SOAPpy.html Comments, feedback, patches, etc... very welcome. Changes since last version: VERSION 0.8 (4/23/01) - Added more types - Early multi-referencing support (Parser) - Reorganized the parser, much cleaner now - Preserve whitepsace in strings (per the standard) - Full XML attribute support (Parser/Builder) - Object (de)serialization now maintains element order - Fixed the zero-length array problem - Made indentation uniform (spaces not tabs) - Made Header and Body work more like real structs - Changed the parseSOAP api, now returns the body structure, instead of a list of body elements - Changed the soapaction and namespaces for the interop server - New silabclient options - Initial encoding support From gerhard.nospam at bigfoot.de Sat Apr 7 18:43:26 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 8 Apr 2001 00:43:26 +0200 Subject: Install MySQL + Python + Win2K References: Message-ID: On Sat, 07 Apr 2001 14:06:10 GMT, zc wrote: >Thanks Gerhard !!! > >It worked the first time. >This is waht I did (this is for all other newbies in my situation, that is: >Win2k + Python + MySQL-3.23.32) >Steps: >#1: Download Python2.1b2 from www.python.org >#2: Download MySQL-python-0.3.5-win32-1.zip (from >http://home.t-online.de/home/err666/) >#3: Install Python >#4: unzip MySQL-python-0.3.5-win32-1.zip to a dir of you choice >#5: modify setup.py (in the mysql module dir), so that the win32 section >reflects you installation of mysql paths >#6: in DOS prompt run: python setup.py install >#7: if you had no errors in step 6: > start python command prompt and type: import MySQLdb > if you see no tracback, you are OK >At least this is how it woeked for me. >I also tested the connection from Apache. Worked fine. Good to know it did work :-) Just for information: you can skip step #5. You even don't need to have anything MySQL installed, if all you want is connect to a different MySQL server. Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From grey at despair.rpglink.com Tue Apr 17 20:48:03 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Wed, 18 Apr 2001 00:48:03 -0000 Subject: Hygienic macros (was: do...until wisdom needed...) References: Message-ID: On Wed, 18 Apr 2001 00:37:11 GMT, Brett g Porter wrote: >Hi -- for the non-LISP-ers among us -- could someone give a pr?cis on what >makes a macro 'hygienic'? A quick Google search turned up tons of links, but >none that were explanatory (at least not to a non-LISP programmer like >myself), and ESR's Jargon File doesn't cover it. From what I've read of the thread it is a system by which one would be allowed to alter and extend the base language to include features/syntax not present in the core language. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From tim.one at home.com Sun Apr 22 16:19:27 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 22 Apr 2001 16:19:27 -0400 Subject: Nested Scopes in Idle/PythonWin In-Reply-To: <15075.12467.428038.904759@slothrop.digicool.com> Message-ID: [Greg Chapman] > No, I'm talking about the interactive interpreter: > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> def make_adder(x): > return lambda y: x+y > SyntaxError: local name 'x' in 'make_adder' shadows use of 'x' as > global in nested scope 'lambda' (, line 1) [Jeremy Hylton] > You didn't tell the interpreter that you wanted to use nested scopes. > > >>> from __future__ import nested_scopes > >>> def make_adder(x): > ... return lambda y: x + y > ... > >>> Greg is using IDLE, not a cmdline Python, and it doesn't work in IDLE. This has been listed as an unresolved issue in PEP 236 all along: Unresolved Problem: Simulated Interactive Shells Interactive shells "built by hand" (by tools such as IDLE and Emacs Python-mode) should behave like native interactive shells (see above). However, the machinery used internally by native interactive shells has not been exposed, and there isn't a clear way for tools building their own interactive shells to achieve the desired behavior. That's still the case (else I would have updated the PEP to say something else there ). From dsh8290 at rit.edu Wed Apr 18 17:41:50 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 18 Apr 2001 17:41:50 -0400 Subject: why python annoys me In-Reply-To: ; from loewis@informatik.hu-berlin.de on Wed, Apr 18, 2001 at 01:40:53PM +0200 References: <3ADCBECE.1BDFFCD@netplus.net> Message-ID: <20010418174149.G20005@harmony.cs.rit.edu> On Wed, Apr 18, 2001 at 01:40:53PM +0200, Martin von Loewis wrote: | Luke writes: | > | > Why do you always have to access class data members as self.* What a | > pain in the ass, and anti-OO. | | I disagree. In Smalltalk, which is one of the oldest OO languages, the | object being dealt with is always referred-to as "self". Even in a | natural language, the actor always refers to the subject of an action, | even if the subject is the actor ("I understand this", not "Understand | this"). Only in English. In other languages (Spanish comes to mind, I don't really know any others but AFAIK all Romance languages are identical in this regard) the verb changes to indicate the subject. I belive this comes from the time (~1044 AD) when the Norman French invaded England. At that time the smart (rich) people spoke French while the uneducated (poor) people spoke English. As a result of the English speakers being uneducated and spread out the language evolved to become closer to slang and varied from region to region. Sometime after the french were no longer ruling the writers of the time began to re-standardize the language. I think that the functions should be named differently to indicate the subject for each possible use of the function so the compiler/interpreter will automatically know exactly which subject is "self"/"this" . -D From sholden at holdenweb.com Fri Apr 27 07:46:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Apr 2001 11:46:05 GMT Subject: My First CGI Script References: <3AE8F40D.64261D7@nmt.edu> Message-ID: <1_cG6.25386$qc2.7354390@typhoon.southeast.rr.com> "Jeff Shipman" wrote in message news:3AE8F40D.64261D7 at nmt.edu... > Ben Ocean wrote: > > **How do I capture the data? > > What I normally do first is > > form = cgi.FieldStorage() > > That grabs all of the data from your form. Then, you > can grab the individual components of your form by > using it like a dictionary. (ie: form["name"], form["address"]) > Ben, if you haven't used the cgi module's FieldStorage object before, I seem to remember that form["name"] is not a simple string value but another FieldStorage, so you access the value of the form element called "name" using form["name"].value regards Steve From erikw at lineo.com Mon Apr 23 19:07:18 2001 From: erikw at lineo.com (Erik Weber) Date: Mon, 23 Apr 2001 16:07:18 -0700 Subject: Making a python extension in c++ Message-ID: <988067008.220977@db.lineo.com> I am attempting to make a Python-2.0 extension on Linux. If I include in Setup the lines *shared* test test.c it compiles test.so no problem. If however I use the lines *shared* test test.cc then the build fails with; [erikw at devbrick4 testwiz]$ make fpic -g -O2 -Wall -Wstrict-prototypes -I/usr/local/include/python2.0 -I/usr /loc al/include/python2.0 -DHAVE_CONFIG_H -c ./test.cc make: fpic: Command not found make: [test.o] Error 127 (ignored) gcc -shared test.o -o test.so gcc: test.o: No such file or directory gcc: No input files make: *** [test.so] Error 1 [erikw at devbrick4 testwiz]$ It seems to me as though the ".cc" extension causes the Makefile.pre.in stuff to fail. Has anyone compiled a C++ based extension? If so, what did your Setup file look like? -- -Erik Weber Lineo Seattle 206.285.2506 x204 From qrczak at knm.org.pl Mon Apr 2 12:51:18 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 2 Apr 2001 16:51:18 GMT Subject: PEP 245 References: <3AC7B79A.B9601E5C@shindich.com> Message-ID: Sun, 1 Apr 2001 23:30:32 +0000 (UTC), Alex Shindich pisze: > > To get better error messages early, instead of cryptic errors raised > > deep where the object was finally actually used. > > Try this: > class MyInterface: > def foo (self): > """ > """ > raise UnimplementedMethodException ("Method foo is not implemented.") It doesn't change a message that an internal function i never heard about tried to call an object which is not callable into a message that a function I called expects a predicate. > All it guarantees is that the concrete class has methods with the > same names as those in the interface. No framework can *guarantee* more. Any framework can be misused by providing useless instances of generic concepts. > Hmm... I happened to like to Java... It's just that I use it when > I need strong typing. And I totally love Python, and I use it > whenever I can... A flaw in Java's approach to specifying interfaces is that it requires to specify all of them during definition of a class. It's not necessary (no matter if typing is static or dynamic) and Python will surely not require it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From grey at despair.rpglink.com Tue Apr 17 11:40:18 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 17 Apr 2001 15:40:18 -0000 Subject: do...until wisdom needed... References: <3ADC4FEA.2664FDF7@noaa.gov> Message-ID: On Tue, 17 Apr 2001 10:15:06 -0400, Benjamin.Altman wrote: >While I wouldn't care either way for a loop.. until construct, I don't quite >see how it is so complicated. It isn't complicated in and of itself. Look at my example of Perl's handling of a simple conditional expression. 6 different ways to express one concept. Taken individually each is not that difficult to understand. Taken together it is a maintenance nightmare. I should know, I have to deal with the "simplicity" of those 6 different ways to express one concept on a daily basis at work. My way of handling it is to force myself to standardize on the most common and extensible format (if (!condition){}) and rewrite all other forms to that when encountered. Even then I am only reducing it to one of two possible formats and dealing with precidence issues. Well, actually, 12 as someone has pointed out. I'm sure we're missing more. 12 with their own slightly variant way of doing things. That is where the complexity comes in. No, do..until is not that hard. Heck, IIRC the language I learned procedural programming in, Turbo Pascal, has it. But having it when it clearly isn't needed only adds unneeded complexity. What I find most ironic is this discussion was spawned by someone who wants to reimpliment Python for an embedded system. One would think that on an embedded system that one would want to conserve space by using the least number of variations of common concepts, not waste it implementing several special cases. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From nas at python.ca Thu Apr 19 11:03:36 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 19 Apr 2001 08:03:36 -0700 Subject: Problem building Python 2.1 on HPUX11.0 In-Reply-To: ; from richardt@edshk.demon.co.uk on Wed, Apr 18, 2001 at 02:49:19PM +0100 References: Message-ID: <20010419080336.A31005@glacier.fnational.com> Richard Townsend wrote: > Is there a way to build 2.1 without using a C++ compiler ? ./configure --without-cxx is the magic you want. Neil From sheila at spamcop.net Thu Apr 5 19:02:54 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 05 Apr 2001 23:02:54 GMT Subject: CGI script refuses to run python References: Message-ID: On Thu, 5 Apr 2001 15:46:25 -0700, "vikas" wrote in comp.lang.python in article : :Ok, I have the same error. :However, my sys.path has the correct paths in it. :i.e. python is installed in /usr/local/lib/python2.0. : :I tried making shell scripts to set the env :and then try to invoke python. It seems like if :I set the PYTHONPATH before invoking python, :it works. But any python scripts invoked by that :python scripts don't work! : :Any ideas? : It really doesn't sound to me, like you have it installed in the right place. If you did, surely it would be able to find everything it needs for the scripts to run??? Is the binary in /usr/local/lib also? Usually it should be in /usr/local/bin I believe. Run a script similar to this one (This one is a cgi-script, meant to be invoked from a browser, but it should run at the command line, too): ------------------------------------------ #! /usr/local/bin/python2.0 import sys print "Content-type: text/plain\n\n" print sys.version print for path in sys.path: print path print print "Those are the paths" ------------------------------------------ That will show what the path actually are. If you do not have the binary installed where it expects, and the libraries installed where it expects, I'd think you'd be having problems. The work-around that I had, before I re-installed, was to reset the paths inside of each script right at the beginning of the script, to point to the directories where the binary and the libraries were installed. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :Sheila King wrote in message :news:hhanctghter75fs890kk98ttmue18pi2p2 at 4ax.com... :> Try this URL: :> :> http://www.aota.net/ubb/Forum3/HTML/001564-1.html :> :> -- :> Sheila King :> http://www.thinkspot.net/sheila/ :> http://www.k12groups.org/ :> :> :> On Wed, 4 Apr 2001 14:53:46 -0700, "vikas" wrote in :> comp.lang.python in article : :> :> :Hi, :> :I am trying to get this python cgi script to work on apache. :> :I made a test script to break down the problem. :> : :> :So now the script is just: :> :#!/usr/local/bin/python :> : :> :I still get the same error in the web server log: :> : :> :Could not find platform independant libraries :> :Could not find platform dependant libraries :> :Consider setting $PYTHONHOME to [:] :> :'import site' failed; use -v for traceback :> : :> :How do I fix this? :> : :> :Thanx :> :Vikas :> : :> : From sholden at holdenweb.com Tue Apr 3 08:59:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 3 Apr 2001 08:59:58 -0400 Subject: bzip2 extension exist for python? References: Message-ID: "Jan Dries" wrote in message news:mailman.986158682.29623.python-list at python.org... > Moshe Zadka wrote: > > > Does Python have a bzip2 extension? I'm looking for something that > > > resembles the functionality of the gzip module. > > > > You shouldn't worry about idiotic things like bzip2, when superior > > technologies like lzip (http://lzip.sourceforge.net). I am now working > > on a reimplementation of lzip in Python, since I feel the current lzip > > code base is too messy to use. Expect updates! > > This is truly fantastic, unlike anything I've ever seen before. > Since you are reimplementing it in Python, just some thoughts: I did a > quick analysis of the Lessis-Moore algorithm, and it has occured to me > that if one were to put an md5-filter in front, filtering all the data > prior to feeding it into the LM-algorightm, it could achieve even > greater compression. And of course, for the unzip one could simply use > reverse md5. > I did a little work to get a rough implementation in Python, and it appears you are right. The result is a file compression algorithm which allows you to add free space to your filestore by creating new files. This has led me to speculate that most operating systems could really use negative filesizes. Is your disk getting a little full? Just md5lzip your largest files and you create free space on your disk! I'd like to thank Moshe Zadka for making his original code available to facilitate these experiments. regards Steve From max at alcyone.com Mon Apr 16 18:37:55 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 16 Apr 2001 15:37:55 -0700 Subject: Python and Apache References: <3ADB4669.4EA1D2E2@alcyone.com> <88imdtcouov6kebuqt9smvf3s385nat907@4ax.com> Message-ID: <3ADB7443.F189F871@alcyone.com> David Fuess wrote: > Yes, that's what I thought also, but I am able to execute > > /usr/local/bin/python /home/httpd/cgi-bin/hello > > and it works. Also I've checked and everything is where it's supposed > to be. "which python" returns "/usr/local/bin/python". Interesting > though that when I attempt ./hello when CWD=/home/httpd/cgi-bin I get > the file not found error also(?). I'm wondering if the /cgi-bin/ -> > /home/httpd/cgi-bin is working correctly. Well, check it. If the paths are correct, then it's probably either 1. the script is executable by you but not by nobody (what Apache runs as) or 2. you have Apache configured in such way that it will execute CGI scripts only if they end in .cgi. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Let he who does not know what war is go to war. \__/ (a Spanish proverb) Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From zope at thewebsons.com Fri Apr 27 09:16:35 2001 From: zope at thewebsons.com (Ben Ocean) Date: Fri, 27 Apr 2001 06:16:35 -0700 Subject: My First CGI Script Message-ID: <5.0.2.1.0.20010427061628.00aca5b0@thewebsons.com> If anyone has a simple cgi script they could share with me that does anything remotely similar to the needs I outline herein and the script I've cobbled together at the bottom of this email it would be appreciated! At 10:22 PM 4/26/2001 -0600, you wrote: >Ben Ocean wrote: > > **How do I capture the data? > >What I normally do first is > >form = cgi.FieldStorage() > >That grabs all of the data from your form. Then, you >can grab the individual components of your form by >using it like a dictionary. (ie: form["name"], form["address"]) I'm lucky. This first project is dirt-down simple. I don't care what the data is! I just need to get it to the client after the visitor enters it. I was designing a page to put up on the site, but perhaps it would just be easier to email the data to the client. >There are a couple of good examples in the library reference. I wasn't able to find anything simple. The examples I found were too complex for newbies. Probably didn't look in the right place... > > **How do I write a Web page on the fly and assign it the name *Report*? > >Anyway, as I was saying, what I normally do is just print the >results to stdout like so: > >print 'Content-type: text/html\n\n' > >print '\n'\ > ' \n'\ > ' This is my name: '+form["name"]+'\n'\ > ' \n'\ > '' > >and your browser should pick it up just fine. Do I define a function called main? TIA, BenO Here's my script, such as it is right now: #!/usr/bin/python import sys # just for debugging purposes import cgi import time import string import os form = cgi.FieldStorage() print 'Content-type: text/html\n\n' # specify the filename of the page to send the dealership Report = repr(time.time()) + ".html" # read the entire file as a string def main(): start = "\nHere's the data a potential customer requested from the Kelley Blue Book link on your Web site:
 
\n" FormData = open("/apache/vhosts/bladechevy/cgi-bin/kelleyblue.html","r") formstuff = "" while FormData.readline(): safe = string.maketrans("`|~!@#$%^&*()_+=:;{}[]", "----------------------") line = string.replace(string.replace(string.replace(string.translate(FormData.readline(), safe), "
\n") formstuff = string.join([formstuff,line]) end = "\n" all = string.join([start,formstuff,end]) FormData.close() # close the file if (__name__ == "__main__"): main() From tim.one at home.com Fri Apr 6 01:57:32 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 6 Apr 2001 01:57:32 -0400 Subject: Conditional operator in Python? In-Reply-To: <9ajdgq$of1$1@slb6.atl.mindspring.net> Message-ID: [Tim] > hard-to-believe-that-semantically-significant-leading-zeroes- > ever-seemed-like-"a-good-idea"-to-anyone-ly y'rs - tim [Andrew Dalke] > I do remember a letter to the editor in CACM You shouldn't read that. CACM has become the National Enquirer of comp.lang.python wannabes. > a few years ago Ah, OK -- nevermind. Just be sure you don't do it again. > complaining about all the CS oriented computer science languages > which didn't have a very useful feature in COBOL - a data type > which understood that leading zeros are important for identifier > numbers. Eg, 04/03/01 as a date or 001-453-23264 as a part number. Hmm. 04/03/01 sure looks like 4/3 to me! What's the matter with strings? They don't automagically have a "field" concept, or automagically verify that assignments to fields contain data of the proper form, that's what. But it's easy enough to write a Python factory function to produce classes with those abilities, given a format description string (call it, oh, "picture"). OTOH, trailing zeroes can be useful in real-world arithmetic, and the REXX language defines (e.g.) 4.73 - 1.03 to be 3.70, not 3.7, and way not 3.7000000000000002. I'm going to inflict that on Python someday. > But that's neither here nor there, and since the thread > in CACM went nowhere over several months of agumentative > debate, perhaps I shouldn't have brought it up here. Na, we routinely settle debates in one arrogant msg here that the trade rags can't resolve in a decade. Just another part of c.l.py's job. > So, umm, what do you think of Riemann-Stiljes integration > as it pertains to mark&sweep garbage collection of boxed > integers? If you view time as the horizontal axis and bytes of boxed integers reclaimed per instant as the vertical, the area under "the curve" is the cumulative boxed-byte-seconds (BBS) reclaimed. The connection to R-S integration is thus immediate, as "the curve" is really a discontinuous step function. > How does that compare to Knuth's view? Uncle Don and I have never disagreed on this point! Don't go looking to stir up trouble, Andrew. If you must, join me in complaining about his C coding style. Like: t=TT-1; while (t) { for (j=KK-1;j>0;j--) ul[j+j]=ul[j],u[j+j]=u[j]; /* "square" */ for (j=KK+KK-2;j>KK-LL;j-=2) ul[KK+KK-1-j]=0.0,u[KK+KK-1-j]=u[j]-ul[j]; for (j=KK+KK-2;j>=KK;j--) if(ul[j]) { ul[j-(KK-LL)]=ulp-ul[j-(KK-LL)], u[j-(KK-LL)]=mod_sum(u[j-(KK-LL)],u[j]); ul[j-KK]=ulp-ul[j-KK],u[j-KK]=mod_sum(u[j-KK],u[j]); } if (is_odd(s)) { /* "multiply by z" */ for (j=KK;j>0;j--) ul[j]=ul[j-1],u[j]=u[j-1]; ul[0]=ul[KK],u[0]=u[KK]; /* shift the buffer cyclically */ if (ul[KK]) ul[LL]=ulp-ul[LL],u[LL]=mod_sum(u[LL],u[KK]); } if (s) s>>=1; else t--; } for (j=0;j And what if the cosmological constant is positive? It appears that Perl 6 is determined to test that empirically. > (Phew - swerved that conversation just in time!) failing-to-see-the-connection-to-transfinite-cardinals-ly y'rs - tim From root at rainerdeyke.com Fri Apr 20 23:44:32 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 21 Apr 2001 03:44:32 GMT Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> <3ADF54F1.6000409@hccnet.nl> <3AE0F802.3983C9DB@01019freenet.de> Message-ID: "Oliver Korpilla" wrote in message news:3AE0F802.3983C9DB at 01019freenet.de... > > Python does not force you in thinking OO, procedural or functional. > > That's what I ment. > > What about functional ? Pyhon doesn't either ENABLE you to work functional!! > apply, filter and map are 3 nice functions, and the data types are nice, too, > but without list comprehension or partial applicatiob, curried function etc. > you can't use them that much neither... Python has list comprehensions. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From qrczak at knm.org.pl Sun Apr 15 05:30:10 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 15 Apr 2001 09:30:10 GMT Subject: Class Variable Question References: <9at1ul010vn@news1.newsguy.com> <3ad2a7dd$0$47987$e2e8da3@nntp.cts.com> <9aush501oro@news2.newsguy.com> Message-ID: Tue, 10 Apr 2001 13:58:35 +0200, Alex Martelli pisze: > It _could_, but it won't. If your unit-tests are anywhere close to > 1/10th as large as they should be, they'll catch all your typos 'hey > pronto'. If your unit-tests are even skimpier than that, your software > is going to be so frail and weakly anyway that a few more uncaught > typos aren't going to matter one way or another. PyChecker has found typos in the Python distribution. I conclude that Python hasn't been tested ehough - otherwise, as you are saying, these typos would have been caught. Does it mean that Python is so poorly written that a few more uncaught typos don't make a difference? > Your C++ compiler doesn't catch all the typos you can make where you > type '+' while meaning to type '-', or '>' intending '<', etc, for > example. Of course. No language catches such typos. It doesn't imply that catching detectable typos (e.g. using names which are not defined) is worthless! I'm seeing again this poor argument: some mechanism doesn't solve all problems, so it's worse than having nothing... -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From m.hadfield at niwa.cri.nz Thu Apr 5 18:40:12 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Thu, 5 Apr 2001 22:40:12 +0000 (UTC) Subject: PythonWin 2 UNIX References: Message-ID: <008101c0be21$602cc980$d938a8c0@Hadfield> From: "dsavitsk" > but the point is that this seems wrong. Python is billed as being "cross > platform", not "cross platform once you run a utility or boot up PFE and > convert the file." In general I really like PythonWin so I hate to say > anything negative about it, but if PFE can get by w/o line endings on win32, > why can't PyWin? Maybe this will show my ignorance, but if the same > scintilla source can build on both windows and unix, why can't it be > modified to be like PFE and not need line endings? I'm sure it can, but no-one has done it yet. Any volunteers? --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From nessus at mit.edu Fri Apr 6 13:43:32 2001 From: nessus at mit.edu (Douglas Alan) Date: 06 Apr 2001 13:43:32 -0400 Subject: problem executing python scripts in cygwin bash shell References: <69AD80E50414598C.875157435733CF34.B50964BA627F4825@lp.airnews.net> Message-ID: "John J. Lee" writes: > Aha! Good idea. Perhaps even better: > #!/bin/sh > temp = "$@ " > //d/apps/Python20/python `cygpath -w $1` ${temp#* } Good idea, but not quite right. You really want: #!/bin/sh exec //d/apps/Python20/python "`cygpath -w $1`" ${1+"$@"} |>oug From sholden at cox.rr.com Tue Apr 24 12:10:28 2001 From: sholden at cox.rr.com (Steve Holden) Date: Tue, 24 Apr 2001 16:10:28 GMT Subject: Change cwd in the underlying shell from Python script? References: <%mcF6.18949$ii.2113952@afrodite.telenet-ops.be> Message-ID: wrote in message news:%mcF6.18949$ii.2113952 at afrodite.telenet-ops.be... > Joakim Hove wrote: > > bash:/original/path$ myscript.py > > > > [The Python script goes through a "serious calculation", and finds > > the new path "/new/path/to/where/I/want/tobe". > > > > When the script is finished the cwd of the underlying shell has > > been changed to this new path.] > > > > bash:/new/path/to/where/I/want/tobe$ > > > > Is something like this possible? > > No. The cwd is a property of a process. You can change directories > anywhere you want in your Python script, but it won't influence the > parent process (bash). > > Greetings, > -- > ben . de . rydt at pandora . be ------------------ your comments > http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora > However, what you *could* do is: In the parent process, issue the command: PATH=$PATH:`pathcalculator.py`; export PATH If your pathcalculator.py produces, on standard output, the directory (or colon-separated list of directories) you want to add to your path, the backquotes in the shell use that value in the PATH=... assignment. If you want to completely reset the path, you would just use PATH=`yourpathcalculator.py`; export PATH You don't need to bother with the export if you don't care whether sub-shells see the new path or not, but I suspect this isn't likely to be the case. regards Steve From wolfson at uchicago.edu Thu Apr 19 18:11:07 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Thu, 19 Apr 2001 17:11:07 -0500 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <9bjl2901ifj@news1.newsguy.com> <9bkc0t02sac@news1.newsguy.com> <9bkvi30uf8@news1.newsguy.com> Message-ID: <6nJD6.514$E4.20337@uchinews> In article , "Rainer Deyke" wrote: > "Alex Martelli" wrote in message > news:9bkvi30uf8 at news1.newsguy.com... >> "Rainer Deyke" wrote in message >> news:OLlD6.46125$J%5.15304817 at news2.rdc2.tx.home.com... How do you stop >> a class from having subclasses in Python? > > def f(): > class C: > pass > C() >>> from klass import klass >>> def get_atuple(self): return self.atuple >>> def init(self, tup): self.atuple = tup >>> def set_atuple(self, tup): self.atuple = tup >>> TupleHaver = klass({}, {'__init__':init, 'get_atuple':get_atuple, 'set_atuple':set_atuple}) t = TupleHaver((1,2,'hi')) >>> t.get_atuple() (1, 2, 'hi') >>> t.set_atuple(('la la', 'la')) >>> t.get_atuple() ('la la', 'la') ### part of klass.py def klass(static_var_dict, methdict): def make(*initv, **initk): inst = lambda: None m = {} for k in methdict.keys(): m[k] = fako(methdict[k], inst) inst.func_dict = m inst.func_dict.update(static_var_dict) m.get('__init__', lambda\ *a, **k: None)(*initv, **initk) return inst return make def fako(func, inst): return lambda *a, **k: func( *((inst,)+a), **k) -- Barnabas T. Rumjuggler Thou hast been called, O Sleep! The friend of woe, But 'tis the happy who have called thee so. -- Robert Southey From korpo at 01019freenet.de Fri Apr 13 12:05:47 2001 From: korpo at 01019freenet.de (Oliver Korpilla) Date: Fri, 13 Apr 2001 18:05:47 +0200 Subject: Test framework for Python Message-ID: <3AD723DB.29D241AE@01019freenet.de> Hi! I'm looking for a test framework for usage with Python. It should be easy-to-use, well-documented and free. Additionally, of course, it should be able to test automatically, and give "neat little reports" for usage in tracking down bugs. Besides, what would anyone recommend as profiling tools for Python to determine performance bottlenecks ? Is there a refactoring browser for Python available or in development? Thanks in advance, Korpo From sheila at spamcop.net Sat Apr 7 19:26:01 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 07 Apr 2001 23:26:01 GMT Subject: looking for command-pipe performance advice References: Message-ID: On Sat, 7 Apr 2001 17:23:51 -0400, "Steve Holden" wrote in comp.lang.python in article : :> body = string.join(raw_body, "") :> :Surely this line is completely redundant here, since you called read() and :not readlines()? Maybe you changed form the latter to the former and :overlooked this? Oops! You're right! I think I did have readlines() in a previous version of the script, and forgot to remove the "join" command when I switched that. I removed the join command now. Tnx, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From ullrich at math.okstate.edu Wed Apr 25 14:16:50 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 25 Apr 2001 18:16:50 GMT Subject: PIL can't open bmp References: <20010424.17443864@mis.configured.host> Message-ID: <3ae7140f.83798863@news.okstate.edu> On Tue, 24 Apr 2001 17:44:38 GMT, Thomas Kwapich wrote: >Hi, > >I need to convert bmp files to eps files under win98. I thought using=20= > >python (v2.1) and the python image library (v1.1.1) is a good idea. But = > >when I try to open an bmp file I get an IOError: Unsupported BMP pixel=20= > >depth. So, what can I do? Do you know what the pixel depth _is_? MS introduced 15-bit and 16-bit bitmaps around 1995, and there's lots of commercial software that still doesn't believe such bmp files exist. >Many thanks in advance. > >Thomas From Robert.Denham at dnr.qld.gov.au Fri Apr 6 02:23:30 2001 From: Robert.Denham at dnr.qld.gov.au (Robert Denham) Date: Fri, 06 Apr 2001 16:23:30 +1000 Subject: numeric: local neighbour hood functions on arrays Message-ID: <3ACD60E2.B795ADD7@dnr.qld.gov.au> I have a question about applying a local filter to an array. What would be the most efficient way of creating a new array consisting of a function of a pixels neighbourhood. Eg, take a 3x3 neighbourhood, and say the sum of the pixels in the neighbourhod. eg 1 1 1 2 x 1 the x is replaced by 8. This would be repeated for every element of the array. 1 0 1 What to do on the boundaries is less of a numerical problem than a philosophical one. I can work that out later. I am sure this is a frequently used type of function, so I would welcome any suggestions. Robert Denham Department of Natural Resources Queensland Australia From greg at cosc.canterbury.ac.nz Tue Apr 3 01:25:34 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 03 Apr 2001 17:25:34 +1200 Subject: CGI script to count downloads Message-ID: <3AC95ECE.B8F5E93E@cosc.canterbury.ac.nz> I'm trying to write a script that will keep a count of the number of times a file is downloaded. So far, the script just takes the name of the required file, opens the file, and passes on its contents. It works fine, except for one annoying thing: When Netscape pops up the box requesting a file name for saving, the default filename seems to be constructed in a screwy way from parts of the URL. For instance, if the URL used to retrieve the file is download.py?file=download/akaroa2.6.1doc.tar.gz then the default filename that Netscape gives me is akaroa2.6.1doc.tar.py So, my question is, can I put anything in the headers of the response to give the browser a hint as to what name the file should be saved under? Or is there a better way of going about this whole counting business? This is the script I'm using: #!/usr/local/cosc/bin/python print "Content-Type: compressed/gzip" print import cgi, sys form = cgi.FieldStorage() path = form["file"].value f = open(path) sys.stdout.write(f.read()) f.close() -- 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 wolfson at uchicago.edu Sat Apr 21 17:27:35 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Sat, 21 Apr 2001 16:27:35 -0500 Subject: How best to write this if-else? References: <9bsrpj$3gj@news.Informatik.Uni-Oldenburg.DE> Message-ID: In article , "Roy Smith" wrote: > What if I want to execute different code depending on which expression I > matched? Something along the lines of (pseudocode): > > if (m = e1.match(line)): > text1 = m.group(1) > do_complicated_processing (text1) > elif (m = e2.match(line)): > text1 = m.group(1) > text2 = m.group(2) > print text1, text2 > elif (m = e3.match(line)): > return You could do def meaningful_name_1(matchobject): do_complicated_processing(matchobject.group(1)) def meaningful_name_2(matchobject): ...etc re_dispatch = {re.compile(blah):meaningful_name_1, re.compile(durh):meaningful_name_2 ..etc } for re, func in re_dispatch.items(): m = re.match(line) if m: func(m) break else: no match found -- Barnabas T. Rumjuggler Thou hast been called, O Sleep! The friend of woe, But 'tis the happy who have called thee so. -- Robert Southey From stephen_purcell at yahoo.com Tue Apr 17 07:01:35 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 17 Apr 2001 13:01:35 +0200 Subject: How to search for and display files in a bunchof subdirectory?? In-Reply-To: ; from e_tsang@trillium.com on Mon, Apr 16, 2001 at 04:19:12PM -0700 References: Message-ID: <20010417130135.A7395@freedom.puma-ag.com> Tsang, Edward1 wrote: > Let say I invoke the script in directory d, but I have abunch of > subdirectories under d. > > tpTcCTFTEST10/ tpTcCTFTESTTIGHT02/ tpTcTNLC14_2/ > tpTcTNLC6_5/ > > and each subdirectory contains a file tp_acc.1. I want to do some processing > to this file, but asking the user to click each folder and input the file > name is just too much work for them, how can I just display the files in the > subdirectories. Use the 'glob' module, which simulates '*' and '?' expansion of filenames: import glob filenames = glob.glob('tpTc*/tp_acc.1') 'filenames' will now contain a list of the files in the subdirectories. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From kamikaze at kuoi.asui.uidaho.edu Fri Apr 20 17:22:32 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 20 Apr 2001 21:22:32 GMT Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha References: <9blulk$dtj$1@panix6.panix.com> <9boeru$ej9$1@news.udel.edu> Message-ID: Fri, 20 Apr 2001 20:45:46 +0200 in , Kalle Svensson spake: >Sez Mark 'Kamikaze' Hughes [regarding the GPL]: >I think you've got the "virus" thing all wrong. It doesn't force you to use >the GPL for your programs unless they are derivative works of a program >licensed under the GPL. Or unless someone else makes changes to your code to integrate even a teensy little bit of GPL-infected code, and then your code is diseased, too. >I think you underestimate the contributions of RMS. He didn't just write >emacs, you know... Really? What's he done, then? He did some part of GCC, but that was a long time and a lot of programmers ago. >> What has he done for us (instead of to us) *lately*? Nothing. He's a >> waste of meat. >What have *you* done for us (lately or ever)? My guess is that you're a >waste of meat too, by that reasoning. You could have spent a few seconds doing research, but no; -100 points for you. During the week, I write Java and XML-based networking software for $A_BIG_CO. On the weekends, I write games, currently in Python, which is what brought us here, as you'd know if you'd been reading the thread instead of just trolling on your religion's keywords. And that's just the current activity. You have picked exactly the wrong kind of person to ask that question of: I *work* for a living. As long as something moves and produces, they're still alive. When someone stops, like St*llm*n, they're a corpse, an unperson. >May I ask what makes you able to judge the quality of the works of RMS, >Linus, Guido and ESR, especially considering that they write very different >kinds of software. emacs is not linux is not python is not fetchmail. What makes me able to judge? I'm a thinking, reasoning, observant human being. Anyone who isn't able to judge is lacking one or more of those traits. And for those specific programs, I'm a programmer who's used some or all of their stuff at various times. Eric's little tools and joke languages are nice but hardly earth-shattering, and his work on the Jargon File has been a mixed blessing. Python's a really keen language. The Linux kernel is okay, but HP-UX and *BSD are better (maybe Slowlaris, but maybe not); I only use it because the installed base and driver support make up for it. And the only reason Emacs isn't all of those others is that it hasn't got 'round to absorbing them like the Blob. Of course, I understand (especially given your site) that you have to react this way, since I've slandered your messiah. Get over it. Anyway, this is enough commentary from me on the subject, I'll say no more on it here. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From sja at image.dk Sun Apr 29 05:31:55 2001 From: sja at image.dk (=?iso-8859-1?Q?Snebj=F8rn?= Andersen) Date: Sun, 29 Apr 2001 11:31:55 +0200 Subject: Call graph tool? Message-ID: <3AEBDF8A.FC6CD57C@image.dk> Is anyone aware of a tool for automatically generating call graphs from python code? /Snebj?rn From grante at visi.com Thu Apr 12 12:01:33 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 12 Apr 2001 16:01:33 GMT Subject: how to calculate the size of sys.stdin? References: Message-ID: In article , Michael Hudson wrote: >grante at visi.com (Grant Edwards) writes: > >> In article , Robin Thomas wrote: >> >> >sys.stdin is more like a pipe, and not a regular file. You >> >can't ask a pipe how many bytes it contains before you read >> >from it. >> >> Actually, you can. >> >> At least on some Unix systems, the FIONREAD ioctl() call will >> tell you how many bytes there are in a pipe waiting to be read. >> IIRC, it also works on some tty devices as well. Probably not >> very portable, and somebody could have shoved more bytes into >> the other end after the ioctl() and before the read(), so you >> could get more that you expect, but you shouldn't get less. > >That's interesting for a pet project of mine. How on earth does one >go about learning things like that? I learned it by reading Usenet and looking at device driver source code. >Is this sort of stuff in Stevens' APUE? Might be. I don't have a copy at hand. -- Grant Edwards grante Yow! He is the at MELBA-BEING... the ANGEL visi.com CAKE... XEROX him... XEROX him -- From ullrich at math.okstate.edu Fri Apr 20 12:00:26 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 20 Apr 2001 16:00:26 GMT Subject: With or Using References: <81c5876c4a%tim@worthy.demon.co.uk> <3ADC5AE1.53C3C4FE@alcyone.com> <2b95c26c4a%tim@worthy.demon.co.uk> <3addbc5a.680231093@news.okstate.edu> Message-ID: <3ae05916.851452721@news.okstate.edu> On Fri, 20 Apr 2001 01:44:04 GMT, "Gary Walker" wrote: >I don't necessarily think I'm one of the five experts, but I have used >Delphi since 1.0. > >The with keyword never, ever struck me one which was designed to save >keystrokes. Rather, it seemed to add clarity and succinctness to the code. >I'm a team leader of a 6 person software development effort. If members of >my team asked me my preference, I'd say use it. I've seen many people say that "with" is a bad thing in Delphi. Their point is that it makes it _harder_ to understand the code. The problem being that we're dealing with these huge components with many properties; together with the fact that AMethod is the same as Self.AMethod (inside an object method) it can cause confusion. Like procedure TForm1.Something; begin with Button1 do begin Canvas.Whatever; end; end; People write that and think that it's going to draw Whatever on the button's Canvas, which it would if the button had a Canvas. Instead it draws something on the form's Canvas. If you say Button1.Canvas.Whatever instead the compiler knows what you meant and gives you an error. That's the argument. I used to think it was silly - you just have to know what has what methods and there's no problem. I don't think it's so silly as I used to. >Consider this: > >Recipe for Lemonade > >Add 8 cups water to a large pitcher >Add 1/2 cup lemon juice to a large pitcher >Add 2 cups sugar to a large pitcher >Stir the ingredients that are in the large pitcher > >Now consider: > >To a large pitcher add: > 8 cups water > 1/2 cup lemon juice > 2 cups sugar > and stir. > >Did the second one confuse you? Did you forget the large pitcher?? Of course >not. It's much easier to understand. So it is with with. Well actually the two snippets are not equivalent, but never mind that. No, it didn't confuse me. But this has no bearing on the objection to "with" in Delphi because it's such a simple situation (and also the problem that inside a "with" inside an object method an unqualified reference can refer either to the thing we're using with with or to Self doesn't arise here.) >I believe Python allows a similar idea with the FROM keyword. If you specify >the object that you're importing from a specific module, aren't you allowed >to reference it without qualifying the module? > >As in: > >from SimpleHTTPServer import SimpleHTTPRequestHandler > >Doesn't this allow you to now reference SimpleHTTPRequestHandler without >specifying SimpleHTTPServer?? Or am I missing something...?? The difference is this: Suppose that SimpleHTTPServer does not _contain_ a SimpleHTTPRequestHandler class. Probably you'd agree that the import statement should then give a compiler error, right? Or do you feel that if SimpleHTTPServer does not contain a SimpleHTTPRequestHandler class but there is already such a class in the enclosing scope then the import statement should "succeed"? >>It's in Delphi all right. Now find five Delphi experts and ask them >>whether they think it's a good idea. >> >>>> It saves a small amount of typing (and not very much) at the expense of >>>> a lack of clarity and the addition of ambiguity. >>> >>>I thought with Python's block indenting it would be pretty clear what >>>was being referred to. >>> > > > From dsh8290 at rit.edu Sat Apr 21 15:38:04 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 21 Apr 2001 15:38:04 -0400 Subject: why python annoys me In-Reply-To: <3AE1D1DE.BF3CEA18@Lugoj.Com>; from JamesL@Lugoj.Com on Sat, Apr 21, 2001 at 11:30:54AM -0700 References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> <3ADF54F1.6000409@hccnet.nl> <3AE0F802.3983C9DB@01019freenet.de> <9brd4f0p7u@news1.newsguy.com> <3AE1D1DE.BF3CEA18@Lugoj.Com> Message-ID: <20010421153804.A6377@harmony.cs.rit.edu> On Sat, Apr 21, 2001 at 11:30:54AM -0700, James Logajan wrote: | Alex Martelli wrote: | > [...] since Python does have list comprehensions, [...] | | Not being a computer scientist, I hope you can excuse a profoundly ignorant | question, but what are (or is?) "list comprehensions"? And another question They are described in the Ref Man (on python.org). Someone gave a pretty good explanation on this list, or on tutor at python.org. Search the archives if you want to find it. Basically it is a syntacical sugar for creating a list whose elements have a certain property and originally were in an existing list. | (probably harder to answer): is there someplace on the web or in print where | I can find a good definition of "functional programming"? I'm pretty sure it | doesn't mean classical procedural notation, more like mathematical or | logical notation, but I can't be sure. It is rather similar to the notation used in defining functions in my Discrete Math 2 course. I would say that Lisp and Scheme are the most widely known Functional Programming languages. I think that the ML family and maybe Haskell have something of FP in them, but I don't really know much about those languages (just what I hear on this group). HTH, -D From aahz at panix.com Sun Apr 15 18:31:46 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Apr 2001 15:31:46 -0700 Subject: Python Performance vs. C++ in a Complex System References: <3ADA06B9.A2292921@downright.com> Message-ID: <9bd7gi$cq1$1@panix3.panix.com> In article , Elliott Chapin wrote: > >So how does Python do context switching, [anybody]? It depends on whether you use native Python threads or microthreads built on top of Stackless Python. Python threads are built on top of OS-level threads, so the OS handles the context switch. Microthreads are built on top of continuations in Stackless, and an essentially cooperative multi-tasker handles the context switches. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From paIulHATE_nicSPAMolay at merck.com Wed Apr 4 03:46:44 2001 From: paIulHATE_nicSPAMolay at merck.com (Paul Nicolay) Date: Wed, 4 Apr 2001 09:46:44 +0200 Subject: Python on the AS/400? References: <9ac4de$24k$1@merck.com> <_ipy6.24131$BC6.6683774@e3500-chi1.usenetserver.com> <3ACA341B.539F70E@us.ibm.com> Message-ID: <9aejha$q3a$1@merck.com> Hi, It seems I'm missing some postings... Regarding Kragens question, AS/400 is no different than UNIX in this matter... we also have a select() function. I prototyped the function in ILE-RPG and it works fine as it should be. Kind regards, Paul ------------------------ Karl Hanson wrote in message <3ACA341B.539F70E at us.ibm.com>... Kragen Sitaker wrote: > > In article <9ac4de$24k$1 at merck.com>, > Paul Nicolay wrote: > >I'll try to answer your questions... > > > >1. The AS/400 is indeed a reasonable platform (and scales way beyond what > >others offer) to have network servers running, the question is however is > >Python the best environment to write them in (which I doubt seriously) ? > > I suppose it depends on the particular network server. (Unless you > mean "Python on the AS/400", in which case I share your serious > doubts.) > > So how do you do event-driven I/O on OS/400? > > Unix assigns a small process-local integer to each I/O stream called a > "file descriptor"; there's a system call called 'select' to which you > pass three bitvectors: one with bits set at indices of file descriptors > you want to be notified of readability on, one with bits set at indices > of file descriptors you want to be notified of writability on, and wone > with bits set at indices of file descriptors you want to be notified of > "exceptional conditions" on. You also pass a timeout. When the > timeout expires, or when one or more of the events you've requested > notification of happens, select() returns, having cleared all the bits > in these bitvectors that correspond to events that didn't happen --- > leaving only the bits set that correspond to events that did happen. > This may not be related, but there is a select() Sockets API.. for details go here: http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/index.htm?info/api s/aplist.htm Select UNIX-Type, then Sockets APIs. -- Karl Hanson The contents of this message express only the sender's opinion. This message does not necessarily reflect the policy or views of my employer, Merck & Co., Inc. All responsibility for the statements made in this Usenet posting resides solely and completely with the sender. From StanleyKrute at starband.net Sun Apr 29 20:39:24 2001 From: StanleyKrute at starband.net (Stanley Krute) Date: Mon, 30 Apr 2001 00:39:24 GMT Subject: newbie seeks inaccurate arithmetic insight Message-ID: <0v2H6.791$KM6.666348554@twister2.starband.net> Hi I just started on the Python learning path. I tried some calculator stuff, and got this sort of result: http://static.userland.com/images/stanleydaily/pythonarithmetic.gif I searched the Tutorial at http://www.python.org/doc/current/tut/tut.html and the Reference manual at http://www.python.org/doc/current/ref/ref.html for some discussion of why simple decimal arithmetic gives these sorts of inaccurate results. But I couldn't find anything. Can someone provide one or more URLs that discuss the topic ?? Thanks Stan From erenouf at opticominc.com Sat Apr 7 23:28:22 2001 From: erenouf at opticominc.com (Eric Renouf) Date: Sun, 08 Apr 2001 03:28:22 GMT Subject: Lists and Files References: <99njdo$oa3$1@news.lth.se> Message-ID: <3ACFDA73.AE956F03@opticominc.com> Try using repr instead of string, then evalling the string when you read it back in instead of trying to cast it to a list. fds.write(repr(stooges)) ... no_longer_stooges = eval(fds.read()) David Andreas Alderud wrote: I'm new to Python, started yesterday, is there a good way to handle lists > and files? > > For example: > > stooges = ['val1', 'val2', 1, [['val2_1', 'val2_2', 0], ['val2_1', > 'val2_2', 0]]] > fds = open("stooges", "w") > # fds.write(stooges) doesn't work, maybe I can encapsulate and pack it > to some other format, other than str that is, one that works? > fds.write(str(stooges)) > fds.close() > fds = open("stooges", "r") > no_longer_stooges = list(fds.read()) > print no_longer_stooges > => > ['[', "'", 'v', 'a', 'l', '1', "'", ',', ' ', "'", 'v', 'a', > 'l', '2', "'", ',', ' ', '1', ',', ' ', '[', '[', "'", 'v', 'a', 'l', '2', > '_', '1', "'", ',', ' ', "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', > '0', ']', ',', ' ', '[', "'", 'v', 'a', 'l', '2', '_', '1', "'", ',', ' ', > "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', '0', ']', ']', ']'] > > and that's not what I want, I could write a parser for the dynamic data but > I rather not if there is a good way to handle it. > Someone _must_ have stumbled across this problem before me, as it seams like > a common thing to do, and solved it, so I rather not duplicate the effort, > any hits and pointers or full solutions? > > /Kind regards, > David A. Alderud -- Eric Renouf Software Engineer Opticom Inc. www.getiview.com From balexander at rsv.ricoh.com Sun Apr 29 17:58:58 2001 From: balexander at rsv.ricoh.com (Bob Alexander) Date: Sun, 29 Apr 2001 14:58:58 -0700 Subject: Signals and readline() References: Message-ID: <3AEC8EA2.F06EA734@rsv.ricoh.com> I am observing that when a Python program (Unix) receives a signal while waiting for a response from readline() from a pipe, an empty string is returned even though the pipe is still open thus should not indicate EOF. After receiving the empty string, normal IO continues. What I would expect to happen in this case is to get a IOError exception with errno=EINTR, but I get no exception. The current behavior is bad because there is no way to distinguish between the incorrect empty line and a real end of file. This looks like a bug to me, but I thought I'd post to the list before submitting a bug report as a sanity check. I can provide more details and a little test program to reproduce the problem. Bob From marshall44 at home.com Sun Apr 15 04:37:53 2001 From: marshall44 at home.com (marshall) Date: Sun, 15 Apr 2001 04:37:53 -0400 Subject: embedding Tkinter in a C application via python Message-ID: <3AD95DE1.7A37066D@home.com> Trying to embed python/Tkinter app with C backend. All I get is attribute errors when running the embedded python app from C. Either the error is basename from th Tkinter module or new instance of Tkinter in module. Here is the python module from Tkinter import * from ARLclasses import GuiMixin from MLNcommon import Display from mlnclient import MLNDisplay from Dialog import Dialog from ScrolledText import ScrolledText from normalDate import ND from commands import * from socket import * from ftplib import FTP import os import sys,random import regex import string import struct import select import time, glob import Pmw class DOMI(GuiMixin,MLNDisplay,Display): def __init__(self, master=None): #Frame.__init__(self, master) #self.pack(self) #self.Init_Display(0000,3,3) self.Init_GUI = "Display" print self.Init_GUI def Init_Display(self,tod,num_ci,num_mlns): from Tkinter import * from ARLclasses import GuiMixin from MLNcommon import Display from mlnclient import MLNDisplay self.ClientGui() print "Starting GUI" def start_sim(self): for self.trk_x,self.trk_y,self.trk_z,self.hdg in [(23,340,400,2),(45,400,5000,3),(30,450,20000,3),(78,500,10000,3),(88,476,600,2),(564,34,30000,7),(453,56,14532,5),(400,76,23489,1),(356,89,15439,2)]: self.target_icon(self.ppi_display,self.trk_x,self.trk_y,self.trk_x,self.trk_y,4) self.link_sim() print "simulated tracks from sim" def ownship_loc(self,tod,x,y,Xdot,Ydot): self.timeofday = tod self.osX = x self.osY = y print self.timeofday self.os_loc(self.ppi_display,self.osX,self.osY,Xdot,Ydot) def ppi_plot_track(self,trk_id,Xpos,Ypos,Xdot,Ydot): self.trkx = Xpos self.trky = Ypos plot = self.target_icon(self.ppi_display,self.trkx,self.trky,Xdot,Ydot,trk_id) class TEST: def __init__(self, display=None): self.function = "Odell" self.printer() def printer(self): print 'Odells ass' if __name__ == '__main__': DOMI().mainloop() Odell -------------- next part -------------- A non-text attachment was scrubbed... Name: marshall44.vcf Type: text/x-vcard Size: 220 bytes Desc: Card for marshall URL: From BPettersen at NAREX.com Thu Apr 26 16:47:39 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 26 Apr 2001 14:47:39 -0600 Subject: Standalone EXE (Newbie question) Message-ID: yes. helpful'ly y'rs -b -----Original Message----- From: DJ [mailto:no at spam.com] Sent: Thursday, April 26, 2001 2:21 PM To: python-list at python.org Subject: Standalone EXE (Newbie question) Hey there, Just looking into Python. My big question is this: can an app that I create with Python be compiled into a standalone EXE that does not require that a Setup be run in order for the program run. (OS: Win9x/Win2K) Thank you. -- http://mail.python.org/mailman/listinfo/python-list From dalke at acm.org Tue Apr 17 19:22:23 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 17 Apr 2001 17:22:23 -0600 Subject: do...until wisdom needed... References: <3ADC4FEA.2664FDF7@noaa.gov> Message-ID: <9bik6r$e9v$1@slb1.atl.mindspring.net> Benjamin.Altman wrote: > Someone in this thread mentioned that they needed to go back > to k&h to recall it and I can't quite understand why (even though > you might say that recollection and simplicity are mutually > exclusive). That was me. I use that construct in C so infrequently that it merges with my memories of the same construct in other languages so I forget if it's do { .. } while(); do { .. } until(); repeat { .. } while(); or repeat { .. } until(); The name of this thread shows the problem. Why is it named "do...until" instead of "do...while" ? Andrew dalke at acm.org From timr at probo.com Mon Apr 9 01:15:45 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 08 Apr 2001 22:15:45 -0700 Subject: problem executing python scripts in cygwin bash shell References: <69AD80E50414598C.875157435733CF34.B50964BA627F4825@lp.airnews.net> Message-ID: "Tom Satter" wrote: > >I like to use the following for my python scripts since >this works on Cygwin, MKS, Linux, and Solaris... I think you used the wrong verb here. I could believe "I am forced to use..." or "I have resigned myself to using...", but certainly not "I *LIKE* to use..."! >#!/bin/sh >"""true" -*- python -*- >exec python -tt `echo $0 | sed -e 's@\\\\@/@g' -e >'s@^/cygdrive/\([a-zA-Z]\)/@\1:/@' -e 's@^//\([a-zA-Z]\)/@\1:/@'` ${1+"$@"} > >Script Comment goes here... > >""" >Put the script here... -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nessus at mit.edu Mon Apr 2 20:44:06 2001 From: nessus at mit.edu (Douglas Alan) Date: 02 Apr 2001 20:44:06 -0400 Subject: "Fastest growing programming language" References: Message-ID: "Tim Peters" writes: > [Douglas Alan] > > What's the source for Python being the "fastest growing programming > > language"? Just curious. > Who said it? I'd ask them. I don't know who said it. The quote is from a press release regarding the creation of the Python Software Foundation that is prominently posted on www.python.org. I suppose we could ask Lori Pike whose name appears at the bottom of the press release as a "Media & Analysts Contact" at ActiveState. |>oug From fredrik at pythonware.com Wed Apr 4 17:22:25 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 04 Apr 2001 21:22:25 GMT Subject: A couple garbage collector questions References: Message-ID: Douglas Alan wrote: > Another question: Why didn't Python just include Bohm's conservative > GC package to implement Python's cycle detection? it's one of those annoying theory vs. practice things. lots of people have played with that. nobody has been able to make Python+Boehm run faster than reference counting plus Neil's approach. that doesn't mean that it's impossible, though -- but it probably needs far more work than "just including" it. see: http://groups.yahoo.com/group/python-list/message/122067 and even if this is solved, the Boehm GC isn't very portable, compared to the rest of the code base... Cheers /F From nomail at nomail.com Wed Apr 11 14:25:08 2001 From: nomail at nomail.com (Dry Ice) Date: Wed, 11 Apr 2001 11:25:08 -0700 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> <9b0pqq$1kt$1@news1.xs4all.nl> Message-ID: <3ad49fc4_3@news4.newsfeeds.com> > > . . . > > What "substantial" is might be defined in terms > > of project length. Perhaps something which would > > take a good programmer several months. > > In that case, there are no substantial python applications. > Everbody knows that any conceivable project can be > implemented in python in a week or less. Get real. (Or did you forget the smiley face?) The programming language and its relative convenience is only a portion of the picture. Any program of substance, i.e., NOT a no-brainer, has a great deal of logic and structure which is EXPRESSED in the language environment. Perhaps one can write a useful and good app in a week in Python, but not "any conceivable project" unless one's powers of conception are severely limited. > > Here's a better definition: A substantial application is > a project that, if implemented in C++, java, or perl, > would be 75% finished in 24 programmer-months or > more. > > ---------------------------------------------------- > Copyright (c) 2001 by Ken Seehof > This document may not be distributed, copied, > duplicated, or replicated in any form without > express permission by Ken Seehof. > Permission is hereby granted. > kseehof at neuralintegrator.com > ---------------------------------------------------- > > > From tim.one at home.com Tue Apr 10 22:22:32 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 10 Apr 2001 22:22:32 -0400 Subject: Chocolate [was Re: Python Books for 2002] In-Reply-To: Message-ID: [Konrad Hinsen] > Come to France - chocolatewise this is a highly civilized country. [Alex Martelli] > And not _only_ chocolatewise -- in bread AND wine AND cheese, as well > as in high-quality chocolate, I consider you guys the only ones on a > par with Italy... [Ben Wolfson] > What? Everyone knows that India is on par with your rather > Eurocentric, if I may say so, selections, at least in bread. On the chance that these selections aren't so much Eurocentric as Anglophobic, I'd like to remind everyone that America Leads the World in both Twinkies and Coke. Although I have to admit that Mexican Coke is better. But *nobody* beats my homeland's Twinkies! who-needs-lindt-when-you've-got-hostess-ly y'rs - tim From brian at brian.cbs.umn.edu Thu Apr 12 16:12:17 2001 From: brian at brian.cbs.umn.edu (Brian Langenberger) Date: Thu, 12 Apr 2001 20:12:17 +0000 (UTC) Subject: Escaping strings to be used in shell commands? References: <9b4g2j$2tm$1@laurel.tc.umn.edu> <9b4psl$3uh$1@laurel.tc.umn.edu> Message-ID: <9b5271$5hf$1@laurel.tc.umn.edu> Timothy Grant wrote: : However, I am curious why there is more a problem with an app : calling the useradd command, than there is with an admin : issuing a useradd from the command line? As long as python isn't running setuid root, or as long as the script is suitable chmod'ed for admins only, os.system() isn't much of a big deal (aside from unintended consequences). But whenever such scripts make it out for user-level use, os.system() gives me the creeps because of all the nastiness that can result. I just don't trust it for much of anything :) From jcc.ugm at ix.netcom.com Fri Apr 6 20:13:16 2001 From: jcc.ugm at ix.netcom.com (Jonathan Claggett) Date: Fri, 6 Apr 2001 20:13:16 -0400 Subject: Changing global variables in tkinter/pmw callback In-Reply-To: <004f01c0becc$dad3e6e0$0300a8c0@arthur> Message-ID: Alex wrote: "...but the resulting confusion between items and attributes seems a strange target to aim for." I ought to just admit now to being overly excited by all of python's nifty extensibility. It IS nifty, so you can hardly expect Instead, I'll rashly claim that blurring the line between attributes and hashes is sometimes useful when dealing with a structure whose attributes you wish to access programmatically. One example might be a doubly linked list where most of the code accesses the attributes directly but a generic traverse function uses a parameter to access the attributes. My (trivial) example: # normal usage (using Bunch as a structure) head = Bunch(value="cat", left=None, right=None) tail = Bunch(value="dog", left=None, right=None) head.right = tail tail.left = head # generic usage (using Bunch as a hash) def traverse(node, next): while node: print node.value node = node[next] traverse(head, "right") traverse(tail, "left") From sholden at holdenweb.com Sun Apr 8 00:09:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 8 Apr 2001 00:09:32 -0400 Subject: Lists and Files References: <99njdo$oa3$1@news.lth.se> <3ACFDA73.AE956F03@opticominc.com> Message-ID: "Eric Renouf" wrote in message news:3ACFDA73.AE956F03 at opticominc.com... > Try using repr instead of string, then evalling the string when you read it > back in instead of trying to cast it to a list. > > fds.write(repr(stooges)) > ... > no_longer_stooges = eval(fds.read()) > > David Andreas Alderud wrote: > I'm new to Python, started yesterday, is there a good way to handle lists > > > and files? > > > > For example: > > > > stooges = ['val1', 'val2', 1, [['val2_1', 'val2_2', 0], ['val2_1', > > 'val2_2', 0]]] > > fds = open("stooges", "w") > > # fds.write(stooges) doesn't work, maybe I can encapsulate and pack it > > to some other format, other than str that is, one that works? > > fds.write(str(stooges)) > > fds.close() > > fds = open("stooges", "r") > > no_longer_stooges = list(fds.read()) > > print no_longer_stooges > > => > > ['[', "'", 'v', 'a', 'l', '1', "'", ',', ' ', "'", 'v', 'a', > > 'l', '2', "'", ',', ' ', '1', ',', ' ', '[', '[', "'", 'v', 'a', 'l', '2', > > '_', '1', "'", ',', ' ', "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', > > '0', ']', ',', ' ', '[', "'", 'v', 'a', 'l', '2', '_', '1', "'", ',', ' ', > > "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', '0', ']', ']', ']'] > > > > and that's not what I want, I could write a parser for the dynamic data but > > I rather not if there is a good way to handle it. > > Someone _must_ have stumbled across this problem before me, as it seams like > > a common thing to do, and solved it, so I rather not duplicate the effort, > > any hits and pointers or full solutions? > > > > /Kind regards, > > David A. Alderud > David: I think you would find the "marshall" and "pickle" module documentation enlightening. Both of these will handle reading and writing Python objects from/to files. Examine the different limitations and choose the appropriate poison. regards Steve From kno at jtan.com Mon Apr 16 12:26:35 2001 From: kno at jtan.com (Matt Dunford) Date: Mon, 16 Apr 2001 16:26:35 GMT Subject: ANNOUNCE: saxogram - a vocabulary list generator Message-ID: I thought I'd announce this just in case anyone out there is interested. I've written a little python script called saxogram which generates vocabulary lists for foreign languages. I find that it helps me read online websites written in German. You feed it some text, the program matches words to a dictionary and spits out a list which you can use as a reference as you read. So far, it supports German, Italian, and Latin. It needs work, of course. It's a bit slow and lacks robust dictionaries. A cvs'd version can found at http://sourceforge.net/projects/saxogram/ -- From cribeiro at mail.inet.com.br Tue Apr 10 08:49:45 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Tue, 10 Apr 2001 09:49:45 -0300 Subject: Chocolate [was Re: Python Books for 2002] Message-ID: <5.0.2.1.0.20010410094940.022a38b0@mail.inet.com.br> At 11:56 10/04/01 +0200, you wrote: >During my first trip to the U.S. I experienced that eating something >called "Lindt" had absolutely nothing to do with chocolate made by >the swiss company Lindt. We're way off topic anyway, but what about coffee? As a brazilian I was surprised by the american coffee. After all, the USA buy the *very best* coffee beans from Brazil and Colombia, and use it... to make that? It's watered coffee, decaf - so it's not coffee after all :-) We're used to strong coffee here (I think we're on par with the Italians). Also the bread... I could not find good bread in any of the places where I gone (there are some good, specialty bakers in my home city, so I'm used to good bread too :-). For chocolate, the quality in Brazil varies widely, from the "chocolate-flavored" drinks to the very best (made traditionally by families that came from Europe at the turn of the 20th century). p.s. If you come to Brazil, go to a *real* coffee shop, please. There are also *lots* of places with terrible coffee around, specially at Rio de Janeiro . Carlos Ribeiro From kevinmrodgers at home.com Tue Apr 24 20:16:26 2001 From: kevinmrodgers at home.com (Kevin Rodgers) Date: Wed, 25 Apr 2001 00:16:26 GMT Subject: BLT installation woes under W98 (Python 2.1) References: Message-ID: "Peter Brown" wrote in message news:wkzod7gx1v.fsf at acm.org... > seen people ask about BLT, anyway). Is there a known way to install > BLT into the Tcl directory structure under C:\Python21? Should I be > compiling BLT and/or Tcl from scratch? If so, how would I tell Python > to use the Tcl I just made, not the Tcl it came with? Here's how I did it: * Install Python * Install Tcl/Tk 8.3.whatever using installer from Scriptics (or wherever it is now) * Install BLT 2.4u from its installer * Copy the "blt2.4" directory from the Tcl/Tk install to the python21\tcl directory; I copied the BLT .lib files too (although I don't know if they're needed) * Put the BLT DLLs in a system directory (windows\system, say); I've never had any luck with putting the DLLs in the Python DLL directory That (or something like it) should work; unfortunately, I'm not at the machine I did this on, so I may be a little off on some of the steps. good luck! From danielk at aracnet.com Thu Apr 12 11:06:52 2001 From: danielk at aracnet.com (Daniel Klein) Date: Thu, 12 Apr 2001 08:06:52 -0700 Subject: Python Programming Ettiquette References: Message-ID: On Thu, 12 Apr 2001 15:45:00 +1000, zzzzz wrote: >Is there any accepted programming etiquette on how to best go about this? I think the Object Police would be paying you a visit if you used approach a). Daniel Klein From cribeiro at mail.inet.com.br Tue Apr 10 20:47:20 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Tue, 10 Apr 2001 21:47:20 -0300 Subject: IDispatch objects, problems with ActivePython In-Reply-To: Message-ID: <5.0.2.1.0.20010410214449.02162920@mail.inet.com.br> At 21:01 10/04/01 +0000, Lasse V?gs?ther Karlsen wrote: >The Delphi component will be made freely available on the web as soon >as I have ironed out all the bugs (like this one) so please help me >help other Delphi programmers start using Python. Have you seen the Python for Delphi project? Maybe they something useful for you. Check it at http://www.multimania.com/marat/delphi/python.htm. They have some components to encapsulate Python inside Delphi apps. I began evaluating it yesterday, so it's too soon for me to tell you exactly how good it is. Carlos Ribeiro From ocschwar at mit.edu Tue Apr 17 16:39:11 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 17 Apr 2001 16:39:11 -0400 Subject: Perl & Python: Parrot References: <3adbc4e7$1_2@excalibur.gbmtech.net> <3adc48d5$0$36584$e2e8da3@nntp.cts.com> Message-ID: "Robert Johnson" writes: > Newbie Question: What does Perl offer that Python cannot already do? I know It incorporates into itself many ideas that are present elsewhere in the Unix environment. For some of us, this is a major plus. For others, especially newbies, it is a minus. > where Perl is used but I am not familiar with the Perl language. I know > also that Perl has a strong user-base & plenty of support modules but it > seems to me this is more a matter of coding the equivalent modules into > Python. > > > "Eschathon" wrote in message > news:3adbc4e7$1_2 at excalibur.gbmtech.net... > > That was quite an interesting joke. However, after a lot of deliberation > I > > decided that it would be an excellent idea to unite Perl and Python. When > I > > am doing CGI or bash scripting I always use the languages in conjunction. > > Let me know what you guys think! > > > > > > -- Omri Schwarz --- Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From phd at phd.fep.ru Wed Apr 11 06:42:24 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 11 Apr 2001 14:42:24 +0400 (MSD) Subject: converting string to dict ? In-Reply-To: Message-ID: On Wed, 11 Apr 2001, Jason Cunliffe wrote: > A web input form passes {'name':'Cleopatra'} as a string. > Please, is there a nice clean function to convert this string to a dict? "eval" Please, please send me your URL - I will hack you through your call to the eval! :))) Seriously, do not trust ANYTHING from the web. Do not convert things into objects, do not eval them - NEVER! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From christian at rocketnetwork.com Tue Apr 10 15:35:39 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Tue, 10 Apr 2001 12:35:39 -0700 Subject: using os module to copy files on windows Message-ID: <9avnkk$23$1@bob.news.rcn.net> Hello, I've been using the os.system() call to copy files using the dos cmd line in my python scripts. for instance. os.system('xcopy d:\\folder\\* d:\\folder2\\') this does the job fine, but i'd like to eradicate all dependencies on the cmd line from my scripts. Is there a python os method that is equivalent to this? any help would be much appreciated, thank you, christian From neotaku at free.fr Tue Apr 24 03:32:51 2001 From: neotaku at free.fr (Neotaku) Date: Tue, 24 Apr 2001 07:32:51 GMT Subject: Type Object of wxPython Control References: Message-ID: Do you know if in wxPython Objects there is a free property like the Tag property in visual basic where you can put anything you want ? "Robin Dunn" a ?crit dans le message news: oG_E6.2$GdX.2818226 at news.randori.com... > > > > but the "print type(object)" give type-instance and i want it to tell > me > > it is "wxStaticBox" or "wxWindows" or "wxButton"...how can i do that ? > > Normally you would do object.__class__.__name__ but currently in wxPython > that will give you "wxWindow" because of the way SWIG is wrapping a new > shadow object around the C++ pointer. I expect to have either a workaround > or an actuall fix in place for the first or second 2.3.x release. > > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com Java give you jitters? > http://wxPython.org Relax with wxPython! > > > > From aahz at panix.com Thu Apr 12 14:42:17 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Apr 2001 11:42:17 -0700 Subject: PEP 245 References: <3ACDB3A1.9B4E3B5A@projtech.com> Message-ID: <9b4su9$sm8$1@panix3.panix.com> In article <3ACDB3A1.9B4E3B5A at projtech.com>, Scott Finnie wrote: > >Hmmm. A question about PEP245: how do interfaces differ from types? > >Both seem to have the same motivation: to declare not what something is, >but what it can do: > > . "An object's type ... determines the operations that an object > supports (e.g., ``does it have a length?)" > - Python Language reference section 3.1 > . "Interfaces try to provide a way for you to ... specify a contractual > obligation for your object" > (PEP245, "The Problem" section). > >There are currently limitations on typing (only covers built-ins, object >can only be of a single type) but neither of these seem justifiable >reasons for introducing a new construct rather than extending the >existing one? What you're talking about here is the type/class split. There have been a lot of suggestions for healing that, but they all require a *lot* of work (plus probably breaking a lot of code). Interfaces are in a lot of ways a gimmick for creating type-like functionality for classes. There are some differences, though: Python currently does not have a mechanism for specifying the interface for a type. It seems rather likely that creating an interface mechanism for classes and then extending it to types will be the easier and simpler route. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Why is this newsgroup different from all other newsgroups? From mal at lemburg.com Thu Apr 19 16:25:50 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 19 Apr 2001 22:25:50 +0200 Subject: [Python-Dev] ANN: Experimental Number Types (Integer, Rational, Floats) References: <3ADF36C9.1D9AA305@lemburg.com> Message-ID: <3ADF49CE.10EF2A5D@lemburg.com> Michael Hudson wrote: > > Before I d/l and take a look... > > "M.-A. Lemburg" writes: > > > (e.g. Integer(2) + "3" works as one would expect ;-). > > So it raises an exception? Seriously, that's what *I'd* expect, and > if it's not what your package does, I beg you to reconsider. Integer(2) + "3" gives you Integer(5). This is a side-effect of how the implementation converts arbitrary objects into ones usable for coercion: Integer(2) + "3" is interpreted as Integer(2) + Integer("3") which gives Integer(2) + Integer(3). After having played with it for a while, I must say, that I kind of like it :-) -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From qrczak at knm.org.pl Fri Apr 13 12:56:32 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 13 Apr 2001 18:56:32 +0200 Subject: OT - Closing Off An Open-Source Product In-Reply-To: <20010413101756.A702-100000@open-systems.net>; from chris@voodooland.net on Fri, Apr 13, 2001 at 10:20:56AM -0500 References: <20010413101756.A702-100000@open-systems.net> Message-ID: <20010413185632.A22399@qrnik.zagroda> On Fri, Apr 13, 2001 at 10:20:56AM -0500, Chris Watson wrote: > The license perhaps. The *code* is TOTALLY free. A code is always tainted with its license. It's impossible to say what one can do with a code without considering its license. A BSDL licensed code is not totally free: it cannot be linked with GPL code. > Its sort of a way of enofrcing the BSDL. "You can do anything with > this code, period, and no one can change the license on this code > removing those rights. Similarly as GPL is enforcing that the code will be free. The difference is that GPL is talking about the source, and you are talking about either source or binary. > So basically your back to BSDL vs GPL which is truly free? The BSDL doesnt > put restrictions on code use, the GPL does. GPL puts restrictions: it forbids putting restriction about availability of the source. BSDL also puts restrictions: it forbids putting restrictions which would forbid putting restrictions about availability of the source. Disallowing putting a restriction is always a restriction itself! In some sense BSDL gives more freedom: it forbids putting a restriction. In the same sense GPL gives more freedom: it forbids putting a restriction. In another sense BSDL takes away freedom: it introduces a restriction (which forbids putting other restrictions). Same for GPL: it introduces a restriction (which forbids putting other restrictions). I could introduce SuperGPL which is related to BSDL as BSDL is related to GPL. It would say that you cannot put restrictions which would disallow putting restrictions which would ensure that the code remains free. It's incompatible with BSDL but compatible with GPL. Of course you could respond with SuperBSDL etc. You can't say where in this infinite sequence lives most freedom, because freedom is not monotonic. Giving more freedom means that other people are allowed to take away more freedom. OTOH ensuring that other people can't take away freedom is taking away some freedom yourself. Stating what restrictions other people can put is in a contravariant position. The more freedom you want to ensure, the more you have to restrict, and vice versa. There is no point of infinite freedom. Well, in some sense it's the beginning of the sequence: public domain code. But it doesn't disallow other people from introducing restrictions on the availability of the source, because it doesn't disallow anything - this is what "totally free" means. You can disallow that, and you have GPL. You don't like it, so you can disallow putting that restriction, and you have BSDL. I don't like that, so I can disallow putting that restriction, and we have SuperGPL. Et caetera. > This just keeps people from putting those nasty evil GPL restrictions > on BSD code. You replaced evil GPL restrictions with evil BSDL restrictions. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From nessus at mit.edu Mon Apr 2 23:44:13 2001 From: nessus at mit.edu (Douglas Alan) Date: 02 Apr 2001 23:44:13 -0400 Subject: A couple garbage collector questions References: Message-ID: Neil Schemenauer writes: > Douglas Alan wrote: > > (1) Why does it use the rather unusual algorithm it does, rather > > than a more typical mark and sweep? The per-object storage cost > > for the extra reference count is surely greater than the bit or > > two required for a typical mark and sweep. > Mark and sweep requires that you find all root pointers. That's > difficult to do if you want it to be portable and allow for easy > embedding and extension of the language. Why doesn't the procedure that a C extension (or embedder) uses to increment the reference count of a Python object just register such objects as root objects? The reference count decrementer would then unregister such objects. > > (2) Why does the algorithm need back-pointers for the object chain? > So that removing objects from the set is O(1). In explaining to you why I didn't yet understand why you need back-pointers, I figured it out. (I.e. you have to remove objects that you don't arrive at via walking down the list.) Thanks! |>oug From smarsh at hotmail.com Fri Apr 13 15:40:23 2001 From: smarsh at hotmail.com (scott) Date: Fri, 13 Apr 2001 19:40:23 GMT Subject: Pythonwin interactive window editing? Message-ID: <3AD7560F.9FFDB567@hotmail.com> Just installed Pythonwin (ActivePython build 202) on NT4. Seems very nice so far except... Previously (an hour ago) I used the history feature of IDLE 0.6 that came with BeOpen Python 2.0 to recall previous commands (Alt-p etc). Is something like this available in the Pythonwin interactive window? I uninstalled BeOpen Python 2.0 before installing Pythonwin. Thanks in advance. P.S. On a related note, I can't seem to use IDLE anymore. I tried to start c:\Python20\Tools\IDLE\idle.pyw I got an error message (unable to locate DLL tk83.dll). Sure enough, this isn't on my system. Is IDLE supposed to work using Pythonwin? The following (and the fact that IDLE is included in Activestates distribution) seems to indicate it should: http://www.activestate.com/ASPN/Downloads/ActivePython/More "New in this version: ... this distribution includes the _tkinter module which allows the use of the IDLE IDE... Can I / how can I use IDLE from the Pythonwin distribution? Again, thanks for any insights. From jimd at vega.starshine.org Sat Apr 14 04:22:21 2001 From: jimd at vega.starshine.org (Jim Dennis) Date: 14 Apr 2001 08:22:21 GMT Subject: First Python Script: Roman Numbers References: <9b6pqv$1seu$1@news.idiom.com> Message-ID: <9b91bt$13uv$1@news.idiom.com> In article <9b6pqv$1seu$1 at news.idiom.com>, Jim Dennis wrote: > Here's my first Python script. Way back when I was taking classes > at a community college and learning Pascal, I got an assignment to > convert numbers to roman numeral strings. After tangling with the > various rules for a bit, I realized that I could actually eliminate > most of the conditionals by using a more elegant list of tokens. > Since then I use the "toRoman" as a stock exercise for teaching > myself new scripting and programming languages. I've even used > version in Bourne syntax for teaching classes in shell scripting > (I've included that, too). I didn't mention it in my original post, but my fromRoman function is new. I'd never spend the time to get that working in the various other forms of this exercise that I've done. Naturally there was a bug in the first version that I posted (thus, this follow up). The problem was that strings like IXIV are not canonical Roman numbers (that would add up to 13 or XIII). It took about six lines of code to fix that (make a dictionary of illegal combinations and a list of tokens to skip. If we see CM, XC or IX we add the appropriate patterns, CD, XL or IV respectively to the skip list). For fun, I'll add a new test suite generator. It generates every string consisting of the single letter roman numeral tokens: MDCLXVI; In other words, it counts in base 7 using those as the digits. Actually I'll simply re-write and generate something I did in Pascal about 10 years ago --- a toy to count in "any" base --- which I orginally wrote to "count" in base 26 using the letters of the Roman alphabet as the "base." Maybe I'll post that tomorrow. > Here's the script, I'll let it speak for itself: >#!/usr/bin/env python ># Roman Number Converter ># by James T. Dennis (c)2001 ># This code is released and licensed under the terms of the GPL ># or, at the user's option, the BSD license as specified at the ># following URLs: ># http://www.freebsd.org/copyright/freebsd-license.html ># http://www.gnu.org/copyleft/gpl.html ># ># In any event it is provided free of charge, "as-is" and wholly ># without any warranty. Use it, mangle it, incorporate it into ># any software that will have it. > ># Convert natural numbers to their Roman numeral representations ># and vice versa. > ># First we associate a list of numeric values with ># their Roman numeral (string token) equivalents as follows: > >Rom={} >Rom["M"] = 1000 >Rom["CM"] = 900 >Rom["D"] = 500 >Rom["CD"] = 400 >Rom["C"] = 100 >Rom["XC"] = 90 >Rom["L"] = 50 >Rom["XL"] = 40 >Rom["X"] = 10 >Rom["IX"] = 9 >Rom["V"] = 5 >Rom["IV"] = 4 >Rom["I"] = 1 > >RomSeq = ( "M", "CM", "D", "CD", "C", "XC", "L", "XL", > "X", "IX", "V", "IV", "I" ) > ># In this case we create a Python dictionary (otherwise we'd ># create two arrays, one of integer values and the other of strings ># and use our own functions to search them and translate using a ># common index). We also create a sequence tuple in descending ># order. It's for interating over the value list in a convenient order. > ># We include the two letter tokens (IV, CM, CD, XC, etc) because ># it makes our main conversion loop simpler (as we'll see). ># Basically it means we can loop straight through without having ># to encode a bunch of parsing conditionals (the sequence, including ># the two letter tokens already incorporates most the the parsing ># rules for roman numeral strings). > ># This allows us to convert from Arabic to Roman in about 7 lines ># of code; and from Roman back to Arabic less than 20 > ># Here's how we use these data structures: > >def toRoman (n): > result="" > if n < 1 or n > 4000: > return None > ## raise IndexError? > for i in RomSeq: > while Rom[i] <= n: > result = result + i > n = n - Rom[i] > return result > ># Our result starts as an empty string. ># We interate over the sequence of roman numeral component strings ># if the corresponding value (the value associated with "M" or "CM" ># etc) is greater than our number, we append the current string to ># our result and subtract its corresponding value from our copy of n > ># Converting from a roman numeral string back to arabic representation ># is a bit trickier. We can try using the same data structure. However, ># we could encounter many types of errors. ># We were able to filter out all invalid integers with a single compound ># conditional but there are lots of ways to compose strings that are ># *not* valid roman numerals. > >def fromRoman (s): > result=0 > s = s.upper() > # Start by converting to upper case for convenience # IXIV is not a valid canonical roman number # (13? = XIII) # So let's make a list of the two character token # pairs that are verbotten verbotten = { "CM" : "CD", "XC" : "XL", "IX" : "IV" } # And a list of tokens to skip if we've seen their # (larger) key. Remember that our parsing is "orderly" # so we'll never consider a CM after we've encountered # a CD --- the M, CM, and CD cases will always be # considered in that order. # The list starts empty: we just append values to it # *if* we encounter any of the keys in verbotten. skip = [] > > for i in RomSeq: > # A Roman number, in canonical form, is > # sorted from the larger tokens towards the > # lower valued ones. Thus IIMXCC is not > # a proper roman number (it would have to be > # sorted to MCXCII or 1192). In fact CMM is > # also not valid --- it would have to be MCM > # and CMCM is is not valid at all it can't > # be simply re-arranged, it must be re-written > # (MDCCC) > > # So we simply walk through the list of tokens > # in sequence (just as we did for convert toRoman) > # and we compare each token to the "head" of the > # remaining string. # However we have to mix in a couple extra checks # to prevent sequences of more than three of the # [MCXI] tokens or more than one of any of the # others. if i in skip: # we've seen CM, XC, or IX so we # skip the corresponding CD, XL, and IV tokens continue > > seen = 0 > limit = 1 > if i in ("M", "C", "X", "I"): > limit = 3 > # The M, C, X and I tokens make appear in sequences > # up to three times. All others may only appear once > # each # The seen/limit parsing works for most cases. # One case that is unaddressed by it is exlemplified # by the sequences IXIV (13? == XIII) or CMCD (1300) # See we use the verbotten dictionary to set our # a "skip" list, if we see > > head = s[:len(i)] > while i == head: > # on a match (head of string matches token): > # track number of times we've see this token > # vs. the token's sequence limit > seen = seen + 1 > if seen > limit: > break if verbotten.has_key(i): skip.append(verbotten[i]) > > s = s[len(i):] > # behead the remaining string > head = s[:len(i)] > # and get the new head of the string > result = result + Rom[i] > # oh yeah, and add corresponding value to result > > if s == "": > return result > >## The following simply prints a list >## by converting to a roman number *and back*. >longest="" >for i in range(1,4000): > s=toRoman(i) > if i != fromRoman(s): > print "Error? is %s really %d" % (s, i) > print "%5d\t%s" % (fromRoman(s), s) > if len(s) > len(longest): > longest = s >print longest > > >#### End of script > > The last 10 lines are just a test suite. > > I've noticed that this script works fine under Python 2.x > but it seems that s.upper() isn't in Python 1.5.x (or that > I have to import a string module; I didn't spend time on that). > > Here's a shell script version of just the "toRoman()" > function: > > >#!/bin/bash >valarray="1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10" >valarray="$valarray X 9 IX 5 V 4 IV 1 I" > >[ "$1" -lt 4000 ] || { > echo "Can't Represent numbers over 4000 in this character set" >&2 > exit 1 > } > >n="$1" >set -- $valarray >while [ "$n" -gt 0 ]; do # build roman numeral > while [ "$n" -lt "$1" ]; do # find scale > shift 2 > done > while [ "$n" -ge $1 ]; do # add values to result > let n-=$1 > result=$result$2 > done > done >echo $result From zzizz_ at notmail.com Sun Apr 15 20:45:41 2001 From: zzizz_ at notmail.com (zzzzz) Date: Mon, 16 Apr 2001 10:45:41 +1000 Subject: list comprehensions whats happening here References: Message-ID: <60gkdt0ntjvn461c595llle469ntvndh2n@4ax.com> Thanks everyone, It's interesting what you can come up with when you can't remember the syntax and the tuple in the code is fairly obvious after its been pointed out. z. On Fri, 13 Apr 2001 15:19:21 -0400, "Steve Holden" wrote: >"Carlos Ribeiro" wrote ... >> At 07:06 13/04/01 -0700, Emile van Sebille wrote: >> >I suspect the answer lies somewhere in the comma converting the parts of >the >> >list comprehension into a list itself, much as the comma is used in >normal >> >iteration idiom: >> > >> >for i in 1,2 >> >> As other have pointed out, your're right, that does explain why it works >> that way. But... >> >> >>>[[i,j] [1,2,3], for j in 'abc',] >> Traceback ( File "", line 1 >> [[i,j] [1,2,3], for j in 'abc',] >> >> does not work, yet >> >Why should this work? A list comprehension substitutes one or more bound >variables into a legitimate expression to generate the list members. But > > [i,j] [1,2,3] > >is *not* a legitimate expression: the interpreter will complain because it >thinks you are trying to subscript the list [i,j] with a tuple 1,2,3 -- list >subscripts have to be integers. > >> >>> [[i,j] for i in range(3), for j in range(3)] >> [[[0, 1, 2], 0], [[0, 1, 2], 1], [[0, 1, 2], 2]] >> >> work. >> >Indeed. Let's take this a piece at a time... start by giving j a fixed value >42. > > [[i,j] for i in range(3),] > >is a legitimate expression: it is equivalent to > > [[i,j] for i in (range(3), )] > >In other words, it produces a list of [i,j] lists, for i taking on every >value of the tuple (range(3), ) - a single-element tuple, so the result from >either of these expressions would be > > [[[0, 1, 2], 42]] > >This is correct: we get a single element list whose only element is the list >[i, j], where i was range(3) (the only value in the single-element tuple i >was iterating across) and j was 42. > >Let's look at your expression again, using a different range for j just so >it's clearer which contributes to what: > > [[i,j] for i in range(3), for j in range(6,9)] > >should give you a list containing three elements, since now j takes on not >just a single value but three. Sure enough, the result is > > [[[0, 1, 2], 6], [[0, 1, 2], 7], [[0, 1, 2], 8]] > >This is a list of three elements, one for each value of j. Each element of >the list is a list of two elements, the first of which is the value of i >(which is to say, range(3), or [0,1,2]) followed by a value of j (which is >to say 6, then 7, then 8). > >And that's why > >[[i,j] for i in range(3), for j in range(3)] > >evaluates to > >[[[0, 1, 2], 0], [[0, 1, 2], 1], [[0, 1, 2], 2]] > >It's also why > >[[i,j] for i in range(3), for j in range(6,9),] # note second trailing comma > >has only one value - because both i and j are iterating over single-element >tuples. > >[[[0, 1, 2], [6, 7, 8]]] > > >> I am not advocating that something is wrong; I just want to point out that >> some funny things are happening as a side effect of the grammar and/or >> compiler. It's impossible to supply a list as part of the list >> comprehension syntax, but you can fake it by writing a comma after the for >> clause. That's just weird, and unexpected. >> >Nope, that's a tuple, not a list. Just so happened that it's a >single-element tuple, whose only member is a list. If it's any help, I agree >it's weird and unexpected, but you have to realise we're out on the edges >here. > >> Question: this may turn out to be wrong, and it may be fixed in the >future; >> OTOH, it can be useful, and (in a rather obscure way) consistent with >> Python syntax. What's the take on this? Let it be, or fix it, as a >> undesirable side effect that don't belong to list comprehensions? >> >My own take is that everything is entirely consistent, and should be left >alone. There's a good reason why the list comprehension syntax doesn't have >commas in it! > >Hope this helps. > >regards > Steve > > From jwbaxter at olympus.net Sun Apr 1 00:54:37 2001 From: jwbaxter at olympus.net (John W. Baxter) Date: Sat, 31 Mar 2001 21:54:37 -0800 Subject: Conditional operator in Python? References: Message-ID: <310320012154377437%jwbaxter@olympus.net> In article , Tim Peters wrote: > Eric, there's no feature from *any* language that isn't regularly suggested > for Python. I haven't seen many suggestions that we adopt APL's syntax and character set. RATS...and April 1 would have been the perfect day for such a request. Ah, well...next year. --John From mark21rowe at yahoo.com Thu Apr 12 19:41:12 2001 From: mark21rowe at yahoo.com (Mark Rowe) Date: Fri, 13 Apr 2001 11:41:12 +1200 Subject: Tangents and the like... Message-ID: <3ad64110$1@news.actrix.gen.nz> Hey, Just been reading through the Math modules documentation and i can't see any way to find the inverse tangent of a number.... I know that this is possible, but how? Mark From fdrake at beowolf.digicool.com Fri Apr 13 01:10:02 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Fri, 13 Apr 2001 01:10:02 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010413051002.795BD2879C@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ More description and explanation in the unittest documentation; update to match the final code and decisions from the pyunit-interest mailing list. Added information on urllib.FancyURLopener's handling of basic authentication and how to change the prompting behavior. Added documentation for the ColorPicker module for the Macintosh. From paulp at ActiveState.com Sat Apr 21 13:46:38 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 21 Apr 2001 10:46:38 -0700 Subject: ActiveState PPM probs References: <9bq8h1$h5q$1@flood.weeg.uiowa.edu> <%o3E6.1759$LK1.328611972@newssvr16.news.prodigy.com> <9bs76f$aku$1@rzsun03.rrz.uni-hamburg.de> Message-ID: <3AE1C77E.9B26A62D@ActiveState.com> Thomas Weiner wrote: > >.... > > and: > > >>> import _imaging > Traceback (most recent call last): > File "", line 1, in ? > ImportError: Module use of python15.dll conflicts with this version of > Python. Please search your hard drive for *another* _imaging.dll or _imaging.pyd. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jeremy at digicool.com Thu Apr 5 15:31:24 2001 From: jeremy at digicool.com (Jeremy Hylton) Date: Thu, 5 Apr 2001 15:31:24 -0400 (EDT) Subject: Defining a code object from a function In-Reply-To: <3acc9132$0$12241$ed9e5944@reading.news.pipex.net> References: <3acc9132$0$12241$ed9e5944@reading.news.pipex.net> Message-ID: <15052.51212.477358.830371@slothrop.digicool.com> >>>>> "NB" == Neil Benn writes: NB> Hello, NB> I have a class as follows:- NB> class plate: NB> NoColumns = 0 NB> NoRows = 0 NB> currentRow = 0 NB> def __init__(self): NB> print "creating plate" NB> print "created plate" NB> def hasMoreRows(self): NB> if currentRow < noRows: NB> return 1ist NB> else: NB> return 0 NB> def nextRow(self): NB> self.currentRow = self.currentRow + 1 NB> return self.currentRow NB> I'm using the inspect module to get information about the NB> method NB> arguments back. NB> However................... NB> My problem is [...] It looks like you have other problems :-). The hasMoreRows() method will fail with a NameError because you use a bunch of unbound names. I think you need to change it to: def hasMoreRows(self): if self.currentRow < self.noRows: return 1 else: return 0 You're also initializing NoColumns, NoRows, and currentRow as class attributes. This will probably work correctly in your application, because all of the attributes you are using are immutable objects. The first assignment to, e.g. self.NoRows, will create an instance attribute self.NoRows. But if you used a list or some other mutable object, you'd have to be more careful. It is sometime better to initialize instance variable in the __init__(): def __init__(self): self.currentRow = 0 self.NoRows = 0 self.NoColumns = 0 self.listAttr = [] If you are clear on the distinction between class attributes and instance attributes, then I apologize for being pedantic. But it's easy to get confused and the hasMoreRows() method suggests that you're new to Python. Jeremy From larry at smith-house.org Tue Apr 3 21:03:02 2001 From: larry at smith-house.org (Larry Smith) Date: Tue, 03 Apr 2001 21:03:02 -0400 Subject: What an April Fool =:-) References: <3Rny6.81496$Ok4.6607298@news1.rdc1.ct.home.com> Message-ID: <3ACA72C6.938BC260@smith-house.org> Dan Sugalski wrote: > > Kemp Randy-W18971 wrote: > > Is that the announce where you by a Perl book, and they throw in a free > > parrot? Or is it the other way around? > > Nope, the announcement of Parrot itself. Just a moment, Sir! This parrot is stone dead! 'E's passed on! This parrot is _no_ _more_! He has ceased to be! 'E's expired and gone to meet 'is maker! 'E's a stiff! Bereft of life, 'e rests in peace! If you hadn't posted that foolish april fool's joke 'e'd be pushing up the daisies! 'Is metabolic processes are now 'istory! 'E's off the twig! 'E's kicked the bucket, 'e's shuffled off 'is mortal coil, run down the curtain and joined the bleedin' choir invisible!! THIS IS AN EX-PARROT!! ...as opposed to an ex-Perot, if I might be permitted to mix my references... -- .-. .-. .---. .---. .-..-. | Do not mistake my cynicism | |__ / | \| |-< | |-< > / | for dispair for deep inside `----'`-^-'`-'`-'`-'`-' `-' | me is an optimist forever http://www.smith-house.org/ | asking, "Why not?" From macransen at nemo.it Wed Apr 25 10:34:06 2001 From: macransen at nemo.it (Owen Ransen) Date: Wed, 25 Apr 2001 15:34:06 +0100 Subject: test_threads fails on Mac? Message-ID: <01HW.B70C9EEE0000AD5D0D8037A0@news.newsguy.com> I downloaded Python (which gives me this version info: Python 2.0 (#71, Oct 22 2000, 22:09:24) [CW PPC w/GUSI2 w/THREADS] and run test.autotest, and it appears to crash when it reaches test_threads. I think it crashes because the machine it just sits there and I can't switch out of Python to any other application. Is this a known bug? The readme says I may need to "run compileall" before testing, but as a Python beginner I do not know what that means. TIA Owen From claird at starbase.neosoft.com Wed Apr 18 15:56:41 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Apr 2001 14:56:41 -0500 Subject: Hygienic macros (was: do...until wisdom needed...) References: <9bkfmm$es3$0@216.39.170.247> Message-ID: In article , Douglas Alan wrote: >whisper at oz.net (Dave LeBlanc) writes: > >> FWIW, Tcl is actually based on Lisp - i'm told quite closely once you >> get past the syntactical sugar. > >I don't know what you mean by "based on". They are very dissimilar. > >|>oug Inner-circle Tcl-ers widely believe Tcl and Lisp "feel the same": 'Course, there's also a long tradition of devoted Lispers deprecating Tcl, sometimes quite passionately. I'll spare you references to those instances. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From paulp at ActiveState.com Wed Apr 18 14:36:36 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 18 Apr 2001 11:36:36 -0700 Subject: do...until wisdom needed... References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <87n19fvdzo.fsf_-_@elbereth.ccraig.org> <9bk0ce026c6@news1.newsguy.com> <3d1yqqf5pp.fsf@ute.cnri.reston.va.us> Message-ID: <3ADDDEB4.E346FE07@ActiveState.com> Andrew Kuchling wrote: > > Paul Prescod writes: > > And if some smart people can use hygenic macros to make Python code that > > is more maintainable or readable, why should they be disallowed? Python > > I'm increasingly opposed to new Python features, but I'm still not > ruling out the idea of hygenic macros. Their presence might remove > the pressure to add new features, which would mean the language core > would be that more stable. I don't really believe that. I tihnk that hygenic macros could and should be used for: 1. experimentation 2. domain specific "little languages" based on Python like ptml or pyslt or pymake or ... > I expect it's very difficult to provide a > simple interface for them in Python, though, because the syntax, and > the resulting parse trees, are more complicated and less regular than > in Lisp; maybe I'm just pessimistic, though. A complicated interface to them might be just what is necessary to make their use infrequent enough to not be frightening. I would say: "just hand the macro a parse tree and ask it to return you another one." -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From claird at starbase.neosoft.com Thu Apr 19 10:18:36 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Apr 2001 09:18:36 -0500 Subject: Performance measurements (was: python on the smalltalk VM) References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> Message-ID: <4EA03F26C2C54BAB.26EA5ACB1D9CD09A.30161D811690E63A@lp.airnews.net> In article , Douglas Alan wrote: . [apt summary of Self] . . >After many years of research, they came up with a compiler for Self >that would generate code that runs about one half to one third the >speed of compiled C code. This is 30 to 50 times faster than Python. . . . Something's not right here. Even recognizing, as I'm sure we all do, that the speeds of various languages are exceedingly fuzzy measurements, it's been a loooooooong time since I've seen any signif- icant comparisons which put C two decimal orders of magnitude faster than Python. Is there a typo somewhere in this transmission? Do you have a specific instance of such a measurement? It might be instructive. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ramagnus at zvw.de Thu Apr 19 11:57:28 2001 From: ramagnus at zvw.de (Rolf Magnus) Date: Thu, 19 Apr 2001 17:57:28 +0200 Subject: why python annoys me References: <3ADCBECE.1BDFFCD@netplus.net> <3ADCCC65.5030100@hccnet.nl> Message-ID: <9bn1pi$96c$2@news.sns-felb.debis.de> Jaap Spies wrote: > Did you give Jython a try? With Jython you can use the 'nice things of > Python' with the best of Java. With "the best of Java", do you mean the poor memory management? I heard that's one of the biggest difference between Python and Jython. From echapin at sympatico.ca Tue Apr 24 10:09:01 2001 From: echapin at sympatico.ca (Elliott Chapin) Date: Tue, 24 Apr 2001 14:09:01 GMT Subject: bell() Message-ID: <1OfF6.626247$Pm2.10484047@news20.bellglobal.com> I would like to use bell() without creating a dialog. I guess it should be possible, but I haven't been able to find out how. Please help. Thanks, -- --------------------------------------------------------------- Elliott Chapin http:// www3.sympatico.ca/echapin From szz at philoslabs.com Fri Apr 6 11:33:13 2001 From: szz at philoslabs.com (Szalay Zoltan) Date: Fri, 06 Apr 2001 17:33:13 +0200 Subject: operator on functions Message-ID: <3ACDE1B9.2070109@philoslabs.com> Hi everybody out there! It would be a nice feature of Python syntax providing an operator to compose a function from another two: h=f*g . I mean (f*g)(x)=f(g(x). It would be useful e.g. in the following situation: dict={ key1 : func1, key2 : f * g, key3 : func3 } I know the following gives the same result: dict={ key1 : func1, key2 : lambda x: f(g(x)), key3 : func3 } But the former one is more elegant. (IMHO) Zoltan Szalay szz at philoslabs.com From timr at probo.com Sat Apr 14 01:43:12 2001 From: timr at probo.com (Tim Roberts) Date: Fri, 13 Apr 2001 22:43:12 -0700 Subject: Problem with win32api function References: <3AD70CBA.8050202@ActiveState.com> Message-ID: Mark Hammond wrote: >Dublanc, David wrote: > >> I have a problem with the fonction win32file.GetDiskFreeSpace >> The maximum number of space is : 65536 bytes. So if the hard disk capacity >> is > 2 Go, the function returns a wrong result. >> >> Do you have solution for this problem ? > >Check out the documentation in the help files - the number of bytes is >not returned, but 4 different values are to help you calculate it: I think he realized this. He's talking about the fourth parameter, total cylinders, which is limited to 65536. He is also correct. The GetDiskFreeSpace API is defective on Win9X; that's why GetDiskFreeSpaceEx was invented. Here, watch this; my 5GB disk gets reported as 2G: C:\WINDOWS>ver Windows 98 [Version 4.10.1998] C:\WINDOWS>chkdsk CHKDSK has NOT checked this drive for errors. You must use SCANDISK to detect and fix errors on this drive. Volume DURHAM created 06-12-2000 3:25p Volume Serial Number is 3945-0106 4,842,144 kilobytes total disk space 1,451,076 kilobytes free 4,096 bytes in each allocation unit 1,210,536 total allocation units on disk 362,769 available allocation units on disk 651,264 total bytes memory 602,976 bytes free Instead of using CHKDSK, try using SCANDISK. SCANDISK can reliably detect and fix a much wider range of disk problems. C:\WINDOWS>python Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import win32file >>> a,b,c,d=win32file.GetDiskFreeSpace('c:\\') >>> a,b,c,d (64, 512, 45346, 65526) >>> print 1L*a*b*d 2147155968 >>> print 1L*a*b*c 1485897728 >>> C:\WINDOWS> -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From kc5tja at garnet.armored.net Wed Apr 18 13:37:14 2001 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 18 Apr 2001 10:37:14 -0700 Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> Message-ID: On 18 Apr 2001 08:10:28 GMT, Dave LeBlanc wrote: >Since self is used for every method of every class, isn't it a bit >redundant? I don't know of another OO language that makes you manually >carry around the "this"/"self" pointer/reference... Oberon. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From mwh21 at cam.ac.uk Thu Apr 26 14:01:47 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Thu, 26 Apr 2001 19:01:47 +0100 (BST) Subject: python-dev summary 2001-04-12 - 2001-04-26 Message-ID: This is a summary of traffic on the python-dev mailing list between Apr 12 and Apr 25 (inclusive) 2001. It is intended to inform the wider Python community of ongoing developments. To comment, just post to python-list at python.org or comp.lang.python in the usual way. Give your posting a meaningful subject line, and if it's about a PEP, include the PEP number (e.g. Subject: PEP 201 - Lockstep iteration) All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on a PEP if you have an opinion. This is the sixth summary written by Michael Hudson. Summaries are archived at: Posting distribution (with apologies to mbm) Number of articles in summary: 293 40 | [|] | [|] | [|] [|] [|] | [|] [|] [|] [|] | [|] [|] [|] [|] 30 | [|] [|] [|] [|] | [|] [|] [|] [|] | [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] 20 | [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] 10 | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] 0 +-019-039-037-038-006-028-018-012-042-016-008-023-003-004 Thu 12| Sat 14| Mon 16| Wed 18| Fri 20| Sun 22| Tue 24| Fri 13 Sun 15 Tue 17 Thu 19 Sat 21 Mon 23 Wed 25 * Python 2.1 is released! * After Tim found a bug of staggering subtlety in the dict code: And Guido released a release candidate or two: Python 2.1 was unleashed on the world: which has already been incorporated into the cygwin distribution: * Iterators * Guido asked whether we thought he should check his prototype iterator implementation into the main trunk: After everyone said "yes!", he did so, so you can play around with iterators if you build a Python from CVS. Discussion of this feature is going on the python-iterators list at sourceforge: * Class methods * Thomas Heller posted another plea for class methods to be included in some future version of Python: Discussion wandered around a bit, drifting onto metaclasses and some tantalizing hints of Guido's plans for attacking the dreaded type/class split in Python 2.2. * Suirprise! * Tim Peter's posted a surprising consequence of how Python handles chained comparisons: This may elicit a warning from the compiler in 2.2... Cheers, M. From kens at sightreader.com Tue Apr 10 00:44:51 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 9 Apr 2001 21:44:51 -0700 Subject: After Parrot, what next? References: <3ad2724b$1@news.iprimus.com.au> Message-ID: <002d01c0c179$4f9aea10$04090a0a@upcast.com> Actually, COBOL has been a largely overlooked language. It was once one of the most important programming languages on the planet. It would be unfortunate to disregard its usefulness just because it is old. The Parrot designers need to take this venerable language into account. Among the many features of COBOL that have been lost in recent years are line numbers and columnar structure (the latter having been kept in some versions of FORTRAN). XML would allow the actual column arrangement to be decided later in a style sheet. Maybe something like this: line getlines line ... We need to learn to combine the best of both the old and the new. ----- Original Message ----- From: "Andrew Hamm" Newsgroups: comp.lang.python,comp.lang.perl To: Sent: Monday, April 09, 2001 7:38 PM Subject: Re: After Parrot, what next? > Roy Smith wrote in message ... > >A bunch of us were discussing the new Parrot syntax (i.e things like > >"left_angle_bracket_right_angle_bracket") today and came up with a great > >idea for a new language syntax, which mixes the best ideas of Parrot and > >XML. Instead of: > > > Noooooooooooooooo!!!!!! > > Why make life harder for people just to make life easier for parsers? Can > you imagine how dizzying a couple of pages of that would be? It looks > bulkier than COBOL to boot. Have you used Lisp in a previous incarnation? > -- > "Having fun is half the fun" - Guru Adrian > No matter what happens, somebody will find a way to take > it way too seriously - Micheal Tod (wishes he said this) > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From SBrunning at trisystems.co.uk Wed Apr 11 07:20:09 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 11 Apr 2001 12:20:09 +0100 Subject: useless comments (was Re: ActiveState going the wrong way) Message-ID: <31575A892FF6D1118F5800600846864D78BACF@intrepid> > From: Alex Martelli [SMTP:aleaxit at yahoo.com] > > I have yet to find a "useless" comment. > > Have you TRULY never seen such beauties as > > x++; // increment x by one I can beat that. This comment would explain to someone who had never seen C what this line of code does. That's not *useless*, it's merely next to useless. I'm working in RPGIII at the moment*, and I came across this little beauty: .....CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments+++++++.. .... C COMIT Comit (RPG is a fixed format, columnar language. Not pretty. I've included a 'ruler', to show where the columns are.) The opcode is 'COMIT' - i.e. commit database changes. Notice that in the comment, the programmer didn't even bother to use the whole word! Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk * It's a living. ----------------------------------------------------------------------- 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 mda at idatar.com Wed Apr 4 21:37:22 2001 From: mda at idatar.com (David Allen) Date: Thu, 05 Apr 2001 01:37:22 GMT Subject: del()? References: Message-ID: In article , "Jay Collins" wrote: > does del() free the ram used by string? I'm not sure, but it definately nukes it from python's environment so you can't use it anymore. It is likely that it frees the ram but maybe not right at that instant. > like > > a = "my string" > del(a) > > will I get my ram back? Should I even worry about this since gc takes care > of this? I usually use del() exclusively to get rid of keys to dictionaries. As in: >>> d = {} >>> d['foo'] = 'bar' >>> d['baz'] = 'quux' >>> d {'foo': 'bar', 'baz': 'quux'} >>> del(d['foo']) >>> d {'baz': 'quux'} >>> -- David Allen http://opop.nols.com/ ---------------------------------------- Marriage is the only adventure open to the cowardly. -- Voltaire From robin at illusionsexeculink.com Sun Apr 8 19:03:54 2001 From: robin at illusionsexeculink.com (robin at illusionsexeculink.com) Date: Sun, 08 Apr 2001 19:03:54 -0400 Subject: ActiveState Ruby? References: Message-ID: "Brian Quinlan" wrote: >I find it more relevant to speculate on whether Python would fork if the >merpeople start invading our cities riding on the backs of giant king crabs. In that eventuality, instead of a Python fork, I would recommend lobster crackers, a bib, and some hot melted butter. ----- robin robin at illusionsexeculink.com media artist / remove illusions to reply information architect www.execulink.com/~robin/ Isolation tank paves way to execute an attack. From aleaxit at yahoo.com Tue Apr 10 07:07:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Apr 2001 13:07:06 +0200 Subject: Chocolate [was Re: Python Books for 2002] References: <3E96A80984E6D7B7.A7CB9CE9541F0D99.8ACE6F39B6739737@lp.airnews.net> <11A279245FF128F8.7A0E8AF314DD0135.E3C0007C3BD57C8C@lp.airnews.net> <9akknn0p3@news2.newsguy.com> Message-ID: <9aupgl01lvq@news2.newsguy.com> "Konrad Hinsen" wrote in message news:m366gdqgrr.fsf at chinon.cnrs-orleans.fr... > "Steve Holden" writes: > > > One thing I *don't* understand is how come the stuff Hershey and similar > > companies sell is even allowed to be called chocolate. One of the nastier > > surprises about moving to the USA was the discovery that many items sold > > Come to France - chocolatewise this is a highly civilized country. And not _only_ chocolatewise -- in bread AND wine AND cheese, as well as in high-quality chocolate, I consider you guys the only ones on a par with Italy... > No problem to find 85% pure chocolate even in an ordinary supermarket. Interesting! Here, you win -- most Italian supermarkets focus on low-price, industrial-quality chocolate (_large_ hypermarkets are fortunately an exception -- to some extent this goes for wine, cheese, and bread, too). Alex From garabik at center.fmph.uniba.sk.spam Thu Apr 26 13:04:35 2001 From: garabik at center.fmph.uniba.sk.spam (Radovan Garabik) Date: 26 Apr 2001 17:04:35 GMT Subject: Passwords / PAM References: <3ae82229.3001736@news.laplaza.org> Message-ID: <9c9kf3$l22$1@sunnews.cern.ch> Mats Wichmann wrote: : Turns out I need a way to deal with prompting a user for a password : and having it be encoded in the proper manner; some of the target : systems are using crypt-style password encoding and some are using : MD5. I'm presuming I could use PAM for this... does anyone know of a : Python PAM module? I didn't locate one in a brief search, but I'm : suspecting there is one out there... my debian box gives me: atlas13:pts/3:~% cat /usr/doc/python-pam/copyright This is the Debian package of a Python PAM module. This package was put together by Gregor Hoffleit , from sources obtained from ftp://ftp.pangalactic.org/pub/tummy/. Author: Rob Riggs Copyright: Copyright (c) 1999 Rob Riggs and tummy.com, Ltd. All rights reserved. Released under GNU GPL version 2. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL'. atlas13:pts/3:~% I used it a few times and it worked ok -- ----------------------------------------------------------- | 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 shredwheat at mediaone.net Sat Apr 7 18:10:15 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sat, 07 Apr 2001 22:10:15 GMT Subject: PyChecker - a python source code bug finder References: Message-ID: "Neal Norwitz" wrote > PyChecker is a python source code checking tool to help you find common > bugs. It is meant to find problems that are typically caught by a > compiler. Because of the dynamic nature of python, some warnings may be > incorrect; however, spurious warnings should be fairly infrequent. amazing. this is just great. i hope once it matures we can see it included in the standard python distributions (2.2!) thanks neal, this is something i've been wanting since my first days with python. From aleaxit at yahoo.com Fri Apr 27 04:46:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Apr 2001 10:46:29 +0200 Subject: function pointers References: <6gfgetculv0iqj1id4dpqb7jvmt8jlrs03@4ax.com> <3AE84119.4EA9C1AC@alcyone.com> <90bhetcu10kn5otresb1dq65pps2vha6ii@4ax.com> Message-ID: <9cbbl3057t@news1.newsguy.com> "Courageous" wrote in message news:90bhetcu10kn5otresb1dq65pps2vha6ii at 4ax.com... > > >Indeed, being able to move around bound methods is one of the things > >that impressed me most about Python. > > Yup. And for those of you not following the Evil Empire (tm), > C-sharp has an analogous structure called a "delegate". I think it's more of a Hejlsberg "trademark" -- he put it in Delphi when he architected that for Borland, then he moved to MS and put it in MS's version of Java (and made it a cornerstone of the WFC framework), and now in C#. > This is an answer to the whole static-member-function- > dispatch-to-non-static-member-function lunacy that crept > into C++ as callbacks grew into favor. And it beats the hell > out of those spurious lunatical functor objects as well. :) I don't really share your (and Hejlsberg's:-) enthusiasm for 'delegates' (and strongly dislike the NAME 'delegate' for this purpose, but that's another issue); first class callables ARE nice, but, in a Java-ish framework, it has always seemed to me that interfaces plus inner classes met that need pretty well. (In C++, you run smack into lack of garbage collection for this as for many other potential idioms, of course -- so you roll your own RC or whatever, etc, etc -- can you spell "boilerplate"?-). Bound methods *AND* other more-generally curried functions are definitely alternatives to using objects/interfaces/ classes for this purpose, of course. I do like having the choice in Python, particularly because its general signature-based polymorphism means I can pass bound methods when they will suffice and other kinds of callables where I need more generality. In a language that is statically type-checked at runtime, I suspect that interfaces' better generality makes them preferable to "bound-methods" (given that no other currying is directly supported). Alex From fredrik at pythonware.com Wed Apr 18 12:23:06 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 18 Apr 2001 16:23:06 GMT Subject: Deprecate self References: <9bji5k$417$0@216.39.170.247> <3ADDBDFE.4403459A@netplus.net> Message-ID: "Luke" trolls again: > Java's system works just fine. It is assumed when you are writing a class, > that a variable is part of that class. It makes more sense. After all why > wouldn't you assume first that a variable that is part of a class belongs to > that class. If you are dumb and want to put an identical variable in a local > scope in a function, for example, then you use this.foo to distinguish. Java > is more logical IMHO looks like you haven't studied Python's class model close enough to actually know what you're talking about here... (hint: how do you declare class members in Python?) Cheers /F From sholden at cox.rr.com Sun Apr 22 23:18:28 2001 From: sholden at cox.rr.com (Steve Holden) Date: Mon, 23 Apr 2001 03:18:28 GMT Subject: Another question References: <3AE3926E.BD9F4A3E@swt.edu> Message-ID: <8aNE6.29732$Yk5.10268628@typhoon.southeast.rr.com> "ps54713" wrote in message news:3AE3926E.BD9F4A3E at swt.edu... > I have a Profile page where i have various text box fields like first > name , last name, ssn , etc. > I also have a button "Clear Form". All the fields should get erased once > i click on it. > Can anybody suggest the best way to implement the "clear form" function. > > I have implemented this page using PMW and TKInter widgets. > > Thankyou > Praveen > Probably build a list of all text input elements contains in the form. THen, when the user presses the "Clear Form" buttin, you can just iterate over the loop setting all those inputs' value to the empty string. regards STeve From phd at phd.fep.ru Wed Apr 4 08:57:37 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 4 Apr 2001 16:57:37 +0400 (MSD) Subject: Smtplib... In-Reply-To: <01040407443500.00574@tos1> Message-ID: On Wed, 4 Apr 2001, Vincent A. Primavera wrote: > When sending mail with smtplib, how would you attach a file? Absoluteley the same way you'd use sending mail with sendmail. First, learn a bit the MIME standards. Then learn to use MimeWriter.py from standard Python library. Search the Net for examples. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Wed Apr 11 08:10:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Apr 2001 14:10:35 +0200 Subject: Changing global variables in tkinter/pmw callback References: <3ACC21BF.14E708B7@mek.dtu.dk> <3ACC4EB1.376225AF@mek.dtu.dk> <3s0z6.5511$4N4.1170119@newsc.telia.net> <3ACD5D99.47AED2BE@mek.dtu.dk> <9ajvm90253c@news2.newsguy.com> Message-ID: <9b1hjk020p8@news2.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9d703n.fge.qrczak at qrnik.zagroda... > Fri, 6 Apr 2001 10:45:00 +0200, Alex Martelli pisze: > > > If some place after the call you had for example a loop such as > > DO 10, I=1,3 > > then the loop's body would 'of course' now be executed four times, > > for example. > > > > We _don't_ really want this, do we? Numbers *had better* be > > completely immutable objects -- programming becomes a funny > > game indeed if the actual values of numbers start changing > > from under our feet. > > I would say that if numbers were immutable, then using a numeric > literal would have to allocate a fresh object each time, otherwise > the semantics would be too confusing, if well defined at all. In Python, identity of immutable objects WILL differ if the object values differ, and it's UNDEFINED whether it will or won't differ if the object values are equal. You can see it this way: 'basic' semantics is that "a fresh object" is indeed allocated each time a literal is mentioned, BUT the compiler/runtime system is empowered to optimize by sharing a single immutable object for separate literals which it can prove must lead to the same value. It doesn't seem to me to make the semantics at all confusing. If you meant something different from what you just wrote (such as "if numbers were MUTABLE", rather than "immutable" as you said) then what I wrote still holds, but I would sure agree that mutable number objects might make for confusing semantics -- surely would if literals were not defined as 'generators' to be freshly executed each time, and maybe even if they weren't. > Immutability allows unrestricted sharing of values which look > the same. For immutable objects generally only '==' matters, not > 'is'. Deep copying becomes equivalent to all kinds of shallow copying > and to rebinding a reference. Passing by value becomes equivalent to > passing by reference. All basically true, except I'm not too sure about deep copy equivalence to shallow, given the generality of your assertion about 'immutable objects'. An object can be immutable by immutably referring to mutable objects, after all: >>> tup = ([], []) >>> tup[0].append(23) >>> tup ([23], []) The tuple has not mutated, but it sure looks like deep vs shallow copying it might have mattered. We might amend your asserted equivalence to cases where ONLY immutable objects are involved -- *NO* mutability allowed anywhere in the web of objects which may be referencing each other (hmmm, not sure you can _make_ a reference cycle with immutable objects *only* -- guess not, if you're not allowed to refer to an object until it's "fully-built"). > In an immutable world the 'boxes' and 'post-it tags' paradigms are > unified - to the point that some people are confused and believe > that Python works according to the 'boxes' paradigm, until they leave > the immutable world and want to observe mutation of an integer. They > can't create a reference to a mutating integer, because it was not > the integer which was mutating, only the object which contained it... ...or, vice versa, they get surprised because a=[] b=a a.append(23) has (from their POV) "mutated what's in b" (thinking of b as a box that holds a copy of what "was in a" at assignment time). Yep, good point -- and another case where mutability, apparently so natural a concept, yields complexity (the other, classic case being the typestrict-OO poser "if banana IS-A fruit, how comes bag-of-banana IS-NOT-A bag-of-fruit" -- bag mutability [ability to insert an apple into it, for example] being the root cause). > When a language with 'post-it tags' semantics wants to express > boxes with changing contents, it can do it in two styles: either > introduce a boxing mechanism for individual objects (this is what > SML and Haskell do), or pack multiple objects into some structures > with mutable contents (this is what Python and OCaml do). Either of > these styles can simulate the other one. I thought I was following you up until the middle of this paragraph. What's the "boxing mechanism for individual objects" in Haskell? I do understand (I think) how a mutable field in a one-field structure trivially lets you "box an individual object", a la type 'a ref = ref of mutable 'a but doesn't Caml introduce further primitives for references (how would I define := otherwise...)? Alex From grey at despair.rpglink.com Tue Apr 10 16:45:22 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Tue, 10 Apr 2001 20:45:22 -0000 Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE> <3ad34fb4.1636258213@News.CIS.DFN.DE> Message-ID: On Tue, 10 Apr 2001 14:53:36 -0400, D-Man wrote: >| c) A console to execute ad-hoc commands. >sort of, with the ':!' command. Emacs can have a buffer with a shell >running in it (and still use other buffers). (can vim have a >persistant buffer like that?) A console to run ad-hoc commands? You mean like clicking on the rxvt button and having one there? Erm, no X/GUI? How about ALT-F2, ALT-F3? :) I fail to see why a persistant buffer is 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 barry at wooz.org Thu Apr 12 00:23:28 2001 From: barry at wooz.org (Barry A. Warsaw) Date: Thu, 12 Apr 2001 00:23:28 -0400 Subject: OT - Closing Off An Open-Source Product References: <20010411183525.P754-100000@open-systems.net> <3AD4F4FB.3D13F205@ActiveState.com> <0l9B6.147943$m04.6141182@e420r-atl1.usenetserver.com> Message-ID: <15061.11712.162167.751094@anthem.wooz.org> >>>>> "SH" == Steve Holden writes: SH> Of course, the music industry has found itself at the sharp SH> end of this issue. In order to justify its existence it has to SH> try to convince the courts its IP should be paramount. But if SH> music industrialists think that musicians haven't clearly seen SH> much of the industry is technically unnecessary, they are SH> crazy. The bell is tolling, whether Napster's rather dodgy SH> business model survives or not. SH> The music companies only have IP rights because the musicians SH> sign them away to get access to the distribution channels. The SH> traditional channels are slowly becoming redundant. the SH> consumer can deal directly with a band's web site, download SH> and burn their own CDs. Maybe the real music industry will be SH> web sites in twenty years. No kidding. I personally know several local-ish bands that, almost immediately upon signing with a label, went $500k to $1M in debt, lost their copyrights, and had to pay off that debt with the meager percentage of their sales that they got back in royalties, before they ever saw a dime. Needless to say, most never recoup. And for what? Mostly the prestige of "being signed" and the very slim chance of becoming zillionaires. Oh, and limos, new guitars, loads of wasted studio time, and other pampering, all of which you have to recoup, of course. Okay, this is way off topic for this list, but today you can spend $15k of your own hard earned money producing 1000 CDs of equal quality to anything the labels will get you. Afterwards, you own it 100%, can sell them at shows, many stores, and via the Internet. Then you try to get a distribution-only deal where you keep a much bigger chunk of the wholesale price. And you wonder why there's such mass marketed crap on the radio and MTV? Personally, I say boycott the labels, go out and see a good local band in your neighborhood bar, and support them by buying their CD. Or buy stuff directly from the band by visiting their web-sites, like, say www.cravindogs.com. :) Oh yeah, and keep your own merchandising rights. The Dave Matthews band made $80M selling T-shirts. If you don't think merch is the way to go yet, remember the "dancing baby" that was all the rage a few years ago? The company made way more money licensing that out than they ever did selling the software the baby was a demo for. :) anyone-for-python-beenie-babies?-ly y'rs, -Barry From killspam at darwinwars.com Mon Apr 16 01:24:12 2001 From: killspam at darwinwars.com (Andrew Brown) Date: Mon, 16 Apr 2001 05:24:12 GMT Subject: The Kompany & Black Adder References: Message-ID: Albert Wagner wrote in : > Has > anyone here bought Black Adder? What has your experience been? I have been playing with a beta version on Windows 2000. Apparently it works better on other platforms. For me at the moment it is completely unusable, largely because it crashes every time it enters the debugger (and also when I start a new project). The editor is a mess, too. On the other hand, the email support I have been getting has been courteous, helpful, and well-informed. I think these guys will get there in the end. The next beta should be usable, and the one after that useful. I really hope they succeed, and not just because I paid for it :-) Has anyone used BA successfully under Linux? From erenouf at opticominc.com Fri Apr 6 21:47:36 2001 From: erenouf at opticominc.com (Eric Renouf) Date: Sat, 07 Apr 2001 01:47:36 GMT Subject: Commercial Products in Python? References: <3abb86ee.142862695@localhost> <3ABBD84B.9020404@ActiveState.com> <87bsqp515e.fsf@gabriel.heim6.tu-clausthal.de> Message-ID: <3ACE7159.3D4117EA@opticominc.com> I'm assuming that the question here is what commercial products were written in Python. The company that I work for works almost exclusively in Python. The product is called iView and is made by Opticom Inc. (www.getiview.com) Patrick Bothe wrote: > Hi, > > I think some pieces of code of "Severance - Blade of Darkness" > (PC-GAME) are coded in Python 1.5.2. > > bye, > Patrick > > -- > Der Kopf ist rund, (_ ) > damit das Denken die Richtung ?ndern kann. \\\@@ ) ^ > \/, \( > [Francis Picabia] cXc_/_) Eric Renouf Software Engineer Opticom Inc. www.getiview.com From kalle at gnupung.net Fri Apr 20 14:45:46 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Fri, 20 Apr 2001 20:45:46 +0200 Subject: [ANNOUNCE] Umbra role-playing game 0.2 pre-alpha In-Reply-To: ; from kamikaze@kuoi.asui.uidaho.edu on Fri, Apr 20, 2001 at 05:54:50PM +0000 References: <9blulk$dtj$1@panix6.panix.com> <9boeru$ej9$1@news.udel.edu> Message-ID: <20010420204546.C7649@apone.network.loc> Sez Mark 'Kamikaze' Hughes [regarding the GPL]: > And of course, everyone has the right to put their own code under > whatever license he likes... But using a virus license like his that > takes away other peoples' rights to their own software, just by being > mixed with his, is just vile. I think you've got the "virus" thing all wrong. It doesn't force you to use the GPL for your programs unless they are derivative works of a program licensed under the GPL. > Or even better, forget about him. He's just some loser who can't even > get a real job, and wrote a slow, bloated editor many years ago. Some > people like it, I'm told; tastes vary, so that's fair enough. But > NOBODY deserves any attention unless they produce new stuff, and then > only in proportion to how good that stuff is. I think you underestimate the contributions of RMS. He didn't just write emacs, you know... > What has he done for us (instead of to us) *lately*? Nothing. He's a > waste of meat. What have *you* done for us (lately or ever)? My guess is that you're a waste of meat too, by that reasoning. > Compare, for instance, to Linus or Guido. They write code. Any fame > they get is justified, because they've written *GOOD* code. Eric S. > Raymond is a borderline case; he does write code, sometimes very useful > code (and sometimes stuff like C-Intercal...). But he's also a > shameless exhibitionist, and needs about a 99% fame reduction. May I ask what makes you able to judge the quality of the works of RMS, Linus, Guido and ESR, especially considering that they write very different kinds of software. emacs is not linux is not python is not fetchmail. > > For a programmer to > >'own his/her own software' means, in practical terms, to be able to release > >it under exactly the license terms he/she wants, and have those terms > >respected/enforced. That is what he and collaborators have done with the > >GPL license and what you have done with yours. > > Until someone infects some non-GPL code with the GPL. Then it's been > stolen. See above. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From whisper at oz.net Thu Apr 12 22:27:12 2001 From: whisper at oz.net (Dave LeBlanc) Date: 13 Apr 2001 02:27:12 GMT Subject: OT - Closing Off An Open-Source Product References: <20010411183525.P754-100000@open-systems.net> <3AD4F4FB.3D13F205@ActiveState.com> <0l9B6.147943$m04.6141182@e420r-atl1.usenetserver.com> Message-ID: <9b5o60$kim$0@216.39.170.247> On Thu, 12 Apr 2001 00:23:28 -0400, barry at wooz.org (Barry A. Warsaw) > >Okay, this is way off topic for this list, but today you can spend >$15k of your own hard earned money producing 1000 CDs of equal quality >to anything the labels will get you. Afterwards, you own it 100%, can >sell them at shows, many stores, and via the Internet. Then you try >to get a distribution-only deal where you keep a much bigger chunk of >the wholesale price. > I dunno where YOU buy, but 1k CD's are one hell of a lot less then $15K in my neighborhood... more like <<$1k, including labels (not sure about jewel cases). >-Barry > Dave LeBlanc From sholden at holdenweb.com Fri Apr 13 15:19:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Apr 2001 15:19:21 -0400 Subject: list comprehensions whats happening here References: Message-ID: "Carlos Ribeiro" wrote ... > At 07:06 13/04/01 -0700, Emile van Sebille wrote: > >I suspect the answer lies somewhere in the comma converting the parts of the > >list comprehension into a list itself, much as the comma is used in normal > >iteration idiom: > > > >for i in 1,2 > > As other have pointed out, your're right, that does explain why it works > that way. But... > > >>>[[i,j] [1,2,3], for j in 'abc',] > Traceback ( File "", line 1 > [[i,j] [1,2,3], for j in 'abc',] > > does not work, yet > Why should this work? A list comprehension substitutes one or more bound variables into a legitimate expression to generate the list members. But [i,j] [1,2,3] is *not* a legitimate expression: the interpreter will complain because it thinks you are trying to subscript the list [i,j] with a tuple 1,2,3 -- list subscripts have to be integers. > >>> [[i,j] for i in range(3), for j in range(3)] > [[[0, 1, 2], 0], [[0, 1, 2], 1], [[0, 1, 2], 2]] > > work. > Indeed. Let's take this a piece at a time... start by giving j a fixed value 42. [[i,j] for i in range(3),] is a legitimate expression: it is equivalent to [[i,j] for i in (range(3), )] In other words, it produces a list of [i,j] lists, for i taking on every value of the tuple (range(3), ) - a single-element tuple, so the result from either of these expressions would be [[[0, 1, 2], 42]] This is correct: we get a single element list whose only element is the list [i, j], where i was range(3) (the only value in the single-element tuple i was iterating across) and j was 42. Let's look at your expression again, using a different range for j just so it's clearer which contributes to what: [[i,j] for i in range(3), for j in range(6,9)] should give you a list containing three elements, since now j takes on not just a single value but three. Sure enough, the result is [[[0, 1, 2], 6], [[0, 1, 2], 7], [[0, 1, 2], 8]] This is a list of three elements, one for each value of j. Each element of the list is a list of two elements, the first of which is the value of i (which is to say, range(3), or [0,1,2]) followed by a value of j (which is to say 6, then 7, then 8). And that's why [[i,j] for i in range(3), for j in range(3)] evaluates to [[[0, 1, 2], 0], [[0, 1, 2], 1], [[0, 1, 2], 2]] It's also why [[i,j] for i in range(3), for j in range(6,9),] # note second trailing comma has only one value - because both i and j are iterating over single-element tuples. [[[0, 1, 2], [6, 7, 8]]] > I am not advocating that something is wrong; I just want to point out that > some funny things are happening as a side effect of the grammar and/or > compiler. It's impossible to supply a list as part of the list > comprehension syntax, but you can fake it by writing a comma after the for > clause. That's just weird, and unexpected. > Nope, that's a tuple, not a list. Just so happened that it's a single-element tuple, whose only member is a list. If it's any help, I agree it's weird and unexpected, but you have to realise we're out on the edges here. > Question: this may turn out to be wrong, and it may be fixed in the future; > OTOH, it can be useful, and (in a rather obscure way) consistent with > Python syntax. What's the take on this? Let it be, or fix it, as a > undesirable side effect that don't belong to list comprehensions? > My own take is that everything is entirely consistent, and should be left alone. There's a good reason why the list comprehension syntax doesn't have commas in it! Hope this helps. regards Steve From osuchw at ecn.ab.ca.remove_me Thu Apr 19 00:32:28 2001 From: osuchw at ecn.ab.ca.remove_me (waldekO) Date: Wed, 18 Apr 2001 22:32:28 -0600 Subject: Create/Edit Win32 Shortcuts? References: Message-ID: <9UtD6.2758$h4.54829@jekyl.ab.tac.net> What I used to do is to create Shell object using COM package and utilize its methods to do the job. for example: from win32com.client import Dispatch >>> shell = Dispatch('WScript.Shell') >>> lnk = shell.CreateShortcut('c:\\windows\\desktop\calc.lnk') >>> lnk.TargetPath = 'c:\\windows\\calc.exe' >>> lnk.Save() For details of all parameters refer to Microsoft Windows Scripting Host documentation. waldekO Don Tuttle wrote in message news:HLkD6.3016$481.1337066 at typhoon.southeast.rr.com... > I can't believe that Python doesn't have the ability to create/edit Win32 > shortcuts (.lnk files). But after an hour of searching the archives and my > books I can't find anything at all. Would someone point me in the right > direction? > > Don > > > From sheila at spamcop.net Wed Apr 18 13:02:56 2001 From: sheila at spamcop.net (Sheila King) Date: Wed, 18 Apr 2001 17:02:56 GMT Subject: News client in Python? References: <9bkge2$ggc$0@216.39.170.247> Message-ID: <64irdtcjfmfq73fa8lvvmbe1gbmdukc4pf@4ax.com> On 18 Apr 2001 16:46:58 GMT, whisper at oz.net (Dave LeBlanc) wrote in comp.lang.python in article <9bkge2$ggc$0 at 216.39.170.247>: :Ugh... i've had it with Free Agent and all the spam kiddies i'd like :to make disappear. : :Is there a nice python implementation of a news reader? : :Dave LeBlanc I don't think there is a Python newsreader that has as advanced features as you are looking for. (I'd be happy to find out otherwise.) In the meantime, you might want to try Xnews: http://xnews.3dnews.net -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From brian at sweetapp.com Mon Apr 16 23:51:41 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Mon, 16 Apr 2001 20:51:41 -0700 Subject: Resuming in exception handling In-Reply-To: Message-ID: Just restructure your code: LWPath = 'C:\\LAND WARRIOR 1.0' flist = glob.glob( LWPath + '\\LW*.txt') for fname in flist: print 'removing ' + fname try: os.remove(fname) except OSError: print('skipping ' + fname) flist.remove(fname) -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Lucas Vogel Sent: Monday, April 16, 2001 8:12 PM To: python-list at python.org Subject: Resuming in exception handling -----BEGIN PGP SIGNED MESSAGE----- I want to resume the for statement in the chunk of code I am running in this (very simple) script. Here's what I have so far... import os, glob #place all LW*.txt files in list and kill them LWPath = 'C:\\LAND WARRIOR 1.0' try: flist = glob.glob( LWPath + '\\LW*.txt') for fname in flist: print 'removing ' + fname os.remove(fname) del flist except OSError: print('skipping ' + fname) flist.remove(fname) I get an OSError about a file permission on one of the files it tries to delete. When it gets that exception I want it to simply move on to the next file. How do I do that? Thanks =============================== Lucas Vogel -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use iQCVAwUBOtu0jClA8LjISNKLAQEfEgP+NhC1PQ2hysuxLPap764rdd/oVGhM0YGT Y44iwcHvi09uQhqu6+sgUu3ADYMdz4bXIRzteEdaI0wW9VjhHEXrCCFOuX6dfpEM bJNxSt0LBXYQJluBIq+o6AmDTkL5PLXCCeRBrmk0nxotDYej9+d39YKd/uN84kYA PcQNwV6AP5g= =xR4G -----END PGP SIGNATURE----- -- http://mail.python.org/mailman/listinfo/python-list From lac at cd.chalmers.se Fri Apr 13 10:16:39 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Fri, 13 Apr 2001 16:16:39 +0200 (MET DST) Subject: How do I make PmwTreeBrowse work Message-ID: <200104131416.QAA20623@boris.cd.chalmers.se> I am unclear what you mean by a Tree Browser, but Mark Lutz' Programming Python second edition comes with PyTree, a generic tree data structure viewer written in python with Tkinter. Trees are sketched as labels embedded in a canvas, connected by lines with arrows. (See page 1020-1033). Is this what you want? Laura Creighton lac at cd.chalmers.se From dsh8290 at rit.edu Wed Apr 18 17:34:22 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 18 Apr 2001 17:34:22 -0400 Subject: why python annoys me In-Reply-To: ; from loewis@informatik.hu-berlin.de on Wed, Apr 18, 2001 at 01:43:54PM +0200 References: <3ADCBECE.1BDFFCD@netplus.net> Message-ID: <20010418173422.F20005@harmony.cs.rit.edu> On Wed, Apr 18, 2001 at 01:43:54PM +0200, Martin von Loewis wrote: | neelk at alum.mit.edu (Neelakantan Krishnaswami) writes: | | > Hi Paul, I think I will have to disagree with you on this point. ints | > and arrays are not objects in Java, whereas the corresponding things | > in Python are. | | This is OT, but arrays in Java are objects. You create them with new, | they follow an inheritance hierarchy, can be polymorphically passed | where Object is allowed, and support introspection. They are objects (of a sort, more like a C struct IMO), but they do not inherit from java.lang.Object and thus can't be passed to a method that wants a java.lang.Object. Also where is the inheritance hierarchy for arrays you mentioned? -D From sill at localhost.kitenet.net Wed Apr 11 05:30:20 2001 From: sill at localhost.kitenet.net (rainy) Date: Wed, 11 Apr 2001 09:30:20 GMT Subject: ActiveState going the wrong way References: <3ad259bc.4612388@News.CIS.DFN.DE><3ad34fb4.1636258213@News.CIS.DFN.DE><20010410145336.A2614@harmony.cs.rit.edu><45m0b9.fem.ln@alltel.net> <9b11k301hob@news2.newsguy.com> Message-ID: On Wed, 11 Apr 2001 09:27:38 +0200, Alex Martelli wrote: >"Daniel Berlin" wrote in message >news:mailman.986967914.17053.python-list at python.org... > >""" >Maniac writes: >> I strongly disagree lack of autocompletion will in the short run (in your >> words lower productivity) but will also increase the skill of the >> programmer by forcing you to look up functions and other such stuff that >> you accidently store in your brain and you are EGAD "forced" to learn >> something that the next time you're coding you happen to remember the >> function. The process of "learning" can't be forgotten > >Whoops, sorry to blow your entire argument out of the water, but this >entire paragraph is pure bullshit. >""" > >Don't worry, the "we should eschew this helpful technology because >our minds would atrophize" brigade won't be deflected by any such >trifles as common sense, science, or realizing they're spewing BS. > >They've been at it since (first historically recorded case AFAIK) >the Druids repressed that newfangled invention, reading and writing, Even before that, IIRC. I remember some reference to an egyptian god (perhaps plato or some greek from that period wrote about this though) who basically said the same thing. >as it would damage people's abilities to memorize things if they >knew they could always look them up again (but I would not be >surprised to learn that there were some of them around earlier in >Lascaux, decrying this novel technology of painting -- how it >would damage the users' ability to actually recognize animals >to be hunted, if they got too familiar with the abstractions >involved in their painted forms, etc, etc...). > > >Alex > > > -- Andrei From mwh21 at cam.ac.uk Thu Apr 19 19:31:12 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 20 Apr 2001 00:31:12 +0100 Subject: Installed modules list? References: <3ADC2C39.F8C91811@schlund.de> Message-ID: Carsten Gaebler writes: > Is there a simple way of generating a list of all installed modules > or do I have to walk through all directories in sys.path? In general, in the presence of import hooks, you can't. In practice, you can have a good go at it. I can send you code if you want, 'tho it's not especially nice... Cheers, M. -- Well, yes. I don't think I'd put something like "penchant for anal play" and "able to wield a buttplug" in a CV unless it was relevant to the gig being applied for... -- Matt McLeod, alt.sysadmin.recovery From timo at alum.mit.edu Thu Apr 19 23:24:55 2001 From: timo at alum.mit.edu (Timothy O'Malley) Date: Thu, 19 Apr 2001 23:24:55 -0400 Subject: socket timing problem References: <3ADCE798.118B113D@mediaone.net> <180420012047095504%timo@alum.mit.edu> Message-ID: <190420012324550634%timo@alum.mit.edu> [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] hola. In article , David Bolen wrote: > I was wondering - how many Windows based systems are making use of > this? We've tried it once or twice briefly but had some problems and > held off until we had more time to look at it. I was very interested > in using it to apply timeouts to XMLRPC calls. I've not used it much under Windows, but other people seem to have. Periodically, I'll get comments or fixes from Windows developers. > example, she found that the handling of connect() under Windows wasn't > working since it returned a different result than the code expected if > you called connect() again after a non-blocking result. It must be that I just came back from vacation, but I'm confused by this sentence. What was the "non-blocking result"? Can you give me examples of the error. If I can get an example, I'll see what I can do to fix the problem. > The wierd thing was that the select that that was supposed to wait > until the connect succeeded (or a timeout) was just returning immediately, > even if it hadn't finished connecting to the target machine - then the > immediate retry of the connect() was what gave an invalid parameters > result. For two reasons, I think that the select() was doing the right thing. In both cases, they basically amount to the fact that you were already connected. 1- If you were indeed seeing the 10022 error code, I think this is the Windows error (correct me if I go astray) code for a socket that is already connected. It's the analog of EISCONN in the UNIX world. 2- The way timeoutsocket works, it could not impact the select() call's behavior in this regard. The select() routine uses the fileno() method of the object, and timeoutsocket does not define a fileno() method. Instead, timeoutsocket passes any undefined method access to the underlying socket object. > Anyway, I'm curious if there is anyone else using it successfully > under Windows (perhaps it's an NT thing)? Me too. From whisper at oz.net Sat Apr 14 15:40:39 2001 From: whisper at oz.net (Dave LeBlanc) Date: 14 Apr 2001 19:40:39 GMT Subject: First Python Script: Roman Numbers References: <9b6pqv$1seu$1@news.idiom.com> Message-ID: <9ba93n$8j5$0@216.39.170.247> Beer is not free, it's only rented ;-) On Fri, 13 Apr 2001 22:47:01 -0400, Mark Pilgrim wrote: >in article B6FD2AD3.56C1%f8dy at diveintopython.org, Mark Pilgrim at >f8dy at diveintopython.org wrote on 4/13/01 10:14 PM: >> You should also (shameless plug alert) >> check out my free-as-in-beer online book > >!@#$, I spend an hour writing a great example script, then flub the intro. >This should read "free-as-in-speech", not "free-as-in-beer". The book is >licensed under the GNU Free Documentation License. > >-M >You're smart; why haven't you learned Python yet? >http://diveintopython.org/ > > > From hannah at schlund.de Wed Apr 18 11:26:44 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 18 Apr 2001 17:26:44 +0200 Subject: Hygienic macros (was: do...until wisdom needed...) References: Message-ID: <9bkbnk$auv$1@c3po.schlund.de> Hello! In article , Douglas Alan wrote: >[...] >The problem with non-hygienic macros is that variable names used by the >macro implementation can conflict with variable names that are passed >into the macro. Hygienic macros solve this problem by putting the >variables in different namespaces. And you can fix this in Lisp too, using gensyms (uniquely generated symbols for the purpose of macro expansion), like this: (defmacro list2 (&rest elements) (let ((variable-names (mapcar #'(lambda (foo) (gensym)) elements))) `(let ,(mapcar #'(lambda (vname form) `(,vname ,form)) variable-names elements) (list ,@(loop for i in variable-names collect i collect i))))) (this doesn't really make much sense in reality, as you can just write a function (declaim (inline list2)) (defun list2 (&rest elements) (loop for i in elements collect i collect i)) but is to illustrate the avoiding of name capturing in Lisp macros). An advantage of that is that you *can* capture names if you intend to, such as in Lisp's loop macro, which locally defines a "loop-finish"- macro to abort the loop from inside. Something that can't be done IIRC with Schemes "hygienic macros". Kind regards, Hannah. PS: The gensym thing is often made easier with macros like with-gensyms in Lisp, so to write hygienic macros in Lisp isn't really much more difficult than in Scheme, and you can in fact program an emulation of Schemes define-syntax with CL's macro facility. From costas at meezon.com Wed Apr 25 16:01:49 2001 From: costas at meezon.com (costas at meezon.com) Date: Wed, 25 Apr 2001 20:01:49 GMT Subject: Creating commands with Python Message-ID: <3ae72c79.2937814018@News.CIS.DFN.DE> Is there a way in Python to define new keyworded commands. For example Python has the "import from" command. If not, why does Python have this inconsitent keyword based command? Thanks Costas From whisper at oz.nospamnet Sun Apr 29 23:46:01 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 30 Apr 2001 03:46:01 GMT Subject: newbie seeks inaccurate arithmetic insight References: <0v2H6.791$KM6.666348554@twister2.starband.net> Message-ID: <9cin5p$ioi$0@216.39.170.247> In article <0v2H6.791$KM6.666348554 at twister2.starband.net>, StanleyKrute at starband.net says... > Hi > > I just started on the Python learning path. > > I tried some calculator stuff, and got this > sort of result: > > http://static.userland.com/images/stanleydaily/pythonarithmetic.gif > > I searched the Tutorial at http://www.python.org/doc/current/tut/tut.html > and the Reference manual at http://www.python.org/doc/current/ref/ref.html > for some discussion of why simple decimal arithmetic > gives these sorts of inaccurate results. But I couldn't find anything. > > Can someone provide one or more URLs that > discuss the topic ?? > > Thanks > > Stan > > > Inacurate arithmetic isn't hard at all: just add (or subtract or multiply or divide) an additional number of your choice! Who WAS that masked man! From aleaxit at yahoo.com Fri Apr 20 09:59:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Apr 2001 15:59:32 +0200 Subject: If you want X, you know where to find it (was Re: do...until wisdom needed...) References: <9be84s0q12@news1.newsguy.com> <9bfjoc0cjh@news2.newsguy.com> <9bfq560noo@news2.newsguy.com> <9bhdd30ltt@news1.newsguy.com> <9bir7a$5vo$1@slb3.atl.mindspring.net> <9bjtbr02108@news1.newsguy.com> <9bl6i701e09@news1.newsguy.com> <9bmgid081b@news1.newsguy.com> <9bng2l019nb@news1.newsguy.com> Message-ID: <9bpfbu0284a@news1.newsguy.com> "Steve Holden" wrote in message news:OULD6.38441$uN3.797893 at e420r-atl1.usenetserver.com... [snip] > Doug, Alex: > > Perhaps you could put your dictionaries in touch by email and spare the rest > of us? Then we might get back to discussing *Python*! > > getting-a-little-bit-tired-of-it-all-ly y'rs - steve OK, OK. I'll skip the email part, but if sensible people like Steve are getting so tired of this thread to post messages such as this, I won't post in this thread any more unless there is some specific Python-related issue to be made. There -- happy now? Alex From philh at comuno.freeserve.co.uk Mon Apr 30 12:23:42 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 30 Apr 2001 17:23:42 +0100 Subject: Whither SmallScript? (was Re: Integer micro-benchmarks) References: <5bhG6.29435$qc2.7596549@typhoon.southeast.rr.com> Message-ID: On Mon, 30 Apr 2001 14:38:10 -0000, Andrew Hunt wrote: >> > class Foo < Bar >> > def myMethod >> > File.new ("test.dat", "w") { |f| >> > f.puts "Hello world!" >> > } >> > end >> > end >> >> What do the vertical bars around the f ("|f|") above indicate ? > >A local variable to the block, used to pass the parameter from File.new. > >> ( Maybe it's those extra non alphanumeric operator looking chars >> that make folks think of Perl -- even if they are used differently, >> to someone that doesn't read Ruby, it looks like more "line noise".) > >Doesn't Smalltalk use vertical bars as well? Yes. > I don't think that >qualifies as line noise. I find them rather aesthetically pleasing. > The @-prefix on instance variables might, Yuk. It's $one $of $the $things $I $dislike $about $Perl. And PHP, for that matter. -- *****[ Phil Hunt ***** philh at comuno.freeserve.co.uk ]***** "Mommy, make the nasty penguin go away." -- Jim Allchin, MS head of OS development, regarding open source software (paraphrased). From jwbaxter at olympus.net Tue Apr 17 02:27:45 2001 From: jwbaxter at olympus.net (John W. Baxter) Date: Mon, 16 Apr 2001 23:27:45 -0700 Subject: ANNOUNCE: A *second* Python 2.1 release candidate! References: Message-ID: <160420012327456092%jwbaxter@olympus.net> In article , Tim Peters wrote: > If not, I don't buy that it's because you've > been waiting since January to get Easter, Passover and taxes out of the way > . Tim leaves out the suicide of Emperor Otho (69AD), and Wilber Wright's birth (1867) and Charlie Chaplin's birth (1889). And that's just today's (Apr 16) celebrations, yesterday (besides Easter) there was the sinking of the Titanic to commemorate. And before that MLK birthday, and President's Day, and Mardi Gras, and so on, including the April 2, 1502 death of Prince Arthur, son of Henry VII, which cleared the way for Henry VIII later on. It's a wonder any software testing ever gets done. ;-) --John From just at letterror.com Wed Apr 25 10:50:22 2001 From: just at letterror.com (Just van Rossum) Date: Wed, 25 Apr 2001 16:50:22 +0200 Subject: Mac Python IDE Font Settings References: <01HW.B70C9B1B0001A7360EA3FB90@news.newsguy.com> Message-ID: <3AE6E42E.2F3418CE@letterror.com> Owen Ransen wrote: > > On my Mac the Python interactive Window is a bit small and the > text a bit hard to read. How can I increase the size of the font used > in the interactive Window. > > Neither Edit Default Settings nor Set Default Edit Font appear to > change the Python interactive Window font size... You have to look for the mysterious popup menu, that looks like an arrow, at the top right of the window. Just From michel at digicool.com Thu Apr 5 15:04:27 2001 From: michel at digicool.com (Michel Pelletier) Date: Thu, 5 Apr 2001 12:04:27 -0700 Subject: Pep 245 Message-ID: > I guess I should just give up my fight against PEP 245... It is clear > to me that either I am the only one who things that interfaces, at > least in the proposed form, are next to useless in Python, probably not the only one. > or those > who agree with me do not read the news group, or simply don't care > enough to reply. These behaviors of other people whom you've never met are "clear" to you? But this is beside the point, it's seems to me you're just venting, I'm not sure why. PEP 245 is just a proposal. Guido will accept it or reject based on its merits and comments from the community. Rest assured, I will cite your comments in the PEP when I post a new revision. > It is also obvious to me that there is serious > thrust for interface adoption coming from "Digital Creations"... (Do > new Guido's employers have a lot of say in the situation? I can > speculate that they do... but then again I don't know for sure.) Conspiracy theories this early in the morning? If you read PEP 245 you'll see that this idea has been in the works for over two years. Long before PL came to work for us. There was quite a bit of discussion in the types-sig archive from years back by Jim, Tim, PaulP, Guido, and many others. PEP 245 is not just some idea that I came up with, I didn't come up with it at all! I'm just championing it. As for DC having Python influence, well of course, but not the reasons that you speculate. The reason is we're probably the biggest large scale Python production system in existence. It's not because we pay Guido's salary. And it's certainly not because I'm "influencing" Guido, at IPC 9, he didn't even recognize me or remember my name. (Not at all his fault, of course, he's cannot be expected to remember the names of the thousands of people who use python even though he may want to, and he and I had only very briefly met once before as co-workers, and we have *never* worked together on any projects, interfaces or otherwise.) > One thing still bothers me -- Perl people will have a real reason to > laugh. Indeed, interfaces in a loosely typed language that supports > introspection -- that's a real joke! Please, is FUD how you're going to argue against this? -Michel From tim.one at home.com Sat Apr 14 18:54:51 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 14 Apr 2001 18:54:51 -0400 Subject: ANNOUNCE: A Python 2.1 release candidate! In-Reply-To: <3AD8A21D.34800DB9@home.com> Message-ID: [Don O'Donnell] > "informative prints", tracing function entries and exits, call it what > you will, it's all debugging to me. And I like to be able to: > 1. Turn it on and off at run time. > 2. Completely eliminate it from the compiled code when compiled with > optimization. As you showed later, you already know how to do this without assigning to __debug__. > ... > But while I'm testing (without the -O switch) I can use the __debug__ > variable as a dynamic run-time switch to turn debugging on and of at > will. Can only repeat that it was never intended that you be able to assign to __debug__: Guido views this change as fixing an old bug. Note that you use __xxx__ names at your own risk, in the absence of docs explicitly blessing the uses you make of them, and nothing in the docs said you could change __debug__'s value at runtime. The 2.1 docs explicitly say you cannot (as was always Guido's intent). > IT'S PERFECT, IT'S WONDERFUL, ITS JUST WHAT I WANT! WHY WOULD ANYONE > WANT TO CHANGE SUCH AN EXCELLENT DESIGN? Explained in the last reply. I understand you're not satisfied with the explanation, but that doesn't mean I'm hiding a better one that can only be coaxed into the open VIA SHOUTING . > ... > To have to write: > if __debug__: > if DEBUG: > print ... > seems awfully tedious. Then design and sell a better facility. Many have been suggested in the past, and __debug__ is a minimal gimmick that got in as part of the assert implementation. Here's Guido's original design note, in the midst of a long thread with *lots* of interesting suggestions: http://groups.yahoo.com/group/python-list/message/19647 > ... > It seems to me that removing such an excellent feature from the > language because it surprises some people is very wrong. You were using an undocumented accident that was never intended. To call this "removing a feature" is thus absurd in most senses, but quite understandable in the only sense you care about . I'm happy that Guido takes a larger view of it, though. > ... > A recent posting to this NG concerned the surprising effect of > extraneous commas in a list comprehension. But when studied carefully > in the light of the excellent Language Ref Manual, its behaviour was > exactly as expected. Are we to assume that this "surprising" > behaviour also needs to be "corrected" by changing the semantics of > the list comprehension. I sincerely hope not. I don't see a way to make time for it myself, but, yes, I'd like to tighten the *syntax* of listcomps here. The example was indeed very surprising, to both newbies and experts. That sucks. Note that the prototype listcomp implementation originally allowed stuff like [i, i for i in range(5)] too. That also made "exactly as expected" sense from a legalistic POV. But it's a strained view, and the syntax of listcomps was tightened to require parens around tuple targets. It's considerably clearer even to the experienced eye to force that one to be spelled: [(i, i) for i in range(5)] instead, and 2.0 does require that spelling. No functionality was lost. It would make similar good sense to require spelling [(i, i) for i in range(5),] as [(i, i) for i in (range(5),)] for those people who truly want the [([0, 1, 2, 3, 4], [0, 1, 2, 3, 4])] result. For everyone else, we've almost certainly changed a typo into a logic error by allowing the former spelling. Again, no functionality would be lost. > PLEASE DON'T DUMB DOWN PYTHON... IT'S SO BEAUTIFUL AS IT IS! Make it smarter, then, by reviving the debate about truly *good* debugging facilities. The __debug__ gimmick is minimal, feeble and hard to build on (esp. now that the implementation is changing to match its design). You seem to have a two-state "everything or nothing" notion of what constitutes good debugging support; over the long term I'll be glad if enforcing the read-only nature of __debug__ now irritates people enough to dream up richer mechanisms. I doubt Guido has that in mind, though. From steven at haryan.to Mon Apr 2 13:22:41 2001 From: steven at haryan.to (Steven Haryanto) Date: Tue, 03 Apr 2001 00:22:41 +0700 Subject: excluding unit test code Message-ID: <4.3.2.7.2.20010403002042.01afa7e8@202.53.255.51> Since an XP-faithful coder can write lots of test suites, is there a simple way to exclude these code in a module from the production code? Steve From be at mek.dtu.dk Fri Apr 6 06:15:31 2001 From: be at mek.dtu.dk (Brian Elmegaard) Date: Fri, 06 Apr 2001 12:15:31 +0200 Subject: Classes, OOP, Tkinter general comments and detailed questions... References: <3ACBADAC.C7843F96@earthlink.net> <3ACD5E97.D1BE3C06@mek.dtu.dk> <3ACC2621.2CE4DC83@earthlink.net> Message-ID: <3ACD9743.B3331109@mek.dtu.dk> Ron Stephens wrote: > > Thanks for your post. It definitely helps make me feel just a little bit less > stupid..Sometimes misery loves company ;-0))) Yes, but otoh the experts are in this group. And they seem to able to help you out of any kind of trouble. Also, the demos and source of tkinter and pmw may help you as examples. -- Brian http://www.et.dtu.dk/energysystems http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From phlip_cpp at my-deja.com Thu Apr 26 15:12:16 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Thu, 26 Apr 2001 12:12:16 -0700 Subject: Tkinter: Make them come back! Message-ID: <6u_F6.416$h22.63105@news.pacbell.net> Hypo nt: I want two top level windows, each with a label in it... from Tkinter import * top1 = Toplevel() lab1 = Label(top1, text='simple 1') lab1.pack() top2 = Toplevel() lab2 = Label(top2, text='simple 2') lab2.pack() mainloop() That gives us one big top level window with nothing in it, and two little windows each with a little label in it. >sigh< -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- All sensors report Patti having a very good time -- From sholden at holdenweb.com Mon Apr 16 12:30:01 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Apr 2001 12:30:01 -0400 Subject: Strange error with unbound method References: Message-ID: "Fernando Rodr?guez" wrote ... > Hi! > > I have a class called ParaStyle (see code below). This class has a > method called makeBlackAndWhite that returns a new instance of class > ParaStyle. > ...When activated as a callable using ParaStyle(), rather than being used as an object reference as in ParaStyle ... > I want to transform a list of ParaStyle instances into a list of the > result of applying the makeBlackAndWhite method of each instance. > > If I do: > paraStyles = map( ParaStyle.makeBlackAndWhite, paraStyles ) > > I get the following error: > TypeError: unbound method must be called with class instance 1st argument > That's because the map() call is the (approximate) equivalent on result = [] for p in paraStyles: result.append(ParaStyle.makeBlackAndWhite(p)) paraStyles = result In other words, the method doesn't know which instance it is supposed to be applied to because it's called as an *object method* and therefore note bound to any particular instance. > While if I do it with a for loop: > l = [] > for para in paraStyles: > l.append( para.makeBlackAndWhite() ) > > I dont get any error! =:-O > In this case, of course, you are implicitly providing an instance because makeBlackAndWhite is here called as an *instance mthod*, and so the instance is provided as a first argument to the call. > What's going on???? O:-) > The Python interpreter is doing its job! I'm sure other readers will be happy to supply you with a suitable map()-based implementation. I personally prefer the explicit solution you give as your second case. regards stEve [ code snipped ] From dalke at acm.org Sat Apr 21 18:46:24 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 21 Apr 2001 16:46:24 -0600 Subject: [Python-Dev] Class Methods References: <027401c0c9ab$5e3c88f0$e000a8c0@thomasnotebook> <15072.21064.298318.393753@slothrop.digicool.com> Message-ID: <9bt2l5$lt5$3@slb0.atl.mindspring.net> M.-A. Lemburg wrote: >Here's something to start the fight ;-) ... > >1) What would you do with class methods that you cannot do with > e.g. globals and functions ? One of the things I like about C++ is that it offers the ability to define your memory allocator for a class. This came in very handy for a system I wrote which used shared memory to pass data structures in a master/slave control struture. I am not proposing that this be added to Python. I've only needed such a feature once in the last 6 years. I instead mention it as something which is better done with class methods than with globals and functions. I believe this is the only thing in C++ which is class-function-like, but it's been a while since I got into the details of C++. Andrew dalke at acm.org From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Thu Apr 19 12:11:43 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Thu, 19 Apr 2001 16:11:43 GMT Subject: python on the smalltalk VM References: <9blgnh$2ro$1@nntp9.atl.mindspring.net> Message-ID: In article , "Chris Gonnerman" wrote: > ----- Original Message ----- > From: "Andrew Dalke" > Subject: python on the smalltalk VM > > > > http://www.smalltalkconsulting.com/html/SmalltalkSolutions2001%232.html > > This URL appears dead to me... is there an alternate location? I don't have a problem loading the URL Here is a snippet from that page: After the break I attended the Building COM and .NET in SmallScript ? by David Simmons for a few minutes About 70 people in attendence. Standing room only. David talked about his Smallscript goals, he then launched into an explanation of how Smallscript is build by showing us the source code. If you were a Microsoft developer this would have been very interesting, and it is interesting to see how it all interfaced to the existing MS framework for development. David's take is that Smalltalk is built wrong for scripting, it has a monolithic image. It really should be a bunch of Smalltalk pieces. Smallscript isn't a Smalltalk traditional image. It's the best features of the language but changed for doing scripting. SmallScript is small, it is free, it's not an IDE. It's a compiler and execution engine. Someone else needs to build an IDE and frameworks, QKS may build a simple IDE but these aren't an important part of their research. Smallscript like all scripting languages is text based just tackle it with your emac editor. Someone asked what is the revenue model for QKS? It's not tools (We all know that today, look around how many tools companies are there?) Consulting is a big part Microsoft is a big part. Python is a big part for the execution engine, this is a new area. The Smalltalk VM runs Python 10 to 100x faster. {JMM I should point out the Perl and Python folks are working toward having/wanting/needing a universal VM} SmallScript is subset of Smalltalk dialects, not of the frameworks. You can migrate frameworks, and it has a lot of features for foreign function interoperability. David then moved on within his slides and talked about the files you need to support Smallscript. The point being there are only a few small files required. He then brought up the VisualStudio project for building this and explained how the VM starts and worked us thru what happens when the VM launches. The execution path is very short and took about 85ms on this machine, thus 12 executions a second. A more optimized VM, this was a test VM, would run faster. However David pointed out on a heavier loaded machine you could have at least a 30ms variation in startup times because of system load. But the key point here was that you can run a lot of individual scripts per second if required. Later at lunch David pointed out that perhaps it wasn't clear in the presentation that the entire image is built from the class definitions at startup, there is NO image. It's all built from the definitions really really fast. On termination a module can decide if it must save a persistent state, which could be loaded on restarting. In fact If I recall correctly he say that a rather large smalltalk image would be built by the engine in less than 6 seconds. From nothing to a known state on each startup, this is a important concept. On-ware to DLL hell, well maybe not. .Net get out of this problem domain. Components are self describing and have versioning which allows you to resolve all the requirements to run an application and to move things around without harming the application. Smallscript allows you to build small DLLS which are compiled very quickly. Smallscript takes the strengths of Smalltalk, it's a simple grammar it's untyped. And it's easy to refactor and change versus C or C++. In Smalltalk it was hard to deal with the outside, handing a Smalltalk object to an external DLL is/was an adventure. In .Net it just gets passed, no wrapping or marshalling etc. Alas at this point I had an errand to run. -- From fredrik at pythonware.com Tue Apr 17 14:37:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 17 Apr 2001 18:37:46 GMT Subject: do...until wisdom found... References: <3ADC6F1F.DE1A2FB1@mentor.com> Message-ID: <_30D6.5094$sk3.1505071@newsb.telia.net> Dennis Baker wrote > ) while 1: > ) set up for this cycle > ) if c: break > ) whatever needs to be done > > That's a product of poor design. I consider it a failure to > resort to this sort of construct. since your comment makes no sense at all to me, maybe you could elaborate? Cheers /F From alex at shindich.com Sun Apr 15 03:46:11 2001 From: alex at shindich.com (Alex Shindich) Date: Sun, 15 Apr 2001 00:46:11 -0700 Subject: A few words about Python interfaces References: <5.0.2.1.0.20010412125219.0227a050@mail.inet.com.br> <5.0.2.1.0.20010414132039.022e0c50@mail.inet.com.br> Message-ID: <3AD951C3.159960BD@shindich.com> Carlos Ribeiro wrote: > > At 01:03 14/04/01 -0700, Alex Shindich wrote: > >If I understood you correctly, you propose to check interface meta-data > >at run time. While this might be acceptable for may applications, some > >applications may not be able to wait for it. The interface documentation > >in my mind is meant for the developers rather than programs. Although > >XML was meant to be read by programs.. Go figure ;) > > PEP 245 does not specify any means to check interfaces, either at compile > or run time. PEPE246 does it, by means of adapters. The problem is that > adapters may turn out to be a very popular idiom, and one that is not very > efficient, given the way the check is going to be done - by means of > (sometimes extensive) run time analysis of the objects given as parameters. > > >I do not think that code that uses explicit interfaces is going to look > >worse then code that makes use of implicit interfaces. My fear is that > >addition of explicit interfaces is going to introduce many Java-like > >idioms into Python. > > So we share a very similar fear :-) I have nothing against Java-like > idioms, except by the fact that adapters are going to be evaluated at run > time, and the cost of this operation may be prohibitive. I agree. I think that bi-directional adapters are wonderful when they are not being pushed down everyone's throat. > >(...) Although I still do not understand WHY > >Python needs to deal with any of that? > > The interfaces proposal (PEP245) is being lead by Digital Creations. I see > the reason behind their commitment, as they have to deal with a much more > complex environment than other software developers. Zope is a very flexible > framework, and keeps being extended by its users. Having some way to use > interfaces (instead of relying on inheritance) is a big win for frameworks > like Zope. It adds flexibility while keeping some control at Digital > Creations, as they may specify formal interfaces for their framework. Zope > users will only need to follow the interface specification, without any > need to derive objects out of Zope base classes. Zope can come with documentation on what methods should be implemented for Zope-compatible components, and users would be able to create such components even today. Also, Zope can provide a bunch of classes like: class MyZopeInterface: """""" def myZopeMethod (self, a, b, c): """The docs go here...""" raise MyZopeException, "Method 'MyZopeMethod' is not implemented" ... What's the big deal if users had to inherit from those classes? Regards, Alex Shindich mailto:alex at shindich.com Visit http://www.shindich.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: alex.vcf Type: text/x-vcard Size: 194 bytes Desc: Card for Alex Shindich URL: From dhumphrey at pdqdot.net Thu Apr 5 13:58:39 2001 From: dhumphrey at pdqdot.net (David Humphrey) Date: Thu, 5 Apr 2001 12:58:39 -0500 Subject: problem executing python scripts in cygwin bash shell Message-ID: <69AD80E50414598C.875157435733CF34.B50964BA627F4825@lp.airnews.net> I'm sure this one has been answered before, but I couldn't find the solution in any of the newgroups, so here goes again. I can run bash scripts that are in the path but not python scripts. Each script has the appropriate (I think) #! declaration on the first line. Here's a short record of my tests: $ pwd /home/administrator $ echo $PATH /usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/c ygdrive/c/BGIUtils:/cygdrive/d/Utils/Python20/:/cygdrive/d/Utils/ULTRAE~1:/c ygdrive/d/Utils/Perl/bin/:/cygdrive/d/dlh/bin:. $ ls -al /usr/local/bin total 1 drwxr-xr-x 2 administ None 0 Jan 10 16:01 . drwxr-xr-x 5 administ None 0 Jan 10 16:01 .. -rwxr-xr-x 1 administ None 59 Apr 5 11:35 test.sh -rwxr-xr-x 1 administ None 77 Apr 5 11:34 test1.py -rwxr-xr-x 1 administ None 92 Apr 5 11:39 test2.py $ cat /usr/local/bin/test.sh #!/usr/bin/bash echo "Hello, World (from the bash script)" $ cat /usr/local/bin/test1.py #!d:/Utils/python20/python.exe print "Hello, World (from the python script)" $ cat /usr/local/bin/test2.py #!/cygdrive/d/Utils/python20/python.exe print "Hello, World (from the python test2 script)" $ test.sh Hello, World (from the bash script) $ test1.py d:\Utils\python20\python.exe: can't open file '/usr/local/bin/test1.py' $ test2.py d:\Utils\python20\python.exe: can't open file '/usr/local/bin/test2.py' $ >From this, I infer that cygwin bash understands the #! notation properly, so I must have a problem with paths or some other configuration parameter. Also, I've run these same tests with c:\ instead of /cygdrive/c and d:\ instead of /cygdrive/d. Has someone out there been successful doing this? Configuration details: Windows NT 4.0 GNU bash, version 2.04.5(12)-release (i686-pc-cygwin) ActiveState Python 2.0.3 Regards, David L. Humphrey Manager, Software Development Bell Geospace, Inc From cribeiro at mail.inet.com.br Wed Apr 25 07:25:41 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Wed, 25 Apr 2001 08:25:41 -0300 Subject: idioms for abstract base classes In-Reply-To: Message-ID: <5.0.2.1.0.20010425082225.0238caf0@mail.inet.com.br> At 13:18 24/04/01 -0700, zooko at zooko.com wrote: >Eventually, we started just undoing the inheritance -- I changed >CryptoCommsHandler to just implement all of its methods instead of using >any of >the ones inherited from BaseCommsHandler, and next time I touch >TCPCommsHandler >I'll do the same to it. Then we can nuke DummyCommsHandler (which is only >good >for testing the unused "chaining" feature anyway) and CommsHandler and >BaseCommsHandler. It will feel really good to get rid of those after all the >trouble they've caused. This is the kind of problem that could be solved with interfaces. We had a lot of discussions on that, and the PEPs are still pending. The discussion is (as far as I recall) if Python needs some explicit support for interfaces. Some people feel that we can use interfaces nicely in Python today, just by documenting it carefully, and using the dynamic nature of the language. You are not trapped by a rigid hierarchy; object similarities are handled through their support of interfaces, instead of using inheritance. Carlos Ribeiro From olczyk at interaccess.com Wed Apr 4 04:25:25 2001 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Wed, 04 Apr 2001 08:25:25 GMT Subject: ActiveState Ruby? References: Message-ID: <3aca9899.96034343@nntp.interaccess.com> On Sun, 01 Apr 2001 15:00:08 GMT, "Daniel Berger" wrote: > I think one of the reasons for Python's >growing popularity is the fact that ActiveState has a Python distribution >(the other reason being O'Reilly). Hi. Just passing through and thought I would clear up some misapprehensions about Python. Anyone who thinks that ActiveState has played a major role in Python's growth has their head up their ass. The growth in Python took off at least a half year before ActiveState produced anything ( most linux distro still distribute 1.x versions ActiveState didn't release anything untill 2.0 ). After 2.0 the distribution on python.org was available. There was a short time when the BeOpen site was down, and the only place to find the latest version of python was at ActiveState and most downloads came from there. Otherwise it just seemed more convinient to download BeOpen's version. Plus if BeOpens version disagreed with ActiveStates on a point, who do you think would have the correct version? From fredrik at pythonware.com Wed Apr 18 14:20:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 18 Apr 2001 18:20:13 GMT Subject: I need to convert PNG images to JPG..can python help References: Message-ID: Chris Richard Adams wrote: > I've been using ImageMagick on Linux to convert images from PNG to JPG, > but now need to include that code in a python script. My options are to > somehow figure out how do call imagemagick's 'convert' from a python > script or to use a library/module within python. Anyone have an > tips/advice? import os os.system("convert ...") or, using PIL (http://www.pythonware.com/products/pil): import Image im = Image.open("infile.png") im.save("outfile.jpg") Cheers /F From e_tsang at trillium.com Sun Apr 22 13:03:30 2001 From: e_tsang at trillium.com (Tsang, Edward1) Date: Sun, 22 Apr 2001 10:03:30 -0700 Subject: Using cPickle, pickle or marshal to preserve attribute values of a class instance Message-ID: Well I have tried that alreaydand found out that pickle raised an PickleErro exception on pickling tkapp :( I have actually included the code segment for your reference.. the variables that hold the states that I want to preserve are marked by # state I want to preserve and # end of state want to preserve They are in the self.init function of Class Gui. andthe lines what I inserted the pickle is also marked by #pickle insertion comment lines ... they are in the main function at end of file. what should I do , any suggestion ... I am not thinking should I pull those states out into a seperate class that Class gui could read, and I pickle the state class instead??? Thanks Code attached: from Tkinter import * from tkFileDialog import * from Dialog import Dialog import re import string import time import os import stat import math # to preserve class instance attributes import pickle def makeMenu(gui): # make menu button : "File" File_button = Menubutton(gui.menuframe, text='File', underline=0) File_button.grid(row=0, column=0, sticky=W) tempText = Text() color = tempText.cget('background') Dummy_button = Menubutton(gui.menuframe, width=63, activebackground=color, highlightcolor='Blue',text='', underline=0) Dummy_button.grid(row=0, column=1, sticky=W) Dummy_button.menu = Menu(Dummy_button) File_button.menu = Menu(File_button) File_button.menu.add_command(label='Open Test Log ...', underline=0, command=gui.openfile) File_button.menu.add_command(label='Save Message Sequence Chart...', underline=0, command=gui.save) File_button.menu.add('separator') File_button.menu.add_command(label='Quit', underline=0, command=gui.quit) File_button['menu'] = File_button.menu gui.menuframe.tk_menuBar(File_button, Dummy_button) def getTabs(line): num=0 for char in line: if (char != '\t'): break num=num+1 return(num) class Gui: def __init__(self, master, img): self.master = master; # define each frame # main frame is at the very top # button frame is the command button frame # list frame is used for all of the list boxes # quit frame is used for the quit button self.headerframe = Frame(self.master, width = 80) self.headerframe.grid(row=0, column=0, sticky='W') self.menuframe = Frame(self.headerframe, relief=RAISED, borderwidth=2, width = 80) self.menuframe.grid(row=0, column=0, sticky='W') makeMenu(self) self.logoframe = Frame(self.headerframe, width = 80) self.logoframe.grid(row=0, column=0, sticky='E') # column affects locaton of logo self.buttonframe = Frame(self.master, width = 80) self.buttonframe.grid(row=1, column=0, sticky='W') self.octetframe = Frame(self.master, width = 80) self.octetframe.grid(row=2, column=0, sticky='W') self.octetframe2 = Frame(self.master, width = 5) self.octetframe2.grid(row=80, column=0, sticky='W') self.listFrame = Frame(self.master, width = 80) self.groupsList = Frame(self.listFrame, width = 50) self.groupsList.grid(row=0, column=0, sticky=N) # state I want to preserve self.inputName = StringVar() self.outputName = StringVar() self.inputName.set("") self.outputName.set("") self.inputFileList = [] self.outputFileList = [] self.stackname = StringVar() self.stackname.set("") self.name = StringVar() self.iut = StringVar() self.name.set("") self.iut.set("") # define all buttons self.type = IntVar() self.counter = IntVar() # end of state I want to preserve self.ie = Checkbutton(self.buttonframe, text="Build ALL ", variable=self.type, onvalue = 1, offvalue =0) self.ie.pack() self.ie.grid(row=0, column=1, pady=10, sticky=W) self.build = Button(self.buttonframe, text="Build", command=self.buildMSC) self.build.grid(row=0, column=3) self.clear = Button(self.buttonframe, text="Clear", command=self.clear) self.clear.grid(row=0, column=4) # define all labels Label(self.logoframe, image=img).grid(row=0,column=4,sticky=E) # define all listboxes self.pdudfn = Text(self.octetframe, font='*-Courier-Bold-R-Normal-*-120-*', height=20, width=80) self.pdudfn.grid(row=0, column=0, sticky=W) self.pdudfn.tag_config('HIGHLIGHT', background="White") self.pdubuild = Text(self.octetframe2, font='*-Courier-Bold-R-Normal-*-120-*', height=5, width=80) self.pdubuild.grid(row=0, column=0, sticky=W) self.pdubuild.tag_config('HIGHLIGHT', background="White") # define all scrollbars self.pdudfn.scrollY = Scrollbar(self.octetframe, orient=VERTICAL) self.pdudfn['yscrollcommand'] = self.pdudfn.scrollY.set self.pdudfn.scrollY['command'] = self.pdudfn.yview self.pdudfn.scrollY.grid(row=0, column=1,sticky='NS') self.pdubuild.scrollY = Scrollbar(self.octetframe2, orient=VERTICAL) self.pdubuild['yscrollcommand'] = self.pdubuild.scrollY.set self.pdubuild.scrollY['command'] = self.pdubuild.yview self.pdubuild.scrollY.grid(row=0, column=1,sticky='NS') def buildMSC(self): value = self.type.get() if value == 1: self.buildAllMsc() self.saveArrows() def clear(self): self.pdubuild['state']=NORMAL self.pdubuild.delete("0.0", END) self.pdudfn.delete("0.0", END) self.pdubuild['state']=DISABLED filename = self.outputName.get() try: self.fd = open(filename,"w") except IOError: Dialog(self.master, text="Cannot open file to clear.", title="Error", bitmap='error', default=0, strings=('OK',)) return self.fd.close() def save(self, event=None): defaultfile = self.inputName.get() if self.type.get() == 1: Dialog(self.master, text="Application is under auto mode. File names are self generated.", title="Error", bitmap='error', default=0, strings=('OK',)) return outputName = asksaveasfilename(defaultextension=".arr", filetypes=["{Message Sequence Chart} {.arr}"], initialfile="%s.arr"%defaultfile ) self.outputName.set(outputName) try: self.fd=open(outputName,"w"); self.fd.close(); except IOError: Dialog(self.master, text="Cannot open file to save.", title="Error", bitmap='error', default=0, strings=('OK',)) except: pass def buildFileList(self,arg,dirname,files): inputfile = self.inputName.get() if inputfile == "": return inputfile = os.path.basename(inputfile) for file in files: if re.search(inputfile,file): fullpath= os.path.join(dirname, file) if fullpath[-4:] == '.arr': pass else: self.inputFileList.append(fullpath) self.outputFileList.append(fullpath+'.arr') self.inputFileList.sort() self.outputFileList.sort() def openfile(self, event=None): try: inputName = askopenfilename(filetypes=["{Test Log Files} {*}"]) if inputName == "": Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return self.inputName.set(inputName) self.inputFileList.append(inputName) outputName = inputName + '.arr' self.outputName.set(outputName) self.outputFileList.append(self.outputName) except: Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return def quit(self, event=None): self.menuframe.quit() def ctfPrint(self,string): if self.outputName.get() == "": self.save() #Open file and append string fd = open(self.outputName.get(),"a+") fd.write(string) self.pdudfn.insert(END, string) #Close file fd.close() def createTestList(self): line = None inputfile = self.inputName.get() try: fd = open(inputfile, 'r') except IOError: Dialog(self.master, text="Cannot open file", title="Error", bitmap='error', default=0, strings=('OK',)) return # display status to stdout and status window stateString = "\nBuild MSC for %s"%inputfile print stateString self.pdubuild.insert(END, stateString) trclist = fd.readlines() strip = string.strip for x in range(0,len(trclist)): trclist[x]=strip(trclist[x]) fd.close() idx = 0 counter = 0 tstlist = [] for line in trclist: if line == "": # skip blank line continue if line[0] == "-": counter = counter+1 if counter == 1: tstlist.append([]) if counter > 0: tstlist[idx].append(line) if counter == 4: idx = idx + 1 counter = 0 return tstlist def getData(self): self.name.get() self.iut.get() self.inputWindow.destroy() def stackData(self): self.inputWindow = Toplevel(self.master) self.inputWindow.geometry("+%d+%d" % (self.master.winfo_rootx()+180, self.master.winfo_rooty()+180)) self.inputWindow.title("Enter stack data") Label(self.inputWindow, text ="Please enter the 2 letter prefix for each stack seperated by a space.").grid(row=1, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text = "There must be a minimum of 2 stacks and a maximum of 5.").grid(row=2, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text = "The second entry is the IUT i.e Xx Yy Zz").grid(row=3, columnspan=2, pady=2, sticky=W) Label(self.inputWindow, text="Stack Names:").grid(row=4, sticky=W) self.e1 = Entry(self.inputWindow, textvariable=self.stackname, width=35) self.e1.grid(row=4, column=1, sticky="EW", pady=1) okButton = Button(self.inputWindow, text="Ok", command=self.getData) okButton.grid(row=5, column=1, sticky=W, pady=6) self.inputWindow.wait_window() def buildAllMsc(self): index = 0 listDir = os.getcwd() os.path.walk(listDir,self.buildFileList,None) if self.inputFileList != []: for file in self.inputFileList: self.inputName.set(file) self.outputName.set(self.outputFileList[index]) self.saveArrows() index = index +1 self.master.update() self.pdubuild.insert(END, "Processing Completed") else: Dialog(self.master, text="Input Log File name must be specified to produce arrow diagrams", title="Error", bitmap='error', default=0, strings=('OK',)) return def saveArrows(self): tstList = None temp = None stackList = {} numStacks = None upper = 0 lower = 0 mngmt = 0 other = 0 columnWidth = None emptySpace = None arrowLine = None stack = None emptyLine = None space = "" stacknames = "" upperTx = None upperRx = None lowerTx = None lowerRx = None mngmtTx = None mngmtRx = None otherTx = None otherRx = None lowerFunction = None upperFunction = None mngmtFunction = None otherFunction = None test = None testList = None event = None eventList = None line = None function = None if self.outputName == "": save() tstList = self.createTestList() if tstList == None: return temp = self.stackname.get() # first time invoked if self.counter.get() == 0: self.stackData() temp = self.stackname.get() self.counter.set(1) # this is no the first run, stackname should be stored already temp = self.stackname.get() if temp == "": return # clear msc window self.pdudfn.delete("0.0", END) stackList = string.split(temp) numStacks = len(stackList) upper = 0 lower = 0 mngmt = 0 other = 0 if numStacks > 2: lower = 2 if numStacks > 3: mngmt = 3 if numStacks > 4: other = 4 columnWidth = 70/(numStacks-1) emptySpace = " "*columnWidth arrowLine = "-"*(columnWidth-1) stack = "|%s"%emptySpace emptyLine = stack*(numStacks-1) + "|\n" space = "" stacknames = "" for name in stackList: stacknames = stacknames + space + name space = " "*(columnWidth - len(name)+1) # Arrow for event travels from upper stack to the right? upperTx = "|%s>"%arrowLine + stack*(numStacks-2) + "|\n" upperRx = "|<%s"%arrowLine + stack*(numStacks-2) + "|\n" upperFunction = "|%s" + stack*(numStacks-2) + "|\n" lowerTx = stack + "|<%s"%arrowLine + stack*(numStacks-3) + "|\n" lowerRx = stack + "|%s>"%arrowLine + stack*(numStacks-3) + "|\n" lowerFunction = stack + "|%s" + stack*(numStacks-3) + "|\n" mngmtTx = stack + "|<--%s"%(arrowLine*2) + stack*(numStacks-4) +"|\n" mngmtRx = stack + "|%s-->"%(arrowLine*2) + stack*(numStacks-4) +"|\n" mngmtFunction = stack + "|%s" + stack*(numStacks-4) + "|\n" otherTx = stack + "|<----%s"%(arrowLine*3) + stack*(numStacks-5) +"|\n" otherRx = stack + "|%s---->"%(arrowLine*3) + stack*(numStacks-5) +"|\n" otherFunction = stack+ "|%s" + stack*(numStacks-5) +"|\n" split = string.split strip = string.strip search = re.search linecounter = 0 for test in tstList: evntsList = [] if linecounter < 1: self.ctfPrint(stacknames + "\n") linecounter = linecounter +1 isFunction = FALSE for line in test: if ((search( "CallFunc", line) != None) or (search( "@event@", line) != None)): wordList = split(line) for word in wordList : if isFunction == TRUE : print "Found a primitive: %s"%word newLine = "Transmit : " + word evntsList.append(newLine) isFunction = FALSE break if word == "CallFunc": isFunction = TRUE if (search("@event@", word)) != None : word = re.sub("@event@", "", word) print "Found an event: %s"%word newLine = "Received : " + word evntsList.append(newLine) break for event in evntsList: function = split(event)[2] extra_info = split(event, function)[1] extra_info = strip(extra_info) if event[0:8] == "Transmit": if event[14:16] == stackList[upper]: function = function + " "*(columnWidth-len(function)) extra_info = extra_info + " "*(columnWidth-len(extra_info)) self.ctfPrint(upperTx) self.ctfPrint(upperFunction%function) self.ctfPrint(upperFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[lower]: function = " "*(columnWidth-len(function)) + function extra_info = " "*(columnWidth-len(extra_info)) + extra_info self.ctfPrint(lowerTx) self.ctfPrint(lowerFunction%function) self.ctfPrint(lowerFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[mngmt]: function = emptySpace + "|" +" "*(columnWidth-len(function)) + function extra_info = emptySpace + "|" +" "*(columnWidth-len(extra_info)) + extra_info self.ctfPrint(mngmtTx) self.ctfPrint(mngmtFunction%function) self.ctfPrint(mngmtFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[other]: function = (emptySpace + "|")*2 +" "*(columnWidth-len(function)) + function extra_info = (emptySpace + "|")*2 +" "*(columnWidth-len(extra_info)) + extra_info self.ctfPrint(otherTx) self.ctfPrint(otherFunction%function) self.ctfPrint(otherFunction%extra_info) self.ctfPrint(emptyLine) elif event[0:8] == "Received": if event[14:16] == stackList[upper]: function = function + " "*(columnWidth-len(function)) extra_info = extra_info + " "*(columnWidth-len(extra_info)) self.ctfPrint(upperTx) self.ctfPrint(upperFunction%function) self.ctfPrint(upperFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[lower]: function = " "*(columnWidth-len(function)) + function extra_info = " "*(columnWidth-len(extra_info)) + extra_info self.ctfPrint(lowerTx) self.ctfPrint(lowerFunction%function) self.ctfPrint(lowerFunction%extra_info) self.ctfPrint(emptyLine) elif event[14:16] == stackList[mngmt]: function = function + " "*(columnWidth-len(function)) + stack self.ctfPrint(mngmtRx) self.ctfPrint(mngmtFunction%function) self.ctfPrint(emptyLine) elif event[14:16] == stackList[other]: function = function + " "*(columnWidth-len(function)) + stack*2 self.ctfPrint(otherRx) self.ctfPrint(otherFunction%function) self.ctfPrint(emptyLine) self.ctfPrint("hor \n") # Main function, run as a standalone program def main(): sep = os.sep print "Loading \n" root = Tk() tharnbase = os.environ['THARN'] img = PhotoImage(file=tharnbase+sep+'modules'+sep+'gui'+sep+'trillium.gif') try: # depersist and display an object gui = pickle.load(open("msc.dat","rb")) except: # invoke the first time gui = Gui(root,img) root.protocol('WM_DELETE_WINDOW', root.quit) root.title("TRILLIUM MSC Builder") root.iconname("MSCBld") root.mainloop() # persist and dump object attributes. pickle.dump(gui, open("flup.dat","wb")) if __name__ == '__main__': main() -----Original Message----- From: Gabriel Ambuehl [mailto:gabriel_ambuehl at buz.ch] Sent: Sunday, April 22, 2001 9:47 AM To: Tsang, Edward1 Cc: python-list at python.org Subject: Re[2]: Using cPickle, pickle or marshal to preserve attribute values of a class instance -----BEGIN PGP SIGNED MESSAGE----- Hello Edward1, Sunday, April 22, 2001, 6:19:47 PM, you wrote: > double check on the python I am using , the sys admin has not installed the > whole standard python 1.5.1. cPickle and pickle are oth missing only > marshall .... he told me he did no install any modules that are system > dependent (OS) ?!?! pickle should work if you copy the module into the dir with your app. Cpickle needs to be compiled on the same platform as the app will run, so this is probably not possible. Best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.0.2i iQEVAwUBOuL86sZa2WpymlDxAQEk6wf8COSWTpydUSuoo6f/cpH5JyV6L/ZjeaAd Rz55E6VWptk147H/kEK84NTyQHKUeHu042n/J8n0kMxEg5nDSmymTEMXxOd3JMpX QZGnJZbbaEfeiyeRNSn1b6DGJhnY2obJFwyQCyg+OYo099qNAfrV6Ubk8El5soH6 NhHosVR9Hv1sTBjAYbWC3DiL6nlpGb3koKZJExTVF6mw2z6nWgsdgtXwst3mVWNj /E0qwZc0fEunJolyoxBZjTx/uUbR/Km2LRYVKn+yFHZ1KZgIB3wRqn8xpqX021nn 52BhTH3VEJqrSzH14lsospFVbiOxKEszKeNkdXrZvqW5/wEobuC5wA== =4oJK -----END PGP SIGNATURE----- From cce at clarkevans.com Thu Apr 5 00:12:04 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Wed, 4 Apr 2001 23:12:04 -0500 (EST) Subject: PEP 245 In-Reply-To: <5.0.2.1.0.20010405000921.021c9ec0@mail.inet.com.br> Message-ID: > This is my own experiment with adapters and interfaces. I could not join > the SourceForge project, and I dont know how things are being implemented > right now. Use as you wish (even as a example of don't-do-this ). The current source code is at http://adapt.sourceforge.net/adapt.py you shouldn't need a IE browser to access this. Also, the PEP is at http://python.sourceforge.net/peps/pep-0246.html > >>> for i in f.__adapt__(I1_Sequence): print i > ... > 1 > 2 > 3 > 4 Ok. According to the PEP, you could write this as: import adapt from adapt for i in adapt(f,I1_Sequence): print i And then, in your FakeSequence, you should use __conform__ instead of __adapt__ (__adapt__ is used in the protocol) > def __adapt__(self, protocol): > if protocol == I1_Sequence: > return MakeInterfaceAdapter_V1(protocol, self, self.ir_sequence) > elif protocol == I2_Sequence: > return MakeInterfaceAdapter_V2(protocol, self, self.ir_sequence) > else: > return None Let's say you are now introducing an I3_Sequence, and FakeSequence is already fixed and distributed to too many clients to be resonably changeable. You can give the I3_Sequence class an __adapt__ method which knows about FakeSequence and returns the appropriate adapter. This is the bi-directional part... ;) Clark From gerhard.nospam at bigfoot.de Thu Apr 5 07:20:37 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 05 Apr 2001 13:20:37 +0200 Subject: unable to install MySQLdb (version 0.3.5 ) using ActivePython (build 203) on Win 98 References: Message-ID: <3ACC5505.4F407778@bigfoot.de> robin and jim wrote: > > Hello, > > I just downloaded the 2001-03-28 build of MySQLdb (version 0.3.5 ) from > http://home.t-online.de/home/err666/ (thanks Gerhard!) and issued the > command: > > python setup.py install > > using ActivePython (build 203) on a Windows 98 (2nd edition) computer. > > Below is the result. Any suggestions about what I'm doing wrong. Thanks. > > [... snipped, actual exception follows:] > > File "c:\python20\lib\distutils\core.py", line 138, in setup > dist.run_commands() > File "c:\python20\lib\distutils\dist.py", line 829, in run_commands > self.run_command(cmd) > File "c:\python20\lib\distutils\dist.py", line 849, in run_command > cmd_obj.run() > File "c:\python20\lib\distutils\command\install.py", line 483, in run > self.run_command(cmd_name) > File "c:\python20\lib\distutils\cmd.py", line 328, in run_command > self.distribution.run_command(command) > File "c:\python20\lib\distutils\dist.py", line 849, in run_command > cmd_obj.run() > File "c:\python20\lib\distutils\command\install_lib.py", line 93, in run > self.byte_compile(outfiles) > File "c:\python20\lib\distutils\command\install_lib.py", line 130, in > byte_com > pile > verbose=self.verbose, dry_run=self.dry_run) > File "c:\python20\lib\distutils\util.py", line 423, in byte_compile > compile(file, cfile, dfile) > File "c:\python20\lib\py_compile.py", line 60, in compile > codeobject = __builtin__.compile(codestring, dfile or file, 'exec') > TypeError: compile, argument 1: expected string without null bytes, string > found I am sorry, but I don't know what's happening here. I just confirmed that it really works under my configuration (ActivePython build 202, Windows 2000 SP 1 en). Maybe downloading the file again will help. Maybe reverting to build 202 will, though if it build 203 is still Python 2.0, it shouldn't matter. Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From ddublanc at free.fr Thu Apr 12 16:07:05 2001 From: ddublanc at free.fr (Dublanc, David) Date: Thu, 12 Apr 2001 20:07:05 GMT Subject: Problem with win32api function Message-ID: I have a problem with the fonction win32file.GetDiskFreeSpace The maximum number of space is : 65536 bytes. So if the hard disk capacity is > 2 Go, the function returns a wrong result. Do you have solution for this problem ? Thanks. -- David From news at myNOSPAM.org Mon Apr 23 15:16:29 2001 From: news at myNOSPAM.org (Stephen Hansen) Date: Mon, 23 Apr 2001 19:16:29 GMT Subject: Python + Borland - msvcrt = grr. References: Message-ID: Hello, I'm wondering what compilers that you are aware of would throw such a warning after something related to the following code. Borland is complaining rather loudly (in the order of 200+ warnings, although some are for other things I havn't looked into) because of the use of this idiom. I'm not sugguesting it must be changed, but now that I understand what's going on, it seems *correct* that this throws a warning. 'retval' is assigned a value, in this case, NULL, and there is no path of execution where it's even remotely possible for that NULL to be used... so its a wasted operation. Why? Because retval is never actually used until it is assigned to later on. --- snip --- (from arraymodule, btw :)) static PyObject * array_buffer_info(arrayobject *self, PyObject *args) { PyObject* retval = NULL; if (!PyArg_ParseTuple(args, ":buffer_info")) return NULL; retval = PyTuple_New(2); if (!retval) return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size))); return retval; } --- snip --- --Stephen (replace 'nospam' with 'seraph' to respond in email) "Fredrik Lundh" wrote in message news:nlXE6.9158$4N4.2042457 at newsc.telia.net... > Stephen Hansen wrote: > > It explains the infinate spam of warning messages I get, though, > > since quite a few pointers are initialized to NULL and that NULL is > > never read in. This is not something I think the Gods'o'Python > > would care to have fixed, though. Dispite a 'no warnings' policy :) > > other compilers complain about possible "use before assignment" if > you don't initialize them to NULL... > > Cheers /F > > From neal at metaslash.com Thu Apr 12 00:26:06 2001 From: neal at metaslash.com (Neal Norwitz) Date: Thu, 12 Apr 2001 00:26:06 -0400 Subject: PyChecker - a python source code bug finder References: <3ACFF0CA.6E284971@nonospammytheworld.com> Message-ID: <3AD52E5E.A9C7AD01@metaslash.com> Robin Becker wrote: > > I get some oddities > > 1) I see messages like this > c:\python\reportlab\graphics\charts\axes.py:588 Base class > (reportlab.graphics.charts.axes.ValueAxis) __init__() not called There was a bug in 0.1 that caused this to happen. This is handled better in 0.2 (current released version). I'm not positive it works in all cases, but it is definitely better than before. Better yet, get the current version from CVS. There are more warnings (at least one I know of, unused local variables) that can be generated and there are now command line options. Here are the current options that can be specified on the command line: Options: Toggle warning for ... [default] -s, --doc turn off all warnings for no doc strings -m, --moduledoc no module doc strings [on] -c, --classdoc no class doc strings [on] -f, --funcdoc no function/method doc strings [off] -i, --import unused imports [on] -l, --local unused local variables, except tuples [on] -t, --tuple all unused local variables, including tuples [off] -v, --var all unused module variables [off] -p, --privatevar unused private module variables [on] -d, --debug turn on debugging for checker [off] In addition, you should be able to specify python module/package names or file names (thanks to Jeff Collins). This should help Mac users, I believe. > Still it seems quite useful. Can it do anything with unnecessary > > from M import * It doesn't by default, but if you use the -v option, it does. Neal > -- > Robin Becker From Jason.Tishler at dothill.com Tue Apr 17 15:12:19 2001 From: Jason.Tishler at dothill.com (Jason Tishler) Date: Tue, 17 Apr 2001 15:12:19 -0400 Subject: Cygwin Python Distribution (was ANNOUNCE: Python 2.1 final release) In-Reply-To: <200104171429.JAA23792@cj20424-a.reston1.va.home.com>; from guido@digicool.com on Tue, Apr 17, 2001 at 09:29:44AM -0500 References: <200104171429.JAA23792@cj20424-a.reston1.va.home.com> Message-ID: <20010417151219.T275@dothill.com> On Tue, Apr 17, 2001 at 09:29:44AM -0500, Guido van Rossum wrote: > - ports to several new platforms, including Cygwin and RISCOS I have contributed Python to the standard Cygwin distribution. Cygwin Python is located in the contrib/python directory on the Cygwin mirrors. Cygwin's setup.exe will automatically install Cygwin Python the next time one installs or updates from a mirror. If interested, see the following for a copy of the announcement: http://www.cygwin.com/ml/cygwin/2001-04/msg01074.html I kindly request that people post to python-list at python.org or cygwin at sources.redhat.com as appropriate instead of emailing me directly. Thanks, Jason -- Jason Tishler Director, Software Engineering Phone: +1 (732) 264-8770 x235 Dot Hill Systems Corp. Fax: +1 (732) 264-8798 82 Bethany Road, Suite 7 Email: Jason.Tishler at dothill.com Hazlet, NJ 07730 USA WWW: http://www.dothill.com From sheila at spamcop.net Thu Apr 5 20:57:56 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 06 Apr 2001 00:57:56 GMT Subject: looking for command-pipe performance advice References: Message-ID: On 5 Apr 2001 23:45:12 -0000, jason-dated-af27661e5bfe243d at mastaler.com wrote in comp.lang.python in article : :Can anyone suggest a more efficient, and/or higher performance method :of reading in a mail message as standard input, and then feeding the :message to a command pipe (qmail in my case). : :I do need to examine the mail headers, but don't need to look at the :message body at all. : :Here is what I'm doing currently: Why do you need the cStringIO module/objects? I do something similar with my email, and don't use that at all. :-------------------------------------------------------------------- : :import os, rfc822, cStringIO : :raw_message = sys.stdin.read() :message = cStringIO.StringIO(raw_message) :headers = rfc822.Message(message) : :# header examination and processing deleted : :inject_message = os.popen('/var/qmail/bin/qmail-inject','w') :inject_message.write(raw_message) :inject_message.close() : :-------------------------------------------------------------------- Couldn't you just do this? headers = rfc822.Message(sys.stdin, 0) # header examination # inject_message = os.popen('/var/qmail/bin/qmail-inject', 'w') inject_message.write(headers+'\n') inject_message.write(sys.stdin.read()) inject_message.close() It saves on importing the cStingIO module, and you only have to work with the body once, fewer variable assignments. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From 045521104 at telia.com Mon Apr 23 13:56:41 2001 From: 045521104 at telia.com (Martin Johansson) Date: Mon, 23 Apr 2001 17:56:41 GMT Subject: Homepages Message-ID: Hi! I have a program that will take down a homepage and it works. But I want the program to take down all the pages that are listed and linked at one page. Anyone have a great tip? /Martin From matt at mondoinfo.com Mon Apr 30 22:42:27 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 01 May 2001 02:42:27 GMT Subject: Help closing seconds Tkinter window References: <3aeddfc5@news.advancenet.net> Message-ID: On Mon, 30 Apr 2001 17:08:24 -0500, Rob Eden wrote: > I have two windows in my application: one is the "main" winodw >and is always present, so it's using the default window. The second >window is only available sometimes, so I'm using a Toplevel. The >second window can disappear for two reasons: 1) the user clicks a >button (this part's easy) or 2) after a timeout. This does not seem >to be easy. Hm. It should be. > I've tried using destroy(), but it just seems to ignore it. I've >tried using withdraw(), but that hangs. So, being a Java programmer, >I figured that maybe the GUI thread needs to call this method. The >only way I could see that I thought might do this is the "after()" >method... but that also hnags when called. Since there's no good >documentation for that method that I've found (if it exists, please >point me!), I'm not really sure that that's even what that method >does. The best documentation for Tkinter than I know of is Fredrik Lundh's excellent An Introduction to Tkinter: http://www.pythonware.com/library/tkinter/introduction/index.htm after() is described at (wrapped for line length): http://www.pythonware.com/library/tkinter/ introduction/x9129-alarm-handlers-and-other.htm It's a little hard to tell just what the problem you're having is. If destroy is being ignored something odd is surely up. I'll append an example that may help. If it doesn't, can you post a minimum example that fails? Regards, Matt from Tkinter import * class mainWin: def __init__(self,root): self.root=root b=Button(self.root,text="foo",command=self.otherWin) b.pack() return None def otherWin(self): t=Toplevel() l=Label(t,text="bar") l.pack() self.root.after(5000,t.destroy) return None def main(): root=Tk() mainWin(root) root.mainloop() return None if __name__=="__main__": main() From gloonie at netscape.net Thu Apr 5 22:15:55 2001 From: gloonie at netscape.net (Glenn R. Williams) Date: Thu, 05 Apr 2001 22:15:55 -0400 Subject: Redhat 7.0 and Python 2.0 - SUCCESS References: <3ACA74EA.AA62D45A@netscape.net> Message-ID: <3ACD26DB.D03C098B@netscape.net> Hi All, I tried Sean's suggestion for installing Python 2.1b on Redhat 7.0 Linux, and so far so good! A few minor adjustments were needed, but I can now start control-panel and ximian red-carpet. Summary: 1. The dependencies listed were as follows: failed dependencies: python = 1.5.2 is needed by python-tools-1.5.2-27 python = 1.5.2 is needed by tkinter-1.5.2-27 python = 1.5.2 is needed by python-devel-1.5.2-27 /usr/bin/python is needed by kernelcfg-0.6-9 /usr/bin/python is needed by netcfg-2.36-1 /usr/bin/python is needed by up2date-2.1.7-1 /usr/bin/python is needed by rhn_register-1.0-7 /usr/bin/python is needed by postgresql-python-7.0.2-17 /usr/bin/python is needed by xinetd-2.1.8.9pre11-1 /usr/bin/python is needed by anaconda-7.0.1-6 /usr/bin/python is needed by rpmlint-0.14-4 /usr/bin/python is needed by rhn_register-gnome-1.0-7 /usr/bin/python is needed by up2date-gnome-2.1.7-1 2. I downloaded Sean's SRPM, and did a rpm -bb on the spec file. 3. I went into the /usr/src/redhat/BUILD/Python-2.1b2/Modules and uncommented the line #crypt cryptmodule.c # -lcrypt # crypt(3); to: crypt cryptmodule.c -lcrypt # crypt(3); 4. I did a make install from /usr/src/redhat/BUILD/Python-2.1b2. This placed the crypto module in the lib-dynload library. 5. Just to update the rpm db, I then did rpm -Uvv on the binary. Since I had already installed crypt, this just completed the rest of the settings. 6. When I first ran Redhat's control-panel, I got an error on two statements in redhat modules: In /usr/lib/rhs/python/rhentry.py and /usr/lib/rhs/python/PasswordCrypt.py, change 'import rand' to 'import random'. 7. Two references to regex and regsub were listed as deprecated, but worked. 8. One final note: I had to use --nodeps on the rpm option when installing the rpm binary I created to override the first three message. Many thanks to Sean for his suggestions. I will post any new troubles, should any arise. Glenn Sean Reifschneider wrote: > > On Tue, Apr 03, 2001 at 09:12:10PM -0400, Glenn R. Williams wrote: > >I am having trouble using Python 2.0. Redhat 7.0 system configuration > >programs like control-panel are written in Python (which is good), but > >their cryptographic module in lib-dynlink doesn't work with Python 2.0. > >Has ayone else experienced this problem? > > Seems like you need to enable the "crypt" module when building Python. > Alternatively you might want to try my 2.0 SRPM from > ftp://ftp.tummy.com/pub/tummy/RPMS/SRPMS -- install it and comment out the > line in "/usr/src/redhad/SPECS/python-2.0.spec" for "binsuffix", then do > "rpm -ba /usr/src/redhad/SPECS/python-2.0.spec" to build the binary RPM. > > Sean > -- > A ship in port is safe, but that is not what ships are for. > -- Rear Admiral Grace Murray Hopper > Sean Reifschneider, Inimitably Superfluous > tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python -- Glenn R. Williams Director, Special Projects RSG Systems, Inc. From rcameszREMOVETHIS at dds.removethistoo.nl Fri Apr 13 11:31:23 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Fri, 13 Apr 2001 15:31:23 GMT Subject: why does activestate (win98) python not support globbing References: <9b4of1$j16$1@bmerhc5e.ca.nortel.com> Message-ID: Steve Holden wrote: >"Fredrik Lundh" wrote ... >> Paul Prescodwrote: >>> It's simply Windows versus Unix. On Unix the *shell* does >>> globbing. The program never sees the unexpanded filename. On >>> Windows, the application must do globbing (if it wants to). >> >> to be precise, it's a linking issue. to get globbing behaviour, >> just link the executable with setargv.obj (provided with visual >> C). >> >> for some reason, GvR didn't want this as a default. cannot recall >> his arguments, though... >> >Seems sensible since it's not the platform default for other command >line programs? Nasty to have to glob wildcards, but consistent with >the DOS heritage. Why nasty? This is one instance were I think UNIX has got it wrong. It's much better to leave commandline parameters alone than to try and interpret them in a particular way. Explicit is better than implicit. Robert Amesz From michael at stroeder.com Sun Apr 15 20:12:19 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 16 Apr 2001 02:12:19 +0200 Subject: 2.1 and SocketServer.py Message-ID: <3ADA38E3.F0CE12D9@stroeder.com> HI! I derived my own HTTP server from SocketServer.TCPServer and defined a multi-threaded variant in an own class (mainly for own exception logging, see code below). This used to work in Python 2.0 but not in Python 2.1. I understand that there's a new base class SocketServer.BaseServer but I couldn't figure out how that affects my stuff. After the main thread is stopped I get the following exception: Traceback (most recent call last): File "/home/michael/Proj/python/ldap/web2ldap/pylib/msHTTPServer.py", line 79, in run apply(self._func,(self._request,self._client_address)) File "/usr/lib/python2.1/SocketServer.py", line 246, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.1/SocketServer.py", line 494, in __init__ self.setup() File "/usr/lib/python2.1/SocketServer.py", line 537, in setup self.rfile = self.connection.makefile('rb', self.rbufsize) error: (9, 'Ung\xfcltiger Dateideskriptor') Any clue? Ciao, Michael. ------------------------------------------------------------------------ class MyHTTPServer(SocketServer.TCPServer): def __init__(self, server_address, RequestHandlerClass): self.access_log = sys.stdout self.error_log = sys.stderr SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass) def server_bind(self): """Override server_bind to set socket options.""" self.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) SocketServer.TCPServer.server_bind(self) def handle_error(self,request,client_address): """ Generic low-level handler for exceptions """ import traceback exc_obj,exc_value,exc_traceback = sys.exc_info() print 'Time: %s\nClient address: %s:%d' % ( time.strftime( '%Y-%m-%dT%H:%M:%SZ',time.gmtime(time.time()) ), client_address[0],client_address[1], ) if isinstance(exc_value,KeyboardInterrupt): raise KeyboardInterrupt elif isinstance(exc_value,IOError) and exc_value.errno==32: print 'IOError %s: User interrupted connection.' % ( repr(exc_value.errno) ) else: traceback.print_exception(exc_obj,exc_value,exc_traceback) print '-'*66 try: import threading except ImportError: MyThreadingHTTPServer = MyHTTPServer else: class MyHTTPThread(threading.Thread): """Thread class for HTTP handler thread""" def __init__(self,func,request,client_address,handle_error): self._func=func self._request=request self._client_address=client_address self._handle_error=handle_error threading.Thread.__init__(self) def run(self): try: apply(self._func,(self._request,self._client_address)) except: apply(self._handle_error,(self._request,self._client_address)) class MyThreadingHTTPServer(MyHTTPServer): def process_request(self, request, client_address): """Start a new thread to process the request.""" t = MyHTTPThread( self.finish_request,request,client_address,self.handle_error ) t.start() From warren-postma at home.com Fri Apr 27 16:15:40 2001 From: warren-postma at home.com (Warren Postma) Date: Fri, 27 Apr 2001 20:15:40 GMT Subject: G3 AllInOne on Ebay Message-ID: Hi. Two quick questions: 1. Will you ship to Canada if I win this auction? 2. The picture looks like you have a floppy and a zip drive, do you have both, or just a floppy? Warren From bsass at freenet.edmonton.ab.ca Wed Apr 4 13:37:25 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 4 Apr 2001 11:37:25 -0600 (MDT) Subject: def () syntax ? In-Reply-To: <20010404.095211.716334471.21458@mead.troikanetworks.com> Message-ID: On Wed, 4 Apr 2001, Bruce Edge wrote: > Can the follwoing be accomplished in Python? > > I want to create a func named "abc": > > >>> name="abc" > > >>> eval ("name") > 'abc' > > >>> def eval ("name") (): > File "", line 1 > def eval ("name") (): > ^ > SyntaxError: invalid syntax >>> def hi(): ... print "Hi!" ... >>> a = hi >>> eval("hi()") Hi! >>> eval("a()") Hi! >>> - Bruce From stephen_purcell at yahoo.com Thu Apr 12 08:42:36 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 12 Apr 2001 14:42:36 +0200 Subject: #define python-list@python.org '#define' In-Reply-To: <20010412144018.A14948@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Thu, Apr 12, 2001 at 02:40:18PM +0200 References: <01041208054801.01378@tos1.ralphpill.com> <20010412144018.A14948@freedom.puma-ag.com> Message-ID: <20010412144236.B14948@freedom.puma-ag.com> > > Does Python have an equivalent to C's #define? Looks like I need a preprocessor to help me write my mails correctly... -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From tim at worthy.demon.co.uk Sun Apr 22 07:56:40 2001 From: tim at worthy.demon.co.uk (Tim Howarth) Date: Sun, 22 Apr 2001 12:56:40 +0100 Subject: NTFS permissions Message-ID: <1e232f6f4a%tim@worthy.demon.co.uk> Having serached Google I've found a couple of queries about this but no easy solutions. Has anyone wrapped up the various win32 file/security calls to give simple access to setting NTFS file permissions ? Whilst trying to work out how to do this I found that there is a Perl (hiss) module (or whatever they are called) "Win32 Perms" which does this. I've started from the sample in Mark Hammond/Andy Robinson's Python Win32 book in "batchusercreate" where he sets access permissions on a share but I want to set the permissions on the actual directory. Cutting it back as far as I can for testing, trying simply to copy a security descriptor; import win32security sd=win32security.GetFileSecurity('g:\\TestACL\\aaa.txt',win32security. DACL_SECURITY_INFORMATION) win32security.SetFileSecurity('g:\\TestACL\\bbb.txt',win32security. DACL_SECURITY_INFORMATION,sd) results in an error message "the data area passed to a system call is too small" but the permissions are copied. Using batchusercreate as a model to create a new DACL and apply that to a directory results in the usernames being applied but access not set. Applying to a file does set access permissions but both attempts result in an error message with a helpful message - "No error message available". Anyone know what's wrong with the above, or better still, got a simplified wrapper around the various API calls, (in fact I don't think win32 has all that might be needed - e.g. GetSecurityDescriptorDACL to handle all requirements). The only reason for wanting to do this is some simple web browser based user management, without the need to resort to - os.system("echo y| cacls....). -- ___ |im ---- ARM Powered ---- From neal at metaslash.com Sun Apr 15 03:38:34 2001 From: neal at metaslash.com (Neal Norwitz) Date: Sun, 15 Apr 2001 03:38:34 -0400 Subject: Python 2.1 RC - PyChecker References: Message-ID: <3AD94FFA.7D930EF0@metaslash.com> I've run the CVS version of PyChecker (http://pychecker.sourceforge.net) against Python 2.1 RC1. Below are the real or possible problems I found. Some of the "not used" could be real errors, most are not. All "uses named arguments" can be safely ignored. "No global"s are definitely problems AFAICT (except 1 which can't be reached). Neal -- MimeWriter.py:108 Function (addheader) uses named arguments MimeWriter.py:117 Function (startbody) uses named arguments StringIO.py:187 Local variable (here) not used UserString.py:137 Base class (UserString.UserString) __init__() not called aifc.py:181 Local variable (math) not used asynchat.py:99 No method (collect_incoming_data) found asynchat.py:112 No method (found_terminator) found (2 methods documented, but should add method and raise exception?) asyncore.py:155 Local variable (l) not used audiodev.py:214 No global (BUFFERSIZE) found bdb.py:220 Local variable (bp) not used cgi.py:743 Base class (UserDict.UserDict) __init__() not called cgi.py:843 Local variable (traceback) not used chunk.py:109 No attribute (chunk_size) found (should be chunksize) fileinput.py:292 Function (input) uses named arguments getpass.py:29 Local variable (getpass) not used gopherlib.py:172 Local variable (port) not used gzip.py:276 Local variable (orig_size) not used ihooks.py:494 Function (import_it) uses named arguments ihooks.py:498 Function (import_it) uses named arguments imaplib.py:1019 No global (j) found locale.py:273 No global (l) found (can't be reach, but could remove last else and always raise error) mailbox.py:21 No attribute (stop) found mailbox.py:23 No attribute (start) found mailbox.py:29 No method (_search_start) found mailbox.py:34 No method (_search_end) found (_search_*() used in subclasses, add method and raise exception?) mailbox.py:106 No method (_isrealfromline) found mailbox.py:260 Local variable (time) not used mhlib.py:651 Local variable (messages) not used netrc.py:13 No global (file) found (should be filename) nturl2path.py:45 Local variable (string) not used pstats.py:188 Local variable (std_list) not used pyclbr.py:206 Local variable (imports) not used pydoc.py:170 Base class (exceptions.Exception) __init__() not called rfc822.py:607 Local variable (expectaddrspec) not used robotparser.py:234 Local variable (sys) not used sgmllib.py:178 No global (SGMLParserError) found (should be SGMLParseError?) shlex.py:99 Local variable (tok) not used smtpd.py:312 No global (UnimplementedError) found smtpd.py:375 Local variable (paths) not used sndhdr.py:87 Local variable (hdr_size) not used sndhdr.py:134 Local variable (style) not used sre_parse.py:286 Local variable (here) not used threading.py:547 Local variable (random) not used threading.py:611 Local variable (time) not used token.py:85 Local variable (string) not used unittest.py:675 Local variable (opts) not used urllib.py:1147 Local variable (x) not used urllib2.py:450 No global (error_302_dict) found (needs req.?) urllib2.py:630 No attribute (parent) found urllib2.py:1053 No global (OpenerDirectory) found urlparse.py:58 Local variable (path) not used webbrowser.py:77 No global (ret) found From Dan.Rolander at marriott.com Wed Apr 25 11:00:15 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Wed, 25 Apr 2001 11:00:15 -0400 Subject: Help please, IBM Python users???? Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF652F@mcnc-mdm1-ex01> I subscribe to IBM's developerWorks newsletter, which often has Python articles in it. If you go to http://www.ibm.com/developerworks and do a search for Python you'll currently find 71 hits. Dan -----Original Message----- From: Ron Stephens [mailto:rdsteph at earthlink.net] Sent: Sunday, April 22, 2001 7:51 PM To: python-list at python.org Subject: Help please, IBM Python users???? Yes, I recall reading somewhere about extensive involvement of IBM folks in using Python and in even contributing to the Python community. Unfortunately, having been on a reading binge about Python the last month, and having a poor memory, leaves me unable to say where I read this, on the web or in a book or magazine even ;-)) But since it would help a newsgroup reader possibly convince company management to use Python, I am hoping someone online here can help with a reference. Any IBM folks out there??? Ron Stephens http://www.awaretek.com/python -- http://mail.python.org/mailman/listinfo/python-list From nessus at mit.edu Wed Apr 11 18:54:03 2001 From: nessus at mit.edu (Douglas Alan) Date: 11 Apr 2001 18:54:03 -0400 Subject: other python ideas References: <9atmor$dji$2@nntp9.atl.mindspring.net> <9au0pp$rua$1@slb7.atl.mindspring.net> Message-ID: Nonexistence writes: > > Douglas Alan: > > > Unfortunately, the Common Lisp module system is unbearably > > > complex. > For most purposes, all you need to know about Common Lisp's module > (package) system are DEFPACKAGE, IN-PACKAGE, and the ":" "::" > referencing convention; I can't see how that is more complex than > what is available in Python. I've been told by someone who claims to know that a full 50% of bugs that turned up in a popular CommonLisp implementation were in the package system. If that doesn't imply that it is too complex, I don't know what would. The module system in Python is very simple by anyone's standards. I've also tried on occassion to wade through the Lisp Machine package system specs. It is not easy going. This is not to say that the CommonLisp package system doesn't provide some great benefits. It does. It's just that you pay heavily for those benefits. It might be nice to think about if it's possible to get most of the benefit without as much of the cost. |>oug From yann.cointepas at chups.jussieu.fr Fri Apr 27 11:54:22 2001 From: yann.cointepas at chups.jussieu.fr (Yann Cointepas) Date: Fri, 27 Apr 2001 15:54:22 +0000 Subject: Thread interruption Message-ID: <9cbtnn$o7p$1@vishnu.jussieu.fr> Is there any portable ( Unix and Windows) way to interrupt a thread ? I made a program that is a graphical environment that is used to launch user Python scripts. Each user script is executed in its own thread "within" a common graphical environment provided by the main program. I would like to allow the user to kill a script but I found no clean and portable way to interrupt a thread from another thread. Is it possible ? Will it be possible ? At least I realy need to interrupt a thread on Unix, can I safely use Python threads and a C extension module which uses libpthread ? Thanks for any hint. -- Yann Cointepas Tel: +33 1 53 82 84 14 INSERM U494 - CHU Piti?-Salp?tri?re Fax: +33 1 53 82 84 48 91 Boulevard de l'H?pital 75634 PARIS CEDEX 13 France From mal at lemburg.com Tue Apr 3 10:49:27 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 03 Apr 2001 16:49:27 +0200 Subject: ANN: eGenix.com mxODBC Database Interface Version 2.0.1 Message-ID: <3AC9E2F7.788FDA9@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mxODBC Database Package for Python Version 2.0.1 Full Source Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ?: The eGenix.com mxODBC Database Package for Python is part of the eGenix.com mx Extension Series for Python, a collection of professional quality software tools which enhance Python's usability in many important areas such as ODBC database connectivity, fast text processing, date/time processing and web site programming. ________________________________________________________________________ WHAT'S NEW ? This patch release fixes a few problems which were found by users on Windows platforms: * Execution of SQL commands lead to a hanging Python processes for some users. * Handling of date/time values resulted in exceptions on some Windows configurations. Due to popular demand, I am now also providing precompiled Windows binaries for the older Python 1.5.2 version. Binaries for Python 2.1 will be announced after its final release. ________________________________________________________________________ SPECIAL OFFER theKompany.com has licensed the eGenix.com mx Commercial Package (which includes mxODBC) for inclusion in their brand new Qt-based Python IDE BlackAdder. It allows developing portable GUI-based database applications which run on Windows and Linux platforms without any change to the source code. BlackAdder includes a 1 CPU license for this package at no extra cost, so you may want to check out their great new product. See http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#BlackAdder for details. ________________________________________________________________________ EGENIX.COM MX COMMERCIAL PACKAGE OVERVIEW: mxODBC - Generic ODBC 2.0-3.5 interface for Python mxODBC is an extension package that provides a Python Database API compliant interface to ODBC capable database drivers and managers. In addition to the capabilities provided through the standard DB API it also gives access to a rich set of catalog methods which allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce (other in/output formats are available too). mxODBC allows you to interface to more than one database from one process, making inter-database interfacing very flexible and reliable. The source version includes a varity of preconfigured setups for many commonly used databases such as MySQL, Oracle, Informix, Solid, SAP DB, Sybase ASA and ASE, DBMaker and many more. The precompiled versions for Windows and Linux include the interfaces to the standard ODBC manager on these platforms to allow for a more easily configurable setup. More details are available at: http://www.lemburg.com/files/python/mxODBC.html ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ Note that in order to use mxODBC you will also need to install the eGenix.com mx BASE package which can be downloaded from the same location. ________________________________________________________________________ WHAT DOES IT COST ? mxODBC comes with a licenses which allows non-commercial use at no charge, but costs a moderate fee for commercial use. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxCOMMERCIAL for details. The package comes with full source code. ________________________________________________________________________ WHERE CAN I GET SUPPORT ? Commercial quality support for these packages is available from eGenix.com Software GmbH. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Support for details about the eGenix support offerings. ________________________________________________________________________ REFERENCE:

eGenix.com mxODBC Package - eGenix.com mxODBC Database Interface 2.0.1 with distutils support and precompiled binaries for Windows and Linux. (31-Mar-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From kalle at gnupung.net Sun Apr 1 21:44:32 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Mon, 2 Apr 2001 03:44:32 +0200 Subject: I want to learn PYTHON! In-Reply-To: ; from kapblp@bellsouth.nOt on Sun, Apr 01, 2001 at 08:42:48PM -0400 References: <1iqx6.3744$aD4.234302@news2.atl> <3AC6714F.F3EAC690@yahoo.com> Message-ID: <20010402034432.C6450@apone.network.loc> Sez KEVIN: > Second, why not 2.1? Because it isn't out of beta, which means there could be stability problems. Better to play it safe. That way, if you encounter problems, at least it's not likely to be something nobody knew about before. > "Steve" wrote in message > news:3AC6714F.F3EAC690 at yahoo.com... > > Step one: > > Go to http://www.python.org and download Python version 2.0 for Windows. [snip] Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From phrxy at csv.warwick.ac.uk Wed Apr 11 17:23:33 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 11 Apr 2001 22:23:33 +0100 Subject: linux & users' python-extensions In-Reply-To: References: <9at1bd0107b@news1.newsguy.com> Message-ID: On 11 Apr 2001, [iso-8859-2] Pawe? Sto?owski wrote: [...] > OK, I've this: > PYTHONPATH=~/lib/python2.0:/usr/local/lib/python2.0 > PYTHONHOME=~ > > Now, when I put spam.py in ~/lib/python2.0, it works. But what should I > do to make visible an extension module to the system (without cluttering > global configuration)?. There are some Setup.* files in > /usr/local/lib/python2.0/config/ (main python files) that list > dependencies beetwen .py and extension modules; do I have to make a copy > of it in my home dir and add my module there? I've tried to do so, but > nothing happened. Did i miss something? Don't have a copy here to check, but if those 'Setup.*' files are setup.py scripts, then no, you don't have to copy them anywhere -- see the Distutils docs in the standard distribution of Python. If they're something else, that I know not about, wait for somebody else to answer the question. :) You don't need to copy them anywhere to make your modules visible, though. For an extension module to be visible, it just has to be in sys.path. /usr/local/lib/python2.0/site-packages should already be in there (IIRC that's set in site.py). One way of adding paths to sys.path is to put a foo.pth file in, now, is it /usr/local/lib/python2.0, or /usr/local/lib/python2.0/site-packages, or either? I've been using windows for a while, can't remember. The contents of foo.pth should be a relative directory path that you want to add to sys.path. For full details, try Guido's essay about the 'new' module import system, on http://www.python.org/ somewhere in the docs section. Otherwise, just get your users (or yourself) to add directories to PYTHONPATH in whatever shell scripts are appropriate. John From webbmaster at mindspring.com Fri Apr 6 10:41:22 2001 From: webbmaster at mindspring.com (John Yeager) Date: Fri, 06 Apr 2001 19:41:22 +0500 Subject: Which happens first? Message-ID: I know that this may be a dumb questio, yet I am new to programming and I am courious in a mathmatical expression such as ( 16 * ( 15j + ( 4.2 - 3.9 ) + 20 ) / -2 ) % 5 which happens first is the () or is it the conversion to the complex number?? I would think it would be the () From James_Althoff at i2.com Mon Apr 23 16:48:07 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 23 Apr 2001 13:48:07 -0700 Subject: Named code blockes Message-ID: I agree with you that embedded functions -- supported by the new nested_scopes feature -- helps a lot. I still think the nameless block approach is more readable than the named function approach -- in this case mainly because nested functions make the code a bit more confusing at first glance. (I've seen inexperienced programmers have their minds boggled by the notion of defining a function inside of a function.) But, this could just be a matter of preference on my part. Besides, I like the Smalltalk syntax (being highly prejudiced in this regard due to having been part of the gang that devised it in the first place -- having said that, however, I do like the Python indentation-based syntax even better). Jim wrote in message > Now suppose the call to collection.do(xxx) is in the middle of a > very long class def. Then I have to put the doThisAndDoThatToItem > def before the class or after the class thereby separating the definition > from its one and only use by possibly hundreds of lines of > code. This is not nice for readability. With the advent of nested_scopes, I believe you can accomplish this by just embedding a 'def' in either the __init__ or the collection.do function, making your code as readable as that smalltalk code was. :) For instance: class Dummy: def __init__(self, collection): def DoThisAndDoThatToItem(item): item.DoThis() item.DoThat() collection.do(DoThisAndDoThatToItem) Now. Is that readable? Its 'eh', but its far more readable then the Smalltalkism of 'named code blocks', and it doesn't seperate that function def from its one and only use, which is your other problem. --S (replace 'NOSPAM' with 'seraph' to respond in email) -- http://mail.python.org/mailman/listinfo/python-list From hgg9140 at cola.ca.boeing.com Tue Apr 24 14:30:22 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Tue, 24 Apr 2001 18:30:22 GMT Subject: getting Gadfly data into a list References: Message-ID: Does it support "fetchall:? cursor.execute('select * from MyTable') rows=cursor.fetchall() for row in rows: #do something to the individual tuple If so, that generally returns a list of tuples. Lee Joramo writes: > I have set up a small database using gadfly. Is there a way to directly pull > query results into a list? Currently the only way that I have found to > access the data is by using "cursor.pp()". But this displays a nicely > formatted table that is difficult to use for anything. > > For example, I have the following: > > >>>cursor.execute('select * from MyTable') > >>>print cursor.pp() > > MY_INTEGER | MY_FLOAT | MY_STRING > ================================== > 1 | 3.13 | abc > 2 | 5.23425 | 345 > 3 | 10.23423 | green frog > > I would like to do something like: > > >>>a = cursor.LIST_RESULTS() > >>>print a > [[1, 3.13, 'abc'], [2, 5.23425, "abc"], [3, 10.23423, "green frog"]] > > > TIA, > > Lee Joramo > lee.list at joramo.com > -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From grante at visi.com Thu Apr 12 11:20:08 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 12 Apr 2001 15:20:08 GMT Subject: #define... References: Message-ID: In article , Vincent A. Primavera wrote: > Does Python have an equivalent to C's #define? No. Of course you can run files throught cpp or m4 -- if you really want to use a pre-processor, you can. -- Grant Edwards grante Yow! There's a lot of BIG at MONEY in MISERY if you have visi.com an AGENT!! From greg at cosc.canterbury.ac.nz Mon Apr 2 22:10:16 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 03 Apr 2001 14:10:16 +1200 Subject: list tuple vs Re: References: <62Mx6.1152$p5.4531@news1.rivrw1.nsw.optushome.com.au> Message-ID: <3AC93108.356CBFB6@cosc.canterbury.ac.nz> William Tanksley wrote: > > Always doing things backwards, Forth programmers are. Ah, that explains it -- Yoda grew up in a household of Forth programmers! Oops, sorry, I mean household programmers Forth of in Yoda up grew. -- Ewing Greg, Dept Science Computer, University Canterbury of, Churchchrist, Zealand New. Address email my to get, page web my visit please: greg~\nz.ac.canterbury.cosc.www\:http From danielk at aracnet.com Sat Apr 21 23:30:09 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 21 Apr 2001 20:30:09 -0700 Subject: A list of Python users? Message-ID: Is there a published list of Python users? People ask me all the time 'Who uses it?". I've search Google Groups and found a few names mentioned but I'm looking for more. Thanks, Daniel Klein Portland OR From mda at idatar.com Mon Apr 2 19:51:30 2001 From: mda at idatar.com (David Allen) Date: Mon, 02 Apr 2001 23:51:30 GMT Subject: A couple garbage collector questions References: Message-ID: <6g8y6.248$jL4.262638@typhoon1.ba-dsg.net> In article , "Douglas Alan" wrote: > I have a couple of questions regarding the new Python garbage collector: > > (1) Why does it use the rather unusual algorithm it does, rather > than a more typical mark and sweep? The per-object storage cost for > the extra reference count is surely greater than the bit or two > required for a typical mark and sweep. I'm not positive, but I think it's for simplicity. Frankly, I'm a bit confused as to why everybody and their brother seems to want to implement reference count based garbage collectors when better has been available through languages like LISP for years. I do know for a fact though that reference counting is a lot easier than other forms of GC. It does tend to get tricked by circular references. I'm not sure if this is an issue in python, but I believe it still is in perl. In perl you can have two variables which merely refer to each other that will never get GC'd because their reference count will always be > 0. I plead ignorance on most GC issues - I'm hoping somebody will jump in and let us know The Official Reason(TM). That, and why software today isn't using years of research on GC techniques to its advantage. I'd crosspost this to comp.lang.lisp if I didn't know it would generate flamage. -- David Allen http://opop.nols.com/ ---------------------------------------- Great minds run in great circles. From jkraska1 at san.rr.com Sun Apr 22 12:25:56 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 22 Apr 2001 16:25:56 GMT Subject: Python Interpreter Reentrancy? References: <9buuql$oki$1@panix3.panix.com> Message-ID: >I'm not quite sure what you're asking for. It's certainly the case that >multiple threads in a C application can call Python code, but each time >you call into Python, you need to acquire the GIL first (along with first >making sure that you've done all the proper initialization). I'm asking for a reentrant Python interpreter -- one in which a global interpreter lock isn't necessary. Clearly that's not around yet. C// From be at mek.dtu.dk Mon Apr 2 03:25:29 2001 From: be at mek.dtu.dk (Brian Elmegaard) Date: Mon, 02 Apr 2001 09:25:29 +0200 Subject: right-justifying menus in tkinter Message-ID: <3AC82969.CE740E53@mek.dtu.dk> Hi, in pmw there is a side option for the menus in a menubar. I can't find something similar for lain tkinter. How can I put a help menu to the right? -- Brian http://www.et.dtu.dk/energysystems http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From greg at electricrain.com Wed Apr 11 15:42:51 2001 From: greg at electricrain.com (Gregory P. Smith) Date: Wed, 11 Apr 2001 12:42:51 -0700 Subject: [ANN] py2exe - version 0.2.5 released In-Reply-To: <20010411113123.A1301@zot.electricrain.com>; from greg@electricrain.com on Wed, Apr 11, 2001 at 11:31:23AM -0700 References: <20010411113123.A1301@zot.electricrain.com> Message-ID: <20010411124251.B12671@zot.electricrain.com> > > py2exe is a distutils extension to convert python scripts into > > standalone windows executables. > > Has anyone successfully packaged a program using the zope > DocumentTemplate module? nevermind. in my simpler test cases just using DocumentTemplate it always packages fine. I think its semething else strange in our software causing DT to fail. -- Gregory P. Smith gnupg/pgp: http://electricrain.com/greg/keys/ C379 1F92 3703 52C9 87C4 BE58 6CDA DB87 105D 9163 From richardt at edshk.demon.co.uk Thu Apr 19 08:43:23 2001 From: richardt at edshk.demon.co.uk (Richard Townsend) Date: Thu, 19 Apr 2001 13:43:23 +0100 Subject: Python 2.1 compile error on HPUX Message-ID: I get the following errors when compiling Python2.1 on HPUX11. cc: "Modules/termios.c", line 529: error 1588: "VREPRINT" undefined. cc: "Modules/termios.c", line 529: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 530: error 1588: "VDISCARD" undefined. cc: "Modules/termios.c", line 530: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 747: error 1588: "MDCD" undefined. cc: "Modules/termios.c", line 747: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 750: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 753: error 1588: "MCTS" undefined. cc: "Modules/termios.c", line 753: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 756: error 1588: "MDSR" undefined. cc: "Modules/termios.c", line 756: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 759: error 1588: "MDTR" undefined. cc: "Modules/termios.c", line 759: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 765: error 1588: "MRI" undefined. cc: "Modules/termios.c", line 765: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 768: error 1521: Incorrect initialization. cc: "Modules/termios.c", line 771: error 1588: "MRTS" undefined. cc: "Modules/termios.c", line 771: error 1521: Incorrect initialization. Can anybody tell me how to fix this problem, please? -- Richard Townsend From tdelaney at avaya.com Sun Apr 29 21:48:53 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 30 Apr 2001 11:48:53 +1000 Subject: With or Using Message-ID: > > One thing I haven't seen yet is when you need to write > > a.b.c().d[4].e.f.g.h().i = 1 > > a.b.c().d[4].e.f.g.h().j = 1 > > a.b.c().d[4].e.f.g.h().k = 1 > > that you could just as well write > > temp = a.b.c().d[4].e.f.g.h() > > temp.i = 1 > > temp.j = 1 > > temp.k = 1 > > or (ugly!) > > for temp in a.b.c().d[4].e.f.g.h(),: > > temp.i = 1 > > temp.j = 1 > > temp.k = 1 > > i.e., store a reference to the same thing the long > expression gives you > > in an easy-to-type place. > > > Of course, augmented assignment was made for situations where > you would like > to avoid writing > > a.b.c().d[4].e.f.g.h().k = a.b.c().d[4].e.f.g.h().k + 1 > > allowing you instead to write > > a.b.c().d[4].e.f.g.h().k += 1 I am of course aware that the above is using silly made-up expressions, but they raise an important point. Both of the above may actually have different semantics. In each case you have a large number of function calls (remember, each class attribute access can be a function call ...). If any one of those calls returns a different object to the previous invocation, the two verions may be semantically different. In this case, binding to a temporary may be the wrong thing to do (or at least less of the expression should be bound to the temporary). If they are *not* semantically different however you can save quite a bit of time by assigning to a temporary variable - if you don't, all of those things need to be evaluated each time. Tim Delaney From Max.Haas at unibas.ch Sun Apr 15 08:17:12 2001 From: Max.Haas at unibas.ch (Max Haas) Date: Sun, 15 Apr 2001 14:17:12 +0200 Subject: Advice for a little search engine Message-ID: Hi all, I tried to implement a little search engine. Python is not the language I know thoroughly and I?ve never written a search engine in any language. That?s why I would like to ask (after having read as many Python documents I could) if the following sketch is somewhat reasonable or if there are basic mistakes. (The program runs but it should be as fast as possible! Hm. Not just a good job for an outsider.) Problem: 738 files with Latin text. Every file represents a singular source. Find every match of a term. (I need e.g. structura, structuram, structurae etc.) To do: Enter a question in form of a regex and look for all occurrences. If there is a match: (a) if it?s the first match then give the contents of the file (in the canonical form of those who prepared the files this is always line 10-15) and then (aa) give every match with (user defined) x words before the match, the matched word, and y words after the match; (b) if there was already a match in this source then do only (aa) The program: 1. Enter the question and x and y. The question will then be the compiled object p. 2. Read every file in (something like fp.readlines()). 3. Transform the file to a string (string.join(list_of_file)). 4. m = p.findall(string). If m is not None then: a. Give the file contents (lines 10-15) b. look for the occurrence of every word in m and note the position (with string.find) c. Give x words before the matched word, the matched word and then y words after ... The main problem for me is: do I understand correctly the function of p.findall(string) in combination with string.find? Many thanks in advance Max From cribeiro at mail.inet.com.br Sun Apr 1 23:22:18 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Mon, 02 Apr 2001 00:22:18 -0300 Subject: PEP 245 In-Reply-To: References: <5.0.2.1.0.20010401125214.02295330@mail.inet.com.br> Message-ID: <5.0.2.1.0.20010402001654.022e3e50@mail.inet.com.br> At 16:29 01/04/01 -0700, Alex Shindich wrote: >I do not want to restart the whole discussion on the difference between >base classes and interfaces, but I am of the opinion that they both >represent an is-a relationship. Almost... base classes represent an "is-a" relationship. Interface implementation represent an "work-as" relatioship (if there is anything like this :-). >Arguably, this behavior is already available through runtime method >binding. That's right. I was just saying that I prefer it to stay this way. >This makes interfaces to be as good as doc strings... In a sense, yes. In a dynamic typed language almost nothing is enforced; there's the language syntax and nothing else. The documentation is the last resort. Readability also helps a lot. If the interface support makes for more readable code, then I'm all for it, if just for this reason. Carlos Ribeiro From kragen at dnaco.net Mon Apr 2 18:35:48 2001 From: kragen at dnaco.net (Kragen Sitaker) Date: Mon, 02 Apr 2001 22:35:48 GMT Subject: excluding unit test code References: <4.3.2.7.2.20010403002042.01afa7e8@202.53.255.51> Message-ID: <897y6.19687$BC6.5596003@e3500-chi1.usenetserver.com> In article , Steve Purcell wrote: >Steven Haryanto wrote: >> Since an XP-faithful coder can write lots of test suites, >> is there a simple way to exclude these code in a module >> from the production code? > >Yes -- put the test code in a separate module to the tested code! > >But consider shipping tests with production code anyway. You never know when >they'll help you track down a problem. My usual practice is to run module unit tests at import time. This helps me laugh at people that tout compile-time checking as a strength of low-level statically-typed languages. Obviously this becomes less desirable as your test suite becomes slower; typically it adds a few milliseconds (often as much as 20%) to the load time of my modules. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From fluxent at yahoo.com Wed Apr 4 13:45:52 2001 From: fluxent at yahoo.com (Bill Seitz) Date: Wed, 4 Apr 2001 10:45:52 -0700 (PDT) Subject: [pythonwin] find() failing? Message-ID: <20010404174552.14744.qmail@web4904.mail.yahoo.com> Getting a weird bug I can't figure out. I'm running Python within IIS. I'm coming from a form with 2 buttons, so they set an input named 'act'. I'm grabbing that parameter, as well as the others, from a dictionary named 'field'. Then I'm deciding which lump of code to run based on the button value. Here's the little snippet of code: act= field['act'] import string if string.find(act, 'reject') > -1: ...... And here's what happens every time: Error Type: Python ActiveX Scripting Engine (0x80020009) Traceback (innermost last): File "

Map information
VariableValue
Name DM-Codex.unr
Title Codex
Author Cliff
...."), "\" value-\"", ""), "\">", "
"), "\" value-\"", ""), "\">", "